diff --git a/init.lua b/init.lua index 36c7688..3edcc19 100644 --- a/init.lua +++ b/init.lua @@ -52,9 +52,9 @@ i3 = { saves = { -- Metadata to save bag = true, home = true, + font_size = true, waypoints = true, inv_items = true, - drop_items = true, known_recipes = true, }, diff --git a/src/common.lua b/src/common.lua index 96cd28f..a6e1647 100644 --- a/src/common.lua +++ b/src/common.lua @@ -558,35 +558,12 @@ local function compress_items(list, start_i) return new_inv end -local function drop_items(player, inv, list, start_i, rej, remove) - for i = start_i, #list do - local stack = list[i] - local name = stack:get_name() - - for _, it in ipairs(rej) do - if name == it then - if not remove then - spawn_item(player, stack) - end - - inv:set_stack("main", i, ItemStack("")) - end - end - end - - return inv:get_list"main" -end - local function sort_inventory(player, data) local inv = player:get_inventory() local list = inv:get_list"main" local size = inv:get_size"main" local start_i = data.ignore_hotbar and (i3.settings.hotbar_len + 1) or 1 - if true_table(data.drop_items) then - list = drop_items(player, inv, list, start_i, data.drop_items, true) - end - if data.inv_compress then list = compress_items(list, start_i) else diff --git a/src/fields.lua b/src/fields.lua index 75fa735..999dbb0 100644 --- a/src/fields.lua +++ b/src/fields.lua @@ -19,11 +19,6 @@ local function inv_fields(player, data, fields) return end - if fields.drop_items then - local items = split(fields.drop_items, ",") - data.drop_items = items - end - for field in pairs(fields) do if sub(field, 1, 4) == "btn_" then data.subcat = indexof(i3.categories, sub(field, 5)) @@ -158,6 +153,9 @@ local function inv_fields(player, data, fields) elseif fields.bag_rename then data.bag_rename = true + elseif fields.sb_font_size then + data.font_size = tonumber(fields.sb_font_size:match"-?%d+$") + elseif fields.confirm_rename then local bag = get_detached_inv("bag", name) local bagstack = bag:get_stack("main", 1) diff --git a/src/gui.lua b/src/gui.lua index 556e29b..ddf39d0 100644 --- a/src/gui.lua +++ b/src/gui.lua @@ -576,11 +576,11 @@ local function show_popup(fs, data) local show_sorting = data.show_setting == "sorting" local show_misc = data.show_setting == "misc" - fs(fmt("style[setting_home;textcolor=%s;font=bold;sound=i3_click]", + fs(fmt("style[setting_home;textcolor=%s;font=bold;font_size=16;sound=i3_click]", show_home and colors.yellow or "#fff"), - fmt("style[setting_sorting;textcolor=%s;font=bold;sound=i3_click]", + fmt("style[setting_sorting;textcolor=%s;font=bold;font_size=16;sound=i3_click]", show_sorting and colors.yellow or "#fff"), - fmt("style[setting_misc;textcolor=%s;font=bold;sound=i3_click]", + fmt("style[setting_misc;textcolor=%s;font=bold;font_size=16;sound=i3_click]", show_misc and colors.yellow or "#fff")) button(2.2, 9.25, 1.8, 0.55, "setting_home", "Home") @@ -624,14 +624,10 @@ local function show_popup(fs, data) checkbox(2.4, 10.95, "cb_ignore_hotbar", "Ignore hotbar", tostring(data.ignore_hotbar)) checkbox(5.4, 10.05, "cb_auto_sorting", "Automation", tostring(data.auto_sorting)) - for _ = 1, 3 do - box(5.4, 10.68, 2.4, 0.45, "#707070") - end - - fs("style[drop_items;font_size=15;font=mono;textcolor=#dbeeff]", - fmt("field[5.4,10.68;2.4,0.45;drop_items;Remove items:;%s]", - ESC(concat(data.drop_items or {}, ","))), - "field_close_on_enter[drop_items;false]") + local sign = (data.font_size > 0 and "+") or (data.font_size > 0 and "-") or "" + label(5.4, 10.55, ES"Font size" .. fmt(": %s", sign .. data.font_size)) + fs"scrollbaroptions[min=-5;max=5;smallstep=1;largestep=1;thumbsize=2]" + fs(fmt("scrollbar[5.4,10.8;2.5,0.25;horizontal;sb_font_size;%d]", data.font_size)) fs(fmt("tooltip[cb_inv_compress;%s;#707070;#fff]", ES"Enable this option to compress your inventory"), @@ -640,10 +636,7 @@ local function show_popup(fs, data) fmt("tooltip[cb_ignore_hotbar;%s;#707070;#fff]", ES"Enable this option to sort your inventory except the hotbar slots"), fmt("tooltip[cb_auto_sorting;%s;#707070;#fff]", - ES"Enable this option to sort your inventory automatically"), - fmt("tooltip[drop_items;%s;#707070;#fff]", - "Add a comma-separated list of items to remove on inventory sorting.\n" .. - "Format: " .. ("mod:item,mod:item, ..."):gsub("(%a+:%a+)", clr("#bddeff", "%1")))) + ES"Enable this option to sort your inventory automatically")) end end end @@ -1586,7 +1579,15 @@ local function make_fs(player, data) msg(data.player_name, fmt("#fs elements: %u", #fs)) end - return concat(fs) + fs = concat(fs) + + if data.font_size ~= 0 then + fs = fs:gsub("([font][global]*)([%s_])size=(%d+)", function(a, b, c) + return fmt("%s%ssize=%s", a, b, tostring(tonumber(c) + data.font_size)) + end) + end + + return fs end return make_fs, get_inventory_fs diff --git a/src/styles.lua b/src/styles.lua index 7c31ef2..0d34018 100644 --- a/src/styles.lua +++ b/src/styles.lua @@ -77,7 +77,8 @@ local styles = string.format([[ style_type[label,field;font_size=16] style_type[button;border=false;content_offset=0] style_type[image_button,item_image_button,checkbox,dropdown;border=false;sound=i3_click] - style_type[item_image_button;bgimg_hovered=%s;bgimg_middle=9;padding=-9] + style_type[item_image_button;bgimg_middle=9;padding=-9] + style_type[item_image_button:hovered;bgimg=%s] style[;sound=] style[nofav;sound=i3_cannot]