mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
ACE_Settings: added function to add settings at runtime
This commit is contained in:
parent
658f30b9a2
commit
051ad00806
@ -11,6 +11,7 @@ PREP(addCustomEventHandler);
|
||||
PREP(addLineToDebugDraw);
|
||||
PREP(addMapMarkerCreatedEventHandler);
|
||||
PREP(addScrollWheelEventHandler);
|
||||
PREP(addSetting);
|
||||
PREP(adminKick);
|
||||
PREP(ambientBrightness);
|
||||
PREP(applyForceWalkStatus);
|
||||
|
40
addons/common/functions/fnc_addSetting.sqf
Normal file
40
addons/common/functions/fnc_addSetting.sqf
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Author: CAA-Picard
|
||||
* Adds a new setting at runtime, with all it's metadata.
|
||||
* If has only local effects.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: _name (String)
|
||||
* 1: _typeName (String)
|
||||
* 2: _isClientSetable (Bool)
|
||||
* 3: _localizedName (String)
|
||||
* 4: _localizedDescription (String)
|
||||
* 5: _possibleValues (Array)
|
||||
* 6: _isForced (Bool)
|
||||
* 7: _defaultValue (Any)
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_8_PVT(_this,_name,_typeName,_isClientSetable,_localizedName,_localizedDescription,_possibleValues,_isForced,_value);
|
||||
|
||||
_settingData = [_name] call FUNC(getSettingData);
|
||||
|
||||
// Exit if the setting already exists
|
||||
if (count _settingData > 0) exitWith {};
|
||||
|
||||
// Update the variable
|
||||
TRACE_2("Setting added",_name,_value);
|
||||
|
||||
// Init the variable
|
||||
missionNamespace setVariable [_name, _value];
|
||||
|
||||
// Add the setting data
|
||||
GVAR(settings) pushBack _this;
|
||||
|
||||
// Raise event locally
|
||||
["SettingChanged", [_name, _value]] call FUNC(localEvent);
|
Loading…
Reference in New Issue
Block a user