Update AdvancedEditingOpen ephemeral setting

This commit is contained in:
Exter-N 2025-10-24 14:12:42 +02:00
parent 34f067f13d
commit 2742e4d485
5 changed files with 32 additions and 11 deletions

View file

@ -41,7 +41,7 @@ public class EphemeralConfig : ISavable, IDisposable, IService
public ChangedItemIconFlag ChangedItemFilter { get; set; } = ChangedItemFlagExtensions.DefaultFlags; public ChangedItemIconFlag ChangedItemFilter { get; set; } = ChangedItemFlagExtensions.DefaultFlags;
public bool FixMainWindow { get; set; } = false; public bool FixMainWindow { get; set; } = false;
public string LastModPath { get; set; } = string.Empty; public string LastModPath { get; set; } = string.Empty;
public bool AdvancedEditingOpen { get; set; } = false; public HashSet<string> AdvancedEditingOpenForModPaths { get; set; } = [];
public bool ForceRedrawOnFileChange { get; set; } = false; public bool ForceRedrawOnFileChange { get; set; } = false;
public bool IncognitoMode { get; set; } = false; public bool IncognitoMode { get; set; } = false;

View file

@ -32,6 +32,24 @@ public class ModStorage : IReadOnlyList<Mod>
IEnumerator IEnumerable.GetEnumerator() IEnumerator IEnumerable.GetEnumerator()
=> GetEnumerator(); => GetEnumerator();
/// <summary>
/// Try to obtain a mod by its directory name (unique identifier).
/// </summary>
public bool TryGetMod(string identifier, [NotNullWhen(true)] out Mod? mod)
{
foreach (var m in Mods)
{
if (string.Equals(m.Identifier, identifier, StringComparison.OrdinalIgnoreCase))
{
mod = m;
return true;
}
}
mod = null;
return false;
}
/// <summary> /// <summary>
/// Try to obtain a mod by its directory name (unique identifier, preferred), /// Try to obtain a mod by its directory name (unique identifier, preferred),
/// or the first mod of the given name if no directory fits. /// or the first mod of the given name if no directory fits.

View file

@ -27,8 +27,8 @@ public class ModSelection : EventBase<ModSelection.Arguments, ModSelection.Prior
_communicator = communicator; _communicator = communicator;
_collections = collections; _collections = collections;
_config = config; _config = config;
if (_config.LastModPath.Length > 0) if (_config.LastModPath.Length > 0 && mods.TryGetMod(config.LastModPath, out var mod))
SelectMod(mods.FirstOrDefault(m => string.Equals(m.Identifier, config.LastModPath, StringComparison.OrdinalIgnoreCase))); SelectMod(mod);
_communicator.CollectionChange.Subscribe(OnCollectionChange, CollectionChange.Priority.ModSelection); _communicator.CollectionChange.Subscribe(OnCollectionChange, CollectionChange.Priority.ModSelection);
_communicator.CollectionInheritanceChanged.Subscribe(OnInheritanceChange, CollectionInheritanceChanged.Priority.ModSelection); _communicator.CollectionInheritanceChanged.Subscribe(OnInheritanceChange, CollectionInheritanceChanged.Priority.ModSelection);

View file

@ -141,8 +141,14 @@ public class Penumbra : IDalamudPlugin
if (!_disposed) if (!_disposed)
{ {
_windowSystem = system; _windowSystem = system;
if (_config is { OpenWindowAtStart: true, Ephemeral.AdvancedEditingOpen: true } && _services.GetService<ModSelection>().Mod is {} mod) if (_config is { OpenWindowAtStart: true, Ephemeral.AdvancedEditingOpenForModPaths.Count: > 0 })
_services.GetService<ModEditWindowFactory>().OpenForMod(mod); {
var mods = _services.GetService<ModManager>();
var editWindowFactory = _services.GetService<ModEditWindowFactory>();
foreach (var identifier in _config.Ephemeral.AdvancedEditingOpenForModPaths)
if (mods.TryGetMod(identifier, out var mod))
editWindowFactory.OpenForMod(mod);
}
} }
else else
system.Dispose(); system.Dispose();

View file

@ -180,8 +180,8 @@ public partial class ModEditWindow : IndexedWindow, IDisposable
public override void OnClose() public override void OnClose()
{ {
base.OnClose(); base.OnClose();
_config.Ephemeral.AdvancedEditingOpen = false; if (Mod is not null && _config.Ephemeral.AdvancedEditingOpenForModPaths.Remove(Mod.Identifier))
_config.Ephemeral.Save(); _config.Ephemeral.Save();
AppendTask(() => AppendTask(() =>
{ {
_left.Dispose(); _left.Dispose();
@ -194,11 +194,8 @@ public partial class ModEditWindow : IndexedWindow, IDisposable
public override void Draw() public override void Draw()
{ {
if (!_config.Ephemeral.AdvancedEditingOpen) if (Mod is not null && _config.Ephemeral.AdvancedEditingOpenForModPaths.Add(Mod.Identifier))
{
_config.Ephemeral.AdvancedEditingOpen = true;
_config.Ephemeral.Save(); _config.Ephemeral.Save();
}
if (IsLoading) if (IsLoading)
{ {