diff --git a/addons/map_gestures/functions/fnc_transmitterInit.sqf b/addons/map_gestures/functions/fnc_transmitterInit.sqf index 3c363d6f04..6a031e419b 100644 --- a/addons/map_gestures/functions/fnc_transmitterInit.sqf +++ b/addons/map_gestures/functions/fnc_transmitterInit.sqf @@ -45,9 +45,11 @@ if (!isNil QGVAR(MouseDownHandlerID)) then { GVAR(MouseDownHandlerID) = _mapCtrl ctrlAddEventHandler ["MouseButtonDown", { if (!GVAR(enabled)) exitWith {}; - params ["", "_button"]; + params ["", "_button", "_x", "_y", "_shift", "_ctrl", "_alt"]; - if (_button == 0) then {call FUNC(initTransmit);}; + if (_button == 0 && {[_shift, _ctrl, _alt] isEqualTo [false, false, false]}) then { + call FUNC(initTransmit); + }; }]; // MouseUp EH @@ -60,5 +62,7 @@ GVAR(MouseUpHandlerID) = _mapCtrl ctrlAddEventHandler ["MouseButtonUp", { params ["", "_button"]; - if (_button == 0) then {call FUNC(endTransmit);}; + if (_button == 0) then { + call FUNC(endTransmit); + }; }]; diff --git a/addons/markers/ACE_Settings.hpp b/addons/markers/ACE_Settings.hpp deleted file mode 100644 index b1866a7d21..0000000000 --- a/addons/markers/ACE_Settings.hpp +++ /dev/null @@ -1,17 +0,0 @@ -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 index dd20546fb0..61a6827491 100644 --- a/addons/markers/CfgVehicles.hpp +++ b/addons/markers/CfgVehicles.hpp @@ -2,47 +2,8 @@ class CfgVehicles { class ACE_Module; class ACE_ModuleMarkers: ACE_Module { author = ECSTRING(common,ACETeam); - category = "ACE"; displayName = CSTRING(Module_DisplayName); - function = QFUNC(initModule); scope = 1; - 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/XEH_PREP.hpp b/addons/markers/XEH_PREP.hpp index 521f692389..bbac954b66 100644 --- a/addons/markers/XEH_PREP.hpp +++ b/addons/markers/XEH_PREP.hpp @@ -1,4 +1,3 @@ - PREP(getEnabledChannels); PREP(initInsertMarker); PREP(mapDisplayInitEH); @@ -11,8 +10,7 @@ PREP(placeMarker); PREP(sendMarkersJIP); PREP(setMarkerJIP); PREP(setMarkerNetwork); +PREP(canMove); +PREP(onMouseButtonDown); +PREP(onMouseButtonUp); 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 900b17ecf7..ad0c2dfde3 100644 --- a/addons/markers/XEH_postInit.sqf +++ b/addons/markers/XEH_postInit.sqf @@ -18,27 +18,20 @@ GVAR(currentMarkerAngle) = 0; GVAR(currentMarkerColorConfigName) = ""; GVAR(currentMarkerConfigName) = ""; -// set marker pos local on every computer (prevent markers visible for everyone) -[QGVAR(applyMarkerPosLocal), { - params["_marker", "_pos"]; +// set marker pos local on every machine (prevent markers visible for everyone) +[QGVAR(setMarkerPosLocal), { + params ["_marker", "_pos"]; _marker setMarkerPosLocal _pos; + // handle JIP 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);}; + + 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/XEH_preInit.sqf b/addons/markers/XEH_preInit.sqf index 7ee91d67e5..efe44f145e 100644 --- a/addons/markers/XEH_preInit.sqf +++ b/addons/markers/XEH_preInit.sqf @@ -54,4 +54,28 @@ if (isNil QGVAR(MarkerColorsCache)) then { //Server Sync JIP markers: [QGVAR(sendMarkersJIP), FUNC(sendMarkersJIP)] call CBA_fnc_addEventHandler; +// settings +[ + QGVAR(moveRestriction), "LIST", + [LSTRING(MoveRestriction), LSTRING(MoveRestriction_Description)], + format ["ACE %1", localize ELSTRING(map,Module_DisplayName)], + [ + [ + MOVE_RESTRICTION_NOBODY, + MOVE_RESTRICTION_ALL, + MOVE_RESTRICTION_ADMINS, + MOVE_RESTRICTION_GROUP_LEADERS, + MOVE_RESTRICTION_GROUP_LEADERS_ADMINS + ], + [ + LSTRING(MoveRestriction_Nobody), + LSTRING(MoveRestriction_All), + LSTRING(MoveRestriction_Admins), + LSTRING(MoveRestriction_GroupLeaders), + LSTRING(MoveRestriction_GroupLeadersAndAdmins) + ], + 1 + ] +] call cba_settings_fnc_init; + ADDON = true; diff --git a/addons/markers/config.cpp b/addons/markers/config.cpp index 1881183ac1..8ae05d96aa 100644 --- a/addons/markers/config.cpp +++ b/addons/markers/config.cpp @@ -15,7 +15,6 @@ 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_canMove.sqf similarity index 56% rename from addons/markers/functions/fnc_canMoveMarker.sqf rename to addons/markers/functions/fnc_canMove.sqf index 4e7a5d9e5b..c97aafe07a 100644 --- a/addons/markers/functions/fnc_canMoveMarker.sqf +++ b/addons/markers/functions/fnc_canMove.sqf @@ -9,20 +9,21 @@ * Whether the player can move markers * * Example: - * [] call ace_markers_fnc_canMoveMarker + * [] call ace_markers_fnc_canMove * * Public: No */ #include "script_component.hpp" switch (GVAR(moveRestriction)) do { - case MOVE_RESTRICTION_ALL: { true }; - case MOVE_RESTRICTION_ADMINS: { IS_ADMIN }; + case MOVE_RESTRICTION_NOBODY: {false}; + case MOVE_RESTRICTION_ALL: {true}; + case MOVE_RESTRICTION_ADMINS: {IS_ADMIN}; case MOVE_RESTRICTION_GROUP_LEADERS: { - leader group ACE_player == ACE_player + leader ACE_player == ACE_player }; case MOVE_RESTRICTION_GROUP_LEADERS_ADMINS: { - (leader group ACE_player == ACE_player) || IS_ADMIN + (leader ACE_player == ACE_player) || IS_ADMIN }; - default { true }; -}; + default {true}; +}; // return diff --git a/addons/markers/functions/fnc_initModule.sqf b/addons/markers/functions/fnc_initModule.sqf deleted file mode 100644 index c30c80d874..0000000000 --- a/addons/markers/functions/fnc_initModule.sqf +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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_mapDisplayInitEH.sqf b/addons/markers/functions/fnc_mapDisplayInitEH.sqf index 662f6f80c0..4a740f0424 100644 --- a/addons/markers/functions/fnc_mapDisplayInitEH.sqf +++ b/addons/markers/functions/fnc_mapDisplayInitEH.sqf @@ -15,8 +15,6 @@ */ #include "script_component.hpp" -disableSerialization; - params ["_display"]; TRACE_1("params",_display); @@ -32,3 +30,8 @@ private _curSelColor = missionNamespace getVariable [QGVAR(curSelMarkerColor), 0 TRACE_2("color",_bisColorLB,_curSelColor); _bisColorLB ctrlAddEventHandler ["LBSelChanged", {_this call FUNC(onLBSelChangedColor)}]; _bisColorLB lbSetCurSel _curSelColor; + +// movable markers +private _ctrlMap = _display displayCtrl 51; +_ctrlMap ctrlAddEventHandler ["MouseButtonDown", {_this call FUNC(onMouseButtonDown)}]; +_ctrlMap ctrlAddEventHandler ["MouseButtonUp", {_this call FUNC(onMouseButtonUp)}]; diff --git a/addons/markers/functions/fnc_movePFH.sqf b/addons/markers/functions/fnc_movePFH.sqf index 021561b560..4b83d63756 100644 --- a/addons/markers/functions/fnc_movePFH.sqf +++ b/addons/markers/functions/fnc_movePFH.sqf @@ -16,23 +16,21 @@ */ #include "script_component.hpp" -params ["_args", "_idPFH"]; -_args params ["_marker"]; +(_this select 0) params ["_marker", "_ctrlMap", "_originalPos", "_originalAlpha", "_mapGesturesEnabled"]; -if (isNull (findDisplay 12 displayCtrl 51) || {!(player getVariable [QGVAR(moveInProgress), false])}) exitWith { - [_idPFH] call CBA_fnc_removePerFrameHandler; +if (isNull _ctrlMap || !GVAR(moving)) exitWith { + (_this select 1) call CBA_fnc_removePerFrameHandler; - private _origin = ACE_player getVariable [QGVAR(movedMarkerOrigin), getMarkerPos _marker]; + private _finalPos = getMarkerPos _marker; - if !([QGVAR(markerMoveEnded), [ACE_player, _marker, _origin, getMarkerPos _marker]] call CBA_fnc_localEvent) exitWith { - _marker setMarkerPosLocal _origin; + if !([QGVAR(markerMoveEnded), [ACE_player, _marker, _originalPos, _finalPos]] call CBA_fnc_localEvent) then { + _marker setMarkerPosLocal _originalPos; + } else { + [QGVAR(setMarkerPosLocal), [_marker, _finalPos]] call CBA_fnc_globalEvent; }; - [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 setMarkerAlphaLocal _originalAlpha; + _ctrlMap ctrlMapCursor ["Track", "Track"]; }; -_marker setMarkerPosLocal ((findDisplay 12 displayCtrl 51) posScreenToWorld getMousePosition); +_marker setMarkerPosLocal (_ctrlMap posScreenToWorld getMousePosition); diff --git a/addons/markers/functions/fnc_onMouseButtonDown.sqf b/addons/markers/functions/fnc_onMouseButtonDown.sqf new file mode 100644 index 0000000000..e389ff6637 --- /dev/null +++ b/addons/markers/functions/fnc_onMouseButtonDown.sqf @@ -0,0 +1,41 @@ +/* + * 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 ["_ctrlMap", "_button", "_x", "_y", "_shift", "_ctrl", "_alt"]; + +if (_button != 0 || {!([_shift, _ctrl, _alt] isEqualTo [false, false, true])}) exitWith {}; + +ctrlMapMouseOver _ctrlMap params [["_type", ""], "_marker"]; + +if (_type == "marker" && {_marker find "_USER_DEFINED" != -1 && {call FUNC(canMove)}}) then { + _ctrlMap ctrlMapCursor ["Track", "Move"]; + + private _originalPos = getMarkerPos _marker; + private _originalAlpha = markerAlpha _marker; + + if !([QGVAR(markerMoveStarted), [ACE_player, _marker, _originalPos]] call CBA_fnc_localEvent) exitWith {}; + + GVAR(moving) = true; + _marker setMarkerAlphaLocal 0.5; + [FUNC(movePFH), 0, [_marker, _ctrlMap, _originalPos, _originalAlpha, _mapGesturesEnabled]] call CBA_fnc_addPerFrameHandler; +}; diff --git a/addons/markers/functions/fnc_onMouseButtonDownMap.sqf b/addons/markers/functions/fnc_onMouseButtonDownMap.sqf deleted file mode 100644 index 6e001a5f87..0000000000 --- a/addons/markers/functions/fnc_onMouseButtonDownMap.sqf +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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_onMouseButtonUp.sqf similarity index 58% rename from addons/markers/functions/fnc_onMouseButtonUpMap.sqf rename to addons/markers/functions/fnc_onMouseButtonUp.sqf index c1abfdf73f..3df6b8d55e 100644 --- a/addons/markers/functions/fnc_onMouseButtonUpMap.sqf +++ b/addons/markers/functions/fnc_onMouseButtonUp.sqf @@ -5,6 +5,11 @@ * 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 @@ -16,6 +21,6 @@ */ #include "script_component.hpp" -params ["_mapCtrl", "_button"]; +params ["_ctrlMap", "_button", "_x", "_y", "_shift", "_ctrl", "_alt"]; -player setVariable [QGVAR(moveInProgress), false]; +GVAR(moving) = false; diff --git a/addons/markers/script_component.hpp b/addons/markers/script_component.hpp index cd77c827a6..c081cbcc39 100644 --- a/addons/markers/script_component.hpp +++ b/addons/markers/script_component.hpp @@ -25,6 +25,7 @@ localize "str_channel_direct" \ ] +#define MOVE_RESTRICTION_NOBODY -1 #define MOVE_RESTRICTION_ALL 0 #define MOVE_RESTRICTION_ADMINS 1 #define MOVE_RESTRICTION_GROUP_LEADERS 2 diff --git a/addons/markers/stringtable.xml b/addons/markers/stringtable.xml index 8ce677cbbc..ae348bf65d 100644 --- a/addons/markers/stringtable.xml +++ b/addons/markers/stringtable.xml @@ -26,50 +26,17 @@ 标志 맵마커 - - This module allows you to customize markers placement. - Dieses Modul ermöglicht die Steuerung der Platzierung von Markierungen. - モジュールではマーカー配置のカスタマイズを可能にします。 - Questo modulo permette di personalizzare i marcatori a piacimento. - 此模塊可讓你自定標誌的擺放方式。 - 此模块可让你自定标志的摆放方式。 - 이 모듈을 설정해서 맵마커 배치에 대하여 설정 할 수 있습니다. - - - Movable markers - Bewegbare Markierungen - 可動式マーカー - Marcatori mobili - 可移動的標誌 - 可移动的标志 - 마커 이동 - - - Should map markers placed by players be movable? - Sollen Markierungen, die von Spielern platziert wurden, verschiebbar sein? - プレイヤーによって配置されたマーカーを可動式にしますか? - I marcatori in mappa piazzati dai giocatori dovrebbero poter essere mossi ? - 玩家放置的地圖標誌可以被移動嗎? - 玩家放置的地图标志可以被移动吗? - 배치한 마커를 플레이어가 움직일 수 있게 합니까? - - - Move restriction - Verschiebungsrestriktion - 可動制限 - Restrizione di movimento - 移動限制 - 移动限制 - 이동 제한 + + Allow moving markers for + Erlaube Marker zu bewegen für - Apply move restrictions so that not every player is able to move markers. - Restriktionen, damit nicht jeder Spieler Marker verschieben kann - マーカーを可動出来るプレイヤーを決定します。 - Applica le restrizioni di movimento cosicchè ogni giocatore possa spostare i marcatori. - 設定那些玩家可以移動標誌的位置。 - 设定那些玩家可以移动标志的位置。 - 일부의 플레이어가 마커를 움직일 수 있도록 제한권한을 설정하세요. + Restricts which players are able to move markers while holding the Alt key. + Beschränkt welche Spieler Marker mit gedrückter Alt-Taste bewegen können. + + + Nobody + Niemand All players