From a27869944d1cd9f1cd0265ae5d012e7cc2fa55b7 Mon Sep 17 00:00:00 2001 From: Hobbeslionheart Date: Sat, 2 Apr 2022 08:27:23 -0400 Subject: [PATCH] Refactored CreateWindow Using the new methods in UIElement, the buttons have been refactored to be inactive to solve issue #1560 if the monster's health is fully damaged. This will prevent some unintended behavior going forward, but more work will be needed in other scripts to prevent this. --- .../Assets/Scripts/Quest/MonsterDialogMoM.cs | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/unity/Assets/Scripts/Quest/MonsterDialogMoM.cs b/unity/Assets/Scripts/Quest/MonsterDialogMoM.cs index 3c9d10a7a..2e2fcf3a8 100644 --- a/unity/Assets/Scripts/Quest/MonsterDialogMoM.cs +++ b/unity/Assets/Scripts/Quest/MonsterDialogMoM.cs @@ -51,26 +51,29 @@ public override void CreateWindow() //Attack Button UIElement ui = new UIElement(); + ui.SetGameObjectName("Attack"); ui.SetLocation(UIScaler.GetHCenter(-8f), 2, 16, 2); - ui.SetText(new StringKey("val","ACTION_X",ATTACK)); + ui.SetText(ATTACK); ui.SetFontSize(UIScaler.GetMediumFont()); - ui.SetButton(Attack); - ui.SetGameObjectName("Attack"); - new UIElementBorder(ui); - + ui.SetActiveState(monster.damage == monster.GetHealth(), false, Attack); + //Evade Button ui = new UIElement(); + ui.SetGameObjectName("Evade"); ui.SetLocation(UIScaler.GetHCenter(-8f), 4.5f, 16, 2); ui.SetText(EVADE); ui.SetFontSize(UIScaler.GetMediumFont()); - ui.SetButton(Evade); - ui.SetGameObjectName("Evade"); - new UIElementBorder(ui); - + ui.SetActiveState(monster.damage == monster.GetHealth(), false, Evade); + + //Cancel Button ui = new UIElement(); ui.SetGameObjectName("Cancel"); ui.SetLocation(UIScaler.GetHCenter(-5f), 7, 10, 2); - if (monster.damage == monster.GetHealth()) + ui.SetText(CommonStringKeys.CANCEL); + ui.SetFontSize(UIScaler.GetMediumFont()); + ui.SetActiveState(monster.damage == monster.GetHealth(), false, OnCancel); + + /*if (monster.damage == monster.GetHealth()) { //Cancel inactive ui.SetText(CommonStringKeys.CANCEL, Color.gray); @@ -82,8 +85,8 @@ public override void CreateWindow() ui.SetText(CommonStringKeys.CANCEL); ui.SetButton(OnCancel); new UIElementBorder(ui); - } - ui.SetFontSize(UIScaler.GetMediumFont()); + }*/ + } }