2 --Copyright (C) 2013 sapier
4 --This program is free software; you can redistribute it and/or modify
5 --it under the terms of the GNU Lesser General Public License as published by
6 --the Free Software Foundation; either version 2.1 of the License, or
7 --(at your option) any later version.
9 --This program is distributed in the hope that it will be useful,
10 --but WITHOUT ANY WARRANTY; without even the implied warranty of
11 --MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 --GNU Lesser General Public License for more details.
14 --You should have received a copy of the GNU Lesser General Public License along
15 --with this program; if not, write to the Free Software Foundation, Inc.,
16 --51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 --------------------------------------------------------------------------------
20 local function dlg_confirm_reset_formspec(data)
23 "label[1,1;".. fgettext("Are you sure to reset your singleplayer world?") .. "]"..
24 "button[1,2;2.6,0.5;dlg_reset_singleplayer_confirm;"..
25 fgettext("Yes") .. "]" ..
26 "button[4,2;2.8,0.5;dlg_reset_singleplayer_cancel;"..
27 fgettext("No!!!") .. "]"
31 local function dlg_confirm_reset_btnhandler(this, fields, dialogdata)
33 if fields["dlg_reset_singleplayer_confirm"] ~= nil then
35 local worldlist = core.get_worlds()
36 local found_singleplayerworld = false
38 for i=1,#worldlist,1 do
39 if worldlist[i].name == "singleplayerworld" then
40 found_singleplayerworld = true
41 gamedata.worldindex = i
45 if found_singleplayerworld then
46 core.delete_world(gamedata.worldindex)
49 core.create_world("singleplayerworld", 1)
51 worldlist = core.get_worlds()
53 found_singleplayerworld = false
55 for i=1,#worldlist,1 do
56 if worldlist[i].name == "singleplayerworld" then
57 found_singleplayerworld = true
58 gamedata.worldindex = i
68 local function showconfirm_reset(tabview)
69 local new_dlg = dialog_create("reset_spworld",
70 dlg_confirm_reset_formspec,
71 dlg_confirm_reset_btnhandler,
80 local function formspec(tabview, name, tabdata)
82 "vertlabel[0,0;" .. fgettext("SETTINGS") .. "]" ..
83 "box[0.75,0;3.25,4;#999999]" ..
84 "checkbox[1,0;cb_fancy_trees;".. fgettext("Fancy Trees") .. ";"
85 .. dump(core.setting_getbool("new_style_leaves")) .. "]"..
86 "checkbox[1,0.5;cb_smooth_lighting;".. fgettext("Smooth Lighting")
87 .. ";".. dump(core.setting_getbool("smooth_lighting")) .. "]"..
88 "checkbox[1,1;cb_3d_clouds;".. fgettext("3D Clouds") .. ";"
89 .. dump(core.setting_getbool("enable_3d_clouds")) .. "]"..
90 "checkbox[1,1.5;cb_opaque_water;".. fgettext("Opaque Water") .. ";"
91 .. dump(core.setting_getbool("opaque_water")) .. "]"..
92 "checkbox[1,2.0;cb_pre_ivis;".. fgettext("Preload item visuals") .. ";"
93 .. dump(core.setting_getbool("preload_item_visuals")) .. "]"..
94 "checkbox[1,2.5;cb_particles;".. fgettext("Enable Particles") .. ";"
95 .. dump(core.setting_getbool("enable_particles")) .. "]"..
96 "checkbox[1,3.0;cb_finite_liquid;".. fgettext("Finite Liquid") .. ";"
97 .. dump(core.setting_getbool("liquid_finite")) .. "]"..
98 "box[4.25,0;3.25,2.5;#999999]" ..
99 "checkbox[4.5,0;cb_mipmapping;".. fgettext("Mip-Mapping") .. ";"
100 .. dump(core.setting_getbool("mip_map")) .. "]"..
101 "checkbox[4.5,0.5;cb_anisotrophic;".. fgettext("Anisotropic Filtering") .. ";"
102 .. dump(core.setting_getbool("anisotropic_filter")) .. "]"..
103 "checkbox[4.5,1.0;cb_bilinear;".. fgettext("Bi-Linear Filtering") .. ";"
104 .. dump(core.setting_getbool("bilinear_filter")) .. "]"..
105 "checkbox[4.5,1.5;cb_trilinear;".. fgettext("Tri-Linear Filtering") .. ";"
106 .. dump(core.setting_getbool("trilinear_filter")) .. "]"..
107 "box[7.75,0;4,3.5;#999999]" ..
108 "checkbox[8,0;cb_shaders;".. fgettext("Shaders") .. ";"
109 .. dump(core.setting_getbool("enable_shaders")) .. "]"..
110 "button[1,4.5;2.25,0.5;btn_change_keys;".. fgettext("Change keys") .. "]"
112 local android = false
114 tab_string = tab_string ..
115 "box[4.25,2.75;3.25,2.5;#999999]" ..
116 "checkbox[4.5,2.75;cb_touchscreen_target;".. fgettext("Touch free target") .. ";"
117 .. dump(core.setting_getbool("touchtarget")) .. "]" ..
118 "button[8,4.5;3.75,0.5;btn_reset_singleplayer;".. fgettext("Reset singleplayer world") .. "]"
121 if core.setting_get("touchscreen_threshold") ~= nil then
122 tab_string = tab_string ..
123 "label[4.5,3.5;" .. fgettext("Touchthreshold (px)") .. "]" ..
124 "dropdown[4.5,4;3;dd_touchthreshold;0,10,20,30,40,50;" ..
125 ((tonumber(core.setting_get("touchscreen_threshold"))/10)+1) .. "]"
128 if core.setting_getbool("enable_shaders") then
129 tab_string = tab_string ..
130 "checkbox[8,0.5;cb_bumpmapping;".. fgettext("Bumpmapping") .. ";"
131 .. dump(core.setting_getbool("enable_bumpmapping")) .. "]"..
132 "checkbox[8,1.0;cb_parallax;".. fgettext("Parallax Occlusion") .. ";"
133 .. dump(core.setting_getbool("enable_parallax_occlusion")) .. "]"..
134 "checkbox[8,1.5;cb_waving_water;".. fgettext("Waving Water") .. ";"
135 .. dump(core.setting_getbool("enable_waving_water")) .. "]"..
136 "checkbox[8,2.0;cb_waving_leaves;".. fgettext("Waving Leaves") .. ";"
137 .. dump(core.setting_getbool("enable_waving_leaves")) .. "]"..
138 "checkbox[8,2.5;cb_waving_plants;".. fgettext("Waving Plants") .. ";"
139 .. dump(core.setting_getbool("enable_waving_plants")) .. "]"
141 tab_string = tab_string ..
142 "textlist[8.33,0.7;3,1;;#888888" .. fgettext("Bumpmapping") .. ";0;true]" ..
143 "textlist[8.33,1.2;3,1;;#888888" .. fgettext("Parallax Occlusion") .. ";0;true]" ..
144 "textlist[8.33,1.7;3,1;;#888888" .. fgettext("Waving Water") .. ";0;true]" ..
145 "textlist[8.33,2.2;3,1;;#888888" .. fgettext("Waving Leaves") .. ";0;true]" ..
146 "textlist[8.33,2.7;3,1;;#888888" .. fgettext("Waving Plants") .. ";0;true]"
151 --------------------------------------------------------------------------------
152 local function handle_settings_buttons(this, fields, tabname, tabdata)
153 if fields["cb_fancy_trees"] then
154 core.setting_set("new_style_leaves", fields["cb_fancy_trees"])
157 if fields["cb_smooth_lighting"] then
158 core.setting_set("smooth_lighting", fields["cb_smooth_lighting"])
161 if fields["cb_3d_clouds"] then
162 core.setting_set("enable_3d_clouds", fields["cb_3d_clouds"])
165 if fields["cb_opaque_water"] then
166 core.setting_set("opaque_water", fields["cb_opaque_water"])
169 if fields["cb_mipmapping"] then
170 core.setting_set("mip_map", fields["cb_mipmapping"])
173 if fields["cb_anisotrophic"] then
174 core.setting_set("anisotropic_filter", fields["cb_anisotrophic"])
177 if fields["cb_bilinear"] then
178 core.setting_set("bilinear_filter", fields["cb_bilinear"])
181 if fields["cb_trilinear"] then
182 core.setting_set("trilinear_filter", fields["cb_trilinear"])
185 if fields["cb_shaders"] then
186 if (core.setting_get("video_driver") == "direct3d8" or core.setting_get("video_driver") == "direct3d9") then
187 core.setting_set("enable_shaders", "false")
188 gamedata.errormessage = fgettext("To enable shaders the OpenGL driver needs to be used.")
190 core.setting_set("enable_shaders", fields["cb_shaders"])
194 if fields["cb_pre_ivis"] then
195 core.setting_set("preload_item_visuals", fields["cb_pre_ivis"])
198 if fields["cb_particles"] then
199 core.setting_set("enable_particles", fields["cb_particles"])
202 if fields["cb_finite_liquid"] then
203 core.setting_set("liquid_finite", fields["cb_finite_liquid"])
206 if fields["cb_bumpmapping"] then
207 core.setting_set("enable_bumpmapping", fields["cb_bumpmapping"])
209 if fields["cb_parallax"] then
210 core.setting_set("enable_parallax_occlusion", fields["cb_parallax"])
213 if fields["cb_waving_water"] then
214 core.setting_set("enable_waving_water", fields["cb_waving_water"])
217 if fields["cb_waving_leaves"] then
218 core.setting_set("enable_waving_leaves", fields["cb_waving_leaves"])
220 if fields["cb_waving_plants"] then
221 core.setting_set("enable_waving_plants", fields["cb_waving_plants"])
224 if fields["btn_change_keys"] ~= nil then
225 core.show_keys_menu()
228 if fields["cb_touchscreen_target"] then
229 core.setting_set("touchtarget", fields["cb_touchscreen_target"])
232 if fields["dd_touchthreshold"] then
233 core.setting_set("touchscreen_threshold",fields["dd_touchthreshold"])
236 if fields["btn_reset_singleplayer"] then
237 showconfirm_reset(this)
244 caption = fgettext("Settings"),
245 cbf_formspec = formspec,
246 cbf_button_handler = handle_settings_buttons