]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - builtin/mainmenu/dlg_settings_advanced.lua
Builtin: Translatable join, leave, profiler msgs (#11064)
[dragonfireclient.git] / builtin / mainmenu / dlg_settings_advanced.lua
index 67e8c9ede87284ad411df2dc14324e053c9d8787..c16e4aad00c8a5839191728a87c2014e5ed42b1f 100644 (file)
@@ -639,12 +639,23 @@ local function create_change_setting_formspec(dialogdata)
                -- Flags
                formspec = table.concat(fields)
                                .. "checkbox[0.5," .. height - 0.6 .. ";cb_defaults;"
+                               --[[~ "defaults" is a noise parameter flag.
+                               It describes the default processing options
+                               for noise settings in main menu -> "All Settings". ]]
                                .. fgettext("defaults") .. ";" -- defaults
                                .. tostring(flags["defaults"] == true) .. "]" -- to get false if nil
                                .. "checkbox[5," .. height - 0.6 .. ";cb_eased;"
+                               --[[~ "eased" is a noise parameter flag.
+                               It is used to make the map smoother and
+                               can be enabled in noise settings in
+                               main menu -> "All Settings". ]]
                                .. fgettext("eased") .. ";" -- eased
                                .. tostring(flags["eased"] == true) .. "]"
                                .. "checkbox[5," .. height - 0.15 .. ";cb_absvalue;"
+                               --[[~ "absvalue" is a noise parameter flag.
+                               It is short for "absolute value".
+                               It can be enabled in noise settings in
+                               main menu -> "All Settings". ]]
                                .. fgettext("absvalue") .. ";" -- absvalue
                                .. tostring(flags["absvalue"] == true) .. "]"
                height = height + 1
@@ -670,34 +681,42 @@ local function create_change_setting_formspec(dialogdata)
                height = height + 1.1
 
        elseif setting.type == "flags" then
-               local enabled_flags = flags_to_table(get_current_value(setting))
+               local current_flags = flags_to_table(get_current_value(setting))
                local flags = {}
-               for _, name in ipairs(enabled_flags) do
+               for _, name in ipairs(current_flags) do
                        -- Index by name, to avoid iterating over all enabled_flags for every possible flag.
-                       flags[name] = true
+                       if name:sub(1, 2) == "no" then
+                               flags[name:sub(3)] = false
+                       else
+                               flags[name] = true
+                       end
                end
-               local flags_count = #setting.possible
-               local max_height = flags_count / 4
+               local flags_count = #setting.possible / 2
+               local max_height = math.ceil(flags_count / 2) / 2
 
                -- More space for flags
                description_height = description_height - 1
                height = height - 1
 
                local fields = {} -- To build formspec
-               for i, name in ipairs(setting.possible) do
-                       local x = 0.5
-                       local y = height + i / 2 - 0.75
-                       if i - 1 >= flags_count / 2 then -- 2nd column
-                               x = 5
-                               y = y - max_height
+               local j = 1
+               for _, name in ipairs(setting.possible) do
+                       if name:sub(1, 2) ~= "no" then
+                               local x = 0.5
+                               local y = height + j / 2 - 0.75
+                               if j - 1 >= flags_count / 2 then -- 2nd column
+                                       x = 5
+                                       y = y - max_height
+                               end
+                               j = j + 1;
+                               local checkbox_name = "cb_" .. name
+                               local is_enabled = flags[name] == true -- to get false if nil
+                               checkboxes[checkbox_name] = is_enabled
+
+                               fields[#fields + 1] = ("checkbox[%f,%f;%s;%s;%s]"):format(
+                                       x, y, checkbox_name, name, tostring(is_enabled)
+                               )
                        end
-                       local checkbox_name = "cb_" .. name
-                       local is_enabled = flags[name] == true -- to get false if nil
-                       checkboxes[checkbox_name] = is_enabled
-
-                       fields[#fields + 1] = ("checkbox[%f,%f;%s;%s;%s]"):format(
-                               x, y, checkbox_name, name, tostring(is_enabled)
-                       )
                end
                formspec = table.concat(fields)
                height = height + max_height + 0.25
@@ -833,8 +852,12 @@ local function handle_change_setting_buttons(this, fields)
                elseif setting.type == "flags" then
                        local values = {}
                        for _, name in ipairs(setting.possible) do
-                               if checkboxes["cb_" .. name] then
-                                       table.insert(values, name)
+                               if name:sub(1, 2) ~= "no" then
+                                       if checkboxes["cb_" .. name] then
+                                               table.insert(values, name)
+                                       else
+                                               table.insert(values, "no" .. name)
+                                       end
                                end
                        end