PlayerInventoryUI:Adding background textures to the crafting menu. #34
This commit is contained in:
@@ -726,7 +726,7 @@ end
|
|||||||
---@param textureName string Is the filename of an image.
|
---@param textureName string Is the filename of an image.
|
||||||
---@param name string
|
---@param name string
|
||||||
---@param label string?
|
---@param label string?
|
||||||
---@param pressedTextureName string Is the filename of an image on pressed state.
|
---@param pressedTextureName string? Is the filename of an image on pressed state.
|
||||||
---@param noclip boolean? Means the image button doesn't need to be within specified formsize. Default: `true`
|
---@param noclip boolean? Means the image button doesn't need to be within specified formsize. Default: `true`
|
||||||
---@param drawborder boolean? Draw button border or not. Default `false`
|
---@param drawborder boolean? Draw button border or not. Default `false`
|
||||||
---@return Formspec
|
---@return Formspec
|
||||||
@@ -738,7 +738,7 @@ function Formspec:imageButton(x, y, w, h, textureName, name, label, pressedTextu
|
|||||||
x, y, w, h, textureName, name, label or '')
|
x, y, w, h, textureName, name, label or '')
|
||||||
else
|
else
|
||||||
element = ('image_button[%s,%s;%s,%s;%s;%s;%s;%s;%s;%s]'):format(
|
element = ('image_button[%s,%s;%s,%s;%s;%s;%s;%s;%s;%s]'):format(
|
||||||
x, y, w, h, textureName, name, label or '', pressedTextureName, noclip or true, drawborder or false)
|
x, y, w, h, textureName, name, label or '', noclip or true, drawborder or false, pressedTextureName)
|
||||||
end
|
end
|
||||||
|
|
||||||
self:addElement(element)
|
self:addElement(element)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---Number of crafting recipes on one menu page.
|
---Number of crafting recipes on one menu page.
|
||||||
local PAGE_NUMBER_ITEMS = 28
|
local PAGE_NUMBER_ITEMS = 24
|
||||||
|
|
||||||
local PrimitiveCraftHandler = Smc.requireCraftSystemPrimitiveCraftHandler()
|
local PrimitiveCraftHandler = Smc.requireCraftSystemPrimitiveCraftHandler()
|
||||||
|
|
||||||
@@ -44,28 +44,38 @@ local function getCraftPane(self, playerName, paneType)
|
|||||||
self:setContex(playerName, paneType..'_pane_craft_page_number', pageNumber)
|
self:setContex(playerName, paneType..'_pane_craft_page_number', pageNumber)
|
||||||
end
|
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
|
for i = PAGE_NUMBER_ITEMS*pageNumber-PAGE_NUMBER_ITEMS+1, PAGE_NUMBER_ITEMS*pageNumber do
|
||||||
local craft = crafts[i]
|
local craft = crafts[i]
|
||||||
if craft == nil then
|
if craft == nil then
|
||||||
break
|
break
|
||||||
end
|
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
|
if w >= 4 then
|
||||||
w = 0
|
w = 0
|
||||||
h = h + 1
|
h = h + 1.125
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
CraftPane:
|
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):
|
container(craftsListForm, 0.5, 0.5):
|
||||||
button(1.5, 7.5, 1, 0.5, paneType..'::page_back', '<'):
|
button(1.75, 7.75, 1, 0.5, paneType..'::page_back', '<'):
|
||||||
button(2.5, 7.5, 1, 0.5, paneType..'::page_forward', '>'):
|
button(2.75, 7.75, 1, 0.5, paneType..'::page_forward', '>'):
|
||||||
label(2.25,8.25, ('%s/%s'):format(pageNumber, pagesMax))
|
label(2.5,8.5, ('%s/%s'):format(pageNumber, pagesMax))
|
||||||
|
|
||||||
if selectedCraft ~= nil then
|
if selectedCraft ~= nil then
|
||||||
local craft = PrimitiveCraftHandler:getCraftByName(selectedCraft)
|
local craft = PrimitiveCraftHandler:getCraftByName(selectedCraft)
|
||||||
@@ -76,14 +86,14 @@ local function getCraftPane(self, playerName, paneType)
|
|||||||
end
|
end
|
||||||
local itemDef = core.registered_items[itemName]
|
local itemDef = core.registered_items[itemName]
|
||||||
CraftPane:
|
CraftPane:
|
||||||
itemImage(5, 0.5, 2, 2, itemName):
|
itemImage(5.5, 0.5, 2, 2, itemName):
|
||||||
areaLabel(5, 3, 6, 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, 7, 4, 1, 'Craft:'):
|
areaLabel(5.5, 7, 4, 1, 'Craft:'):
|
||||||
button(5, 7.5, 2, 1, paneType..'::craft_item', '1'):
|
button(5.5, 7.5, 2, 1, paneType..'::craft_item', '1'):
|
||||||
button(7, 7.5,2, 1, paneType..'::craft_item', ''..tostring(itemDef.stack_max))
|
button(7.5, 7.5,2, 1, paneType..'::craft_item', ''..tostring(itemDef.stack_max))
|
||||||
end
|
end
|
||||||
|
|
||||||
return CraftPane
|
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