2 Commits

8 changed files with 154 additions and 115 deletions

View File

@@ -3,6 +3,8 @@ local PrimitiveCraftHandler = Smc.requireCraftSystemPrimitiveCraftHandler()
---@type PlayerInventoryUI ---@type PlayerInventoryUI
local PlayerInventoryUI = Mod.getInfo('smc__ui__player_inventory').require('PlayerInventoryUI') local PlayerInventoryUI = Mod.getInfo('smc__ui__player_inventory').require('PlayerInventoryUI')
-- TODO: перенести обработки в PlayerUI
-- Handling the button click for selecting an item for crafting. -- Handling the button click for selecting an item for crafting.
-- Opens the item description and allows you to craft the selected item. -- Opens the item description and allows you to craft the selected item.
PlayerInventoryUI:registerOnFormFieldActionMatch('.+::%S+::item_button',function(player, fieldName, fieldValue) PlayerInventoryUI:registerOnFormFieldActionMatch('.+::%S+::item_button',function(player, fieldName, fieldValue)

View File

@@ -40,21 +40,21 @@ local function getFormSpecString(self, playerName, isSelect)
size = {x=21, y=12}, size = {x=21, y=12},
}) })
listForm: listForm
list('current_player', 'main', 10.5, 6.5, 8, 4): :list('current_player', 'main', 10.5, 6.5, 8, 4)
scrollContainer(listFormItems, 0.5, 0.5, 9, 11, 'admin_commands:list_items', 'vertical'): :scrollContainer(listFormItems, 0.5, 0.5, 9, 11, 'admin_commands:list_items', 'vertical')
scrollbar(10, 0.5, 0.25, 10, 'vertical', 'admin_commands:list_items', self:getContex(playerName, 'scroll')) :scrollbar(10, 0.5, 0.25, 10, 'vertical', 'admin_commands:list_items', self:getContex(playerName, 'scroll'))
if isSelect then if isSelect then
---@type ItemStackString ---@type ItemStackString
local item = self:getContex(playerName, 'select_item') local item = self:getContex(playerName, 'select_item')
local itemDef = core.registered_items[item] local itemDef = core.registered_items[item]
listForm: listForm
itemImage(11, 0.5, 2, 2, item): :itemImage(11, 0.5, 2, 2, item)
areaLabel(11, 4.5, 4, 1, 'Add to inventory:'): :areaLabel(11, 4.5, 4, 1, 'Add to inventory:')
button(11, 5, 3, 1, 'admin_commands:list_add_item', '1'): :button(11, 5, 3, 1, 'admin_commands:list_add_item', '1')
button(14, 5,3, 1, 'admin_commands:list_add_item', ''..tostring(itemDef.stack_max)): :button(14, 5,3, 1, 'admin_commands:list_add_item', ''..tostring(itemDef.stack_max))
areaLabel(14.5, 0.5, 6, 4, :areaLabel(14.5, 0.5, 6, 4,
item..'\n\n'.. item..'\n\n'..
itemDef._title..'\n'.. itemDef._title..'\n'..
itemDef._description) itemDef._description)

View File

@@ -6,7 +6,6 @@ local require = Mod.getInfo('smc__ui__player_inventory').require
---@alias PlayerInventoryUI.TabType 'left'|'right' ---@alias PlayerInventoryUI.TabType 'left'|'right'
---@alias PlayerInventoryUI.getTabFunc fun(self:PlayerInventoryUI,playerName:string,tabType:PlayerInventoryUI.TabType):Formspec ---@alias PlayerInventoryUI.getTabFunc fun(self:PlayerInventoryUI,playerName:string,tabType:PlayerInventoryUI.TabType):Formspec
---@alias PlayerInventoryUI.TabName 'select_tab_menu'|'bag_tab'|'craft_tab'|'equip_tab'|'ref_tab' ---@alias PlayerInventoryUI.TabName 'select_tab_menu'|'bag_tab'|'craft_tab'|'equip_tab'|'ref_tab'
---@type PlayerInventoryUI.getTabFunc ---@type PlayerInventoryUI.getTabFunc
@@ -54,113 +53,144 @@ local tabButtonTextures = {
} }
} }
---@param tabName PlayerInventoryUI.TabName ---Returns the formspec definition for the compact (single tab)
local function getTab(tabName) ---version of the player's inventory.
if tabName == nil then
---@type PlayerInventoryUI.TabName
tabName = 'select_tab_menu'
end
local tab = tabs[tabName]
assert(tab ~= nil, ('The tab with the `%s` does not exist.'):format(tabName))
return tab
end
---@param self PlayerInventoryUI ---@param self PlayerInventoryUI
---@param playerName string ---@param playerName string
---@return string ---@return string
local function getCompactForm(self, playerName) local function getCompactForm(self, playerName)
-- We geet the name of the selected (active) tab.
-- The left tab is considered the primary tab (shown in the compact version).
--
-- If the tab is not specified, the equipment tab will be opened by default.
---@type PlayerInventoryUI.TabName ---@type PlayerInventoryUI.TabName
local leftTabName = self:getContex(playerName, 'left_tab_name') or 'craft_tab' local leftTabName = self:getContex(playerName, 'left_tab_name') or 'equip_tab'
-- TODO: убрать, если будет не нужно
local leftTabIsBlock = self:getContex(playerName, 'left_tab_is_block') local leftTabIsBlock = self:getContex(playerName, 'left_tab_is_block')
-- Create an instance of the inventory form.
local InventoryForm = Formspec:new({ local InventoryForm = Formspec:new({
size = {x=14, y=12.5}, size = {x=14, y=12.5},
position = {x=0.5, y=0.55}, position = {x=0.5, y=0.55},
noPrepend = true, noPrepend = true,
}) })
-- We get a table for textures for tab selection buttons according to the active tab.
local leftTabButtonTextures = tabButtonTextures[leftTabName] local leftTabButtonTextures = tabButtonTextures[leftTabName]
InventoryForm: InventoryForm
bgcolor('#00000000', 'neither'): -- Removing the inventory background color:
background(0, 0.5, 14, 12.5, 'player_inventory_compact_middle_background.png', false): :bgcolor('#00000000', 'neither')
listColors('#00000000', '#e1b69150'): -- A permanent part of the inventory:
imageButton(13, 9.75, 0.5, 1, 'player_inventory_compact_mode_button_on.png', 'change_compact_mode'): :background(0, 0.5, 14, 12.5, 'player_inventory_compact_middle_background.png', false)
list('current_player', 'main', 1.5,9.75, 9,1): :listColors('#00000000', '#e1b69150')
list('current_player', 'main', 1.5,11.25, 9,1, 9): :list('current_player', 'main', 1.5,9.75, 9,1)
container(tabs[leftTabName](self, playerName, 'left'), 1.5, 0.5): :list('current_player', 'main', 1.5,11.25, 9,1, 9)
-- Selection buttons for the left panel: -- Inventory mode switch button (compact/full):
imageButton(1.5,0,2,0.5, leftTabButtonTextures[1],'select_left_craft_tab', core.colorize('#e1b691','craft')): :imageButton(13, 9.75, 0.5, 1, 'player_inventory_compact_mode_button_on.png', 'change_compact_mode')
imageButton(3.5,0,2,0.5, leftTabButtonTextures[2], 'select_left_equip_tab', core.colorize('#e1b691','equip')): -- Tab:
imageButton(5.5,0,2,0.5, leftTabButtonTextures[3], 'select_left_bag_tab', core.colorize('#e1b691','bags')): :container(tabs[leftTabName](self, playerName, 'left'), 1.5, 0.5)
imageButton(7.5,0,2,0.5, leftTabButtonTextures[4], 'select_left_ref_tab', core.colorize('#e1b691','refs')) -- Selection buttons for the (left) panel:
:imageButton(1.5,0,2,0.5, leftTabButtonTextures[1],'select_left_craft_tab', core.colorize('#e1b691','craft'))
:imageButton(3.5,0,2,0.5, leftTabButtonTextures[2], 'select_left_equip_tab', core.colorize('#e1b691','equip'))
:imageButton(5.5,0,2,0.5, leftTabButtonTextures[3], 'select_left_bag_tab', core.colorize('#e1b691','bags'))
:imageButton(7.5,0,2,0.5, leftTabButtonTextures[4], 'select_left_ref_tab', core.colorize('#e1b691','refs'))
return InventoryForm:toString() return InventoryForm:toString()
end end
---Returns the formspec definition for the full (two tab)
---version of the player's inventory.
---@param self PlayerInventoryUI ---@param self PlayerInventoryUI
---@param playerName string ---@param playerName string
---@return string ---@return string
local function getFullForm(self, playerName) local function getFullForm(self, playerName)
-- We get the names of the active tabs (left and right).
-- The tabs are identical, but when switching the inventory
-- to compact mode, the left tab becomes the primary one.
--
-- The default values ​​are:
-- * left tab - equipment;
-- * right tab - crafting menu.
---@type PlayerInventoryUI.TabName ---@type PlayerInventoryUI.TabName
local leftTabName = self:getContex(playerName, 'left_tab_name') or 'craft_tab' local leftTabName = self:getContex(playerName, 'left_tab_name') or 'craft_tab'
---@type PlayerInventoryUI.TabName ---@type PlayerInventoryUI.TabName
local rightTabName = self:getContex(playerName, 'right_tab_name') or 'craft_tab' local rightTabName = self:getContex(playerName, 'right_tab_name') or 'craft_tab'
-- TODO: убрать, если будет не нужно
local leftTabIsBlock = self:getContex(playerName, 'left_tab_is_block') local leftTabIsBlock = self:getContex(playerName, 'left_tab_is_block')
local rightTabIsBlock = self:getContex(playerName, 'right_tab_is_block') local rightTabIsBlock = self:getContex(playerName, 'right_tab_is_block')
-- Create an instance of the inventory form.
local InventoryForm = Formspec:new({ local InventoryForm = Formspec:new({
size = {x=22, y=12.5}, size = {x=22, y=12.5},
position = {x=0.5, y=0.55}, position = {x=0.5, y=0.55},
noPrepend = true, noPrepend = true,
}) })
-- We get texture tables for the tab selection buttons depending on the active tabs.
local leftTabButtonTextures = tabButtonTextures[leftTabName] local leftTabButtonTextures = tabButtonTextures[leftTabName]
local rightTabButtonTextures = tabButtonTextures[rightTabName] local rightTabButtonTextures = tabButtonTextures[rightTabName]
InventoryForm: InventoryForm
bgcolor('#00000000', 'neither'): -- Removing the inventory background color:
background(0, 9.5, 22, 3, 'player_inventory_middle_background.png', false): :bgcolor('#00000000', 'neither')
listColors('#00000000', '#e1b69150'): -- A permanent part of the inventory:
imageButton(17, 9.75, 0.5, 1, 'player_inventory_compact_mode_button_off.png', 'change_compact_mode'): :background(0, 9.5, 22, 3, 'player_inventory_middle_backgound.png', false)
list('current_player', 'main', 5.5,9.75, 9,1): :listColors('#00000000', '#e1b69150')
list('current_player', 'main', 5.5,11.25, 9,1, 9): :list('current_player', 'main', 5.5,9.75, 9,1)
container(tabs[leftTabName](self, playerName, 'left'), 0, 0.5): :list('current_player', 'main', 5.5,11.25, 9,1, 9)
container(tabs[rightTabName](self, playerName, 'right'), 11, 0.5): -- Inventory mode switch button (compact/full):
:imageButton(17, 9.75, 0.5, 1, 'player_inventory_compact_mode_button_off.png', 'change_compact_mode')
-- Tabs:
:container(tabs[leftTabName](self, playerName, 'left'), 0, 0.5)
:container(tabs[rightTabName](self, playerName, 'right'), 11, 0.5)
-- Selection buttons for the left panel: -- Selection buttons for the left panel:
imageButton(0,0,2,0.5, leftTabButtonTextures[1],'select_left_craft_tab', core.colorize('#e1b691','craft')): :imageButton(0,0,2,0.5, leftTabButtonTextures[1],'select_left_craft_tab', core.colorize('#e1b691','craft'))
imageButton(2,0,2,0.5, leftTabButtonTextures[2], 'select_left_equip_tab', core.colorize('#e1b691','equip')): :imageButton(2,0,2,0.5, leftTabButtonTextures[2], 'select_left_equip_tab', core.colorize('#e1b691','equip'))
imageButton(4,0,2,0.5, leftTabButtonTextures[3], 'select_left_bag_tab', core.colorize('#e1b691','bags')): :imageButton(4,0,2,0.5, leftTabButtonTextures[3], 'select_left_bag_tab', core.colorize('#e1b691','bags'))
imageButton(6,0,2,0.5, leftTabButtonTextures[4], 'select_left_ref_tab', core.colorize('#e1b691','refs')): :imageButton(6,0,2,0.5, leftTabButtonTextures[4], 'select_left_ref_tab', core.colorize('#e1b691','refs'))
imageButton(11,0,2,0.5, rightTabButtonTextures[1],'select_right_craft_tab', core.colorize('#e1b691','craft')): -- Selection buttons for the right panel:
imageButton(13,0,2,0.5, rightTabButtonTextures[2], 'select_right_equip_tab', core.colorize('#e1b691','equip')): :imageButton(11,0,2,0.5, rightTabButtonTextures[1],'select_right_craft_tab', core.colorize('#e1b691','craft'))
imageButton(15,0,2,0.5, rightTabButtonTextures[3], 'select_right_bag_tab', core.colorize('#e1b691','bags')): :imageButton(13,0,2,0.5, rightTabButtonTextures[2], 'select_right_equip_tab', core.colorize('#e1b691','equip'))
imageButton(17,0,2,0.5, rightTabButtonTextures[4], 'select_right_ref_tab', core.colorize('#e1b691','refs')) :imageButton(15,0,2,0.5, rightTabButtonTextures[3], 'select_right_bag_tab', core.colorize('#e1b691','bags'))
:imageButton(17,0,2,0.5, rightTabButtonTextures[4], 'select_right_ref_tab', core.colorize('#e1b691','refs'))
return InventoryForm:toString() return InventoryForm:toString()
end end
---Returns the inventory formspec definition
---depending on the selected inventory mod (compact/full).
---
---The selected inventory mode is contained in the context of the `PlayerInventoryUI` UI class.
---@param self PlayerInventoryUI ---@param self PlayerInventoryUI
---@param playerName string ---@param playerName string
---@return string ---@return string
local function getFormSpecString(self, playerName) local function getFormSpecString(self, playerName)
-- We get the selected inventory mode.
-- * `true` - compact mode
-- * `false` - full mode
---@type boolean ---@type boolean
local compactMode = self:getContex(playerName, 'compact_mode') local compactMode = self:getContex(playerName, 'compact_mode')
-- If the mode is not selected...
if compactMode == nil then if compactMode == nil then
-- ...by default it will be `true` (compact mode).
compactMode = true compactMode = true
end end
-- If compact mode is selected...
if compactMode then if compactMode then
-- ...return the compact inventory definition.
return getCompactForm(self, playerName) return getCompactForm(self, playerName)
else else
-- ...else we return the full version of the inventory.
return getFullForm(self, playerName) return getFullForm(self, playerName)
end end
end end
---Context keys for the `PlayerInventoryUI` class.
---@alias PlayerInventoryUI.ContexKey ---@alias PlayerInventoryUI.ContexKey
--- 'compact_mode'| --- 'compact_mode'|
--- ---
@@ -186,16 +216,23 @@ end
---@field setContex fun(self:PlayerInventoryUI,player:string|Player,key:PlayerInventoryUI.ContexKey,value:any) ---@field setContex fun(self:PlayerInventoryUI,player:string|Player,key:PlayerInventoryUI.ContexKey,value:any)
local PlayerInventoryUI = BaseUI:new('', getFormSpecString, false) local PlayerInventoryUI = BaseUI:new('', getFormSpecString, false)
-- We are overriding the `BaseUI.showForm`.
local showForm = PlayerInventoryUI.showForm local showForm = PlayerInventoryUI.showForm
function PlayerInventoryUI:showForm(playerName) function PlayerInventoryUI:showForm(playerName)
-- We get a player by his name.
local player = core.get_player_by_name(playerName) local player = core.get_player_by_name(playerName)
assert(player ~= nil) assert(player ~= nil)
-- We overwrite the player's inventory definition so that the updated inventory
-- is shown to the player when they press the "open inventory" key.
player:set_inventory_formspec(PlayerInventoryUI:getFormSpecString(playerName)) player:set_inventory_formspec(PlayerInventoryUI:getFormSpecString(playerName))
-- We call the standard `BaseUI.showForm` function for the standard operation.
return showForm(self, playerName) return showForm(self, playerName)
end end
-- Handling the press of the inventory mode change button.
PlayerInventoryUI:registerOnFormFieldAction('change_compact_mode', function(player, fieldName, fieldValue) PlayerInventoryUI:registerOnFormFieldAction('change_compact_mode', function(player, fieldName, fieldValue)
local playerName = player:get_player_name() local playerName = player:get_player_name()
@@ -208,6 +245,7 @@ PlayerInventoryUI:registerOnFormFieldAction('change_compact_mode', function(play
PlayerInventoryUI:showForm(playerName) PlayerInventoryUI:showForm(playerName)
end) end)
-- Handling the left inventory tab selection button press.
PlayerInventoryUI:registerOnFormFieldActionMatch('select_left_%S+', function(player, fieldName, fieldValue) PlayerInventoryUI:registerOnFormFieldActionMatch('select_left_%S+', function(player, fieldName, fieldValue)
local tabName = stringMatch(fieldName, 'select_%S+_(%S+_%S+)') local tabName = stringMatch(fieldName, 'select_%S+_(%S+_%S+)')
assert(tabName ~= nil) assert(tabName ~= nil)
@@ -218,13 +256,7 @@ PlayerInventoryUI:registerOnFormFieldActionMatch('select_left_%S+', function(pla
PlayerInventoryUI:showForm(playerName) PlayerInventoryUI:showForm(playerName)
end) end)
PlayerInventoryUI:registerOnFormFieldAction('close_right_tab', function(player, fieldName, fieldValue) -- Handling the right inventory tab selection button press.
local playerName = player:get_player_name()
PlayerInventoryUI:setContex(playerName, 'right_tab_name', 'select_tab_menu')
PlayerInventoryUI:showForm(playerName)
end)
PlayerInventoryUI:registerOnFormFieldActionMatch('select_right_%S+', function(player, fieldName, fieldValue) PlayerInventoryUI:registerOnFormFieldActionMatch('select_right_%S+', function(player, fieldName, fieldValue)
local tabName = stringMatch(fieldName, 'select_%S+_(%S+_%S+)') local tabName = stringMatch(fieldName, 'select_%S+_(%S+_%S+)')
assert(tabName ~= nil) assert(tabName ~= nil)
@@ -235,6 +267,7 @@ PlayerInventoryUI:registerOnFormFieldActionMatch('select_right_%S+', function(pl
PlayerInventoryUI:showForm(playerName) PlayerInventoryUI:showForm(playerName)
end) end)
-- Handling the click of the button to turning back through the crafting menu pages.
PlayerInventoryUI:registerOnFormFieldActionMatch('%S+::page_back', function(player, fieldName, fieldValue) PlayerInventoryUI:registerOnFormFieldActionMatch('%S+::page_back', function(player, fieldName, fieldValue)
local tabType = stringMatch(fieldName, '(%S+)::page_back') local tabType = stringMatch(fieldName, '(%S+)::page_back')
assert(tabType == 'left' or tabType == 'right') assert(tabType == 'left' or tabType == 'right')
@@ -251,6 +284,7 @@ PlayerInventoryUI:registerOnFormFieldActionMatch('%S+::page_back', function(play
PlayerInventoryUI:showForm(playerName) PlayerInventoryUI:showForm(playerName)
end) end)
-- Handling the click of the button to turning forward through the crafting menu pages.
PlayerInventoryUI:registerOnFormFieldActionMatch('%S+::page_forward', function(player, fieldName, fieldValue) PlayerInventoryUI:registerOnFormFieldActionMatch('%S+::page_forward', function(player, fieldName, fieldValue)
local tabType = stringMatch(fieldName, '(%S+)::page_forward') local tabType = stringMatch(fieldName, '(%S+)::page_forward')
assert(tabType == 'left' or tabType == 'right') assert(tabType == 'left' or tabType == 'right')
@@ -267,6 +301,7 @@ PlayerInventoryUI:registerOnFormFieldActionMatch('%S+::page_forward', function(p
PlayerInventoryUI:showForm(playerName) PlayerInventoryUI:showForm(playerName)
end) end)
-- Processing closing of the selected item group in the crafting menu (returning to the main list of crafts).
PlayerInventoryUI:registerOnFormFieldActionMatch('%S+::close_group', function(player, fieldName, fieldValue) PlayerInventoryUI:registerOnFormFieldActionMatch('%S+::close_group', function(player, fieldName, fieldValue)
local tabType = stringMatch(fieldName, '(%S+)::close_group') local tabType = stringMatch(fieldName, '(%S+)::close_group')
assert(tabType == 'left' or tabType == 'right') assert(tabType == 'left' or tabType == 'right')
@@ -276,4 +311,6 @@ PlayerInventoryUI:registerOnFormFieldActionMatch('%S+::close_group', function(pl
PlayerInventoryUI:showForm(playerName) PlayerInventoryUI:showForm(playerName)
end) end)
-- TODO: перенести сюда обработку вызовов из Player
return PlayerInventoryUI return PlayerInventoryUI

View File

@@ -7,9 +7,9 @@ local Formspec = Smc.requireFormspec()
local function getBagTab(self, playerName, tabType) local function getBagTab(self, playerName, tabType)
local BagTab = Formspec:new() local BagTab = Formspec:new()
BagTab: BagTab
image(0, 0, 11, 9, 'player_inventory_tab_background.png'): :image(0, 0, 11, 9, 'player_inventory_tab_background.png')
label(2,2, 'BAG PANE') :label(2,2, 'BAG PANE')
return BagTab return BagTab
end end

View File

@@ -47,8 +47,8 @@ local function getCraftTab(self, playerName, tabType)
local w, h = 0.0, 0.0 local w, h = 0.0, 0.0
if selectedGroup ~= nil then if selectedGroup ~= nil then
craftsListForm: craftsListForm
imageButton(0, 0, 1.125, 1.125, 'player_inventory_craft_tab_close_group_button_background.png', tabType..'::close_group') :imageButton(0, 0, 1.125, 1.125, 'player_inventory_craft_tab_close_group_button_background.png', tabType..'::close_group')
w = 1.125 w = 1.125
end end
@@ -65,23 +65,23 @@ local function getCraftTab(self, playerName, tabType)
if output ~= nil then if output ~= nil then
if craft.name == selectedCraft then if craft.name == selectedCraft then
craftsListForm: craftsListForm
imageButton(w, h, 1.125, 1.125, 'player_inventory_craft_tab_button_pressed_background.png', craft.name..'::'..tabType..'::item_button') :imageButton(w, h, 1.125, 1.125, 'player_inventory_craft_tab_button_pressed_background.png', craft.name..'::'..tabType..'::item_button')
else else
craftsListForm: craftsListForm
imageButton(w, h, 1.125, 1.125, 'player_inventory_craft_tab_button_background.png', craft.name..'::'..tabType..'::item_button') :imageButton(w, h, 1.125, 1.125, 'player_inventory_craft_tab_button_background.png', craft.name..'::'..tabType..'::item_button')
end end
craftsListForm: craftsListForm
itemImage(w+0.0625, h+0.0625, 1, 1, output) :itemImage(w+0.0625, h+0.0625, 1, 1, output)
else else
local craft = craft[1] local craft = craft[1]
assert(craft ~= nil) assert(craft ~= nil)
craftsListForm: craftsListForm
imageButton(w, h, 1.125, 1.125, 'player_inventory_craft_tab_button_background.png', craft.group..'::'..tabType..'::group_button'): :imageButton(w, h, 1.125, 1.125, 'player_inventory_craft_tab_button_background.png', craft.group..'::'..tabType..'::group_button')
itemImage(w+0.0625, h+0.0625, 1, 1, craft.output): :itemImage(w+0.0625, h+0.0625, 1, 1, craft.output)
image(w, h, 1.125, 1.125, 'player_inventory_craft_tab_group_button_overlay.png') :image(w, h, 1.125, 1.125, 'player_inventory_craft_tab_group_button_overlay.png')
end end
w = w + 1.125 w = w + 1.125
@@ -91,12 +91,12 @@ local function getCraftTab(self, playerName, tabType)
end end
end end
CraftTab: CraftTab
background(0, 0, 11, 9, 'player_inventory_craft_tab_background.png'): :background(0, 0, 11, 9, 'player_inventory_craft_tab_background.png')
container(craftsListForm, 0.5, 0.5): :container(craftsListForm, 0.5, 0.5)
button(1.75, 7.75, 1, 0.5, tabType..'::page_back', '<'): :button(1.75, 7.75, 1, 0.5, tabType..'::page_back', '<')
button(2.75, 7.75, 1, 0.5, tabType..'::page_forward', '>'): :button(2.75, 7.75, 1, 0.5, tabType..'::page_forward', '>')
label(2.5,8.5, ('%s/%s'):format(pageNumber, pagesMax)) :label(2.5,8.5, ('%s/%s'):format(pageNumber, pagesMax))
if selectedCraft ~= '' then if selectedCraft ~= '' then
local craft = PrimitiveCraftHandler:getCraftByName(selectedCraft) local craft = PrimitiveCraftHandler:getCraftByName(selectedCraft)
@@ -115,15 +115,15 @@ local function getCraftTab(self, playerName, tabType)
end end
end end
CraftTab: CraftTab
itemImage(5.5, 0.5, 2, 2, craft.output): :itemImage(5.5, 0.5, 2, 2, craft.output)
areaLabel(5.5, 3, 4, 4, :areaLabel(5.5, 3, 4, 4,
itemDef._title..'\n'.. itemDef._title..'\n'..
itemDef._description..'\n\n'.. itemDef._description..'\n\n'..
'Needed:\n'..recipe): 'Needed:\n'..recipe)
areaLabel(5.5, 7, 4, 1, 'Craft:'): :areaLabel(5.5, 7, 4, 1, 'Craft:')
button(5.5, 7.5, 2, 1, tabType..'::craft_item', '1'): :button(5.5, 7.5, 2, 1, tabType..'::craft_item', '1')
button(7.5, 7.5,2, 1, tabType..'::craft_item', ''..tostring(itemDef.stack_max)) :button(7.5, 7.5,2, 1, tabType..'::craft_item', ''..tostring(itemDef.stack_max))
end end
return CraftTab return CraftTab

View File

@@ -7,9 +7,9 @@ local Formspec = Smc.requireFormspec()
local function getEquipTab(self, playerName, tabType) local function getEquipTab(self, playerName, tabType)
local EquipTab = Formspec:new() local EquipTab = Formspec:new()
EquipTab: EquipTab
image(0, 0, 11, 9, 'player_inventory_tab_background.png'): :image(0, 0, 11, 9, 'player_inventory_tab_background.png')
label(2,2, 'EQUIPMENT PANE') :label(2,2, 'EQUIPMENT PANE')
return EquipTab return EquipTab
end end

View File

@@ -7,9 +7,9 @@ local Formspec = Smc.requireFormspec()
local function getRefTab(self, playerName, tabType) local function getRefTab(self, playerName, tabType)
local RefTab = Formspec:new() local RefTab = Formspec:new()
RefTab: RefTab
image(0, 0, 11, 9, 'player_inventory_tab_background.png'): :image(0, 0, 11, 9, 'player_inventory_tab_background.png')
label(2,2, 'REFERENCE PANE') :label(2,2, 'REFERENCE PANE')
return RefTab return RefTab
end end

View File

@@ -28,22 +28,22 @@ local function getFormSpecString(self, playerName, isSelect)
end end
end end
listForm: listForm
scrollContainer(listFormItems, 0.5, 0.5, 8, 6, 'work_station:list_items', 'vertical'): :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') :scrollbar(8, 0.5, 0.25, 7, 'vertical', 'work_station:list_items')
if isSelect then if isSelect then
local stage = craft.stagesByName[craft.startStageName] local stage = craft.stagesByName[craft.startStageName]
local outputDef = core.registered_nodes[craft.output] local outputDef = core.registered_nodes[craft.output]
listForm: listForm
itemImage(9, 0.5, 2, 2, craft.output): :itemImage(9, 0.5, 2, 2, craft.output)
areaLabel(9, 6, 2, 1, 'Start crafting:'): :areaLabel(9, 6, 2, 1, 'Start crafting:')
button(9, 6.5, 3, 1, 'work_station:start_craft', 'x1'): :button(9, 6.5, 3, 1, 'work_station:start_craft', 'x1')
button(12, 6.5,3, 1, 'work_station:start_craft', 'x10'): :button(12, 6.5,3, 1, 'work_station:start_craft', 'x10')
areaLabel(11.5, 0.5, 4, 4, :areaLabel(11.5, 0.5, 4, 4,
outputDef._title..'\n'.. outputDef._title..'\n'..
outputDef._description): outputDef._description)
areaLabel(9, 2.5, 6, 4, 'Craft description:'..'\n'..craft:toString()) :areaLabel(9, 2.5, 6, 4, 'Craft description:'..'\n'..craft:toString())
end end
return listForm:toString() return listForm:toString()