Tagging - Add more tags (#8908)

* Added more tags and reorganised interaction

* Removed empty lines from stringtable

* Fix macros, use item picture as interaction icon

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

* Use texture as icon, remove colour from names

* Tagging - Compile actions when added

Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
pterolatypus 2022-05-17 17:54:47 +01:00 committed by GitHub
parent bf8aa1ab7f
commit 699e286db7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 147 additions and 38 deletions

View File

@ -1,26 +1,78 @@
#define GLUE(g1,g2) g1##g2
#define TAG(name,col) class TRIPLES(ACE,name,col) { \
displayName = CSTRING(name); \
requiredItem = QUOTE(GLUE(ACE_Spraypaint,col)); \
textures[] = {QPATHTOF(UI\tags\col\name.paa)}; \
icon = QPATHTOF(UI\tags\col\name.paa); \
} \
class ACE_Tags {
class ACE_XBlack {
displayName = CSTRING(XBlack);
requiredItem = "ACE_SpraypaintBlack";
textures[] = {QPATHTOF(UI\tags\black\0.paa), QPATHTOF(UI\tags\black\1.paa), QPATHTOF(UI\tags\black\2.paa)};
icon = QPATHTOF(UI\icons\iconTaggingBlack.paa);
icon = QPATHTOF(UI\tags\black\0.paa);
};
class ACE_XRed {
displayName = CSTRING(XRed);
requiredItem = "ACE_SpraypaintRed";
textures[] = {QPATHTOF(UI\tags\red\0.paa), QPATHTOF(UI\tags\red\1.paa), QPATHTOF(UI\tags\red\2.paa)};
icon = QPATHTOF(UI\icons\iconTaggingRed.paa);
icon = QPATHTOF(UI\tags\red\0.paa);
};
class ACE_XGreen {
displayName = CSTRING(XGreen);
requiredItem = "ACE_SpraypaintGreen";
textures[] = {QPATHTOF(UI\tags\green\0.paa), QPATHTOF(UI\tags\green\1.paa), QPATHTOF(UI\tags\green\2.paa)};
icon = QPATHTOF(UI\icons\iconTaggingGreen.paa);
icon = QPATHTOF(UI\tags\green\0.paa);
};
class ACE_XBlue {
displayName = CSTRING(XBlue);
requiredItem = "ACE_SpraypaintBlue";
textures[] = {QPATHTOF(UI\tags\blue\0.paa), QPATHTOF(UI\tags\blue\1.paa), QPATHTOF(UI\tags\blue\2.paa)};
icon = QPATHTOF(UI\icons\iconTaggingBlue.paa);
icon = QPATHTOF(UI\tags\blue\0.paa);
};
TAG(arrow_up,Black);
TAG(arrow_down,Black);
TAG(arrow_left,Black);
TAG(arrow_right,Black);
TAG(circle,Black);
TAG(cross,Black);
TAG(diamond,Black);
TAG(square,Black);
TAG(triangle,Black);
TAG(triangle_inverted,Black);
TAG(arrow_up,Blue);
TAG(arrow_down,Blue);
TAG(arrow_left,Blue);
TAG(arrow_right,Blue);
TAG(circle,Blue);
TAG(cross,Blue);
TAG(diamond,Blue);
TAG(square,Blue);
TAG(triangle,Blue);
TAG(triangle_inverted,Blue);
TAG(arrow_up,Green);
TAG(arrow_down,Green);
TAG(arrow_left,Green);
TAG(arrow_right,Green);
TAG(circle,Green);
TAG(cross,Green);
TAG(diamond,Green);
TAG(square,Green);
TAG(triangle,Green);
TAG(triangle_inverted,Green);
TAG(arrow_up,Red);
TAG(arrow_down,Red);
TAG(arrow_left,Red);
TAG(arrow_right,Red);
TAG(circle,Red);
TAG(cross,Red);
TAG(diamond,Red);
TAG(square,Red);
TAG(triangle,Red);
TAG(triangle_inverted,Red);
};

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -3,6 +3,7 @@ PREP(addTagActions);
PREP(applyCustomTag);
PREP(checkTaggable);
PREP(compileConfigTags);
PREP(compileTagAction);
PREP(createTag);
PREP(moduleInit);
PREP(parseConfigTag);

View File

@ -7,7 +7,7 @@ PREP_RECOMPILE_START;
PREP_RECOMPILE_END;
GVAR(cachedTags) = [];
GVAR(cachedRequiredItems) = [];
GVAR(itemActions) = createHashMap;
#include "initSettings.sqf"

View File

@ -19,38 +19,18 @@ params ["_unit"];
private _actions = [];
{
_x params ["_class", "_displayName", "_requiredItem", "_textures", "_icon", "_materials"];
_actions pushBack [
[
format ["ACE_ConfigTag_%1", _class],
_displayName,
_icon,
{
(_this select 2) params ["_unit", "_class", "_textures", "", "_materials"];
(
if (count _textures == count _materials) then {
private _textureIndex = floor random count _textures;
[_textures select _textureIndex, _materials select _textureIndex]
} else {
[selectRandom _textures, selectRandom _materials]
}
) params ["_randomTexture", "_randomMaterial"];
[_unit, _randomTexture, _randomMaterial] call FUNC(tag);
_unit setVariable [QGVAR(lastUsedTag), _class];
},
{
(_this select 2) params ["_unit", "", "", "_requiredItem"];
_requiredItem in (_unit call EFUNC(common,uniqueItems))
},
format ["ACE_TagItem_%1", _x],
getText (configFile >> "CfgWeapons" >> _x >> "displayName"),
getText (configFile >> "CfgWeapons" >> _x >> "picture"),
{},
[_unit, _class, _textures, _requiredItem, _materials]
{(_this select 2) in (_player call EFUNC(common,uniqueItems))},
{},
_x
] call EFUNC(interact_menu,createAction),
[],
_y apply { [_x, [], _unit] }, //sub-actions for each individual tag
_unit
];
} forEach GVAR(cachedTags);
]
} forEach GVAR(itemActions);
_actions

View File

@ -36,5 +36,5 @@ _requiredItem = configName (configFile >> "CfgWeapons" >> _requiredItem); // Con
_this set [2, _requiredItem];
GVAR(cachedTags) pushBack _this;
GVAR(cachedRequiredItems) pushBackUnique _requiredItem;
_this call FUNC(compileTagAction);
TRACE_1("Added custom script tag",_this);

View File

@ -20,7 +20,7 @@
// Exit if no required item in inventory
if ([_unit, {
GVAR(cachedRequiredItems) arrayIntersect (_unit call EFUNC(common,uniqueItems)) isEqualTo []
(keys GVAR(itemActions)) arrayIntersect (_unit call EFUNC(common,uniqueItems)) isEqualTo []
}, _unit, QGVAR(checkRequiredItemsCache), 9999, "cba_events_loadoutEvent"] call EFUNC(common,cachedCall)) exitWith {false};
private _startPosASL = eyePos _unit;

View File

@ -23,7 +23,7 @@
_result params ["_tagInfo", "_requiredItem"];
GVAR(cachedTags) pushBack _tagInfo;
GVAR(cachedRequiredItems) pushBackUnique _requiredItem;
_tagInfo call FUNC(compileTagAction);
};
} forEach ("true" configClasses (configFile >> "ACE_Tags"));
@ -35,6 +35,6 @@
_result params ["_tagInfo", "_requiredItem"];
GVAR(cachedTags) pushBack _tagInfo;
GVAR(cachedRequiredItems) pushBackUnique _requiredItem;
_tagInfo call FUNC(compileTagAction);
};
} forEach ("true" configClasses (missionConfigFile >> "ACE_Tags"));

View File

@ -0,0 +1,46 @@
#include "script_component.hpp"
/*
* Author: PabstMirror
* Compiles tags from ACE_Tags and returns children actions.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [unit] call ace_tagging_fnc_compileTagAction
*
* Public: No
*/
params ["_class", "_displayName", "_requiredItem", "_textures", "_icon", "_materials"];
private _actions = GVAR(itemActions) getOrDefault [_requiredItem, []];
_actions pushBack ([
_class,
_displayName,
_icon,
{
(_this select 2) params ["_class", "_textures", "_materials"];
(
if (count _textures == count _materials) then {
private _textureIndex = floor random count _textures;
[_textures select _textureIndex, _materials select _textureIndex]
} else {
[selectRandom _textures, selectRandom _materials]
}
) params ["_randomTexture", "_randomMaterial"];
[_player, _randomTexture, _randomMaterial] call FUNC(tag);
_player setVariable [QGVAR(lastUsedTag), _class];
},
{true}, // required item is checked at an upper level
{},
[_class, _textures, _materials]
] call EFUNC(interact_menu,createAction));
GVAR(itemActions) set [_requiredItem, _actions];

View File

@ -191,6 +191,36 @@
<Chinese>藍色X標記</Chinese>
<Turkish>X Mavi</Turkish>
</Key>
<Key ID="STR_ACE_Tagging_arrow_up">
<English>Up Arrow</English>
</Key>
<Key ID="STR_ACE_Tagging_arrow_down">
<English>Down Arrow</English>
</Key>
<Key ID="STR_ACE_Tagging_arrow_left">
<English>Left Arrow</English>
</Key>
<Key ID="STR_ACE_Tagging_arrow_right">
<English>Right Arrow</English>
</Key>
<Key ID="STR_ACE_Tagging_circle">
<English>Circle</English>
</Key>
<Key ID="STR_ACE_Tagging_cross">
<English>Cross</English>
</Key>
<Key ID="STR_ACE_Tagging_diamond">
<English>Diamond</English>
</Key>
<Key ID="STR_ACE_Tagging_square">
<English>Square</English>
</Key>
<Key ID="STR_ACE_Tagging_triangle">
<English>Triangle</English>
</Key>
<Key ID="STR_ACE_Tagging_triangle_inverted">
<English>Triangle Inverted</English>
</Key>
<Key ID="STR_ACE_Tagging_SpraypaintBlack">
<English>Spray Paint (Black)</English>
<German>Sprühfarbe (Schwarz)</German>