PlayerInventoryUI:Adding background textures to the crafting menu. #34
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
---Number of crafting recipes on one menu page.
|
||||
local PAGE_NUMBER_ITEMS = 28
|
||||
local PAGE_NUMBER_ITEMS = 24
|
||||
|
||||
local PrimitiveCraftHandler = Smc.requireCraftSystemPrimitiveCraftHandler()
|
||||
|
||||
@@ -44,28 +44,38 @@ local function getCraftPane(self, playerName, paneType)
|
||||
self:setContex(playerName, paneType..'_pane_craft_page_number', pageNumber)
|
||||
end
|
||||
|
||||
local w, h = 0, 0
|
||||
local registeredItems = core.registered_items
|
||||
local w, h = 0.0, 0.0
|
||||
for i = PAGE_NUMBER_ITEMS*pageNumber-PAGE_NUMBER_ITEMS+1, PAGE_NUMBER_ITEMS*pageNumber do
|
||||
local craft = crafts[i]
|
||||
if craft == nil then
|
||||
break
|
||||
end
|
||||
craftsListForm:itemImageButton(w, h, 1, 1, craft.output, craft.name..'::'..paneType..'::item_button')
|
||||
if craft.name == selectedCraft then
|
||||
craftsListForm:
|
||||
imageButton(w, h, 1.125, 1.125, 'player_inventory_craft_pane_button_pressed_background.png', craft.name..'::'..paneType..'::item_button')
|
||||
else
|
||||
craftsListForm:
|
||||
imageButton(w, h, 1.125, 1.125, 'player_inventory_craft_pane_button_background.png', craft.name..'::'..paneType..'::item_button')
|
||||
end
|
||||
|
||||
w = w + 1
|
||||
craftsListForm:
|
||||
itemImage(w+0.0625, h+0.0625, 1, 1, craft.output)
|
||||
|
||||
w = w + 1.125
|
||||
|
||||
if w >= 4 then
|
||||
w = 0
|
||||
h = h + 1
|
||||
h = h + 1.125
|
||||
end
|
||||
end
|
||||
|
||||
CraftPane:
|
||||
image(0, 0, 11, 9, 'player_inventory_pane_background.png'):
|
||||
image(0, 0, 11, 9, 'player_inventory_craft_pane_background.png'):
|
||||
container(craftsListForm, 0.5, 0.5):
|
||||
button(1.5, 7.5, 1, 0.5, paneType..'::page_back', '<'):
|
||||
button(2.5, 7.5, 1, 0.5, paneType..'::page_forward', '>'):
|
||||
label(2.25,8.25, ('%s/%s'):format(pageNumber, pagesMax))
|
||||
button(1.75, 7.75, 1, 0.5, paneType..'::page_back', '<'):
|
||||
button(2.75, 7.75, 1, 0.5, paneType..'::page_forward', '>'):
|
||||
label(2.5,8.5, ('%s/%s'):format(pageNumber, pagesMax))
|
||||
|
||||
if selectedCraft ~= nil then
|
||||
local craft = PrimitiveCraftHandler:getCraftByName(selectedCraft)
|
||||
@@ -76,14 +86,14 @@ local function getCraftPane(self, playerName, paneType)
|
||||
end
|
||||
local itemDef = core.registered_items[itemName]
|
||||
CraftPane:
|
||||
itemImage(5, 0.5, 2, 2, itemName):
|
||||
areaLabel(5, 3, 6, 4,
|
||||
itemImage(5.5, 0.5, 2, 2, itemName):
|
||||
areaLabel(5.5, 3, 4, 4,
|
||||
itemDef._title..'\n'..
|
||||
itemDef._description..'\n\n'..
|
||||
'Needed:\n'..recipe):
|
||||
areaLabel(5, 7, 4, 1, 'Craft:'):
|
||||
button(5, 7.5, 2, 1, paneType..'::craft_item', '1'):
|
||||
button(7, 7.5,2, 1, paneType..'::craft_item', ''..tostring(itemDef.stack_max))
|
||||
areaLabel(5.5, 7, 4, 1, 'Craft:'):
|
||||
button(5.5, 7.5, 2, 1, paneType..'::craft_item', '1'):
|
||||
button(7.5, 7.5,2, 1, paneType..'::craft_item', ''..tostring(itemDef.stack_max))
|
||||
end
|
||||
|
||||
return CraftPane
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 100 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
Reference in New Issue
Block a user