mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-15 13:14:17 +01:00
Tmp for Mod2
This commit is contained in:
parent
069ae772a5
commit
48e442a9fd
30 changed files with 697 additions and 252 deletions
53
Penumbra/Mods/Subclasses/ISubMod.cs
Normal file
53
Penumbra/Mods/Subclasses/ISubMod.cs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using Penumbra.GameData.ByteString;
|
||||
using Penumbra.Meta.Manipulations;
|
||||
|
||||
namespace Penumbra.Mods;
|
||||
|
||||
public interface ISubMod
|
||||
{
|
||||
public string Name { get; }
|
||||
|
||||
public IReadOnlyDictionary< Utf8GamePath, FullPath > Files { get; }
|
||||
public IReadOnlyDictionary< Utf8GamePath, FullPath > FileSwaps { get; }
|
||||
public IReadOnlySet< MetaManipulation > Manipulations { get; }
|
||||
|
||||
public static void WriteSubMod( JsonWriter j, JsonSerializer serializer, ISubMod mod, DirectoryInfo basePath, int? priority )
|
||||
{
|
||||
j.WriteStartObject();
|
||||
j.WritePropertyName( nameof( Name ) );
|
||||
j.WriteValue( mod.Name );
|
||||
if( priority != null )
|
||||
{
|
||||
j.WritePropertyName( nameof( IModGroup.Priority ) );
|
||||
j.WriteValue( priority.Value );
|
||||
}
|
||||
|
||||
j.WritePropertyName( nameof( mod.Files ) );
|
||||
j.WriteStartObject();
|
||||
foreach( var (gamePath, file) in mod.Files )
|
||||
{
|
||||
if( file.ToRelPath( basePath, out var relPath ) )
|
||||
{
|
||||
j.WritePropertyName( gamePath.ToString() );
|
||||
j.WriteValue( relPath.ToString() );
|
||||
}
|
||||
}
|
||||
|
||||
j.WriteEndObject();
|
||||
j.WritePropertyName( nameof( mod.FileSwaps ) );
|
||||
j.WriteStartObject();
|
||||
foreach( var (gamePath, file) in mod.FileSwaps )
|
||||
{
|
||||
j.WritePropertyName( gamePath.ToString() );
|
||||
j.WriteValue( file.ToString() );
|
||||
}
|
||||
|
||||
j.WriteEndObject();
|
||||
j.WritePropertyName( nameof( mod.Manipulations ) );
|
||||
serializer.Serialize( j, mod.Manipulations );
|
||||
j.WriteEndObject();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue