1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-11-20 00:25:20 +01:00

Show unavailable settings in menu (#16679)

This commit is contained in:
sfan5
2025-11-16 14:59:56 +01:00
committed by GitHub
parent 7c310cd7f5
commit 7e53e65549
2 changed files with 33 additions and 13 deletions

View File

@@ -137,6 +137,7 @@ local function load()
-- insert after "touch_controls"
table.insert(page_by_id.controls_touchscreen.content, 2, touchscreen_layout)
do
local content = page_by_id.graphics_and_audio_effects.content
local idx = table.indexof(content, "enable_dynamic_shadows")
@@ -407,18 +408,8 @@ function page_has_contents(page, actual_content)
for _, item in ipairs(actual_content) do
if item == false or item.heading then --luacheck: ignore
-- skip
elseif type(item) == "string" then
local setting = get_setting_info(item)
assert(setting, "Unknown setting: " .. item)
if check_requirements(setting.name, setting.requires, setting.context) then
return true
end
elseif item.get_formspec then
if check_requirements(item.id, item.requires, item.context) then
return true
end
else
error("Unknown content in page: " .. dump(item))
return true
end
end
@@ -429,6 +420,7 @@ end
local function build_page_components(page)
-- Filter settings based on requirements
local content = {}
local settings_off = {}
local last_heading
for _, item in ipairs(page.content) do
if item == false then --luacheck: ignore
@@ -437,8 +429,9 @@ local function build_page_components(page)
last_heading = item
else
local name, requires, context
local setting
if type(item) == "string" then
local setting = get_setting_info(item)
setting = get_setting_info(item)
assert(setting, "Unknown setting: " .. item)
name = setting.name
requires = setting.requires
@@ -457,6 +450,8 @@ local function build_page_components(page)
last_heading = nil
end
content[#content + 1] = item
elseif setting then
settings_off[#settings_off + 1] = setting
end
end
end
@@ -475,6 +470,14 @@ local function build_page_components(page)
retval[i] = component_funcs.heading(item.heading)
end
end
if #settings_off > 0 then
retval[#retval + 1] = component_funcs.heading(fgettext_ne("Unavailable"),
-- luacheck: ignore
fgettext_ne("These settings are unavailable due to your platform, hardware or in combination with the current settings.")
)
retval[#retval + 1] = component_funcs.unavail_list(settings_off)
end
return retval
end