From a38cdda8e36da5737946f11f4b474e74e2498d98 Mon Sep 17 00:00:00 2001 From: Michael Braun Date: Sat, 8 Aug 2015 08:26:15 +0200 Subject: [PATCH] First iteration on implementing Dslyecxi's ST Map Gestures --- addons/map_gestures/$PBOPREFIX$ | 1 + addons/map_gestures/ACE_Settings.hpp | 50 ++++++++++ addons/map_gestures/CfgEventHandlers.hpp | 11 +++ addons/map_gestures/CfgVehicles.hpp | 64 +++++++++++++ addons/map_gestures/XEH_postInit.sqf | 16 ++++ addons/map_gestures/XEH_preInit.sqf | 17 ++++ addons/map_gestures/config.cpp | 17 ++++ .../functions/fnc_assignClientIDOnServer.sqf | 24 +++++ .../functions/fnc_drawMapGestures.sqf | 48 ++++++++++ .../functions/fnc_endTransmit.sqf | 21 ++++ .../functions/fnc_getProximityPlayers.sqf | 23 +++++ .../functions/fnc_initTransmit.sqf | 21 ++++ .../functions/fnc_moduleGroupSettings.sqf | 53 +++++++++++ .../functions/fnc_moduleSettings.sqf | 35 +++++++ .../functions/fnc_receiverInit.sqf | 32 +++++++ .../functions/fnc_sanitizeName.sqf | 30 ++++++ .../map_gestures/functions/fnc_transmit.sqf | 42 ++++++++ .../functions/fnc_transmitterInit.sqf | 59 ++++++++++++ .../functions/script_component.hpp | 1 + addons/map_gestures/script_component.hpp | 12 +++ addons/map_gestures/stringtable.xml | 95 +++++++++++++++++++ 21 files changed, 672 insertions(+) create mode 100644 addons/map_gestures/$PBOPREFIX$ create mode 100644 addons/map_gestures/ACE_Settings.hpp create mode 100644 addons/map_gestures/CfgEventHandlers.hpp create mode 100644 addons/map_gestures/CfgVehicles.hpp create mode 100644 addons/map_gestures/XEH_postInit.sqf create mode 100644 addons/map_gestures/XEH_preInit.sqf create mode 100644 addons/map_gestures/config.cpp create mode 100644 addons/map_gestures/functions/fnc_assignClientIDOnServer.sqf create mode 100644 addons/map_gestures/functions/fnc_drawMapGestures.sqf create mode 100644 addons/map_gestures/functions/fnc_endTransmit.sqf create mode 100644 addons/map_gestures/functions/fnc_getProximityPlayers.sqf create mode 100644 addons/map_gestures/functions/fnc_initTransmit.sqf create mode 100644 addons/map_gestures/functions/fnc_moduleGroupSettings.sqf create mode 100644 addons/map_gestures/functions/fnc_moduleSettings.sqf create mode 100644 addons/map_gestures/functions/fnc_receiverInit.sqf create mode 100644 addons/map_gestures/functions/fnc_sanitizeName.sqf create mode 100644 addons/map_gestures/functions/fnc_transmit.sqf create mode 100644 addons/map_gestures/functions/fnc_transmitterInit.sqf create mode 100644 addons/map_gestures/functions/script_component.hpp create mode 100644 addons/map_gestures/script_component.hpp create mode 100644 addons/map_gestures/stringtable.xml diff --git a/addons/map_gestures/$PBOPREFIX$ b/addons/map_gestures/$PBOPREFIX$ new file mode 100644 index 0000000000..8672ea58f4 --- /dev/null +++ b/addons/map_gestures/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\map_gestures diff --git a/addons/map_gestures/ACE_Settings.hpp b/addons/map_gestures/ACE_Settings.hpp new file mode 100644 index 0000000000..c7b9a8b2ed --- /dev/null +++ b/addons/map_gestures/ACE_Settings.hpp @@ -0,0 +1,50 @@ +class ACE_Settings { + class GVAR(enabled) { + value = 1; + typeName = "BOOL"; + displayName = CSTRING(enabled_displayName); + description = CSTRING(enabled_description); + }; + class GVAR(maxRange) { + value = 7; + typeName = "SCALAR"; + displayName = CSTRING(maxRange_displayName); + description = CSTRING(maxRange_description); + }; + class GVAR(interval) { + value = 0.03; + typeName = "SCALAR"; + displayName = CSTRING(interval_displayName); + description = CSTRING(interval_description); + }; + class GVAR(defaultLeadColor) { + value[] = {1, 0.88, 0, 0.95}; + typeName = "COLOR"; + displayName = CSTRING(defaultLeadColor_displayName); + description = CSTRING(defaultLeadColor_description); + }; + class GVAR(defaultColor) { + value[] = {1, 0.88, 0, 0.7}; + typeName = "COLOR"; + displayName = CSTRING(defaultColor_displayName); + description = CSTRING(defaultColor_description); + }; + class GVAR(GroupColorConfigurations) { + value[] = {}; + typeName = "ARRAY"; + displayName = CSTRING(GroupColorConfigurations_displayName); + description = CSTRING(GroupColorConfigurations_description); + }; + class GVAR(GroupColorConfigurationsGroups) { + value[] = {}; + typeName = "ARRAY"; + displayName = CSTRING(GroupColorConfigurationsGroups_displayName); + description = CSTRING(GroupColorConfigurationsGroups_description); + }; + class GVAR(GroupColorConfigurationsGroupIndex) { + value[] = {}; + typeName = "ARRAY"; + displayName = CSTRING(GroupColorConfigurationsGroupIndex_displayName); + description = CSTRING(GroupColorConfigurationsGroupIndex_description); + }; +}; diff --git a/addons/map_gestures/CfgEventHandlers.hpp b/addons/map_gestures/CfgEventHandlers.hpp new file mode 100644 index 0000000000..e75956f440 --- /dev/null +++ b/addons/map_gestures/CfgEventHandlers.hpp @@ -0,0 +1,11 @@ +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; + +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; diff --git a/addons/map_gestures/CfgVehicles.hpp b/addons/map_gestures/CfgVehicles.hpp new file mode 100644 index 0000000000..30204629a8 --- /dev/null +++ b/addons/map_gestures/CfgVehicles.hpp @@ -0,0 +1,64 @@ +class CfgVehicles { + class ACE_Module; + class GVAR(moduleSettings): ACE_Module { + scope = 2; + category = "ACE"; + displayName = CSTRING(moduleSettings_displayName); + function = QFUNC(moduleSettings); + isGlobal = 0; + author = ECSTRING(common,ACETeam); + class Arguments { + class enabled { + displayName = CSTRING(enabled_DisplayName); + typeName = "BOOL"; + defaultValue = 1; + }; + class maxRange { + displayName = CSTRING(maxRange_displayName); + description = CSTRING(maxRange_description); + typeName = "NUMBER"; + defaultValue = 4; + }; + class interval { + displayName = CSTRING(interval_displayName); + description = CSTRING(interval_description); + typeName = "NUMBER"; + defaultValue = 0.03; + }; + class defaultLeadColor { + displayName = CSTRING(defaultLeadColor_displayName); + description = CSTRING(defaultLeadColor_description); + typeName = "STRING"; + defaultValue = "0,0,0,0"; + }; + class defaultColor { + displayName = CSTRING(defaultColor_displayName); + description = CSTRING(defaultColor_description); + typeName = "STRING"; + defaultValue = "0,0,0,0"; + }; + }; + }; + class GVAR(moduleGroupSettings): ACE_Module { + scope = 2; + category = "ACE"; + displayName = CSTRING(moduleGroupSettings_displayName); + function = QFUNC(moduleGroupSettings); + isGlobal = 0; + author = ECSTRING(common,ACETeam); + class Arguments { + class leadColor { + displayName = CSTRING(leadColor_displayName); + description = CSTRING(leadColor_description); + typeName = "STRING"; + defaultValue = "0,0,0,0"; + }; + class color { + displayName = CSTRING(color_displayName); + description = CSTRING(color_description); + typeName = "STRING"; + defaultValue = "0,0,0,0"; + }; + }; + }; +}; diff --git a/addons/map_gestures/XEH_postInit.sqf b/addons/map_gestures/XEH_postInit.sqf new file mode 100644 index 0000000000..777463e86a --- /dev/null +++ b/addons/map_gestures/XEH_postInit.sqf @@ -0,0 +1,16 @@ +#include "script_component.hpp" + +if (!hasInterface) exitWith {}; + +["SettingsInitialized", { + [{ + if (isNull (findDisplay 12)) exitWith {}; + + params ["", "_pfhId"]; + + call FUNC(receiverInit); + call FUNC(transmitterInit); + + [_pfhId] call CBA_fnc_removePerFrameHandler; + }, 1, []] call CBA_fnc_addPerFrameHandler; +}] call EFUNC(common,addEventHandler); diff --git a/addons/map_gestures/XEH_preInit.sqf b/addons/map_gestures/XEH_preInit.sqf new file mode 100644 index 0000000000..08159aa972 --- /dev/null +++ b/addons/map_gestures/XEH_preInit.sqf @@ -0,0 +1,17 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP(assignClientIDOnServer); +PREP(drawMapGestures); +PREP(endTransmit); +PREP(getProximityPlayers); +PREP(initTransmit); +PREP(moduleGroupSettings); +PREP(moduleSettings); +PREP(receiverInit); +PREP(sanitizeName); +PREP(transmit); +PREP(transmitterInit); + +ADDON = true; diff --git a/addons/map_gestures/config.cpp b/addons/map_gestures/config.cpp new file mode 100644 index 0000000000..72e7f82078 --- /dev/null +++ b/addons/map_gestures/config.cpp @@ -0,0 +1,17 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author[] = {"Dslyecxi", "MikeMatrix"}; + authorUrl = "https://github.com/MikeMatrix"; + VERSION_CONFIG; + }; +}; + +#include "ACE_Settings.hpp" +#include "CfgEventHandlers.hpp" +#include "CfgVehicles.hpp" diff --git a/addons/map_gestures/functions/fnc_assignClientIDOnServer.sqf b/addons/map_gestures/functions/fnc_assignClientIDOnServer.sqf new file mode 100644 index 0000000000..129c5066e1 --- /dev/null +++ b/addons/map_gestures/functions/fnc_assignClientIDOnServer.sqf @@ -0,0 +1,24 @@ +/* + * Author: MikeMatrix + * Assign readable client ID to unit on the server. + * + * Arguments: + * 0: Unit name + * + * Return Value: + * None + * + * Example: + * ["MikeMatrix"] call ace_map_gestures_fnc_assignClientIDOnServer + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unitName"]; + +{ + if (name _x == _unitName) then { + _x setVariable [QGVAR(owner_id), owner _x, true]; + }; +} count playableUnits; diff --git a/addons/map_gestures/functions/fnc_drawMapGestures.sqf b/addons/map_gestures/functions/fnc_drawMapGestures.sqf new file mode 100644 index 0000000000..0b352418af --- /dev/null +++ b/addons/map_gestures/functions/fnc_drawMapGestures.sqf @@ -0,0 +1,48 @@ +/* + * Author: MikeMatrix + * Receives and draws map gestures from nearby players. + * + * Arguments: + * 0: Map Handle + * + * Return Value: + * None + * + * Example: + * [findDisplay 12 displayCtrl 51] call ace_map_gesutres_fnc_drawMapGestures + * + * Public: No + */ +#include "script_component.hpp" + +if (!GVAR(enabled)) exitWith {}; +if (!visibleMap) exitWith {}; + +params ["_mapHandle"]; + +_nearDudes = [ACE_player, GVAR(maxRange)] call FUNC(getProximityPlayers); +{ + _nameSane = [name _x] call FUNC(sanitizeName); + _drawPosVariableName = format [QGVAR(%1_DrawPos), _nameSane]; + if (!isNil _drawPosVariableName) then { + _pos = call compile _drawPosVariableName; + if (alive _x && + (_pos distance [0, 0, 0]) > 50 && + {_x getVariable QGVAR(Transmit)}) then { + _group = group _x; + _grpName = groupID _group; + + _color = [1, 1, 1, 1]; + if (_grpName in GVAR(GroupColorConfigurationsGroups)) then { + _grpNameIndex = GVAR(GroupColorConfigurationsGroups) find _grpName; + _color = (GVAR(GroupColorConfigurations) select (GVAR(GroupColorConfigurationsGroupIndex) select _grpNameIndex)) select (_x != leader _group); + } else { + _color = if (_x == leader _group) then {GVAR(defaultLeadColor)} else {GVAR(defaultColor)}; + }; + + _mapHandle drawIcon ["\a3\ui_f\data\gui\cfg\Hints\icon_text\group_1_ca.paa", _color, _pos, 55, 55, 0, "", 1, 0.030, "PuristaBold", "left"]; + _mapHandle drawIcon ["#(argb,8,8,3)color(0,0,0,0)", [.2,.2,.2,.3], _pos, 20, 20, 0, name _x, 0, 0.030, "PuristaBold", "left"]; + }; + }; + nil +} count _nearDudes; diff --git a/addons/map_gestures/functions/fnc_endTransmit.sqf b/addons/map_gestures/functions/fnc_endTransmit.sqf new file mode 100644 index 0000000000..0db082aa65 --- /dev/null +++ b/addons/map_gestures/functions/fnc_endTransmit.sqf @@ -0,0 +1,21 @@ +/* + * Author: MikeMatrix + * Ensure that all variables used to indicate transmission are disabled. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [] call ace_map_gestures_fnc_endTransmit + * + * Public: No + */ +#include "script_component.hpp" + +if (!GVAR(enabled)) exitWith {}; + +ACE_player setVariable [QGVAR(Transmit), false, true]; +GVAR(EnableTransmit) = false; diff --git a/addons/map_gestures/functions/fnc_getProximityPlayers.sqf b/addons/map_gestures/functions/fnc_getProximityPlayers.sqf new file mode 100644 index 0000000000..eb1b609778 --- /dev/null +++ b/addons/map_gestures/functions/fnc_getProximityPlayers.sqf @@ -0,0 +1,23 @@ +/* + * Author: MikeMatrix + * Returns all players in a given range and in the units vehicle. + * + * Arguments: + * 0: Unit + * 1: Range + * + * Return Value: + * All units in proximity + * + * Example: + * ["example value"] call ace_module_fnc_functionName + * + * Public: No + */ +#include "script_component.hpp" + +params ["_unit", "_range"]; + +_proximityPlayers = (getPos _unit) nearEntities [["CAMAnBase"], _range]; +_proximityPlayers = _proximityPlayers - [_unit]; +(_proximityPlayers + (crew vehicle _unit)) diff --git a/addons/map_gestures/functions/fnc_initTransmit.sqf b/addons/map_gestures/functions/fnc_initTransmit.sqf new file mode 100644 index 0000000000..546e5d3c3b --- /dev/null +++ b/addons/map_gestures/functions/fnc_initTransmit.sqf @@ -0,0 +1,21 @@ +/* + * Author: MikeMatrix + * Initializes transmitting map gestures. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [] call ace_map_gestures_fnc_initTransmit + * + * Public: No + */ +#include "script_component.hpp" + +if (!GVAR(enabled)) exitWith {}; + +GVAR(EnableTransmit) = true; +[FUNC(transmit), GVAR(interval), []] call CBA_fnc_addPerFrameHandler; diff --git a/addons/map_gestures/functions/fnc_moduleGroupSettings.sqf b/addons/map_gestures/functions/fnc_moduleGroupSettings.sqf new file mode 100644 index 0000000000..b51f4b99b4 --- /dev/null +++ b/addons/map_gestures/functions/fnc_moduleGroupSettings.sqf @@ -0,0 +1,53 @@ +/* + * Author: MikeMatrix + * Initializes Settings for the groups modules and transcodes settings to a useable format. + * + * Arguments: + * 0: Logic + * 1: Units + * 2: Activated + * + * Return Value: + * None + * + * Example: + * [module, [player], true] call ace_map_gestures_fnc_moduleGroupSettings + * + * Public: No + */ +#include "script_component.hpp" + +params ["_logic", "_units", "_activated"]; + +if (!_activated) exitWith {}; +if (!isServer) exitWith {}; + +_leadColor = call compile ("[" + (_logic getVariable ["leadColor", ""]) + "]"); +if (isNil "_leadColor" || !((typeName _leadColor) isEqualTo "ARRAY") || {count _leadColor != 4}) exitWith {}; +_color = call compile ("[" + (_logic getVariable ["color", ""]) + "]"); +if (isNil "_color" || !((typeName _color) isEqualTo "ARRAY") || {count _color != 4}) exitWith {}; + +_configurations = +GVAR(GroupColorConfigurations); +if (isNil "_configurations") then {_configurations = []}; +_configurationIndex = _configurations pushBack [_leadColor, _color]; + +_configurationGroups = +GVAR(GroupColorConfigurationsGroups); +_configurationGroupsIndex = +GVAR(GroupColorConfigurationsGroupIndex); + +if (isNil "_configurationGroups") then {_configurationGroups = [];}; +if (isNil "_configurationGroupsIndex") then {_configurationGroupsIndex = [];}; +_completedGroups = []; +{ + private "_group"; + _group = groupID (group _x); + if (!(_group in _completedGroups)) then { + _index = if (_group in _configurationGroups) then {_configurationGroups find _group} else {_configurationGroups pushBack _group}; + _configurationGroupsIndex set [_index, _configurationIndex]; + _completedGroups pushBack _group; + }; + nil +} count _units; + +[QGVAR(GroupColorConfigurations), _configurations, true, true] call EFUNC(common,setSetting); +[QGVAR(GroupColorConfigurationsGroups), _configurationGroups, true, true] call EFUNC(common,setSetting); +[QGVAR(GroupColorConfigurationsGroupIndex), _configurationGroupsIndex, true, true] call EFUNC(common,setSetting); diff --git a/addons/map_gestures/functions/fnc_moduleSettings.sqf b/addons/map_gestures/functions/fnc_moduleSettings.sqf new file mode 100644 index 0000000000..d53e118b46 --- /dev/null +++ b/addons/map_gestures/functions/fnc_moduleSettings.sqf @@ -0,0 +1,35 @@ +/* + * Author: MikeMatrix + * Initializes Settings for the module and transcodes settings to a useable format. + * + * Arguments: + * 0: Logic + * 1: Units + * 2: Activated + * + * Return Value: + * None + * + * Example: + * [module, [player], true] call ace_map_gestures_fnc_moduleGroupSettings + * + * Public: No + */ +#include "script_component.hpp" + +params ["_logic", "_units", "_activated"]; + +if (!_activated) exitWith {}; +if (!isServer) exitWith {}; + +[_logic, QGVAR(enabled), "enabled"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(maxRange), "maxRange"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(interval), "interval"] call EFUNC(common,readSettingFromModule); + +_defaultLeadColor = call compile ("[" + (_logic getVariable ["defaultLeadColor", ""]) + "]"); +if (isNil "_leadColor" || !((typeName _leadColor) isEqualTo "ARRAY") || {count _leadColor != 4}) exitWith {}; +[QGVAR(defaultLeadColor), _defaultLeadColor, true, true] call EFUNC(common,setSetting); + +_defaultColor = call compile ("[" + (_logic getVariable ["defaultColor", ""]) + "]"); +if (isNil "_color" || !((typeName _color) isEqualTo "ARRAY") || {count _color != 4}) exitWith {}; +[QGVAR(defaultColor), _defaultColor, true, true] call EFUNC(common,setSetting); diff --git a/addons/map_gestures/functions/fnc_receiverInit.sqf b/addons/map_gestures/functions/fnc_receiverInit.sqf new file mode 100644 index 0000000000..44b5bada47 --- /dev/null +++ b/addons/map_gestures/functions/fnc_receiverInit.sqf @@ -0,0 +1,32 @@ +/* + * Author: MikeMatrix + * Initializes the receiver and hooks it to the Draw event of the map. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [] call ace_map_gestures_fnc_receiverInit + * + * Public: No + */ +#include "script_component.hpp" + +{ + if (isPlayer _x) then { + _nameSane = [name _x] call FUNC(sanitizeName); + call compile format [QUOTE(GVAR(%1_DrawPos) = [ARR_3(1,1,1)];), _nameSane]; + }; + nil +} count allUnits; + +ACE_player setVariable [QGVAR(Transmit), false, true]; +GVAR(EnableTransmit) = false; + +if (!isNil QGVAR(DrawMapHandlerID)) then { + (findDisplay 12 displayCtrl 51) ctrlRemoveEventHandler ["Draw", GVAR(DrawMapHandlerID)]; GVAR(DrawMapHandlerID) = nil; +}; +GVAR(DrawMapHandlerID) = findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", FUNC(drawMapGestures)]; diff --git a/addons/map_gestures/functions/fnc_sanitizeName.sqf b/addons/map_gestures/functions/fnc_sanitizeName.sqf new file mode 100644 index 0000000000..bafe9d3052 --- /dev/null +++ b/addons/map_gestures/functions/fnc_sanitizeName.sqf @@ -0,0 +1,30 @@ +/* + * Author: MikeMatrix + * Cleans up unit names to be usable within variable names. + * + * Arguments: + * 0: Name + * + * Return Value: + * Sanitized name + * + * Example: + * ["I am a non valid variable name"] call ace_map_gestures_fnc_sanitizeName + * + * Public: No + */ +#include "script_component.hpp" + +private ["_alphabet", "_nameSanitized"]; + +params ["_name"]; + +_alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]; + +_nameSanitized = []; +{ + if (toString [_x] in _alphabet) then {_nameSanitized pushBack _x}; + nil +} count (toArray _name); + +toString _nameSanitized diff --git a/addons/map_gestures/functions/fnc_transmit.sqf b/addons/map_gestures/functions/fnc_transmit.sqf new file mode 100644 index 0000000000..9defec2fd8 --- /dev/null +++ b/addons/map_gestures/functions/fnc_transmit.sqf @@ -0,0 +1,42 @@ +/* + * Author: MikeMatrix + * Transmit PFH + * + * Arguments: + * 0: Arguments + * 1: PFH ID + * + * Return Value: + * Return description + * + * Example: + * [[], 2] call ace_map_gestures_fnc_transmit + * + * Public: No + */ +#include "script_component.hpp" + +private ["_nearDudes", "_ownerID", "_nameSane"]; + +params ["", "_pfhId"]; + +if (!GVAR(EnableTransmit) || !visibleMap) exitWith { + call FUNC(endTransmit); + [_pfhId] call CBA_fnc_removePerFrameHandler; +}; + +_nearDudes = [ACE_player, GVAR(maxRange)] call FUNC(getProximityPlayers); +TRACE_1("Near",_nearDudes) + +{ + _ownerID = _x getVariable QGVAR(owner_id); + if (isNil _ownerID) exitWith { + [0, {[_this] call FUNC(assignClientIDOnServer)}, name _x] call cba_fnc_GlobalExecute; + }; + _ownerID = _x getVariable QGVAR(owner_id); + + if (_ownerID != ACE_player getVariable QGVAR(owner_id)) then { + _nameSane = [name ACE_player] call FUNC(sanitizeName); + _ownerID publicVariableClient format [QGVAR(%1_DrawPos), _nameSane]; + }; +} count _nearDudes; diff --git a/addons/map_gestures/functions/fnc_transmitterInit.sqf b/addons/map_gestures/functions/fnc_transmitterInit.sqf new file mode 100644 index 0000000000..3c0cfa7c10 --- /dev/null +++ b/addons/map_gestures/functions/fnc_transmitterInit.sqf @@ -0,0 +1,59 @@ +/* + * Author: MikeMatrix + * Initializes the transmitting event handlers. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * [] call ace_map_gestures_fnc_transmitterInit + * + * Public: No + */ +#include "script_component.hpp" + +private ["_mapCtrl", "_nameSane"]; + +disableSerialization; + +_mapCtrl = findDisplay 12 displayCtrl 51; + +// MouseMoving EH. +if (!isNil QGVAR(MouseMoveHandlerID)) then {_mapCtrl ctrlRemoveEventHandler ["MouseMoving", GVAR(MouseMoveHandlerID)]; GVAR(MouseMoveHandlerID) = nil;}; +GVAR(MouseMoveHandlerID) = _mapCtrl ctrlAddEventHandler ["MouseMoving", { + if (EGVAR(maptools,drawing_isDrawing)) exitWith {}; + if (EGVAR(maptools,mapTool_isDragging)) exitWith {}; + if (EGVAR(maptools,mapTool_isRotating)) exitWith {}; + + params ["_control", "_posX", "_posY"]; + + if (GVAR(EnableTransmit)) then { + if (!(ACE_player getVariable QGVAR(Transmit))) then { + ACE_player setVariable [QGVAR(Transmit), true, true]; + }; + + _nameSane = [name ACE_player] call FUNC(sanitizeName); + call compile format [QUOTE(GVAR(%1_DrawPos) = %2), _nameSane, _control ctrlMapScreenToWorld [_posX, _posY]]; + }; +}]; + +// MouseDown EH +if (!isNil QGVAR(MouseDownHandlerID)) then {_mapCtrl ctrlRemoveEventHandler ["MouseButtonDown",GVAR(MouseDownHandlerID)]; GVAR(MouseDownHandlerID) = nil;}; +GVAR(MouseDownHandlerID) = _mapCtrl ctrlAddEventHandler ["MouseButtonDown", { + if (!GVAR(enabled)) exitWith {}; + + params ["", "_button"]; + + if (_button == 0) then {call FUNC(initTransmit);}; +}]; + +// MouseUp EH +if (!isNil QGVAR(MouseUpHandlerID)) then {_mapCtrl ctrlRemoveEventHandler ["MouseButtonUp", GVAR(MouseUpHandlerID)]; GVAR(MouseUpHandlerID) = nil;}; +GVAR(MouseUpHandlerID) = _mapCtrl ctrlAddEventHandler ["MouseButtonUp", { + params ["", "_button"]; + + if (_button == 0) then {call FUNC(endTransmit);}; +}]; diff --git a/addons/map_gestures/functions/script_component.hpp b/addons/map_gestures/functions/script_component.hpp new file mode 100644 index 0000000000..65841c15f9 --- /dev/null +++ b/addons/map_gestures/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\map_gestures\script_component.hpp" diff --git a/addons/map_gestures/script_component.hpp b/addons/map_gestures/script_component.hpp new file mode 100644 index 0000000000..7c6f3a5b2f --- /dev/null +++ b/addons/map_gestures/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT map_gestures +#include "\z\ace\addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_MAP_GESTURES + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_MAP_GESTURES + #define DEBUG_SETTINGS DEBUG_SETTINGS_MAP_GESTURES +#endif + +#include "\z\ace\addons\main\script_macros.hpp" diff --git a/addons/map_gestures/stringtable.xml b/addons/map_gestures/stringtable.xml new file mode 100644 index 0000000000..324e9f92e7 --- /dev/null +++ b/addons/map_gestures/stringtable.xml @@ -0,0 +1,95 @@ + + + + + Map Gestures + + + Enabled + + + Map Gesture Max Range + + + Max range between players to show the map gesture indicator [default: 7 meters] + + + Lead Default Alpha + + + Fallback Alpha value for group leaders. + + + Default Alpha + + + Fallback Alpha value. + + + Lead Default Color + + + Fallback Color value for group leaders. + + + Default Color + + + Fallback Color value. + + + Lead Alpha + + + Alpha value for group leaders of groups synced with this module. + + + Alpha + + + Alpha value for group members of groups synced with this module. + + + Lead Color + + + Color value for group leaders of groups synced with this module. + + + Color + + + Color value for group members of groups synced with this module. + + + Map Gestures - Group Settings + + + Update Interval + + + Time between data updates. + + + Group color configurations + + + Group color configuration containing arrays of color pairs ([leadColor, color]). + + + Group color group name index, containing names of groups with configurations attached to them. + + + Group color group name index + + + Group color group name mapping index + + + Group color group name mapping index, mapping the GroupColorConfigurationsGroups to the GroupColorConfigurations. + + + Enables the Map Gestures. + + +