-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainTools.cs
165 lines (136 loc) · 5.98 KB
/
MainTools.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
using System;
using Modding.Humankind.DevTools;
using Modding.Humankind.DevTools.DeveloperTools.UI;
using DevTools.Humankind.GUITools.UI;
using DevTools.Humankind.GUITools.UI.PauseMenu;
using StyledGUI;
namespace DevTools.Humankind.GUITools
{
public static class MainTools
{
public static bool IsDebugModeEnabled { get; set; } = true;
public static MainToolbar Toolbar { get; set; }
public static InGameMenuWindow InGameMenu { get; set; }
// public static BasicToolWindow BasicWindow { get; set; }
// public static GameInfoToolWindow GameInfoWindow { get; set; }
// public static DistrictPainterToolWindow DistrictPainterWindow { get; set; }
// public static SettlementToolsWindow SettlementWindow { get; set; }
// public static StatisticsAndAchievementsToolWindow StatisticsAndAchievementsWindow { get; set; }
public static ScenarioEditorToolWindow ScenarioEditorWindow { get; set; }
public static GameStatsWindow StatsWindow { get; set; }
public static BackScreenWindow BackScreen { get; set; }
public static EndGameStatisticsWindow EndGameWindow { get; set; }
// public static CameraLayersToolWindow CameraLayersWindow { get; set; }
public static void Main()
{
if (IsDebugModeEnabled) Debug();
ViewController.Initialize(true);
UIController.OnceGUIHasLoaded(() =>
{
StyledGUIUtility.DefaultSkin = UIController.DefaultSkin;
StyledGUIUtility.UnicodeSymbolsFont = Utils.SegoeUISymbolFont;
});
PopupToolWindow.Open<BackScreenWindow>(w => BackScreen = w);
PopupToolWindow.Open<MainToolbar>(w => Toolbar = w);
PopupToolWindow.Open<InGameMenuWindow>(w => InGameMenu = w);
// if (IsDebugModeEnabled && IsTestingPlaygroundEnabled)
// TestingPlayground.Run();
}
public static void ToggleHideToolbarWindow()
{
if (ViewController.IsGloballyDisabled) return;
GlobalSettings.HideToolbarWindow.Value = !GlobalSettings.HideToolbarWindow.Value;
}
public static void ToggleHideAllUIWindows() =>
Loggr.Log("HIDDING ALL GUI TOOLS WINDOWS IS TEMPORARILY DISABLED",
ConsoleColor
.Magenta); //FloatingToolWindow.HideAllGUITools = !FloatingToolWindow.HideAllGUITools);
// public static void CancelGodMode() => AccessTools.PropertySetter(typeof(GodMode), "Enabled")?.Invoke(null, new object[] { false });
/*public static void ToggleBasicToolWindow()
{
if (BasicWindow == null)
{
PopupToolWindow.Open<BasicToolWindow>(w => BasicWindow = w);
return;
}
BasicWindow.Close();
BasicWindow = null;
}*/
public static void ToggleGameOverviewWindow()
{
if (ViewController.IsGloballyDisabled) return;
if (StatsWindow == null)
{
PopupToolWindow.Open<GameStatsWindow>(w => StatsWindow = w);
return;
}
StatsWindow.Close();
StatsWindow = null;
}
public static void ToggleScenarioEditorWindow()
{
if (ViewController.IsGloballyDisabled) return;
if (ScenarioEditorWindow == null)
{
PopupToolWindow.Open<ScenarioEditorToolWindow>(w => ScenarioEditorWindow = w);
return;
}
ScenarioEditorWindow.Close();
ScenarioEditorWindow = null;
}
public static void ToggleEndGameStatisticsWindow()
{
if (ViewController.IsGloballyDisabled) return;
if (EndGameWindow == null)
{
PopupToolWindow.Open<EndGameStatisticsWindow>(w => EndGameWindow = w);
ViewController.ViewMode = ViewModeType.EndGame;
return;
}
CloseEndGameStatisticsWindow();
}
public static void CloseEndGameStatisticsWindow()
{
if (ViewController.IsGloballyDisabled) return;
if (EndGameWindow != null)
{
EndGameWindow.Close(false);
EndGameWindow = null;
}
}
public static bool IsGameOverviewEnabled => StatsWindow != null;
public static bool IsEndGameWindowEnabled => EndGameWindow != null;
public static bool IsScenarioEditorWindowEnabled => ScenarioEditorWindow != null;
public static void Unload() => Unload(true);
public static void Unload(bool saveState = false)
{
if (FeatureFlags.WireRenderer)
WireRenderer.Detach();
Toolbar?.Close(saveState);
InGameMenu?.Close();
// BasicWindow?.Close();
// CameraLayersWindow?.Close();
// GameInfoWindow?.Close();
// DistrictPainterWindow?.Close();
// SettlementWindow?.Close();
// StatisticsAndAchievementsWindow?.Close();
// FameWindow?.Close();
EndGameWindow?.Close();
StatsWindow?.Close();
BackScreen?.Close();
ScenarioEditorWindow?.Close();
ScreenLocker.Unload();
}
private static void Debug()
{
/*var scriptsPath = Path.Combine(Paths.GameRootPath, "scripts");
var files = Directory.GetFiles(scriptsPath, "*.cs", SearchOption.AllDirectories)
.Where(path => path.Substring(scriptsPath.Length, 5) != "\\obj\\");
Loggr.Log(string.Join("\n", files), ConsoleColor.DarkYellow);*/
// When true, draws a colored border for all UIOverlays backing a FloatingToolWindow derived class
UIOverlay.DEBUG_DRAW_OVERLAY = false;
// When not true, adds more verbosity to console output
Modding.Humankind.DevTools.DevTools.QuietMode = FeatureFlags.QuietMode;
}
}
}