'All Settings': Don't use checkboxes for 'no...' mapgen flags (#7847)

This commit is contained in:
Muhammad Rifqi Priyo Susanto 2019-09-02 04:43:41 +07:00 committed by Paramat
parent 0013f064ad
commit cd1d01b8b4
3 changed files with 31 additions and 21 deletions

View File

@ -670,14 +670,18 @@ local function create_change_setting_formspec(dialogdata)
height = height + 1.1 height = height + 1.1
elseif setting.type == "flags" then 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 = {} 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. -- 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 end
local flags_count = #setting.possible local flags_count = #setting.possible / 2
local max_height = flags_count / 4 local max_height = math.ceil(flags_count / 2) / 2
-- More space for flags -- More space for flags
description_height = description_height - 1 description_height = description_height - 1
@ -685,19 +689,21 @@ local function create_change_setting_formspec(dialogdata)
local fields = {} -- To build formspec local fields = {} -- To build formspec
for i, name in ipairs(setting.possible) do for i, name in ipairs(setting.possible) do
local x = 0.5 if name:sub(1, 2) ~= "no" then
local y = height + i / 2 - 0.75 local x = 0.5
if i - 1 >= flags_count / 2 then -- 2nd column local y = height + i / 2 - 0.75
x = 5 if i - 1 >= flags_count / 2 then -- 2nd column
y = y - max_height x = 5
end y = y - max_height
local checkbox_name = "cb_" .. name end
local is_enabled = flags[name] == true -- to get false if nil local checkbox_name = "cb_" .. name
checkboxes[checkbox_name] = is_enabled 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( fields[#fields + 1] = ("checkbox[%f,%f;%s;%s;%s]"):format(
x, y, checkbox_name, name, tostring(is_enabled) x, y, checkbox_name, name, tostring(is_enabled)
) )
end
end end
formspec = table.concat(fields) formspec = table.concat(fields)
height = height + max_height + 0.25 height = height + max_height + 0.25
@ -833,8 +839,12 @@ local function handle_change_setting_buttons(this, fields)
elseif setting.type == "flags" then elseif setting.type == "flags" then
local values = {} local values = {}
for _, name in ipairs(setting.possible) do for _, name in ipairs(setting.possible) do
if checkboxes["cb_" .. name] then if name:sub(1, 2) ~= "no" then
table.insert(values, name) if checkboxes["cb_" .. name] then
table.insert(values, name)
else
table.insert(values, "no" .. name)
end
end end
end end

View File

@ -1887,7 +1887,7 @@ mgfractal_np_dungeons (Dungeon noise) noise_params_3d 0.9, 0.5, (500, 500, 500),
# 'vary_river_depth': If enabled, low humidity and high heat causes rivers # 'vary_river_depth': If enabled, low humidity and high heat causes rivers
# to become shallower and occasionally dry. # to become shallower and occasionally dry.
# 'altitude_dry': Reduces humidity with altitude. # 'altitude_dry': Reduces humidity with altitude.
mgvalleys_spflags (Mapgen Valleys specific flags) flags altitude_chill,humid_rivers,vary_river_depth,altitude_dry altitude_chill,noaltitude_chill,humid_rivers,nohumid_rivers,vary_river_depth,novary_river_depth,altitude_dry,noaltitude_dry mgvalleys_spflags (Mapgen Valleys specific flags) flags altitude_chill,humid_rivers,vary_river_depth,altitude_dry altitude_chill,humid_rivers,vary_river_depth,altitude_dry,noaltitude_chill,nohumid_rivers,novary_river_depth,noaltitude_dry
# The vertical distance over which heat drops by 20 if 'altitude_chill' is # The vertical distance over which heat drops by 20 if 'altitude_chill' is
# enabled. Also the vertical distance over which humidity drops by 10 if # enabled. Also the vertical distance over which humidity drops by 10 if

View File

@ -417,7 +417,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("water_level", "1"); settings->setDefault("water_level", "1");
settings->setDefault("mapgen_limit", "31000"); settings->setDefault("mapgen_limit", "31000");
settings->setDefault("chunksize", "5"); settings->setDefault("chunksize", "5");
settings->setDefault("mg_flags", "dungeons"); settings->setDefault("mg_flags", "caves,dungeons,light,decorations,biomes");
settings->setDefault("fixed_map_seed", ""); settings->setDefault("fixed_map_seed", "");
settings->setDefault("max_block_generate_distance", "8"); settings->setDefault("max_block_generate_distance", "8");
settings->setDefault("projecting_dungeons", "true"); settings->setDefault("projecting_dungeons", "true");