Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #5343 Missing info #5439

Merged
merged 2 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,13 @@ if (NATURALDOCS)
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
endif()

find_program(PYTHON NAMES python)
if (PYTHON)
add_custom_target(enums
COMMAND scripts/scan_enums.py -o src/enum_table.cpp --pattern='*.h' -r src
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
endif()

target_link_libraries(pioneer-lib PUBLIC lz4 fmt::fmt)

list(APPEND pioneerLibs
Expand Down
2 changes: 1 addition & 1 deletion data/factions/001_Solar_Federation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
local f = Faction:new('Solar Federation')
:description_short('The historical birthplace of humankind')
:description('Sol is a fine joint')
:homeworld(0,0,0,0,4)
:homeworld(0,0,0,0,16) --Mars
:foundingDate(3050)
:expansionRate(1)
:military_name('SolFed Military')
Expand Down
8 changes: 8 additions & 0 deletions data/lang/ui-core/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2099,6 +2099,10 @@
"description": "Lobby screen shows the tech level of the station",
"message": "This installation holds a military technology clearance."
},
"TECH_LEVEL": {
"description": "System view label for technology level",
"message": "Tech level"
},
"TEXTURE_COMPRESSION": {
"description": "",
"message": "This frees up more memory for the graphics card, which is likely what you want, at the expense of compressing them during game start."
Expand Down Expand Up @@ -2207,6 +2211,10 @@
"description": "",
"message": "Unoccupied Passenger Cabins"
},
"PASSENGER_CABIN_CAPACITY": {
"description": "Entry for ship info",
"message": "Passenger cabin capacity"
},
"UNPROFITABLE_TRADE": {
"description": "Indicates an unprofitable trade route.",
"message": "Unprofitable Trade"
Expand Down
18 changes: 13 additions & 5 deletions data/libs/SpaceStation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,23 @@ local l = Lang.GetResource("ui-core")
-- Class: SpaceStation
--

function SpaceStation:Constructor()
-- Use a variation of the space station seed itself to ensure consistency
local rand = Rand.New(self.seed .. '-techLevel')
function SpaceStation.GetTechLevel(systemBody)

local rand = Rand.New(systemBody.seed .. '-techLevel')
local techLevel = rand:Integer(1, 6) + rand:Integer(0,6)
if Game.system.faction ~= nil and Game.system.faction.hasHomeworld and Game.system.faction.homeworld == self.path:GetSystemBody().parent.path then
local system = systemBody.path:GetStarSystem()

if system.faction ~= nil and system.faction.hasHomeworld and system.faction.homeworld == systemBody.parent.path then
techLevel = math.max(techLevel, 6) -- bump it upto at least 6 if it's a homeworld like Earth
end
-- cap the techlevel lower end based on the planets population
techLevel = math.max(techLevel, math.min(math.floor(self.path:GetSystemBody().parent.population * 0.5), 11))
techLevel = math.max(techLevel, math.min(math.floor(systemBody.parent.population * 0.5), 11))
return techLevel;
end

function SpaceStation:Constructor()
techLevel = SpaceStation.GetTechLevel(self.path:GetSystemBody())

self:setprop("techLevel", techLevel)
end

Expand Down
8 changes: 4 additions & 4 deletions data/meta/Constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
-- A <Constants.ShipAICmdName> string
---@class ShipAICmdName: string

-- A <Constants.HardpointTag> string
---@class HardpointTag: string
-- A <Constants.DualLaserOrientation> string
---@class DualLaserOrientation: string

-- A <Constants.ShipTypeTag> string
---@class ShipTypeTag: string
Expand Down Expand Up @@ -111,8 +111,8 @@ Constants.ShipAlertStatus = {}
---@type ShipAICmdName[]
Constants.ShipAICmdName = {}

---@type HardpointTag[]
Constants.HardpointTag = {}
---@type DualLaserOrientation[]
Constants.DualLaserOrientation = {}

---@type ShipTypeTag[]
Constants.ShipTypeTag = {}
Expand Down
1 change: 1 addition & 0 deletions data/pigui/modules/info-view/01-ship-info.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ local function shipStats()
{ l.CREW_CABINS..":", shipDef.maxCrew },
{ l.UNOCCUPIED_PASSENGER_CABINS..":", cabinEmpty },
{ l.OCCUPIED_PASSENGER_CABINS..":", cabinOccupied },
{ l.PASSENGER_CABIN_CAPACITY..":", shipDef.equipSlotCapacity.cabin},
false,
{ l.MISSILE_MOUNTS..":", shipDef.equipSlotCapacity.missile},
{ l.SCOOP_MOUNTS..":", shipDef.equipSlotCapacity.scoop},
Expand Down
3 changes: 2 additions & 1 deletion data/pigui/modules/station-view/04-shipMarket.lua
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ local tradeMenu = function()
l.ATMOSPHERIC_SHIELDING, yes_no(def.equipSlotCapacity["atmo_shield"]),
l.ATMO_PRESS_LIMIT, atmoSlot
}, {
l.SCOOP_MOUNTS, def.equipSlotCapacity["scoop"]
l.SCOOP_MOUNTS, def.equipSlotCapacity["scoop"],
l.PASSENGER_CABIN_CAPACITY, def.equipSlotCapacity["cabin"]
},
}

Expand Down
132 changes: 76 additions & 56 deletions data/pigui/modules/system-view-ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local Event = require 'Event'
local Lang = require 'Lang'
local ui = require 'pigui'
local Format = require 'Format'
local SpaceStation = require 'SpaceStation'
local Constants = _G.Constants

local Vector2 = _G.Vector2
Expand Down Expand Up @@ -711,12 +712,15 @@ function Windows.objectInfo.ShouldShow()
return true
end

function Windows.objectInfo.Show()
function Windows.objectInfo:Show()
local obj = systemView:GetSelectedObject()

local isSystemBody = obj.base == Projectable.SYSTEMBODY
local body = obj.ref

--FIXME there is some flickering when changing from one info to another
--which has different lenght. If the new one is shorter then the first header drawing
--seems to be too high (accodring to positioning relative to old info).
--Probably only durring the second drawing the position is ok. The window is anchored at bottom
textIcon(getBodyIcon(obj))
ui.text(isSystemBody and body.name or body.label)
ui.spacing()
Expand All @@ -730,62 +734,78 @@ function Windows.objectInfo.Show()
ui.separator()
ui.spacing()

local data = { }

if isSystemBody then -- system body
local parent = body.parent
local starport = body.superType == "STARPORT"
local surface = body.type == "STARPORT_SURFACE"
local sma = body.semiMajorAxis
local semimajoraxis = nil
if sma and sma > 0 then
semimajoraxis = ui.Format.Distance(sma)
end
local data = {}

local rp = body.rotationPeriod * 24 * 60 * 60
local op = body.orbitPeriod * 24 * 60 * 60
local pop = math.round(body.population * 1e9)
data = {
{ name = lc.MASS, icon = icons.body_radius,
value = (not starport) and ui.Format.Mass(body.mass) or nil },
{ name = lc.RADIUS, icon = icons.body_radius,
value = (not starport) and ui.Format.Distance(body.radius) or nil },
{ name = lc.SURFACE_GRAVITY, icon = icons.body_radius,
value = (not starport) and ui.Format.Speed(body.gravity, true).." ("..ui.Format.Gravity(body.gravity / 9.8066)..")" or nil },
{ name = lc.ORBITAL_PERIOD, icon = icons.body_orbit_period,
value = op and op > 0 and ui.Format.Duration(op, 2) or nil },
{ name = lc.DAY_LENGTH, icon = icons.body_day_length,
value = rp > 0 and ui.Format.Duration(rp, 2) or nil },
{ name = luc.ORBIT_APOAPSIS, icon = icons.body_semi_major_axis,
value = (parent and not surface) and ui.Format.Distance(body.apoapsis) or nil },
{ name = luc.ORBIT_PERIAPSIS, icon = icons.body_semi_major_axis,
value = (parent and not surface) and ui.Format.Distance(body.periapsis) or nil },
{ name = lc.SEMI_MAJOR_AXIS, icon = icons.body_semi_major_axis,
value = semimajoraxis },
{ name = lc.ECCENTRICITY, icon = icons.body_semi_major_axis,
value = (parent and not surface) and string.format("%0.2f", body.eccentricity) or nil },
{ name = lc.AXIAL_TILT, icon = icons.body_semi_major_axis,
value = (not starport) and string.format("%0.2f", body.axialTilt) or nil },
{ name = lc.POPULATION, icon = icons.personal,
value = pop > 0 and ui.Format.NumberAbbv(pop) or nil },

}

elseif obj.ref:IsShip() then -- physical body
-- TODO: the advanced target scanner should add additional data here,
-- but we really do not want to hardcode that here. there should be
-- some kind of hook that the target scanner can hook into to display
-- more info here.
-- This is what should be inserted:
table.insert(data, { name = luc.SHIP_TYPE, value = body:GetShipType() })
if player:GetEquipCountOccupied('target_scanner') > 0 or player:GetEquipCountOccupied('advanced_target_scanner') > 0 then
local hd = body:GetEquip("engine", 1)
table.insert(data, { name = luc.HYPERDRIVE, value = hd and hd:GetName() or lc.NO_HYPERDRIVE })
table.insert(data, { name = luc.MASS, value = Format.MassTonnes(body:GetStats().staticMass) })
table.insert(data, { name = luc.CARGO, value = Format.MassTonnes(body:GetStats().usedCargo) })
end
--SystemBody data is static so we use cache
--Ship data migh be dynamic in the future
if isSystemBody and self.prev_body == body then
data = self.data
else
data = {}
self.prev_body = body

if isSystemBody then -- system body
local parent = body.parent
local starport = body.superType == "STARPORT"
local surface = body.type == "STARPORT_SURFACE"
local sma = body.semiMajorAxis
local semimajoraxis = nil
if sma and sma > 0 then
semimajoraxis = ui.Format.Distance(sma)
end
local rp = body.rotationPeriod * 24 * 60 * 60
local op = body.orbitPeriod * 24 * 60 * 60
local pop = math.round(body.population * 1e9)
local techLevel = starport and SpaceStation.GetTechLevel(body) or nil
if techLevel == 11 then
techLevel = luc.MILITARY
end
data = {
{ name = lc.MASS, icon = icons.body_radius,
value = (not starport) and ui.Format.Mass(body.mass) or nil },
{ name = lc.RADIUS, icon = icons.body_radius,
value = (not starport) and ui.Format.Distance(body.radius) or nil },
{ name = lc.SURFACE_GRAVITY, icon = icons.body_radius,
value = (not starport) and ui.Format.Speed(body.gravity, true).." ("..ui.Format.Gravity(body.gravity / 9.8066)..")" or nil },
{ name = lc.ORBITAL_PERIOD, icon = icons.body_orbit_period,
value = op and op > 0 and ui.Format.Duration(op, 2) or nil },
{ name = lc.DAY_LENGTH, icon = icons.body_day_length,
value = rp > 0 and ui.Format.Duration(rp, 2) or nil },
{ name = luc.ORBIT_APOAPSIS, icon = icons.body_semi_major_axis,
value = (parent and not surface) and ui.Format.Distance(body.apoapsis) or nil },
{ name = luc.ORBIT_PERIAPSIS, icon = icons.body_semi_major_axis,
value = (parent and not surface) and ui.Format.Distance(body.periapsis) or nil },
{ name = lc.SEMI_MAJOR_AXIS, icon = icons.body_semi_major_axis,
value = semimajoraxis },
{ name = lc.ECCENTRICITY, icon = icons.body_semi_major_axis,
value = (parent and not surface) and string.format("%0.2f", body.eccentricity) or nil },
{ name = lc.AXIAL_TILT, icon = icons.body_semi_major_axis,
value = (not starport) and string.format("%0.2f", body.axialTilt) or nil },
{ name = lc.POPULATION, icon = icons.personal,
value = pop > 0 and ui.Format.NumberAbbv(pop) or nil },
{ name = luc.TECH_LEVEL, icon = icons.equipment,
value = starport and techLevel or nil }
}

--change the internal cached data only when new is fully built
--prevents additional flickering
self.data = data

elseif obj.ref:IsShip() then -- physical body
-- TODO: the advanced target scanner should add additional data here,
-- but we really do not want to hardcode that here. there should be
-- some kind of hook that the target scanner can hook into to display
-- more info here.
-- This is what should be inserted:
table.insert(data, { name = luc.SHIP_TYPE, value = body:GetShipType() })
if player:GetEquipCountOccupied('target_scanner') > 0 or player:GetEquipCountOccupied('advanced_target_scanner') > 0 then
local hd = body:GetEquip("engine", 1)
table.insert(data, { name = luc.HYPERDRIVE, value = hd and hd:GetName() or lc.NO_HYPERDRIVE })
table.insert(data, { name = luc.MASS, value = Format.MassTonnes(body:GetStats().staticMass) })
table.insert(data, { name = luc.CARGO, value = Format.MassTonnes(body:GetStats().usedCargo) })
end
else
Web-eWorks marked this conversation as resolved.
Show resolved Hide resolved
data = {}
end
end

ui.withFont(detailfont, function()
Expand Down