mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-13 12:14:17 +01:00
Fix exception with empty option groups.
This commit is contained in:
parent
4610686a70
commit
a5f0c2f943
2 changed files with 87 additions and 95 deletions
|
|
@ -48,6 +48,7 @@ public class ModSettings
|
|||
{
|
||||
if (group.Type is GroupType.Single)
|
||||
{
|
||||
if (group.Count > 0)
|
||||
AddOption(group[(int)settings.Settings[index]]);
|
||||
}
|
||||
else
|
||||
|
|
@ -55,12 +56,10 @@ public class ModSettings
|
|||
foreach (var (option, optionIdx) in group.WithIndex().OrderByDescending(o => group.OptionPriority(o.Index)))
|
||||
{
|
||||
if (((settings.Settings[index] >> optionIdx) & 1) == 1)
|
||||
{
|
||||
AddOption(option);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AddOption(mod.Default);
|
||||
return (dict, set);
|
||||
|
|
@ -68,16 +67,12 @@ public class ModSettings
|
|||
void AddOption(ISubMod option)
|
||||
{
|
||||
foreach (var (path, file) in option.Files.Concat(option.FileSwaps))
|
||||
{
|
||||
dict.TryAdd(path, file);
|
||||
}
|
||||
|
||||
foreach (var manip in option.Manipulations)
|
||||
{
|
||||
set.Add(manip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Automatically react to changes in a mods available options.
|
||||
public bool HandleChanges(ModOptionChangeType type, Mod mod, int groupIdx, int optionIdx, int movedToIdx)
|
||||
|
|
@ -196,10 +191,8 @@ public class ModSettings
|
|||
settings.AddMissingSettings(mod);
|
||||
|
||||
foreach (var (group, setting) in mod.Groups.Zip(settings.Settings))
|
||||
{
|
||||
Settings.Add(group.Name, setting);
|
||||
}
|
||||
}
|
||||
|
||||
// Convert and fix.
|
||||
public bool ToSettings(Mod mod, out ModSettings settings)
|
||||
|
|
@ -214,10 +207,8 @@ public class ModSettings
|
|||
var actualConfig = FixSetting(group, castConfig);
|
||||
list.Add(actualConfig);
|
||||
if (actualConfig != config)
|
||||
{
|
||||
changes = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Add(0);
|
||||
|
|
@ -244,14 +235,15 @@ public class ModSettings
|
|||
foreach (var (setting, idx) in Settings.WithIndex())
|
||||
{
|
||||
if (idx >= mod.Groups.Count)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var group = mod.Groups[idx];
|
||||
if (group.Type == GroupType.Single && setting < group.Count)
|
||||
{
|
||||
dict.Add( group.Name, new[] { group[ ( int )setting ].Name } );
|
||||
dict.Add(group.Name, new[]
|
||||
{
|
||||
group[(int)setting].Name,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public sealed class SingleModGroup : IModGroup
|
|||
public int Priority { get; set; }
|
||||
public uint DefaultSettings { get; set; }
|
||||
|
||||
public readonly List<SubMod> OptionData = new();
|
||||
public readonly List<SubMod> OptionData = [];
|
||||
|
||||
public int OptionPriority(Index _)
|
||||
=> Priority;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue