Skip to content

Commit

Permalink
Fix #535: Map key bind interferes with race editor help (#573)
Browse files Browse the repository at this point in the history
Added onClientResourceStart and onClientResourceStop event handlers to
listen on the root element.

When both the editor resource, and the race resource are active, it
unbinds toggleMap from F2

When the editor resource is active, and you stop the race resource, it
binds toggleMap back to F2.

Since the help menu in Race is only active when the editor is active,
this should really be the only time it should either bind or unbind the
toggleMap.
  • Loading branch information
MittellBuurman authored Nov 12, 2024
1 parent 2b3bc10 commit e62bc54
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion [gameplay]/freeroam/fr_client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2243,11 +2243,21 @@ addEventHandler('onClientResourceStart', resourceRoot,
createWindow(wndMain)
hideAllWindows()
bindKey('f1', 'down', toggleFRWindow)
bindKey('f2', 'down', toggleMap)
guiCheckBoxSetSelected(getControl(wndMain, 'jetpack'), isPedWearingJetpack(localPlayer))
guiCheckBoxSetSelected(getControl(wndMain, 'falloff'), canPedBeKnockedOffBike(localPlayer))
end
)

addEventHandler('onClientResourceStart', root,
function(startedResource)
local editorResource, raceResource = getResourceFromName('editor'), getResourceFromName('race')
if (editorResource and raceResource and startedResource == raceResource) then
unbindKey('f2', 'down', toggleMap)
end
end
)

function showWelcomeMap()
createWindow(wndSpawnMap)
showCursor(true)
Expand All @@ -2267,7 +2277,6 @@ function toggleMap()
showCursor(true)
end
end
bindKey("f2", "down", toggleMap)

function toggleFRWindow()
if isWindowOpen(wndMain) then
Expand Down Expand Up @@ -2355,6 +2364,15 @@ addEventHandler('onClientResourceStop', resourceRoot,
end
)

addEventHandler('onClientResourceStop', root,
function(stoppingResource)
local editorResource, raceResource = getResourceFromName('editor'), getResourceFromName('race')
if (editorResource and raceResource and stoppingResource == raceResource) then
bindKey('f2', 'down', toggleMap)
end
end
)

function setVehicleGhost(sourceVehicle,value)

local vehicles = getElementsByType("vehicle")
Expand Down

0 comments on commit e62bc54

Please sign in to comment.