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..b8f93a3be 100644 --- a/addons/area_markers/XEH_postInit.sqf +++ b/addons/area_markers/XEH_postInit.sqf @@ -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; + 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"]; @@ -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"]; @@ -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; }; diff --git a/addons/area_markers/functions/fnc_applyProperties.sqf b/addons/area_markers/functions/fnc_applyProperties.sqf index dd7688eee..0b663cb1b 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_globalEventJIP; diff --git a/addons/area_markers/functions/fnc_configure.sqf b/addons/area_markers/functions/fnc_configure.sqf index 741ea3399..7275a90a3 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); + +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..139b9d870 --- /dev/null +++ b/addons/area_markers/functions/fnc_updateAlpha.sqf @@ -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 + * 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) 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; + }; +}; diff --git a/addons/area_markers/functions/fnc_updateMarkerPos.sqf b/addons/area_markers/functions/fnc_updateMarkerPos.sqf new file mode 100644 index 000000000..14f742cd0 --- /dev/null +++ b/addons/area_markers/functions/fnc_updateMarkerPos.sqf @@ -0,0 +1,20 @@ +/* + * 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]