X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=builtin%2Fmainmenu%2Ftab_settings.lua;h=ec2d7b1f55138150beaf8093e553b18204997c0b;hb=3978b9b8ed1c318c3f9a088beb331c26bca6de6b;hp=281dde3d0f8ce3c486595d0e2ac9000bcded4922;hpb=8ea86338ab01792f98f289a053c51f81869a8ddc;p=minetest.git diff --git a/builtin/mainmenu/tab_settings.lua b/builtin/mainmenu/tab_settings.lua index 281dde3d0..ec2d7b1f5 100644 --- a/builtin/mainmenu/tab_settings.lua +++ b/builtin/mainmenu/tab_settings.lua @@ -43,6 +43,14 @@ local labels = { fgettext("2x"), fgettext("4x"), fgettext("8x") + }, + shadow_levels = { + fgettext("Disabled"), + fgettext("Very Low"), + fgettext("Low"), + fgettext("Medium"), + fgettext("High"), + fgettext("Very High") } } @@ -66,6 +74,10 @@ local dd_options = { antialiasing = { table.concat(labels.antialiasing, ","), {"0", "2", "4", "8"} + }, + shadow_levels = { + table.concat(labels.shadow_levels, ","), + { "0", "1", "2", "3", "4", "5" } } } @@ -110,6 +122,15 @@ local getSettingIndex = { end end return 1 + end, + ShadowMapping = function() + local shadow_setting = core.settings:get("shadow_levels") + for i = 1, #dd_options.shadow_levels[2] do + if shadow_setting == dd_options.shadow_levels[2][i] then + return i + end + end + return 1 end } @@ -122,58 +143,6 @@ local function antialiasing_fname_to_name(fname) return 0 end -local function dlg_confirm_reset_formspec(data) - return "size[8,3]" .. - "label[1,1;" .. fgettext("Are you sure to reset your singleplayer world?") .. "]" .. - "button[1,2;2.6,0.5;dlg_reset_singleplayer_confirm;" .. fgettext("Yes") .. "]" .. - "button[4,2;2.8,0.5;dlg_reset_singleplayer_cancel;" .. fgettext("No") .. "]" -end - -local function dlg_confirm_reset_btnhandler(this, fields, dialogdata) - - if fields["dlg_reset_singleplayer_confirm"] ~= nil then - local worldlist = core.get_worlds() - local found_singleplayerworld = false - - for i = 1, #worldlist do - if worldlist[i].name == "singleplayerworld" then - found_singleplayerworld = true - gamedata.worldindex = i - end - end - - if found_singleplayerworld then - core.delete_world(gamedata.worldindex) - end - - core.create_world("singleplayerworld", 1) - worldlist = core.get_worlds() - found_singleplayerworld = false - - for i = 1, #worldlist do - if worldlist[i].name == "singleplayerworld" then - found_singleplayerworld = true - gamedata.worldindex = i - end - end - end - - this.parent:show() - this:hide() - this:delete() - return true -end - -local function showconfirm_reset(tabview) - local new_dlg = dialog_create("reset_spworld", - dlg_confirm_reset_formspec, - dlg_confirm_reset_btnhandler, - nil) - new_dlg:set_parent(tabview) - tabview:hide() - new_dlg:show() -end - local function formspec(tabview, name, tabdata) local tab_string = "box[0,0;3.75,4.5;#999999]" .. @@ -191,7 +160,7 @@ local function formspec(tabview, name, tabdata) .. getSettingIndex.NodeHighlighting() .. "]" .. "dropdown[0.25,3.6;3.5;dd_leaves_style;" .. dd_options.leaves[1] .. ";" .. getSettingIndex.Leaves() .. "]" .. - "box[4,0;3.75,4.5;#999999]" .. + "box[4,0;3.75,4.9;#999999]" .. "label[4.25,0.1;" .. fgettext("Texturing:") .. "]" .. "dropdown[4.25,0.55;3.5;dd_filters;" .. dd_options.filters[1] .. ";" .. getSettingIndex.Filter() .. "]" .. @@ -200,67 +169,82 @@ local function formspec(tabview, name, tabdata) "label[4.25,2.15;" .. fgettext("Antialiasing:") .. "]" .. "dropdown[4.25,2.6;3.5;dd_antialiasing;" .. dd_options.antialiasing[1] .. ";" .. getSettingIndex.Antialiasing() .. "]" .. - "label[4.25,3.45;" .. fgettext("Screen:") .. "]" .. - "checkbox[4.25,3.6;cb_autosave_screensize;" .. fgettext("Autosave Screen Size") .. ";" - .. dump(core.settings:get_bool("autosave_screensize")) .. "]" .. - "box[8,0;3.75,4.5;#999999]" .. - "checkbox[8.25,0;cb_shaders;" .. fgettext("Shaders") .. ";" - .. dump(core.settings:get_bool("enable_shaders")) .. "]" + "box[8,0;3.75,4.5;#999999]" - if PLATFORM == "Android" then + local video_driver = core.settings:get("video_driver") + local shaders_enabled = core.settings:get_bool("enable_shaders") + if video_driver == "opengl" then + tab_string = tab_string .. + "checkbox[8.25,0;cb_shaders;" .. fgettext("Shaders") .. ";" + .. tostring(shaders_enabled) .. "]" + elseif video_driver == "ogles2" then tab_string = tab_string .. - "button[8,4.75;4.1,1;btn_reset_singleplayer;" - .. fgettext("Reset singleplayer world") .. "]" + "checkbox[8.25,0;cb_shaders;" .. fgettext("Shaders (experimental)") .. ";" + .. tostring(shaders_enabled) .. "]" else + core.settings:set_bool("enable_shaders", false) + shaders_enabled = false tab_string = tab_string .. - "button[8,4.75;4,1;btn_change_keys;" - .. fgettext("Change Keys") .. "]" + "label[8.38,0.2;" .. core.colorize("#888888", + fgettext("Shaders (unavailable)")) .. "]" end tab_string = tab_string .. - "button[0,4.75;4,1;btn_advanced_settings;" - .. fgettext("Advanced Settings") .. "]" + "button[8,4.75;3.95,1;btn_change_keys;" + .. fgettext("Change Keys") .. "]" + + tab_string = tab_string .. + "button[0,4.75;3.95,1;btn_advanced_settings;" + .. fgettext("All Settings") .. "]" if core.settings:get("touchscreen_threshold") ~= nil then tab_string = tab_string .. - "label[4.3,4.1;" .. fgettext("Touchthreshold (px)") .. "]" .. - "dropdown[3.85,4.55;3.85;dd_touchthreshold;0,10,20,30,40,50;" .. - ((tonumber(core.settings:get("touchscreen_threshold")) / 10) + 1) .. "]" + "label[4.25,3.5;" .. fgettext("Touch threshold (px):") .. "]" .. + "dropdown[4.25,3.95;3.5;dd_touchthreshold;0,10,20,30,40,50;" .. + ((tonumber(core.settings:get("touchscreen_threshold")) / 10) + 1) .. + "]" + else + tab_string = tab_string .. + "label[4.25,3.65;" .. fgettext("Screen:") .. "]" .. + "checkbox[4.25,3.9;cb_autosave_screensize;" .. fgettext("Autosave Screen Size") .. ";" + .. dump(core.settings:get_bool("autosave_screensize")) .. "]" end - if core.settings:get_bool("enable_shaders") then + if shaders_enabled then tab_string = tab_string .. - "checkbox[8.25,0.5;cb_bumpmapping;" .. fgettext("Bump Mapping") .. ";" - .. dump(core.settings:get_bool("enable_bumpmapping")) .. "]" .. - "checkbox[8.25,1;cb_tonemapping;" .. fgettext("Tone Mapping") .. ";" + "checkbox[8.25,0.5;cb_tonemapping;" .. fgettext("Tone Mapping") .. ";" .. dump(core.settings:get_bool("tone_mapping")) .. "]" .. - "checkbox[8.25,1.5;cb_generate_normalmaps;" .. fgettext("Normal Mapping") .. ";" - .. dump(core.settings:get_bool("generate_normalmaps")) .. "]" .. - "checkbox[8.25,2;cb_parallax;" .. fgettext("Parallax Occlusion") .. ";" - .. dump(core.settings:get_bool("enable_parallax_occlusion")) .. "]" .. - "checkbox[8.25,2.5;cb_waving_water;" .. fgettext("Waving Water") .. ";" + "checkbox[8.25,1;cb_waving_water;" .. fgettext("Waving Liquids") .. ";" .. dump(core.settings:get_bool("enable_waving_water")) .. "]" .. - "checkbox[8.25,3;cb_waving_leaves;" .. fgettext("Waving Leaves") .. ";" + "checkbox[8.25,1.5;cb_waving_leaves;" .. fgettext("Waving Leaves") .. ";" .. dump(core.settings:get_bool("enable_waving_leaves")) .. "]" .. - "checkbox[8.25,3.5;cb_waving_plants;" .. fgettext("Waving Plants") .. ";" + "checkbox[8.25,2;cb_waving_plants;" .. fgettext("Waving Plants") .. ";" .. dump(core.settings:get_bool("enable_waving_plants")) .. "]" + + if video_driver == "opengl" then + tab_string = tab_string .. + "label[8.25,2.8;" .. fgettext("Dynamic shadows:") .. "]" .. + "label[8.25,3.2;" .. fgettext("(game support required)") .. "]" .. + "dropdown[8.25,3.7;3.5;dd_shadows;" .. dd_options.shadow_levels[1] .. ";" + .. getSettingIndex.ShadowMapping() .. "]" + else + tab_string = tab_string .. + "label[8.38,2.7;" .. core.colorize("#888888", + fgettext("Dynamic shadows")) .. "]" + end else tab_string = tab_string .. "label[8.38,0.7;" .. core.colorize("#888888", - fgettext("Bump Mapping")) .. "]" .. - "label[8.38,1.2;" .. core.colorize("#888888", fgettext("Tone Mapping")) .. "]" .. + "label[8.38,1.2;" .. core.colorize("#888888", + fgettext("Waving Liquids")) .. "]" .. "label[8.38,1.7;" .. core.colorize("#888888", - fgettext("Normal Mapping")) .. "]" .. + fgettext("Waving Leaves")) .. "]" .. "label[8.38,2.2;" .. core.colorize("#888888", - fgettext("Parallax Occlusion")) .. "]" .. + fgettext("Waving Plants")) .. "]".. "label[8.38,2.7;" .. core.colorize("#888888", - fgettext("Waving Water")) .. "]" .. - "label[8.38,3.2;" .. core.colorize("#888888", - fgettext("Waving Leaves")) .. "]" .. - "label[8.38,3.7;" .. core.colorize("#888888", - fgettext("Waving Plants")) .. "]" + fgettext("Dynamic shadows")) .. "]" end return tab_string @@ -274,7 +258,7 @@ local function handle_settings_buttons(this, fields, tabname, tabdata) adv_settings_dlg:set_parent(this) this:hide() adv_settings_dlg:show() - --mm_texture.update("singleplayer", current_game()) + --mm_game_theme.update("singleplayer", current_game()) return true end if fields["cb_smooth_lighting"] then @@ -302,31 +286,13 @@ local function handle_settings_buttons(this, fields, tabname, tabdata) return true end if fields["cb_shaders"] then - if (core.settings:get("video_driver") == "direct3d8" or - core.settings:get("video_driver") == "direct3d9") then - core.settings:set("enable_shaders", "false") - gamedata.errormessage = fgettext("To enable shaders the OpenGL driver needs to be used.") - else - core.settings:set("enable_shaders", fields["cb_shaders"]) - end - return true - end - if fields["cb_bumpmapping"] then - core.settings:set("enable_bumpmapping", fields["cb_bumpmapping"]) + 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_generate_normalmaps"] then - core.settings:set("generate_normalmaps", fields["cb_generate_normalmaps"]) - return true - end - if fields["cb_parallax"] then - core.settings:set("enable_parallax_occlusion", fields["cb_parallax"]) - return true - end if fields["cb_waving_water"] then core.settings:set("enable_waving_water", fields["cb_waving_water"]) return true @@ -342,14 +308,6 @@ local function handle_settings_buttons(this, fields, tabname, tabdata) core.show_keys_menu() return true end - if fields["cb_touchscreen_target"] then - core.settings:set("touchtarget", fields["cb_touchscreen_target"]) - return true - end - if fields["btn_reset_singleplayer"] then - showconfirm_reset(this) - return true - end --Note dropdowns have to be handled LAST! local ddhandled = false @@ -402,6 +360,34 @@ local function handle_settings_buttons(this, fields, tabname, tabdata) ddhandled = true end + for i = 1, #labels.shadow_levels do + if fields["dd_shadows"] == labels.shadow_levels[i] then + core.settings:set("shadow_levels", dd_options.shadow_levels[2][i]) + ddhandled = true + end + end + + if fields["dd_shadows"] == labels.shadow_levels[1] then + core.settings:set("enable_dynamic_shadows", "false") + else + 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 s = shadow_presets[table.indexof(labels.shadow_levels, fields["dd_shadows"])] + if s then + core.settings:set("enable_dynamic_shadows", "true") + core.settings:set("shadow_map_max_distance", s[1]) + core.settings:set("shadow_map_texture_size", s[2]) + core.settings:set("shadow_map_texture_32bit", s[3]) + core.settings:set("shadow_filters", s[4]) + core.settings:set("shadow_map_color", s[5]) + end + end + return ddhandled end