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 0000000..f7b6acd Binary files /dev/null and b/textures/i3_bg_goto.png differ