diff --git a/mods/CORE/Formspec/src/Formspec.lua b/mods/CORE/Formspec/src/Formspec.lua index 14de59f..61415af 100644 --- a/mods/CORE/Formspec/src/Formspec.lua +++ b/mods/CORE/Formspec/src/Formspec.lua @@ -726,7 +726,7 @@ end ---@param textureName string Is the filename of an image. ---@param name 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 drawborder boolean? Draw button border or not. Default `false` ---@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 '') else 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 self:addElement(element) diff --git a/mods/UI/PlayerInventoryUI/src/PlayerInventoryUI/getCraftPane.lua b/mods/UI/PlayerInventoryUI/src/PlayerInventoryUI/getCraftPane.lua index f222201..9a36d1a 100644 --- a/mods/UI/PlayerInventoryUI/src/PlayerInventoryUI/getCraftPane.lua +++ b/mods/UI/PlayerInventoryUI/src/PlayerInventoryUI/getCraftPane.lua @@ -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 diff --git a/mods/UI/PlayerInventoryUI/textures/player_inventory_craft_pane_background.png b/mods/UI/PlayerInventoryUI/textures/player_inventory_craft_pane_background.png new file mode 100644 index 0000000..dc64e55 Binary files /dev/null and b/mods/UI/PlayerInventoryUI/textures/player_inventory_craft_pane_background.png differ diff --git a/mods/UI/PlayerInventoryUI/textures/player_inventory_craft_pane_button_background.png b/mods/UI/PlayerInventoryUI/textures/player_inventory_craft_pane_button_background.png new file mode 100644 index 0000000..a12a34e Binary files /dev/null and b/mods/UI/PlayerInventoryUI/textures/player_inventory_craft_pane_button_background.png differ diff --git a/mods/UI/PlayerInventoryUI/textures/player_inventory_craft_pane_button_pressed_background.png b/mods/UI/PlayerInventoryUI/textures/player_inventory_craft_pane_button_pressed_background.png new file mode 100644 index 0000000..c5accf1 Binary files /dev/null and b/mods/UI/PlayerInventoryUI/textures/player_inventory_craft_pane_button_pressed_background.png differ