Fix changing file redirections manually not counting as applied changes.

This commit is contained in:
Ottermandias 2022-06-11 22:13:29 +02:00
parent 02f1a4cedd
commit 1d3a31db6f
2 changed files with 19 additions and 19 deletions

View file

@ -163,7 +163,7 @@ public partial class Mod
// If pathIdx is equal to the total number of paths, path will be added, otherwise replaced. // 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 ) 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; return false;
} }
@ -174,7 +174,7 @@ public partial class Mod
return false; return false;
} }
if( pathIdx == registry.SubModUsage.Count ) if( (pathIdx == - 1 || pathIdx == registry.SubModUsage.Count) && !path.IsEmpty )
{ {
registry.SubModUsage.Add( ( CurrentOption, path ) ); registry.SubModUsage.Add( ( CurrentOption, path ) );
++registry.CurrentUsage; ++registry.CurrentUsage;

View file

@ -154,17 +154,12 @@ public partial class ModEditWindow
if( ImGui.IsItemDeactivatedAfterEdit() ) if( ImGui.IsItemDeactivatedAfterEdit() )
{ {
if( Utf8GamePath.FromString( _gamePathEdit, out var path, false ) )
{
_editor!.SetGamePath( _fileIdx, _pathIdx, path );
}
_fileIdx = -1; _fileIdx = -1;
_pathIdx = -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() ) if( ImGui.IsItemDeactivatedAfterEdit() )
{ {
_fileIdx = -1;
_pathIdx = -1;
if( Utf8GamePath.FromString( _gamePathEdit, out var path, false ) && !path.IsEmpty ) if( Utf8GamePath.FromString( _gamePathEdit, out var path, false ) && !path.IsEmpty )
{ {
registry.SubModUsage.Add( ( subMod, path ) ); _editor!.SetGamePath( _fileIdx, _pathIdx, path );
++registry.CurrentUsage;
} }
_fileIdx = -1;
_pathIdx = -1;
} }
} }
@ -200,19 +194,22 @@ public partial class ModEditWindow
ImGui.DragInt( "##skippedFolders", ref _folderSkip, 0.01f, 0, 10 ); 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." ); ImGuiUtil.HoverTooltip( "Skip the first N folders when automatically constructing the game path from the file path." );
ImGui.SameLine(); ImGui.SameLine();
spacing.Pop( ); spacing.Pop();
if( ImGui.Button( "Add Paths" ) ) if( ImGui.Button( "Add Paths" ) )
{ {
_editor!.AddPathsToSelected( _editor!.AvailableFiles.Where( _selectedFiles.Contains ), _folderSkip ); _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(); ImGui.SameLine();
if( ImGui.Button( "Remove Paths" ) ) if( ImGui.Button( "Remove Paths" ) )
{ {
_editor!.RemovePathsFromSelected( _editor!.AvailableFiles.Where( _selectedFiles.Contains ) ); _editor!.RemovePathsFromSelected( _editor!.AvailableFiles.Where( _selectedFiles.Contains ) );
} }
ImGuiUtil.HoverTooltip( "Remove all game paths associated with the selected files in the current option." ); 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 ) ); _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(); ImGui.SameLine();
var changes = _editor!.FileChanges; var changes = _editor!.FileChanges;
var tt = changes ? "Apply the current file setup to the currently selected option." : "No changes made."; 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(); _editor!.RevertFiles();
} }
ImGuiUtil.HoverTooltip( "Revert all revertible changes since the last file or option reload or data refresh." ); ImGuiUtil.HoverTooltip( "Revert all revertible changes since the last file or option reload or data refresh." );
ImGui.SetNextItemWidth( 250 * ImGuiHelpers.GlobalScale ); ImGui.SetNextItemWidth( 250 * ImGuiHelpers.GlobalScale );