mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-15 05:04:15 +01:00
Add context menu to clear temporary settings.
This commit is contained in:
parent
79938b6dd0
commit
b7b9defaa6
3 changed files with 25 additions and 12 deletions
|
|
@ -130,8 +130,8 @@ public class TemporaryApi(
|
||||||
return ApiHelpers.Return(ret, args);
|
return ApiHelpers.Return(ret, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public (PenumbraApiEc, (bool, bool, int, Dictionary<string, List<string>>)?, string) QueryTemporaryModSettings(Guid collectionId, string modDirectory,
|
public (PenumbraApiEc, (bool, bool, int, Dictionary<string, List<string>>)?, string) QueryTemporaryModSettings(Guid collectionId,
|
||||||
string modName, int key)
|
string modDirectory, string modName, int key)
|
||||||
{
|
{
|
||||||
var args = ApiHelpers.Args("CollectionId", collectionId, "ModDirectory", modDirectory, "ModName", modName);
|
var args = ApiHelpers.Args("CollectionId", collectionId, "ModDirectory", modDirectory, "ModName", modName);
|
||||||
if (!collectionManager.Storage.ById(collectionId, out var collection))
|
if (!collectionManager.Storage.ById(collectionId, out var collection))
|
||||||
|
|
@ -296,15 +296,7 @@ public class TemporaryApi(
|
||||||
if (collection.Identity.Index <= 0)
|
if (collection.Identity.Index <= 0)
|
||||||
return ApiHelpers.Return(PenumbraApiEc.NothingChanged, args);
|
return ApiHelpers.Return(PenumbraApiEc.NothingChanged, args);
|
||||||
|
|
||||||
var numRemoved = 0;
|
var numRemoved = collectionManager.Editor.ClearTemporarySettings(collection, key);
|
||||||
for (var i = 0; i < collection.Settings.Count; ++i)
|
|
||||||
{
|
|
||||||
if (collection.GetTempSettings(i) is { } tempSettings
|
|
||||||
&& tempSettings.Lock == key
|
|
||||||
&& collectionManager.Editor.SetTemporarySettings(collection, modManager[i], null, key))
|
|
||||||
++numRemoved;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ApiHelpers.Return(numRemoved > 0 ? PenumbraApiEc.Success : PenumbraApiEc.NothingChanged, args);
|
return ApiHelpers.Return(numRemoved > 0 ? PenumbraApiEc.Success : PenumbraApiEc.NothingChanged, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,20 @@ public class CollectionEditor(SaveService saveService, CommunicatorService commu
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int ClearTemporarySettings(ModCollection collection, int key = 0)
|
||||||
|
{
|
||||||
|
var numRemoved = 0;
|
||||||
|
for (var i = 0; i < collection.Settings.Count; ++i)
|
||||||
|
{
|
||||||
|
if (collection.GetTempSettings(i) is { } tempSettings
|
||||||
|
&& tempSettings.Lock == key
|
||||||
|
&& SetTemporarySettings(collection, modStorage[i], null, key))
|
||||||
|
++numRemoved;
|
||||||
|
}
|
||||||
|
|
||||||
|
return numRemoved;
|
||||||
|
}
|
||||||
|
|
||||||
public bool CanSetTemporarySettings(ModCollection collection, Mod mod, int key)
|
public bool CanSetTemporarySettings(ModCollection collection, Mod mod, int key)
|
||||||
{
|
{
|
||||||
var old = collection.GetTempSettings(mod.Index);
|
var old = collection.GetTempSettings(mod.Index);
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ public sealed class ModFileSystemSelector : FileSystemSelector<Mod, ModFileSyste
|
||||||
SubscribeRightClickLeaf(ToggleLeafFavorite);
|
SubscribeRightClickLeaf(ToggleLeafFavorite);
|
||||||
SubscribeRightClickLeaf(DrawTemporaryOptions);
|
SubscribeRightClickLeaf(DrawTemporaryOptions);
|
||||||
SubscribeRightClickLeaf(l => QuickMove(l, _config.QuickMoveFolder1, _config.QuickMoveFolder2, _config.QuickMoveFolder3));
|
SubscribeRightClickLeaf(l => QuickMove(l, _config.QuickMoveFolder1, _config.QuickMoveFolder2, _config.QuickMoveFolder3));
|
||||||
|
SubscribeRightClickMain(ClearTemporarySettings, 105);
|
||||||
SubscribeRightClickMain(ClearDefaultImportFolder, 100);
|
SubscribeRightClickMain(ClearDefaultImportFolder, 100);
|
||||||
SubscribeRightClickMain(() => ClearQuickMove(0, _config.QuickMoveFolder1, () => {_config.QuickMoveFolder1 = string.Empty; _config.Save();}), 110);
|
SubscribeRightClickMain(() => ClearQuickMove(0, _config.QuickMoveFolder1, () => {_config.QuickMoveFolder1 = string.Empty; _config.Save();}), 110);
|
||||||
SubscribeRightClickMain(() => ClearQuickMove(1, _config.QuickMoveFolder2, () => {_config.QuickMoveFolder2 = string.Empty; _config.Save();}), 120);
|
SubscribeRightClickMain(() => ClearQuickMove(1, _config.QuickMoveFolder2, () => {_config.QuickMoveFolder2 = string.Empty; _config.Save();}), 120);
|
||||||
|
|
@ -237,10 +238,16 @@ public sealed class ModFileSystemSelector : FileSystemSelector<Mod, ModFileSyste
|
||||||
// Add custom context menu items.
|
// Add custom context menu items.
|
||||||
private void EnableDescendants(ModFileSystem.Folder folder)
|
private void EnableDescendants(ModFileSystem.Folder folder)
|
||||||
{
|
{
|
||||||
if (ImGui.MenuItem("Enable Descendants"))
|
if (ImUtf8.MenuItem("Enable Descendants"u8))
|
||||||
SetDescendants(folder, true);
|
SetDescendants(folder, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ClearTemporarySettings()
|
||||||
|
{
|
||||||
|
if (ImUtf8.MenuItem("Clear Temporary Settings"u8))
|
||||||
|
_collectionManager.Editor.ClearTemporarySettings(_collectionManager.Active.Current);
|
||||||
|
}
|
||||||
|
|
||||||
private void DisableDescendants(ModFileSystem.Folder folder)
|
private void DisableDescendants(ModFileSystem.Folder folder)
|
||||||
{
|
{
|
||||||
if (ImUtf8.MenuItem("Disable Descendants"u8))
|
if (ImUtf8.MenuItem("Disable Descendants"u8))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue