Skip to content

Commit

Permalink
area markers with configurable visibility by side
Browse files Browse the repository at this point in the history
  • Loading branch information
Fusselwurm committed Apr 3, 2020
1 parent 8eff435 commit fea8d01
Show file tree
Hide file tree
Showing 9 changed files with 203 additions and 7 deletions.
2 changes: 2 additions & 0 deletions addons/area_markers/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ PREP(onMouseButtonDown);
PREP(onMouseButtonUp);
PREP(onMouseDblClick);
PREP(onMouseMoving);
PREP(updateAlpha);
PREP(updateIcon);
PREP(updateMarkerPos);
7 changes: 7 additions & 0 deletions addons/area_markers/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ if (isServer) then {
[QGVAR(deleteIcon), _marker] call CBA_fnc_globalEvent;
};
}] call CBA_fnc_addEventHandler;

#define SIDES_ARRAY_HASH [[], [east, west, independent, civilian]] call CBA_fnc_hashCreate;
ISNILS(GVAR(markerVisibilities), SIDES_ARRAY_HASH);
publicVariable QGVAR(markerVisibilities);
};

[QGVAR(updateAlpha), LINKFUNC(updateAlpha)] call CBA_fnc_addEventHandler;

if (hasInterface) then {
["zen_curatorDisplayLoaded", {
params ["_display"];
Expand Down Expand Up @@ -79,4 +85,5 @@ if (hasInterface) then {
[QGVAR(createIcon), LINKFUNC(createIcon)] call CBA_fnc_addEventHandler;
[QGVAR(deleteIcon), LINKFUNC(deleteIcon)] call CBA_fnc_addEventHandler;
[QGVAR(updateIcon), LINKFUNC(updateIcon)] call CBA_fnc_addEventHandler;
[QGVAR(updateMarkerPos), LINKFUNC(updateMarkerPos)] call CBA_fnc_addEventHandler;
};
14 changes: 13 additions & 1 deletion addons/area_markers/functions/fnc_applyProperties.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ _marker setMarkerColor _color;

private _ctrlAlphaSlider = _ctrlConfigure controlsGroupCtrl IDC_CONFIGURE_ALPHA_SLIDER;
private _alpha = sliderPosition _ctrlAlphaSlider;
_marker setMarkerAlpha _alpha;

[QGVAR(updateIcon), [_marker, _rotation, _color]] call CBA_fnc_globalEvent;

private _sidesControlGroup = _ctrlConfigure controlsGroupCtrl IDC_CONFIGURE_SIDEVISIBILITY;
private _sides = IDCS_CONFIGURE_SIDEVISIBILITY_ALL
apply { _sidesControlGroup controlsGroupCtrl _x }
apply {
if (_x getVariable [QGVAR(value), true])
then { _x getVariable [QGVAR(side), sideUnknown] }
else { sideUnknown }
}
select {
_x != sideUnknown
};
[QGVAR(updateAlpha), [_marker, _sides, _alpha]] call CBA_fnc_globalEvent;
35 changes: 35 additions & 0 deletions addons/area_markers/functions/fnc_configure.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,41 @@ private _ctrlAlphaSlider = _ctrlConfigure controlsGroupCtrl IDC_CONFIGURE_ALPHA_
private _ctrlAlphaEdit = _ctrlConfigure controlsGroupCtrl IDC_CONFIGURE_ALPHA_EDIT;
[_ctrlAlphaSlider, _ctrlAlphaEdit, 0, 1, markerAlpha _marker, 0.1, 0, true] call EFUNC(common,initSliderEdit);

call {
GVAR(configure_updateSideControl) = {
params [
["_control", controlNull],
["_isSet", true, [false, true]]
];

private _side = _control getVariable [QGVAR(side), sideUnknown];
private _color = [_side] call BIS_fnc_sideColor;
private _scale = 1;
private _alpha = 0.5;
if (_isSet) then {
_scale = 1.2;
_alpha = 1;
};
_control setVariable [QGVAR(value), _isSet];
_color set [3, _alpha];
_control ctrlSetTextColor _color;
[_control, _scale, 0] call BIS_fnc_ctrlSetScale;
};

private _selectedSides = [GVAR(markerVisibilities), _marker] call CBA_fnc_hashGet;
private _sidesControlGroup = _ctrlConfigure controlsGroupCtrl IDC_CONFIGURE_SIDEVISIBILITY;
{
private _control = _sidesControlGroup controlsGroupCtrl _x;
_control ctrlAddEventHandler ["ButtonClick", {
params ["_control"];
[_control, !(_control getVariable [QGVAR(value), true])] call GVAR(configure_updateSideControl);
}];
private _controlSide = _foreachindex call bis_fnc_sideType;
_control setVariable [QGVAR(side), _controlSide];
[_control, _controlSide in _selectedSides] call GVAR(configure_updateSideControl);
} forEach IDCS_CONFIGURE_SIDEVISIBILITY_ALL;
};

private _ctrlButtonCancel = _ctrlConfigure controlsGroupCtrl IDC_CONFIGURE_CANCEL;
_ctrlButtonCancel ctrlAddEventHandler ["ButtonClick", {
params ["_ctrlButtonCancel"];
Expand Down
3 changes: 2 additions & 1 deletion addons/area_markers/functions/fnc_onMouseButtonUp.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ params ["_ctrlMouse", "_button"];
if (_button == 0) then {
// Update position globally to the current local position once moving is finished
private _marker = ctrlParentControlsGroup _ctrlMouse getVariable [QGVAR(marker), ""];
_marker setMarkerPos markerPos _marker;

[QGVAR(updateMarkerPos), [_marker, markerPos _marker]] call CBA_fnc_globalEvent;

_ctrlMouse setVariable [QGVAR(moving), false];
};
34 changes: 34 additions & 0 deletions addons/area_markers/functions/fnc_updateAlpha.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "script_component.hpp"
/*
* Author: Fusselwurm
* Set the alpha of a marker depending on the player's side
*
* Arguments:
* 0: Marker <STRING>
* 1: Sides that may see the marker <ARRAY>
* 2: Alpha value to use for players of passed `sides`
*
* Return Value:
* None
*
* Example:
* ["marker_0", [west,civilian], 0.7] call zen_area_markers_fnc_updateAlpha
*
* Public: No
*/

params ["_marker", "_sides", "_alpha"];

if (isServer) exitWith {
[GVAR(markerVisibilities), _marker, _sides] call CBA_fnc_hashSet;
publicVariable QGVAR(markerVisibilities);
};

if (!hasInterface) exitWith {}; // ignore HCs

private _localAlpha = if (
(playerSide in _sides) ||
(!isNull (getAssignedCuratorLogic player)) // ZEUS should always see the markers!
) then { _alpha } else { 0 };

_marker setMarkerAlphaLocal _localAlpha;
21 changes: 21 additions & 0 deletions addons/area_markers/functions/fnc_updateMarkerPos.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "script_component.hpp"
/*
* Author: Fusselwurm
* Set the marker position locally
*
* Arguments:
* 0: Marker <STRING>
* 1: Marker position
*
* Return Value:
* None
*
* Example:
* ["marker_0", [3265.59,853.12]] call zen_area_markers_fnc_updatePos
*
* Public: No
*/

params ["_marker", "_pos"];

_marker setMarkerPosLocal _pos;
88 changes: 83 additions & 5 deletions addons/area_markers/gui.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class RscText;
class RscPicture;
class RscActivePicture;
class ctrlXSliderH;
class RscButtonMenuOK;
class RscButtonMenuCancel;
Expand Down Expand Up @@ -51,9 +52,9 @@ class GVAR(configure): RscControlsGroupNoScrollbars {
class Container: RscControlsGroupNoScrollbars {
idc = -1;
x = safeZoneWAbs / 2 - POS_W(13.5);
y = safeZoneH / 2 - POS_H(6.5);
y = safeZoneH / 2 - POS_H(8.55);
w = POS_W(27);
h = POS_H(13);
h = POS_H(17.1);
class controls {
class Title: RscText {
text = CSTRING(EditAreaMarker);
Expand All @@ -68,7 +69,7 @@ class GVAR(configure): RscControlsGroupNoScrollbars {
x = 0;
y = POS_H(1.1);
w = POS_W(27);
h = POS_H(10.8);
h = POS_H(17.8);
colorBackground[] = {0, 0, 0, 0.7};
};
class Transformation: RscControlsGroupNoScrollbars {
Expand Down Expand Up @@ -232,17 +233,94 @@ class GVAR(configure): RscControlsGroupNoScrollbars {
};
};
};
class SideVisibility: RscControlsGroupNoScrollbars {
idc = -1;
x = POS_W(0.5);
y = POS_H(11.6);
w = POS_W(26);
h = POS_H(4.1);
class controls {
class Title: EGVAR(common,RscLabel) {
text = "$STR_disp_arcunit_side";
w = POS_W(26);
};
class Background: EGVAR(common,RscBackground) {
x = 0;
y = POS_H(1);
w = POS_W(26);
h = POS_H(3);
};

class SideVisibilityIcons: RscControlsGroupNoScrollbars {
idc = IDC_CONFIGURE_SIDEVISIBILITY;
x = POS_W(3);
y = POS_H(1.1);
w = POS_W(20);
h = POS_H(3);
onSetFocus = "[_this,""RscAttributeOwners"",'CuratorCommon'] call (uinamespace getvariable ""BIS_fnc_initCuratorAttribute"")";
class controls {
class Background: RscText {
x = 0;
y = 0;
w = POS_W(20);
h = POS_H(2.9);
colorBackground[] = {0, 0, 0, 0.7};
};
class BLUFOR: RscActivePicture
{
idc=IDC_CONFIGURE_SIDEVISIBILITY_WEST;
text="\a3\Ui_F_Curator\Data\Displays\RscDisplayCurator\side_west_ca.paa";
x=POS_W(3);
y=POS_H(0.4);
w=POS_W(2);
h=POS_H(2);
tooltip="$STR_WEST";
};
class OPFOR: BLUFOR
{
idc=IDC_CONFIGURE_SIDEVISIBILITY_EAST;
text="\a3\Ui_F_Curator\Data\Displays\RscDisplayCurator\side_east_ca.paa";
x=POS_W(7);
y=POS_H(0.4);
w=POS_W(2);
h=POS_H(2);
tooltip="$STR_EAST";
};
class Independent: BLUFOR
{
idc=IDC_CONFIGURE_SIDEVISIBILITY_GUER;
text="\a3\Ui_F_Curator\Data\Displays\RscDisplayCurator\side_guer_ca.paa";
x=POS_W(11);
y=POS_H(0.4);
w=POS_W(2);
h=POS_H(2);
tooltip="$STR_guerrila";
};
class Civilian: BLUFOR
{
idc=IDC_CONFIGURE_SIDEVISIBILITY_CIV;
text="\a3\Ui_F_Curator\Data\Displays\RscDisplayCurator\side_civ_ca.paa";
x=POS_W(15);
y=POS_H(0.4);
w=POS_W(2);
h=POS_H(2);
tooltip="$STR_Civilian";
};
};
};
};
};
class ButtonOK: RscButtonMenuOK {
idc = IDC_CONFIGURE_OK;
x = POS_W(22);
y = POS_H(12);
y = POS_H(16.1);
w = POS_W(5);
h = POS_H(1);
};
class ButtonCancel: RscButtonMenuCancel {
idc = IDC_CONFIGURE_CANCEL;
x = 0;
y = POS_H(12);
y = POS_H(16.1);
w = POS_W(5);
h = POS_H(1);
};
Expand Down
6 changes: 6 additions & 0 deletions addons/area_markers/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,9 @@
#define IDC_CONFIGURE_ALPHA_EDIT 42879
#define IDC_CONFIGURE_OK 42880
#define IDC_CONFIGURE_CANCEL 428781
#define IDC_CONFIGURE_SIDEVISIBILITY 428782
#define IDC_CONFIGURE_SIDEVISIBILITY_WEST 428783
#define IDC_CONFIGURE_SIDEVISIBILITY_EAST 428784
#define IDC_CONFIGURE_SIDEVISIBILITY_GUER 428785
#define IDC_CONFIGURE_SIDEVISIBILITY_CIV 428786
#define IDCS_CONFIGURE_SIDEVISIBILITY_ALL [IDC_CONFIGURE_SIDEVISIBILITY_EAST, IDC_CONFIGURE_SIDEVISIBILITY_WEST, IDC_CONFIGURE_SIDEVISIBILITY_GUER, IDC_CONFIGURE_SIDEVISIBILITY_CIV]

0 comments on commit fea8d01

Please sign in to comment.