feat: page locking, external page changing
This commit is contained in:
@@ -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": "<Gamepad>/select",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Debug Lock Page",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "Binding",
|
||||
"id": "e9c97b2b-23b4-4cde-bfe2-451ddf093b27",
|
||||
"path": "<Gamepad>/dpad/down",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Debug Lock Page",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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<GameObject, List<string>>(thisPageObject, new List<string>());
|
||||
ChangeToPage(pageName);
|
||||
SetCurrentPageVisible();
|
||||
}
|
||||
|
||||
@@ -145,6 +146,21 @@ namespace Reset.Core.Tools{
|
||||
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(){
|
||||
// Do nothing if there's only one page
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user