#include "..\script_component.hpp"

[
	QGVAR(emptyGroupCleanup_enable),
	"CHECKBOX",
	"Empty Group Cleanup Enabled",
	[QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)],
	true,
	true,
	{
		params ["_value"];
		[
			QGVAR(emptyGroupCleanup_enable),
			_value
		] call EFUNC(common,logSettingChanged);

		if (!isNull (missionNamespace getVariable [QGVAR(emptyGroupCleanupPFH), locationNull])) then {
			deleteLocation GVAR(emptyGroupCleanupPFH);
		};

		call FUNC(addEmptyGroupCleanupPFH);
	}
] call CBA_fnc_addSetting;

//---------------------
//	Server CPS
//---------------------

[
	QGVAR(server_cps_enable),
	"CHECKBOX",
	"Server CPS Metrics Enabled",
	[QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)],
	true,
	true,
	{
		params ["_value"];
		[
			QGVAR(cps_enable),
			_value
		] call EFUNC(common,logSettingChanged);
	}
] call CBA_fnc_addSetting;

[QGVAR(cps_enable), true] call CBA_settings_fnc_set;

[
	QGVAR(server_cps_interval),
	"TIME",
	"Server CPS Metrics Interval",
	[QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)],
	[60,300,120],
	true,
	{
		if (!isServer) exitWith {};
		
		params ["_value"];

		[
			QGVAR(cps_interval),
			_value
		] call EFUNC(common,logSettingChanged);
		
		_cpsPFH = missionNamespace getVariable [QGVAR(server_cps_handler), ObjNull];
		if (!isNull _cpsPFH) then {
			_cpsPFH call CBA_fnc_deletePerFrameHandlerObject;
		};

		[] call FUNC(addServerStatsPFH);
	}
] call CBA_fnc_addSetting;


//---------------------
//	Client CPS
//---------------------

[
	QGVAR(client_cps_enable),
	"CHECKBOX",
	"Client CPS Metrics Enabled",
	[QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)],
	true,
	true,
	{
		params ["_value"];
		[
			QGVAR(client_cps_enable),
			_value
		] call EFUNC(common,logSettingChanged);
	}
] call CBA_fnc_addSetting;

[QGVAR(client_cps_enable), true] call CBA_settings_fnc_set;

[
	QGVAR(client_cps_interval),
	"TIME",
	"Client CPS Metrics Interval",
	[QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)],
	[60,300,120],
	true,
	{
		if (!hasInterface) exitWith {};
		
		params ["_value"];

		[
			QGVAR(client_cps_interval),
			_value
		] call EFUNC(common,logSettingChanged);

		_cpsPFH = player getVariable [QGVAR(client_cps_handler), ObjNull];
		if (!isNull _cpsPFH) then {
			_cpsPFH call CBA_fnc_deletePerFrameHandlerObject;
		};

		[] call FUNC(addClientStatsPFH);
	}
] call CBA_fnc_addSetting;

[
	LEVEL_INFO,
	QUOTE(COMPONENT),
	"CREATED SETTINGS",
	[]
] call EFUNC(common,log);