diff --git a/ConsoleCommands.cs b/ConsoleCommands.cs new file mode 100644 index 0000000..a88bfe1 --- /dev/null +++ b/ConsoleCommands.cs @@ -0,0 +1,102 @@ +using MIU; +using System; +using System.Collections.Generic; +using System.Reflection; +using UnityEngine; + +namespace CustomCosmeticLoader +{ + internal class ConsoleCommands + { + [ConsoleCommand(description = "Shows help for Custom Cosmetic Loader commands")] + public static string cclHelp() + { + MIU.Console.Instance.Write("Available commands:"); + foreach (MethodInfo method in typeof(ConsoleCommands).GetMethods()) + { + if (!method.IsDefined(typeof(ConsoleCommandAttribute), false)) + continue; + + ConsoleCommandAttribute attr = method.GetCustomAttribute(); + + string name = attr.name; + if (name == null) + name = method.Name; + + if (attr.paramsDescription != null && attr.paramsDescription.Length > 0) + MIU.Console.Instance.Write(" " + name + " " + attr.paramsDescription + ": " + attr.description); + else + MIU.Console.Instance.Write(" " + name + ": " + attr.description); + } + return ""; + } + + [ConsoleCommand(description = "Enables/disables the custom cosmetic loader", paramsDescription = "[true/false]", hidden = true)] + public static string cclSetEnabled(params string[] args) + { + if (args.Length != 1 || (args[0] != "true" && args[0] != "false")) + return "Requires a true or false argument"; + + if (args[0] == "false") + { + Config.enabled = false; + return "Disabled custom cosmetic loader"; + } + + Config.enabled = true; + Config.ensureSkinSelected(); + if (!Config.enabled) + return "No skins found, could not enable!"; + 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)] + public static string cclSetCurrentSkin(params string[] args) + { + if (args.Length != 1) + return "Requires 1 argument, the name of the custom skin"; + + foreach (KeyValuePair skin in Config.skins) + { + if (skin.Key == args[0]) + { + Config.currentSkin = skin.Key; + return "Using custom skin " + skin.Key; + } + } + + return "Couldn't find skin " + args[0]; + } + + [ConsoleCommand(description = "Change which cosmetic to hijack", paramsDescription = "[skinName]", hidden = true)] + public static string cclSetHijackSkin(params string[] args) + { + if (args.Length != 1) + return "Requires 1 argument, the name of the skin cosmetic to hijack"; + + if (args[0] == "*") + { + Config.skinNameToHijack = "*"; + return "Hijack skin set to all skins"; + } + + foreach (Cosmetic skin in CosmeticManager.Skins) + { + if (skin.Id == args[0]) + { + Config.skinNameToHijack = args[0]; + return "Hijack skin set to " + args[0]; + } + } + + return "Couldn't find cosmetic " + args[0]; + } + } +} diff --git a/Shared.cs b/Shared.cs index ed4baf0..3edc55a 100644 --- a/Shared.cs +++ b/Shared.cs @@ -11,6 +11,9 @@ namespace CustomCosmeticLoader { get { + if (skinToHijack != null && skinToHijack.Id != Config.skinNameToHijack) + skinToHijack = null; + if (skinToHijack == null) { DetermineSkinToHijack();