Skip to content

Commit d94d8e2

Browse files
committed
area markers with configurable visibility by side
1 parent 8eff435 commit d94d8e2

9 files changed

+203
-7
lines changed

addons/area_markers/XEH_PREP.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ PREP(onMouseButtonDown);
99
PREP(onMouseButtonUp);
1010
PREP(onMouseDblClick);
1111
PREP(onMouseMoving);
12+
PREP(updateAlpha);
1213
PREP(updateIcon);
14+
PREP(updateMarkerPos);

addons/area_markers/XEH_postInit.sqf

+7
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@ if (isServer) then {
3030
[QGVAR(deleteIcon), _marker] call CBA_fnc_globalEvent;
3131
};
3232
}] call CBA_fnc_addEventHandler;
33+
34+
#define SIDES_ARRAY_HASH [[], [east, west, independent, civilian]] call CBA_fnc_hashCreate;
35+
ISNILS(GVAR(markerVisibilities), SIDES_ARRAY_HASH);
36+
publicVariable QGVAR(markerVisibilities);
3337
};
3438

39+
[QGVAR(updateAlpha), LINKFUNC(updateAlpha)] call CBA_fnc_addEventHandler;
40+
3541
if (hasInterface) then {
3642
["zen_curatorDisplayLoaded", {
3743
params ["_display"];
@@ -79,4 +85,5 @@ if (hasInterface) then {
7985
[QGVAR(createIcon), LINKFUNC(createIcon)] call CBA_fnc_addEventHandler;
8086
[QGVAR(deleteIcon), LINKFUNC(deleteIcon)] call CBA_fnc_addEventHandler;
8187
[QGVAR(updateIcon), LINKFUNC(updateIcon)] call CBA_fnc_addEventHandler;
88+
[QGVAR(updateMarkerPos), LINKFUNC(updateMarkerPos)] call CBA_fnc_addEventHandler;
8289
};

addons/area_markers/functions/fnc_applyProperties.sqf

+13-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ _marker setMarkerColor _color;
4141

4242
private _ctrlAlphaSlider = _ctrlConfigure controlsGroupCtrl IDC_CONFIGURE_ALPHA_SLIDER;
4343
private _alpha = sliderPosition _ctrlAlphaSlider;
44-
_marker setMarkerAlpha _alpha;
4544

4645
[QGVAR(updateIcon), [_marker, _rotation, _color]] call CBA_fnc_globalEvent;
46+
47+
private _sidesControlGroup = _ctrlConfigure controlsGroupCtrl IDC_CONFIGURE_SIDEVISIBILITY;
48+
private _sides = IDCS_CONFIGURE_SIDEVISIBILITY_ALL
49+
apply { _sidesControlGroup controlsGroupCtrl _x }
50+
apply {
51+
if (_x getVariable [QGVAR(value), true])
52+
then { _x getVariable [QGVAR(side), sideUnknown] }
53+
else { sideUnknown }
54+
}
55+
select {
56+
_x != sideUnknown
57+
};
58+
[QGVAR(updateAlpha), [_marker, _sides, _alpha]] call CBA_fnc_globalEvent;

addons/area_markers/functions/fnc_configure.sqf

+35
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,41 @@ private _ctrlAlphaSlider = _ctrlConfigure controlsGroupCtrl IDC_CONFIGURE_ALPHA_
9393
private _ctrlAlphaEdit = _ctrlConfigure controlsGroupCtrl IDC_CONFIGURE_ALPHA_EDIT;
9494
[_ctrlAlphaSlider, _ctrlAlphaEdit, 0, 1, markerAlpha _marker, 0.1, 0, true] call EFUNC(common,initSliderEdit);
9595

96+
call {
97+
GVAR(configure_updateSideControl) = {
98+
params [
99+
["_control", controlNull],
100+
["_isSet", true, [false, true]]
101+
];
102+
103+
private _side = _control getVariable [QGVAR(side), sideUnknown];
104+
private _color = [_side] call BIS_fnc_sideColor;
105+
private _scale = 1;
106+
private _alpha = 0.5;
107+
if (_isSet) then {
108+
_scale = 1.2;
109+
_alpha = 1;
110+
};
111+
_control setVariable [QGVAR(value), _isSet];
112+
_color set [3, _alpha];
113+
_control ctrlSetTextColor _color;
114+
[_control, _scale, 0] call BIS_fnc_ctrlSetScale;
115+
};
116+
117+
private _selectedSides = [GVAR(markerVisibilities), _marker] call CBA_fnc_hashGet;
118+
private _sidesControlGroup = _ctrlConfigure controlsGroupCtrl IDC_CONFIGURE_SIDEVISIBILITY;
119+
{
120+
private _control = _sidesControlGroup controlsGroupCtrl _x;
121+
_control ctrlAddEventHandler ["ButtonClick", {
122+
params ["_control"];
123+
[_control, !(_control getVariable [QGVAR(value), true])] call GVAR(configure_updateSideControl);
124+
}];
125+
private _controlSide = _foreachindex call bis_fnc_sideType;
126+
_control setVariable [QGVAR(side), _controlSide];
127+
[_control, _controlSide in _selectedSides] call GVAR(configure_updateSideControl);
128+
} forEach IDCS_CONFIGURE_SIDEVISIBILITY_ALL;
129+
};
130+
96131
private _ctrlButtonCancel = _ctrlConfigure controlsGroupCtrl IDC_CONFIGURE_CANCEL;
97132
_ctrlButtonCancel ctrlAddEventHandler ["ButtonClick", {
98133
params ["_ctrlButtonCancel"];

addons/area_markers/functions/fnc_onMouseButtonUp.sqf

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ params ["_ctrlMouse", "_button"];
2121
if (_button == 0) then {
2222
// Update position globally to the current local position once moving is finished
2323
private _marker = ctrlParentControlsGroup _ctrlMouse getVariable [QGVAR(marker), ""];
24-
_marker setMarkerPos markerPos _marker;
24+
25+
[QGVAR(updateMarkerPos), [_marker, markerPos _marker]] call CBA_fnc_globalEvent;
2526

2627
_ctrlMouse setVariable [QGVAR(moving), false];
2728
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include "script_component.hpp"
2+
/*
3+
* Author: Fusselwurm
4+
* Set the alpha of a marker depending on the player's side
5+
*
6+
* Arguments:
7+
* 0: Marker <STRING>
8+
* 1: Sides that may see the marker <ARRAY>
9+
* 2: Alpha value to use for players of passed `sides`
10+
*
11+
* Return Value:
12+
* None
13+
*
14+
* Example:
15+
* ["marker_0", [west,civilian], 0.7] call zen_area_markers_fnc_updateAlpha
16+
*
17+
* Public: No
18+
*/
19+
20+
params ["_marker", "_sides", "_alpha"];
21+
22+
if (isServer) exitWith {
23+
[GVAR(markerVisibilities), _marker, _sides] call CBA_fnc_hashSet;
24+
publicVariable QGVAR(markerVisibilities);
25+
};
26+
27+
if (!hasInterface) exitWith {}; // ignore HCs
28+
29+
private _localAlpha = if (
30+
(playerSide in _sides) ||
31+
(!isNull (getAssignedCuratorLogic player)) // ZEUS should always see the markers!
32+
) then { _alpha } else { 0 };
33+
34+
_marker setMarkerAlphaLocal _localAlpha;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include "script_component.hpp"
2+
/*
3+
* Author: Fusselwurm
4+
* Set the marker position locally
5+
*
6+
* Arguments:
7+
* 0: Marker <STRING>
8+
* 1: Marker position
9+
*
10+
* Return Value:
11+
* None
12+
*
13+
* Example:
14+
* ["marker_0", [3265.59,853.12]] call zen_area_markers_fnc_updateMarkerPos
15+
*
16+
* Public: No
17+
*/
18+
19+
params ["_marker", "_pos"];
20+
21+
_marker setMarkerPosLocal _pos;

addons/area_markers/gui.hpp

+83-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class RscText;
22
class RscPicture;
3+
class RscActivePicture;
34
class ctrlXSliderH;
45
class RscButtonMenuOK;
56
class RscButtonMenuCancel;
@@ -51,9 +52,9 @@ class GVAR(configure): RscControlsGroupNoScrollbars {
5152
class Container: RscControlsGroupNoScrollbars {
5253
idc = -1;
5354
x = safeZoneWAbs / 2 - POS_W(13.5);
54-
y = safeZoneH / 2 - POS_H(6.5);
55+
y = safeZoneH / 2 - POS_H(8.55);
5556
w = POS_W(27);
56-
h = POS_H(13);
57+
h = POS_H(17.1);
5758
class controls {
5859
class Title: RscText {
5960
text = CSTRING(EditAreaMarker);
@@ -68,7 +69,7 @@ class GVAR(configure): RscControlsGroupNoScrollbars {
6869
x = 0;
6970
y = POS_H(1.1);
7071
w = POS_W(27);
71-
h = POS_H(10.8);
72+
h = POS_H(17.8);
7273
colorBackground[] = {0, 0, 0, 0.7};
7374
};
7475
class Transformation: RscControlsGroupNoScrollbars {
@@ -232,17 +233,94 @@ class GVAR(configure): RscControlsGroupNoScrollbars {
232233
};
233234
};
234235
};
236+
class SideVisibility: RscControlsGroupNoScrollbars {
237+
idc = -1;
238+
x = POS_W(0.5);
239+
y = POS_H(11.6);
240+
w = POS_W(26);
241+
h = POS_H(4.1);
242+
class controls {
243+
class Title: EGVAR(common,RscLabel) {
244+
text = "$STR_disp_arcunit_side";
245+
w = POS_W(26);
246+
};
247+
class Background: EGVAR(common,RscBackground) {
248+
x = 0;
249+
y = POS_H(1);
250+
w = POS_W(26);
251+
h = POS_H(3);
252+
};
253+
254+
class SideVisibilityIcons: RscControlsGroupNoScrollbars {
255+
idc = IDC_CONFIGURE_SIDEVISIBILITY;
256+
x = POS_W(3);
257+
y = POS_H(1.1);
258+
w = POS_W(20);
259+
h = POS_H(3);
260+
onSetFocus = "[_this,""RscAttributeOwners"",'CuratorCommon'] call (uinamespace getvariable ""BIS_fnc_initCuratorAttribute"")";
261+
class controls {
262+
class Background: RscText {
263+
x = 0;
264+
y = 0;
265+
w = POS_W(20);
266+
h = POS_H(2.9);
267+
colorBackground[] = {0, 0, 0, 0.7};
268+
};
269+
class BLUFOR: RscActivePicture
270+
{
271+
idc=IDC_CONFIGURE_SIDEVISIBILITY_WEST;
272+
text="\a3\Ui_F_Curator\Data\Displays\RscDisplayCurator\side_west_ca.paa";
273+
x=POS_W(3);
274+
y=POS_H(0.4);
275+
w=POS_W(2);
276+
h=POS_H(2);
277+
tooltip="$STR_WEST";
278+
};
279+
class OPFOR: BLUFOR
280+
{
281+
idc=IDC_CONFIGURE_SIDEVISIBILITY_EAST;
282+
text="\a3\Ui_F_Curator\Data\Displays\RscDisplayCurator\side_east_ca.paa";
283+
x=POS_W(7);
284+
y=POS_H(0.4);
285+
w=POS_W(2);
286+
h=POS_H(2);
287+
tooltip="$STR_EAST";
288+
};
289+
class Independent: BLUFOR
290+
{
291+
idc=IDC_CONFIGURE_SIDEVISIBILITY_GUER;
292+
text="\a3\Ui_F_Curator\Data\Displays\RscDisplayCurator\side_guer_ca.paa";
293+
x=POS_W(11);
294+
y=POS_H(0.4);
295+
w=POS_W(2);
296+
h=POS_H(2);
297+
tooltip="$STR_guerrila";
298+
};
299+
class Civilian: BLUFOR
300+
{
301+
idc=IDC_CONFIGURE_SIDEVISIBILITY_CIV;
302+
text="\a3\Ui_F_Curator\Data\Displays\RscDisplayCurator\side_civ_ca.paa";
303+
x=POS_W(15);
304+
y=POS_H(0.4);
305+
w=POS_W(2);
306+
h=POS_H(2);
307+
tooltip="$STR_Civilian";
308+
};
309+
};
310+
};
311+
};
312+
};
235313
class ButtonOK: RscButtonMenuOK {
236314
idc = IDC_CONFIGURE_OK;
237315
x = POS_W(22);
238-
y = POS_H(12);
316+
y = POS_H(16.1);
239317
w = POS_W(5);
240318
h = POS_H(1);
241319
};
242320
class ButtonCancel: RscButtonMenuCancel {
243321
idc = IDC_CONFIGURE_CANCEL;
244322
x = 0;
245-
y = POS_H(12);
323+
y = POS_H(16.1);
246324
w = POS_W(5);
247325
h = POS_H(1);
248326
};

addons/area_markers/script_component.hpp

+6
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,9 @@
5454
#define IDC_CONFIGURE_ALPHA_EDIT 42879
5555
#define IDC_CONFIGURE_OK 42880
5656
#define IDC_CONFIGURE_CANCEL 428781
57+
#define IDC_CONFIGURE_SIDEVISIBILITY 428782
58+
#define IDC_CONFIGURE_SIDEVISIBILITY_WEST 428783
59+
#define IDC_CONFIGURE_SIDEVISIBILITY_EAST 428784
60+
#define IDC_CONFIGURE_SIDEVISIBILITY_GUER 428785
61+
#define IDC_CONFIGURE_SIDEVISIBILITY_CIV 428786
62+
#define IDCS_CONFIGURE_SIDEVISIBILITY_ALL [IDC_CONFIGURE_SIDEVISIBILITY_EAST, IDC_CONFIGURE_SIDEVISIBILITY_WEST, IDC_CONFIGURE_SIDEVISIBILITY_GUER, IDC_CONFIGURE_SIDEVISIBILITY_CIV]

0 commit comments

Comments
 (0)