diff --git a/addons/markers/ACE_Settings.hpp b/addons/markers/ACE_Settings.hpp new file mode 100644 index 0000000000..b1866a7d21 --- /dev/null +++ b/addons/markers/ACE_Settings.hpp @@ -0,0 +1,17 @@ +class ACE_Settings { + class GVAR(movableMarkersEnabled) { + category = CSTRING(Module_DisplayName); + value = 0; + typeName = "BOOL"; + displayName = CSTRING(MovableMarkers_DisplayName); + description = CSTRING(MovableMarkers_Description); + }; + class GVAR(moveRestriction) { + category = CSTRING(Module_DisplayName); + value = 0; + typeName = "SCALAR"; + displayName = CSTRING(MoveRestriction_DisplayName); + description = CSTRING(MoveRestriction_Description); + values[] = {CSTRING(MoveRestriction_All), CSTRING(MoveRestriction_Admins), CSTRING(MoveRestriction_GroupLeaders), CSTRING(MoveRestriction_GroupLeadersAndAdmins)}; + }; +}; diff --git a/addons/markers/CfgVehicles.hpp b/addons/markers/CfgVehicles.hpp new file mode 100644 index 0000000000..2fd3778738 --- /dev/null +++ b/addons/markers/CfgVehicles.hpp @@ -0,0 +1,48 @@ +class CfgVehicles { + class ACE_Module; + class ACE_ModuleMarkers: ACE_Module { + author = ECSTRING(common,ACETeam); + category = "ACE"; + displayName = CSTRING(Module_DisplayName); + function = QFUNC(initModule); + scope = 2; + isGlobal = 1; + isSingular = 1; + icon = QPATHTOF(UI\Icon_Module_Markers_ca.paa); + class Arguments { + class MovableMarkersEnabled { + displayName = CSTRING(MovableMarkers_DisplayName); + description = CSTRING(MovableMarkers_Description); + typeName = "BOOL"; + defaultValue = 0; + }; + class MoveRestriction { + displayName = CSTRING(MoveRestriction_DisplayName); + description = CSTRING(MoveRestriction_Description); + typeName = "NUMBER"; + class values { + class all { + name = CSTRING(MoveRestriction_All); + value = MOVE_RESTRICTION_ALL; + default = MOVE_RESTRICTION_ALL; + }; + class admins { + name = CSTRING(MoveRestriction_Admins); + value = MOVE_RESTRICTION_ADMINS; + }; + class groupLeaders { + name = CSTRING(MoveRestriction_GroupLeaders); + value = MOVE_RESTRICTION_GROUP_LEADERS; + }; + class groupLeadersAndAdmins { + name = CSTRING(MoveRestriction_GroupLeadersAndAdmins); + value = MOVE_RESTRICTION_GROUP_LEADERS_ADMINS; + }; + }; + }; + }; + class ModuleDescription { + description = CSTRING(Module_Description); + }; + }; +}; diff --git a/addons/markers/UI/Icon_Module_Markers_ca.paa b/addons/markers/UI/Icon_Module_Markers_ca.paa new file mode 100644 index 0000000000..8c9e41e0ca Binary files /dev/null and b/addons/markers/UI/Icon_Module_Markers_ca.paa differ diff --git a/addons/markers/XEH_PREP.hpp b/addons/markers/XEH_PREP.hpp index c6ad5c6ba2..521f692389 100644 --- a/addons/markers/XEH_PREP.hpp +++ b/addons/markers/XEH_PREP.hpp @@ -11,3 +11,8 @@ PREP(placeMarker); PREP(sendMarkersJIP); PREP(setMarkerJIP); PREP(setMarkerNetwork); +PREP(movePFH); +PREP(onMouseButtonDownMap); +PREP(onMouseButtonUpMap); +PREP(initModule); +PREP(canMoveMarker); diff --git a/addons/markers/XEH_postInit.sqf b/addons/markers/XEH_postInit.sqf index 6e1af95a50..eadf5be907 100644 --- a/addons/markers/XEH_postInit.sqf +++ b/addons/markers/XEH_postInit.sqf @@ -18,3 +18,28 @@ GVAR(currentMarkerPosition) = []; GVAR(currentMarkerAngle) = 0; GVAR(currentMarkerColorConfigName) = ""; GVAR(currentMarkerConfigName) = ""; + +// set marker pos local on every computer (prevent markers visible for everyone) +[QGVAR(applyMarkerPosLocal), { + params["_marker", "_pos"]; + _marker setMarkerPosLocal _pos; + + if (isServer) then { + private _index = (GETGVAR(allMapMarkers,[])) find _marker; // case-sensitive, but should be fine + if (_index < 0) exitWith {ERROR_1("Could not find data for %1", _marker);}; + private _data = GVAR(allMapMarkersProperties) select _index; + _data set [2, _pos]; + }; +}] call CBA_fnc_addEventHandler; + +["ace_settingsInitialized", { + if (GVAR(movableMarkersEnabled)) then { + if (!hasInterface) exitWith {}; + [{ + !isNull (findDisplay 12) + }, { + (findDisplay 12 displayCtrl 51) ctrlAddEventHandler ["MouseButtonDown", FUNC(onMouseButtonDownMap)]; + (findDisplay 12 displayCtrl 51) ctrlAddEventHandler ["MouseButtonUp", FUNC(onMouseButtonUpMap)]; + }] call CBA_fnc_waitUntilAndExecute; + }; +}] call CBA_fnc_addEventHandler; diff --git a/addons/markers/config.cpp b/addons/markers/config.cpp index 1a8c310735..1881183ac1 100644 --- a/addons/markers/config.cpp +++ b/addons/markers/config.cpp @@ -15,4 +15,7 @@ class CfgPatches { }; #include "CfgEventHandlers.hpp" +#include "ACE_Settings.hpp" +#include "CfgVehicles.hpp" + #include "InsertMarker.hpp" diff --git a/addons/markers/functions/fnc_canMoveMarker.sqf b/addons/markers/functions/fnc_canMoveMarker.sqf new file mode 100644 index 0000000000..4e7a5d9e5b --- /dev/null +++ b/addons/markers/functions/fnc_canMoveMarker.sqf @@ -0,0 +1,28 @@ +/* + * Author: chris579 + * Checks whether the player can move markers. + * + * Arguments: + * None + * + * Return Value: + * Whether the player can move markers + * + * Example: + * [] call ace_markers_fnc_canMoveMarker + * + * Public: No + */ +#include "script_component.hpp" + +switch (GVAR(moveRestriction)) do { + case MOVE_RESTRICTION_ALL: { true }; + case MOVE_RESTRICTION_ADMINS: { IS_ADMIN }; + case MOVE_RESTRICTION_GROUP_LEADERS: { + leader group ACE_player == ACE_player + }; + case MOVE_RESTRICTION_GROUP_LEADERS_ADMINS: { + (leader group ACE_player == ACE_player) || IS_ADMIN + }; + default { true }; +}; diff --git a/addons/markers/functions/fnc_initModule.sqf b/addons/markers/functions/fnc_initModule.sqf new file mode 100644 index 0000000000..c30c80d874 --- /dev/null +++ b/addons/markers/functions/fnc_initModule.sqf @@ -0,0 +1,21 @@ +/* + * Author: chris579 + * Initializes the Markers Module. + * + * Arguments: + * 0: Logic + * + * Return Value: + * None + * + * Example: + * [LOGIC] call ACE_markers_fnc_initModule + * + * Public: No + */ +#include "script_component.hpp" + +params ["_logic"]; + +[_logic, QGVAR(movableMarkersEnabled), "MovableMarkersEnabled"] call EFUNC(common,readSettingFromModule); +[_logic, QGVAR(moveRestriction), "MoveRestriction"] call EFUNC(common,readSettingFromModule); diff --git a/addons/markers/functions/fnc_movePFH.sqf b/addons/markers/functions/fnc_movePFH.sqf new file mode 100644 index 0000000000..021561b560 --- /dev/null +++ b/addons/markers/functions/fnc_movePFH.sqf @@ -0,0 +1,38 @@ +/* + * Author: chris579 + * When the marker is being moved. + * + * Arguments: + * 0: Marker data + * 1: PFH ID + * + * Return Value: + * None + * + * Example: + * [[MARKER], 5] call ace_markers_fnc_movePFH + * + * Public: No + */ +#include "script_component.hpp" + +params ["_args", "_idPFH"]; +_args params ["_marker"]; + +if (isNull (findDisplay 12 displayCtrl 51) || {!(player getVariable [QGVAR(moveInProgress), false])}) exitWith { + [_idPFH] call CBA_fnc_removePerFrameHandler; + + private _origin = ACE_player getVariable [QGVAR(movedMarkerOrigin), getMarkerPos _marker]; + + if !([QGVAR(markerMoveEnded), [ACE_player, _marker, _origin, getMarkerPos _marker]] call CBA_fnc_localEvent) exitWith { + _marker setMarkerPosLocal _origin; + }; + + [QGVAR(applyMarkerPosLocal), [_marker, getMarkerPos _marker]] call CBA_fnc_globalEvent; + _marker setMarkerAlphaLocal (ACE_player getVariable [QGVAR(movedMarkerAlpha), 1]); + + EGVAR(map_gestures,enabled) = ACE_player getVariable [QGVAR(mapGesturesSetting), false]; + (findDisplay 12 displayCtrl 51) ctrlMapCursor ["Track", "Track"]; +}; + +_marker setMarkerPosLocal ((findDisplay 12 displayCtrl 51) posScreenToWorld getMousePosition); diff --git a/addons/markers/functions/fnc_onMouseButtonDownMap.sqf b/addons/markers/functions/fnc_onMouseButtonDownMap.sqf new file mode 100644 index 0000000000..6e001a5f87 --- /dev/null +++ b/addons/markers/functions/fnc_onMouseButtonDownMap.sqf @@ -0,0 +1,53 @@ +/* + * Author: chris579 + * Triggered when a mouse button is pressed on the map. + * + * Arguments: + * 0: Map Control the EVH was assigned to + * 1: Button code + * 2: Position of x + * 3: Position of y + * 4: State of Shift + * 5: State of Ctrl + * 6: State of Alt + * + * Return Value: + * None + * + * Example: + * [CONTROL, 2, 0, 0, true, false, false] call ace_markers_fnc_onMouseButtonDownMap + * + * Public: No + */ +#include "script_component.hpp" + +params ["_mapCtrl", "_button", "_x", "_y", "_shift", "_ctrl", "_alt"]; + +if (_button != 0) exitWith {}; + +private _mouseOver = ctrlMapMouseOver _mapCtrl; + +if (count _mouseOver == 2) then { + if ((_mouseOver select 0) == "marker") then { + private _markerName = _mouseOver select 1; + + if (_markerName find "_USER_DEFINED" != -1) then { + if (!_ctrl && !_shift && _alt && ([] call FUNC(canMoveMarker))) then { + // move marker + _mapCtrl ctrlMapCursor ["Track", "Move"]; + + if !([QGVAR(markerMoveStarted), [ACE_player, _markerName, getMarkerPos _markerName]] call CBA_fnc_localEvent) exitWith {}; + + ACE_player setVariable [QGVAR(movedMarkerOrigin), getMarkerPos _markerName]; + ACE_player setVariable [QGVAR(movedMarkerAlpha), markerAlpha _markerName]; + ACE_player setVariable [QGVAR(moveInProgress), true]; + ACE_player setVariable [QGVAR(mapGesturesSetting), EGVAR(map_gestures,enabled)]; + EGVAR(map_gestures,enabled) = false; + + _markerName setMarkerAlphaLocal 0.5; + [FUNC(movePFH), 0, [_markerName]] call CBA_fnc_addPerFrameHandler; + + }; + }; + }; +}; diff --git a/addons/markers/functions/fnc_onMouseButtonUpMap.sqf b/addons/markers/functions/fnc_onMouseButtonUpMap.sqf new file mode 100644 index 0000000000..c1abfdf73f --- /dev/null +++ b/addons/markers/functions/fnc_onMouseButtonUpMap.sqf @@ -0,0 +1,21 @@ +/* + * Author: chris579 + * Triggered when a mouse button is released on the map. + * + * Arguments: + * 0: Map Control the evh was assigned to + * 1: Button code + * + * Return Value: + * None + * + * Example: + * [CONTROL, 2] call ace_markers_fnc_onMouseButtonUpMap + * + * Public: No + */ +#include "script_component.hpp" + +params ["_mapCtrl", "_button"]; + +player setVariable [QGVAR(moveInProgress), false]; diff --git a/addons/markers/script_component.hpp b/addons/markers/script_component.hpp index 80256466e9..cd77c827a6 100644 --- a/addons/markers/script_component.hpp +++ b/addons/markers/script_component.hpp @@ -24,3 +24,8 @@ localize "str_channel_vehicle", \ localize "str_channel_direct" \ ] + +#define MOVE_RESTRICTION_ALL 0 +#define MOVE_RESTRICTION_ADMINS 1 +#define MOVE_RESTRICTION_GROUP_LEADERS 2 +#define MOVE_RESTRICTION_GROUP_LEADERS_ADMINS 3 diff --git a/addons/markers/stringtable.xml b/addons/markers/stringtable.xml index 1c87546a5e..b03a660844 100644 --- a/addons/markers/stringtable.xml +++ b/addons/markers/stringtable.xml @@ -17,5 +17,45 @@ 方位: %1° 方位: %1° + + Markers + Markierungen + + + This module allows you to customize markers placement. + Dieses Modul ermöglicht die Steuerung der Platzierung von Markierungen. + + + Movable markers + Bewegbare Markierungen + + + Should map markers placed by players be movable? + Sollen Markierungen, die von Spielern platziert wurden, verschiebbar sein? + + + Move restriction + Verschiebungsrestriktion + + + Apply move restrictions so that not every player is able to move markers. + Restriktionen, damit nicht jeder Spieler Marker verschieben kann + + + All players + Alle Spieler + + + Admins + Admins + + + Group leaders + Gruppenführer + + + Group leaders and Admins + Gruppenführer und Admins +