Make the limit of 32 options for a multi-select group explicit and handle it better.

This commit is contained in:
Ottermandias 2022-05-13 15:01:50 +02:00
parent 976f7840cd
commit a86a73bbf5
5 changed files with 73 additions and 37 deletions

View file

@ -15,6 +15,8 @@ public enum SelectType
public interface IModGroup : IEnumerable< ISubMod >
{
public const int MaxMultiOptions = 32;
public string Name { get; }
public string Description { get; }
public SelectType Type { get; }

View file

@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Dalamud.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OtterGui.Filesystem;
@ -57,6 +58,11 @@ public partial class Mod
{
foreach( var child in options.Children() )
{
if( ret.PrioritizedOptions.Count == IModGroup.MaxMultiOptions )
{
PluginLog.Warning($"Multi Group {ret.Name} has more than {IModGroup.MaxMultiOptions} options, ignoring excessive options." );
break;
}
var subMod = new SubMod();
subMod.Load( basePath, child, out var priority );
ret.PrioritizedOptions.Add( ( subMod, priority ) );

View file

@ -101,7 +101,7 @@ public class ModSettings
=> group.Type switch
{
SelectType.Single => ( uint )Math.Min( value, group.Count - 1 ),
SelectType.Multi => ( uint )( value & ( ( 1 << group.Count ) - 1 ) ),
SelectType.Multi => ( uint )( value & ( ( 1ul << group.Count ) - 1 ) ),
_ => value,
};