Skip to content

Commit cd1d01b

Browse files
srifqiparamat
authored andcommittedSep 1, 2019
'All Settings': Don't use checkboxes for 'no...' mapgen flags (#7847)
1 parent 0013f06 commit cd1d01b

File tree

3 files changed

+31
-21
lines changed

3 files changed

+31
-21
lines changed
 

Diff for: ‎builtin/mainmenu/dlg_settings_advanced.lua

+29-19
Original file line numberDiff line numberDiff line change
@@ -670,34 +670,40 @@ local function create_change_setting_formspec(dialogdata)
670670
height = height + 1.1
671671

672672
elseif setting.type == "flags" then
673-
local enabled_flags = flags_to_table(get_current_value(setting))
673+
local current_flags = flags_to_table(get_current_value(setting))
674674
local flags = {}
675-
for _, name in ipairs(enabled_flags) do
675+
for _, name in ipairs(current_flags) do
676676
-- Index by name, to avoid iterating over all enabled_flags for every possible flag.
677-
flags[name] = true
677+
if name:sub(1, 2) == "no" then
678+
flags[name:sub(3)] = false
679+
else
680+
flags[name] = true
681+
end
678682
end
679-
local flags_count = #setting.possible
680-
local max_height = flags_count / 4
683+
local flags_count = #setting.possible / 2
684+
local max_height = math.ceil(flags_count / 2) / 2
681685

682686
-- More space for flags
683687
description_height = description_height - 1
684688
height = height - 1
685689

686690
local fields = {} -- To build formspec
687691
for i, name in ipairs(setting.possible) do
688-
local x = 0.5
689-
local y = height + i / 2 - 0.75
690-
if i - 1 >= flags_count / 2 then -- 2nd column
691-
x = 5
692-
y = y - max_height
693-
end
694-
local checkbox_name = "cb_" .. name
695-
local is_enabled = flags[name] == true -- to get false if nil
696-
checkboxes[checkbox_name] = is_enabled
692+
if name:sub(1, 2) ~= "no" then
693+
local x = 0.5
694+
local y = height + i / 2 - 0.75
695+
if i - 1 >= flags_count / 2 then -- 2nd column
696+
x = 5
697+
y = y - max_height
698+
end
699+
local checkbox_name = "cb_" .. name
700+
local is_enabled = flags[name] == true -- to get false if nil
701+
checkboxes[checkbox_name] = is_enabled
697702

698-
fields[#fields + 1] = ("checkbox[%f,%f;%s;%s;%s]"):format(
699-
x, y, checkbox_name, name, tostring(is_enabled)
700-
)
703+
fields[#fields + 1] = ("checkbox[%f,%f;%s;%s;%s]"):format(
704+
x, y, checkbox_name, name, tostring(is_enabled)
705+
)
706+
end
701707
end
702708
formspec = table.concat(fields)
703709
height = height + max_height + 0.25
@@ -833,8 +839,12 @@ local function handle_change_setting_buttons(this, fields)
833839
elseif setting.type == "flags" then
834840
local values = {}
835841
for _, name in ipairs(setting.possible) do
836-
if checkboxes["cb_" .. name] then
837-
table.insert(values, name)
842+
if name:sub(1, 2) ~= "no" then
843+
if checkboxes["cb_" .. name] then
844+
table.insert(values, name)
845+
else
846+
table.insert(values, "no" .. name)
847+
end
838848
end
839849
end
840850

Diff for: ‎builtin/settingtypes.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1887,7 +1887,7 @@ mgfractal_np_dungeons (Dungeon noise) noise_params_3d 0.9, 0.5, (500, 500, 500),
18871887
# 'vary_river_depth': If enabled, low humidity and high heat causes rivers
18881888
# to become shallower and occasionally dry.
18891889
# 'altitude_dry': Reduces humidity with altitude.
1890-
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
1890+
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
18911891

18921892
# The vertical distance over which heat drops by 20 if 'altitude_chill' is
18931893
# enabled. Also the vertical distance over which humidity drops by 10 if

Diff for: ‎src/defaultsettings.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ void set_default_settings(Settings *settings)
417417
settings->setDefault("water_level", "1");
418418
settings->setDefault("mapgen_limit", "31000");
419419
settings->setDefault("chunksize", "5");
420-
settings->setDefault("mg_flags", "dungeons");
420+
settings->setDefault("mg_flags", "caves,dungeons,light,decorations,biomes");
421421
settings->setDefault("fixed_map_seed", "");
422422
settings->setDefault("max_block_generate_distance", "8");
423423
settings->setDefault("projecting_dungeons", "true");

0 commit comments

Comments
 (0)
Please sign in to comment.