mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-13 12:14:17 +01:00
Add some settingchanged events.
This commit is contained in:
parent
add4b8aa83
commit
1000841f69
9 changed files with 128 additions and 126 deletions
|
|
@ -1 +1 @@
|
||||||
Subproject commit 2b6bcf338794b34bcba2730c70dcbb73ce97311b
|
Subproject commit 79ffdd69a28141a1ac93daa24d76573b2fa0d71e
|
||||||
|
|
@ -141,6 +141,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
||||||
_communicator.ModPathChanged.Subscribe(ModPathChangeSubscriber, ModPathChanged.Priority.Api);
|
_communicator.ModPathChanged.Subscribe(ModPathChangeSubscriber, ModPathChanged.Priority.Api);
|
||||||
_communicator.ModSettingChanged.Subscribe(OnModSettingChange, Communication.ModSettingChanged.Priority.Api);
|
_communicator.ModSettingChanged.Subscribe(OnModSettingChange, Communication.ModSettingChanged.Priority.Api);
|
||||||
_communicator.CreatedCharacterBase.Subscribe(OnCreatedCharacterBase, Communication.CreatedCharacterBase.Priority.Api);
|
_communicator.CreatedCharacterBase.Subscribe(OnCreatedCharacterBase, Communication.CreatedCharacterBase.Priority.Api);
|
||||||
|
_communicator.ModOptionChanged.Subscribe(OnModOptionEdited, ModOptionChanged.Priority.Api);
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe void Dispose()
|
public unsafe void Dispose()
|
||||||
|
|
@ -342,10 +343,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
||||||
{
|
{
|
||||||
CheckInitialized();
|
CheckInitialized();
|
||||||
if (!_config.EnableMods)
|
if (!_config.EnableMods)
|
||||||
return new[]
|
return [path];
|
||||||
{
|
|
||||||
path,
|
|
||||||
};
|
|
||||||
|
|
||||||
var ret = _collectionManager.Active.Individual(NameToIdentifier(characterName, worldId)).ReverseResolvePath(new FullPath(path));
|
var ret = _collectionManager.Active.Individual(NameToIdentifier(characterName, worldId)).ReverseResolvePath(new FullPath(path));
|
||||||
return ret.Select(r => r.ToString()).ToArray();
|
return ret.Select(r => r.ToString()).ToArray();
|
||||||
|
|
@ -355,10 +353,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
||||||
{
|
{
|
||||||
CheckInitialized();
|
CheckInitialized();
|
||||||
if (!_config.EnableMods)
|
if (!_config.EnableMods)
|
||||||
return new[]
|
return [path];
|
||||||
{
|
|
||||||
path,
|
|
||||||
};
|
|
||||||
|
|
||||||
AssociatedCollection(gameObjectIdx, out var collection);
|
AssociatedCollection(gameObjectIdx, out var collection);
|
||||||
var ret = collection.ReverseResolvePath(new FullPath(path));
|
var ret = collection.ReverseResolvePath(new FullPath(path));
|
||||||
|
|
@ -369,10 +364,7 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
||||||
{
|
{
|
||||||
CheckInitialized();
|
CheckInitialized();
|
||||||
if (!_config.EnableMods)
|
if (!_config.EnableMods)
|
||||||
return new[]
|
return [path];
|
||||||
{
|
|
||||||
path,
|
|
||||||
};
|
|
||||||
|
|
||||||
var ret = _collectionResolver.PlayerCollection().ReverseResolvePath(new FullPath(path));
|
var ret = _collectionResolver.PlayerCollection().ReverseResolvePath(new FullPath(path));
|
||||||
return ret.Select(r => r.ToString()).ToArray();
|
return ret.Select(r => r.ToString()).ToArray();
|
||||||
|
|
@ -698,6 +690,9 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
case ModPathChangeType.Reloaded:
|
||||||
|
TriggerSettingEdited(mod);
|
||||||
|
break;
|
||||||
case ModPathChangeType.Deleted when oldDirectory != null:
|
case ModPathChangeType.Deleted when oldDirectory != null:
|
||||||
ModDeleted?.Invoke(oldDirectory.Name);
|
ModDeleted?.Invoke(oldDirectory.Name);
|
||||||
break;
|
break;
|
||||||
|
|
@ -1262,4 +1257,31 @@ public class PenumbraApi : IDisposable, IPenumbraApi
|
||||||
|
|
||||||
private void OnCreatedCharacterBase(nint gameObject, ModCollection collection, nint drawObject)
|
private void OnCreatedCharacterBase(nint gameObject, ModCollection collection, nint drawObject)
|
||||||
=> CreatedCharacterBase?.Invoke(gameObject, collection.Name, drawObject);
|
=> CreatedCharacterBase?.Invoke(gameObject, collection.Name, drawObject);
|
||||||
|
|
||||||
|
private void OnModOptionEdited(ModOptionChangeType type, Mod mod, int groupIndex, int optionIndex, int moveIndex)
|
||||||
|
{
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case ModOptionChangeType.GroupDeleted:
|
||||||
|
case ModOptionChangeType.GroupMoved:
|
||||||
|
case ModOptionChangeType.GroupTypeChanged:
|
||||||
|
case ModOptionChangeType.PriorityChanged:
|
||||||
|
case ModOptionChangeType.OptionDeleted:
|
||||||
|
case ModOptionChangeType.OptionMoved:
|
||||||
|
case ModOptionChangeType.OptionFilesChanged:
|
||||||
|
case ModOptionChangeType.OptionFilesAdded:
|
||||||
|
case ModOptionChangeType.OptionSwapsChanged:
|
||||||
|
case ModOptionChangeType.OptionMetaChanged:
|
||||||
|
TriggerSettingEdited(mod);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TriggerSettingEdited(Mod mod)
|
||||||
|
{
|
||||||
|
var collection = _collectionResolver.PlayerCollection();
|
||||||
|
var (settings, parent) = collection[mod.Index];
|
||||||
|
if (settings != null)
|
||||||
|
ModSettingChanged?.Invoke(ModSettingChange.Edited, collection.Name, mod.Identifier, parent != collection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -323,6 +323,7 @@ public class CollectionCacheManager : IDisposable
|
||||||
FullRecalculation(collection);
|
FullRecalculation(collection);
|
||||||
break;
|
break;
|
||||||
case ModSettingChange.TemporaryMod:
|
case ModSettingChange.TemporaryMod:
|
||||||
|
case ModSettingChange.Edited:
|
||||||
// handled otherwise
|
// handled otherwise
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,23 +2,18 @@ using Penumbra.Collections.Cache;
|
||||||
|
|
||||||
namespace Penumbra.Collections.Manager;
|
namespace Penumbra.Collections.Manager;
|
||||||
|
|
||||||
public class CollectionManager
|
public class CollectionManager(
|
||||||
|
CollectionStorage storage,
|
||||||
|
ActiveCollections active,
|
||||||
|
InheritanceManager inheritances,
|
||||||
|
CollectionCacheManager caches,
|
||||||
|
TempCollectionManager temp,
|
||||||
|
CollectionEditor editor)
|
||||||
{
|
{
|
||||||
public readonly CollectionStorage Storage;
|
public readonly CollectionStorage Storage = storage;
|
||||||
public readonly ActiveCollections Active;
|
public readonly ActiveCollections Active = active;
|
||||||
public readonly InheritanceManager Inheritances;
|
public readonly InheritanceManager Inheritances = inheritances;
|
||||||
public readonly CollectionCacheManager Caches;
|
public readonly CollectionCacheManager Caches = caches;
|
||||||
public readonly TempCollectionManager Temp;
|
public readonly TempCollectionManager Temp = temp;
|
||||||
public readonly CollectionEditor Editor;
|
public readonly CollectionEditor Editor = editor;
|
||||||
|
|
||||||
public CollectionManager(CollectionStorage storage, ActiveCollections active, InheritanceManager inheritances,
|
|
||||||
CollectionCacheManager caches, TempCollectionManager temp, CollectionEditor editor)
|
|
||||||
{
|
|
||||||
Storage = storage;
|
|
||||||
Active = active;
|
|
||||||
Inheritances = inheritances;
|
|
||||||
Caches = caches;
|
|
||||||
Temp = temp;
|
|
||||||
Editor = editor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using OtterGui.Classes;
|
using OtterGui.Classes;
|
||||||
|
using Penumbra.Api;
|
||||||
using Penumbra.Mods;
|
using Penumbra.Mods;
|
||||||
using Penumbra.Mods.Manager;
|
using Penumbra.Mods.Manager;
|
||||||
|
|
||||||
|
|
@ -18,6 +19,9 @@ public sealed class ModOptionChanged()
|
||||||
{
|
{
|
||||||
public enum Priority
|
public enum Priority
|
||||||
{
|
{
|
||||||
|
/// <seealso cref="PenumbraApi.OnModOptionEdited"/>
|
||||||
|
Api = int.MinValue,
|
||||||
|
|
||||||
/// <seealso cref="Collections.Cache.CollectionCacheManager.OnModOptionChange"/>
|
/// <seealso cref="Collections.Cache.CollectionCacheManager.OnModOptionChange"/>
|
||||||
CollectionCacheManager = -100,
|
CollectionCacheManager = -100,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,15 +19,15 @@ public sealed class ModPathChanged()
|
||||||
{
|
{
|
||||||
public enum Priority
|
public enum Priority
|
||||||
{
|
{
|
||||||
|
/// <seealso cref="PenumbraApi.ModPathChangeSubscriber"/>
|
||||||
|
Api = int.MinValue,
|
||||||
|
|
||||||
/// <seealso cref="EphemeralConfig.OnModPathChanged"/>
|
/// <seealso cref="EphemeralConfig.OnModPathChanged"/>
|
||||||
EphemeralConfig = -500,
|
EphemeralConfig = -500,
|
||||||
|
|
||||||
/// <seealso cref="Collections.Cache.CollectionCacheManager.OnModChangeAddition"/>
|
/// <seealso cref="Collections.Cache.CollectionCacheManager.OnModChangeAddition"/>
|
||||||
CollectionCacheManagerAddition = -100,
|
CollectionCacheManagerAddition = -100,
|
||||||
|
|
||||||
/// <seealso cref="PenumbraApi.ModPathChangeSubscriber"/>
|
|
||||||
Api = 0,
|
|
||||||
|
|
||||||
/// <seealso cref="Mods.Manager.ModCacheManager.OnModPathChange"/>
|
/// <seealso cref="Mods.Manager.ModCacheManager.OnModPathChange"/>
|
||||||
ModCacheManager = 0,
|
ModCacheManager = 0,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ using Penumbra.Meta.Manipulations;
|
||||||
using Penumbra.Mods.Manager;
|
using Penumbra.Mods.Manager;
|
||||||
using Penumbra.Mods.Subclasses;
|
using Penumbra.Mods.Subclasses;
|
||||||
|
|
||||||
namespace Penumbra.Mods;
|
namespace Penumbra.Mods.Editor;
|
||||||
|
|
||||||
public class ModMetaEditor(ModManager modManager)
|
public class ModMetaEditor(ModManager modManager)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -23,17 +23,8 @@ public enum ModDataChangeType : ushort
|
||||||
Note = 0x0800,
|
Note = 0x0800,
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ModDataEditor
|
public class ModDataEditor(SaveService saveService, CommunicatorService communicatorService)
|
||||||
{
|
{
|
||||||
private readonly SaveService _saveService;
|
|
||||||
private readonly CommunicatorService _communicatorService;
|
|
||||||
|
|
||||||
public ModDataEditor(SaveService saveService, CommunicatorService communicatorService)
|
|
||||||
{
|
|
||||||
_saveService = saveService;
|
|
||||||
_communicatorService = communicatorService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Create the file containing the meta information about a mod from scratch. </summary>
|
/// <summary> Create the file containing the meta information about a mod from scratch. </summary>
|
||||||
public void CreateMeta(DirectoryInfo directory, string? name, string? author, string? description, string? version,
|
public void CreateMeta(DirectoryInfo directory, string? name, string? author, string? description, string? version,
|
||||||
string? website)
|
string? website)
|
||||||
|
|
@ -44,12 +35,12 @@ public class ModDataEditor
|
||||||
mod.Description = description ?? mod.Description;
|
mod.Description = description ?? mod.Description;
|
||||||
mod.Version = version ?? mod.Version;
|
mod.Version = version ?? mod.Version;
|
||||||
mod.Website = website ?? mod.Website;
|
mod.Website = website ?? mod.Website;
|
||||||
_saveService.ImmediateSave(new ModMeta(mod));
|
saveService.ImmediateSave(new ModMeta(mod));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModDataChangeType LoadLocalData(Mod mod)
|
public ModDataChangeType LoadLocalData(Mod mod)
|
||||||
{
|
{
|
||||||
var dataFile = _saveService.FileNames.LocalDataFile(mod);
|
var dataFile = saveService.FileNames.LocalDataFile(mod);
|
||||||
|
|
||||||
var importDate = 0L;
|
var importDate = 0L;
|
||||||
var localTags = Enumerable.Empty<string>();
|
var localTags = Enumerable.Empty<string>();
|
||||||
|
|
@ -101,14 +92,14 @@ public class ModDataEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
if (save)
|
if (save)
|
||||||
_saveService.QueueSave(new ModLocalData(mod));
|
saveService.QueueSave(new ModLocalData(mod));
|
||||||
|
|
||||||
return changes;
|
return changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModDataChangeType LoadMeta(ModCreator creator, Mod mod)
|
public ModDataChangeType LoadMeta(ModCreator creator, Mod mod)
|
||||||
{
|
{
|
||||||
var metaFile = _saveService.FileNames.ModMetaPath(mod);
|
var metaFile = saveService.FileNames.ModMetaPath(mod);
|
||||||
if (!File.Exists(metaFile))
|
if (!File.Exists(metaFile))
|
||||||
{
|
{
|
||||||
Penumbra.Log.Debug($"No mod meta found for {mod.ModPath.Name}.");
|
Penumbra.Log.Debug($"No mod meta found for {mod.ModPath.Name}.");
|
||||||
|
|
@ -161,10 +152,10 @@ public class ModDataEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newFileVersion != ModMeta.FileVersion)
|
if (newFileVersion != ModMeta.FileVersion)
|
||||||
if (ModMigration.Migrate(creator, _saveService, mod, json, ref newFileVersion))
|
if (ModMigration.Migrate(creator, saveService, mod, json, ref newFileVersion))
|
||||||
{
|
{
|
||||||
changes |= ModDataChangeType.Migration;
|
changes |= ModDataChangeType.Migration;
|
||||||
_saveService.ImmediateSave(new ModMeta(mod));
|
saveService.ImmediateSave(new ModMeta(mod));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (importDate != null && mod.ImportDate != importDate.Value)
|
if (importDate != null && mod.ImportDate != importDate.Value)
|
||||||
|
|
@ -191,8 +182,8 @@ public class ModDataEditor
|
||||||
|
|
||||||
var oldName = mod.Name;
|
var oldName = mod.Name;
|
||||||
mod.Name = newName;
|
mod.Name = newName;
|
||||||
_saveService.QueueSave(new ModMeta(mod));
|
saveService.QueueSave(new ModMeta(mod));
|
||||||
_communicatorService.ModDataChanged.Invoke(ModDataChangeType.Name, mod, oldName.Text);
|
communicatorService.ModDataChanged.Invoke(ModDataChangeType.Name, mod, oldName.Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeModAuthor(Mod mod, string newAuthor)
|
public void ChangeModAuthor(Mod mod, string newAuthor)
|
||||||
|
|
@ -201,8 +192,8 @@ public class ModDataEditor
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mod.Author = newAuthor;
|
mod.Author = newAuthor;
|
||||||
_saveService.QueueSave(new ModMeta(mod));
|
saveService.QueueSave(new ModMeta(mod));
|
||||||
_communicatorService.ModDataChanged.Invoke(ModDataChangeType.Author, mod, null);
|
communicatorService.ModDataChanged.Invoke(ModDataChangeType.Author, mod, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeModDescription(Mod mod, string newDescription)
|
public void ChangeModDescription(Mod mod, string newDescription)
|
||||||
|
|
@ -211,8 +202,8 @@ public class ModDataEditor
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mod.Description = newDescription;
|
mod.Description = newDescription;
|
||||||
_saveService.QueueSave(new ModMeta(mod));
|
saveService.QueueSave(new ModMeta(mod));
|
||||||
_communicatorService.ModDataChanged.Invoke(ModDataChangeType.Description, mod, null);
|
communicatorService.ModDataChanged.Invoke(ModDataChangeType.Description, mod, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeModVersion(Mod mod, string newVersion)
|
public void ChangeModVersion(Mod mod, string newVersion)
|
||||||
|
|
@ -221,8 +212,8 @@ public class ModDataEditor
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mod.Version = newVersion;
|
mod.Version = newVersion;
|
||||||
_saveService.QueueSave(new ModMeta(mod));
|
saveService.QueueSave(new ModMeta(mod));
|
||||||
_communicatorService.ModDataChanged.Invoke(ModDataChangeType.Version, mod, null);
|
communicatorService.ModDataChanged.Invoke(ModDataChangeType.Version, mod, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeModWebsite(Mod mod, string newWebsite)
|
public void ChangeModWebsite(Mod mod, string newWebsite)
|
||||||
|
|
@ -231,8 +222,8 @@ public class ModDataEditor
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mod.Website = newWebsite;
|
mod.Website = newWebsite;
|
||||||
_saveService.QueueSave(new ModMeta(mod));
|
saveService.QueueSave(new ModMeta(mod));
|
||||||
_communicatorService.ModDataChanged.Invoke(ModDataChangeType.Website, mod, null);
|
communicatorService.ModDataChanged.Invoke(ModDataChangeType.Website, mod, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeModTag(Mod mod, int tagIdx, string newTag)
|
public void ChangeModTag(Mod mod, int tagIdx, string newTag)
|
||||||
|
|
@ -247,9 +238,9 @@ public class ModDataEditor
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mod.Favorite = state;
|
mod.Favorite = state;
|
||||||
_saveService.QueueSave(new ModLocalData(mod));
|
saveService.QueueSave(new ModLocalData(mod));
|
||||||
;
|
;
|
||||||
_communicatorService.ModDataChanged.Invoke(ModDataChangeType.Favorite, mod, null);
|
communicatorService.ModDataChanged.Invoke(ModDataChangeType.Favorite, mod, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeModNote(Mod mod, string newNote)
|
public void ChangeModNote(Mod mod, string newNote)
|
||||||
|
|
@ -258,9 +249,9 @@ public class ModDataEditor
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mod.Note = newNote;
|
mod.Note = newNote;
|
||||||
_saveService.QueueSave(new ModLocalData(mod));
|
saveService.QueueSave(new ModLocalData(mod));
|
||||||
;
|
;
|
||||||
_communicatorService.ModDataChanged.Invoke(ModDataChangeType.Favorite, mod, null);
|
communicatorService.ModDataChanged.Invoke(ModDataChangeType.Favorite, mod, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ChangeTag(Mod mod, int tagIdx, string newTag, bool local)
|
private void ChangeTag(Mod mod, int tagIdx, string newTag, bool local)
|
||||||
|
|
@ -282,19 +273,19 @@ public class ModDataEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags.HasFlag(ModDataChangeType.ModTags))
|
if (flags.HasFlag(ModDataChangeType.ModTags))
|
||||||
_saveService.QueueSave(new ModMeta(mod));
|
saveService.QueueSave(new ModMeta(mod));
|
||||||
|
|
||||||
if (flags.HasFlag(ModDataChangeType.LocalTags))
|
if (flags.HasFlag(ModDataChangeType.LocalTags))
|
||||||
_saveService.QueueSave(new ModLocalData(mod));
|
saveService.QueueSave(new ModLocalData(mod));
|
||||||
|
|
||||||
if (flags != 0)
|
if (flags != 0)
|
||||||
_communicatorService.ModDataChanged.Invoke(flags, mod, null);
|
communicatorService.ModDataChanged.Invoke(flags, mod, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveDataFile(DirectoryInfo oldMod, DirectoryInfo newMod)
|
public void MoveDataFile(DirectoryInfo oldMod, DirectoryInfo newMod)
|
||||||
{
|
{
|
||||||
var oldFile = _saveService.FileNames.LocalDataFile(oldMod.Name);
|
var oldFile = saveService.FileNames.LocalDataFile(oldMod.Name);
|
||||||
var newFile = _saveService.FileNames.LocalDataFile(newMod.Name);
|
var newFile = saveService.FileNames.LocalDataFile(newMod.Name);
|
||||||
if (!File.Exists(oldFile))
|
if (!File.Exists(oldFile))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,19 +31,8 @@ public enum ModOptionChangeType
|
||||||
DefaultOptionChanged,
|
DefaultOptionChanged,
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ModOptionEditor
|
public class ModOptionEditor(CommunicatorService communicator, SaveService saveService, Configuration config)
|
||||||
{
|
{
|
||||||
private readonly Configuration _config;
|
|
||||||
private readonly CommunicatorService _communicator;
|
|
||||||
private readonly SaveService _saveService;
|
|
||||||
|
|
||||||
public ModOptionEditor(CommunicatorService communicator, SaveService saveService, Configuration config)
|
|
||||||
{
|
|
||||||
_communicator = communicator;
|
|
||||||
_saveService = saveService;
|
|
||||||
_config = config;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Change the type of a group given by mod and index to type, if possible. </summary>
|
/// <summary> Change the type of a group given by mod and index to type, if possible. </summary>
|
||||||
public void ChangeModGroupType(Mod mod, int groupIdx, GroupType type)
|
public void ChangeModGroupType(Mod mod, int groupIdx, GroupType type)
|
||||||
{
|
{
|
||||||
|
|
@ -52,8 +41,8 @@ public class ModOptionEditor
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mod.Groups[groupIdx] = group.Convert(type);
|
mod.Groups[groupIdx] = group.Convert(type);
|
||||||
_saveService.QueueSave(new ModSaveGroup(mod, groupIdx, _config.ReplaceNonAsciiOnImport));
|
saveService.QueueSave(new ModSaveGroup(mod, groupIdx, config.ReplaceNonAsciiOnImport));
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.GroupTypeChanged, mod, groupIdx, -1, -1);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.GroupTypeChanged, mod, groupIdx, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Change the settings stored as default options in a mod.</summary>
|
/// <summary> Change the settings stored as default options in a mod.</summary>
|
||||||
|
|
@ -64,8 +53,8 @@ public class ModOptionEditor
|
||||||
return;
|
return;
|
||||||
|
|
||||||
group.DefaultSettings = defaultOption;
|
group.DefaultSettings = defaultOption;
|
||||||
_saveService.QueueSave(new ModSaveGroup(mod, groupIdx, _config.ReplaceNonAsciiOnImport));
|
saveService.QueueSave(new ModSaveGroup(mod, groupIdx, config.ReplaceNonAsciiOnImport));
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.DefaultOptionChanged, mod, groupIdx, -1, -1);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.DefaultOptionChanged, mod, groupIdx, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Rename an option group if possible. </summary>
|
/// <summary> Rename an option group if possible. </summary>
|
||||||
|
|
@ -76,7 +65,7 @@ public class ModOptionEditor
|
||||||
if (oldName == newName || !VerifyFileName(mod, group, newName, true))
|
if (oldName == newName || !VerifyFileName(mod, group, newName, true))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_saveService.ImmediateDelete(new ModSaveGroup(mod, groupIdx, _config.ReplaceNonAsciiOnImport));
|
saveService.ImmediateDelete(new ModSaveGroup(mod, groupIdx, config.ReplaceNonAsciiOnImport));
|
||||||
var _ = group switch
|
var _ = group switch
|
||||||
{
|
{
|
||||||
SingleModGroup s => s.Name = newName,
|
SingleModGroup s => s.Name = newName,
|
||||||
|
|
@ -84,8 +73,8 @@ public class ModOptionEditor
|
||||||
_ => newName,
|
_ => newName,
|
||||||
};
|
};
|
||||||
|
|
||||||
_saveService.ImmediateSave(new ModSaveGroup(mod, groupIdx, _config.ReplaceNonAsciiOnImport));
|
saveService.ImmediateSave(new ModSaveGroup(mod, groupIdx, config.ReplaceNonAsciiOnImport));
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.GroupRenamed, mod, groupIdx, -1, -1);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.GroupRenamed, mod, groupIdx, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Add a new, empty option group of the given type and name. </summary>
|
/// <summary> Add a new, empty option group of the given type and name. </summary>
|
||||||
|
|
@ -107,8 +96,8 @@ public class ModOptionEditor
|
||||||
Name = newName,
|
Name = newName,
|
||||||
Priority = maxPriority,
|
Priority = maxPriority,
|
||||||
});
|
});
|
||||||
_saveService.ImmediateSave(new ModSaveGroup(mod, mod.Groups.Count - 1, _config.ReplaceNonAsciiOnImport));
|
saveService.ImmediateSave(new ModSaveGroup(mod, mod.Groups.Count - 1, config.ReplaceNonAsciiOnImport));
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.GroupAdded, mod, mod.Groups.Count - 1, -1, -1);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.GroupAdded, mod, mod.Groups.Count - 1, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Add a new mod, empty option group of the given type and name if it does not exist already. </summary>
|
/// <summary> Add a new mod, empty option group of the given type and name if it does not exist already. </summary>
|
||||||
|
|
@ -128,11 +117,11 @@ public class ModOptionEditor
|
||||||
/// <summary> Delete a given option group. Fires an event to prepare before actually deleting. </summary>
|
/// <summary> Delete a given option group. Fires an event to prepare before actually deleting. </summary>
|
||||||
public void DeleteModGroup(Mod mod, int groupIdx)
|
public void DeleteModGroup(Mod mod, int groupIdx)
|
||||||
{
|
{
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.PrepareChange, mod, groupIdx, -1, -1);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.PrepareChange, mod, groupIdx, -1, -1);
|
||||||
mod.Groups.RemoveAt(groupIdx);
|
mod.Groups.RemoveAt(groupIdx);
|
||||||
UpdateSubModPositions(mod, groupIdx);
|
UpdateSubModPositions(mod, groupIdx);
|
||||||
_saveService.SaveAllOptionGroups(mod, false, _config.ReplaceNonAsciiOnImport);
|
saveService.SaveAllOptionGroups(mod, false, config.ReplaceNonAsciiOnImport);
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.GroupDeleted, mod, groupIdx, -1, -1);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.GroupDeleted, mod, groupIdx, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Move the index of a given option group. </summary>
|
/// <summary> Move the index of a given option group. </summary>
|
||||||
|
|
@ -142,8 +131,8 @@ public class ModOptionEditor
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UpdateSubModPositions(mod, Math.Min(groupIdxFrom, groupIdxTo));
|
UpdateSubModPositions(mod, Math.Min(groupIdxFrom, groupIdxTo));
|
||||||
_saveService.SaveAllOptionGroups(mod, false, _config.ReplaceNonAsciiOnImport);
|
saveService.SaveAllOptionGroups(mod, false, config.ReplaceNonAsciiOnImport);
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.GroupMoved, mod, groupIdxFrom, -1, groupIdxTo);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.GroupMoved, mod, groupIdxFrom, -1, groupIdxTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Change the description of the given option group. </summary>
|
/// <summary> Change the description of the given option group. </summary>
|
||||||
|
|
@ -159,8 +148,8 @@ public class ModOptionEditor
|
||||||
MultiModGroup m => m.Description = newDescription,
|
MultiModGroup m => m.Description = newDescription,
|
||||||
_ => newDescription,
|
_ => newDescription,
|
||||||
};
|
};
|
||||||
_saveService.QueueSave(new ModSaveGroup(mod, groupIdx, _config.ReplaceNonAsciiOnImport));
|
saveService.QueueSave(new ModSaveGroup(mod, groupIdx, config.ReplaceNonAsciiOnImport));
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.DisplayChange, mod, groupIdx, -1, -1);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.DisplayChange, mod, groupIdx, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Change the description of the given option. </summary>
|
/// <summary> Change the description of the given option. </summary>
|
||||||
|
|
@ -172,8 +161,8 @@ public class ModOptionEditor
|
||||||
return;
|
return;
|
||||||
|
|
||||||
s.Description = newDescription;
|
s.Description = newDescription;
|
||||||
_saveService.QueueSave(new ModSaveGroup(mod, groupIdx, _config.ReplaceNonAsciiOnImport));
|
saveService.QueueSave(new ModSaveGroup(mod, groupIdx, config.ReplaceNonAsciiOnImport));
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.DisplayChange, mod, groupIdx, optionIdx, -1);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.DisplayChange, mod, groupIdx, optionIdx, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Change the internal priority of the given option group. </summary>
|
/// <summary> Change the internal priority of the given option group. </summary>
|
||||||
|
|
@ -189,8 +178,8 @@ public class ModOptionEditor
|
||||||
MultiModGroup m => m.Priority = newPriority,
|
MultiModGroup m => m.Priority = newPriority,
|
||||||
_ => newPriority,
|
_ => newPriority,
|
||||||
};
|
};
|
||||||
_saveService.QueueSave(new ModSaveGroup(mod, groupIdx, _config.ReplaceNonAsciiOnImport));
|
saveService.QueueSave(new ModSaveGroup(mod, groupIdx, config.ReplaceNonAsciiOnImport));
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.PriorityChanged, mod, groupIdx, -1, -1);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.PriorityChanged, mod, groupIdx, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Change the internal priority of the given option. </summary>
|
/// <summary> Change the internal priority of the given option. </summary>
|
||||||
|
|
@ -206,8 +195,8 @@ public class ModOptionEditor
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m.PrioritizedOptions[optionIdx] = (m.PrioritizedOptions[optionIdx].Mod, newPriority);
|
m.PrioritizedOptions[optionIdx] = (m.PrioritizedOptions[optionIdx].Mod, newPriority);
|
||||||
_saveService.QueueSave(new ModSaveGroup(mod, groupIdx, _config.ReplaceNonAsciiOnImport));
|
saveService.QueueSave(new ModSaveGroup(mod, groupIdx, config.ReplaceNonAsciiOnImport));
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.PriorityChanged, mod, groupIdx, optionIdx, -1);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.PriorityChanged, mod, groupIdx, optionIdx, -1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -232,8 +221,8 @@ public class ModOptionEditor
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_saveService.QueueSave(new ModSaveGroup(mod, groupIdx, _config.ReplaceNonAsciiOnImport));
|
saveService.QueueSave(new ModSaveGroup(mod, groupIdx, config.ReplaceNonAsciiOnImport));
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.DisplayChange, mod, groupIdx, optionIdx, -1);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.DisplayChange, mod, groupIdx, optionIdx, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Add a new empty option of the given name for the given group. </summary>
|
/// <summary> Add a new empty option of the given name for the given group. </summary>
|
||||||
|
|
@ -252,8 +241,8 @@ public class ModOptionEditor
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_saveService.QueueSave(new ModSaveGroup(mod, groupIdx, _config.ReplaceNonAsciiOnImport));
|
saveService.QueueSave(new ModSaveGroup(mod, groupIdx, config.ReplaceNonAsciiOnImport));
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.OptionAdded, mod, groupIdx, group.Count - 1, -1);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.OptionAdded, mod, groupIdx, group.Count - 1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Add a new empty option of the given name for the given group if it does not exist already. </summary>
|
/// <summary> Add a new empty option of the given name for the given group if it does not exist already. </summary>
|
||||||
|
|
@ -298,15 +287,15 @@ public class ModOptionEditor
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_saveService.QueueSave(new ModSaveGroup(mod, groupIdx, _config.ReplaceNonAsciiOnImport));
|
saveService.QueueSave(new ModSaveGroup(mod, groupIdx, config.ReplaceNonAsciiOnImport));
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.OptionAdded, mod, groupIdx, group.Count - 1, -1);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.OptionAdded, mod, groupIdx, group.Count - 1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Delete the given option from the given group. </summary>
|
/// <summary> Delete the given option from the given group. </summary>
|
||||||
public void DeleteOption(Mod mod, int groupIdx, int optionIdx)
|
public void DeleteOption(Mod mod, int groupIdx, int optionIdx)
|
||||||
{
|
{
|
||||||
var group = mod.Groups[groupIdx];
|
var group = mod.Groups[groupIdx];
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.PrepareChange, mod, groupIdx, optionIdx, -1);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.PrepareChange, mod, groupIdx, optionIdx, -1);
|
||||||
switch (group)
|
switch (group)
|
||||||
{
|
{
|
||||||
case SingleModGroup s:
|
case SingleModGroup s:
|
||||||
|
|
@ -319,8 +308,8 @@ public class ModOptionEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
group.UpdatePositions(optionIdx);
|
group.UpdatePositions(optionIdx);
|
||||||
_saveService.QueueSave(new ModSaveGroup(mod, groupIdx, _config.ReplaceNonAsciiOnImport));
|
saveService.QueueSave(new ModSaveGroup(mod, groupIdx, config.ReplaceNonAsciiOnImport));
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.OptionDeleted, mod, groupIdx, optionIdx, -1);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.OptionDeleted, mod, groupIdx, optionIdx, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Move an option inside the given option group. </summary>
|
/// <summary> Move an option inside the given option group. </summary>
|
||||||
|
|
@ -330,8 +319,8 @@ public class ModOptionEditor
|
||||||
if (!group.MoveOption(optionIdxFrom, optionIdxTo))
|
if (!group.MoveOption(optionIdxFrom, optionIdxTo))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_saveService.QueueSave(new ModSaveGroup(mod, groupIdx, _config.ReplaceNonAsciiOnImport));
|
saveService.QueueSave(new ModSaveGroup(mod, groupIdx, config.ReplaceNonAsciiOnImport));
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.OptionMoved, mod, groupIdx, optionIdxFrom, optionIdxTo);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.OptionMoved, mod, groupIdx, optionIdxFrom, optionIdxTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Set the meta manipulations for a given option. Replaces existing manipulations. </summary>
|
/// <summary> Set the meta manipulations for a given option. Replaces existing manipulations. </summary>
|
||||||
|
|
@ -342,10 +331,10 @@ public class ModOptionEditor
|
||||||
&& subMod.Manipulations.All(m => manipulations.TryGetValue(m, out var old) && old.EntryEquals(m)))
|
&& subMod.Manipulations.All(m => manipulations.TryGetValue(m, out var old) && old.EntryEquals(m)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.PrepareChange, mod, groupIdx, optionIdx, -1);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.PrepareChange, mod, groupIdx, optionIdx, -1);
|
||||||
subMod.ManipulationData.SetTo(manipulations);
|
subMod.ManipulationData.SetTo(manipulations);
|
||||||
_saveService.QueueSave(new ModSaveGroup(mod, groupIdx, _config.ReplaceNonAsciiOnImport));
|
saveService.QueueSave(new ModSaveGroup(mod, groupIdx, config.ReplaceNonAsciiOnImport));
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.OptionMetaChanged, mod, groupIdx, optionIdx, -1);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.OptionMetaChanged, mod, groupIdx, optionIdx, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Set the file redirections for a given option. Replaces existing redirections. </summary>
|
/// <summary> Set the file redirections for a given option. Replaces existing redirections. </summary>
|
||||||
|
|
@ -355,10 +344,10 @@ public class ModOptionEditor
|
||||||
if (subMod.FileData.SetEquals(replacements))
|
if (subMod.FileData.SetEquals(replacements))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.PrepareChange, mod, groupIdx, optionIdx, -1);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.PrepareChange, mod, groupIdx, optionIdx, -1);
|
||||||
subMod.FileData.SetTo(replacements);
|
subMod.FileData.SetTo(replacements);
|
||||||
_saveService.QueueSave(new ModSaveGroup(mod, groupIdx, _config.ReplaceNonAsciiOnImport));
|
saveService.QueueSave(new ModSaveGroup(mod, groupIdx, config.ReplaceNonAsciiOnImport));
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.OptionFilesChanged, mod, groupIdx, optionIdx, -1);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.OptionFilesChanged, mod, groupIdx, optionIdx, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Add additional file redirections to a given option, keeping already existing ones. Only fires an event if anything is actually added.</summary>
|
/// <summary> Add additional file redirections to a given option, keeping already existing ones. Only fires an event if anything is actually added.</summary>
|
||||||
|
|
@ -369,8 +358,8 @@ public class ModOptionEditor
|
||||||
subMod.FileData.AddFrom(additions);
|
subMod.FileData.AddFrom(additions);
|
||||||
if (oldCount != subMod.FileData.Count)
|
if (oldCount != subMod.FileData.Count)
|
||||||
{
|
{
|
||||||
_saveService.QueueSave(new ModSaveGroup(mod, groupIdx, _config.ReplaceNonAsciiOnImport));
|
saveService.QueueSave(new ModSaveGroup(mod, groupIdx, config.ReplaceNonAsciiOnImport));
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.OptionFilesAdded, mod, groupIdx, optionIdx, -1);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.OptionFilesAdded, mod, groupIdx, optionIdx, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -381,10 +370,10 @@ public class ModOptionEditor
|
||||||
if (subMod.FileSwapData.SetEquals(swaps))
|
if (subMod.FileSwapData.SetEquals(swaps))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.PrepareChange, mod, groupIdx, optionIdx, -1);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.PrepareChange, mod, groupIdx, optionIdx, -1);
|
||||||
subMod.FileSwapData.SetTo(swaps);
|
subMod.FileSwapData.SetTo(swaps);
|
||||||
_saveService.QueueSave(new ModSaveGroup(mod, groupIdx, _config.ReplaceNonAsciiOnImport));
|
saveService.QueueSave(new ModSaveGroup(mod, groupIdx, config.ReplaceNonAsciiOnImport));
|
||||||
_communicator.ModOptionChanged.Invoke(ModOptionChangeType.OptionSwapsChanged, mod, groupIdx, optionIdx, -1);
|
communicator.ModOptionChanged.Invoke(ModOptionChangeType.OptionSwapsChanged, mod, groupIdx, optionIdx, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue