mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Fix issue with ImcGroup settings and IPC.
This commit is contained in:
parent
102e7335a7
commit
de0309bfa7
3 changed files with 18 additions and 19 deletions
|
|
@ -77,10 +77,10 @@ public class ModSettingsApi : IPenumbraApiModSettings, IApiService, IDisposable
|
|||
if (!_collectionManager.Storage.ById(collectionId, out var collection))
|
||||
return (PenumbraApiEc.CollectionMissing, null);
|
||||
|
||||
var settings = collection.Id == Guid.Empty
|
||||
? null
|
||||
: ignoreInheritance
|
||||
? collection.Settings[mod.Index]
|
||||
var settings = collection.Id == Guid.Empty
|
||||
? null
|
||||
: ignoreInheritance
|
||||
? collection.Settings[mod.Index]
|
||||
: collection[mod.Index].Settings;
|
||||
if (settings == null)
|
||||
return (PenumbraApiEc.Success, null);
|
||||
|
|
@ -160,11 +160,11 @@ public class ModSettingsApi : IPenumbraApiModSettings, IApiService, IDisposable
|
|||
if (optionIdx < 0)
|
||||
return ApiHelpers.Return(PenumbraApiEc.OptionMissing, args);
|
||||
|
||||
var setting = mod.Groups[groupIdx] switch
|
||||
var setting = mod.Groups[groupIdx].Behaviour switch
|
||||
{
|
||||
MultiModGroup => Setting.Multi(optionIdx),
|
||||
SingleModGroup => Setting.Single(optionIdx),
|
||||
_ => Setting.Zero,
|
||||
GroupDrawBehaviour.MultiSelection => Setting.Multi(optionIdx),
|
||||
GroupDrawBehaviour.SingleSelection => Setting.Single(optionIdx),
|
||||
_ => Setting.Zero,
|
||||
};
|
||||
var ret = _collectionEditor.SetModSetting(collection, mod, groupIdx, setting)
|
||||
? PenumbraApiEc.Success
|
||||
|
|
@ -191,20 +191,20 @@ public class ModSettingsApi : IPenumbraApiModSettings, IApiService, IDisposable
|
|||
var setting = Setting.Zero;
|
||||
switch (mod.Groups[groupIdx])
|
||||
{
|
||||
case SingleModGroup single:
|
||||
case { Behaviour: GroupDrawBehaviour.SingleSelection } single:
|
||||
{
|
||||
var optionIdx = optionNames.Count == 0 ? -1 : single.OptionData.IndexOf(o => o.Name == optionNames[^1]);
|
||||
var optionIdx = optionNames.Count == 0 ? -1 : single.Options.IndexOf(o => o.Name == optionNames[^1]);
|
||||
if (optionIdx < 0)
|
||||
return ApiHelpers.Return(PenumbraApiEc.OptionMissing, args);
|
||||
|
||||
setting = Setting.Single(optionIdx);
|
||||
break;
|
||||
}
|
||||
case MultiModGroup multi:
|
||||
case { Behaviour: GroupDrawBehaviour.MultiSelection } multi:
|
||||
{
|
||||
foreach (var name in optionNames)
|
||||
{
|
||||
var optionIdx = multi.OptionData.IndexOf(o => o.Mod.Name == name);
|
||||
var optionIdx = multi.Options.IndexOf(o => o.Name == name);
|
||||
if (optionIdx < 0)
|
||||
return ApiHelpers.Return(PenumbraApiEc.OptionMissing, args);
|
||||
|
||||
|
|
@ -256,7 +256,8 @@ public class ModSettingsApi : IPenumbraApiModSettings, IApiService, IDisposable
|
|||
private void OnModSettingChange(ModCollection collection, ModSettingChange type, Mod? mod, Setting _1, int _2, bool inherited)
|
||||
=> ModSettingChanged?.Invoke(type, collection.Id, mod?.ModPath.Name ?? string.Empty, inherited);
|
||||
|
||||
private void OnModOptionEdited(ModOptionChangeType type, Mod mod, IModGroup? group, IModOption? option, IModDataContainer? container, int moveIndex)
|
||||
private void OnModOptionEdited(ModOptionChangeType type, Mod mod, IModGroup? group, IModOption? option, IModDataContainer? container,
|
||||
int moveIndex)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ public class ModDataEditor(SaveService saveService, CommunicatorService communic
|
|||
var save = true;
|
||||
if (File.Exists(dataFile))
|
||||
{
|
||||
save = false;
|
||||
try
|
||||
{
|
||||
var text = File.ReadAllText(dataFile);
|
||||
|
|
@ -60,6 +59,7 @@ public class ModDataEditor(SaveService saveService, CommunicatorService communic
|
|||
favorite = json[nameof(Mod.Favorite)]?.Value<bool>() ?? favorite;
|
||||
note = json[nameof(Mod.Note)]?.Value<string>() ?? note;
|
||||
localTags = json[nameof(Mod.LocalTags)]?.Values<string>().OfType<string>() ?? localTags;
|
||||
save = false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
@ -239,7 +239,6 @@ public class ModDataEditor(SaveService saveService, CommunicatorService communic
|
|||
|
||||
mod.Favorite = state;
|
||||
saveService.QueueSave(new ModLocalData(mod));
|
||||
;
|
||||
communicatorService.ModDataChanged.Invoke(ModDataChangeType.Favorite, mod, null);
|
||||
}
|
||||
|
||||
|
|
@ -250,7 +249,6 @@ public class ModDataEditor(SaveService saveService, CommunicatorService communic
|
|||
|
||||
mod.Note = newNote;
|
||||
saveService.QueueSave(new ModLocalData(mod));
|
||||
;
|
||||
communicatorService.ModDataChanged.Invoke(ModDataChangeType.Favorite, mod, null);
|
||||
}
|
||||
|
||||
|
|
@ -260,7 +258,7 @@ public class ModDataEditor(SaveService saveService, CommunicatorService communic
|
|||
if (tagIdx < 0 || tagIdx > which.Count)
|
||||
return;
|
||||
|
||||
ModDataChangeType flags = 0;
|
||||
ModDataChangeType flags;
|
||||
if (tagIdx == which.Count)
|
||||
{
|
||||
flags = ModLocalData.UpdateTags(mod, local ? null : which.Append(newTag), local ? which.Append(newTag) : null);
|
||||
|
|
|
|||
|
|
@ -185,10 +185,10 @@ public class ModSettings
|
|||
|
||||
switch (mod.Groups[idx])
|
||||
{
|
||||
case SingleModGroup single when setting.Value < (ulong)single.Options.Count:
|
||||
case { Behaviour: GroupDrawBehaviour.SingleSelection } single when setting.Value < (ulong)single.Options.Count:
|
||||
dict.Add(single.Name, [single.Options[setting.AsIndex].Name]);
|
||||
break;
|
||||
case MultiModGroup multi:
|
||||
case { Behaviour: GroupDrawBehaviour.MultiSelection } multi:
|
||||
var list = multi.Options.WithIndex().Where(p => setting.HasFlag(p.Index)).Select(p => p.Value.Name).ToList();
|
||||
dict.Add(multi.Name, list);
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue