mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-02-18 05:47:52 +01:00
Make line endings explicit in editorconfig and share in sub projects, also apply editorconfig everywhere and move some namespaces.
This commit is contained in:
parent
53adb6fa54
commit
2b4a01df06
155 changed files with 1620 additions and 1614 deletions
|
|
@ -1,58 +1,57 @@
|
|||
using Newtonsoft.Json;
|
||||
using Penumbra.Meta.Manipulations;
|
||||
using Penumbra.Mods.Subclasses;
|
||||
using Penumbra.String.Classes;
|
||||
|
||||
namespace Penumbra.Mods;
|
||||
namespace Penumbra.Mods.Subclasses;
|
||||
|
||||
public interface ISubMod
|
||||
{
|
||||
public string Name { get; }
|
||||
public string FullName { get; }
|
||||
public string Name { get; }
|
||||
public string FullName { get; }
|
||||
public string Description { get; }
|
||||
|
||||
public IReadOnlyDictionary< Utf8GamePath, FullPath > Files { get; }
|
||||
public IReadOnlyDictionary< Utf8GamePath, FullPath > FileSwaps { get; }
|
||||
public IReadOnlySet< MetaManipulation > Manipulations { get; }
|
||||
public IReadOnlyDictionary<Utf8GamePath, FullPath> Files { get; }
|
||||
public IReadOnlyDictionary<Utf8GamePath, FullPath> FileSwaps { get; }
|
||||
public IReadOnlySet<MetaManipulation> Manipulations { get; }
|
||||
|
||||
public bool IsDefault { get; }
|
||||
|
||||
public static void WriteSubMod( JsonWriter j, JsonSerializer serializer, ISubMod mod, DirectoryInfo basePath, int? priority )
|
||||
public static void WriteSubMod(JsonWriter j, JsonSerializer serializer, ISubMod mod, DirectoryInfo basePath, int? priority)
|
||||
{
|
||||
j.WriteStartObject();
|
||||
j.WritePropertyName( nameof( Name ) );
|
||||
j.WriteValue( mod.Name );
|
||||
j.WritePropertyName( nameof(Description) );
|
||||
j.WriteValue( mod.Description );
|
||||
if( priority != null )
|
||||
j.WritePropertyName(nameof(Name));
|
||||
j.WriteValue(mod.Name);
|
||||
j.WritePropertyName(nameof(Description));
|
||||
j.WriteValue(mod.Description);
|
||||
if (priority != null)
|
||||
{
|
||||
j.WritePropertyName( nameof( IModGroup.Priority ) );
|
||||
j.WriteValue( priority.Value );
|
||||
j.WritePropertyName(nameof(IModGroup.Priority));
|
||||
j.WriteValue(priority.Value);
|
||||
}
|
||||
|
||||
j.WritePropertyName( nameof( mod.Files ) );
|
||||
j.WritePropertyName(nameof(mod.Files));
|
||||
j.WriteStartObject();
|
||||
foreach( var (gamePath, file) in mod.Files )
|
||||
foreach (var (gamePath, file) in mod.Files)
|
||||
{
|
||||
if( file.ToRelPath( basePath, out var relPath ) )
|
||||
if (file.ToRelPath(basePath, out var relPath))
|
||||
{
|
||||
j.WritePropertyName( gamePath.ToString() );
|
||||
j.WriteValue( relPath.ToString() );
|
||||
j.WritePropertyName(gamePath.ToString());
|
||||
j.WriteValue(relPath.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
j.WriteEndObject();
|
||||
j.WritePropertyName( nameof( mod.FileSwaps ) );
|
||||
j.WritePropertyName(nameof(mod.FileSwaps));
|
||||
j.WriteStartObject();
|
||||
foreach( var (gamePath, file) in mod.FileSwaps )
|
||||
foreach (var (gamePath, file) in mod.FileSwaps)
|
||||
{
|
||||
j.WritePropertyName( gamePath.ToString() );
|
||||
j.WriteValue( file.ToString() );
|
||||
j.WritePropertyName(gamePath.ToString());
|
||||
j.WriteValue(file.ToString());
|
||||
}
|
||||
|
||||
j.WriteEndObject();
|
||||
j.WritePropertyName( nameof( mod.Manipulations ) );
|
||||
serializer.Serialize( j, mod.Manipulations );
|
||||
j.WritePropertyName(nameof(mod.Manipulations));
|
||||
serializer.Serialize(j, mod.Manipulations);
|
||||
j.WriteEndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,9 @@ using OtterGui.Filesystem;
|
|||
using Penumbra.Api.Enums;
|
||||
using Penumbra.Meta.Manipulations;
|
||||
using Penumbra.Mods.Manager;
|
||||
using Penumbra.Mods.Subclasses;
|
||||
using Penumbra.String.Classes;
|
||||
|
||||
namespace Penumbra.Mods;
|
||||
namespace Penumbra.Mods.Subclasses;
|
||||
|
||||
/// <summary> Contains the settings for a given mod. </summary>
|
||||
public class ModSettings
|
||||
|
|
@ -267,4 +266,4 @@ public class ModSettings
|
|||
|
||||
return ( Enabled, Priority, dict );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,9 @@ using Newtonsoft.Json.Linq;
|
|||
using OtterGui;
|
||||
using OtterGui.Filesystem;
|
||||
using Penumbra.Api.Enums;
|
||||
using Penumbra.Mods.Subclasses;
|
||||
|
||||
namespace Penumbra.Mods;
|
||||
|
||||
namespace Penumbra.Mods.Subclasses;
|
||||
|
||||
/// <summary> Groups that allow all available options to be selected at once. </summary>
|
||||
public sealed class MultiModGroup : IModGroup
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,9 +3,8 @@ using Newtonsoft.Json.Linq;
|
|||
using OtterGui;
|
||||
using OtterGui.Filesystem;
|
||||
using Penumbra.Api.Enums;
|
||||
using Penumbra.Mods.Subclasses;
|
||||
|
||||
namespace Penumbra.Mods;
|
||||
namespace Penumbra.Mods.Subclasses;
|
||||
|
||||
/// <summary> Groups that allow only one of their available options to be selected. </summary>
|
||||
public sealed class SingleModGroup : IModGroup
|
||||
|
|
@ -18,59 +17,55 @@ 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 = new();
|
||||
|
||||
public int OptionPriority( Index _ )
|
||||
public int OptionPriority(Index _)
|
||||
=> Priority;
|
||||
|
||||
public ISubMod this[ Index idx ]
|
||||
=> OptionData[ idx ];
|
||||
public ISubMod this[Index idx]
|
||||
=> OptionData[idx];
|
||||
|
||||
[JsonIgnore]
|
||||
public int Count
|
||||
=> OptionData.Count;
|
||||
|
||||
public IEnumerator< ISubMod > GetEnumerator()
|
||||
public IEnumerator<ISubMod> GetEnumerator()
|
||||
=> OptionData.GetEnumerator();
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
=> GetEnumerator();
|
||||
|
||||
public static SingleModGroup? Load( Mod mod, JObject json, int groupIdx )
|
||||
public static SingleModGroup? Load(Mod mod, JObject json, int groupIdx)
|
||||
{
|
||||
var options = json[ "Options" ];
|
||||
var options = json["Options"];
|
||||
var ret = new SingleModGroup
|
||||
{
|
||||
Name = json[ nameof( Name ) ]?.ToObject< string >() ?? string.Empty,
|
||||
Description = json[ nameof( Description ) ]?.ToObject< string >() ?? string.Empty,
|
||||
Priority = json[ nameof( Priority ) ]?.ToObject< int >() ?? 0,
|
||||
DefaultSettings = json[ nameof( DefaultSettings ) ]?.ToObject< uint >() ?? 0u,
|
||||
Name = json[nameof(Name)]?.ToObject<string>() ?? string.Empty,
|
||||
Description = json[nameof(Description)]?.ToObject<string>() ?? string.Empty,
|
||||
Priority = json[nameof(Priority)]?.ToObject<int>() ?? 0,
|
||||
DefaultSettings = json[nameof(DefaultSettings)]?.ToObject<uint>() ?? 0u,
|
||||
};
|
||||
if( ret.Name.Length == 0 )
|
||||
{
|
||||
if (ret.Name.Length == 0)
|
||||
return null;
|
||||
}
|
||||
|
||||
if( options != null )
|
||||
{
|
||||
foreach( var child in options.Children() )
|
||||
if (options != null)
|
||||
foreach (var child in options.Children())
|
||||
{
|
||||
var subMod = new SubMod( mod );
|
||||
subMod.SetPosition( groupIdx, ret.OptionData.Count );
|
||||
subMod.Load( mod.ModPath, child, out _ );
|
||||
ret.OptionData.Add( subMod );
|
||||
var subMod = new SubMod(mod);
|
||||
subMod.SetPosition(groupIdx, ret.OptionData.Count);
|
||||
subMod.Load(mod.ModPath, child, out _);
|
||||
ret.OptionData.Add(subMod);
|
||||
}
|
||||
}
|
||||
|
||||
if( ( int )ret.DefaultSettings >= ret.Count )
|
||||
if ((int)ret.DefaultSettings >= ret.Count)
|
||||
ret.DefaultSettings = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public IModGroup Convert( GroupType type )
|
||||
public IModGroup Convert(GroupType type)
|
||||
{
|
||||
switch( type )
|
||||
switch (type)
|
||||
{
|
||||
case GroupType.Single: return this;
|
||||
case GroupType.Multi:
|
||||
|
|
@ -79,47 +74,41 @@ public sealed class SingleModGroup : IModGroup
|
|||
Name = Name,
|
||||
Description = Description,
|
||||
Priority = Priority,
|
||||
DefaultSettings = 1u << ( int )DefaultSettings,
|
||||
DefaultSettings = 1u << (int)DefaultSettings,
|
||||
};
|
||||
multi.PrioritizedOptions.AddRange( OptionData.Select( ( o, i ) => ( o, i ) ) );
|
||||
multi.PrioritizedOptions.AddRange(OptionData.Select((o, i) => (o, i)));
|
||||
return multi;
|
||||
default: throw new ArgumentOutOfRangeException( nameof( type ), type, null );
|
||||
default: throw new ArgumentOutOfRangeException(nameof(type), type, null);
|
||||
}
|
||||
}
|
||||
|
||||
public bool MoveOption( int optionIdxFrom, int optionIdxTo )
|
||||
public bool MoveOption(int optionIdxFrom, int optionIdxTo)
|
||||
{
|
||||
if( !OptionData.Move( optionIdxFrom, optionIdxTo ) )
|
||||
{
|
||||
if (!OptionData.Move(optionIdxFrom, optionIdxTo))
|
||||
return false;
|
||||
}
|
||||
|
||||
// Update default settings with the move.
|
||||
if( DefaultSettings == optionIdxFrom )
|
||||
if (DefaultSettings == optionIdxFrom)
|
||||
{
|
||||
DefaultSettings = ( uint )optionIdxTo;
|
||||
DefaultSettings = (uint)optionIdxTo;
|
||||
}
|
||||
else if( optionIdxFrom < optionIdxTo )
|
||||
else if (optionIdxFrom < optionIdxTo)
|
||||
{
|
||||
if( DefaultSettings > optionIdxFrom && DefaultSettings <= optionIdxTo )
|
||||
{
|
||||
if (DefaultSettings > optionIdxFrom && DefaultSettings <= optionIdxTo)
|
||||
--DefaultSettings;
|
||||
}
|
||||
}
|
||||
else if( DefaultSettings < optionIdxFrom && DefaultSettings >= optionIdxTo )
|
||||
else if (DefaultSettings < optionIdxFrom && DefaultSettings >= optionIdxTo)
|
||||
{
|
||||
++DefaultSettings;
|
||||
}
|
||||
|
||||
UpdatePositions( Math.Min( optionIdxFrom, optionIdxTo ) );
|
||||
UpdatePositions(Math.Min(optionIdxFrom, optionIdxTo));
|
||||
return true;
|
||||
}
|
||||
|
||||
public void UpdatePositions( int from = 0 )
|
||||
public void UpdatePositions(int from = 0)
|
||||
{
|
||||
foreach( var (o, i) in OptionData.WithIndex().Skip( from ) )
|
||||
{
|
||||
o.SetPosition( o.GroupIdx, i );
|
||||
}
|
||||
foreach (var (o, i) in OptionData.WithIndex().Skip(from))
|
||||
o.SetPosition(o.GroupIdx, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
using Newtonsoft.Json.Linq;
|
||||
using Penumbra.Import;
|
||||
using Penumbra.Meta;
|
||||
using Penumbra.Meta.Manipulations;
|
||||
using Penumbra.Mods.Subclasses;
|
||||
using Penumbra.String.Classes;
|
||||
|
||||
namespace Penumbra.Mods;
|
||||
namespace Penumbra.Mods.Subclasses;
|
||||
|
||||
/// <summary>
|
||||
/// A sub mod is a collection of
|
||||
Loading…
Add table
Add a link
Reference in a new issue