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

Add Sidebars to the Flight UI #5431

Merged
merged 12 commits into from
Dec 2, 2022
Merged
16 changes: 16 additions & 0 deletions data/lang/ui-core/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2318,5 +2318,21 @@
"ZOOM": {
"description": "Label for a zoom (magnification) control bar.",
"message": "Zoom"
},
"CARGO_CAPACITY": {
"description": "Label to show a ship's total cargo space.",
"message": "Cargo Capacity"
},
"TOGGLE_CARGO_WINDOW": {
"description": "Label for a button toggling the cargo display window.",
"message": "Toggle Cargo Window"
},
"JETTISON_MODE": {
"description": "",
"message": "Jettison Mode"
},
"NO_CARGO": {
"description": "Message displayed when the player has no cargo in their hold.",
"message": "NO CARGO"
}
}
2 changes: 2 additions & 0 deletions data/libs/EquipSet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ local Serializer = require 'Serializer'
-- Class: EquipSet
--
-- A container for a ship's equipment.

---@class EquipSet
local EquipSet = utils.inherits(nil, "EquipSet")

EquipSet.default = {
Expand Down
2 changes: 2 additions & 0 deletions data/libs/Player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
-- Functions for interacting with the Player.
--

---@class Player
local Player = package.core["Player"]

local Serializer = require 'Serializer'
local Event = require 'Event'
local Game = require 'Game'
Expand Down
2 changes: 2 additions & 0 deletions data/libs/Ship.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
-- Copyright © 2008-2022 Pioneer Developers. See AUTHORS.txt for details
-- Licensed under the terms of the GPL v3. See licenses/GPL-3.txt

---@class Ship
local Ship = package.core['Ship']

local Game = package.core['Game']
local Engine = require 'Engine'
local Event = require 'Event'
Expand Down
43 changes: 39 additions & 4 deletions data/libs/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,25 @@ function utils.map_table(table, predicate)
return t
end

--
-- Function: map_array
--
-- Return a new array created from applying a transformer predicate to the
-- values of the provided array object. If the predicate returns a nil value,
-- that value will be skipped.
--
-- Example:
-- > transformed = utils.map_array(t, function(v) return v + 32 end)
--
function utils.map_array(array, predicate)
local t = {}
for i, v in ipairs(array) do
v = predicate(v)
if v ~= nil then table.insert(t, v) end
end
return t
end

--
-- Function: filter_table
--
Expand All @@ -141,6 +160,22 @@ function utils.filter_table(table, predicate)
end
return t
end
--
-- Function: filter_array
--
-- Return a new array created from applying a filter predicate to the values
-- of the provided array object.
--
-- Example:
-- > filtered = utils.filter_array(t, function (i, v) return true end)
--
function utils.filter_array(array, predicate)
local t = {}
for i, v in ipairs(array) do
if predicate(v) then table.insert(t, v) end
end
return t
end

--
-- Function: stable_sort
Expand Down Expand Up @@ -412,27 +447,27 @@ end
--
-- Return an iterator that iterates through the first N values of the given array table.
--
utils.take = function(t, n)
utils.take = function(t, n, skip)
local f = function(s, k)
k = k + 1
if k > n or s[k] == nil then return nil end
return k, s[k]
end
return f, t, 0
return f, t, skip or 0
end

--
-- Function: reverse
--
-- Return an iterator that iterates backwards through the given array table.
--
utils.reverse = function(t)
utils.reverse = function(t, start)
local f = function(s, k)
k = k - 1
if k <= 0 then return end
return k, s[k]
end
return f, t, #t + 1
return f, t, (start or #t) + 1
end

--
Expand Down
173 changes: 173 additions & 0 deletions data/meta/Constants.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
-- Copyright © 2008-2022 Pioneer Developers. See AUTHORS.txt for details
-- Licensed under the terms of the GPL v3. See licenses/GPL-3.txt

-- THIS FILE IS AUTO-GENERATED, CHANGES WILL BE OVERWRITTEN
-- enum table generated by scan_enums.py

---@meta

-- ============================================================================

-- Document lua Constants as typed subclasses of string for API visibility sake

-- A <Constants.PhysicsObjectType> string
---@class PhysicsObjectType: string

-- A <Constants.ShipAIError> string
---@class ShipAIError: string

-- A <Constants.ShipFlightState> string
---@class ShipFlightState: string

-- A <Constants.ShipJumpStatus> string
---@class ShipJumpStatus: string

-- A <Constants.ShipAlertStatus> string
---@class ShipAlertStatus: string

-- A <Constants.ShipAICmdName> string
---@class ShipAICmdName: string

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

-- A <Constants.ShipTypeTag> string
---@class ShipTypeTag: string

-- A <Constants.DockingRefusedReason> string
---@class DockingRefusedReason: string

-- A <Constants.ProjectableTypes> string
---@class ProjectableTypes: string

-- A <Constants.ProjectableBases> string
---@class ProjectableBases: string

-- A <Constants.SystemViewMode> string
---@class SystemViewMode: string

-- A <Constants.SystemViewColorIndex> string
---@class SystemViewColorIndex: string

-- A <Constants.PolitEcon> string
---@class PolitEcon: string

-- A <Constants.PolitGovType> string
---@class PolitGovType: string

-- A <Constants.BodyType> string
---@class BodyType: string

-- A <Constants.BodySuperType> string
---@class BodySuperType: string

-- A <Constants.DetailLevel> string
---@class DetailLevel: string

-- A <Constants.FileSystemRoot> string
---@class FileSystemRoot: string

-- A <Constants.PiGuiFaceFlags> string
---@class PiGuiFaceFlags: string

-- A <Constants.ModelDebugFlags> string
---@class ModelDebugFlags: string

-- A <Constants.CruiseDirection> string
---@class CruiseDirection: string

-- A <Constants.FollowMode> string
---@class FollowMode: string

-- A <Constants.ShipTypeThruster> string
---@class ShipTypeThruster: string

-- A <Constants.PropulsionFuelStatus> string
---@class PropulsionFuelStatus: string

-- A <Constants.ShipControllerFlightControlState> string
---@class ShipControllerFlightControlState: string

-- ============================================================================

-- Global Constants namespace
Constants = {}

---@type PhysicsObjectType[]
Constants.PhysicsObjectType = {}

---@type ShipAIError[]
Constants.ShipAIError = {}

---@type ShipFlightState[]
Constants.ShipFlightState = {}

---@type ShipJumpStatus[]
Constants.ShipJumpStatus = {}

---@type ShipAlertStatus[]
Constants.ShipAlertStatus = {}

---@type ShipAICmdName[]
Constants.ShipAICmdName = {}

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

---@type ShipTypeTag[]
Constants.ShipTypeTag = {}

---@type DockingRefusedReason[]
Constants.DockingRefusedReason = {}

---@type ProjectableTypes[]
Constants.ProjectableTypes = {}

---@type ProjectableBases[]
Constants.ProjectableBases = {}

---@type SystemViewMode[]
Constants.SystemViewMode = {}

---@type SystemViewColorIndex[]
Constants.SystemViewColorIndex = {}

---@type PolitEcon[]
Constants.PolitEcon = {}

---@type PolitGovType[]
Constants.PolitGovType = {}

---@type BodyType[]
Constants.BodyType = {}

---@type BodySuperType[]
Constants.BodySuperType = {}

---@type DetailLevel[]
Constants.DetailLevel = {}

---@type FileSystemRoot[]
Constants.FileSystemRoot = {}

---@type PiGuiFaceFlags[]
Constants.PiGuiFaceFlags = {}

---@type ModelDebugFlags[]
Constants.ModelDebugFlags = {}

---@type CruiseDirection[]
Constants.CruiseDirection = {}

---@type FollowMode[]
Constants.FollowMode = {}

---@type ShipTypeThruster[]
Constants.ShipTypeThruster = {}

---@type PropulsionFuelStatus[]
Constants.PropulsionFuelStatus = {}

---@type ShipControllerFlightControlState[]
Constants.ShipControllerFlightControlState = {}

3 changes: 3 additions & 0 deletions data/meta/Body.lua → data/meta/CoreObject/Body.meta.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
---@class Body
local Body = {}

-- Ensure the CoreImport field is visible to static analysis
package.core["Body"] = Body

--- Get a C++ or Lua component object from the body if present.
---
--- Note: the caller should check the return value if there is a possibility if
Expand Down
11 changes: 6 additions & 5 deletions data/meta/Game.lua → data/meta/CoreObject/Game.meta.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

---@class Game
---
---@field player Body #TODO: add Ship / Player to type tree
---@field player Player The player's current ship
---@field system StarSystem? The system the game is currently playing in or nil when in hyperspace.
---@field systemView unknown #TODO: add type info for SystemView interface
---@field sectorView unknown #TODO: add type info for SectorView interface
Expand Down Expand Up @@ -82,7 +82,8 @@ function Game.GetDateTime() end
function Game.GetPartsFromDateTime(time) end

---@param newAccel string
function Game.SetTimeAcceleration(newAccel) end
---@param force boolean?
function Game.SetTimeAcceleration(newAccel, force) end
---@return string
function Game.GetTimeAcceleration() end
---@return string
Expand All @@ -93,9 +94,9 @@ function Game.InHyperspace() end
---@return number
function Game.GetHyperspaceTravelledPercentage() end

---@param type string
function Game.GetWorldCamType(type) end
---@return string
function Game.SetWorldCamType() end
function Game.GetWorldCamType() end
---@param type string
function Game.SetWorldCamType(type) end

return Game
18 changes: 18 additions & 0 deletions data/meta/CoreObject/ModelBody.meta.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- Copyright © 2008-2022 Pioneer Developers. See AUTHORS.txt for details
-- Licensed under the terms of the GPL v3. See licenses/GPL-3.txt

-- This file implements type information about C++ classes for Lua static analysis

---@meta

---
---@class ModelBody : Body
---
---@field model SceneGraph.Model
---

---@class ModelBody
local ModelBody = {}

-- Ensure the CoreImport field is visible to static analysis
package.core["ModelBody"] = ModelBody
18 changes: 18 additions & 0 deletions data/meta/CoreObject/Player.meta.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- Copyright © 2008-2022 Pioneer Developers. See AUTHORS.txt for details
-- Licensed under the terms of the GPL v3. See licenses/GPL-3.txt

-- This file implements type information about C++ classes for Lua static analysis

---@meta

---
---@class Player : Ship
---

---@class Player : Ship
local Player = {}

-- Ensure the CoreImport field is visible to static analysis
package.core["Player"] = Player

-- TODO: document methods as required
Loading