From d94d8e2f9c4d642f47fb1928d295861c7f0961d0 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Tue, 24 Mar 2020 23:53:45 +0100 Subject: [PATCH 01/14] area markers with configurable visibility by side --- addons/area_markers/XEH_PREP.hpp | 2 + addons/area_markers/XEH_postInit.sqf | 7 ++ .../functions/fnc_applyProperties.sqf | 14 ++- .../area_markers/functions/fnc_configure.sqf | 35 ++++++++ .../functions/fnc_onMouseButtonUp.sqf | 3 +- .../functions/fnc_updateAlpha.sqf | 34 +++++++ .../functions/fnc_updateMarkerPos.sqf | 21 +++++ addons/area_markers/gui.hpp | 88 +++++++++++++++++-- addons/area_markers/script_component.hpp | 6 ++ 9 files changed, 203 insertions(+), 7 deletions(-) create mode 100644 addons/area_markers/functions/fnc_updateAlpha.sqf create mode 100644 addons/area_markers/functions/fnc_updateMarkerPos.sqf diff --git a/addons/area_markers/XEH_PREP.hpp b/addons/area_markers/XEH_PREP.hpp index 89f30f795..dda0bdf40 100644 --- a/addons/area_markers/XEH_PREP.hpp +++ b/addons/area_markers/XEH_PREP.hpp @@ -9,4 +9,6 @@ PREP(onMouseButtonDown); PREP(onMouseButtonUp); PREP(onMouseDblClick); PREP(onMouseMoving); +PREP(updateAlpha); PREP(updateIcon); +PREP(updateMarkerPos); diff --git a/addons/area_markers/XEH_postInit.sqf b/addons/area_markers/XEH_postInit.sqf index 47d48a4e8..a0c4952d0 100644 --- a/addons/area_markers/XEH_postInit.sqf +++ b/addons/area_markers/XEH_postInit.sqf @@ -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"]; @@ -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; }; diff --git a/addons/area_markers/functions/fnc_applyProperties.sqf b/addons/area_markers/functions/fnc_applyProperties.sqf index dd7688eee..7d32a7f10 100644 --- a/addons/area_markers/functions/fnc_applyProperties.sqf +++ b/addons/area_markers/functions/fnc_applyProperties.sqf @@ -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; diff --git a/addons/area_markers/functions/fnc_configure.sqf b/addons/area_markers/functions/fnc_configure.sqf index 741ea3399..8f1e2565d 100644 --- a/addons/area_markers/functions/fnc_configure.sqf +++ b/addons/area_markers/functions/fnc_configure.sqf @@ -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"]; diff --git a/addons/area_markers/functions/fnc_onMouseButtonUp.sqf b/addons/area_markers/functions/fnc_onMouseButtonUp.sqf index 1821ae83b..2ae7e7b02 100644 --- a/addons/area_markers/functions/fnc_onMouseButtonUp.sqf +++ b/addons/area_markers/functions/fnc_onMouseButtonUp.sqf @@ -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]; }; diff --git a/addons/area_markers/functions/fnc_updateAlpha.sqf b/addons/area_markers/functions/fnc_updateAlpha.sqf new file mode 100644 index 000000000..e7743f494 --- /dev/null +++ b/addons/area_markers/functions/fnc_updateAlpha.sqf @@ -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 + * 1: Sides that may see the marker + * 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; diff --git a/addons/area_markers/functions/fnc_updateMarkerPos.sqf b/addons/area_markers/functions/fnc_updateMarkerPos.sqf new file mode 100644 index 000000000..fceeda2b6 --- /dev/null +++ b/addons/area_markers/functions/fnc_updateMarkerPos.sqf @@ -0,0 +1,21 @@ +#include "script_component.hpp" +/* + * Author: Fusselwurm + * Set the marker position locally + * + * Arguments: + * 0: Marker + * 1: Marker position + * + * Return Value: + * None + * + * Example: + * ["marker_0", [3265.59,853.12]] call zen_area_markers_fnc_updateMarkerPos + * + * Public: No + */ + +params ["_marker", "_pos"]; + +_marker setMarkerPosLocal _pos; diff --git a/addons/area_markers/gui.hpp b/addons/area_markers/gui.hpp index db12c0f29..1b60fbf41 100644 --- a/addons/area_markers/gui.hpp +++ b/addons/area_markers/gui.hpp @@ -1,5 +1,6 @@ class RscText; class RscPicture; +class RscActivePicture; class ctrlXSliderH; class RscButtonMenuOK; class RscButtonMenuCancel; @@ -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); @@ -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 { @@ -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); }; diff --git a/addons/area_markers/script_component.hpp b/addons/area_markers/script_component.hpp index b769f549d..a830482d7 100644 --- a/addons/area_markers/script_component.hpp +++ b/addons/area_markers/script_component.hpp @@ -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] From 5bc54b511d4b38fd0b63d051d600792e0de28115 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Mon, 6 Apr 2020 10:16:20 +0200 Subject: [PATCH 02/14] Update addons/area_markers/functions/fnc_applyProperties.sqf Co-Authored-By: Ralfs Garkaklis --- addons/area_markers/functions/fnc_applyProperties.sqf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/area_markers/functions/fnc_applyProperties.sqf b/addons/area_markers/functions/fnc_applyProperties.sqf index 7d32a7f10..a02b64a94 100644 --- a/addons/area_markers/functions/fnc_applyProperties.sqf +++ b/addons/area_markers/functions/fnc_applyProperties.sqf @@ -48,9 +48,9 @@ private _sidesControlGroup = _ctrlConfigure controlsGroupCtrl IDC_CONFIGURE_SIDE 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 } + if (_x getVariable [QGVAR(value), true]) then { + _x getVariable [QGVAR(side), sideUnknown] + } else { sideUnknown }; } select { _x != sideUnknown From 9c50679bfd9856637e0b391e9658de086f442884 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Mon, 6 Apr 2020 10:16:56 +0200 Subject: [PATCH 03/14] Update addons/area_markers/functions/fnc_updateAlpha.sqf Co-Authored-By: Ralfs Garkaklis --- addons/area_markers/functions/fnc_updateAlpha.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/area_markers/functions/fnc_updateAlpha.sqf b/addons/area_markers/functions/fnc_updateAlpha.sqf index e7743f494..5a5dce097 100644 --- a/addons/area_markers/functions/fnc_updateAlpha.sqf +++ b/addons/area_markers/functions/fnc_updateAlpha.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: Fusselwurm - * Set the alpha of a marker depending on the player's side + * Set the alpha of a marker depending on the player's side. * * Arguments: * 0: Marker From 944a3cf8aae347ce20681050f6e4e73ecacee481 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Mon, 6 Apr 2020 10:20:17 +0200 Subject: [PATCH 04/14] Update addons/area_markers/functions/fnc_updateAlpha.sqf Co-Authored-By: Ralfs Garkaklis --- addons/area_markers/functions/fnc_updateAlpha.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/area_markers/functions/fnc_updateAlpha.sqf b/addons/area_markers/functions/fnc_updateAlpha.sqf index 5a5dce097..642ed1ca2 100644 --- a/addons/area_markers/functions/fnc_updateAlpha.sqf +++ b/addons/area_markers/functions/fnc_updateAlpha.sqf @@ -12,7 +12,7 @@ * None * * Example: - * ["marker_0", [west,civilian], 0.7] call zen_area_markers_fnc_updateAlpha + * ["marker_0", [west, civilian], 0.7] call zen_area_markers_fnc_updateAlpha * * Public: No */ From b60d19370d389b46451c803302e6ed25a03bba19 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Mon, 6 Apr 2020 10:20:25 +0200 Subject: [PATCH 05/14] Update addons/area_markers/functions/fnc_updateMarkerPos.sqf Co-Authored-By: Ralfs Garkaklis --- addons/area_markers/functions/fnc_updateMarkerPos.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/area_markers/functions/fnc_updateMarkerPos.sqf b/addons/area_markers/functions/fnc_updateMarkerPos.sqf index fceeda2b6..96320c009 100644 --- a/addons/area_markers/functions/fnc_updateMarkerPos.sqf +++ b/addons/area_markers/functions/fnc_updateMarkerPos.sqf @@ -11,7 +11,7 @@ * None * * Example: - * ["marker_0", [3265.59,853.12]] call zen_area_markers_fnc_updateMarkerPos + * ["marker_0", [3265.59, 853.12]] call zen_area_markers_fnc_updateMarkerPos * * Public: No */ From 81f1febfda33ccf291c63283390ebf3e365623c7 Mon Sep 17 00:00:00 2001 From: Ralfs Garkaklis Date: Mon, 6 Apr 2020 11:23:15 +0300 Subject: [PATCH 06/14] Update addons/area_markers/functions/fnc_applyProperties.sqf --- addons/area_markers/functions/fnc_applyProperties.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/area_markers/functions/fnc_applyProperties.sqf b/addons/area_markers/functions/fnc_applyProperties.sqf index a02b64a94..f9104c38d 100644 --- a/addons/area_markers/functions/fnc_applyProperties.sqf +++ b/addons/area_markers/functions/fnc_applyProperties.sqf @@ -49,7 +49,7 @@ private _sides = IDCS_CONFIGURE_SIDEVISIBILITY_ALL apply { _sidesControlGroup controlsGroupCtrl _x } apply { if (_x getVariable [QGVAR(value), true]) then { - _x getVariable [QGVAR(side), sideUnknown] + _x getVariable [QGVAR(side), sideUnknown] } else { sideUnknown }; } select { From 764cd1a20f2c8f56f04aa20bfc0eb4d748489af2 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Mon, 6 Apr 2020 10:42:08 +0200 Subject: [PATCH 07/14] code style --- addons/area_markers/functions/fnc_updateAlpha.sqf | 15 ++++++++------- .../functions/fnc_updateMarkerPos.sqf | 5 ++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/addons/area_markers/functions/fnc_updateAlpha.sqf b/addons/area_markers/functions/fnc_updateAlpha.sqf index 642ed1ca2..f0b9ac99a 100644 --- a/addons/area_markers/functions/fnc_updateAlpha.sqf +++ b/addons/area_markers/functions/fnc_updateAlpha.sqf @@ -6,7 +6,7 @@ * Arguments: * 0: Marker * 1: Sides that may see the marker - * 2: Alpha value to use for players of passed `sides` + * 2: Alpha value to use for players of passed `sides` * * Return Value: * None @@ -26,9 +26,10 @@ if (isServer) exitWith { 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; +private _isVisibleSide = playerSide in _sides; +private _isZeus = !isNull (getAssignedCuratorLogic player); +if (_isVisibleSide || _isZeus) then { + _marker setMarkerAlphaLocal _alpha; +} else { + _marker setMarkerAlphaLocal 0; +}; diff --git a/addons/area_markers/functions/fnc_updateMarkerPos.sqf b/addons/area_markers/functions/fnc_updateMarkerPos.sqf index 96320c009..14f742cd0 100644 --- a/addons/area_markers/functions/fnc_updateMarkerPos.sqf +++ b/addons/area_markers/functions/fnc_updateMarkerPos.sqf @@ -1,11 +1,10 @@ -#include "script_component.hpp" /* * Author: Fusselwurm - * Set the marker position locally + * Set the marker position locally. * * Arguments: * 0: Marker - * 1: Marker position + * 1: Marker position * * Return Value: * None From 200521102a180f990914a6442d479bcdb2aab0cb Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Mon, 6 Apr 2020 10:44:50 +0200 Subject: [PATCH 08/14] remove unnecessary closure --- .../area_markers/functions/fnc_configure.sqf | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/addons/area_markers/functions/fnc_configure.sqf b/addons/area_markers/functions/fnc_configure.sqf index 8f1e2565d..7275a90a3 100644 --- a/addons/area_markers/functions/fnc_configure.sqf +++ b/addons/area_markers/functions/fnc_configure.sqf @@ -93,41 +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; +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"]; From 296e8366b92033162ec2a6aea9cf43125ea86f5f Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Mon, 6 Apr 2020 11:30:40 +0200 Subject: [PATCH 09/14] add a newline for readability --- addons/area_markers/functions/fnc_updateAlpha.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/area_markers/functions/fnc_updateAlpha.sqf b/addons/area_markers/functions/fnc_updateAlpha.sqf index f0b9ac99a..96c5f0ac1 100644 --- a/addons/area_markers/functions/fnc_updateAlpha.sqf +++ b/addons/area_markers/functions/fnc_updateAlpha.sqf @@ -28,6 +28,7 @@ if (!hasInterface) exitWith {}; // ignore HCs private _isVisibleSide = playerSide in _sides; private _isZeus = !isNull (getAssignedCuratorLogic player); + if (_isVisibleSide || _isZeus) then { _marker setMarkerAlphaLocal _alpha; } else { From 2972decab24212351781b1c47fb690180358fff7 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Wed, 8 Apr 2020 15:52:43 +0200 Subject: [PATCH 10/14] Update addons/area_markers/functions/fnc_updateAlpha.sqf Co-Authored-By: Ralfs Garkaklis --- addons/area_markers/functions/fnc_updateAlpha.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/area_markers/functions/fnc_updateAlpha.sqf b/addons/area_markers/functions/fnc_updateAlpha.sqf index 96c5f0ac1..7889209aa 100644 --- a/addons/area_markers/functions/fnc_updateAlpha.sqf +++ b/addons/area_markers/functions/fnc_updateAlpha.sqf @@ -24,7 +24,7 @@ if (isServer) exitWith { publicVariable QGVAR(markerVisibilities); }; -if (!hasInterface) exitWith {}; // ignore HCs +if (ZEN_isHC) exitWith {}; private _isVisibleSide = playerSide in _sides; private _isZeus = !isNull (getAssignedCuratorLogic player); From 3901cac5feeae15fb756d88f0f98d84b2862a7e0 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Thu, 23 Jul 2020 16:04:13 +0200 Subject: [PATCH 11/14] even to Zeus, force-show markers in curatorCam only --- addons/area_markers/XEH_postInit.sqf | 15 +++++++++++++++ addons/area_markers/functions/fnc_updateAlpha.sqf | 7 +++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/addons/area_markers/XEH_postInit.sqf b/addons/area_markers/XEH_postInit.sqf index a0c4952d0..44673257c 100644 --- a/addons/area_markers/XEH_postInit.sqf +++ b/addons/area_markers/XEH_postInit.sqf @@ -34,6 +34,10 @@ if (isServer) then { #define SIDES_ARRAY_HASH [[], [east, west, independent, civilian]] call CBA_fnc_hashCreate; ISNILS(GVAR(markerVisibilities), SIDES_ARRAY_HASH); publicVariable QGVAR(markerVisibilities); + + #define ALPHAS_HASH [[], 1] call CBA_fnc_hashCreate; + ISNILS(GVAR(markerAlphas), ALPHAS_HASH); + publicVariable QGVAR(markerAlphas); }; [QGVAR(updateAlpha), LINKFUNC(updateAlpha)] call CBA_fnc_addEventHandler; @@ -61,6 +65,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"]; @@ -80,6 +88,13 @@ 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; diff --git a/addons/area_markers/functions/fnc_updateAlpha.sqf b/addons/area_markers/functions/fnc_updateAlpha.sqf index 7889209aa..a4d3567b5 100644 --- a/addons/area_markers/functions/fnc_updateAlpha.sqf +++ b/addons/area_markers/functions/fnc_updateAlpha.sqf @@ -22,12 +22,15 @@ params ["_marker", "_sides", "_alpha"]; if (isServer) exitWith { [GVAR(markerVisibilities), _marker, _sides] call CBA_fnc_hashSet; publicVariable QGVAR(markerVisibilities); + [GVAR(markerAlphas), _marker, _alpha] call CBA_fnc_hashSet; + publicVariable QGVAR(markerAlphas); + }; if (ZEN_isHC) exitWith {}; -private _isVisibleSide = playerSide in _sides; -private _isZeus = !isNull (getAssignedCuratorLogic player); +private _isVisibleSide = (side player) in _sides; +private _isZeus = !isNull curatorCamera; if (_isVisibleSide || _isZeus) then { _marker setMarkerAlphaLocal _alpha; From e6e432343810b7c6e9112d931f34979b0b208b5b Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Thu, 23 Jul 2020 16:49:17 +0200 Subject: [PATCH 12/14] dont break in SP --- .../functions/fnc_updateAlpha.sqf | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/addons/area_markers/functions/fnc_updateAlpha.sqf b/addons/area_markers/functions/fnc_updateAlpha.sqf index a4d3567b5..139b9d870 100644 --- a/addons/area_markers/functions/fnc_updateAlpha.sqf +++ b/addons/area_markers/functions/fnc_updateAlpha.sqf @@ -19,21 +19,20 @@ params ["_marker", "_sides", "_alpha"]; -if (isServer) exitWith { +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 (ZEN_isHC) exitWith {}; - -private _isVisibleSide = (side player) in _sides; -private _isZeus = !isNull curatorCamera; +if (hasInterface) then { + private _isVisibleSide = (side player) in _sides; + private _isZeus = !isNull curatorCamera; -if (_isVisibleSide || _isZeus) then { - _marker setMarkerAlphaLocal _alpha; -} else { - _marker setMarkerAlphaLocal 0; + if (_isVisibleSide || _isZeus) then { + _marker setMarkerAlphaLocal _alpha; + } else { + _marker setMarkerAlphaLocal 0; + }; }; From c5967d20da28ee86a054dfe63f2dada0c44b8e21 Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Thu, 23 Jul 2020 17:05:12 +0200 Subject: [PATCH 13/14] use JIP event for area_marker alpha changes As all alpha changes are done locally, JIP players would not get the updated values. --- addons/area_markers/functions/fnc_applyProperties.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/area_markers/functions/fnc_applyProperties.sqf b/addons/area_markers/functions/fnc_applyProperties.sqf index f9104c38d..0b663cb1b 100644 --- a/addons/area_markers/functions/fnc_applyProperties.sqf +++ b/addons/area_markers/functions/fnc_applyProperties.sqf @@ -55,4 +55,4 @@ private _sides = IDCS_CONFIGURE_SIDEVISIBILITY_ALL select { _x != sideUnknown }; -[QGVAR(updateAlpha), [_marker, _sides, _alpha]] call CBA_fnc_globalEvent; +[QGVAR(updateAlpha), [_marker, _sides, _alpha]] call CBA_fnc_globalEventJIP; From ecccc6e01b0a4af469e4e5e5c1ba1011202a00ea Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Thu, 23 Jul 2020 17:44:57 +0200 Subject: [PATCH 14/14] do not set default value for CBA hash when using eachPair see https://github.com/CBATeam/CBA_A3/issues/1358 --- addons/area_markers/XEH_postInit.sqf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/area_markers/XEH_postInit.sqf b/addons/area_markers/XEH_postInit.sqf index 44673257c..b8f93a3be 100644 --- a/addons/area_markers/XEH_postInit.sqf +++ b/addons/area_markers/XEH_postInit.sqf @@ -35,8 +35,7 @@ if (isServer) then { ISNILS(GVAR(markerVisibilities), SIDES_ARRAY_HASH); publicVariable QGVAR(markerVisibilities); - #define ALPHAS_HASH [[], 1] call CBA_fnc_hashCreate; - ISNILS(GVAR(markerAlphas), ALPHAS_HASH); + ISNILS(GVAR(markerAlphas), call CBA_fnc_hashCreate); publicVariable QGVAR(markerAlphas); };