diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c1b185ea72..39c16b7eec9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/data/factions/001_Solar_Federation.lua b/data/factions/001_Solar_Federation.lua index ff0ae833a3f..0a21cddfd6f 100644 --- a/data/factions/001_Solar_Federation.lua +++ b/data/factions/001_Solar_Federation.lua @@ -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') diff --git a/data/lang/ui-core/en.json b/data/lang/ui-core/en.json index 71d5bf607be..2b1ea480752 100644 --- a/data/lang/ui-core/en.json +++ b/data/lang/ui-core/en.json @@ -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." @@ -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" diff --git a/data/libs/SpaceStation.lua b/data/libs/SpaceStation.lua index be9e3176556..e5081ef9678 100644 --- a/data/libs/SpaceStation.lua +++ b/data/libs/SpaceStation.lua @@ -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 diff --git a/data/meta/Constants.lua b/data/meta/Constants.lua index 6697b12e49b..7c2f053afd1 100644 --- a/data/meta/Constants.lua +++ b/data/meta/Constants.lua @@ -28,8 +28,8 @@ -- A string ---@class ShipAICmdName: string --- A string ----@class HardpointTag: string +-- A string +---@class DualLaserOrientation: string -- A string ---@class ShipTypeTag: string @@ -111,8 +111,8 @@ Constants.ShipAlertStatus = {} ---@type ShipAICmdName[] Constants.ShipAICmdName = {} ----@type HardpointTag[] -Constants.HardpointTag = {} +---@type DualLaserOrientation[] +Constants.DualLaserOrientation = {} ---@type ShipTypeTag[] Constants.ShipTypeTag = {} diff --git a/data/pigui/modules/info-view/01-ship-info.lua b/data/pigui/modules/info-view/01-ship-info.lua index 8bf1e1e529d..4060cbc6276 100644 --- a/data/pigui/modules/info-view/01-ship-info.lua +++ b/data/pigui/modules/info-view/01-ship-info.lua @@ -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}, diff --git a/data/pigui/modules/station-view/04-shipMarket.lua b/data/pigui/modules/station-view/04-shipMarket.lua index 9eb51792a81..97704aab887 100644 --- a/data/pigui/modules/station-view/04-shipMarket.lua +++ b/data/pigui/modules/station-view/04-shipMarket.lua @@ -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"] }, } diff --git a/data/pigui/modules/system-view-ui.lua b/data/pigui/modules/system-view-ui.lua index 9f3951fe719..d1a48dc365b 100644 --- a/data/pigui/modules/system-view-ui.lua +++ b/data/pigui/modules/system-view-ui.lua @@ -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 @@ -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() @@ -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 + data = {} + end end ui.withFont(detailfont, function()