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

feat(ui): add keybinding for target radial #5962

Merged
merged 1 commit into from
Nov 14, 2024
Merged
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
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