From 0c4b4e6c4fd587a065f0fa73446a3debad21af45 Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Sun, 14 Aug 2022 19:18:29 +0200 Subject: [PATCH] Add ability to goto pagenum from pagenum button --- src/common.lua | 1 + src/fields.lua | 16 ++++++++++++---- src/gui.lua | 19 ++++++++++++++++++- src/styles.lua | 2 ++ textures/i3_bg_goto.png | Bin 0 -> 2298 bytes 5 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 textures/i3_bg_goto.png diff --git a/src/common.lua b/src/common.lua index a6e1647..3e34c0c 100644 --- a/src/common.lua +++ b/src/common.lua @@ -595,6 +595,7 @@ local function reset_data(data) data.scrbar_usg = 1 data.query_item = nil data.enable_search = nil + data.goto_page = nil data.recipes = nil data.usages = nil data.export_rcp = nil diff --git a/src/fields.lua b/src/fields.lua index 7038eea..3dcadfb 100644 --- a/src/fields.lua +++ b/src/fields.lua @@ -1,7 +1,7 @@ local set_fs = i3.set_fs -IMPORT("vec_eq", "vec_round") IMPORT("reg_items", "reg_aliases") +IMPORT("min", "max", "vec_eq", "vec_round") IMPORT("S", "random", "translate", "ItemStack") IMPORT("sort", "copy", "insert", "remove", "indexof") IMPORT("fmt", "find", "match", "sub", "lower", "split", "toupper") @@ -89,6 +89,7 @@ local function inv_fields(player, data, fields) data.show_settings = nil data.waypoint_see = nil data.bag_rename = nil + data.goto_page = nil if data.filter == "" then data.enable_search = nil @@ -342,6 +343,14 @@ local function rcp_fields(player, data, fields) sort_by_category(data) end + elseif fields.pagenum then + data.goto_page = not data.goto_page + + elseif fields.goto_page then + local pagenum = tonumber(fields.goto_page) + data.pagenum = max(1, min(data.pagemax, pagenum or data.pagenum)) + data.goto_page = nil + elseif fields.prev_page or fields.next_page then if data.pagemax == 1 then return end data.pagenum -= (fields.prev_page and 1 or -1) @@ -428,9 +437,8 @@ core.register_on_player_receive_fields(function(player, formname, fields) end -- No-op buttons - if fields.player_name or fields.awards or fields.home_pos or fields.pagenum or - fields.no_item or fields.no_rcp or fields.select_sorting or fields.sort_method or - fields.bg_content then + if fields.player_name or fields.awards or fields.home_pos or fields.no_item or + fields.no_rcp or fields.select_sorting or fields.sort_method or fields.bg_content then return false end diff --git a/src/gui.lua b/src/gui.lua index 8e8b7f3..75410d0 100644 --- a/src/gui.lua +++ b/src/gui.lua @@ -1374,7 +1374,11 @@ local function get_items_fs(fs, data, player, full_height) data.pagemax = max(1, ceil(#items / ipp)) - button(data.inv_width + 5.6, 0.14, 1.88, 0.7, "pagenum", + + fs(fmt("style[pagenum;bgimg=%s;bgimg_hovered=%s;bgimg_middle=9;padding=-9]", + data.goto_page and PNG.pagenum_hover or "", PNG.pagenum_hover)) + + button(data.inv_width + 5.8, 0.14, 1.48, 0.7, "pagenum", fmt("%s / %u", clr(colors.yellow, data.pagenum), data.pagemax)) if #items == 0 then @@ -1417,6 +1421,19 @@ local function get_items_fs(fs, data, player, full_height) end end + if data.goto_page then + image(data.inv_width + 4.8, 0.85, 2.9, 0.8, PNG.bg_goto) + fs"style_type[label;font_size=16;textcolor=#ddd]" + label(data.inv_width + 5, 1.25, ES"Go to page" .. ":") + box(data.inv_width + 6.5, 1, 1, 0.45, "#bababa10") + + fs(fmt("style[goto_page;font=mono,bold;font_size=16;textcolor=%s]", colors.yellow), + fmt("field[%f,%f;1,0.45;goto_page;;%s]", data.inv_width + 6.55, 1.05, data.pagenum), + "field_close_on_enter[goto_page;false]") + + fs"style_type[label;font_size=16;textcolor=#fff]" + end + local _tabs = {"All", "Nodes", "Items"} local tab_len, tab_hgh = 1.8, 0.5 diff --git a/src/styles.lua b/src/styles.lua index 18e1fc8..66fab38 100644 --- a/src/styles.lua +++ b/src/styles.lua @@ -4,6 +4,7 @@ local PNG = { blank = "i3_blank.png", bg = "i3_bg.png", bg_full = "i3_bg_full.png", + bg_goto = "i3_bg_goto.png", bg_content = "i3_bg_content.png", bar = "i3_bar.png", hotbar = "i3_hotbar.png", @@ -26,6 +27,7 @@ local PNG = { cancel = "i3_cancel.png", export = "i3_export.png", slot = "i3_slot.png^\\[resize:128x128", + pagenum_hover = "i3_slot.png^\\[resize:128x128^\\[opacity:130", tab = "i3_tab.png", tab_small = "i3_tab_small.png", tab_top = "i3_tab.png^\\[transformFY", diff --git a/textures/i3_bg_goto.png b/textures/i3_bg_goto.png new file mode 100644 index 0000000000000000000000000000000000000000..f7b6acd8e5e0aa962ad7b5b6874f578f33b48fbf GIT binary patch literal 2298 zcmZ{ldo-_OP-{14RzxDfmp7lQK_hz~}+eu06 zlK=onIoR8{0U)FTJ*U8TK{2da;U@rK>11nbR|jir?1kvav*hp)05l3N6{=!;St2$?P?6!U9xly{lVfZ zmGb7Caf{^SN7?Jzt1+p0c*96s=fOQgN7%K9NLiQ2vE9$Mx)C0QL~aZ>>WZ%Ym%g~3 zdE;jUx@egqPJc0h3vcvV4!)J`-9O5xVzBPqcJIiK^PX?-@xD9iy;b&wHrw8D|4Cel zx_vO>L_XH)7&_#Xt96dY4S7lOOBc!}9sSrwm*y98I9mIrgw%bW*!JbuQ$DnQabwL= zkQf-gMUsav3)N+uPsL2eFNv%j74}Tz1fCbtFRwH<^?48Hzuu)=Z&q?&%x?u)yJUn9 z1p_6e3Q$oj*1?G&_69C3tAosKj%kG|;tn>)PElUIojQ>> zX)A9z>{%GxC*@s(y$yWOu$chgvdVE{WZ=K9(8Opj>rF-}l zA+X8cND@is17Or+mq;BK0$a?i`tgsutoA5^POBj8UON|qO61VNlS04+g-Rftne*); zY3dfv0ICcMn?Sl+i>J9|*!m#UKxYbD-NpRccrT}DM59K6$+n4Q$N)+iUjZ{jq||0H z%i{Lo5Q=myD*+aP0ryt<)xxY-&*X4NlrR=y`U89o9@o|UVljhhD2D_y+mbnB@7x=s zbiet1i@@QFZp+p2O$;9LY^ZQ4FcHdVO5>eCpcibZ+Pxg|o56+(UR8POpXv|&#f8DL zfo;n6+i?uN+C+LC7r}}d-o5avXf#V^gRHjKN0J~jJ1P#64K&pPvL-0mOZrNr^n!Nc&EGZ+JTb9IS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