Skip to content

Commit

Permalink
Local missions should list distances in AU rather than Ly
Browse files Browse the repository at this point in the history
In table of all player's accepted missions, display distance for
local deliveries in AU, and interstellar in LY.
  • Loading branch information
impaktor committed Feb 10, 2024
1 parent e7f3122 commit d0b585d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions data/pigui/modules/info-view/04-missions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ local textTable = require 'pigui.libs.text-table'
local PiGuiFace = require 'pigui.libs.face'
local InfoView = require 'pigui.views.info-view'

local AU = 1.4960 * 1e11

local pionillium = ui.fonts.pionillium
local orbiteer = ui.fonts.orbiteer
local l = Lang.GetResource("ui-core")
local lc = Lang.GetResource("core")

local columnPadding = ui.rescaleUI(Vector2(18, 18), Vector2(1600, 900))
local itemSpacing = ui.rescaleUI(Vector2(6, 12), Vector2(1600, 900))
Expand Down Expand Up @@ -102,13 +105,24 @@ local function makeMissionRows()
end

local playerSystem = Game.system or Game.player:GetHyperspaceTarget()
local dist = playerSystem:DistanceTo(mission.location)
local days = math.max(0, (mission.due - Game.time) / (24*60*60))

-- Use AU for interplanetary, LY for interstellar distances
local dist, dist_display
if mission.location:IsSameSystem(playerSystem.path) then
local systemBody = mission.location:GetSystemBody().body

dist = Game.player:GetPositionRelTo(systemBody):length() / AU
dist_display = string.format("\n%.2f %s", dist, lc.UNIT_AU)
else
dist = playerSystem:DistanceTo(mission.location)
dist_display = string.format("\n%.2f %s", dist, l.LY)
end

local row = {
mission:GetTypeDescription(),
mission.client.name,
locationName .. string.format("\n%.2f %s", dist, l.LY),
locationName .. dist_display,
ui.Format.Date(mission.due) .."\n".. string.format(l.D_DAYS_LEFT, days),
ui.Format.Money(mission.reward),
}
Expand Down

0 comments on commit d0b585d

Please sign in to comment.