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