WorkStation: create WorkStation class, register test node & crafts, add work station UI
This commit is contained in:
4
mods/UI/WorkStationUI/init.lua
Normal file
4
mods/UI/WorkStationUI/init.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
local modInfo = Mod.getInfo('smc__ui__work_station')
|
||||
local require = modInfo.require
|
||||
|
||||
return require('WorkStationUI')
|
||||
2
mods/UI/WorkStationUI/mod.conf
Normal file
2
mods/UI/WorkStationUI/mod.conf
Normal file
@@ -0,0 +1,2 @@
|
||||
name = smc__ui__work_station
|
||||
depends = smc__core__formspec
|
||||
40
mods/UI/WorkStationUI/src/WorkStationUI.lua
Normal file
40
mods/UI/WorkStationUI/src/WorkStationUI.lua
Normal file
@@ -0,0 +1,40 @@
|
||||
local modInfo = Mod.getInfo('smc__core__formspec')
|
||||
local require = modInfo.require
|
||||
|
||||
---@type Formspec
|
||||
local Formspec = require('Formspec')
|
||||
|
||||
---@class WorkStationUI
|
||||
local WorkStationUI = {}
|
||||
|
||||
---@param items string[]
|
||||
---@return string
|
||||
function WorkStationUI:selectionCraftForm(items)
|
||||
local listForm = Formspec:new({
|
||||
size = {x=10, y=8},
|
||||
})
|
||||
|
||||
local listFormItems = Formspec:new()
|
||||
table.sort(items)
|
||||
local w, h = 0, 0
|
||||
|
||||
---@param name string
|
||||
for _, name in ipairs(items) do
|
||||
listFormItems:itemImageButton(w, h, 2, 2, name, name..'::item_button')
|
||||
|
||||
w = w + 2
|
||||
|
||||
if w > 9 then
|
||||
w = 0
|
||||
h = h + 2
|
||||
end
|
||||
end
|
||||
|
||||
listForm:
|
||||
scrollContainer(listFormItems, 0.5, 0.5, 8, 6, 'work_station:list_items', 'vertical'):
|
||||
scrollbar(8, 0.5, 0.25, 7, 'vertical', 'work_station:list_items')
|
||||
|
||||
return listForm:toString()
|
||||
end
|
||||
|
||||
return WorkStationUI
|
||||
Reference in New Issue
Block a user