2using System.Collections.Generic;
4using System.Reflection;
5using System.Diagnostics;
6using System.Runtime.CompilerServices;
10using Microsoft.Xna.Framework;
11using Microsoft.Xna.Framework.Input;
12using Microsoft.Xna.Framework.Graphics;
17 public partial class CUI
19 internal static List<DebugConsole.Command> AddedCommands =
new List<DebugConsole.Command>();
20 internal static void AddCommands()
22 AddedCommands.Add(
new DebugConsole.Command(
"cuicreatepalette",
23 "cuicreatepalette name frontcolor [backcolor]", CUICreatePalette_Command)
25 AddedCommands.Add(
new DebugConsole.Command(
"printkeys",
"", PrintSprites_Command));
26 AddedCommands.Add(
new DebugConsole.Command(
"printcolors",
"", PrintColors_Command));
27 AddedCommands.Add(
new DebugConsole.Command(
"cuipalette",
"load palette as primary", Palette_Command, () =>
new string[][] { CUIPalette.LoadedPalettes.Keys.ToArray() }));
28 AddedCommands.Add(
new DebugConsole.Command(
"cuipalettedemo",
"", PaletteDemo_Command));
29 AddedCommands.Add(
new DebugConsole.Command(
"cuicreatepaletteset",
"cuicreatepaletteset name primaty secondary tertiary quaternary", CUICreatePaletteSet_Command, () =>
new string[][] {
31 CUIPalette.LoadedPalettes.Keys.ToArray(),
32 CUIPalette.LoadedPalettes.Keys.ToArray(),
33 CUIPalette.LoadedPalettes.Keys.ToArray(),
34 CUIPalette.LoadedPalettes.Keys.ToArray(),
36 AddedCommands.Add(
new DebugConsole.Command(
"cuiloadpaletteset",
"", CUILoadPaletteSet_Command));
37 AddedCommands.Add(
new DebugConsole.Command(
"cuicreateluatypesfile",
"", CUICreateLuaTypesFile_Command));
39 DebugConsole.Commands.InsertRange(0, AddedCommands);
42 public static void PrintColors_Command(
string[] args)
44 foreach (PropertyInfo prop
in typeof(Color).GetProperties(BindingFlags.Static | BindingFlags.Public))
46 CUI.Log($
"{prop} {prop.GetValue(null)}", (Color)prop.GetValue(
null));
50 public static void CUICreateLuaTypesFile_Command(
string[] args)
52 CUI.LuaRegistrar.ConstructLuaStaticsFile();
56 public static void CUICreatePalette_Command(
string[] args)
58 string name = args.ElementAtOrDefault(0);
59 Color colorA = CUIExtensions.ParseColor((args.ElementAtOrDefault(1) ??
"white"));
60 Color colorB = CUIExtensions.ParseColor((args.ElementAtOrDefault(2) ??
"black"));
61 CUIPalette palette = CUIPalette.CreatePaletteFromColors(name, colorA, colorB);
62 CUIPalette.Primary = palette;
65 public static void CUICreatePaletteSet_Command(
string[] args)
68 args.ElementAtOrDefault(0),
69 args.ElementAtOrDefault(1),
70 args.ElementAtOrDefault(2),
71 args.ElementAtOrDefault(3),
72 args.ElementAtOrDefault(4)
76 public static void CUILoadPaletteSet_Command(
string[] args)
78 CUIPalette.LoadSet(Path.Combine(CUIPalette.PaletteSetsPath, args.ElementAtOrDefault(0)));
81 public static void PrintKeysCommand(
string[] args)
83 CUIDebug.PrintKeys = !CUIDebug.PrintKeys;
85 if (CUIDebug.PrintKeys)
87 var values = typeof(Keys).GetEnumValues();
88 foreach (var v
in values)
92 Log(
"---------------------------");
96 public static void PaletteDemo_Command(
string[] args)
98 try { CUIPalette.PaletteDemo(); }
catch (Exception e) { CUI.Warning(e); }
101 public static void Palette_Command(
string[] args)
105 CUIPalette palette = CUIPalette.LoadedPalettes?.GetValueOrDefault(args.ElementAtOrDefault(0) ??
"");
106 if (palette !=
null) CUIPalette.Primary = palette;
108 catch (Exception e) { CUI.Warning(e); }
112 internal static void RemoveCommands()
114 AddedCommands.ForEach(c => DebugConsole.Commands.Remove(c));
115 AddedCommands.Clear();