mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 10:17:22 +01:00
Update AdvancedEditingOpen ephemeral setting
This commit is contained in:
parent
34f067f13d
commit
2742e4d485
5 changed files with 32 additions and 11 deletions
|
|
@ -41,7 +41,7 @@ public class EphemeralConfig : ISavable, IDisposable, IService
|
|||
public ChangedItemIconFlag ChangedItemFilter { get; set; } = ChangedItemFlagExtensions.DefaultFlags;
|
||||
public bool FixMainWindow { get; set; } = false;
|
||||
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 IncognitoMode { get; set; } = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,24 @@ public class ModStorage : IReadOnlyList<Mod>
|
|||
IEnumerator IEnumerable.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>
|
||||
/// Try to obtain a mod by its directory name (unique identifier, preferred),
|
||||
/// or the first mod of the given name if no directory fits.
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ public class ModSelection : EventBase<ModSelection.Arguments, ModSelection.Prior
|
|||
_communicator = communicator;
|
||||
_collections = collections;
|
||||
_config = config;
|
||||
if (_config.LastModPath.Length > 0)
|
||||
SelectMod(mods.FirstOrDefault(m => string.Equals(m.Identifier, config.LastModPath, StringComparison.OrdinalIgnoreCase)));
|
||||
if (_config.LastModPath.Length > 0 && mods.TryGetMod(config.LastModPath, out var mod))
|
||||
SelectMod(mod);
|
||||
|
||||
_communicator.CollectionChange.Subscribe(OnCollectionChange, CollectionChange.Priority.ModSelection);
|
||||
_communicator.CollectionInheritanceChanged.Subscribe(OnInheritanceChange, CollectionInheritanceChanged.Priority.ModSelection);
|
||||
|
|
|
|||
|
|
@ -141,8 +141,14 @@ public class Penumbra : IDalamudPlugin
|
|||
if (!_disposed)
|
||||
{
|
||||
_windowSystem = system;
|
||||
if (_config is { OpenWindowAtStart: true, Ephemeral.AdvancedEditingOpen: true } && _services.GetService<ModSelection>().Mod is {} mod)
|
||||
_services.GetService<ModEditWindowFactory>().OpenForMod(mod);
|
||||
if (_config is { OpenWindowAtStart: true, Ephemeral.AdvancedEditingOpenForModPaths.Count: > 0 })
|
||||
{
|
||||
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
|
||||
system.Dispose();
|
||||
|
|
|
|||
|
|
@ -180,8 +180,8 @@ public partial class ModEditWindow : IndexedWindow, IDisposable
|
|||
public override void OnClose()
|
||||
{
|
||||
base.OnClose();
|
||||
_config.Ephemeral.AdvancedEditingOpen = false;
|
||||
_config.Ephemeral.Save();
|
||||
if (Mod is not null && _config.Ephemeral.AdvancedEditingOpenForModPaths.Remove(Mod.Identifier))
|
||||
_config.Ephemeral.Save();
|
||||
AppendTask(() =>
|
||||
{
|
||||
_left.Dispose();
|
||||
|
|
@ -194,11 +194,8 @@ public partial class ModEditWindow : IndexedWindow, IDisposable
|
|||
|
||||
public override void Draw()
|
||||
{
|
||||
if (!_config.Ephemeral.AdvancedEditingOpen)
|
||||
{
|
||||
_config.Ephemeral.AdvancedEditingOpen = true;
|
||||
if (Mod is not null && _config.Ephemeral.AdvancedEditingOpenForModPaths.Add(Mod.Identifier))
|
||||
_config.Ephemeral.Save();
|
||||
}
|
||||
|
||||
if (IsLoading)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue