diff --git a/Penumbra/Mods/Editor/Mod.Editor.Files.cs b/Penumbra/Mods/Editor/Mod.Editor.Files.cs index 5d56c871..029c93fa 100644 --- a/Penumbra/Mods/Editor/Mod.Editor.Files.cs +++ b/Penumbra/Mods/Editor/Mod.Editor.Files.cs @@ -163,7 +163,7 @@ public partial class Mod // If pathIdx is equal to the total number of paths, path will be added, otherwise replaced. public bool SetGamePath( int fileIdx, int pathIdx, Utf8GamePath path ) { - if( _usedPaths.Contains( path ) || fileIdx < 0 || fileIdx > _availableFiles.Count || pathIdx < 0 ) + if( _usedPaths.Contains( path ) || fileIdx < 0 || fileIdx > _availableFiles.Count ) { return false; } @@ -174,7 +174,7 @@ public partial class Mod return false; } - if( pathIdx == registry.SubModUsage.Count ) + if( (pathIdx == - 1 || pathIdx == registry.SubModUsage.Count) && !path.IsEmpty ) { registry.SubModUsage.Add( ( CurrentOption, path ) ); ++registry.CurrentUsage; diff --git a/Penumbra/UI/Classes/ModEditWindow.Files.cs b/Penumbra/UI/Classes/ModEditWindow.Files.cs index 47a2178c..78f27e3c 100644 --- a/Penumbra/UI/Classes/ModEditWindow.Files.cs +++ b/Penumbra/UI/Classes/ModEditWindow.Files.cs @@ -154,17 +154,12 @@ public partial class ModEditWindow if( ImGui.IsItemDeactivatedAfterEdit() ) { + if( Utf8GamePath.FromString( _gamePathEdit, out var path, false ) ) + { + _editor!.SetGamePath( _fileIdx, _pathIdx, path ); + } _fileIdx = -1; _pathIdx = -1; - if( _gamePathEdit.Length == 0 ) - { - registry.SubModUsage.RemoveAt( j-- ); - --registry.CurrentUsage; - } - else if( Utf8GamePath.FromString( _gamePathEdit, out var path, false ) ) - { - registry.SubModUsage[ j ] = ( subMod, path ); - } } } @@ -181,13 +176,12 @@ public partial class ModEditWindow if( ImGui.IsItemDeactivatedAfterEdit() ) { - _fileIdx = -1; - _pathIdx = -1; if( Utf8GamePath.FromString( _gamePathEdit, out var path, false ) && !path.IsEmpty ) { - registry.SubModUsage.Add( ( subMod, path ) ); - ++registry.CurrentUsage; + _editor!.SetGamePath( _fileIdx, _pathIdx, path ); } + _fileIdx = -1; + _pathIdx = -1; } } @@ -200,19 +194,22 @@ public partial class ModEditWindow ImGui.DragInt( "##skippedFolders", ref _folderSkip, 0.01f, 0, 10 ); ImGuiUtil.HoverTooltip( "Skip the first N folders when automatically constructing the game path from the file path." ); ImGui.SameLine(); - spacing.Pop( ); + spacing.Pop(); if( ImGui.Button( "Add Paths" ) ) { _editor!.AddPathsToSelected( _editor!.AvailableFiles.Where( _selectedFiles.Contains ), _folderSkip ); } - ImGuiUtil.HoverTooltip( "Add the file path converted to a game path to all selected files for the current option, optionally skipping the first N folders." ); - + + ImGuiUtil.HoverTooltip( + "Add the file path converted to a game path to all selected files for the current option, optionally skipping the first N folders." ); + ImGui.SameLine(); if( ImGui.Button( "Remove Paths" ) ) { _editor!.RemovePathsFromSelected( _editor!.AvailableFiles.Where( _selectedFiles.Contains ) ); } + ImGuiUtil.HoverTooltip( "Remove all game paths associated with the selected files in the current option." ); @@ -221,7 +218,9 @@ public partial class ModEditWindow { _editor!.DeleteFiles( _editor!.AvailableFiles.Where( _selectedFiles.Contains ) ); } - ImGuiUtil.HoverTooltip( "Delete all selected files entirely from your filesystem, but not their file associations in the mod, if there are any.\n!!!This can not be reverted!!!" ); + + ImGuiUtil.HoverTooltip( + "Delete all selected files entirely from your filesystem, but not their file associations in the mod, if there are any.\n!!!This can not be reverted!!!" ); ImGui.SameLine(); var changes = _editor!.FileChanges; var tt = changes ? "Apply the current file setup to the currently selected option." : "No changes made."; @@ -239,6 +238,7 @@ public partial class ModEditWindow { _editor!.RevertFiles(); } + ImGuiUtil.HoverTooltip( "Revert all revertible changes since the last file or option reload or data refresh." ); ImGui.SetNextItemWidth( 250 * ImGuiHelpers.GlobalScale );