put style-specific settings in their own tables

and switch between them directly, instead of copy-and-modify.
This commit is contained in:
Vanessa Dannenberg 2021-03-07 06:27:40 -05:00
parent 0c05f06fa8
commit 5a8a75f43b
2 changed files with 34 additions and 51 deletions

View File

@ -35,9 +35,15 @@ unified_inventory = {
-- Trash enabled
trash_enabled = (minetest.settings:get_bool("unified_inventory_trash") ~= false),
imgscale = 1.25,
standard_background = "background9[0,0;1,1;ui_formbg_9_sliced.png;true;16]",}
formspec_x = 1, -- UI doesn't use these first two anymore, but other mods
formspec_y = 1, -- may need them.
-- These tables establish position and layout for the two UI styles.
-- UI doesn't use formspec_[xy] anymore, but other mods may need them.
unified_inventory.style_full = {
formspec_x = 1,
formspec_y = 1,
pagecols = 8,
pagerows = 10,
page_x = 10.75,
@ -55,10 +61,32 @@ unified_inventory = {
form_header_y = 0.4,
btn_spc = 0.85,
btn_size = 0.75,
imgscale = 1.25,
std_inv_x = 0.3,
std_inv_y = 5.75,
standard_background = "background9[0,0;1,1;ui_formbg_9_sliced.png;true;16]",
}
unified_inventory.style_lite = {
formspec_x = 0.6,
formspec_y = 0.6,
pagecols = 4,
pagerows = 6,
page_x = 10.5,
page_y = 1.25,
craft_x = 2.6,
craft_y = 0.75,
resultstr_y = 0.35,
give_btn_x = 0.15,
main_button_x = 10.5,
main_button_y = 7.9,
page_buttons_x = 10.5,
page_buttons_y = 6.3,
searchwidth = 1.6,
form_header_x = 0.2,
form_header_y = 0.2,
btn_spc = 0.8,
btn_size = 0.7,
std_inv_x = 0.1,
std_inv_y = 4.6,
}
-- Disable default creative inventory

View File

@ -21,55 +21,10 @@ end
function unified_inventory.get_per_player_formspec(player_name)
local lite = unified_inventory.lite_mode and not minetest.check_player_privs(player_name, {ui_full=true})
local ui = {}
ui.formspec_x = unified_inventory.formspec_x
ui.formspec_y = unified_inventory.formspec_y
ui.pagecols = unified_inventory.pagecols
ui.pagerows = unified_inventory.pagerows
ui.page_x = unified_inventory.page_x
ui.page_y = unified_inventory.page_y
ui.craft_x = unified_inventory.craft_x
ui.craft_y = unified_inventory.craft_y
ui.resultstr_y = unified_inventory.resultstr_y
ui.give_btn_x = unified_inventory.give_btn_x
ui.main_button_x = unified_inventory.main_button_x
ui.main_button_y = unified_inventory.main_button_y
ui.page_buttons_x = unified_inventory.page_buttons_x
ui.page_buttons_y = unified_inventory.page_buttons_y
ui.searchwidth = unified_inventory.searchwidth
ui.form_header_x = unified_inventory.form_header_x
ui.form_header_y = unified_inventory.form_header_y
ui.btn_spc = unified_inventory.btn_spc
ui.btn_size = unified_inventory.btn_size
ui.std_inv_x = unified_inventory.std_inv_x
ui.std_inv_y = unified_inventory.std_inv_y
ui.standard_inv = unified_inventory.standard_inv
ui.standard_inv_bg = unified_inventory.standard_inv_bg
local ui = unified_inventory.style_full
if lite then
ui.formspec_x = 0.6
ui.formspec_y = 0.6
ui.pagecols = 4
ui.pagerows = 6
ui.page_x = 10.5
ui.page_y = 1.25
ui.craft_x = 2.6
ui.craft_y = 0.75
ui.resultstr_y = 0.35
ui.give_btn_x = 0.15
ui.main_button_x = ui.page_x
ui.main_button_y = 7.9
ui.page_buttons_x = ui.page_x
ui.page_buttons_y = 6.3
ui.searchwidth = 1.6
ui.form_header_x = 0.2
ui.form_header_y = 0.2
ui.btn_spc = 0.8
ui.btn_size = 0.7
ui.std_inv_x = 0.1
ui.std_inv_y = 4.6
ui = unified_inventory.style_lite
end
ui.items_per_page = ui.pagecols * ui.pagerows