From 0e2f233234efc6980d34a533d6d16b508c115c92 Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Sun, 14 Aug 2022 20:12:28 +0200 Subject: [PATCH] Improve Quick Crafting look a bit --- src/callbacks.lua | 2 +- src/common.lua | 8 +++---- src/fields.lua | 24 ++++++++++----------- src/gui.lua | 45 +++++++++++++++++++++++---------------- src/styles.lua | 4 ++-- textures/i3_crafting.png | Bin 0 -> 1842 bytes textures/i3_export.png | Bin 3170 -> 0 bytes 7 files changed, 46 insertions(+), 37 deletions(-) create mode 100644 textures/i3_crafting.png delete mode 100644 textures/i3_export.png diff --git a/src/callbacks.lua b/src/callbacks.lua index c85bb5e..e52068b 100644 --- a/src/callbacks.lua +++ b/src/callbacks.lua @@ -217,7 +217,7 @@ local function init_data(player, info) data.auto_sorting = false data.reverse_sorting = false data.inv_compress = true - data.export_counts = {} + data.crafting_counts = {} data.tab = 1 data.itab = 1 data.subcat = 1 diff --git a/src/common.lua b/src/common.lua index 3e34c0c..7978c31 100644 --- a/src/common.lua +++ b/src/common.lua @@ -413,7 +413,7 @@ local function craft_stack(player, data, craft_rcp) local stackname, stackcount, stackmax = output:get_name(), output:get_count(), output:get_stack_max() local scrbar_val = data[fmt("scrbar_%s", craft_rcp and "rcp" or "usg")] or 1 - for name, count in pairs(data.export_counts[rcp_usg].rcp) do + for name, count in pairs(data.crafting_counts[rcp_usg].rcp) do local items = {[name] = count} if is_group(name) then @@ -424,7 +424,7 @@ local function craft_stack(player, data, craft_rcp) local remaining = count for _, item in ipairs(item_groups) do - for _name, _count in pairs(data.export_counts[rcp_usg].inv) do + for _name, _count in pairs(data.crafting_counts[rcp_usg].inv) do if item == _name and remaining > 0 then local c = min(remaining, _count) items[item] = c @@ -598,8 +598,8 @@ local function reset_data(data) data.goto_page = nil data.recipes = nil data.usages = nil - data.export_rcp = nil - data.export_usg = nil + data.crafting_rcp = nil + data.crafting_usg = nil data.alt_items = nil data.confirm_trash = nil data.show_settings = nil diff --git a/src/fields.lua b/src/fields.lua index 3dcadfb..9a5c6e1 100644 --- a/src/fields.lua +++ b/src/fields.lua @@ -304,8 +304,8 @@ local function select_item(player, data, fields) data.unum = 1 data.scrbar_rcp = 1 data.scrbar_usg = 1 - data.export_rcp = nil - data.export_usg = nil + data.crafting_rcp = nil + data.crafting_usg = nil end end @@ -374,13 +374,13 @@ local function rcp_fields(player, data, fields) elseif fields.prev_recipe or fields.next_recipe then local num = data.rnum + (fields.prev_recipe and -1 or 1) data.rnum = data.recipes[num] and num or (fields.prev_recipe and #data.recipes or 1) - data.export_rcp = nil + data.crafting_rcp = nil data.scrbar_rcp = 1 elseif fields.prev_usage or fields.next_usage then local num = data.unum + (fields.prev_usage and -1 or 1) data.unum = data.usages[num] and num or (fields.prev_usage and #data.usages or 1) - data.export_usg = nil + data.crafting_usg = nil data.scrbar_usg = 1 elseif fields.fav then @@ -392,17 +392,17 @@ local function rcp_fields(player, data, fields) remove(data.favs, fav) end - elseif fields.export_rcp or fields.export_usg then - if fields.export_rcp then - data.export_rcp = not data.export_rcp + elseif fields.crafting_rcp or fields.crafting_usg then + if fields.crafting_rcp then + data.crafting_rcp = not data.crafting_rcp - if not data.export_rcp then + if not data.crafting_rcp then data.scrbar_rcp = 1 end else - data.export_usg = not data.export_usg + data.crafting_usg = not data.crafting_usg - if not data.export_usg then + if not data.crafting_usg then data.scrbar_usg = 1 end end @@ -415,10 +415,10 @@ local function rcp_fields(player, data, fields) craft_stack(player, data, fields.craft_rcp) if fields.craft_rcp then - data.export_rcp = nil + data.crafting_rcp = nil data.scrbar_rcp = 1 else - data.export_usg = nil + data.crafting_usg = nil data.scrbar_usg = 1 end else diff --git a/src/gui.lua b/src/gui.lua index 6a1d03d..b5e6e6b 100644 --- a/src/gui.lua +++ b/src/gui.lua @@ -82,8 +82,8 @@ local function get_stack_max(inv, data, is_recipe, rcp) counts_rcp[it] = (counts_rcp[it] or 0) + 1 end - data.export_counts[rcp_usg] = {} - data.export_counts[rcp_usg].rcp = counts_rcp + data.crafting_counts[rcp_usg] = {} + data.crafting_counts[rcp_usg].rcp = counts_rcp for i = 1, size do local stack = list[i] @@ -111,7 +111,7 @@ local function get_stack_max(inv, data, is_recipe, rcp) end end - data.export_counts[rcp_usg].inv = counts_inv + data.crafting_counts[rcp_usg].inv = counts_inv for name in pairs(counts_rcp) do counts[name] = floor((counts_inv[name] or 0) / (counts_rcp[name] or 0)) @@ -365,7 +365,7 @@ local function get_waypoint_fs(fs, data, player, yextra, ctn_len) if waypoint_preview then image(0.25, y - 3.5, 5, 4, PNG.bg_content) - fs"style[area_preview;font_size=16]" + fs"style[area_preview;font_size=16;textcolor=#ddd]" button(0.25, y - 3.35, 5, 0.55, "area_preview", v.name) image_button(4.65, y - 3.25, 0.25, 0.25, PNG.cancel_hover .. "^\\[brighten", "close_preview", "") @@ -374,7 +374,7 @@ local function get_waypoint_fs(fs, data, player, yextra, ctn_len) end end - fs"style_type[label;font=normal;font_size=16]" + fs"style_type[label;font=normal;font_size=16;textcolor=#fff]" end local function get_bag_fs(fs, data, name, esc_name, bag_size, yextra) @@ -1236,16 +1236,16 @@ local function get_header(fs, data) end end -local function get_export_fs(fs, data, is_recipe, is_usage, max_stacks_rcp, max_stacks_usg) +local function get_crafting_fs(fs, data, is_recipe, is_usage, max_stacks_rcp, max_stacks_usg) local name = is_recipe and "rcp" or "usg" - local show_export = (is_recipe and data.export_rcp) or (is_usage and data.export_usg) + local show_crafting = (is_recipe and data.crafting_rcp) or (is_usage and data.crafting_usg) - fs(fmt("style[export_%s;fgimg=%s;fgimg_hovered=%s]", - name, fmt("%s", show_export and PNG.export_hover or PNG.export), PNG.export_hover)) - image_button(data.inv_width + 7.35, data.yoffset + 0.2, 0.45, 0.45, "", fmt("export_%s", name), "") - fs(fmt("tooltip[export_%s;%s]", name, ES"Quick crafting")) + fs(fmt("style[crafting_%s;fgimg=%s;fgimg_hovered=%s;content_offset=0]", + name, fmt("%s", show_crafting and PNG.crafting_hover or PNG.crafting), PNG.crafting_hover)) + image_button(data.inv_width + 7.35, data.yoffset + 0.2, 0.45, 0.45, "", fmt("crafting_%s", name), "") + fs(fmt("tooltip[crafting_%s;%s]", name, ES"Quick crafting")) - if not show_export then return end + if not show_crafting then return end local craft_max = is_recipe and max_stacks_rcp or max_stacks_usg local stack_fs = (is_recipe and data.scrbar_rcp) or (is_usage and data.scrbar_usg) or 1 @@ -1260,12 +1260,21 @@ local function get_export_fs(fs, data, is_recipe, is_usage, max_stacks_rcp, max_ end end + local x = data.inv_width + 6.8 + + fs"style_type[image,button,image_button;noclip=true]" + image(x, data.yoffset + 0.8, 3, 2, PNG.bg_content) + fs"style[quick_crafting;font_size=16;textcolor=#ddd]" + button(x, data.yoffset + 0.85, 3.05, 0.55, "quick_crafting", ES"Quick Crafting") + fs(fmt("style[scrbar_%s;noclip=true]", name), fmt("scrollbaroptions[min=1;max=%u;smallstep=1]", craft_max)) - local x = data.inv_width + 8.1 - scrollbar(x, data.yoffset, 2.5, 0.35, "horizontal", fmt("scrbar_%s", name), stack_fs) - button(x, data.yoffset + 0.4, 2.5, 0.7, fmt("craft_%s", name), ES("Craft (×@1)", stack_fs)) + scrollbar(x + 0.2, data.yoffset + 1.45, 2.5, 0.35, "horizontal", fmt("scrbar_%s", name), stack_fs) + button(x + 0.2, data.yoffset + 1.85, 2.5, 0.7, fmt("craft_%s", name), ES("Craft (×@1)", stack_fs)) + + fs"style_type[label;font_size=16;textcolor=#fff]" + fs"style_type[image,button,image_button;noclip=false]" end local function get_rcp_extra(fs, data, player, panel, is_recipe, is_usage) @@ -1287,15 +1296,15 @@ local function get_rcp_extra(fs, data, player, panel, is_recipe, is_usage) end if is_recipe and max_stacks_rcp == 0 then - data.export_rcp = nil + data.crafting_rcp = nil data.scrbar_rcp = 1 elseif is_usage and max_stacks_usg == 0 then - data.export_usg = nil + data.crafting_usg = nil data.scrbar_usg = 1 end if max_stacks_rcp > 0 or max_stacks_usg > 0 then - get_export_fs(fs, data, is_recipe, is_usage, max_stacks_rcp, max_stacks_usg) + get_crafting_fs(fs, data, is_recipe, is_usage, max_stacks_rcp, max_stacks_usg) end get_rcp_lbl(fs, data, panel, rn, is_recipe) diff --git a/src/styles.lua b/src/styles.lua index d09fd5b..8215ed3 100644 --- a/src/styles.lua +++ b/src/styles.lua @@ -26,7 +26,7 @@ local PNG = { book = "i3_book.png", sign = "i3_sign.png", cancel = "i3_cancel.png", - export = "i3_export.png", + crafting = "i3_crafting.png", slot = "i3_slot.png^\\[resize:128x128", pagenum_hover = "i3_slot.png^\\[resize:128x128^\\[opacity:130", tab = "i3_tab.png", @@ -54,7 +54,7 @@ local PNG = { cancel_hover = "i3_cancel.png^\\[brighten", search_hover = "i3_search.png^\\[brighten", - export_hover = "i3_export.png^\\[brighten", + crafting_hover = "i3_crafting.png^\\[brighten", trash_hover = "i3_trash.png^\\[brighten^\\[colorize:#f00:100", compress_hover = "i3_compress.png^\\[brighten", sort_hover = "i3_sort.png^\\[brighten", diff --git a/textures/i3_crafting.png b/textures/i3_crafting.png new file mode 100644 index 0000000000000000000000000000000000000000..06d44e766cef687b419821a90db2c9dadfdd72e7 GIT binary patch literal 1842 zcmV-22hI42P)grJ~_O1z`;3r2$y z2pW%#Awf9=btQ_xa;Tt&Lk>aqrtNn9!)KCloVGL5cH5GjWU@)Soqo^ry~p#u-&>!r z`|7^BuS{NmAIJwPfGVI5P!5y=g+PxJ9efbD5O^K<1Xu>V2s{W}35)>-iku3dCr||B z0sdSE-y66a*bX!U?LZsQ1RMnp0egY1z~{hgz+=Gmz}diH5mRE20R(b|fD+&qU>6Vp zI^*0Oz;TiEH*gr(2kZbo1?~h+0V;vvK!3T9Kbr}t(&F0_fKNnBJ8%$K1-uP30AB)E z$X)!|N z$W~WKHwjI^8$gBE1qKwci_&FAX(piwcpfP8lBbJ+(}7!oYk@&PUXGD)5SRuOy9Hkg zTn>Dryt^Ox2p9|G=MV|)K%LfI;0F9u;0L7?Bh@qmp8?ffWC?94N|DV{lH=l%U;{oB z<6$eL&;1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+w|Hm^O~W?f?J)07*qoM6N<$g3ts|^#A|> literal 0 HcmV?d00001 diff --git a/textures/i3_export.png b/textures/i3_export.png deleted file mode 100644 index 0e83282e346b6d067b4e9ef36bd7002d7d9b9d98..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3170 zcmV-o44w0dP)bL-YE^YGzAGd(?R4i68_>FKG7 zq9}tycxdE~jk4LSX=-XR-QC@$qoc#Tef!pwN+mh|QftXxH+X;%@RO61=GCiLK6tFD z$%(~ld{(ViO{G#X8yg#DXJ^OUzklBp3I&tP%>60+9`9@cMeZZ zl(4q8W`>7{FBJ~)aB%R#iP8Q)DgYLV z#1{IRYif5g)pVvdfEQY*n;xAhZ%hm_FFe9%hZP{0Y5vFW5N zN&sNwgM0VxnY(xI#;>86G)l171zK`|_JBG{$WjS;Rs{gBC{Ng;5~`wv<>h5FG&B?w zCU^yuP*36ZW4pU#e+Xg~Bq$;Nld4pUlRK;o$5g@zm9XvP2ug5yB|`io4~&kE#(4($ z0ePa9670vcw15_AX=#b;HY}6U3v^}Zb}~uu6%`JYc`No3R!Zn2OVpn5 zmP$Cmx!?&{$D22A;&6a6;2FLr*haxiYzy$t&Q3EhFc5QdurYv!bp^CviV|wSey;aD z*4##lEd1bDCB`CNgDe3oasbvlGBRT3=H|{(@P-s1z>&q_=HT-Hj+%@8JYpLs^ewG` zXHq0QEg_|7CA5<%N>Z#)ABC^IARRjS^ODJqJakh zhd^Zl6xhV1>$`cNdn!J>Cr_OdD2BK8gUJ&u6IZG1IGB9rWBqaY!SylP?bSE;RDKy4HLG| z*g@JP@QC+2ckaXop^n1krFMH3w_HGhi|-;~=~r9Y9s(CnX!blH<86Z4r3umiQ4-2L z5%7c{WkzSpCV|J7us-Uj*S*meZy~U50v)3(4zX5u(F+O$oD1ZEOaM%dlBr?+5Jza` zIsf2!0+g`hQ)YyN^}&O$13YT{!otE?yeq5cXr(ruY=~O_jJvizx}#WJEM2d}g-YT@ zh*A<|uBv@Q%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