mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
added movable markers option (#5397)
* added movable markers option * added restrictions * added local events * formatting + small fixes * Events for start and end modified + small adjusts * minor fixes * lazy eval * Alt as modifier key * Update XEH_postInit.sqf * Skip UI EH on headless
This commit is contained in:
28
addons/markers/functions/fnc_canMoveMarker.sqf
Normal file
28
addons/markers/functions/fnc_canMoveMarker.sqf
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Author: chris579
|
||||
* Checks whether the player can move markers.
|
||||
*
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return Value:
|
||||
* Whether the player can move markers <BOOL>
|
||||
*
|
||||
* 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 };
|
||||
};
|
21
addons/markers/functions/fnc_initModule.sqf
Normal file
21
addons/markers/functions/fnc_initModule.sqf
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Author: chris579
|
||||
* Initializes the Markers Module.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Logic <Object>
|
||||
*
|
||||
* 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);
|
38
addons/markers/functions/fnc_movePFH.sqf
Normal file
38
addons/markers/functions/fnc_movePFH.sqf
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Author: chris579
|
||||
* When the marker is being moved.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Marker data <ARRAY>
|
||||
* 1: PFH ID <NUMBER>
|
||||
*
|
||||
* 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);
|
53
addons/markers/functions/fnc_onMouseButtonDownMap.sqf
Normal file
53
addons/markers/functions/fnc_onMouseButtonDownMap.sqf
Normal file
@ -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 <CONTROL>
|
||||
* 1: Button code <NUMBER>
|
||||
* 2: Position of x <NUMBER>
|
||||
* 3: Position of y <NUMBER>
|
||||
* 4: State of Shift <BOOL>
|
||||
* 5: State of Ctrl <BOOL>
|
||||
* 6: State of Alt <BOOL>
|
||||
*
|
||||
* 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;
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
21
addons/markers/functions/fnc_onMouseButtonUpMap.sqf
Normal file
21
addons/markers/functions/fnc_onMouseButtonUpMap.sqf
Normal file
@ -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 <CONTROL>
|
||||
* 1: Button code <NUMBER>
|
||||
*
|
||||
* 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];
|
Reference in New Issue
Block a user