Skip to content

Commit

Permalink
feat(radar): tweak sizes and positions
Browse files Browse the repository at this point in the history
Radar buttons are now aligned properly with the other buttons on the
screen.

Also fix the 2D radar being slightly clipped by taking into account its
line thickness.
  • Loading branch information
mwerle committed Nov 25, 2024
1 parent c585ef1 commit cbeb0d4
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions data/pigui/modules/radar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ local pionillium = ui.fonts.pionillium
local colors = ui.theme.colors
local icons = ui.theme.icons

local SCREEN_BORDER = 4
local SCREEN_BORDER = 6

local MAX_RADAR_SIZE = 1000000000
local MIN_RADAR_SIZE = 1000
Expand Down Expand Up @@ -112,12 +112,13 @@ local radar3d = {
-- display the 2D radar
radar2d.draw = function(self, center)
local targets = ui.getTargetsNearby(self.zoom)
local halfsize = self.size * 0.5
local thirdsize = self.size * 0.3
local twothirdsize = self.size * 0.7
local lineThickness = 1.5
local size = self.size - lineThickness
local halfsize = size * 0.5
local thirdsize = size * 0.3
local twothirdsize = size * 0.7
local fgColor = colors.uiPrimary
local bgColor = colors.uiBackground:opacity(0.54)
local lineThickness = 1.5

local function line(x,y)
-- Uncomment to extend the radial line all the way to the outer circle
Expand All @@ -126,8 +127,8 @@ radar2d.draw = function(self, center)
end

-- radar background and border
ui.addCircleFilled(center, self.size, bgColor, ui.circleSegments(self.size), 1)
ui.addCircle(center, self.size, fgColor, ui.circleSegments(self.size), lineThickness * 2)
ui.addCircleFilled(center, size, bgColor, ui.circleSegments(size), 1)
ui.addCircle(center, size, fgColor, ui.circleSegments(size), lineThickness * 2)

-- inner circles
-- Uncomment to add an additional circle dividing the 2D radar display
Expand All @@ -152,7 +153,7 @@ radar2d.draw = function(self, center)
if v.distance > halfRadarSize then
alpha = 255 * (1 - (v.distance - halfRadarSize) / halfRadarSize)
end
local position = center + v.aep * self.size * 2
local position = center + v.aep * size * 2
if v.body == navTarget then
local color = Color(colors.navTarget.r, colors.navTarget.g, colors.navTarget.b, alpha)
ui.addIcon(position, icons.square, color, Vector2(12, 12), ui.anchor.center, ui.anchor.center)
Expand Down Expand Up @@ -340,7 +341,7 @@ local function displayRadar()
-- This is in a window so the buttons work and the mouse-wheel is captured
local window_width = ui.reticuleCircleRadius * 1.8
local window_height = radar2d.size * 2
local window_pos = Vector2(center.x - window_width / 2, center.y - radar2d.size - SCREEN_BORDER)
local window_pos = Vector2(center.x - window_width / 2, center.y - window_height / 2)
local windowFlags = ui.WindowFlags {"NoTitleBar", "NoResize", "NoFocusOnAppearing", "NoBringToFrontOnFocus", "NoSavedSettings"}
ui.setNextWindowPos(window_pos, "Always")
ui.setNextWindowPadding(Vector2(0))
Expand Down

0 comments on commit cbeb0d4

Please sign in to comment.