/// <summary> /// Registers a new bind /// </summary> /// <param name="id">The id of the button</param> /// <param name="text">The text to show on the button</param> /// <param name="command">The command to execute</param> public static void RegisterBind(string id, string text, string command) { if (id.Equals("all")) { Console.LogWarning($"Trying to register user defined button with id 'all' but 'all' is not a valid id!"); return; } if (Console.RegisterButton("user." + id, new ConsoleButton("U: " + text, command))) { File.AppendAllText(bindFile, $"{id}:{text}:{command}\n"); } }
/// <summary> /// Reads all bindings /// </summary> internal static void ReadBinds() { if (!File.Exists(bindFile)) { return; } foreach (string line in File.ReadAllLines(bindFile)) { if (!line.Contains(":")) { continue; } string[] split = line.Split(':'); Console.RegisterButton("user." + split[0], new ConsoleButton("U: " + split[1], split[2])); } }