Skip to content

Commit 74d8fdb

Browse files
mark7est31
authored andcommittedJul 18, 2015
Add antialiasing UI setting
The Irrlicht engine supports antialiasing, and Minetest already supports saving an antialiasing setting in its configuration file. However, Minetest lacked UI elements to set this setting, and previously the only way to enable the feature was by hand-editing the configuration file. Add a drop-down menu that can enable antialiasing.
1 parent c5c609c commit 74d8fdb

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed
 

Diff for: ‎builtin/mainmenu/tab_settings.lua

+41-2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,19 @@ local function getLeavesStyleSettingIndex()
6060
return 1
6161
end
6262

63+
local dd_antialiasing_labels = {
64+
fgettext("None"),
65+
fgettext("2x"),
66+
fgettext("4x"),
67+
fgettext("8x"),
68+
}
69+
70+
local antialiasing = {
71+
{dd_antialiasing_labels[1]..","..dd_antialiasing_labels[2]..","..
72+
dd_antialiasing_labels[3]..","..dd_antialiasing_labels[4]},
73+
{"0", "2", "4", "8"}
74+
}
75+
6376
local function getFilterSettingIndex()
6477
if (core.setting_get(filters[2][3]) == "true") then
6578
return 3
@@ -80,6 +93,26 @@ local function getMipmapSettingIndex()
8093
return 1
8194
end
8295

96+
local function getAntialiasingSettingIndex()
97+
local antialiasing_setting = core.setting_get("fsaa")
98+
for i=1, #(antialiasing[2]) do
99+
if antialiasing_setting == antialiasing[2][i] then
100+
return i
101+
end
102+
end
103+
return 1
104+
end
105+
106+
local function antialiasing_fname_to_name(fname)
107+
for i=1, #(dd_antialiasing_labels) do
108+
if fname == dd_antialiasing_labels[i] then
109+
return antialiasing[2][i]
110+
end
111+
end
112+
113+
return "0"
114+
end
115+
83116
local function video_driver_fname_to_name(selected_driver)
84117
local video_drivers = core.get_video_drivers()
85118

@@ -214,13 +247,17 @@ local function formspec(tabview, name, tabdata)
214247
"dropdown[0.25,3.2;3.3;dd_leaves_style;" .. leaves_style[1][1] .. ";"
215248
.. getLeavesStyleSettingIndex() .. "]" ..
216249
"box[3.75,0;3.75,3.45;#999999]" ..
250+
"box[3.75,0;3.75,4.7;#999999]" ..
217251
"label[3.85,0.1;".. fgettext("Texturing:") .. "]"..
218252
"dropdown[3.85,0.55;3.85;dd_filters;" .. filters[1][1] .. ";"
219253
.. getFilterSettingIndex() .. "]" ..
220254
"dropdown[3.85,1.35;3.85;dd_mipmap;" .. mipmap[1][1] .. ";"
221255
.. getMipmapSettingIndex() .. "]" ..
222-
"label[3.85,2.15;".. fgettext("Rendering:") .. "]"..
223-
"dropdown[3.85,2.6;3.85;dd_video_driver;"
256+
"label[3.85,2.15;".. fgettext("Antialiasing:") .. "]"..
257+
"dropdown[3.85,2.6;3.85;dd_antialiasing;" .. antialiasing[1][1] .. ";"
258+
.. getAntialiasingSettingIndex() .. "]" ..
259+
"label[3.85,3.4;".. fgettext("Rendering:") .. "]"..
260+
"dropdown[3.85,3.85;3.85;dd_video_driver;"
224261
.. driver_formspec_string .. ";" .. driver_current_idx .. "]" ..
225262
"tooltip[dd_video_driver;" ..
226263
fgettext("Restart minetest for driver change to take effect") .. "]" ..
@@ -421,6 +458,8 @@ local function handle_settings_buttons(this, fields, tabname, tabdata)
421458
core.setting_set("anisotropic_filter", "true")
422459
ddhandled = true
423460
end
461+
core.setting_set("fsaa",
462+
antialiasing_fname_to_name(fields["dd_antialiasing"]))
424463

425464
return ddhandled
426465
end

0 commit comments

Comments
 (0)
Please sign in to comment.