mirror of
https://github.com/xivdev/Penumbra.git
synced 2026-01-02 13:53:42 +01:00
More cleanup.
This commit is contained in:
parent
72db023804
commit
0fd14ffefc
6 changed files with 89 additions and 129 deletions
|
|
@ -1,4 +1,3 @@
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using Penumbra.Meta.Manipulations;
|
using Penumbra.Meta.Manipulations;
|
||||||
using Penumbra.Mods.Editor;
|
using Penumbra.Mods.Editor;
|
||||||
using Penumbra.Mods.Groups;
|
using Penumbra.Mods.Groups;
|
||||||
|
|
@ -25,6 +24,12 @@ public class DefaultSubMod(IMod mod) : IModDataContainer
|
||||||
public void AddTo(Dictionary<Utf8GamePath, FullPath> redirections, HashSet<MetaManipulation> manipulations)
|
public void AddTo(Dictionary<Utf8GamePath, FullPath> redirections, HashSet<MetaManipulation> manipulations)
|
||||||
=> SubModHelpers.AddContainerTo(this, redirections, manipulations);
|
=> SubModHelpers.AddContainerTo(this, redirections, manipulations);
|
||||||
|
|
||||||
|
public string GetName()
|
||||||
|
=> FullName;
|
||||||
|
|
||||||
|
public string GetFullName()
|
||||||
|
=> FullName;
|
||||||
|
|
||||||
public (int GroupIndex, int DataIndex) GetDataIndices()
|
public (int GroupIndex, int DataIndex) GetDataIndices()
|
||||||
=> (-1, 0);
|
=> (-1, 0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,24 +15,7 @@ public interface IModDataContainer
|
||||||
public Dictionary<Utf8GamePath, FullPath> FileSwaps { get; set; }
|
public Dictionary<Utf8GamePath, FullPath> FileSwaps { get; set; }
|
||||||
public HashSet<MetaManipulation> Manipulations { get; set; }
|
public HashSet<MetaManipulation> Manipulations { get; set; }
|
||||||
|
|
||||||
public string GetName()
|
public string GetName();
|
||||||
=> this switch
|
public string GetFullName();
|
||||||
{
|
|
||||||
IModOption o => o.FullName,
|
|
||||||
DefaultSubMod => DefaultSubMod.FullName,
|
|
||||||
_ => $"Container {GetDataIndices().DataIndex + 1}",
|
|
||||||
};
|
|
||||||
|
|
||||||
public string GetFullName()
|
|
||||||
=> this switch
|
|
||||||
{
|
|
||||||
IModOption o => o.FullName,
|
|
||||||
DefaultSubMod => DefaultSubMod.FullName,
|
|
||||||
_ when Group != null => $"{Group.Name}: Container {GetDataIndices().DataIndex + 1}",
|
|
||||||
_ => $"Container {GetDataIndices().DataIndex + 1}",
|
|
||||||
};
|
|
||||||
|
|
||||||
public (int GroupIndex, int DataIndex) GetDataIndices();
|
public (int GroupIndex, int DataIndex) GetDataIndices();
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IModDataOption : IModOption, IModDataContainer;
|
|
||||||
|
|
|
||||||
|
|
@ -1,37 +1,13 @@
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using OtterGui;
|
|
||||||
using Penumbra.Meta.Manipulations;
|
|
||||||
using Penumbra.Mods.Editor;
|
|
||||||
using Penumbra.Mods.Groups;
|
using Penumbra.Mods.Groups;
|
||||||
using Penumbra.Mods.Settings;
|
using Penumbra.Mods.Settings;
|
||||||
using Penumbra.String.Classes;
|
|
||||||
|
namespace Penumbra.Mods.SubMods;
|
||||||
namespace Penumbra.Mods.SubMods;
|
|
||||||
|
public class MultiSubMod(Mod mod, MultiModGroup group) : OptionSubMod<MultiModGroup>(mod, group)
|
||||||
public class MultiSubMod(Mod mod, MultiModGroup group) : IModDataOption
|
|
||||||
{
|
{
|
||||||
internal readonly Mod Mod = mod;
|
|
||||||
internal readonly MultiModGroup Group = group;
|
|
||||||
|
|
||||||
public string Name { get; set; } = "Option";
|
|
||||||
|
|
||||||
public string FullName
|
|
||||||
=> $"{Group.Name}: {Name}";
|
|
||||||
|
|
||||||
public string Description { get; set; } = string.Empty;
|
|
||||||
public ModPriority Priority { get; set; } = ModPriority.Default;
|
public ModPriority Priority { get; set; } = ModPriority.Default;
|
||||||
|
|
||||||
public Dictionary<Utf8GamePath, FullPath> Files { get; set; } = [];
|
|
||||||
public Dictionary<Utf8GamePath, FullPath> FileSwaps { get; set; } = [];
|
|
||||||
public HashSet<MetaManipulation> Manipulations { get; set; } = [];
|
|
||||||
|
|
||||||
IMod IModDataContainer.Mod
|
|
||||||
=> Mod;
|
|
||||||
|
|
||||||
IModGroup IModDataContainer.Group
|
|
||||||
=> Group;
|
|
||||||
|
|
||||||
|
|
||||||
public MultiSubMod(Mod mod, MultiModGroup group, JToken json)
|
public MultiSubMod(Mod mod, MultiModGroup group, JToken json)
|
||||||
: this(mod, group)
|
: this(mod, group)
|
||||||
{
|
{
|
||||||
|
|
@ -44,9 +20,9 @@ public class MultiSubMod(Mod mod, MultiModGroup group) : IModDataOption
|
||||||
{
|
{
|
||||||
var ret = new MultiSubMod(mod, group)
|
var ret = new MultiSubMod(mod, group)
|
||||||
{
|
{
|
||||||
Name = Name,
|
Name = Name,
|
||||||
Description = Description,
|
Description = Description,
|
||||||
Priority = Priority,
|
Priority = Priority,
|
||||||
};
|
};
|
||||||
SubModHelpers.Clone(this, ret);
|
SubModHelpers.Clone(this, ret);
|
||||||
|
|
||||||
|
|
@ -57,36 +33,18 @@ public class MultiSubMod(Mod mod, MultiModGroup group) : IModDataOption
|
||||||
{
|
{
|
||||||
var ret = new SingleSubMod(mod, group)
|
var ret = new SingleSubMod(mod, group)
|
||||||
{
|
{
|
||||||
Name = Name,
|
Name = Name,
|
||||||
Description = Description,
|
Description = Description,
|
||||||
};
|
};
|
||||||
SubModHelpers.Clone(this, ret);
|
SubModHelpers.Clone(this, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddDataTo(Dictionary<Utf8GamePath, FullPath> redirections, HashSet<MetaManipulation> manipulations)
|
|
||||||
=> SubModHelpers.AddContainerTo(this, redirections, manipulations);
|
|
||||||
|
|
||||||
public static MultiSubMod CreateForSaving(string name, string description, ModPriority priority)
|
public static MultiSubMod CreateForSaving(string name, string description, ModPriority priority)
|
||||||
=> new(null!, null!)
|
=> new(null!, null!)
|
||||||
{
|
{
|
||||||
Name = name,
|
Name = name,
|
||||||
Description = description,
|
Description = description,
|
||||||
Priority = priority,
|
Priority = priority,
|
||||||
};
|
};
|
||||||
|
}
|
||||||
public (int GroupIndex, int DataIndex) GetDataIndices()
|
|
||||||
=> (Group.GetIndex(), GetDataIndex());
|
|
||||||
|
|
||||||
public (int GroupIndex, int OptionIndex) GetOptionIndices()
|
|
||||||
=> (Group.GetIndex(), GetDataIndex());
|
|
||||||
|
|
||||||
private int GetDataIndex()
|
|
||||||
{
|
|
||||||
var dataIndex = Group.DataContainers.IndexOf(this);
|
|
||||||
if (dataIndex < 0)
|
|
||||||
throw new Exception($"Group {Group.Name} from SubMod {Name} does not contain this SubMod.");
|
|
||||||
|
|
||||||
return dataIndex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
57
Penumbra/Mods/SubMods/OptionSubMod.cs
Normal file
57
Penumbra/Mods/SubMods/OptionSubMod.cs
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
using OtterGui;
|
||||||
|
using Penumbra.Meta.Manipulations;
|
||||||
|
using Penumbra.Mods.Editor;
|
||||||
|
using Penumbra.Mods.Groups;
|
||||||
|
using Penumbra.String.Classes;
|
||||||
|
|
||||||
|
namespace Penumbra.Mods.SubMods;
|
||||||
|
|
||||||
|
public interface IModDataOption : IModDataContainer, IModOption;
|
||||||
|
|
||||||
|
public abstract class OptionSubMod<T>(Mod mod, T group) : IModDataOption
|
||||||
|
where T : IModGroup
|
||||||
|
{
|
||||||
|
internal readonly Mod Mod = mod;
|
||||||
|
internal readonly IModGroup Group = group;
|
||||||
|
|
||||||
|
public string Name { get; set; } = "Option";
|
||||||
|
|
||||||
|
public string FullName
|
||||||
|
=> $"{Group!.Name}: {Name}";
|
||||||
|
|
||||||
|
public string Description { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
IMod IModDataContainer.Mod
|
||||||
|
=> Mod;
|
||||||
|
|
||||||
|
IModGroup IModDataContainer.Group
|
||||||
|
=> Group;
|
||||||
|
|
||||||
|
public Dictionary<Utf8GamePath, FullPath> Files { get; set; } = [];
|
||||||
|
public Dictionary<Utf8GamePath, FullPath> FileSwaps { get; set; } = [];
|
||||||
|
public HashSet<MetaManipulation> Manipulations { get; set; } = [];
|
||||||
|
|
||||||
|
public void AddDataTo(Dictionary<Utf8GamePath, FullPath> redirections, HashSet<MetaManipulation> manipulations)
|
||||||
|
=> SubModHelpers.AddContainerTo(this, redirections, manipulations);
|
||||||
|
|
||||||
|
public string GetName()
|
||||||
|
=> Name;
|
||||||
|
|
||||||
|
public string GetFullName()
|
||||||
|
=> FullName;
|
||||||
|
|
||||||
|
public (int GroupIndex, int DataIndex) GetDataIndices()
|
||||||
|
=> (Group.GetIndex(), GetDataIndex());
|
||||||
|
|
||||||
|
public (int GroupIndex, int OptionIndex) GetOptionIndices()
|
||||||
|
=> (Group.GetIndex(), GetDataIndex());
|
||||||
|
|
||||||
|
private int GetDataIndex()
|
||||||
|
{
|
||||||
|
var dataIndex = Group.DataContainers.IndexOf(this);
|
||||||
|
if (dataIndex < 0)
|
||||||
|
throw new Exception($"Group {Group.Name} from SubMod {Name} does not contain this SubMod.");
|
||||||
|
|
||||||
|
return dataIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,37 +1,13 @@
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using OtterGui;
|
|
||||||
using Penumbra.Meta.Manipulations;
|
|
||||||
using Penumbra.Mods.Editor;
|
|
||||||
using Penumbra.Mods.Groups;
|
using Penumbra.Mods.Groups;
|
||||||
using Penumbra.Mods.Settings;
|
using Penumbra.Mods.Settings;
|
||||||
using Penumbra.String.Classes;
|
|
||||||
|
namespace Penumbra.Mods.SubMods;
|
||||||
namespace Penumbra.Mods.SubMods;
|
|
||||||
|
public class SingleSubMod(Mod mod, SingleModGroup singleGroup) : OptionSubMod<SingleModGroup>(mod, singleGroup)
|
||||||
public class SingleSubMod(Mod mod, SingleModGroup group) : IModDataOption
|
|
||||||
{
|
{
|
||||||
internal readonly Mod Mod = mod;
|
public SingleSubMod(Mod mod, SingleModGroup singleGroup, JToken json)
|
||||||
internal readonly SingleModGroup Group = group;
|
: this(mod, singleGroup)
|
||||||
|
|
||||||
public string Name { get; set; } = "Option";
|
|
||||||
|
|
||||||
public string FullName
|
|
||||||
=> $"{Group.Name}: {Name}";
|
|
||||||
|
|
||||||
public string Description { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
IMod IModDataContainer.Mod
|
|
||||||
=> Mod;
|
|
||||||
|
|
||||||
IModGroup IModDataContainer.Group
|
|
||||||
=> Group;
|
|
||||||
|
|
||||||
public Dictionary<Utf8GamePath, FullPath> Files { get; set; } = [];
|
|
||||||
public Dictionary<Utf8GamePath, FullPath> FileSwaps { get; set; } = [];
|
|
||||||
public HashSet<MetaManipulation> Manipulations { get; set; } = [];
|
|
||||||
|
|
||||||
public SingleSubMod(Mod mod, SingleModGroup group, JToken json)
|
|
||||||
: this(mod, group)
|
|
||||||
{
|
{
|
||||||
SubModHelpers.LoadOptionData(json, this);
|
SubModHelpers.LoadOptionData(json, this);
|
||||||
SubModHelpers.LoadDataContainer(json, this, mod.ModPath);
|
SubModHelpers.LoadDataContainer(json, this, mod.ModPath);
|
||||||
|
|
@ -41,7 +17,7 @@ public class SingleSubMod(Mod mod, SingleModGroup group) : IModDataOption
|
||||||
{
|
{
|
||||||
var ret = new SingleSubMod(mod, group)
|
var ret = new SingleSubMod(mod, group)
|
||||||
{
|
{
|
||||||
Name = Name,
|
Name = Name,
|
||||||
Description = Description,
|
Description = Description,
|
||||||
};
|
};
|
||||||
SubModHelpers.Clone(this, ret);
|
SubModHelpers.Clone(this, ret);
|
||||||
|
|
@ -53,30 +29,12 @@ public class SingleSubMod(Mod mod, SingleModGroup group) : IModDataOption
|
||||||
{
|
{
|
||||||
var ret = new MultiSubMod(mod, group)
|
var ret = new MultiSubMod(mod, group)
|
||||||
{
|
{
|
||||||
Name = Name,
|
Name = Name,
|
||||||
Description = Description,
|
Description = Description,
|
||||||
Priority = priority,
|
Priority = priority,
|
||||||
};
|
};
|
||||||
SubModHelpers.Clone(this, ret);
|
SubModHelpers.Clone(this, ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public void AddDataTo(Dictionary<Utf8GamePath, FullPath> redirections, HashSet<MetaManipulation> manipulations)
|
|
||||||
=> SubModHelpers.AddContainerTo(this, redirections, manipulations);
|
|
||||||
|
|
||||||
public (int GroupIndex, int DataIndex) GetDataIndices()
|
|
||||||
=> (Group.GetIndex(), GetDataIndex());
|
|
||||||
|
|
||||||
public (int GroupIndex, int OptionIndex) GetOptionIndices()
|
|
||||||
=> (Group.GetIndex(), GetDataIndex());
|
|
||||||
|
|
||||||
private int GetDataIndex()
|
|
||||||
{
|
|
||||||
var dataIndex = Group.DataContainers.IndexOf(this);
|
|
||||||
if (dataIndex < 0)
|
|
||||||
throw new Exception($"Group {Group.Name} from SubMod {Name} does not contain this SubMod.");
|
|
||||||
|
|
||||||
return dataIndex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Penumbra.Meta.Manipulations;
|
using Penumbra.Meta.Manipulations;
|
||||||
using Penumbra.Mods.ItemSwap;
|
|
||||||
using Penumbra.String.Classes;
|
using Penumbra.String.Classes;
|
||||||
|
|
||||||
namespace Penumbra.Mods.SubMods;
|
namespace Penumbra.Mods.SubMods;
|
||||||
|
|
@ -92,9 +91,9 @@ public static class SubModHelpers
|
||||||
j.WritePropertyName(nameof(data.Manipulations));
|
j.WritePropertyName(nameof(data.Manipulations));
|
||||||
serializer.Serialize(j, data.Manipulations);
|
serializer.Serialize(j, data.Manipulations);
|
||||||
j.WriteEndObject();
|
j.WriteEndObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Write the data for a selectable mod option on a JsonWriter. </summary>
|
/// <summary> Write the data for a selectable mod option on a JsonWriter. </summary>
|
||||||
public static void WriteModOption(JsonWriter j, IModOption option)
|
public static void WriteModOption(JsonWriter j, IModOption option)
|
||||||
{
|
{
|
||||||
j.WritePropertyName(nameof(option.Name));
|
j.WritePropertyName(nameof(option.Name));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue