Skip to content

Commit

Permalink
feat(radar): improve 'onViewChanged' event handler
Browse files Browse the repository at this point in the history
Use the new 'onViewChanged' event parameters to only add/remove the radar
input frame if the view changes to/from "WorldView".
  • Loading branch information
mwerle committed Nov 18, 2024
1 parent def48f2 commit cea0b81
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions data/pigui/modules/radar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ input_frame:AddAction(keys.radar_toggle_mode)
input_frame:AddAction(keys.radar_zoom_in)
input_frame:AddAction(keys.radar_zoom_out)

keys.radar_reset:OnPressed(function()
print("[DBG] radar_reset pressed.")
end)

local function getColorFor(item)
local body = item.body
if body == player:GetNavTarget() then
Expand Down Expand Up @@ -377,10 +381,10 @@ local function displayRadar()
end -- function displayRadar()

-- view has changed, update input frame
Event.Register("onViewChanged", function()
if Game.CurrentView() == "WorldView" then
Event.Register("onViewChanged", function(newView, previousView)
if newView == "WorldView" then
input_frame:AddToStack()
else
elseif previousView == "WorldView" then
input_frame:RemoveFromStack()
end
end)
Expand Down

0 comments on commit cea0b81

Please sign in to comment.