Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Settings GUI: Noise parameter setting fixes #13797

Merged
merged 5 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions builtin/mainmenu/settings/components.lua
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,12 @@ local function noise_params(setting)
setting = setting,

get_formspec = function(self, avail_w)
-- The "defaults" noise parameter flag doesn't reset a noise
sfan5 marked this conversation as resolved.
Show resolved Hide resolved
-- setting to its default value, so we offer a regular reset button.
-- I'm not sure what the actual purpose of the "defaults" noise
-- parameter flag is.
self.resettable = core.settings:has(setting.name)

local fs = "label[0,0.4;" .. get_label(setting) .. "]" ..
("button[%f,0;2.5,0.8;%s;%s]"):format(avail_w - 2.5, "edit_" .. setting.name, fgettext("Edit"))
return fs, 0.8
Expand Down
23 changes: 13 additions & 10 deletions builtin/mainmenu/settings/dlg_change_mapgen_flags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,15 @@ local function get_formspec(dialogdata)
-- Final formspec will be created at the end of this function
-- Default values below, may be changed depending on setting type
local width = 10
local height = 3.5
local description_height = 3
local height = 2
local description_height = 1.5

local t = get_current_np_group(setting)
local dimension = 3
if setting.type == "noise_params_2d" then
dimension = 2
end

-- More space for 3x3 fields
description_height = description_height - 1.5
height = height - 1.5

local fields = {}
local function add_field(x, name, label, value)
fields[#fields + 1] = ("field[%f,%f;3.3,1;%s;%s;%s]"):format(
Expand Down Expand Up @@ -109,21 +105,21 @@ local function get_formspec(dialogdata)
.. "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". ]]
for noise settings in the settings menu. ]]
.. 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". ]]
the settings menu. ]]
.. 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". ]]
the settings menu. ]]
.. fgettext("absvalue") .. ";" -- absvalue
.. tostring(flags["absvalue"] == true) .. "]"

Expand Down Expand Up @@ -204,7 +200,7 @@ local function buttonhandler(this, fields)
checkboxes = {}

if setting.type == "noise_params_2d" then
fields["te_spready"] = fields["te_spreadz"]
fields["te_spready"] = fields["te_spreadz"]
end
local new_value = {
offset = fields["te_offset"],
Expand Down Expand Up @@ -232,6 +228,13 @@ local function buttonhandler(this, fields)
return true
end

for name, value in pairs(fields) do
if name:sub(1, 3) == "cb_" then
checkboxes[name] = value == "true"
grorp marked this conversation as resolved.
Show resolved Hide resolved
return false -- Don't update the formspec!
end
end

return false
end

Expand Down
2 changes: 1 addition & 1 deletion builtin/mainmenu/settings/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ dofile(path .. DIR_DELIM .. "dlg_settings.lua")
-- For RUN_IN_PLACE the generated files may appear in the 'bin' folder.
-- See comment and alternative line at the end of 'generate_from_settingtypes.lua'.

--assert(loadfile(path .. DIR_DELIM .. "generate_from_settingtypes.lua"))(parse_config_file(true, false))
-- assert(loadfile(path .. DIR_DELIM .. "generate_from_settingtypes.lua"))(settingtypes.parse_config_file(true, false))
1 change: 0 additions & 1 deletion builtin/mainmenu/settings/settingtypes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ local function parse_setting_line(settings, line, read_all, base_level, allow_se
local flags = ""
if index then
flags = default:sub(index)
default = default:sub(1, index - 3) -- Make sure no flags in single-line format
end
table.insert(values, flags)

Expand Down