Add separate option for temporary folder, fix cache StructuredMods not updating on root folder change.

This commit is contained in:
Ottermandias 2021-08-14 21:14:11 +02:00
parent 2ebbb227f7
commit 556bff4e46
12 changed files with 207 additions and 49 deletions

View file

@ -144,6 +144,11 @@ namespace Penumbra.UI
PrintValue( "Mod Manager BasePath IsRooted", Path.IsPathRooted( _plugin.Configuration.ModDirectory ).ToString() );
PrintValue( "Mod Manager BasePath Exists", Directory.Exists( manager.BasePath.FullName ).ToString() );
PrintValue( "Mod Manager Valid", manager.Valid.ToString() );
PrintValue( "Mod Manager Temp Path", manager.TempPath.FullName );
PrintValue( "Mod Manager Temp Path IsRooted",
( !_plugin.Configuration.TempDirectory.Any() || Path.IsPathRooted( _plugin.Configuration.TempDirectory ) ).ToString() );
PrintValue( "Mod Manager Temp Path Exists", Directory.Exists( manager.TempPath.FullName ).ToString() );
PrintValue( "Mod Manager Temp Path IsWritable", manager.TempWritable.ToString() );
ImGui.EndTable();
}

View file

@ -435,7 +435,7 @@ namespace Penumbra.UI
foreach( var collection in _modManager.Collections.Collections.Values
.Where( c => c.Cache != null && c.Settings[ Mod!.Data.BasePath.Name ].Enabled ) )
{
collection.CalculateEffectiveFileList( _modManager.BasePath, false,
collection.CalculateEffectiveFileList( _modManager.TempPath, false,
collection == _modManager.Collections.ActiveCollection );
}

View file

@ -539,7 +539,7 @@ namespace Penumbra.UI
var collection = _modManager.Collections.CurrentCollection;
if( collection.Cache != null )
{
collection.CalculateEffectiveFileList( _modManager.BasePath, metaManips,
collection.CalculateEffectiveFileList( _modManager.TempPath, metaManips,
collection == _modManager.Collections.ActiveCollection );
}
@ -563,6 +563,7 @@ namespace Penumbra.UI
{
folder.Merge( folder.Parent! );
}
_newFolderName = string.Empty;
}

View file

@ -17,8 +17,10 @@ namespace Penumbra.UI
{
private const string LabelTab = "Settings";
private const string LabelRootFolder = "Root Folder";
private const string LabelTempFolder = "Temporary Folder";
private const string LabelRediscoverButton = "Rediscover Mods";
private const string LabelOpenFolder = "Open Mods Folder";
private const string LabelOpenTempFolder = "Open Temporary Folder";
private const string LabelEnabled = "Enable Mods";
private const string LabelEnabledPlayerWatch = "Enable automatic Character Redraws";
private const string LabelWaitFrames = "Wait Frames";
@ -47,10 +49,39 @@ namespace Penumbra.UI
if( ImGui.InputText( LabelRootFolder, ref basePath, 255, ImGuiInputTextFlags.EnterReturnsTrue )
&& _config.ModDirectory != basePath )
{
_config.ModDirectory = basePath;
_configChanged = true;
_base.ReloadMods();
_base._menu.InstalledTab.Selector.ClearSelection();
_base._modManager.DiscoverMods( basePath );
_base._menu.InstalledTab.Selector.Cache.TriggerListReset();
}
}
private void DrawTempFolder()
{
var tempPath = _config.TempDirectory;
ImGui.SetNextItemWidth( 400 );
if( ImGui.InputText( LabelTempFolder, ref tempPath, 255, ImGuiInputTextFlags.EnterReturnsTrue )
&& _config.TempDirectory != tempPath )
{
_base._modManager.SetTempDirectory( tempPath );
}
if( ImGui.IsItemHovered() )
{
ImGui.SetTooltip( "The folder used to store temporary meta manipulation files.\n"
+ "Leave this blank if you have no reason not to.\n"
+ "A folder 'penumbrametatmp' will be created as a subdirectory to the specified directory.\n"
+ "If none is specified (i.e. this is blank) this folder will be created in the root folder instead." );
}
ImGui.SameLine();
if( ImGui.Button( LabelOpenTempFolder ) )
{
if( !Directory.Exists( _base._modManager.TempPath.FullName ) || !_base._modManager.TempWritable )
{
return;
}
Process.Start( _base._modManager.TempPath.FullName );
}
}
@ -58,8 +89,9 @@ namespace Penumbra.UI
{
if( ImGui.Button( LabelRediscoverButton ) )
{
_base.ReloadMods();
_base._menu.InstalledTab.Selector.ClearSelection();
_base._modManager.DiscoverMods();
_base._menu.InstalledTab.Selector.Cache.TriggerListReset();
}
}
@ -108,7 +140,7 @@ namespace Penumbra.UI
{
_config.SortFoldersFirst = foldersFirst;
_base._menu.InstalledTab.Selector.Cache.TriggerListReset();
_configChanged = true;
_configChanged = true;
}
}
@ -224,6 +256,7 @@ namespace Penumbra.UI
private void DrawAdvancedSettings()
{
DrawTempFolder();
DrawLogLoadedFilesBox();
DrawDisableNotificationsBox();
DrawEnableHttpApiBox();

View file

@ -74,7 +74,7 @@ namespace Penumbra.UI
var current = _modManager.Collections.CurrentCollection;
if( current.Cache != null )
{
current.CalculateEffectiveFileList( _modManager.BasePath, recalculateMeta,
current.CalculateEffectiveFileList( _modManager.TempPath, recalculateMeta,
current == _modManager.Collections.ActiveCollection );
_menu.InstalledTab.Selector.Cache.TriggerFilterReset();
}