Skip to content

Commit

Permalink
fix(client): refresh options when menu changes
Browse files Browse the repository at this point in the history
Opening a menu from a global option, without any entity
or zone being targeted, failed to refresh options. Maybe
affects some other cases.
  • Loading branch information
thelindat committed May 17, 2024
1 parent 3dc7eb3 commit 472e1cc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ local GetModelDimensions = GetModelDimensions
local GetOffsetFromEntityInWorldCoords = GetOffsetFromEntityInWorldCoords
local currentTarget = {}
local currentMenu
local menuChanged
local menuHistory = {}
local nearbyZones

Expand Down Expand Up @@ -203,7 +204,7 @@ local function startTargeting()
nearbyZones, zonesChanged = utils.getNearbyZones(endCoords)

local entityChanged = entityHit ~= lastEntity
local newOptions = (zonesChanged or entityChanged) and true
local newOptions = (zonesChanged or entityChanged or menuChanged) and true

if entityHit > 0 and entityChanged then
currentMenu = nil
Expand Down Expand Up @@ -298,7 +299,7 @@ local function startTargeting()
hasTarget = false
SendNuiMessage('{"event": "leftTarget"}')
end
elseif hasTarget ~= 1 and hidden ~= totalOptions then
elseif menuChanged or hasTarget ~= 1 and hidden ~= totalOptions then
hasTarget = options.size

if currentMenu then
Expand All @@ -319,6 +320,8 @@ local function startTargeting()
zones = zones,
}, { sort_keys = true }))
end

menuChanged = false
end

if toggleHotkey and IsPauseMenuActive() then
Expand Down Expand Up @@ -424,6 +427,7 @@ RegisterNUICallback('select', function(data, cb)
menuHistory[menuDepth + 1] = currentMenu
end

menuChanged = true
currentMenu = option.openMenu ~= 'home' and option.openMenu or nil
else
state.setNuiFocus(false)
Expand Down

0 comments on commit 472e1cc

Please sign in to comment.