using MIU; 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 = "Save the custom config loader configuration", hidden = true)] 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")) 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 = "Sets the active custom skin", paramsDescription = "[skinName]", hidden = true)] public static string cclCurrentSkin(params string[] args) { if (args.Length == 0) return "currentSkin: " + Config.currentSkin; 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 cclSkinNameToHijack(params string[] args) { if (args.Length == 0) return "skinNameToHijack: " + Config.skinNameToHijack; 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]; } [ConsoleCommand(description = "Enable/disable custom skins on the My Marble widgets", paramsDescription = "[true/false]", hidden = true)] public static string cclInMainMenu(params string[] args) { if (args.Length == 0) return "inMainMenu: " + (Config.inMainMenu ? "true" : "false"); if (args.Length != 1 || (args[0] != "true" && args[0] != "false")) return "Requires a true or false argument"; Config.inMainMenu = args[0] == "true"; return "Custom skins in main menu " + (Config.inMainMenu ? "enabled" : "disabled"); } [ConsoleCommand(description = "Enable/disable custom skins in the cosmetic menu (for previewing hijack skins)", paramsDescription = "[true/false]", hidden = true)] public static string cclInCosmeticMenu(params string[] args) { if (args.Length == 0) return "inCosmeticMenu: " + (Config.inCosmeticMenu ? "true" : "false"); if (args.Length != 1 || (args[0] != "true" && args[0] != "false")) return "Requires a true or false argument"; Config.inCosmeticMenu = args[0] == "true"; return "Custom skins in cosmetic menu " + (Config.inCosmeticMenu ? "enabled" : "disabled"); } [ConsoleCommand(description = "Enable/disable showing your custom skin in all replays, regardless of player", paramsDescription = "[true/false]", hidden = true)] public static string cclInAllReplays(params string[] args) { if (args.Length == 0) return "inAllReplays: " + (Config.inAllReplays ? "true" : "false"); if (args.Length != 1 || (args[0] != "true" && args[0] != "false")) return "Requires a true or false argument"; Config.inAllReplays = args[0] == "true"; return "Custom skins in all replays " + (Config.inAllReplays ? "enabled" : "disabled"); } [ConsoleCommand(description = "Enable/disable overriding a replay's cosmetics with your cosmetics", paramsDescription = "[true/false]", hidden = true)] public static string cclOverrideReplayCosmetics(params string[] args) { if (args.Length == 0) return "overrideReplayCosmetics: " + (Config.overrideReplayCosmetics ? "true" : "false"); if (args.Length != 1 || (args[0] != "true" && args[0] != "false")) return "Requires a true or false argument"; Config.overrideReplayCosmetics = args[0] == "true"; 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 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\""; } } } }