feat: page locking, external page changing
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user