mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-01-02 05:43:42 +01:00
Use external library for API interface and IPC.
This commit is contained in:
parent
b3f048bfe6
commit
918d5db6a6
69 changed files with 4026 additions and 1873 deletions
|
|
@ -3,22 +3,17 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using OtterGui.Filesystem;
|
||||
using Penumbra.Api.Enums;
|
||||
|
||||
namespace Penumbra.Mods;
|
||||
|
||||
public enum SelectType
|
||||
{
|
||||
Single,
|
||||
Multi,
|
||||
}
|
||||
|
||||
public interface IModGroup : IEnumerable< ISubMod >
|
||||
{
|
||||
public const int MaxMultiOptions = 32;
|
||||
|
||||
public string Name { get; }
|
||||
public string Description { get; }
|
||||
public SelectType Type { get; }
|
||||
public GroupType Type { get; }
|
||||
public int Priority { get; }
|
||||
public uint DefaultSettings { get; set; }
|
||||
|
||||
|
|
@ -31,8 +26,8 @@ public interface IModGroup : IEnumerable< ISubMod >
|
|||
public bool IsOption
|
||||
=> Type switch
|
||||
{
|
||||
SelectType.Single => Count > 1,
|
||||
SelectType.Multi => Count > 0,
|
||||
GroupType.Single => Count > 1,
|
||||
GroupType.Multi => Count > 0,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
|
|
@ -90,7 +85,7 @@ public interface IModGroup : IEnumerable< ISubMod >
|
|||
j.WriteStartArray();
|
||||
for( var idx = 0; idx < group.Count; ++idx )
|
||||
{
|
||||
ISubMod.WriteSubMod( j, serializer, group[ idx ], basePath, group.Type == SelectType.Multi ? group.OptionPriority( idx ) : null );
|
||||
ISubMod.WriteSubMod( j, serializer, group[ idx ], basePath, group.Type == GroupType.Multi ? group.OptionPriority( idx ) : null );
|
||||
}
|
||||
|
||||
j.WriteEndArray();
|
||||
|
|
@ -98,7 +93,7 @@ public interface IModGroup : IEnumerable< ISubMod >
|
|||
Penumbra.Log.Debug( $"Saved group file {file} for group {groupIdx + 1}: {group.Name}." );
|
||||
}
|
||||
|
||||
public IModGroup Convert( SelectType type );
|
||||
public IModGroup Convert( GroupType type );
|
||||
public bool MoveOption( int optionIdxFrom, int optionIdxTo );
|
||||
public void UpdatePositions( int from = 0 );
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ using Newtonsoft.Json;
|
|||
using Newtonsoft.Json.Linq;
|
||||
using OtterGui;
|
||||
using OtterGui.Filesystem;
|
||||
using Penumbra.Api.Enums;
|
||||
|
||||
namespace Penumbra.Mods;
|
||||
|
||||
|
|
@ -15,8 +16,8 @@ public partial class Mod
|
|||
// Groups that allow all available options to be selected at once.
|
||||
private sealed class MultiModGroup : IModGroup
|
||||
{
|
||||
public SelectType Type
|
||||
=> SelectType.Multi;
|
||||
public GroupType Type
|
||||
=> GroupType.Multi;
|
||||
|
||||
public string Name { get; set; } = "Group";
|
||||
public string Description { get; set; } = "A non-exclusive group of settings.";
|
||||
|
|
@ -79,12 +80,12 @@ public partial class Mod
|
|||
return ret;
|
||||
}
|
||||
|
||||
public IModGroup Convert( SelectType type )
|
||||
public IModGroup Convert( GroupType type )
|
||||
{
|
||||
switch( type )
|
||||
{
|
||||
case SelectType.Multi: return this;
|
||||
case SelectType.Single:
|
||||
case GroupType.Multi: return this;
|
||||
case GroupType.Single:
|
||||
var multi = new SingleModGroup()
|
||||
{
|
||||
Name = Name,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using Newtonsoft.Json;
|
|||
using Newtonsoft.Json.Linq;
|
||||
using OtterGui;
|
||||
using OtterGui.Filesystem;
|
||||
using Penumbra.Api.Enums;
|
||||
|
||||
namespace Penumbra.Mods;
|
||||
|
||||
|
|
@ -14,8 +15,8 @@ public partial class Mod
|
|||
// Groups that allow only one of their available options to be selected.
|
||||
private sealed class SingleModGroup : IModGroup
|
||||
{
|
||||
public SelectType Type
|
||||
=> SelectType.Single;
|
||||
public GroupType Type
|
||||
=> GroupType.Single;
|
||||
|
||||
public string Name { get; set; } = "Option";
|
||||
public string Description { get; set; } = "A mutually exclusive group of settings.";
|
||||
|
|
@ -72,12 +73,12 @@ public partial class Mod
|
|||
return ret;
|
||||
}
|
||||
|
||||
public IModGroup Convert( SelectType type )
|
||||
public IModGroup Convert( GroupType type )
|
||||
{
|
||||
switch( type )
|
||||
{
|
||||
case SelectType.Single: return this;
|
||||
case SelectType.Multi:
|
||||
case GroupType.Single: return this;
|
||||
case GroupType.Multi:
|
||||
var multi = new MultiModGroup()
|
||||
{
|
||||
Name = Name,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||
using System.Numerics;
|
||||
using OtterGui;
|
||||
using OtterGui.Filesystem;
|
||||
using Penumbra.Api.Enums;
|
||||
|
||||
namespace Penumbra.Mods;
|
||||
|
||||
|
|
@ -56,8 +57,8 @@ public class ModSettings
|
|||
var config = Settings[ groupIdx ];
|
||||
Settings[ groupIdx ] = group.Type switch
|
||||
{
|
||||
SelectType.Single => ( uint )Math.Max( Math.Min( group.Count - 1, BitOperations.TrailingZeroCount( config ) ), 0 ),
|
||||
SelectType.Multi => 1u << ( int )config,
|
||||
GroupType.Single => ( uint )Math.Max( Math.Min( group.Count - 1, BitOperations.TrailingZeroCount( config ) ), 0 ),
|
||||
GroupType.Multi => 1u << ( int )config,
|
||||
_ => config,
|
||||
};
|
||||
return config != Settings[ groupIdx ];
|
||||
|
|
@ -70,8 +71,8 @@ public class ModSettings
|
|||
var config = Settings[ groupIdx ];
|
||||
Settings[ groupIdx ] = group.Type switch
|
||||
{
|
||||
SelectType.Single => config >= optionIdx ? config > 1 ? config - 1 : 0 : config,
|
||||
SelectType.Multi => Functions.RemoveBit( config, optionIdx ),
|
||||
GroupType.Single => config >= optionIdx ? config > 1 ? config - 1 : 0 : config,
|
||||
GroupType.Multi => Functions.RemoveBit( config, optionIdx ),
|
||||
_ => config,
|
||||
};
|
||||
return config != Settings[ groupIdx ];
|
||||
|
|
@ -87,8 +88,8 @@ public class ModSettings
|
|||
var config = Settings[ groupIdx ];
|
||||
Settings[ groupIdx ] = group.Type switch
|
||||
{
|
||||
SelectType.Single => config == optionIdx ? ( uint )movedToIdx : config,
|
||||
SelectType.Multi => Functions.MoveBit( config, optionIdx, movedToIdx ),
|
||||
GroupType.Single => config == optionIdx ? ( uint )movedToIdx : config,
|
||||
GroupType.Multi => Functions.MoveBit( config, optionIdx, movedToIdx ),
|
||||
_ => config,
|
||||
};
|
||||
return config != Settings[ groupIdx ];
|
||||
|
|
@ -101,8 +102,8 @@ public class ModSettings
|
|||
private static uint FixSetting( IModGroup group, uint value )
|
||||
=> group.Type switch
|
||||
{
|
||||
SelectType.Single => ( uint )Math.Min( value, group.Count - 1 ),
|
||||
SelectType.Multi => ( uint )( value & ( ( 1ul << group.Count ) - 1 ) ),
|
||||
GroupType.Single => ( uint )Math.Min( value, group.Count - 1 ),
|
||||
GroupType.Multi => ( uint )( value & ( ( 1ul << group.Count ) - 1 ) ),
|
||||
_ => value,
|
||||
};
|
||||
|
||||
|
|
@ -202,7 +203,7 @@ public class ModSettings
|
|||
}
|
||||
|
||||
var group = mod.Groups[ idx ];
|
||||
if( group.Type == SelectType.Single && setting < group.Count )
|
||||
if( group.Type == GroupType.Single && setting < group.Count )
|
||||
{
|
||||
dict.Add( group.Name, new[] { group[ ( int )setting ].Name } );
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue