Skip to content

Commit

Permalink
feat(ui): add keybinding for target radial
Browse files Browse the repository at this point in the history
Add a keybinding to open the target radial menu. The bind is empty by
default as per the other target radials.

This allows keyboard controls to fly to, orbit, or dock with the current
frame object or nav target, as appropriate.
  • Loading branch information
mwerle authored and Webster Sheets committed Nov 14, 2024
1 parent 8a22be7 commit 9d2b55e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions data/pigui/libs/radial-menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ local radial_menu_actions_systembody = {
},
}

function ui.openDefaultRadialMenu(id, body)
function ui.openDefaultRadialMenu(id, body, pos, action_binding)
if body then
local actions = {}
for _,v in pairs(radial_menu_actions_all_bodies) do
Expand All @@ -171,7 +171,7 @@ function ui.openDefaultRadialMenu(id, body)
table.insert(actions, v)
end
end
ui.openRadialMenu(id, body, 1, defaultRadialMenuIconSize, actions, defaultRadialMenuPadding)
ui.openRadialMenu(id, body, 1, defaultRadialMenuIconSize, actions, defaultRadialMenuPadding, pos, action_binding)
end
end

Expand Down
10 changes: 7 additions & 3 deletions data/pigui/modules/flight-ui/reticule.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ local showNavigationalNumbers = true
-- to interact with actions and axes in the input system
local bindings = {
assistRadial = bindManager.registerAction('BindFlightAssistRadial'),
fixheadingRadial = bindManager.registerAction('BindFixheadingRadial')
fixheadingRadial = bindManager.registerAction('BindFixheadingRadial'),
targetRadial = bindManager.registerAction('BindTargetRadial'),
}

-- display the pitch indicator on the right inside of the reticule circle
Expand Down Expand Up @@ -321,8 +322,11 @@ local function displayDetailData(target, radius, colorLight, colorDark, tooltip,
local uiPos = ui.pointOnClock(center, radius, 2.46)
-- label of target
local nameSize = ui.addStyledText(uiPos, ui.anchor.left, ui.anchor.baseline, target.label, colorDark, pionillium.medium, tooltip, colors.lightBlackBackground)
if ui.isMouseHoveringRect(uiPos - Vector2(0, pionillium.medium.size), uiPos + nameSize - Vector2(0, pionillium.medium.size)) and ui.isMouseClicked(1) and ui.noModifierHeld() then
ui.openDefaultRadialMenu("game", target)
local isHovered = ui.isMouseHoveringRect(uiPos - Vector2(0, pionillium.medium.size), uiPos + nameSize - Vector2(0, pionillium.medium.size))
and ui.isMouseClicked(1) and ui.noModifierHeld()
if isHovered or bindings.targetRadial.action:IsJustActive() then
local action_binding = bindings.targetRadial.action:IsActive() and bindings.targetRadial.action
ui.openDefaultRadialMenu("game", target, uiPos, action_binding)
end
-- current distance, relative speed
uiPos = ui.pointOnClock(center, radius, 2.75)
Expand Down
2 changes: 2 additions & 0 deletions src/WorldView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ REGISTER_INPUT_BINDING(WorldView)
// radial menu activators
input->AddActionBinding("BindFlightAssistRadial", group, Action{});
input->AddActionBinding("BindFixheadingRadial", group, Action{});
input->AddActionBinding("BindTargetRadial", group, Action{});
}

void WorldView::InputBinding::RegisterBindings()
Expand All @@ -58,6 +59,7 @@ void WorldView::InputBinding::RegisterBindings()
AddAxis("BindRadialHorizontalSelection");
AddAction("BindFlightAssistRadial");
AddAction("BindFixheadingRadial");
AddAction("BindTargetRadial");
}

WorldView::WorldView(Game *game) :
Expand Down

0 comments on commit 9d2b55e

Please sign in to comment.