From acf2e23d71ab9e28aaeb244192ecc9534417ca97 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 26 Aug 2025 13:50:57 -0400 Subject: [PATCH] feat: page locking, external page changing --- Assets/Player/Input/PlayerInputs.inputactions | 42 +++++++++++++++++++ .../Scripts/Core/Tools/DebugOverlayDrawer.cs | 32 +++++++++++++- 2 files changed, 72 insertions(+), 2 deletions(-) diff --git a/Assets/Player/Input/PlayerInputs.inputactions b/Assets/Player/Input/PlayerInputs.inputactions index 43d65f4..b4f7290 100644 --- a/Assets/Player/Input/PlayerInputs.inputactions +++ b/Assets/Player/Input/PlayerInputs.inputactions @@ -94,6 +94,15 @@ "processors": "", "interactions": "", "initialStateCheck": false + }, + { + "name": "Debug Lock Page", + "type": "Button", + "id": "ad725c08-41d1-45b5-b5c9-3db391721b66", + "expectedControlType": "", + "processors": "", + "interactions": "", + "initialStateCheck": false } ], "bindings": [ @@ -305,6 +314,39 @@ "action": "Debug Next Page", "isComposite": false, "isPartOfComposite": true + }, + { + "name": "One Modifier", + "id": "e3076387-3607-4c5a-ac2d-11e2e03565b0", + "path": "OneModifier", + "interactions": "", + "processors": "", + "groups": "", + "action": "Debug Lock Page", + "isComposite": true, + "isPartOfComposite": false + }, + { + "name": "modifier", + "id": "aea9379f-fc0f-4ee8-affa-13b9f4cf1775", + "path": "/select", + "interactions": "", + "processors": "", + "groups": "", + "action": "Debug Lock Page", + "isComposite": false, + "isPartOfComposite": true + }, + { + "name": "Binding", + "id": "e9c97b2b-23b4-4cde-bfe2-451ddf093b27", + "path": "/dpad/down", + "interactions": "", + "processors": "", + "groups": "", + "action": "Debug Lock Page", + "isComposite": false, + "isPartOfComposite": true } ] } diff --git a/Assets/Scripts/Core/Tools/DebugOverlayDrawer.cs b/Assets/Scripts/Core/Tools/DebugOverlayDrawer.cs index 5ea38ea..fa57e2f 100644 --- a/Assets/Scripts/Core/Tools/DebugOverlayDrawer.cs +++ b/Assets/Scripts/Core/Tools/DebugOverlayDrawer.cs @@ -28,6 +28,7 @@ namespace Reset.Core.Tools{ [Space] public string pageNamePrefix = "Debug Page: "; + public static bool Locked; private static float defaultLabelAlpha; private static float defaultValueAlpha; @@ -77,7 +78,7 @@ namespace Reset.Core.Tools{ } // Otherwise, this will make a new one and add it - UIDocument thisDocument = null; + UIDocument thisDocument; if (thisPageObject == null) { // Create a new object @@ -102,7 +103,7 @@ namespace Reset.Core.Tools{ // If this is the only page, set it to the current page if (Instance.Pages.Count == 1) { - Instance.currentPage = new KeyValuePair>(thisPageObject, new List()); + ChangeToPage(pageName); SetCurrentPageVisible(); } @@ -144,6 +145,21 @@ namespace Reset.Core.Tools{ labelBG.style.backgroundColor = ((newColor / 1.2f + Color.gray * .3f)* .7f).Alpha(defaultLabelAlpha); valueBG.style.backgroundColor = ((newColor / 1.5f + Color.gray * .4f) * .6f) .Alpha(defaultValueAlpha); } + + // Change to a specific page + public static void ChangeToPage(string pageName){ + if (Locked) { + Debug.LogWarning($"Can't switch to page {pageName}: Page is currently locked"); + return; + } + + try { + Instance.currentPage = Instance.Pages.Where(pair => pair.Key.name == Instance.pageNamePrefix + pageName).First(); + } catch (Exception e) { + Debug.LogError($"Couldn't switch page to {pageName}: {e.Message}"); + throw; + } + } // Back a page public static void PreviousPage(){ @@ -152,6 +168,12 @@ namespace Reset.Core.Tools{ return; } + // Lock check + if (Locked) { + Debug.LogWarning($"Attempted to switch to a new page but the page is locked."); + return; + } + // Get the index of the current page int currentIndex = Instance.Pages.ToList().IndexOf(Instance.currentPage); @@ -172,6 +194,12 @@ namespace Reset.Core.Tools{ return; } + // Lock check + if (Locked) { + Debug.LogWarning($"Attempted to switch to a new page but the page is locked."); + return; + } + // Get the index of the current page int currentIndex = Instance.Pages.ToList().IndexOf(Instance.currentPage);