mirror of
https://github.com/minetest-mods/i3.git
synced 2024-12-24 18:00:38 +01:00
Add a font size global change slider
This commit is contained in:
parent
1389027a22
commit
48ab26b4c6
2
init.lua
2
init.lua
@ -52,9 +52,9 @@ i3 = {
|
|||||||
saves = { -- Metadata to save
|
saves = { -- Metadata to save
|
||||||
bag = true,
|
bag = true,
|
||||||
home = true,
|
home = true,
|
||||||
|
font_size = true,
|
||||||
waypoints = true,
|
waypoints = true,
|
||||||
inv_items = true,
|
inv_items = true,
|
||||||
drop_items = true,
|
|
||||||
known_recipes = true,
|
known_recipes = true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -558,35 +558,12 @@ local function compress_items(list, start_i)
|
|||||||
return new_inv
|
return new_inv
|
||||||
end
|
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 function sort_inventory(player, data)
|
||||||
local inv = player:get_inventory()
|
local inv = player:get_inventory()
|
||||||
local list = inv:get_list"main"
|
local list = inv:get_list"main"
|
||||||
local size = inv:get_size"main"
|
local size = inv:get_size"main"
|
||||||
local start_i = data.ignore_hotbar and (i3.settings.hotbar_len + 1) or 1
|
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
|
if data.inv_compress then
|
||||||
list = compress_items(list, start_i)
|
list = compress_items(list, start_i)
|
||||||
else
|
else
|
||||||
|
@ -19,11 +19,6 @@ local function inv_fields(player, data, fields)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if fields.drop_items then
|
|
||||||
local items = split(fields.drop_items, ",")
|
|
||||||
data.drop_items = items
|
|
||||||
end
|
|
||||||
|
|
||||||
for field in pairs(fields) do
|
for field in pairs(fields) do
|
||||||
if sub(field, 1, 4) == "btn_" then
|
if sub(field, 1, 4) == "btn_" then
|
||||||
data.subcat = indexof(i3.categories, sub(field, 5))
|
data.subcat = indexof(i3.categories, sub(field, 5))
|
||||||
@ -158,6 +153,9 @@ local function inv_fields(player, data, fields)
|
|||||||
elseif fields.bag_rename then
|
elseif fields.bag_rename then
|
||||||
data.bag_rename = true
|
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
|
elseif fields.confirm_rename then
|
||||||
local bag = get_detached_inv("bag", name)
|
local bag = get_detached_inv("bag", name)
|
||||||
local bagstack = bag:get_stack("main", 1)
|
local bagstack = bag:get_stack("main", 1)
|
||||||
|
33
src/gui.lua
33
src/gui.lua
@ -576,11 +576,11 @@ local function show_popup(fs, data)
|
|||||||
local show_sorting = data.show_setting == "sorting"
|
local show_sorting = data.show_setting == "sorting"
|
||||||
local show_misc = data.show_setting == "misc"
|
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"),
|
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"),
|
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"))
|
show_misc and colors.yellow or "#fff"))
|
||||||
|
|
||||||
button(2.2, 9.25, 1.8, 0.55, "setting_home", "Home")
|
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(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))
|
checkbox(5.4, 10.05, "cb_auto_sorting", "Automation", tostring(data.auto_sorting))
|
||||||
|
|
||||||
for _ = 1, 3 do
|
local sign = (data.font_size > 0 and "+") or (data.font_size > 0 and "-") or ""
|
||||||
box(5.4, 10.68, 2.4, 0.45, "#707070")
|
label(5.4, 10.55, ES"Font size" .. fmt(": %s", sign .. data.font_size))
|
||||||
end
|
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("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]")
|
|
||||||
|
|
||||||
fs(fmt("tooltip[cb_inv_compress;%s;#707070;#fff]",
|
fs(fmt("tooltip[cb_inv_compress;%s;#707070;#fff]",
|
||||||
ES"Enable this option to compress your inventory"),
|
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]",
|
fmt("tooltip[cb_ignore_hotbar;%s;#707070;#fff]",
|
||||||
ES"Enable this option to sort your inventory except the hotbar slots"),
|
ES"Enable this option to sort your inventory except the hotbar slots"),
|
||||||
fmt("tooltip[cb_auto_sorting;%s;#707070;#fff]",
|
fmt("tooltip[cb_auto_sorting;%s;#707070;#fff]",
|
||||||
ES"Enable this option to sort your inventory automatically"),
|
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"))))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1586,7 +1579,15 @@ local function make_fs(player, data)
|
|||||||
msg(data.player_name, fmt("#fs elements: %u", #fs))
|
msg(data.player_name, fmt("#fs elements: %u", #fs))
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
return make_fs, get_inventory_fs
|
return make_fs, get_inventory_fs
|
||||||
|
@ -77,7 +77,8 @@ local styles = string.format([[
|
|||||||
style_type[label,field;font_size=16]
|
style_type[label,field;font_size=16]
|
||||||
style_type[button;border=false;content_offset=0]
|
style_type[button;border=false;content_offset=0]
|
||||||
style_type[image_button,item_image_button,checkbox,dropdown;border=false;sound=i3_click]
|
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[;sound=]
|
||||||
style[nofav;sound=i3_cannot]
|
style[nofav;sound=i3_cannot]
|
||||||
|
Loading…
Reference in New Issue
Block a user