ACE_Settings: added function to add settings at runtime

This commit is contained in:
Nicolás Badano 2015-02-03 02:37:38 -03:00
parent 658f30b9a2
commit 051ad00806
2 changed files with 41 additions and 0 deletions

View File

@ -11,6 +11,7 @@ PREP(addCustomEventHandler);
PREP(addLineToDebugDraw);
PREP(addMapMarkerCreatedEventHandler);
PREP(addScrollWheelEventHandler);
PREP(addSetting);
PREP(adminKick);
PREP(ambientBrightness);
PREP(applyForceWalkStatus);

View 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);