102 lines
2.9 KiB
C#
102 lines
2.9 KiB
C#
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<ConsoleCommandAttribute>();
|
|
|
|
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<string, Texture2D> 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];
|
|
}
|
|
}
|
|
}
|