diff --git a/data/lang/input-core/en.json b/data/lang/input-core/en.json index bcc20e4ba0..128f107365 100644 --- a/data/lang/input-core/en.json +++ b/data/lang/input-core/en.json @@ -338,6 +338,10 @@ "description": "Header for the ShipControls input page.", "message": "Ship - Controls" }, + "PAGE_SHIP_HUD": { + "description": "Header for the ShipHUD input page.", + "message": "Ship - HUD" + }, "PAGE_SHIP_VIEW": { "description": "Header for the ShipView input page.", "message": "Ship - View" diff --git a/data/pigui/modules/radar.lua b/data/pigui/modules/radar.lua index a6f9ef965b..d93669ad59 100644 --- a/data/pigui/modules/radar.lua +++ b/data/pigui/modules/radar.lua @@ -24,13 +24,19 @@ local DEFAULT_RADAR_SIZE = 10000 local shouldDisplay2DRadar = false local blobSize = 6.0 +local input_group = 'ShipHUD.RadarControl' local keys = { - radar_toggle_mode = Input.GetActionBinding('BindRadarToggleMode'), - radar_reset = Input.GetActionBinding('BindRadarZoomReset'), - -- TODO: Convert to Axis? - radar_zoom_in = Input.GetActionBinding('BindRadarZoomIn'), - radar_zoom_out = Input.GetActionBinding('BindRadarZoomOut'), + radar_reset = Input.RegisterActionBinding('BindRadarZoomReset', input_group, { activator = { key = Input.keys.slash } } ), + radar_toggle_mode = Input.RegisterActionBinding('BindRadarToggleMode', input_group, { activator = { key = Input.keys.semicolon } } ), + -- TODO: Add axis + radar_zoom_in = Input.RegisterActionBinding('BindRadarZoomIn', input_group, { activator = { key = Input.keys.comma } } ), + radar_zoom_out = Input.RegisterActionBinding('BindRadarZoomOut', input_group, { activator = { key = Input.keys.period } } ), } +local input_frame = Input.CreateInputFrame("ShipHudRadar", false) +input_frame:AddAction(keys.radar_reset) +input_frame:AddAction(keys.radar_toggle_mode) +input_frame:AddAction(keys.radar_zoom_in) +input_frame:AddAction(keys.radar_zoom_out) local function getColorFor(item) local body = item.body @@ -370,6 +376,15 @@ local function displayRadar() end -- function displayRadar() +-- view has changed, update input frame +Event.Register("onViewChanged", function() + if Game.CurrentView() == "world" then + input_frame:AddToStack() + else + input_frame:RemoveFromStack() + end +end) + -- reset radar to default at game end Event.Register("onGameEnd", function() shouldDisplay2DRadar = false diff --git a/src/Pi.cpp b/src/Pi.cpp index a44c0d37e0..f3fbfc5deb 100644 --- a/src/Pi.cpp +++ b/src/Pi.cpp @@ -1216,6 +1216,7 @@ void Pi::RequestQuit() void Pi::SetView(View *v) { + // TODO: Should it be an error or warning to switch the view to itself? if (currentView) currentView->Detach(); currentView = v; if (currentView) currentView->Attach(); diff --git a/src/ship/PlayerShipController.cpp b/src/ship/PlayerShipController.cpp index ca5d684a02..d35fa3abc5 100644 --- a/src/ship/PlayerShipController.cpp +++ b/src/ship/PlayerShipController.cpp @@ -166,13 +166,6 @@ REGISTER_INPUT_BINDING(PlayerShipController) auto landingGroup = controlsPage->GetBindingGroup("LandingControl"); input->AddActionBinding("BindToggleLandingGear", landingGroup, Action({ SDLK_n })); input->AddAxisBinding("BindControlLandingGear", landingGroup, Axis()); - - auto radarGroup = controlsPage->GetBindingGroup("RadarControl"); - input->AddActionBinding("BindRadarZoomReset", radarGroup, Action({ SDLK_DOWN })); - input->AddActionBinding("BindRadarToggleMode", radarGroup, Action({ SDLK_UP })); - input->AddActionBinding("BindRadarZoomIn", radarGroup, Action({ SDLK_LEFT })); - input->AddActionBinding("BindRadarZoomOut", radarGroup, Action({ SDLK_RIGHT })); - input->AddAxisBinding("BindRadarZoom", radarGroup, Axis()); } PlayerShipController::PlayerShipController() : @@ -250,12 +243,6 @@ void PlayerShipController::InputBinding::RegisterBindings() toggleLandingGear = AddAction("BindToggleLandingGear"); controlLandingGear = AddAxis("BindControlLandingGear"); - - AddAction("BindRadarToggleMode"); - AddAction("BindRadarZoomReset"); - // TODO: Convert to axis? - AddAction("BindRadarZoomIn"); - AddAction("BindRadarZoomOut"); } PlayerShipController::~PlayerShipController()