From 1392ee551d843dd1496438232492a6aa93df19a1 Mon Sep 17 00:00:00 2001 From: Jip Date: Wed, 8 Jun 2022 21:43:34 +0200 Subject: [PATCH] Add guard surrounding expand / contract functions of scoreboard (#3937) --- lua/ui/game/score.lua | 47 +++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/lua/ui/game/score.lua b/lua/ui/game/score.lua index dd3fce150d..849ce2b4f9 100644 --- a/lua/ui/game/score.lua +++ b/lua/ui/game/score.lua @@ -42,6 +42,8 @@ local resModeSwitch = {} local DisplayResMode = 0 local DisplayStorage = 0 +local created = false + function armyGroupHeight() local height = 0 for _, line in controls.armyLines do @@ -51,6 +53,7 @@ function armyGroupHeight() end function CreateScoreUI(parent) + created = true savedParent = GetFrame(0) controls.bg = Group(savedParent) @@ -821,33 +824,37 @@ function ToggleScoreControl(state) end function Expand() - if needExpand then - controls.bg:Show() - controls.collapseArrow:Show() - local sound = Sound({Cue = "UI_Score_Window_Open", Bank = "Interface",}) - PlaySound(sound) - needExpand = false - else - controls.collapseArrow:Show() + if created then + if needExpand then + controls.bg:Show() + controls.collapseArrow:Show() + local sound = Sound({Cue = "UI_Score_Window_Open", Bank = "Interface",}) + PlaySound(sound) + needExpand = false + else + controls.collapseArrow:Show() + end end end function Contract() - if controls.bg then - if not controls.bg:IsHidden() then - local sound = Sound({Cue = "UI_Score_Window_Close", Bank = "Interface",}) - PlaySound(sound) - controls.bg:Hide() - controls.collapseArrow:Hide() - if Prefs.GetFromCurrentProfile("scoreoverlay") ~= false then - needExpand = true + if created then + if controls.bg then + if not controls.bg:IsHidden() then + local sound = Sound({Cue = "UI_Score_Window_Close", Bank = "Interface",}) + PlaySound(sound) + controls.bg:Hide() + controls.collapseArrow:Hide() + if Prefs.GetFromCurrentProfile("scoreoverlay") ~= false then + needExpand = true + end + else + needExpand = false + controls.collapseArrow:Hide() end else - needExpand = false - controls.collapseArrow:Hide() + contractOnCreate = true end - else - contractOnCreate = true end end