From 4881e4ef09a84cfa953e64d22e0e55eea66ba1bc Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 1 Aug 2022 18:24:20 +0200 Subject: [PATCH] Remove Show Advanced, forbid ProgramFiles root folders. --- OtterGui | 2 +- Penumbra/Configuration.cs | 1 - Penumbra/UI/ConfigWindow.CollectionsTab.cs | 2 +- Penumbra/UI/ConfigWindow.EffectiveTab.cs | 5 -- Penumbra/UI/ConfigWindow.ModPanel.Tabs.cs | 31 +++++------ .../UI/ConfigWindow.SettingsTab.Advanced.cs | 8 +-- Penumbra/UI/ConfigWindow.SettingsTab.cs | 52 +++++++------------ 7 files changed, 39 insertions(+), 62 deletions(-) diff --git a/OtterGui b/OtterGui index f137f521..ea6ebcc0 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit f137f521c588472247510a3fd4183bd651477618 +Subproject commit ea6ebcc073412419a051ac73a697980da20233e2 diff --git a/Penumbra/Configuration.cs b/Penumbra/Configuration.cs index 71297304..7f2e7848 100644 --- a/Penumbra/Configuration.cs +++ b/Penumbra/Configuration.cs @@ -59,7 +59,6 @@ public partial class Configuration : IPluginConfiguration public DoubleModifier DeleteModModifier { get; set; } = new(ModifierHotkey.Control, ModifierHotkey.Shift); public bool FixMainWindow { get; set; } = false; - public bool ShowAdvanced { get; set; } public bool AutoDeduplicateOnImport { get; set; } = true; public bool EnableHttpApi { get; set; } = true; diff --git a/Penumbra/UI/ConfigWindow.CollectionsTab.cs b/Penumbra/UI/ConfigWindow.CollectionsTab.cs index 58397133..1299f068 100644 --- a/Penumbra/UI/ConfigWindow.CollectionsTab.cs +++ b/Penumbra/UI/ConfigWindow.CollectionsTab.cs @@ -57,7 +57,7 @@ public partial class ConfigWindow // Only gets drawn when actually relevant. private static void DrawCleanCollectionButton( Vector2 width ) { - if( Penumbra.Config.ShowAdvanced && Penumbra.CollectionManager.Current.HasUnusedSettings ) + if( Penumbra.CollectionManager.Current.HasUnusedSettings ) { ImGui.SameLine(); if( ImGuiUtil.DrawDisabledButton( diff --git a/Penumbra/UI/ConfigWindow.EffectiveTab.cs b/Penumbra/UI/ConfigWindow.EffectiveTab.cs index c45668ca..d096d3ee 100644 --- a/Penumbra/UI/ConfigWindow.EffectiveTab.cs +++ b/Penumbra/UI/ConfigWindow.EffectiveTab.cs @@ -20,11 +20,6 @@ public partial class ConfigWindow // Draw the effective tab if ShowAdvanced is on. public void Draw() { - if( !Penumbra.Config.ShowAdvanced ) - { - return; - } - using var tab = ImRaii.TabItem( "Effective Changes" ); if( !tab ) { diff --git a/Penumbra/UI/ConfigWindow.ModPanel.Tabs.cs b/Penumbra/UI/ConfigWindow.ModPanel.Tabs.cs index 5d9cc3f4..f250035b 100644 --- a/Penumbra/UI/ConfigWindow.ModPanel.Tabs.cs +++ b/Penumbra/UI/ConfigWindow.ModPanel.Tabs.cs @@ -49,31 +49,28 @@ public partial class ConfigWindow | ( _mod.ChangedItems.Count > 0 ? Tabs.ChangedItems : 0 ) | ( _mod.Description.Length > 0 ? Tabs.Description : 0 ) | ( _conflicts.Count > 0 ? Tabs.Conflicts : 0 ) - | ( Penumbra.Config.ShowAdvanced ? Tabs.Edit : 0 ); + | Tabs.Edit; DrawSettingsTab(); DrawDescriptionTab(); DrawChangedItemsTab(); DrawConflictsTab(); DrawEditModTab(); - if( Penumbra.Config.ShowAdvanced ) + if( ImGui.TabItemButton( "Advanced Editing", ImGuiTabItemFlags.Trailing | ImGuiTabItemFlags.NoTooltip ) ) { - if( ImGui.TabItemButton( "Advanced Editing", ImGuiTabItemFlags.Trailing | ImGuiTabItemFlags.NoTooltip ) ) - { - _window.ModEditPopup.ChangeMod( _mod ); - _window.ModEditPopup.ChangeOption( _mod.Default ); - _window.ModEditPopup.IsOpen = true; - } - - ImGuiUtil.HoverTooltip( - "Clicking this will open a new window in which you can\nedit the following things per option for this mod:\n\n" - + "\t\t- file redirections\n" - + "\t\t- file swaps\n" - + "\t\t- metadata manipulations\n" - + "\t\t- model materials\n" - + "\t\t- duplicates\n" - + "\t\t- textures" ); + _window.ModEditPopup.ChangeMod( _mod ); + _window.ModEditPopup.ChangeOption( _mod.Default ); + _window.ModEditPopup.IsOpen = true; } + + ImGuiUtil.HoverTooltip( + "Clicking this will open a new window in which you can\nedit the following things per option for this mod:\n\n" + + "\t\t- file redirections\n" + + "\t\t- file swaps\n" + + "\t\t- metadata manipulations\n" + + "\t\t- model materials\n" + + "\t\t- duplicates\n" + + "\t\t- textures" ); } // Just a simple text box with the wrapped description, if it exists. diff --git a/Penumbra/UI/ConfigWindow.SettingsTab.Advanced.cs b/Penumbra/UI/ConfigWindow.SettingsTab.Advanced.cs index 1166bd58..bf8c0de9 100644 --- a/Penumbra/UI/ConfigWindow.SettingsTab.Advanced.cs +++ b/Penumbra/UI/ConfigWindow.SettingsTab.Advanced.cs @@ -15,11 +15,11 @@ public partial class ConfigWindow { private void DrawAdvancedSettings() { - if( !Penumbra.Config.ShowAdvanced || !ImGui.CollapsingHeader( "Advanced" ) ) - { - return; - } + var header = ImGui.CollapsingHeader( "Advanced" ); + OpenTutorial( BasicTutorialSteps.AdvancedSettings ); + if( !header ) + return; Checkbox( "Auto Deduplicate on Import", "Automatically deduplicate mod files on import. This will make mod file sizes smaller, but deletes (binary identical) files.", Penumbra.Config.AutoDeduplicateOnImport, v => Penumbra.Config.AutoDeduplicateOnImport = v ); diff --git a/Penumbra/UI/ConfigWindow.SettingsTab.cs b/Penumbra/UI/ConfigWindow.SettingsTab.cs index 0735fbda..b256b04a 100644 --- a/Penumbra/UI/ConfigWindow.SettingsTab.cs +++ b/Penumbra/UI/ConfigWindow.SettingsTab.cs @@ -6,7 +6,6 @@ using System.Numerics; using Dalamud.Interface; using Dalamud.Interface.Components; using Dalamud.Interface.ImGuiFileDialog; -using Dalamud.Logging; using Dalamud.Utility; using ImGuiNET; using OtterGui; @@ -45,7 +44,6 @@ public partial class ConfigWindow } DrawEnabledBox(); - DrawShowAdvancedBox(); Checkbox( "Lock Main Window", "Prevent the main window from being resized or moved.", Penumbra.Config.FixMainWindow, v => { Penumbra.Config.FixMainWindow = v; @@ -76,8 +74,8 @@ public partial class ConfigWindow // Shows up only if the current input does not correspond to the current directory. private static bool DrawPressEnterWarning( string newName, string old, float width, bool saved ) { - using var color = ImRaii.PushColor( ImGuiCol.Button, Colors.PressEnterWarningBg ); - var w = new Vector2( width, 0 ); + using var color = ImRaii.PushColor( ImGuiCol.Button, Colors.PressEnterWarningBg ); + var w = new Vector2( width, 0 ); var (text, valid) = CheckPath( newName, old ); return ( ImGui.Button( text, w ) || saved ) && valid; @@ -88,7 +86,7 @@ public partial class ConfigWindow static bool IsSubPathOf( string basePath, string subPath ) { var rel = Path.GetRelativePath( basePath, subPath ); - return rel == "." || (!rel.StartsWith( '.' ) && !Path.IsPathRooted( rel )); + return rel == "." || !rel.StartsWith( '.' ) && !Path.IsPathRooted( rel ); } if( newName.Length > RootDirectoryMaxLength ) @@ -113,6 +111,13 @@ public partial class ConfigWindow return ( "Path may not be on your Desktop.", false ); } + var programFiles = Environment.GetFolderPath( Environment.SpecialFolder.ProgramFiles ); + var programFilesX86 = Environment.GetFolderPath( Environment.SpecialFolder.ProgramFilesX86 ); + if( IsSubPathOf( programFiles, newName ) || IsSubPathOf( programFilesX86, newName ) ) + { + return ( "Path may not be in ProgramFiles.", false ); + } + var dalamud = Dalamud.PluginInterface.ConfigDirectory.Parent!.Parent!; if( IsSubPathOf( dalamud.FullName, newName ) ) { @@ -198,12 +203,19 @@ public partial class ConfigWindow DrawDirectoryPickerButton(); style.Pop(); ImGui.SameLine(); - ImGuiUtil.LabeledHelpMarker( "Root Directory", "This is where Penumbra will store your extracted mod files.\n" + + const string tt = "This is where Penumbra will store your extracted mod files.\n" + "TTMP files are not copied, just extracted.\n" + "This directory needs to be accessible and you need write access here.\n" + "It is recommended that this directory is placed on a fast hard drive, preferably an SSD.\n" + "It should also be placed near the root of a logical drive - the shorter the total path to this folder, the better.\n" - + "Definitely do not place it in your Dalamud directory or any sub-directory thereof." ); + + "Definitely do not place it in your Dalamud directory or any sub-directory thereof."; + ImGuiComponents.HelpMarker( tt ); + OpenTutorial( BasicTutorialSteps.GeneralTooltips ); + ImGui.SameLine(); + ImGui.TextUnformatted( "Root Directory" ); + ImGuiUtil.HoverTooltip( tt ); + group.Dispose(); OpenTutorial( BasicTutorialSteps.ModDirectory ); ImGui.SameLine(); @@ -242,32 +254,6 @@ public partial class ConfigWindow OpenTutorial( BasicTutorialSteps.EnableMods ); } - private static void DrawShowAdvancedBox() - { - var showAdvanced = Penumbra.Config.ShowAdvanced; - using( var _ = ImRaii.Group() ) - { - if( ImGui.Checkbox( "##showAdvanced", ref showAdvanced ) ) - { - Penumbra.Config.ShowAdvanced = showAdvanced; - Penumbra.Config.Save(); - } - - ImGui.SameLine(); - const string tt = "Enable some advanced options in this window and in the mod selector.\n" - + "This is required to enable manually editing any mod information."; - - // Manually split due to tutorial. - ImGuiComponents.HelpMarker( tt ); - OpenTutorial( BasicTutorialSteps.GeneralTooltips ); - ImGui.SameLine(); - ImGui.TextUnformatted( "Show Advanced Settings" ); - ImGuiUtil.HoverTooltip( tt ); - } - - OpenTutorial( BasicTutorialSteps.AdvancedSettings ); - } - private static void DrawColorSettings() { if( !ImGui.CollapsingHeader( "Colors" ) )