Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: area marker visibility by player side #342

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
21 changes: 21 additions & 0 deletions addons/area_markers/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,17 @@ 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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use new 2.02 hash map

ISNILS(GVAR(markerVisibilities), SIDES_ARRAY_HASH);
publicVariable QGVAR(markerVisibilities);

ISNILS(GVAR(markerAlphas), call CBA_fnc_hashCreate);
publicVariable QGVAR(markerAlphas);
};

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

if (hasInterface) then {
["zen_curatorDisplayLoaded", {
params ["_display"];
Expand All @@ -55,6 +64,10 @@ if (hasInterface) then {
} forEach GVAR(markers);
} call CBA_fnc_execNextFrame;

[GVAR(markerAlphas), {
_key setMarkerAlphaLocal _value;
}] call CBA_fnc_hashEachPair;

// Add PFH to update visibility of area marker icons
GVAR(visiblePFH) = [{
params ["_args"];
Expand All @@ -74,9 +87,17 @@ if (hasInterface) then {

["zen_curatorDisplayUnloaded", {
GVAR(visiblePFH) call CBA_fnc_removePerFrameHandler;

[GVAR(markerVisibilities), {
if (!((side player) in _value)) then {
_key setMarkerAlphaLocal 0;
};
}] call CBA_fnc_hashEachPair;

}] call CBA_fnc_addEventHandler;

[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_globalEventJIP;
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);


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];
};
38 changes: 38 additions & 0 deletions addons/area_markers/functions/fnc_updateAlpha.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#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` <SCALAR>
*
* Return Value:
* None
*
* Example:
* ["marker_0", [west, civilian], 0.7] call zen_area_markers_fnc_updateAlpha
*
* Public: No
*/

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

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

if (hasInterface) then {
private _isVisibleSide = (side player) in _sides;
private _isZeus = !isNull curatorCamera;

if (_isVisibleSide || _isZeus) then {
_marker setMarkerAlphaLocal _alpha;
} else {
_marker setMarkerAlphaLocal 0;
};
};
20 changes: 20 additions & 0 deletions addons/area_markers/functions/fnc_updateMarkerPos.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Author: Fusselwurm
* Set the marker position locally.
*
* Arguments:
* 0: Marker <STRING>
* 1: Marker position <ARRAY>
*
* Return Value:
* None
*
* Example:
* ["marker_0", [3265.59, 853.12]] call zen_area_markers_fnc_updateMarkerPos
*
* 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]