mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Split cache and EH to functions
This commit is contained in:
@ -1,6 +1,8 @@
|
|||||||
PREP(addCustomTag);
|
PREP(addCustomTag);
|
||||||
PREP(addTagActions);
|
PREP(addTagActions);
|
||||||
|
PREP(applyCustomTag);
|
||||||
PREP(checkTaggable);
|
PREP(checkTaggable);
|
||||||
|
PREP(compileConfigTags);
|
||||||
PREP(createTag);
|
PREP(createTag);
|
||||||
PREP(tag);
|
PREP(tag);
|
||||||
PREP(tagRandom);
|
PREP(tagRandom);
|
||||||
|
@ -40,59 +40,11 @@ for "_index" from 0 to (_countOptions - 1) do {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (hasInterface) then {
|
if (hasInterface) then {
|
||||||
// Cache tags
|
// Compile and cache config tags
|
||||||
{
|
call FUNC(compileConfigTags);
|
||||||
private _failure = false;
|
|
||||||
private _class = configName _x;
|
|
||||||
|
|
||||||
private _displayName = getText (_x >> "displayName");
|
// Scripted tag adding EH
|
||||||
if (_displayName == "") then {
|
[QGVAR(applyCustomTag), FUNC(applyCustomTag)] call CBA_fnc_addEventHandler;
|
||||||
ACE_LOGERROR_1("Failed compiling ACE_Tags for tag: %1 - missing displayName",_class);
|
|
||||||
_failure = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
private _requiredItem = toLower (getText (_x >> "requiredItem"));
|
|
||||||
if (_requiredItem == "") then {
|
|
||||||
ACE_LOGERROR_1("Failed compiling ACE_Tags for tag: %1 - missing requiredItem",_class);
|
|
||||||
_failure = true;
|
|
||||||
} else {
|
|
||||||
if (!isClass (configFile >> "CfgWeapons" >> _requiredItem)) then {
|
|
||||||
ACE_LOGERROR_2("Failed compiling ACE_Tags for tag: %1 - requiredItem %2 does not exist",_class,_requiredItem);
|
|
||||||
_failure = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
private _textures = getArray (_x >> "textures");
|
|
||||||
if (_textures isEqualTo []) then {
|
|
||||||
ACE_LOGERROR_1("Failed compiling ACE_Tags for tag: %1 - missing textures",_class);
|
|
||||||
_failure = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
private _icon = getText (_x >> "icon");
|
|
||||||
|
|
||||||
if (!_failure) then {
|
|
||||||
GVAR(cachedTags) pushBack [_class, _displayName, _requiredItem, _textures, _icon];
|
|
||||||
if !(_requiredItem in GVAR(cachedRequiredItems)) then {
|
|
||||||
GVAR(cachedRequiredItems) pushBack _requiredItem;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
} forEach ("true" configClasses (configFile >> "ACE_Tags"));
|
|
||||||
|
|
||||||
// Scripted tag adding
|
|
||||||
[QGVAR(addCustomTag), {
|
|
||||||
params ["_identifier", "_displayName", "_requiredItem"];
|
|
||||||
|
|
||||||
// Add only if tag not already added (compare identifiers)
|
|
||||||
if (GVAR(cachedTags) select {_x select 0 == _identifier} isEqualTo []) then {
|
|
||||||
GVAR(cachedTags) pushBack _this;
|
|
||||||
if !(_requiredItem in GVAR(cachedRequiredItems)) then {
|
|
||||||
GVAR(cachedRequiredItems) pushBack _requiredItem;
|
|
||||||
};
|
|
||||||
TRACE_1("Added custom script tag",_this);
|
|
||||||
} else {
|
|
||||||
ACE_LOGINFO_2("Tag with selected identifier already exists: %1 (%2)",_identifier,_displayName)
|
|
||||||
};
|
|
||||||
}] call CBA_fnc_addEventHandler;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!isServer) exitWith {};
|
if (!isServer) exitWith {};
|
||||||
|
@ -51,4 +51,4 @@ _identifier = [_identifier] call EFUNC(common,stringRemoveWhiteSpace);
|
|||||||
_requiredItem = toLower _requiredItem;
|
_requiredItem = toLower _requiredItem;
|
||||||
|
|
||||||
// Add
|
// Add
|
||||||
[QGVAR(addCustomTag), [_identifier, _displayName, _requiredItem, _textures, _icon]] call CBA_fnc_globalEventJIP;
|
[QGVAR(applyCustomTag), [_identifier, _displayName, _requiredItem, _textures, _icon]] call CBA_fnc_globalEventJIP;
|
||||||
|
33
addons/tagging/functions/fnc_applyCustomTag.sqf
Normal file
33
addons/tagging/functions/fnc_applyCustomTag.sqf
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Author: Jonpas
|
||||||
|
* Applies custom tag to the cache.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* 0: Unique Identifier <STRING>
|
||||||
|
* 1: Display Name <STRING>
|
||||||
|
* 2: Required Item <STRING>
|
||||||
|
* 3: Textures Paths <ARRAY>
|
||||||
|
* 4: Icon Path <STRING> (default: "")
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* ["ace_victoryRed", "Victory Red", "ACE_SpraypaintRed", ["path\to\texture1.paa", "path\to\texture2.paa"], "path\to\icon.paa"] call ace_tagging_fnc_addCustomTagLocal
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
params ["_identifier", "_displayName", "_requiredItem"];
|
||||||
|
|
||||||
|
// Add only if tag not already added (compare identifiers)
|
||||||
|
if (GVAR(cachedTags) select {_x select 0 == _identifier} isEqualTo []) then {
|
||||||
|
GVAR(cachedTags) pushBack _this;
|
||||||
|
if !(_requiredItem in GVAR(cachedRequiredItems)) then {
|
||||||
|
GVAR(cachedRequiredItems) pushBack _requiredItem;
|
||||||
|
};
|
||||||
|
TRACE_1("Added custom script tag",_this);
|
||||||
|
} else {
|
||||||
|
ACE_LOGINFO_2("Tag with selected identifier already exists: %1 (%2)",_identifier,_displayName)
|
||||||
|
};
|
53
addons/tagging/functions/fnc_compileConfigTags.sqf
Normal file
53
addons/tagging/functions/fnc_compileConfigTags.sqf
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Author: Jonpas
|
||||||
|
* Compiles and caches tags from ACE_Tags config.
|
||||||
|
*
|
||||||
|
* Arguments:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Return Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* [] call ace_tagging_fnc_compileConfigTags
|
||||||
|
*
|
||||||
|
* Public: No
|
||||||
|
*/
|
||||||
|
#include "script_component.hpp"
|
||||||
|
|
||||||
|
{
|
||||||
|
private _failure = false;
|
||||||
|
private _class = configName _x;
|
||||||
|
|
||||||
|
private _displayName = getText (_x >> "displayName");
|
||||||
|
if (_displayName == "") then {
|
||||||
|
ACE_LOGERROR_1("Failed compiling ACE_Tags for tag: %1 - missing displayName",_class);
|
||||||
|
_failure = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
private _requiredItem = toLower (getText (_x >> "requiredItem"));
|
||||||
|
if (_requiredItem == "") then {
|
||||||
|
ACE_LOGERROR_1("Failed compiling ACE_Tags for tag: %1 - missing requiredItem",_class);
|
||||||
|
_failure = true;
|
||||||
|
} else {
|
||||||
|
if (!isClass (configFile >> "CfgWeapons" >> _requiredItem)) then {
|
||||||
|
ACE_LOGERROR_2("Failed compiling ACE_Tags for tag: %1 - requiredItem %2 does not exist",_class,_requiredItem);
|
||||||
|
_failure = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
private _textures = getArray (_x >> "textures");
|
||||||
|
if (_textures isEqualTo []) then {
|
||||||
|
ACE_LOGERROR_1("Failed compiling ACE_Tags for tag: %1 - missing textures",_class);
|
||||||
|
_failure = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
private _icon = getText (_x >> "icon");
|
||||||
|
|
||||||
|
if (!_failure) then {
|
||||||
|
GVAR(cachedTags) pushBack [_class, _displayName, _requiredItem, _textures, _icon];
|
||||||
|
if !(_requiredItem in GVAR(cachedRequiredItems)) then {
|
||||||
|
GVAR(cachedRequiredItems) pushBack _requiredItem;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} forEach ("true" configClasses (configFile >> "ACE_Tags"));
|
Reference in New Issue
Block a user