mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 16:13:46 +01:00
Add advanced settings checkbox and hide advanced settings by default (#13861)
Co-authored-by: rubenwardy <rw@rubenwardy.com>
This commit is contained in:
parent
01d26c0e0e
commit
26bb397852
@ -291,7 +291,7 @@ local function update_filtered_pages(query)
|
|||||||
|
|
||||||
for _, page in ipairs(all_pages) do
|
for _, page in ipairs(all_pages) do
|
||||||
local content, page_weight = filter_page_content(page, query_keywords)
|
local content, page_weight = filter_page_content(page, query_keywords)
|
||||||
if page_has_contents(content) then
|
if page_has_contents(page, content) then
|
||||||
local new_page = table.copy(page)
|
local new_page = table.copy(page)
|
||||||
new_page.content = content
|
new_page.content = content
|
||||||
|
|
||||||
@ -347,8 +347,17 @@ local function check_requirements(name, requires)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function page_has_contents(content)
|
function page_has_contents(page, actual_content)
|
||||||
for _, item in ipairs(content) do
|
local is_advanced =
|
||||||
|
page.id:sub(1, #"client_and_server") == "client_and_server" or
|
||||||
|
page.id:sub(1, #"mapgen") == "mapgen" or
|
||||||
|
page.id:sub(1, #"advanced") == "advanced"
|
||||||
|
local show_advanced = core.settings:get_bool("show_advanced")
|
||||||
|
if is_advanced and not show_advanced then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, item in ipairs(actual_content) do
|
||||||
if item == false or item.heading then --luacheck: ignore
|
if item == false or item.heading then --luacheck: ignore
|
||||||
-- skip
|
-- skip
|
||||||
elseif type(item) == "string" then
|
elseif type(item) == "string" then
|
||||||
@ -438,7 +447,7 @@ local formspec_show_hack = false
|
|||||||
|
|
||||||
|
|
||||||
local function get_formspec(dialogdata)
|
local function get_formspec(dialogdata)
|
||||||
local page_id = dialogdata.page_id or "most_used"
|
local page_id = dialogdata.page_id or "accessibility"
|
||||||
local page = filtered_page_by_id[page_id]
|
local page = filtered_page_by_id[page_id]
|
||||||
|
|
||||||
local extra_h = 1 -- not included in tabsize.height
|
local extra_h = 1 -- not included in tabsize.height
|
||||||
@ -452,8 +461,10 @@ local function get_formspec(dialogdata)
|
|||||||
local left_pane_width = TOUCHSCREEN_GUI and 4.5 or 4.25
|
local left_pane_width = TOUCHSCREEN_GUI and 4.5 or 4.25
|
||||||
local search_width = left_pane_width + scrollbar_w - (0.75 * 2)
|
local search_width = left_pane_width + scrollbar_w - (0.75 * 2)
|
||||||
|
|
||||||
local technical_names_w = TOUCHSCREEN_GUI and 6 or 5
|
local back_w = 3
|
||||||
|
local checkbox_w = (tabsize.width - back_w - 2*0.2) / 2
|
||||||
local show_technical_names = core.settings:get_bool("show_technical_names")
|
local show_technical_names = core.settings:get_bool("show_technical_names")
|
||||||
|
local show_advanced = core.settings:get_bool("show_advanced")
|
||||||
|
|
||||||
formspec_show_hack = not formspec_show_hack
|
formspec_show_hack = not formspec_show_hack
|
||||||
|
|
||||||
@ -468,14 +479,21 @@ local function get_formspec(dialogdata)
|
|||||||
|
|
||||||
"box[0,0;", tostring(tabsize.width), ",", tostring(tabsize.height), ";#0000008C]",
|
"box[0,0;", tostring(tabsize.width), ",", tostring(tabsize.height), ";#0000008C]",
|
||||||
|
|
||||||
"button[0,", tostring(tabsize.height + 0.2), ";3,0.8;back;", fgettext("Back"), "]",
|
("button[0,%f;%f,0.8;back;%s]"):format(
|
||||||
|
tabsize.height + 0.2, back_w, fgettext("Back")),
|
||||||
|
|
||||||
("box[%f,%f;%f,0.8;#0000008C]"):format(
|
("box[%f,%f;%f,0.8;#0000008C]"):format(
|
||||||
tabsize.width - technical_names_w, tabsize.height + 0.2, technical_names_w),
|
back_w + 0.2, tabsize.height + 0.2, checkbox_w),
|
||||||
("checkbox[%f,%f;show_technical_names;%s;%s]"):format(
|
("checkbox[%f,%f;show_technical_names;%s;%s]"):format(
|
||||||
tabsize.width - technical_names_w + 0.25, tabsize.height + 0.6,
|
back_w + 2*0.2, tabsize.height + 0.6,
|
||||||
fgettext("Show technical names"), tostring(show_technical_names)),
|
fgettext("Show technical names"), tostring(show_technical_names)),
|
||||||
|
|
||||||
|
("box[%f,%f;%f,0.8;#0000008C]"):format(
|
||||||
|
back_w + 2*0.2 + checkbox_w, tabsize.height + 0.2, checkbox_w),
|
||||||
|
("checkbox[%f,%f;show_advanced;%s;%s]"):format(
|
||||||
|
back_w + 3*0.2 + checkbox_w, tabsize.height + 0.6,
|
||||||
|
fgettext("Show advanced settings"), tostring(show_advanced)),
|
||||||
|
|
||||||
"field[0.25,0.25;", tostring(search_width), ",0.75;search_query;;",
|
"field[0.25,0.25;", tostring(search_width), ",0.75;search_query;;",
|
||||||
core.formspec_escape(dialogdata.query or ""), "]",
|
core.formspec_escape(dialogdata.query or ""), "]",
|
||||||
"field_enter_after_edit[search_query;true]",
|
"field_enter_after_edit[search_query;true]",
|
||||||
@ -610,6 +628,23 @@ local function buttonhandler(this, fields)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if fields.show_advanced ~= nil then
|
||||||
|
local value = core.is_yes(fields.show_advanced)
|
||||||
|
core.settings:set_bool("show_advanced", value)
|
||||||
|
|
||||||
|
local suggested_page_id = update_filtered_pages(dialogdata.query)
|
||||||
|
|
||||||
|
if not filtered_page_by_id[dialogdata.page_id] then
|
||||||
|
dialogdata.components = nil
|
||||||
|
dialogdata.leftscroll = 0
|
||||||
|
dialogdata.rightscroll = 0
|
||||||
|
|
||||||
|
dialogdata.page_id = suggested_page_id
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
if fields.search or fields.key_enter_field == "search_query" then
|
if fields.search or fields.key_enter_field == "search_query" then
|
||||||
dialogdata.components = nil
|
dialogdata.components = nil
|
||||||
dialogdata.leftscroll = 0
|
dialogdata.leftscroll = 0
|
||||||
|
@ -2226,12 +2226,14 @@ continuous_forward (Continuous forward) bool false
|
|||||||
# Useful for recording videos
|
# Useful for recording videos
|
||||||
cinematic (Cinematic mode) bool false
|
cinematic (Cinematic mode) bool false
|
||||||
|
|
||||||
# Whether to show technical names.
|
|
||||||
# Affects mods and texture packs in the Content and Select Mods menus, as well as
|
# Affects mods and texture packs in the Content and Select Mods menus, as well as
|
||||||
# setting names in All Settings.
|
# setting names.
|
||||||
# Controlled by the checkbox in the "All settings" menu.
|
# Controlled by a checkbox in the settings menu.
|
||||||
show_technical_names (Show technical names) bool false
|
show_technical_names (Show technical names) bool false
|
||||||
|
|
||||||
|
# Controlled by a checkbox in the settings menu.
|
||||||
|
show_advanced (Show advanced settings) bool false
|
||||||
|
|
||||||
# Enables the sound system.
|
# Enables the sound system.
|
||||||
# If disabled, this completely disables all sounds everywhere and the in-game
|
# If disabled, this completely disables all sounds everywhere and the in-game
|
||||||
# sound controls will be non-functional.
|
# sound controls will be non-functional.
|
||||||
|
Loading…
Reference in New Issue
Block a user