Configuration console commands

This commit is contained in:
Terry Hearst 2023-09-11 01:00:52 -04:00
parent 7c35b2e5da
commit 8764546768

View file

@ -31,9 +31,19 @@ namespace CustomCosmeticLoader
return ""; return "";
} }
[ConsoleCommand(description = "Enables/disables the custom cosmetic loader", paramsDescription = "[true/false]", hidden = true)] [ConsoleCommand(description = "Save the custom config loader configuration", hidden = true)]
public static string cclSetEnabled(params string[] args) public static string cclSaveConfig()
{ {
Config.SaveConfig();
return "Custom cosmetic loader config saved";
}
[ConsoleCommand(description = "Enables/disables the custom cosmetic loader", paramsDescription = "[true/false]", hidden = true)]
public static string cclEnabled(params string[] args)
{
if (args.Length == 0)
return "enabled: " + (Config.enabled ? "true" : "false");
if (args.Length != 1 || (args[0] != "true" && args[0] != "false")) if (args.Length != 1 || (args[0] != "true" && args[0] != "false"))
return "Requires a true or false argument"; return "Requires a true or false argument";
@ -50,16 +60,12 @@ namespace CustomCosmeticLoader
return "Enabled custom cosmetic loader"; return "Enabled custom cosmetic loader";
} }
[ConsoleCommand(description = "Save the custom config loader configuration", hidden = true)]
public static string cclSaveConfig()
{
Config.SaveConfig();
return "Custom cosmetic loader config saved";
}
[ConsoleCommand(description = "Sets the active custom skin", paramsDescription = "[skinName]", hidden = true)] [ConsoleCommand(description = "Sets the active custom skin", paramsDescription = "[skinName]", hidden = true)]
public static string cclSetCurrentSkin(params string[] args) public static string cclCurrentSkin(params string[] args)
{ {
if (args.Length == 0)
return "currentSkin: " + Config.currentSkin;
if (args.Length != 1) if (args.Length != 1)
return "Requires 1 argument, the name of the custom skin"; return "Requires 1 argument, the name of the custom skin";
@ -76,8 +82,11 @@ namespace CustomCosmeticLoader
} }
[ConsoleCommand(description = "Change which cosmetic to hijack", paramsDescription = "[skinName]", hidden = true)] [ConsoleCommand(description = "Change which cosmetic to hijack", paramsDescription = "[skinName]", hidden = true)]
public static string cclSetHijackSkin(params string[] args) public static string cclSkinNameToHijack(params string[] args)
{ {
if (args.Length == 0)
return "skinNameToHijack: " + Config.skinNameToHijack;
if (args.Length != 1) if (args.Length != 1)
return "Requires 1 argument, the name of the skin cosmetic to hijack"; return "Requires 1 argument, the name of the skin cosmetic to hijack";
@ -103,7 +112,7 @@ namespace CustomCosmeticLoader
public static string cclInMainMenu(params string[] args) public static string cclInMainMenu(params string[] args)
{ {
if (args.Length == 0) if (args.Length == 0)
return "inMainMenu: " + (Config.inMainMenu ? "true" : "false"); ; return "inMainMenu: " + (Config.inMainMenu ? "true" : "false");
if (args.Length != 1 || (args[0] != "true" && args[0] != "false")) if (args.Length != 1 || (args[0] != "true" && args[0] != "false"))
return "Requires a true or false argument"; return "Requires a true or false argument";
@ -117,7 +126,7 @@ namespace CustomCosmeticLoader
public static string cclInCosmeticMenu(params string[] args) public static string cclInCosmeticMenu(params string[] args)
{ {
if (args.Length == 0) if (args.Length == 0)
return "inCosmeticMenu: " + (Config.inCosmeticMenu ? "true" : "false"); ; return "inCosmeticMenu: " + (Config.inCosmeticMenu ? "true" : "false");
if (args.Length != 1 || (args[0] != "true" && args[0] != "false")) if (args.Length != 1 || (args[0] != "true" && args[0] != "false"))
return "Requires a true or false argument"; return "Requires a true or false argument";
@ -131,7 +140,7 @@ namespace CustomCosmeticLoader
public static string cclInAllReplays(params string[] args) public static string cclInAllReplays(params string[] args)
{ {
if (args.Length == 0) if (args.Length == 0)
return "inAllReplays: " + (Config.inAllReplays ? "true" : "false"); ; return "inAllReplays: " + (Config.inAllReplays ? "true" : "false");
if (args.Length != 1 || (args[0] != "true" && args[0] != "false")) if (args.Length != 1 || (args[0] != "true" && args[0] != "false"))
return "Requires a true or false argument"; return "Requires a true or false argument";
@ -145,7 +154,7 @@ namespace CustomCosmeticLoader
public static string cclOverrideReplayCosmetics(params string[] args) public static string cclOverrideReplayCosmetics(params string[] args)
{ {
if (args.Length == 0) if (args.Length == 0)
return "overrideReplayCosmetics: " + (Config.overrideReplayCosmetics ? "true" : "false"); ; return "overrideReplayCosmetics: " + (Config.overrideReplayCosmetics ? "true" : "false");
if (args.Length != 1 || (args[0] != "true" && args[0] != "false")) if (args.Length != 1 || (args[0] != "true" && args[0] != "false"))
return "Requires a true or false argument"; return "Requires a true or false argument";
@ -154,5 +163,56 @@ namespace CustomCosmeticLoader
return "Overriding cosmetics in all replays " + (Config.overrideReplayCosmetics ? "enabled" : "disabled"); return "Overriding cosmetics in all replays " + (Config.overrideReplayCosmetics ? "enabled" : "disabled");
} }
[ConsoleCommand(description = "List, add, or remove other players", paramsDescription = "[add/remove, playerName, skinName (if add)]", hidden = true)]
public static string cclOtherPlayers(params string[] args)
{
if (args.Length == 0)
{
MIU.Console.Instance.Write("otherPlayers: " + Config.otherPlayers.Count);
foreach (KeyValuePair<string, string> entry in Config.otherPlayers)
{
MIU.Console.Instance.Write(" " + entry.Key + ": " + entry.Value);
}
return "";
}
switch (args[0])
{
case "add":
if (args.Length != 3)
return "Must have 2 arguments after \"add\"";
string playerName = args[1];
string skinName = args[2];
if (!Config.skins.ContainsKey(skinName))
return "Skin " + skinName + " not found";
if (Config.otherPlayers.ContainsKey(playerName))
{
Config.otherPlayers.Remove(playerName);
Config.otherPlayers.Add(playerName, skinName);
return "Updated " + playerName + ": " + skinName;
}
else
{
Config.otherPlayers.Add(playerName, skinName);
return "Added " + playerName + ": " + skinName;
}
case "remove":
if (args.Length != 2)
return "Must have 1 argument after \"remove\"";
playerName = args[1];
if (Config.otherPlayers.ContainsKey(playerName))
{
Config.otherPlayers.Remove(playerName);
return "Removed " + playerName;
}
else
{
return "Player " + playerName + " not found";
}
default:
return "First argument must be either \"add\" or \"remove\"";
}
}
} }
} }