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..0a96f9c340 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'), + 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: Convert to Axis? - radar_zoom_in = Input.GetActionBinding('BindRadarZoomIn'), - radar_zoom_out = Input.GetActionBinding('BindRadarZoomOut'), + 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", true) +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,8 +376,14 @@ local function displayRadar() end -- function displayRadar() +-- enable radar input frame on game start +Event.Register("onGameStart", function() + input_frame:AddToStack() +end) + -- reset radar to default at game end Event.Register("onGameEnd", function() + input_frame:RemoveFromStack() shouldDisplay2DRadar = false radar2d:resetZoom() radar3d:resetZoom() diff --git a/src/ship/PlayerShipController.cpp b/src/ship/PlayerShipController.cpp index ca5d684a02..9d5225ae7b 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() :