mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-15 05:04:15 +01:00
Add placeholder options to collection chat command, slightly refactor tag -> bulktag command by SoyaX.
This commit is contained in:
parent
b43d0453e1
commit
6e983c8735
2 changed files with 96 additions and 106 deletions
|
|
@ -110,7 +110,7 @@ public class CommandHandler : IDisposable
|
||||||
"debug" => SetDebug( arguments ),
|
"debug" => SetDebug( arguments ),
|
||||||
"collection" => SetCollection( arguments ),
|
"collection" => SetCollection( arguments ),
|
||||||
"mod" => SetMod( arguments ),
|
"mod" => SetMod( arguments ),
|
||||||
"tag" => SetTag( arguments ),
|
"bulktag" => SetTag( arguments ),
|
||||||
_ => PrintHelp( argumentList[ 0 ] ),
|
_ => PrintHelp( argumentList[ 0 ] ),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -139,7 +139,8 @@ public class CommandHandler : IDisposable
|
||||||
Dalamud.Chat.Print( new SeStringBuilder().AddCommand( "collection", "Change your active collection setup. Use without further parameters for more detailed help." )
|
Dalamud.Chat.Print( new SeStringBuilder().AddCommand( "collection", "Change your active collection setup. Use without further parameters for more detailed help." )
|
||||||
.BuiltString );
|
.BuiltString );
|
||||||
Dalamud.Chat.Print( new SeStringBuilder().AddCommand( "mod", "Change a specific mods settings. Use without further parameters for more detailed help." ).BuiltString );
|
Dalamud.Chat.Print( new SeStringBuilder().AddCommand( "mod", "Change a specific mods settings. Use without further parameters for more detailed help." ).BuiltString );
|
||||||
Dalamud.Chat.Print( new SeStringBuilder().AddCommand( "tag", "Change multiple mods settings based on their tags. Use without further parameters for more detailed help." ).BuiltString );
|
Dalamud.Chat.Print( new SeStringBuilder().AddCommand( "tag", "Change multiple mods settings based on their tags. Use without further parameters for more detailed help." )
|
||||||
|
.BuiltString );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -249,6 +250,8 @@ public class CommandHandler : IDisposable
|
||||||
.BuiltString );
|
.BuiltString );
|
||||||
Dalamud.Chat.Print( new SeStringBuilder().AddText( " 》 If the type is " ).AddBlue( "Individual" )
|
Dalamud.Chat.Print( new SeStringBuilder().AddText( " 》 If the type is " ).AddBlue( "Individual" )
|
||||||
.AddText( " you need to specify an individual with an identifier of the form:" ).BuiltString );
|
.AddText( " you need to specify an individual with an identifier of the form:" ).BuiltString );
|
||||||
|
Dalamud.Chat.Print( new SeStringBuilder().AddText( " 》》》 " ).AddGreen( "<me>" ).AddText( " or " ).AddGreen( "<t>" ).AddText( " or " ).AddGreen( "<mo>" )
|
||||||
|
.AddText( " or " ).AddGreen( "<f>" ).AddText( " as placeholders for your character, your target, your mouseover or your focus, if they exist." ).BuiltString );
|
||||||
Dalamud.Chat.Print( new SeStringBuilder().AddText( " 》》》 " ).AddGreen( "p" ).AddText( " | " ).AddWhite( "[Player Name]@<World Name>" )
|
Dalamud.Chat.Print( new SeStringBuilder().AddText( " 》》》 " ).AddGreen( "p" ).AddText( " | " ).AddWhite( "[Player Name]@<World Name>" )
|
||||||
.AddText( ", if no @ is provided, Any World is used." ).BuiltString );
|
.AddText( ", if no @ is provided, Any World is used." ).BuiltString );
|
||||||
Dalamud.Chat.Print( new SeStringBuilder().AddText( " 》》》 " ).AddGreen( "r" ).AddText( " | " ).AddWhite( "[Retainer Name]" ).BuiltString );
|
Dalamud.Chat.Print( new SeStringBuilder().AddText( " 》》》 " ).AddGreen( "r" ).AddText( " | " ).AddWhite( "[Retainer Name]" ).BuiltString );
|
||||||
|
|
@ -292,7 +295,20 @@ public class CommandHandler : IDisposable
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
identifier = _actors.FromUserString( split[ 2 ] );
|
if( ObjectReloader.GetName( split[ 2 ].ToLowerInvariant(), out var obj ) )
|
||||||
|
{
|
||||||
|
identifier = _actors.FromObject( obj, false, true );
|
||||||
|
if( !identifier.IsValid )
|
||||||
|
{
|
||||||
|
Dalamud.Chat.Print( new SeStringBuilder().AddText( "The placeholder " ).AddGreen( split[ 2 ] )
|
||||||
|
.AddText( " did not resolve to a game object with a valid identifier." ).BuiltString );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
identifier = _actors.FromUserString( split[ 2 ] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch( ActorManager.IdentifierParseError e )
|
catch( ActorManager.IdentifierParseError e )
|
||||||
{
|
{
|
||||||
|
|
@ -370,17 +386,7 @@ public class CommandHandler : IDisposable
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var state = split[ 0 ].ToLowerInvariant() switch
|
var state = ConvertToSettingState( split[ 0 ] );
|
||||||
{
|
|
||||||
"enable" => 0,
|
|
||||||
"enabled" => 0,
|
|
||||||
"disable" => 1,
|
|
||||||
"disabled" => 1,
|
|
||||||
"toggle" => 2,
|
|
||||||
"inherit" => 3,
|
|
||||||
"inherited" => 3,
|
|
||||||
_ => -1,
|
|
||||||
};
|
|
||||||
if( state == -1 )
|
if( state == -1 )
|
||||||
{
|
{
|
||||||
Dalamud.Chat.Print( new SeStringBuilder().AddRed( split[ 0 ], true ).AddText( " is not a valid type of setting." ).BuiltString );
|
Dalamud.Chat.Print( new SeStringBuilder().AddRed( split[ 0 ], true ).AddText( " is not a valid type of setting." ).BuiltString );
|
||||||
|
|
@ -398,51 +404,13 @@ public class CommandHandler : IDisposable
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var settings = collection!.Settings[ mod.Index ];
|
if( HandleModState( state, collection!, mod ) )
|
||||||
switch( state )
|
|
||||||
{
|
{
|
||||||
case 0:
|
return true;
|
||||||
if( collection.SetModState( mod.Index, true ) )
|
|
||||||
{
|
|
||||||
Dalamud.Chat.Print( new SeStringBuilder().AddText( "Enabled mod " ).AddPurple( mod.Name, true ).AddText( " in collection " ).AddYellow( collection.Name, true )
|
|
||||||
.AddText( "." ).BuiltString );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
if( collection.SetModState( mod.Index, false ) )
|
|
||||||
{
|
|
||||||
Dalamud.Chat.Print( new SeStringBuilder().AddText( "Disabled mod " ).AddPurple( mod.Name, true ).AddText( " in collection " ).AddYellow( collection.Name, true )
|
|
||||||
.AddText( "." ).BuiltString );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
var setting = !( settings?.Enabled ?? false );
|
|
||||||
if( collection.SetModState( mod.Index, setting ) )
|
|
||||||
{
|
|
||||||
Dalamud.Chat.Print( new SeStringBuilder().AddText( setting ? "Enabled mod " : "Disabled mod " ).AddPurple( mod.Name, true ).AddText( " in collection " )
|
|
||||||
.AddYellow( collection.Name, true )
|
|
||||||
.AddText( "." ).BuiltString );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
if( collection.SetModInheritance( mod.Index, true ) )
|
|
||||||
{
|
|
||||||
Dalamud.Chat.Print( new SeStringBuilder().AddText( "Set mod " ).AddPurple( mod.Name, true ).AddText( " in collection " ).AddYellow( collection.Name, true )
|
|
||||||
.AddText( " to inherit." ).BuiltString );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Dalamud.Chat.Print( new SeStringBuilder().AddText( "Mod " ).AddPurple( mod.Name, true ).AddText( "already had the desired state in collection " )
|
Dalamud.Chat.Print( new SeStringBuilder().AddText( "Mod " ).AddPurple( mod.Name, true ).AddText( "already had the desired state in collection " )
|
||||||
.AddYellow( collection.Name, true ).AddText( "." ).BuiltString );
|
.AddYellow( collection!.Name, true ).AddText( "." ).BuiltString );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -465,17 +433,7 @@ public class CommandHandler : IDisposable
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var state = split[ 0 ].ToLowerInvariant() switch
|
var state = ConvertToSettingState( split[ 0 ] );
|
||||||
{
|
|
||||||
"enable" => 0,
|
|
||||||
"enabled" => 0,
|
|
||||||
"disable" => 1,
|
|
||||||
"disabled" => 1,
|
|
||||||
"toggle" => 2,
|
|
||||||
"inherit" => 3,
|
|
||||||
"inherited" => 3,
|
|
||||||
_ => -1,
|
|
||||||
};
|
|
||||||
|
|
||||||
if( state == -1 )
|
if( state == -1 )
|
||||||
{
|
{
|
||||||
|
|
@ -488,54 +446,23 @@ public class CommandHandler : IDisposable
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var mods = _modManager.Where( m => m.LocalTags.Contains( nameSplit[ 1 ], StringComparer.InvariantCultureIgnoreCase ) ).ToArray();
|
var mods = _modManager.Where( m => m.LocalTags.Contains( nameSplit[ 1 ], StringComparer.OrdinalIgnoreCase ) ).ToList();
|
||||||
|
|
||||||
if( mods.Length == 0 )
|
if( mods.Count == 0 )
|
||||||
{
|
{
|
||||||
Dalamud.Chat.Print( new SeStringBuilder().AddText( "The tag " ).AddRed( nameSplit[ 1 ], true ).AddText( " does not match any mods." ).BuiltString );
|
Dalamud.Chat.Print( new SeStringBuilder().AddText( "The tag " ).AddRed( nameSplit[ 1 ], true ).AddText( " does not match any mods." ).BuiltString );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var changes = false;
|
||||||
foreach( var mod in mods )
|
foreach( var mod in mods )
|
||||||
{
|
{
|
||||||
var settings = collection!.Settings[ mod.Index ];
|
changes |= HandleModState( state, collection!, mod );
|
||||||
switch( state )
|
}
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
if( collection.SetModState( mod.Index, true ) )
|
|
||||||
{
|
|
||||||
Dalamud.Chat.Print( new SeStringBuilder().AddText( "Enabled mod " ).AddPurple( mod.Name, true ).AddText( " in collection " ).AddYellow( collection.Name, true )
|
|
||||||
.AddText( "." ).BuiltString );
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
if( !changes )
|
||||||
case 1:
|
{
|
||||||
if( collection.SetModState( mod.Index, false ) )
|
Dalamud.Chat.Print( new SeStringBuilder().AddText( "No mod states were changed in collection " ).AddYellow( collection!.Name, true ).AddText( "." ).BuiltString );
|
||||||
{
|
|
||||||
Dalamud.Chat.Print( new SeStringBuilder().AddText( "Disabled mod " ).AddPurple( mod.Name, true ).AddText( " in collection " ).AddYellow( collection.Name, true )
|
|
||||||
.AddText( "." ).BuiltString );
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
var setting = !( settings?.Enabled ?? false );
|
|
||||||
if( collection.SetModState( mod.Index, setting ) )
|
|
||||||
{
|
|
||||||
Dalamud.Chat.Print( new SeStringBuilder().AddText( setting ? "Enabled mod " : "Disabled mod " ).AddPurple( mod.Name, true ).AddText( " in collection " )
|
|
||||||
.AddYellow( collection.Name, true )
|
|
||||||
.AddText( "." ).BuiltString );
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
if( collection.SetModInheritance( mod.Index, true ) )
|
|
||||||
{
|
|
||||||
Dalamud.Chat.Print( new SeStringBuilder().AddText( "Set mod " ).AddPurple( mod.Name, true ).AddText( " in collection " ).AddYellow( collection.Name, true )
|
|
||||||
.AddText( " to inherit." ).BuiltString );
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -579,4 +506,67 @@ public class CommandHandler : IDisposable
|
||||||
|
|
||||||
_ => null,
|
_ => null,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static int ConvertToSettingState( string text )
|
||||||
|
=> text.ToLowerInvariant() switch
|
||||||
|
{
|
||||||
|
"enable" => 0,
|
||||||
|
"enabled" => 0,
|
||||||
|
"disable" => 1,
|
||||||
|
"disabled" => 1,
|
||||||
|
"toggle" => 2,
|
||||||
|
"inherit" => 3,
|
||||||
|
"inherited" => 3,
|
||||||
|
_ => -1,
|
||||||
|
};
|
||||||
|
|
||||||
|
private static bool HandleModState( int settingState, ModCollection collection, Mod mod )
|
||||||
|
{
|
||||||
|
var settings = collection!.Settings[ mod.Index ];
|
||||||
|
switch( settingState )
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
if( collection.SetModState( mod.Index, true ) )
|
||||||
|
{
|
||||||
|
Dalamud.Chat.Print( new SeStringBuilder().AddText( "Enabled mod " ).AddPurple( mod.Name, true ).AddText( " in collection " )
|
||||||
|
.AddYellow( collection.Name, true )
|
||||||
|
.AddText( "." ).BuiltString );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
case 1:
|
||||||
|
if( collection.SetModState( mod.Index, false ) )
|
||||||
|
{
|
||||||
|
Dalamud.Chat.Print( new SeStringBuilder().AddText( "Disabled mod " ).AddPurple( mod.Name, true ).AddText( " in collection " )
|
||||||
|
.AddYellow( collection.Name, true )
|
||||||
|
.AddText( "." ).BuiltString );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
case 2:
|
||||||
|
var setting = !( settings?.Enabled ?? false );
|
||||||
|
if( collection.SetModState( mod.Index, setting ) )
|
||||||
|
{
|
||||||
|
Dalamud.Chat.Print( new SeStringBuilder().AddText( setting ? "Enabled mod " : "Disabled mod " ).AddPurple( mod.Name, true ).AddText( " in collection " )
|
||||||
|
.AddYellow( collection.Name, true )
|
||||||
|
.AddText( "." ).BuiltString );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
case 3:
|
||||||
|
if( collection.SetModInheritance( mod.Index, true ) )
|
||||||
|
{
|
||||||
|
Dalamud.Chat.Print( new SeStringBuilder().AddText( "Set mod " ).AddPurple( mod.Name, true ).AddText( " in collection " ).AddYellow( collection.Name, true )
|
||||||
|
.AddText( " to inherit." ).BuiltString );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -316,7 +316,7 @@ public sealed unsafe partial class ObjectReloader : IDisposable
|
||||||
return gPosePlayer ?? Dalamud.Objects[ 0 ];
|
return gPosePlayer ?? Dalamud.Objects[ 0 ];
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool GetName( string lowerName, out GameObject? actor )
|
public static bool GetName( string lowerName, out GameObject? actor )
|
||||||
{
|
{
|
||||||
( actor, var ret ) = lowerName switch
|
( actor, var ret ) = lowerName switch
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue