mirror of
https://github.com/minetest/minetest.git
synced 2024-08-19 04:54:18 +02:00
Settings GUI: Move shadow presets to Shaders, remove Most Used (#13713)
This commit is contained in:
parent
28fce8aad5
commit
752ce1a1b2
@ -19,8 +19,8 @@
|
||||
local component_funcs = dofile(core.get_mainmenu_path() .. DIR_DELIM ..
|
||||
"settings" .. DIR_DELIM .. "components.lua")
|
||||
|
||||
local quick_shader_component = dofile(core.get_mainmenu_path() .. DIR_DELIM ..
|
||||
"settings" .. DIR_DELIM .. "shader_component.lua")
|
||||
local shadows_component = dofile(core.get_mainmenu_path() .. DIR_DELIM ..
|
||||
"settings" .. DIR_DELIM .. "shadows_component.lua")
|
||||
|
||||
|
||||
local full_settings = settingtypes.parse_config_file(false, true)
|
||||
@ -61,31 +61,6 @@ local change_keys = {
|
||||
}
|
||||
|
||||
|
||||
add_page({
|
||||
id = "most_used",
|
||||
title = gettext("Most Used"),
|
||||
content = {
|
||||
change_keys,
|
||||
"language",
|
||||
"fullscreen",
|
||||
PLATFORM ~= "Android" and "autosave_screensize" or false,
|
||||
"touchscreen_threshold",
|
||||
{ heading = gettext("Scaling") },
|
||||
"gui_scaling",
|
||||
"hud_scaling",
|
||||
{ heading = gettext("Graphics / Performance") },
|
||||
"smooth_lighting",
|
||||
"enable_particles",
|
||||
"enable_3d_clouds",
|
||||
"opaque_water",
|
||||
"connected_glass",
|
||||
"node_highlighting",
|
||||
"leaves_style",
|
||||
{ heading = gettext("Shaders") },
|
||||
quick_shader_component,
|
||||
},
|
||||
})
|
||||
|
||||
add_page({
|
||||
id = "accessibility",
|
||||
title = gettext("Accessibility"),
|
||||
@ -155,6 +130,11 @@ end
|
||||
load_settingtypes()
|
||||
|
||||
table.insert(page_by_id.controls_keyboard_and_mouse.content, 1, change_keys)
|
||||
do
|
||||
local content = page_by_id.graphics_and_audio_shaders.content
|
||||
local idx = table.indexof(content, "enable_dynamic_shadows")
|
||||
table.insert(content, idx, shadows_component)
|
||||
end
|
||||
|
||||
|
||||
local function get_setting_info(name)
|
||||
|
@ -1,163 +0,0 @@
|
||||
--Minetest
|
||||
--Copyright (C) 2013 sapier
|
||||
--Copyright (C) 2021-2 x2048
|
||||
--Copyright (C) 2022-3 rubenwardy
|
||||
--
|
||||
--This program is free software; you can redistribute it and/or modify
|
||||
--it under the terms of the GNU Lesser General Public License as published by
|
||||
--the Free Software Foundation; either version 2.1 of the License, or
|
||||
--(at your option) any later version.
|
||||
--
|
||||
--This program is distributed in the hope that it will be useful,
|
||||
--but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
--GNU Lesser General Public License for more details.
|
||||
--
|
||||
--You should have received a copy of the GNU Lesser General Public License along
|
||||
--with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
|
||||
local shadow_levels_labels = {
|
||||
fgettext("Disabled"),
|
||||
fgettext("Very Low"),
|
||||
fgettext("Low"),
|
||||
fgettext("Medium"),
|
||||
fgettext("High"),
|
||||
fgettext("Very High")
|
||||
}
|
||||
|
||||
|
||||
local function get_shadow_mapping_idx()
|
||||
local level = tonumber(core.settings:get("shadow_levels"))
|
||||
if level and level >= 0 and level < #shadow_levels_labels then
|
||||
return level + 1
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
|
||||
local function set_shadow_mapping_idx(v)
|
||||
assert(v >= 1 and v <= #shadow_levels_labels)
|
||||
core.settings:set("shadow_levels", tostring(v - 1))
|
||||
end
|
||||
|
||||
|
||||
return {
|
||||
query_text = "Shaders",
|
||||
get_formspec = function(self, avail_w)
|
||||
local fs = ""
|
||||
|
||||
local video_driver = core.get_active_driver()
|
||||
local shaders_enabled = core.settings:get_bool("enable_shaders")
|
||||
if video_driver == "opengl" then
|
||||
fs = fs ..
|
||||
"checkbox[0,0.25;cb_shaders;" .. fgettext("Shaders") .. ";"
|
||||
.. tostring(shaders_enabled) .. "]"
|
||||
elseif video_driver == "ogles2" then
|
||||
fs = fs ..
|
||||
"checkbox[0,0.25;cb_shaders;" .. fgettext("Shaders (experimental)") .. ";"
|
||||
.. tostring(shaders_enabled) .. "]"
|
||||
else
|
||||
core.settings:set_bool("enable_shaders", false)
|
||||
shaders_enabled = false
|
||||
fs = fs ..
|
||||
"label[0.13,0.25;" .. core.colorize("#888888",
|
||||
fgettext("Shaders (unavailable)")) .. "]"
|
||||
end
|
||||
|
||||
if shaders_enabled then
|
||||
fs = fs ..
|
||||
"container[0,0.75]" ..
|
||||
"checkbox[0,0;cb_tonemapping;" .. fgettext("Tone mapping") .. ";"
|
||||
.. tostring(core.settings:get_bool("tone_mapping")) .. "]" ..
|
||||
"checkbox[0,0.5;cb_waving_water;" .. fgettext("Waving liquids") .. ";"
|
||||
.. tostring(core.settings:get_bool("enable_waving_water")) .. "]" ..
|
||||
"checkbox[0,1;cb_waving_leaves;" .. fgettext("Waving leaves") .. ";"
|
||||
.. tostring(core.settings:get_bool("enable_waving_leaves")) .. "]" ..
|
||||
"checkbox[0,1.5;cb_waving_plants;" .. fgettext("Waving plants") .. ";"
|
||||
.. tostring(core.settings:get_bool("enable_waving_plants")) .. "]"
|
||||
|
||||
if video_driver == "opengl" then
|
||||
fs = fs ..
|
||||
"label[0,2.2;" .. fgettext("Dynamic shadows") .. "]" ..
|
||||
"dropdown[0,2.4;3,0.8;dd_shadows;" .. table.concat(shadow_levels_labels, ",") .. ";" ..
|
||||
get_shadow_mapping_idx() .. ";true]" ..
|
||||
"label[0,3.5;" .. core.colorize("#bbb", fgettext("(The game will need to enable shadows as well)")) .. "]"
|
||||
else
|
||||
fs = fs ..
|
||||
"label[0,2.2;" .. core.colorize("#888888", fgettext("Dynamic shadows")) .. "]"
|
||||
end
|
||||
|
||||
fs = fs .. "container_end[]"
|
||||
else
|
||||
fs = fs ..
|
||||
"container[0.35,0.75]" ..
|
||||
"label[0,0;" .. core.colorize("#888888",
|
||||
fgettext("Tone mapping")) .. "]" ..
|
||||
"label[0,0.5;" .. core.colorize("#888888",
|
||||
fgettext("Waving liquids")) .. "]" ..
|
||||
"label[0,1;" .. core.colorize("#888888",
|
||||
fgettext("Waving leaves")) .. "]" ..
|
||||
"label[0,1.5;" .. core.colorize("#888888",
|
||||
fgettext("Waving plants")) .. "]"..
|
||||
"label[0,2;" .. core.colorize("#888888",
|
||||
fgettext("Dynamic shadows")) .. "]" ..
|
||||
"container_end[]"
|
||||
end
|
||||
return fs, 4.5
|
||||
end,
|
||||
|
||||
on_submit = function(self, fields)
|
||||
if fields.cb_shaders then
|
||||
core.settings:set("enable_shaders", fields.cb_shaders)
|
||||
return true
|
||||
end
|
||||
if fields.cb_tonemapping then
|
||||
core.settings:set("tone_mapping", fields.cb_tonemapping)
|
||||
return true
|
||||
end
|
||||
if fields.cb_waving_water then
|
||||
core.settings:set("enable_waving_water", fields.cb_waving_water)
|
||||
return true
|
||||
end
|
||||
if fields.cb_waving_leaves then
|
||||
core.settings:set("enable_waving_leaves", fields.cb_waving_leaves)
|
||||
return true
|
||||
end
|
||||
if fields.cb_waving_plants then
|
||||
core.settings:set("enable_waving_plants", fields.cb_waving_plants)
|
||||
return true
|
||||
end
|
||||
|
||||
if fields.dd_shadows then
|
||||
local old_shadow_level_idx = get_shadow_mapping_idx()
|
||||
local shadow_level_idx = tonumber(fields.dd_shadows)
|
||||
if shadow_level_idx == nil or shadow_level_idx == old_shadow_level_idx then
|
||||
return false
|
||||
end
|
||||
|
||||
set_shadow_mapping_idx(shadow_level_idx)
|
||||
|
||||
local shadow_presets = {
|
||||
[2] = { 62, 512, "true", 0, "false" },
|
||||
[3] = { 93, 1024, "true", 0, "false" },
|
||||
[4] = { 140, 2048, "true", 1, "false" },
|
||||
[5] = { 210, 4096, "true", 2, "true" },
|
||||
[6] = { 300, 8192, "true", 2, "true" },
|
||||
}
|
||||
local preset = shadow_presets[shadow_level_idx]
|
||||
if preset then
|
||||
core.settings:set("enable_dynamic_shadows", "true")
|
||||
core.settings:set("shadow_map_max_distance", preset[1])
|
||||
core.settings:set("shadow_map_texture_size", preset[2])
|
||||
core.settings:set("shadow_map_texture_32bit", preset[3])
|
||||
core.settings:set("shadow_filters", preset[4])
|
||||
core.settings:set("shadow_map_color", preset[5])
|
||||
else
|
||||
core.settings:set("enable_dynamic_shadows", "false")
|
||||
end
|
||||
return true
|
||||
end
|
||||
end,
|
||||
}
|
121
builtin/mainmenu/settings/shadows_component.lua
Normal file
121
builtin/mainmenu/settings/shadows_component.lua
Normal file
@ -0,0 +1,121 @@
|
||||
--Minetest
|
||||
--Copyright (C) 2021-2 x2048
|
||||
--Copyright (C) 2022-3 rubenwardy
|
||||
--
|
||||
--This program is free software; you can redistribute it and/or modify
|
||||
--it under the terms of the GNU Lesser General Public License as published by
|
||||
--the Free Software Foundation; either version 2.1 of the License, or
|
||||
--(at your option) any later version.
|
||||
--
|
||||
--This program is distributed in the hope that it will be useful,
|
||||
--but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
--GNU Lesser General Public License for more details.
|
||||
--
|
||||
--You should have received a copy of the GNU Lesser General Public License along
|
||||
--with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
|
||||
local shadow_levels_labels = {
|
||||
fgettext("Disabled"),
|
||||
fgettext("Very Low"),
|
||||
fgettext("Low"),
|
||||
fgettext("Medium"),
|
||||
fgettext("High"),
|
||||
fgettext("Very High"),
|
||||
fgettext("Custom"),
|
||||
}
|
||||
local PRESET_DISABLED = 1
|
||||
local PRESET_CUSTOM = #shadow_levels_labels
|
||||
|
||||
|
||||
-- max distance, texture size, texture_32bit, filters, map color
|
||||
local shadow_presets = {
|
||||
[2] = { 62, 512, true, 0, false },
|
||||
[3] = { 93, 1024, true, 0, false },
|
||||
[4] = { 140, 2048, true, 1, false },
|
||||
[5] = { 210, 4096, true, 2, true },
|
||||
[6] = { 300, 8192, true, 2, true },
|
||||
}
|
||||
|
||||
|
||||
local function detect_mapping_idx()
|
||||
if not core.settings:get_bool("enable_dynamic_shadows", false) then
|
||||
return PRESET_DISABLED
|
||||
end
|
||||
|
||||
local shadow_map_max_distance = tonumber(core.settings:get("shadow_map_max_distance"))
|
||||
local shadow_map_texture_size = tonumber(core.settings:get("shadow_map_texture_size"))
|
||||
local shadow_map_texture_32bit = core.settings:get_bool("shadow_map_texture_32bit", false)
|
||||
local shadow_filters = tonumber(core.settings:get("shadow_filters"))
|
||||
local shadow_map_color = core.settings:get_bool("shadow_map_color", false)
|
||||
|
||||
for i = 2, 6 do
|
||||
local preset = shadow_presets[i]
|
||||
if preset[1] == shadow_map_max_distance and
|
||||
preset[2] == shadow_map_texture_size and
|
||||
preset[3] == shadow_map_texture_32bit and
|
||||
preset[4] == shadow_filters and
|
||||
preset[5] == shadow_map_color then
|
||||
return i
|
||||
end
|
||||
end
|
||||
return PRESET_CUSTOM
|
||||
end
|
||||
|
||||
|
||||
local function apply_preset(preset)
|
||||
if preset then
|
||||
core.settings:set_bool("enable_dynamic_shadows", true)
|
||||
core.settings:set("shadow_map_max_distance", preset[1])
|
||||
core.settings:set("shadow_map_texture_size", preset[2])
|
||||
core.settings:set_bool("shadow_map_texture_32bit", preset[3])
|
||||
core.settings:set("shadow_filters", preset[4])
|
||||
core.settings:set_bool("shadow_map_color", preset[5])
|
||||
else
|
||||
core.settings:set_bool("enable_dynamic_shadows", false)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return {
|
||||
query_text = "Shadows",
|
||||
requires = {
|
||||
shaders = true,
|
||||
opengl = true,
|
||||
},
|
||||
get_formspec = function(self, avail_w)
|
||||
local labels = table.copy(shadow_levels_labels)
|
||||
local idx = detect_mapping_idx()
|
||||
|
||||
-- Remove "custom" if not already selected
|
||||
if idx ~= PRESET_CUSTOM then
|
||||
table.remove(labels, PRESET_CUSTOM)
|
||||
end
|
||||
|
||||
local fs =
|
||||
"label[0,0.2;" .. fgettext("Dynamic shadows") .. "]" ..
|
||||
"dropdown[0,0.4;3,0.8;dd_shadows;" .. table.concat(labels, ",") .. ";" .. idx .. ";true]" ..
|
||||
"label[0,1.5;" .. core.colorize("#bbb", fgettext("(The game will need to enable shadows as well)")) .. "]"
|
||||
return fs, 1.8
|
||||
end,
|
||||
on_submit = function(self, fields)
|
||||
if fields.dd_shadows then
|
||||
local old_shadow_level_idx = detect_mapping_idx()
|
||||
local shadow_level_idx = tonumber(fields.dd_shadows)
|
||||
if shadow_level_idx == nil or shadow_level_idx == old_shadow_level_idx then
|
||||
return false
|
||||
end
|
||||
|
||||
if shadow_level_idx == PRESET_CUSTOM then
|
||||
core.settings:set_bool("enable_dynamic_shadows", true)
|
||||
return true
|
||||
end
|
||||
|
||||
local preset = shadow_presets[shadow_level_idx]
|
||||
apply_preset(preset)
|
||||
return true
|
||||
end
|
||||
end,
|
||||
}
|
@ -430,7 +430,7 @@ enable_dynamic_shadows (Dynamic shadows) bool false
|
||||
shadow_strength_gamma (Shadow strength gamma) float 1.0 0.1 10.0
|
||||
|
||||
# Maximum distance to render shadows.
|
||||
shadow_map_max_distance (Shadow map max distance in nodes to render shadows) float 200.0 10.0 1000.0
|
||||
shadow_map_max_distance (Shadow map max distance in nodes to render shadows) float 140.0 10.0 1000.0
|
||||
|
||||
# Texture size to render the shadow map on.
|
||||
# This must be a power of two.
|
||||
|
@ -433,7 +433,7 @@
|
||||
|
||||
# Maximum distance to render shadows.
|
||||
# type: float min: 10 max: 1000
|
||||
# shadow_map_max_distance = 200.0
|
||||
# shadow_map_max_distance = 140.0
|
||||
|
||||
# Texture size to render the shadow map on.
|
||||
# This must be a power of two.
|
||||
|
@ -274,7 +274,7 @@ void set_default_settings()
|
||||
// Effects Shadows
|
||||
settings->setDefault("enable_dynamic_shadows", "false");
|
||||
settings->setDefault("shadow_strength_gamma", "1.0");
|
||||
settings->setDefault("shadow_map_max_distance", "200.0");
|
||||
settings->setDefault("shadow_map_max_distance", "140.0");
|
||||
settings->setDefault("shadow_map_texture_size", "2048");
|
||||
settings->setDefault("shadow_map_texture_32bit", "true");
|
||||
settings->setDefault("shadow_map_color", "false");
|
||||
|
Loading…
Reference in New Issue
Block a user