Add descriptions for SubMods

Adjusted importing of TexTools mods to give each option its own description instead of combining all option descriptions into the group description.
This commit is contained in:
Caraxi 2023-02-04 17:26:13 +10:30
parent e34aca68aa
commit 9f6a45041d
7 changed files with 64 additions and 19 deletions

View file

@ -124,6 +124,23 @@ public sealed partial class Mod
ModOptionChanged.Invoke( ModOptionChangeType.DisplayChange, mod, groupIdx, -1, -1 );
}
public void ChangeOptionDescription( Mod mod, int groupIdx, int optionIdx, string newDescription )
{
var group = mod._groups[ groupIdx ];
var option = group[ optionIdx ];
if( option.Description == newDescription )
{
return;
}
var _ = option switch
{
SubMod s => s.Description = newDescription,
};
ModOptionChanged.Invoke( ModOptionChangeType.DisplayChange, mod, groupIdx, optionIdx, -1 );
}
public void ChangeGroupPriority( Mod mod, int groupIdx, int newPriority )
{
var group = mod._groups[ groupIdx ];

View file

@ -116,6 +116,7 @@ public partial class Mod
var mod = new SubMod( null! ) // Mod is irrelevant here, only used for saving.
{
Name = option.Name,
Description = option.Description,
};
foreach( var (_, gamePath, file) in list )
{

View file

@ -10,6 +10,7 @@ public interface ISubMod
{
public string Name { get; }
public string FullName { get; }
public string Description { get; }
public IReadOnlyDictionary< Utf8GamePath, FullPath > Files { get; }
public IReadOnlyDictionary< Utf8GamePath, FullPath > FileSwaps { get; }
@ -22,6 +23,8 @@ public interface ISubMod
j.WriteStartObject();
j.WritePropertyName( nameof( Name ) );
j.WriteValue( mod.Name );
j.WritePropertyName( nameof(Description) );
j.WriteValue( mod.Description );
if( priority != null )
{
j.WritePropertyName( nameof( IModGroup.Priority ) );

View file

@ -107,6 +107,8 @@ public partial class Mod
public string FullName
=> GroupIdx < 0 ? "Default Option" : $"{ParentMod.Groups[ GroupIdx ].Name}: {Name}";
public string Description { get; set; } = string.Empty;
internal IMod ParentMod { get; private init; }
internal int GroupIdx { get; private set; }
internal int OptionIdx { get; private set; }
@ -143,8 +145,9 @@ public partial class Mod
ManipulationData.Clear();
// Every option has a name, but priorities are only relevant for multi group options.
Name = json[ nameof( ISubMod.Name ) ]?.ToObject< string >() ?? string.Empty;
priority = json[ nameof( IModGroup.Priority ) ]?.ToObject< int >() ?? 0;
Name = json[ nameof( ISubMod.Name ) ]?.ToObject< string >() ?? string.Empty;
Description = json[ nameof( ISubMod.Description ) ]?.ToObject< string >() ?? string.Empty;
priority = json[ nameof( IModGroup.Priority ) ]?.ToObject< int >() ?? 0;
var files = ( JObject? )json[ nameof( Files ) ];
if( files != null )