Skip to content

Commit

Permalink
Show the system security (lawlessness) in the map sector view
Browse files Browse the repository at this point in the history
  • Loading branch information
JonBooth78 committed Oct 31, 2023
1 parent 23b6700 commit cccaad0
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 2 deletions.
32 changes: 32 additions & 0 deletions data/lang/core/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1627,6 +1627,38 @@
"description": "",
"message": "System orbit view"
},
"SYSTEM_SECURITY_TOOLTIP": {
"description": "Describes how safe or dangerous a star system is",
"message": "System security:"
},
"SYSTEM_SECURITY_1": {
"description": "Describes how safe or dangerous a star system is",
"message": "Safe"
},
"SYSTEM_SECURITY_2": {
"description": "Describes how safe or dangerous a star system is",
"message": "Harmless"
},
"SYSTEM_SECURITY_3": {
"description": "Describes how safe or dangerous a star system is",
"message": "Mostly Harmless"
},
"SYSTEM_SECURITY_4": {
"description": "Describes how safe or dangerous a star system is",
"message": "Somewhat Dangerous"
},
"SYSTEM_SECURITY_5": {
"description": "Describes how safe or dangerous a star system is",
"message": "Dangerous"
},
"SYSTEM_SECURITY_6": {
"description": "Describes how safe or dangerous a star system is",
"message": "Very Dangerous"
},
"SYSTEM_SECURITY_7": {
"description": "Describes how safe or dangerous a star system is",
"message": "Deadly"
},
"SYSTEM_TYPE": {
"description": "",
"message": "System type:"
Expand Down
41 changes: 39 additions & 2 deletions data/pigui/views/map-sector-view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ local ui = require 'pigui'
local layout = require 'pigui.libs.window-layout'

local player = nil
local sytleColors = ui.theme.styleColors
local colors = ui.theme.colors
local icons = ui.theme.icons

Expand All @@ -44,8 +45,10 @@ local draw_out_range_labels = false
local draw_uninhabited_labels = true
local automatic_system_selection = true

local function textIcon(icon, tooltip)
ui.icon(icon, Vector2(ui.getTextLineHeight()), svColor.FONT, tooltip)
local function textIcon(icon, tooltip, color)
if nil == color then color = svColor.FONT end

ui.icon(icon, Vector2(ui.getTextLineHeight()), color, tooltip)
ui.sameLine()
end

Expand Down Expand Up @@ -123,6 +126,28 @@ local function calc_star_dist(star)
return dist
end

local function rate_lawlessness(system)
if system.lawlessness < 1.0/7.0 then
return icons.empty, lc.SYSTEM_SECURITY_1, sytleColors.success_500
end
if system.lawlessness < 2.0/7.0 then
return icons.empty, lc.SYSTEM_SECURITY_2, sytleColors.success_500
end
if system.lawlessness < 3.0/7.0 then
return icons.empty, lc.SYSTEM_SECURITY_3, sytleColors.success_500
end
if system.lawlessness < 4.0/7.0 then
return icons.alert1, lc.SYSTEM_SECURITY_4, sytleColors.danger_100
end
if system.lawlessness < 5.0/7.0 then
return icons.alert1, lc.SYSTEM_SECURITY_5, sytleColors.danger_500
end
if system.lawlessness < 6.0/7.0 then
return icons.alert1, lc.SYSTEM_SECURITY_6, sytleColors.danger_500
end
return icons.alert1, lc.SYSTEM_SECURITY_7, sytleColors.danger_500
end

function Windows.systemInfo:Show()
local label = lc.SELECTED_SYSTEM
local current_systempath = sectorView:GetCurrentSystemPath()
Expand Down Expand Up @@ -170,6 +195,18 @@ function Windows.systemInfo:Show()
ui.textWrapped(starsystem.shortDescription)

ui.spacing()

ui.withTooltip(lc.SYSTEM_SECURITY_TOOLTIP, function()
local icon, desc, color = rate_lawlessness(starsystem)
textIcon(icon, nil, color)
if nil == color then
ui.textWrapped( desc )
else
ui.textColored( color, desc )
end
-- ui.textWrapped( "lln: " .. starsystem.lawlessness)
end)

ui.withTooltip(lc.GOVERNMENT_TYPE, function()
textIcon(icons.language)
ui.textWrapped(starsystem.govDescription)
Expand Down

0 comments on commit cccaad0

Please sign in to comment.