mirror of
				https://github.com/luanti-org/luanti.git
				synced 2025-11-04 09:15:29 +01:00 
			
		
		
		
	Settings GUI: Noise parameter setting fixes (#13797)
This commit is contained in:
		@@ -368,6 +368,10 @@ local function noise_params(setting)
 | 
			
		||||
		setting = setting,
 | 
			
		||||
 | 
			
		||||
		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) .. "]" ..
 | 
			
		||||
					("button[%f,0;2.5,0.8;%s;%s]"):format(avail_w - 2.5, "edit_" .. setting.name, fgettext("Edit"))
 | 
			
		||||
			return fs, 0.8
 | 
			
		||||
 
 | 
			
		||||
@@ -49,8 +49,8 @@ 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
 | 
			
		||||
@@ -58,10 +58,6 @@ local function get_formspec(dialogdata)
 | 
			
		||||
		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(
 | 
			
		||||
@@ -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) .. "]"
 | 
			
		||||
 | 
			
		||||
@@ -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"],
 | 
			
		||||
@@ -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] = core.is_yes(value)
 | 
			
		||||
			return false -- Don't update the formspec!
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
 | 
			
		||||
	return false
 | 
			
		||||
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.
 | 
			
		||||
-- 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 = ""
 | 
			
		||||
		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)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user