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