Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firestate Hotkey Instant Response #6586

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/snippets/fix.6586.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(#6586) Firestate toggle hotkey shows instant response on the order button ui instead of the half second delay it had previously.
3 changes: 2 additions & 1 deletion lua/ui/game/gamemain.lua
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,8 @@ function OnSelectionChanged(oldSelection, newSelection, added, removed)
local isOldSelection = table.equal(oldSelection, newSelection)

if not gameUIHidden then
if not isReplay then
-- Not necessary to update the available orders if we're in a replay or the selection hasn't changed
if not (isReplay or isOldSelection) then
import("/lua/ui/game/orders.lua").SetAvailableOrders(availableOrders, availableToggles, newSelection)
end
-- TODO change the current command mode if no longer available? or set to nil?
Expand Down
31 changes: 17 additions & 14 deletions lua/ui/game/orders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -826,16 +826,6 @@ local function CreateFirestatePopup(parent, selected)
end

local function RetaliateOrderBehavior(self, modifiers)
if not self._OnFirestateSelection then
self._OnFirestateSelection = function(self, newState, id)
self._toggleState = newState
SetFireState(currentSelection, id)
self:SetNewTextures(GetOrderBitmapNames(retaliateStateInfo[newState].bitmap))
self._curHelpText = retaliateStateInfo[newState].helpText
self._popup:Destroy()
self._popup = nil
end
end
if self._popup then
self._popup:Destroy()
self._popup = nil
Expand Down Expand Up @@ -889,14 +879,27 @@ local function RetaliateInitFunction(control, unitList)
end
Checkbox.OnDisable(self)
end
control.CycleFireStateUp = function(self)
local newState = self._toggleState >= 2 and 0 or self._toggleState + 1
self:_OnFirestateSelection(newState, retaliateStateInfo[newState].id)
end
control._OnFirestateSelection = function(self, newState, id)
self._toggleState = newState
SetFireState(currentSelection, id)
self:SetNewTextures(GetOrderBitmapNames(retaliateStateInfo[newState].bitmap))
self._curHelpText = retaliateStateInfo[newState].helpText
if self._popup then
self._popup:Destroy()
self._popup = nil
end
end
end

function CycleRetaliateStateUp()
local currentFireState = GetFireState(currentSelection)
if currentFireState > 3 then
currentFireState = 0
local retaliateCheckbox = orderCheckboxMap["RULEUCC_RetaliateToggle"]
if retaliateCheckbox then
retaliateCheckbox:CycleFireStateUp()
end
ToggleFireState(currentSelection, currentFireState)
end

local function pauseFunc()
Expand Down
Loading