api: moved default values to enhancement handler class
This commit is contained in:
parent
2707fb02ea
commit
76804b1df0
@ -14,10 +14,12 @@ Methods:
|
|||||||
- receive_fields(handler, player, context, fields)
|
- receive_fields(handler, player, context, fields)
|
||||||
|
|
||||||
Method does set Attributes:
|
Method does set Attributes:
|
||||||
- enh.formspec_resize
|
- enh.formspec_size
|
||||||
- enh.formspec_before_navfs
|
- enh.formspec_before_navfs
|
||||||
- enh.formspec_after_navfs
|
- enh.formspec_after_navfs
|
||||||
- enh.formspec_after_content
|
- enh.formspec_after_content
|
||||||
|
- theme_main - Theme
|
||||||
|
- theme_inv - Player inventory fields
|
||||||
- enh.custom_nav_fs - if set, default is skipped
|
- enh.custom_nav_fs - if set, default is skipped
|
||||||
]]
|
]]
|
||||||
|
|
||||||
@ -78,13 +80,16 @@ local orig_make_formspec = sfinv.make_formspec
|
|||||||
function sfinv.make_formspec(player, context, content, show_inv, size)
|
function sfinv.make_formspec(player, context, content, show_inv, size)
|
||||||
context.sfinv_navfs_handler = nil -- initialize handler
|
context.sfinv_navfs_handler = nil -- initialize handler
|
||||||
local handler = smart_sfinv_api.get_handler( context )
|
local handler = smart_sfinv_api.get_handler( context )
|
||||||
|
if size then
|
||||||
|
handler.formspec_size = size
|
||||||
|
end
|
||||||
local nav_fs = sfinv.get_nav_fs(player, context, context.nav_titles, context.nav_idx)
|
local nav_fs = sfinv.get_nav_fs(player, context, context.nav_titles, context.nav_idx)
|
||||||
|
|
||||||
handler:run_enhancements("make_formspec", player, context)
|
handler:run_enhancements("make_formspec", player, context)
|
||||||
|
|
||||||
local tmp = {
|
local tmp = {
|
||||||
handler.formspec_resize or size or smart_sfinv_api.default_size,
|
handler.formspec_size,
|
||||||
smart_sfinv_api.theme_main,
|
handler.theme_main,
|
||||||
handler.formspec_before_navfs,
|
handler.formspec_before_navfs,
|
||||||
nav_fs,
|
nav_fs,
|
||||||
handler.formspec_after_navfs,
|
handler.formspec_after_navfs,
|
||||||
@ -92,7 +97,7 @@ function sfinv.make_formspec(player, context, content, show_inv, size)
|
|||||||
handler.formspec_after_content
|
handler.formspec_after_content
|
||||||
}
|
}
|
||||||
if show_inv then
|
if show_inv then
|
||||||
tmp[#tmp + 1] = smart_sfinv_api.theme_inv
|
tmp[#tmp + 1] = handler.theme_inv
|
||||||
end
|
end
|
||||||
return table.concat(tmp, "")
|
return table.concat(tmp, "")
|
||||||
end
|
end
|
||||||
@ -122,4 +127,4 @@ end)
|
|||||||
-- Initialization: hacky access to some default variables
|
-- Initialization: hacky access to some default variables
|
||||||
----------------------------------------------
|
----------------------------------------------
|
||||||
local _dummy_page = orig_make_formspec(nil, {}, "|", true, nil)
|
local _dummy_page = orig_make_formspec(nil, {}, "|", true, nil)
|
||||||
smart_sfinv_api.default_size, smart_sfinv_api.theme_main, smart_sfinv_api.theme_inv = _dummy_page:match("(size%[[%d.,]+%]+)([^|]+)|([^|]+)")
|
enh_handler_class.formspec_size, enh_handler_class.theme_main, enh_handler_class.theme_inv = _dummy_page:match("(size%[[%d.,]+%]+)([^|]+)|([^|]+)")
|
||||||
|
@ -40,7 +40,7 @@ smart_sfinv_api.register_enhancement({
|
|||||||
handler.formspec_before_navfs = "textlist[0,0;2.8,8.6;smart_sfinv_nav_site;" .. table.concat(nav_titles_site, ",") ..
|
handler.formspec_before_navfs = "textlist[0,0;2.8,8.6;smart_sfinv_nav_site;" .. table.concat(nav_titles_site, ",") ..
|
||||||
";" .. context.current_idx_site .. ";true]container[3.5,0]"..handler.formspec_before_navfs
|
";" .. context.current_idx_site .. ";true]container[3.5,0]"..handler.formspec_before_navfs
|
||||||
handler.formspec_after_content = handler.formspec_after_content.."container_end[]"
|
handler.formspec_after_content = handler.formspec_after_content.."container_end[]"
|
||||||
handler.formspec_resize = 'size[11,8.6]'
|
handler.formspec_size = 'size[11,8.6]'
|
||||||
elseif current_idx_above >= 2 then
|
elseif current_idx_above >= 2 then
|
||||||
-- Because "Creative" is inserted, the index needs to be adjusted
|
-- Because "Creative" is inserted, the index needs to be adjusted
|
||||||
current_idx_above = current_idx_above + 1
|
current_idx_above = current_idx_above + 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user