|
5 | 5 | using UnityExplorer.CSConsole;
|
6 | 6 | using UnityExplorer.Inspectors;
|
7 | 7 | using UnityExplorer.UI.Panels;
|
| 8 | +using UnityExplorer.UI.Widgets; |
8 | 9 | using UnityExplorer.UI.Widgets.AutoComplete;
|
9 | 10 | using UniverseLib;
|
10 | 11 | using UniverseLib.Input;
|
@@ -54,10 +55,7 @@ public enum VerticalAnchor
|
54 | 55 | private static readonly Vector2 NAVBAR_DIMENSIONS = new(1020f, 35f);
|
55 | 56 |
|
56 | 57 | private static ButtonRef closeBtn;
|
57 |
| - private static ButtonRef pauseBtn; |
58 |
| - private static InputFieldRef timeInput; |
59 |
| - private static bool pauseButtonPausing; |
60 |
| - private static float lastTimeScale; |
| 58 | + private static TimeScaleWidget timeScaleWidget; |
61 | 59 |
|
62 | 60 | private static int lastScreenWidth;
|
63 | 61 | private static int lastScreenHeight;
|
@@ -141,20 +139,7 @@ public static void Update()
|
141 | 139 | UniverseLib.Config.ConfigManager.Force_Unlock_Mouse = !UniverseLib.Config.ConfigManager.Force_Unlock_Mouse;
|
142 | 140 |
|
143 | 141 | // update the timescale value
|
144 |
| - if (!timeInput.Component.isFocused && lastTimeScale != Time.timeScale) |
145 |
| - { |
146 |
| - if (pauseButtonPausing && Time.timeScale != 0.0f) |
147 |
| - { |
148 |
| - pauseButtonPausing = false; |
149 |
| - OnPauseButtonToggled(); |
150 |
| - } |
151 |
| - |
152 |
| - if (!pauseButtonPausing) |
153 |
| - { |
154 |
| - timeInput.Text = Time.timeScale.ToString("F2"); |
155 |
| - lastTimeScale = Time.timeScale; |
156 |
| - } |
157 |
| - } |
| 142 | + timeScaleWidget.Update(); |
158 | 143 |
|
159 | 144 | // check screen dimension change
|
160 | 145 | Display display = DisplayManager.ActiveDisplay;
|
@@ -232,41 +217,7 @@ private static void Master_Toggle_OnValueChanged(KeyCode val)
|
232 | 217 | closeBtn.ButtonText.text = val.ToString();
|
233 | 218 | }
|
234 | 219 |
|
235 |
| - // Time controls |
236 |
| - |
237 |
| - private static void OnTimeInputEndEdit(string val) |
238 |
| - { |
239 |
| - if (pauseButtonPausing) |
240 |
| - return; |
241 |
| - |
242 |
| - if (float.TryParse(val, out float f)) |
243 |
| - { |
244 |
| - Time.timeScale = f; |
245 |
| - lastTimeScale = f; |
246 |
| - } |
247 |
| - |
248 |
| - timeInput.Text = Time.timeScale.ToString("F2"); |
249 |
| - } |
250 |
| - |
251 |
| - private static void OnPauseButtonClicked() |
252 |
| - { |
253 |
| - pauseButtonPausing = !pauseButtonPausing; |
254 |
| - |
255 |
| - Time.timeScale = pauseButtonPausing ? 0f : lastTimeScale; |
256 |
| - |
257 |
| - OnPauseButtonToggled(); |
258 |
| - } |
259 |
| - |
260 |
| - private static void OnPauseButtonToggled() |
261 |
| - { |
262 |
| - timeInput.Component.text = Time.timeScale.ToString("F2"); |
263 |
| - timeInput.Component.readOnly = pauseButtonPausing; |
264 |
| - timeInput.Component.textComponent.color = pauseButtonPausing ? Color.grey : Color.white; |
265 |
| - |
266 |
| - Color color = pauseButtonPausing ? new Color(0.3f, 0.3f, 0.2f) : new Color(0.2f, 0.2f, 0.2f); |
267 |
| - RuntimeHelper.SetColorBlock(pauseBtn.Component, color, color * 1.2f, color * 0.7f); |
268 |
| - pauseBtn.ButtonText.text = pauseButtonPausing ? "►" : "||"; |
269 |
| - } |
| 220 | + |
270 | 221 |
|
271 | 222 | // UI Construction
|
272 | 223 |
|
@@ -298,26 +249,17 @@ private static void CreateTopNavBar()
|
298 | 249 | UIFactory.SetLayoutElement(NavbarTabButtonHolder, minHeight: 25, flexibleHeight: 999, flexibleWidth: 999);
|
299 | 250 | UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(NavbarTabButtonHolder, false, true, true, true, 4, 2, 2, 2, 2);
|
300 | 251 |
|
301 |
| - // Time controls |
302 |
| - |
303 |
| - Text timeLabel = UIFactory.CreateLabel(navbarPanel, "TimeLabel", "Time:", TextAnchor.MiddleRight, Color.grey); |
304 |
| - UIFactory.SetLayoutElement(timeLabel.gameObject, minHeight: 25, minWidth: 50); |
305 |
| - |
306 |
| - timeInput = UIFactory.CreateInputField(navbarPanel, "TimeInput", "timeScale"); |
307 |
| - UIFactory.SetLayoutElement(timeInput.Component.gameObject, minHeight: 25, minWidth: 40); |
308 |
| - timeInput.Component.GetOnEndEdit().AddListener(OnTimeInputEndEdit); |
309 |
| - |
310 |
| - timeInput.Text = string.Empty; |
311 |
| - timeInput.Text = Time.timeScale.ToString(); |
| 252 | + // Time scale widget |
| 253 | + timeScaleWidget = new(navbarPanel); |
312 | 254 |
|
313 |
| - pauseBtn = UIFactory.CreateButton(navbarPanel, "PauseButton", "||", new Color(0.2f, 0.2f, 0.2f)); |
314 |
| - UIFactory.SetLayoutElement(pauseBtn.Component.gameObject, minHeight: 25, minWidth: 25); |
315 |
| - pauseBtn.OnClick += OnPauseButtonClicked; |
| 255 | + //spacer |
| 256 | + GameObject spacer = UIFactory.CreateUIObject("Spacer", navbarPanel); |
| 257 | + UIFactory.SetLayoutElement(spacer, minWidth: 15); |
316 | 258 |
|
317 | 259 | // Hide menu button
|
318 | 260 |
|
319 | 261 | closeBtn = UIFactory.CreateButton(navbarPanel, "CloseButton", ConfigManager.Master_Toggle.Value.ToString());
|
320 |
| - UIFactory.SetLayoutElement(closeBtn.Component.gameObject, minHeight: 25, minWidth: 80, flexibleWidth: 0); |
| 262 | + UIFactory.SetLayoutElement(closeBtn.Component.gameObject, minHeight: 25, minWidth: 60, flexibleWidth: 0); |
321 | 263 | RuntimeHelper.SetColorBlock(closeBtn.Component, new Color(0.63f, 0.32f, 0.31f),
|
322 | 264 | new Color(0.81f, 0.25f, 0.2f), new Color(0.6f, 0.18f, 0.16f));
|
323 | 265 |
|
|
0 commit comments