forked from Mirrorlandia_minetest/minetest
Settings GUI: Noise parameter setting fixes (#13797)
This commit is contained in:
parent
8ebaf753d3
commit
4f735fba05
@ -368,6 +368,10 @@ local function noise_params(setting)
|
|||||||
setting = setting,
|
setting = setting,
|
||||||
|
|
||||||
get_formspec = function(self, avail_w)
|
get_formspec = function(self, avail_w)
|
||||||
|
-- The "defaults" noise parameter flag doesn't reset a noise
|
||||||
|
-- setting to its default value, so we offer a regular reset button.
|
||||||
|
self.resettable = core.settings:has(setting.name)
|
||||||
|
|
||||||
local fs = "label[0,0.4;" .. get_label(setting) .. "]" ..
|
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"))
|
("button[%f,0;2.5,0.8;%s;%s]"):format(avail_w - 2.5, "edit_" .. setting.name, fgettext("Edit"))
|
||||||
return fs, 0.8
|
return fs, 0.8
|
||||||
|
@ -49,8 +49,8 @@ local function get_formspec(dialogdata)
|
|||||||
-- Final formspec will be created at the end of this function
|
-- Final formspec will be created at the end of this function
|
||||||
-- Default values below, may be changed depending on setting type
|
-- Default values below, may be changed depending on setting type
|
||||||
local width = 10
|
local width = 10
|
||||||
local height = 3.5
|
local height = 2
|
||||||
local description_height = 3
|
local description_height = 1.5
|
||||||
|
|
||||||
local t = get_current_np_group(setting)
|
local t = get_current_np_group(setting)
|
||||||
local dimension = 3
|
local dimension = 3
|
||||||
@ -58,10 +58,6 @@ local function get_formspec(dialogdata)
|
|||||||
dimension = 2
|
dimension = 2
|
||||||
end
|
end
|
||||||
|
|
||||||
-- More space for 3x3 fields
|
|
||||||
description_height = description_height - 1.5
|
|
||||||
height = height - 1.5
|
|
||||||
|
|
||||||
local fields = {}
|
local fields = {}
|
||||||
local function add_field(x, name, label, value)
|
local function add_field(x, name, label, value)
|
||||||
fields[#fields + 1] = ("field[%f,%f;3.3,1;%s;%s;%s]"):format(
|
fields[#fields + 1] = ("field[%f,%f;3.3,1;%s;%s;%s]"):format(
|
||||||
@ -109,21 +105,21 @@ local function get_formspec(dialogdata)
|
|||||||
.. "checkbox[0.5," .. height - 0.6 .. ";cb_defaults;"
|
.. "checkbox[0.5," .. height - 0.6 .. ";cb_defaults;"
|
||||||
--[[~ "defaults" is a noise parameter flag.
|
--[[~ "defaults" is a noise parameter flag.
|
||||||
It describes the default processing options
|
It describes the default processing options
|
||||||
for noise settings in main menu -> "All Settings". ]]
|
for noise settings in the settings menu. ]]
|
||||||
.. fgettext("defaults") .. ";" -- defaults
|
.. fgettext("defaults") .. ";" -- defaults
|
||||||
.. tostring(flags["defaults"] == true) .. "]" -- to get false if nil
|
.. tostring(flags["defaults"] == true) .. "]" -- to get false if nil
|
||||||
.. "checkbox[5," .. height - 0.6 .. ";cb_eased;"
|
.. "checkbox[5," .. height - 0.6 .. ";cb_eased;"
|
||||||
--[[~ "eased" is a noise parameter flag.
|
--[[~ "eased" is a noise parameter flag.
|
||||||
It is used to make the map smoother and
|
It is used to make the map smoother and
|
||||||
can be enabled in noise settings in
|
can be enabled in noise settings in
|
||||||
main menu -> "All Settings". ]]
|
the settings menu. ]]
|
||||||
.. fgettext("eased") .. ";" -- eased
|
.. fgettext("eased") .. ";" -- eased
|
||||||
.. tostring(flags["eased"] == true) .. "]"
|
.. tostring(flags["eased"] == true) .. "]"
|
||||||
.. "checkbox[5," .. height - 0.15 .. ";cb_absvalue;"
|
.. "checkbox[5," .. height - 0.15 .. ";cb_absvalue;"
|
||||||
--[[~ "absvalue" is a noise parameter flag.
|
--[[~ "absvalue" is a noise parameter flag.
|
||||||
It is short for "absolute value".
|
It is short for "absolute value".
|
||||||
It can be enabled in noise settings in
|
It can be enabled in noise settings in
|
||||||
main menu -> "All Settings". ]]
|
the settings menu. ]]
|
||||||
.. fgettext("absvalue") .. ";" -- absvalue
|
.. fgettext("absvalue") .. ";" -- absvalue
|
||||||
.. tostring(flags["absvalue"] == true) .. "]"
|
.. tostring(flags["absvalue"] == true) .. "]"
|
||||||
|
|
||||||
@ -204,7 +200,7 @@ local function buttonhandler(this, fields)
|
|||||||
checkboxes = {}
|
checkboxes = {}
|
||||||
|
|
||||||
if setting.type == "noise_params_2d" then
|
if setting.type == "noise_params_2d" then
|
||||||
fields["te_spready"] = fields["te_spreadz"]
|
fields["te_spready"] = fields["te_spreadz"]
|
||||||
end
|
end
|
||||||
local new_value = {
|
local new_value = {
|
||||||
offset = fields["te_offset"],
|
offset = fields["te_offset"],
|
||||||
@ -232,6 +228,13 @@ local function buttonhandler(this, fields)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for name, value in pairs(fields) do
|
||||||
|
if name:sub(1, 3) == "cb_" then
|
||||||
|
checkboxes[name] = core.is_yes(value)
|
||||||
|
return false -- Don't update the formspec!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -25,4 +25,4 @@ dofile(path .. DIR_DELIM .. "dlg_settings.lua")
|
|||||||
-- For RUN_IN_PLACE the generated files may appear in the 'bin' folder.
|
-- 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'.
|
-- 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))
|
||||||
|
@ -198,7 +198,6 @@ local function parse_setting_line(settings, line, read_all, base_level, allow_se
|
|||||||
local flags = ""
|
local flags = ""
|
||||||
if index then
|
if index then
|
||||||
flags = default:sub(index)
|
flags = default:sub(index)
|
||||||
default = default:sub(1, index - 3) -- Make sure no flags in single-line format
|
|
||||||
end
|
end
|
||||||
table.insert(values, flags)
|
table.insert(values, flags)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user