Skip to content

Commit

Permalink
Tagging - Minor improvements (#228)
Browse files Browse the repository at this point in the history
* Tagging - Improve marker creation

* Tagging - Improve color check performance

* Tagging - Add support for yellow and white colors
  • Loading branch information
veteran29 authored Nov 4, 2024
1 parent de6858e commit 30ba80b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions addons/common/functions/fnc_createPlayerMarker.sqf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "script_component.hpp"
/*
* Author: veteran29
* Create player owned marker.
* Create player owned marker locally.
*
* Arguments:
* 0: Marker position <ARRAY, OBJECT>
Expand Down Expand Up @@ -43,4 +43,4 @@ GVAR(playerMarkerIdx) = GVAR(playerMarkerIdx) + 1;

private _markerId = format ["_USER_DEFINED #%1/%2/%3", getPlayerID _player, _id, _channel];

createMarker [_markerId, _position, _channel, _player] // return
createMarkerLocal [_markerId, _position, _channel, _player] // return
13 changes: 6 additions & 7 deletions addons/tagging/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@ if (hasInterface) then {
// Check if tag created on building by local player
if (!(_object isKindOf "Building") || {_unit isNotEqualTo player}) exitWith {};

private _colorIndex = {
if (_texture find _x != -1) exitWith {_forEachIndex};
-1
} forEach TEXTURE_COLORS;
private _colorIndex = TEXTURE_COLORS findIf {toLower _texture find _x != -1};

// no matching color, do not create marker
if (_colorIndex == -1) exitWith {};
if (_colorIndex == -1) exitWith {
WARNING_1("Unsupported tag color %1",_texture);
};

private _marker = [_object, "side", _unit] call EFUNC(common,createPlayerMarker);
_marker setMarkerShape "ICON";
_marker setMarkerType "hd_dot";
_marker setMarkerShapeLocal "ICON";
_marker setMarkerTypeLocal "hd_dot";
_marker setMarkerColor (MARKER_COLORS select _colorIndex);

}] call CBA_fnc_addEventHandler;
Expand Down
4 changes: 2 additions & 2 deletions addons/tagging/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@

#include "\z\afm\addons\main\script_macros.hpp"

#define MARKER_COLORS ["ColorRed", "ColorGreen", "ColorBlue", "ColorBlack"]
#define TEXTURE_COLORS ["red", "green", "blue", "black"]
#define MARKER_COLORS ["ColorRed", "ColorGreen", "ColorBlue", "ColorBlack", "ColorYellow", "ColorWhite"]
#define TEXTURE_COLORS ["red", "green", "blue", "black", "yellow", "white"]

0 comments on commit 30ba80b

Please sign in to comment.