Skip to content

Commit

Permalink
Merge pull request #6029 from Gliese852/equip-v2-newgame
Browse files Browse the repository at this point in the history
Add support for new equipment to the game start menu.
  • Loading branch information
sturnclaw authored Jan 28, 2025
2 parents 312098f + cbb15f5 commit 3800ddc
Show file tree
Hide file tree
Showing 13 changed files with 1,640 additions and 474 deletions.
60 changes: 60 additions & 0 deletions data/lang/equipment-core/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
"description": "",
"message": "2MW rapid-fire beam laser"
},
"BY_ITEM": {
"description": "Button in the start menu when editing equipment",
"message": "By item"
},
"BY_SLOT": {
"description": "Button in the start menu when editing equipment",
"message": "By slot"
},
"CABINS": {
"description": "Category header for pressurized cabin slots",
"message": "Cabins"
Expand Down Expand Up @@ -163,10 +171,22 @@
"description": "",
"message": "Activate Electronic Countermeasures"
},
"EDIT_EQUIPMENT": {
"description": "Dialog title",
"message": "Edit equipment"
},
"EMPTY_EQUIPMENT_PROVIDING_SLOTS": {
"description": "Tooltip for wrong equipment item",
"message": "Empty equipment providing slots"
},
"EMPTY_SLOT": {
"description": "Text indicating an empty equipment slot.",
"message": "EMPTY"
},
"EQUIPMENT_DOES_NOT_FIT_INTO_THE_SLOT": {
"description": "Tooltip for wrong equipment item",
"message": "Equipment does not fit into the slot"
},
"EQUIPMENT_INTEGRITY": {
"description": "Tooltip explaining remaining equipment integrity",
"message": "Equipment Integrity"
Expand Down Expand Up @@ -295,6 +315,14 @@
"description": "",
"message": "Analyze hyperspace clouds to determine destination and time of arrival or departure."
},
"INVALID_SLOT": {
"description": "Tooltip for wrong equipment item",
"message": "Invalid slot"
},
"ITEM": {
"description": "A piece of equipment",
"message": "Item"
},
"LARGE_PLASMA_ACCEL": {
"description": "",
"message": "Large plasma accelerator"
Expand Down Expand Up @@ -527,6 +555,14 @@
"message": "Mass-produced by local manufacturers on most worlds. These range from being lovingly hand-crafted by artisans on developing worlds to being mindlessly churned out by the millions in automated mega-factories on hyper-industrialised ones.\nBut regardless from where they are sourced, the specifications are tightly controlled by the ISAEEE and should work in most compatible ship systems."
},

"NO_SUITABLE_EQUIPMENT": {
"description": "Message in the start menu when editing equipment",
"message": "No suitable equipment"
},
"NO_SUITABLE_SLOTS": {
"description": "Message in the start menu when editing equipment",
"message": "No suitable slots"
},
"OCCUPIED_BERTHS": {
"description": "Label for the number of passenger berths currently occupied in a cabin equipment item",
"message": "Occupied Berths"
Expand Down Expand Up @@ -637,6 +673,10 @@
"description": "Name for an equipment item that reinforces the hull's superstructure",
"message": "Reinforced Structure"
},
"REQUIRED_SLOT_IS_EMPTY": {
"description": "Tooltip for wrong equipment item",
"message": "Required slot is empty"
},
"SCAN_COMPLETED": {
"description": "",
"message": "Scanning completed"
Expand Down Expand Up @@ -781,6 +821,14 @@
"description": "",
"message": "Used to remotely inspect the equipment, cargo and state of other ships."
},
"TARGET_SLOT_IS_NOT_EMPTY_PUT_THE_REPLACED_ONE_IN_THE_CLIPBOARD_QUESTION": {
"description": "Message in the start menu when editing equipment",
"message": "Target slot is not empty, put the replaced one in the clipboard?"
},
"THE_SAME_EQUIPMENT_HAS_BEEN_ALREADY_INSTALLED": {
"description": "Message in the start menu when editing equipment",
"message": "The same equipment has been already installed."
},
"THRUSTERS_DEFAULT": {
"description": "Equipment name for default RCS thrusters",
"message": "Default Thrusters"
Expand Down Expand Up @@ -840,5 +888,17 @@
"WEAPONS": {
"description": "Category name of weapon-related equipment",
"message": "Weapons"
},
"SLOT": {
"description": "",
"message": "Slot"
},
"SLOT_IS_NOT_EMPTY_REPLACE_THE_EQUIPMENT_QUESTION": {
"description": "",
"message": "Slot is not empty, replace the equipment?"
},
"SLOTLESS": {
"description": "",
"message": "Slotless"
}
}
20 changes: 20 additions & 0 deletions data/lang/ui-core/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@
"description": "",
"message": "Control Options"
},
"COPY": {
"description": "As for clipboard",
"message": "Copy"
},
"COULD_NOT_DELETE_SAVE": {
"description": "",
"message": "Could not delete save"
Expand Down Expand Up @@ -387,6 +391,10 @@
"description": "For hyperjump planner",
"message": "Current system"
},
"CUT": {
"description": "As for clipboard",
"message": "Cut"
},
"DANGEROUS": {
"description": "Player combat rating",
"message": "Dangerous"
Expand Down Expand Up @@ -627,6 +635,10 @@
"description": "When failed mission",
"message": "Failed"
},
"FAILED_TO_RECOVER_SOME_EQUIPMENT": {
"description": "",
"message": "Failed to recover some equipment"
},
"FEATURE_ACCESSORIES": {
"description": "Face feature for FaceGenerator in the PersonalInfo view",
"message": "Accessories"
Expand Down Expand Up @@ -1315,6 +1327,10 @@
"description": "Ship jump status",
"message": "Initiated"
},
"INSTALL": {
"description": "Install something",
"message": "Install"
},
"INSTALLED": {
"description": "Label indicating something is installed",
"message": "Installed"
Expand Down Expand Up @@ -1879,6 +1895,10 @@
"description": "Entry for ship info",
"message": "Passenger cabin capacity"
},
"PASTE": {
"description": "As for clipboard",
"message": "Paste"
},
"PATH_FOUND_BUT_VERIFICATION_FAILED": {
"description": "Message when restoring savegame",
"message": "Path found but verification failed: %s"
Expand Down
21 changes: 21 additions & 0 deletions data/libs/autoload.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,27 @@ table.merge = function(a, b, transformer)
return a
end

-- Copy table recursively using pairs()
--
-- Does not copy metatable
---@generic T
---@param t T
---@return T
table.deepcopy = function(t)

if not t then return nil end

local result = {}
for k, v in pairs(t) do
if type(v) == 'table' then
result[k] = table.deepcopy(v)
else
result[k] = v
end
end
return result
end

-- Append array b to array a
--
-- Does not copy metatable nor recurse into the table.
Expand Down
7 changes: 6 additions & 1 deletion data/pigui/libs/forwarded.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ local pigui = Engine.pigui
---@class ui
local ui = {}

ui.raw = pigui

ui.calcTextAlignment = pigui.CalcTextAlignment
ui.alignTextToLineHeight = pigui.AlignTextToLineHeight
ui.alignTextToFramePadding = pigui.AlignTextToFramePadding
Expand All @@ -20,6 +22,7 @@ ui.screenHeight = pigui.screen_height

ui.bringWindowToDisplayFront = pigui.bringWindowToDisplayFront ---@type fun()

ui.setKeyboardFocusHere = pigui.SetKeyboardFocusHere ---@type fun(offset: number?)
-- Return the size of the specified window's contents from last frame (without padding/decoration)
-- Returns {0,0} if the window hasn't been submitted during the lifetime of the program
ui.getWindowContentSize = pigui.GetWindowContentSize ---@type fun(name: string): Vector2
Expand Down Expand Up @@ -127,7 +130,9 @@ ui.playSfx = pigui.PlaySfx
ui.isItemHovered = pigui.IsItemHovered
ui.isItemActive = pigui.IsItemActive
ui.isItemClicked = pigui.IsItemClicked
ui.isWindowHovered = pigui.IsWindowHovered
ui.isAnyItemActive = pigui.IsAnyItemActive ---@type fun()
ui.isWindowHovered = pigui.IsWindowHovered ---@type fun(flags: any)
ui.isWindowFocused = pigui.IsWindowFocused ---@type fun(flags: any)
ui.vSliderInt = pigui.VSliderInt ---@type fun(l: string, size: Vector2, v: integer, min: integer, max: integer, fmt: string?): value:integer, changed:boolean
ui.sliderInt = pigui.SliderInt ---@type fun(l: string, v: integer, min: integer, max: integer, fmt: string?): value:integer, changed:boolean
ui.colorEdit = pigui.ColorEdit
Expand Down
67 changes: 67 additions & 0 deletions data/pigui/libs/message-box.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ local lui = Lang.GetResource("ui-core")
local font = ui.fonts.pionillium.body
local msgButtonWidth = font.size * 7

--
-- Interface: msgbox
--

local msgbox = {}

local function createBoxModal(msg, footer, footerWidth)
Expand Down Expand Up @@ -36,6 +40,11 @@ local function createBoxModal(msg, footer, footerWidth)
end):open()
end

--
-- Function: msgbox.OK
--
-- msgbox.OK(msg)
--
msgbox.OK = function(msg)
createBoxModal(msg, function(self)
if ui.button(lui.OK, Vector2(msgButtonWidth, 0)) then
Expand All @@ -44,6 +53,11 @@ msgbox.OK = function(msg)
end, msgButtonWidth)
end

--
-- Function: msgbox.OK_CANCEL
--
-- msgbox.OK_CANCEL(msg)
--
msgbox.OK_CANCEL = function(msg, callback)
createBoxModal(msg, function(self)
if ui.button(lui.OK, Vector2(msgButtonWidth, 0)) then
Expand All @@ -59,4 +73,57 @@ msgbox.OK_CANCEL = function(msg, callback)
end, msgButtonWidth * 2 + ui.getItemSpacing().x)
end

--
-- Function: msgbox.YES_NO
--
-- msgbox.YES_NO(msg)
--
msgbox.YES_NO = function(msg, callbacks)
createBoxModal(msg, function(self)
if ui.button(lui.YES, Vector2(msgButtonWidth, 0)) then
if callbacks and callbacks.yes then
callbacks.yes()
end
self:close()
end
ui.sameLine()
if ui.button(lui.NO, Vector2(msgButtonWidth, 0)) then
if callbacks and callbacks.no then
callbacks.no()
end
self:close()
end
end, msgButtonWidth * 2 + ui.getItemSpacing().x)
end

--
-- Function: msgbox.custom
--
-- msgbox.custom(msg, buttons)
--
-- Show a message box with custom buttons and corresponding callbacks.
--
-- Parameters:
--
-- msg - string, message for message box
-- buttons - array of type:
-- label - string, button label
-- callback - function
--
msgbox.custom = function(msg, buttons)
createBoxModal(msg, function(self)
for i, button in ipairs(buttons) do

if i ~= 1 then ui.sameLine() end

if ui.button(button.label, Vector2(msgButtonWidth, 0)) then
if button.callback then
button.callback()
end
self:close()
end
end
end, msgButtonWidth * #buttons + ui.getItemSpacing().x)
end

return msgbox
4 changes: 4 additions & 0 deletions data/pigui/libs/modal-win.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ local function drawModals(idx)
end
end

function ModalWindow:topmost()
return self.stackIdx == #modalStack
end

ui.registerModule('modal', function()
drawModals(1)
end)
Expand Down
Loading

0 comments on commit 3800ddc

Please sign in to comment.