From 6bbd8297dbbdfd32bed89ab84e54e85bcf30ea5b Mon Sep 17 00:00:00 2001 From: elexis Date: Wed, 6 Dec 2017 21:25:17 +0000 Subject: [PATCH] Fix idle worker button mess. fb65288463 mimicked the sprite_over button functionality which exists as a proper property since 5cc814759f. 0e48b7df75 mimicked the sprite_disable and enabled button functionality. The button now shows the proper highlight sprite if the button became enabled without one of the prior mouseover events being sent. Removes duplicate hardcoded filenames and unneeded globals, functions and conditions. Refs #2414, #3736 Differential Revision: Patch By: temple This was SVN commit r20601. --- .../mods/public/gui/session/minimap_panel.xml | 41 +++++++++---------- .../data/mods/public/gui/session/session.js | 20 +-------- 2 files changed, 22 insertions(+), 39 deletions(-) diff --git a/binaries/data/mods/public/gui/session/minimap_panel.xml b/binaries/data/mods/public/gui/session/minimap_panel.xml index ae8d207941..6980215203 100644 --- a/binaries/data/mods/public/gui/session/minimap_panel.xml +++ b/binaries/data/mods/public/gui/session/minimap_panel.xml @@ -5,28 +5,27 @@ type="image" sprite="mapPanel" > - - - - if (g_HasIdleWorker) findIdleUnit(g_WorkerTypes); - if (g_HasIdleWorker) Engine.GetGUIObjectByName("idleOverlay").sprite = "stretched:session/minimap-idle-highlight.png"; - if (g_HasIdleWorker) Engine.GetGUIObjectByName("idleOverlay").sprite = "stretched:session/minimap-idle.png"; - if (g_HasIdleWorker) Engine.GetGUIObjectByName("idleOverlay").sprite = "stretched:session/minimap-idle.png"; - if (g_HasIdleWorker) Engine.GetGUIObjectByName("idleOverlay").sprite = "stretched:session/minimap-idle-highlight.png"; - - - + handleMinimapEvent(arguments[0]); - - - + + + + + findIdleUnit(g_WorkerTypes); + diff --git a/binaries/data/mods/public/gui/session/session.js b/binaries/data/mods/public/gui/session/session.js index 132b0a7062..5cb74db27e 100644 --- a/binaries/data/mods/public/gui/session/session.js +++ b/binaries/data/mods/public/gui/session/session.js @@ -183,10 +183,6 @@ var g_WorkerTypes = ["FemaleCitizen", "Trader", "FishingBoat", "CitizenSoldier"] * Unit classes to be checked for the military-only-selection modifier and for the idle-warrior-hotkey. */ var g_MilitaryTypes = ["Melee", "Ranged"]; -/** - * Cache the idle worker status. - */ -var g_HasIdleWorker = false; function GetSimState() { @@ -778,27 +774,15 @@ function changeGameSpeed(speed) Engine.SetSimRate(speed); } -function hasIdleWorker() +function updateIdleWorkerButton() { - return Engine.GuiInterfaceCall("HasIdleUnits", { + Engine.GetGUIObjectByName("idleWorkerButton").enabled = Engine.GuiInterfaceCall("HasIdleUnits", { "viewedPlayer": g_ViewedPlayer, "idleClasses": g_WorkerTypes, "excludeUnits": [] }); } -function updateIdleWorkerButton() -{ - g_HasIdleWorker = hasIdleWorker(); - - let idleWorkerButton = Engine.GetGUIObjectByName("idleOverlay"); - let prefix = "stretched:session/"; - - if (!g_HasIdleWorker) - idleWorkerButton.sprite = prefix + "minimap-idle-disabled.png"; - else if (idleWorkerButton.sprite != prefix + "minimap-idle-highlight.png") - idleWorkerButton.sprite = prefix + "minimap-idle.png"; -} function onSimulationUpdate() { // Templates change depending on technologies and auras, so they have to be reloaded every turn.