Added UI button to DevDebugWindow to expand it :)

This commit is contained in:
LadyAliceMargatroid 2024-11-04 08:42:15 -08:00
parent 4754677ae3
commit cc019aef1c
4 changed files with 28 additions and 1 deletions

View File

@ -25,6 +25,7 @@ namespace DunGenPlus.DevTools {
public RuntimeDungeon dungeon;
public GameObject devCamera;
public BasePanel[] panels;
public RectTransform canvasRectTransform;
public TMP_Dropdown dungeonFlowSelectionDropDown;
private ExtendedDungeonFlow[] dungeonFlows;
@ -49,6 +50,10 @@ namespace DunGenPlus.DevTools {
private Vector2 cameraYRange;
// canvas
public bool canvasExtended;
private float canvasWidthTarget;
void Awake(){
Instance = this;
@ -70,6 +75,9 @@ namespace DunGenPlus.DevTools {
disabledGameObject.transform.SetParent(transform);
cameraYRange = new Vector2(devCamera.transform.position.y - 200f, devCamera.transform.position.y);
canvasExtended = false;
canvasWidthTarget = 440f;
}
void OnDestroy(){
@ -85,6 +93,10 @@ namespace DunGenPlus.DevTools {
}
void Update(){
var sizeDelta = canvasRectTransform.sizeDelta;
sizeDelta.x = Mathf.Lerp(sizeDelta.x, canvasWidthTarget, Time.deltaTime * 10f);
canvasRectTransform.sizeDelta = sizeDelta;
statusTextMesh.text = dungeon.Generator.Status.ToString();
if (!DevDebugOpen.IsSinglePlayerInShip()) {
@ -111,6 +123,11 @@ namespace DunGenPlus.DevTools {
}
}
public void ToggleCanvasExtended(){
canvasExtended = !canvasExtended;
canvasWidthTarget = canvasExtended ? 800f : 440f;
}
public void SelectDungeonFlow(int index){
selectedExtendedDungeonFlow = dungeonFlows[index];
selectedDungeonFlow = selectedExtendedDungeonFlow.DungeonFlow;

View File

@ -17,6 +17,7 @@ namespace DunGenPlus.DevTools.UIElements {
public LayoutElement layoutElement;
internal float layoutOffset;
internal float layoutWidthBase;
public void SetupBase(TitleParameter titleParameter) {
title = titleParameter.text;
@ -26,8 +27,17 @@ namespace DunGenPlus.DevTools.UIElements {
layoutOffset = titleParameter.offset;
if (layoutElement) {
layoutElement.minWidth -= layoutOffset;
layoutWidthBase = layoutElement.minWidth;
}
}
void Update(){
if (layoutElement) {
var minWidth = layoutWidthBase;
if (DevDebugManager.Instance.canvasExtended) minWidth += 40f;
layoutElement.minWidth = Mathf.Lerp(layoutElement.minWidth, minWidth, Time.deltaTime * 10f);
}
}
public void SetText(string value) {

Binary file not shown.