diff --git a/builtin/mainmenu/settings/dlg_settings.lua b/builtin/mainmenu/settings/dlg_settings.lua index d668fba50..509a6a420 100644 --- a/builtin/mainmenu/settings/dlg_settings.lua +++ b/builtin/mainmenu/settings/dlg_settings.lua @@ -19,6 +19,8 @@ local component_funcs = dofile(core.get_mainmenu_path() .. DIR_DELIM .. "settings" .. DIR_DELIM .. "components.lua") +local shader_warning_component = dofile(core.get_mainmenu_path() .. DIR_DELIM .. + "settings" .. DIR_DELIM .. "shader_warning_component.lua") local shadows_component = dofile(core.get_mainmenu_path() .. DIR_DELIM .. "settings" .. DIR_DELIM .. "shadows_component.lua") @@ -152,7 +154,12 @@ local function load() table.insert(page_by_id.controls_keyboard_and_mouse.content, 1, change_keys) do - local content = page_by_id.graphics_and_audio_effects.content + local content = page_by_id.graphics_and_audio_graphics.content + table.insert(content, 1, shader_warning_component) + + content = page_by_id.graphics_and_audio_effects.content + table.insert(content, 1, shader_warning_component) + local idx = table.indexof(content, "enable_dynamic_shadows") table.insert(content, idx, shadows_component) @@ -706,7 +713,7 @@ local function buttonhandler(this, fields) local function after_setting_change(comp) write_settings_early() - if comp.setting.name == "touch_controls" then + if comp.setting and comp.setting.name == "touch_controls" then -- Changing the "touch_controls" setting may result in a different -- page list. regenerate_page_list(dialogdata) diff --git a/builtin/mainmenu/settings/shader_warning_component.lua b/builtin/mainmenu/settings/shader_warning_component.lua new file mode 100644 index 000000000..d1de0cd4a --- /dev/null +++ b/builtin/mainmenu/settings/shader_warning_component.lua @@ -0,0 +1,26 @@ +-- Minetest +-- SPDX-License-Identifier: LGPL-2.1-or-later + +return { + query_text = "Shaders", + requires = { + shaders_support = true, + shaders = false, + }, + full_width = true, + get_formspec = function(self, avail_w) + local fs = { + "box[0,0;", avail_w, ",1.2;", mt_color_orange, "]", + "label[0.2,0.4;", fgettext("Shaders are disabled."), "]", + "label[0.2,0.8;", fgettext("This is not a recommended configuration."), "]", + "button[", avail_w - 2.2, ",0.2;2,0.8;fix_shader_warning;", fgettext("Enable"), "]", + } + return table.concat(fs, ""), 1.2 + end, + on_submit = function(self, fields) + if fields.fix_shader_warning then + core.settings:remove("enable_shaders") -- default value is true + return true + end + end, +}