From d05af7daccc844ef7baaf6cf0619206ac69b59f8 Mon Sep 17 00:00:00 2001 From: Vanic Date: Sat, 28 Mar 2026 18:14:01 +0300 Subject: [PATCH] `PlayerInventoryUI`:Adding background textures to the crafting menu. #34 --- mods/CORE/Formspec/src/Formspec.lua | 4 +- .../src/PlayerInventoryUI/getCraftPane.lua | 38 +++++++++++------- ...player_inventory_craft_pane_background.png | Bin 0 -> 101860 bytes ...inventory_craft_pane_button_background.png | Bin 0 -> 1495 bytes ...y_craft_pane_button_pressed_background.png | Bin 0 -> 1495 bytes 5 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 mods/UI/PlayerInventoryUI/textures/player_inventory_craft_pane_background.png create mode 100644 mods/UI/PlayerInventoryUI/textures/player_inventory_craft_pane_button_background.png create mode 100644 mods/UI/PlayerInventoryUI/textures/player_inventory_craft_pane_button_pressed_background.png 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 0000000000000000000000000000000000000000..dc64e5507c8ba196b1de72a248eca9853524d89f GIT binary patch literal 101860 zcmeI5PiP!f9LIlaSCcjdQK6NnSP&w`(3G`aq)<{*n>{3G2&gC}BKYr;KvhByu_?XO zgYHQ@^d^FMkP7O-_9%*#26_?|5AhIUjs~=pVx6t*(CK7ecgoAY-*4V$A=#OEGw=O= zpYMkyf!F5rvr|U~cMRVF_>A`oCi+yi5ClB|nZ+qyTx-@4_zMo7f&GE6Bg__JQwH9k<-g@a; zavLuQm?ThNS=*2&8$&YM*kiH*ijI@OrRAUHr{z_-BhL2ex+(}I|S4d z*f}(Ky+%HP)kj5vE&}N%@QpWpcj=ECPdV;_z{9)ll}8@<|5Krh+quOPflUQ&&)p7$ zSN8v|!8z+NyiNhksc9Ev>adLe+oUNH7( zlFQqd|LW`o=+TmvmO*AqX;EvA00QTbaKRD*1h$kGwdM#Qa1IFT8~F&0g&NUI1iPF9rp=2q3VF4rA&G zAh7y~D9}X!fn9VMQ%?Ya)kj2uE&>SbqQjVa0tl==A_{a7KwuXg#?%u)VD%AEpo;(k zyXY{co&W-?kB95l*c`(w#W z0SF*)0O%~~j{pMuV`*Tfm!F?|p}KnkklBEOlvqpvfs5HNVt@bw8wiOKiwPibF&jn< z5I|r9AyHy60R%2)!-xR_2y7rEN-QRTz{PABF+c!;4TMCA#RL$zm<=Na2q3V5kSMX3 zKm-DR^6$)2b@u`kM;qTr1Tx1LYD^s?a7<}euvY}GV5l**gupSSUBO-vxPqa^)Di;6 zly(JsMc@jC8dFOM98=mA>=l747-~!{A#hA-SFl$Eu3)GYXzBhB&i9qx3xLcONIvQo z=9XHESRAzi_M1mw`x!>v0Rl%Izy0PB*nWmlcYwfA$8W!R1h$`H)Eyvj)bZPI9)ay= z7#8Aja!0;`DsqsM9&O78_wQMslfkXch2)KZ!N0+&X{1DXgRu%YLp;-F#d|8+$ez;u-{0 z5!h7V_0wx;{^fb1o#m`c|ersCV;?hK8z|SfWXQFqC7VN1a|XbR5<|zRvr-L zxd|Y!n-8PP2_UfYfGE#R0D;|n7|jwG-uI{8{}%w6vte;&i~s@~3ygBJ1Q0mOgEM0U z5ZG8?l$#}hz*!!g86$we#sZ_H%kD4 zvphI6MgW0t9oTPQ|IjaT_vg*=v6)-n%^krAAagMEEbN0o?dksW|D^w9d1Y2@Z{yllP0qX!*lGf=eZTwfE8jeExxG&F@YMJhhh|Uy E2NNWD1^@s6 literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..a12a34e6e09bf0193abbe6f7404e26de33ddbe38 GIT binary patch literal 1495 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|#^NA%C&rs6b?Si}mUKs7M+SzC z{oH>NS%G|oWRD45bDP46hOx7_4S6Fo+k-*%fF5l;AAz zh%9Dc&{GCs#)_r(Wk5mp5>H=O_E*d@{46YfmTr?77+7^ZT^vI!1R0fB@BU(}4f6XB zR7NpiqSyqe0iy;H4$09l8Vw`DAwXEgXgVSsM*4S{93Cj=Zw0CJboFyt=akR{0L}9& ASO5S3 literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..c5accf11567547a16c4a8737031d199a10eca26c GIT binary patch literal 1495 zcmeAS@N?(olHy`uVBq!ia0vp^LLkh+1|-AI^@Rf|#^NA%C&rs6b?Si}mUKs7M+SzC z{oH>NS%G|oWRD45bDP46hOx7_4S6Fo+k-*%fF5l;AAz zh%9Dc&{GCs#)_r(Wk5mp5>H=O_E*d@{4BaW-S_@8FtF-+x;Tbd2r??M-u=axU~LN& zqYTK33o@{Pi~unx0j5S$3`~?5fUI}aAmq@%&K?aT?BRkeIvPgEp@E$}_`-+