Skip to content

Commit

Permalink
feat(radar): refactor radar code and improve UI layout
Browse files Browse the repository at this point in the history
This commit is a major refactor of the radar module code.

The scanner and radar were each turned into a class (table) to make the
main draw function more generic.
TODO: there's probably a good way to refactor this further to have
both instruments derive from a base class in order to ensure the same
base functionality.

The layout was also modified significantly with both the left and right
button bars moved further away for an overall less cluttered look. This
made room for a couple of new buttons, one to switch between the scanner
and the radar, and the other to indicate the current scanner zoom mode -
automatic or manual.

In order to get the new buttons near the radar to actually work, they
had to be rendered inside a window as otherwise they are completely
unresponsive the mouse.

HOWEVER, placing the entire randar into the window does not work as the
3D radar's background is not rendered when it's in the window (possibly
due to coordinate issues? Alternatively because it's rendered in C++
instead of LUA?) although its "pips" are.

The 2D radar is rendered properly even when inside a window.

Additionally:

* The 'onChangeMFD' event was removed

* The scanner (3D) and radar (2D azimuth) now each have their own zoom
  level. This prevents the radar from ending up with an auto-zoom zoom
  level when switching from the scanner since it only ever has manual
  zoom.

* The ship-internals window is moved to the left a bit to avoid it
  encroaching on the radar area.

* The autopilot controls are moved to the right a little bit to make
  more room for the zoom-level display.

* The new buttons for the radar are aligned to the left of the radar
  area.

* The scanner was made marginally taller.

* The zoom levels are reset for both the scanner and the radar at game-end.

* Add a debugReload() function to the ship-internals window.
  • Loading branch information
mwerle committed Nov 15, 2024
1 parent 3d54882 commit fcf3e0f
Show file tree
Hide file tree
Showing 4 changed files with 207 additions and 138 deletions.
12 changes: 12 additions & 0 deletions data/lang/ui-core/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,18 @@
"description": "Tooltip: Current distance of the radar.",
"message": "Active radar distance"
},
"HUD_RADAR_ZOOM_MODE_AUTOMATIC": {
"description": "Tooltip: Current radar zoom mode.",
"message": "Automatic zoom"
},
"HUD_RADAR_ZOOM_MODE_MANUAL": {
"description": "Tooltip: Current radar zoom mode.",
"message": "Manual zoom"
},
"HUD_RADAR_TOGGLE_MODE": {
"description": "Tooltip: Toggle radar mode.",
"message": "Toggle radar between 2D and 3D modes"
},
"HUD_REQUEST_TIME_ACCEL": {
"description": "Tooltip: Request time acceleration {time}",
"message": "Request time acceleration: {time}"
Expand Down
3 changes: 2 additions & 1 deletion data/pigui/modules/autopilot-window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ local function displayAutoPilotWindow()
local current_view = Game.CurrentView()
local window_h = mainButtonSize.y + smallButtonSize.y + ui.getWindowPadding().y * 2
local shift = smallButtonSize.y
local window_posx = ui.screenWidth/2 + ui.reticuleCircleRadius / 4 * 3
-- X starting position is the edge of the scanner display.
local window_posx = ui.screenWidth/2 + ui.reticuleCircleRadius
local window_posy = ui.screenHeight - window_h
ui.setNextWindowPos(Vector2(window_posx, window_posy) , "Always")
ui.window("AutoPilot", {"NoTitleBar", "NoResize", "NoFocusOnAppearing", "NoBringToFrontOnFocus", "NoSavedSettings", "AlwaysAutoResize"},
Expand Down
Loading

0 comments on commit fcf3e0f

Please sign in to comment.