Add quick tag keybind and setting

This commit is contained in:
jonpas 2016-07-24 20:00:33 +02:00
parent 9b4f565cc5
commit 4b8f203f9b
11 changed files with 175 additions and 36 deletions

View File

@ -0,0 +1,11 @@
class ACE_Settings {
class GVAR(quickTag) {
category = CSTRING(Tagging);
displayName = CSTRING(QuickTag);
description = CSTRING(QuickTagDesc);
typeName = "SCALAR";
value = 1;
values[] = {ECSTRING(Common,Disabled), CSTRING(LastUsed), CSTRING(RandomX), CSTRING(Random)};
isClientSettable = 1;
};
};

View File

@ -1,11 +1,52 @@
class CfgVehicles {
class ACE_Module;
class ACE_ModuleTagging: ACE_Module {
author = ECSTRING(common,ACETeam);
category = "ACE";
displayName = CSTRING(Tagging);
function = QFUNC(moduleInit);
scope = 2;
isGlobal = 1;
//icon = QPATHTOF(UI\Icon_Module_Tagging_ca.paa);//@todo
class Arguments {
class quickTag {
displayName = CSTRING(QuickTag);
description = CSTRING(QuickTagDesc);
typeName = "NUMBER";
class values {
class disabled {
name = ECSTRING(Common,Disabled);
value = 0;
};
class lastUsed {
name = CSTRING(LastUsed);
value = 1;
default = 1;
};
class randomX {
name = CSTRING(RandomX);
value = 2;
};
class random {
name = CSTRING(Random);
value = 3;
};
};
};
};
class ModuleDescription {
description = CSTRING(ModuleDescription);
};
};
class Man;
class CAManBase: Man {
class ACE_SelfActions {
class ACE_Tags {
displayName = CSTRING(Tag);
condition = QUOTE(_player call FUNC(checkTaggable));
statement = QUOTE(_player call FUNC(tagRandom));
statement = QUOTE(_player call FUNC(quickTag));
icon = QPATHTOF(UI\icons\iconTaggingBlack.paa);
insertChildren = QUOTE(_player call FUNC(addTagActions));
};

View File

@ -4,6 +4,7 @@ PREP(applyCustomTag);
PREP(checkTaggable);
PREP(compileConfigTags);
PREP(createTag);
PREP(moduleInit);
PREP(quickTag);
PREP(tag);
PREP(tagRandom);
PREP(tagTestingThread);

View File

@ -45,6 +45,16 @@ if (hasInterface) then {
// Scripted tag adding EH
[QGVAR(applyCustomTag), FUNC(applyCustomTag)] call CBA_fnc_addEventHandler;
// Keybind
["ACE3 Equipment", QGVAR(quickTag), localize LSTRING(QuickTag), {
// Conditions
if !(ACE_player call FUNC(checkTaggable)) exitWith {false};
// Statement
ACE_player call FUNC(quickTag);
true
}, {false}, [0, [false, false, false]], false] call CBA_fnc_addKeybind; // Unbound
};
if (!isServer) exitWith {};

View File

@ -8,16 +8,17 @@ class CfgPatches {
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_interaction"};
author = ECSTRING(common,ACETeam);
authors[] = {"BaerMitUmlaut","esteldunedain"};
authors[] = {"BaerMitUmlaut", "esteldunedain", "Jonpas"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
};
};
#include "ACE_Settings.hpp"
#include "ACE_Tags.hpp"
#include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp"
#include "CfgWeapons.hpp"
#include "ACE_Tags.hpp"
class ACE_newEvents {
createTag = QGVAR(createTag);

View File

@ -27,15 +27,16 @@ private _actions = [];
_displayName,
_icon,
{
(_this select 2) params ["_unit", "_textures"];
(_this select 2) params ["_unit", "_class", "_textures"];
[_unit, selectRandom _textures] call FUNC(tag);
_unit setVariable [QGVAR(lastUsedTag), _class];
},
{
(_this select 2) params ["_unit", "", "_requiredItem"];
(_this select 2) params ["_unit", "", "", "_requiredItem"];
_requiredItem in ((items _unit) apply {toLower _x})
},
{},
[_unit, _textures, _requiredItem]
[_unit, _class, _textures, _requiredItem]
] call EFUNC(interact_menu,createAction),
[],
_unit

View File

@ -0,0 +1,25 @@
/*
* Author: Jonpas
* Initializes the Tagging module.
*
* Arguments:
* 0: The module logic <LOGIC>
* 1: Units <ARRAY>
* 2: Activated <BOOL>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
if (!isServer) exitWith {};
params ["_logic", "", "_activated"];
if (!_activated) exitWith {};
[_logic, QGVAR(quickTag), "quickTag"] call EFUNC(common,readSettingFromModule);
ACE_LOGINFO("Tagging Module Initialized.");

View File

@ -0,0 +1,51 @@
/*
* Author: Jonpas
* Selects random tag and applies it.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player] call ace_tagging_fnc_quickTag
*
* Public: No
*/
#include "script_component.hpp"
// Exit if Quick Tag disabled
if (GVAR(quickTag) == 0) exitWith {};
params ["_unit"];
private _possibleTags = [];
// Last Used
if (GVAR(quickTag) == 1) then {
private _lastUsedTagClass = _unit getVariable [QGVAR(lastUsedTag), nil];
if (!isNil "_lastUsedTagClass") then {
private _lastUsedTag = GVAR(cachedTags) select {(_x select 0) == _lastUsedTagClass};
_possibleTags = _lastUsedTag;
};
};
// Random X
if (GVAR(quickTag == 2)) then {
private _xTags = GVAR(cachedTags) select {(_x select 0) in ["ACE_XBlack", "ACE_XRed", "ACE_XGreen", "ACE_XBlue"]};
_possibleTags = _xTags;
};
// Random
if (GVAR(quickTag) == 3) then {
_possibleTags = GVAR(cachedTags);
};
// Tag
if !(_possibleTags isEqualTo []) then {
private _availableTags = _possibleTags select {(_x select 2) in ((items _unit) apply {toLower _x})};
[_unit, selectRandom ((selectRandom _availableTags) select 3)] call FUNC(tag);
};

View File

@ -1,23 +0,0 @@
/*
* Author: Jonpas
* Selects random tag and applies it.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player] call ace_tagging_fnc_tagRandom
*
* Public: No
*/
#include "script_component.hpp"
params ["_unit"];
private _possibleTags = GVAR(cachedTags) select {(_x select 2) in ((items _unit) apply {toLower _x})};
[_unit, selectRandom ((selectRandom _possibleTags) select 3)] call FUNC(tag);

View File

@ -2,17 +2,17 @@
#define COMPONENT_BEAUTIFIED Tagging
#include "\z\ace\addons\main\script_mod.hpp"
// #define DEBUG_MODE_FULL
// #define DISABLE_COMPILE_CACHE
#define DEBUG_MODE_FULL
#define DISABLE_COMPILE_CACHE
// #define CBA_DEBUG_SYNCHRONOUS
// #define ENABLE_PERFORMANCE_COUNTERS
#ifdef DEBUG_ENABLED_BLANK
#ifdef DEBUG_ENABLED_TAGGING
#define DEBUG_MODE_FULL
#endif
#ifdef DEBUG_SETTINGS_BLANK
#define DEBUG_SETTINGS DEBUG_SETTINGS_BLANK
#ifdef DEBUG_SETTINGS_TAGGING
#define DEBUG_SETTINGS DEBUG_SETTINGS_TAGGING
#endif
#include "\z\ace\addons\main\script_macros.hpp"

View File

@ -1,6 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Project name="ACE">
<Package name="Tagging">
<Key ID="STR_ACE_Tagging_Tagging">
<English>Tagging</English>
</Key>
<Key ID="STR_ACE_Tagging_ModuleDesc">
<English>Configure how the tagging system will operate by default.</English>
</Key>
<Key ID="STR_ACE_Tagging_QuickTag">
<English>Quick Tag</English>
</Key>
<Key ID="STR_ACE_Tagging_QuickTagDesc">
<English>Action performed on main tag interaction point.</English>
</Key>
<Key ID="STR_ACE_Tagging_LastUsed">
<English>Last Used</English>
</Key>
<Key ID="STR_ACE_Tagging_RandomX">
<English>Random X</English>
</Key>
<Key ID="STR_ACE_Tagging_Random">
<English>Random</English>
</Key>
<Key ID="STR_ACE_Tagging_Tag">
<English>Tag</English>
<German>Markieren</German>
@ -12,7 +33,7 @@
<Portuguese>Marcar</Portuguese>
</Key>
<Key ID="STR_ACE_Tagging_XBlack">
<English>X Black</English>
<English>X black</English>
<German>Schwarz X</German>
<Spanish>X en negro</Spanish>
<Polish>X na czarno</Polish>