CrabUI
Loading...
Searching...
No Matches
CUITest.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Reflection;
5using System.Diagnostics;
6using System.Runtime.CompilerServices;
7using System.IO;
8
9using Barotrauma;
10using Microsoft.Xna.Framework;
11using Microsoft.Xna.Framework.Input;
12using Microsoft.Xna.Framework.Graphics;
13using HarmonyLib;
14
15using CrabUI;
16using CrabUIBase;
17
18namespace CrabUITest
19{
20 public partial class CUITest
21 {
22 public static string ModDir => Mod.ModDir;
23 public static string PNGAssetsPath => Path.Combine(ModDir, @"Assets2\Png");
24 public static string DataPath = Path.Combine(ModDir, @"CSharp\Client\CUI Test\Data");
25 public static string IgnoredDataPath = Path.Combine(DataPath, @"Ignore");
26
27
28 public static CUIComponent TestChamber;
29 public static AutomaticTestRunner automaticTestRunner;
30 public static FakeModRunner fakeModRunner;
31
32 public static void CreateTestChamber()
33 {
34 TestChamber = new CUIComponent()
35 {
36 Absolute = new CUINullRect(0, 0, CUI.Main.Real.Width, CUI.Main.Real.Height),
37 BackgroundSprite = new CUISprite(Path.Combine(PNGAssetsPath, "TestChamber.png")),
38 Border = new CUIBorder(Color.Transparent, 0),
39 ChildrenBoundaries = CUIBoundaries.Box,
40 //BackgroundColor = new Color(200, 200, 200, 255),
41 Style = new CUIStyle(){
42 {"BackgroundColor", "200,200,200"},
43 },
44 AKA = "test chamber background",
45 };
46 }
47
48 public static void ClearTestChamber()
49 {
50 TestChamber.RemoveAllChildren();
51 }
52
53 public static void OpenTestChamber() => CUI.Main.Append(TestChamber);
54 public static void CloseTestChamber() => CUI.Main.RemoveChild(TestChamber);
55
56 public static void Autorun()
57 {
58 automaticTestRunner.GUI.Opened = true;
59
60 //manualTestRunner.RunTest(SerializationTest.Calculated);
61 //fakeModRunner.RunTest<CalculatorMod>();
62 //UnitTest.Run<ParserTest>();
63
64 CUIMagnifyingGlass.AddToggleButton();
65 //CUIPropsDebug.Open();
66 }
67
68
69 public static void Initialize()
70 {
71 CUI.PGNAssets = PNGAssetsPath;
72 CreateTestChamber();
73 automaticTestRunner = new AutomaticTestRunner();
74 fakeModRunner = new FakeModRunner();
75 AddCommands();
76 Autorun();
77 }
78
79 public static void Dispose()
80 {
81 RemoveCommands();
82 automaticTestRunner = null;
83 fakeModRunner = null;
84 TestChamber = null;
85 }
86
87 public static string WrapInColor(object o, string cl)
88 {
89 return $"‖color:{cl}‖{o}‖end‖";
90 }
91
92 public static void Log(object msg, Color? cl = null)
93 {
94 cl ??= Color.Cyan;
95 LuaCsLogger.LogMessage($"{msg ?? "null"}", cl * 0.8f, cl);
96 }
97
98 }
99}
Base class for all components.
virtual CUIComponent Append(CUIComponent child, string name=null, [CallerMemberName] string memberName="")
Adds children to the end of the list.
CUIRect Real
Calculated prop, position on real screen in pixels Should be fully calculated after CUIMainComponent....
In fact a static class managing static things.
Definition CUIErrors.cs:16
static CUIMainComponent Main
Orchestrates Drawing and updates, there could be only one CUI.Main is located under vanilla GUI.
Definition CUI.cs:84
It's a debug tool, you can use it with cuimg command, it's very fps comsuming.
Wrapper Containing link to texture and drawing settings, like SourceRedt, DrawMode,...
Definition CUISprite.cs:27
In Fact just an observable dict.
Definition CUIStyle.cs:21
Defining Boundaries, not the same as rect containing min/max x, y, z.
Rectangle with float?
Definition CUIRect.cs:104