Remove Line Drawing from MapTools

And change map tools key to ALT from CTRL
This commit is contained in:
PabstMirror 2016-06-02 14:36:25 -05:00
parent 2e54310ff4
commit 73215b707d
25 changed files with 63 additions and 674 deletions

View File

@ -1,6 +0,0 @@
class ACE_Settings {
class GVAR(everyoneCanDrawOnBriefing) {
value = 1;
typeName = "BOOL";
};
};

View File

@ -3,57 +3,9 @@ class CfgVehicles {
class CAManBase: Man { class CAManBase: Man {
class ACE_SelfActions { class ACE_SelfActions {
class ACE_MapTools {
displayName = CSTRING(MapTools_Menu);
condition = QUOTE((call FUNC(canUseMapTools) || {call FUNC(canUseMapGPS)}));
statement = "";
exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"};
showDisabled = 0;
priority = 100;
class ACE_MapToolsHide {
displayName = CSTRING(MapToolsHide);
condition = QUOTE((call FUNC(canUseMapTools) && {GVAR(mapTool_Shown) != 0}));
statement = QUOTE(GVAR(mapTool_Shown) = 0;);
exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"};
showDisabled = 1;
priority = 5;
};
class ACE_MapToolsShowNormal {
displayName = CSTRING(MapToolsShowNormal);
condition = QUOTE((call FUNC(canUseMapTools) && {GVAR(mapTool_Shown) != 1}));
statement = QUOTE(GVAR(mapTool_Shown) = 1;);
exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"};
showDisabled = 1;
priority = 4;
};
class ACE_MapToolsShowSmall {
displayName = CSTRING(MapToolsShowSmall);
condition = QUOTE((call FUNC(canUseMapTools) && {GVAR(mapTool_Shown) != 2}));
statement = QUOTE(GVAR(mapTool_Shown) = 2;);
exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"};
showDisabled = 1;
priority = 3;
};
class ACE_MapToolsAlignNorth {
displayName = CSTRING(MapToolsAlignNorth);
condition = QUOTE((call FUNC(canUseMapTools) && {GVAR(mapTool_Shown) != 0}));
statement = QUOTE(GVAR(mapTool_angle) = 0;);
exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"};
showDisabled = 1;
priority = 2;
};
class ACE_MapToolsAlignCompass {
displayName = CSTRING(MapToolsAlignCompass);
condition = QUOTE((call FUNC(canUseMapTools) && {GVAR(mapTool_Shown) != 0} && {('ItemCompass' in assigneditems ACE_player) || {'ItemCompass' in assigneditems ACE_player}}));
statement = QUOTE(GVAR(mapTool_angle) = getDir ACE_player;);
exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"};
showDisabled = 1;
priority = 1;
};
class ACE_MapGpsShow { class ACE_MapGpsShow {
displayName = CSTRING(MapGpsShow); displayName = CSTRING(MapGpsShow);
condition = QUOTE((call FUNC(canUseMapGPS) && {!GVAR(mapGpsShow)})); condition = QUOTE((!GVAR(mapGpsShow)) && {call FUNC(canUseMapGPS)});
statement = QUOTE(GVAR(mapGpsShow) = true; [GVAR(mapGpsShow)] call FUNC(openMapGps)); statement = QUOTE(GVAR(mapGpsShow) = true; [GVAR(mapGpsShow)] call FUNC(openMapGps));
exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"}; exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"};
showDisabled = 0; showDisabled = 0;
@ -61,23 +13,60 @@ class CfgVehicles {
}; };
class ACE_MapGpsHide { class ACE_MapGpsHide {
displayName = CSTRING(MapGpsHide); displayName = CSTRING(MapGpsHide);
condition = QUOTE((call FUNC(canUseMapGPS) && {GVAR(mapGpsShow)})); condition = QUOTE((GVAR(mapGpsShow)) && {call FUNC(canUseMapGPS)});
statement = QUOTE(GVAR(mapGpsShow) = false; [GVAR(mapGpsShow)] call FUNC(openMapGps)); statement = QUOTE(GVAR(mapGpsShow) = false; [GVAR(mapGpsShow)] call FUNC(openMapGps));
exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"}; exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"};
showDisabled = 0; showDisabled = 0;
priority = 0; priority = 0;
}; };
};
};
class ACE_Actions { class ACE_MapTools {
class ACE_MainActions { displayName = CSTRING(MapTools_Menu);
class ACE_CopyMap { condition = QUOTE(call FUNC(canUseMapTools));
displayName = CSTRING(CopyMap); statement = "";
condition = QUOTE(([_target] call EFUNC(common,isPlayer) && {'ItemMap' in assigneditems _player} && {'ACE_MapTools' in items _player} && {'ItemMap' in assignedItems _target})); exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"};
statement = QUOTE([ARR_2(_player,_target)] call FUNC(copyMapStart));
showDisabled = 0; showDisabled = 0;
priority = -1; priority = 100;
class ACE_MapToolsHide {
displayName = CSTRING(MapToolsHide);
condition = QUOTE(GVAR(mapTool_Shown) != 0);
statement = QUOTE(GVAR(mapTool_Shown) = 0;);
exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"};
showDisabled = 1;
priority = 5;
};
class ACE_MapToolsShowNormal {
displayName = CSTRING(MapToolsShowNormal);
condition = QUOTE(GVAR(mapTool_Shown) != 1);
statement = QUOTE(GVAR(mapTool_Shown) = 1;);
exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"};
showDisabled = 1;
priority = 4;
};
class ACE_MapToolsShowSmall {
displayName = CSTRING(MapToolsShowSmall);
condition = QUOTE(GVAR(mapTool_Shown) != 2);
statement = QUOTE(GVAR(mapTool_Shown) = 2;);
exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"};
showDisabled = 1;
priority = 3;
};
class ACE_MapToolsAlignNorth {
displayName = CSTRING(MapToolsAlignNorth);
condition = QUOTE(GVAR(mapTool_Shown) != 0);
statement = QUOTE(GVAR(mapTool_angle) = 0;);
exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"};
showDisabled = 1;
priority = 2;
};
class ACE_MapToolsAlignCompass {
displayName = CSTRING(MapToolsAlignCompass);
condition = QUOTE((GVAR(mapTool_Shown) != 0) && {'ItemCompass' in assigneditems ACE_player});
statement = QUOTE(GVAR(mapTool_angle) = getDir ACE_player;);
exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"};
showDisabled = 1;
priority = 1;
}; };
}; };
}; };

View File

@ -1,80 +0,0 @@
class controls {
class CA_PlayerName: RscText {
x = "2 * ( ((safezoneW / safezoneH) min 1.2) / 40)";
};
class ProfilePicture: RscPicture {
x = "13.5 * ( ((safezoneW / safezoneH) min 1.2) / 40)";
};
class ProfileBackground: RscText {
x = "13.3 * ( ((safezoneW / safezoneH) min 1.2) / 40)";
};
class Separator1: RscPicture {
x = "14.5 * ( ((safezoneW / safezoneH) min 1.2) / 40)";
};
class ColorBlack: RscButton {
idc = 36732;
x = "0 * (((safezoneW / safezoneH) min 1.2) / 40)";
y = "0.25 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
w = "0.3 * (((safezoneW / safezoneH) min 1.2) / 40)";
h = "1.00 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
colorBackground[] = {0.2,0.2,0.2,1};
colorBackgroundActive[] = {0,0,0,1};
colorFocused[] = {0,0,0,1};
onButtonClick = QUOTE(missionNamespace setVariable [ARR_2(QUOTE(QGVAR(drawing_drawColor)),'ColorBlack')]);
};
class ColorRed: RscButton {
idc = 36733;
x = "0.3 * (((safezoneW / safezoneH) min 1.2) / 40)";
y = "0.25 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
w = "0.3 * (((safezoneW / safezoneH) min 1.2) / 40)";
h = "1.00 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
colorBackground[] = {0.8,0.2,0.2,1};
colorBackgroundActive[] = {1,0,0,1};
colorFocused[] = {1,0,0,1};
onButtonClick = QUOTE(missionNamespace setVariable [ARR_2(QUOTE(QGVAR(drawing_drawColor)),'ColorRed')]);
};
class ColorGreen: RscButton {
idc = 36734;
x = "0.6 * (((safezoneW / safezoneH) min 1.2) / 40)";
y = "0.25 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
w = "0.3 * (((safezoneW / safezoneH) min 1.2) / 40)";
h = "1.00 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
colorBackground[] = {0.2,0.8,0.2,1};
colorBackgroundActive[] = {0,1,0,1};
colorFocused[] = {0,1,0,1};
onButtonClick = QUOTE(missionNamespace setVariable [ARR_2(QUOTE(QGVAR(drawing_drawColor)),'ColorGreen')]);
};
class ColorBlue: RscButton {
idc = 36735;
x = "0.9 * (((safezoneW / safezoneH) min 1.2) / 40)";
y = "0.25 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
w = "0.3 * (((safezoneW / safezoneH) min 1.2) / 40)";
h = "1.00 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
colorBackground[] = {0.2,0.2,0.8,1};
colorBackgroundActive[] = {0,0,1,1};
colorFocused[] = {0,0,1,1};
onButtonClick = QUOTE(missionNamespace setVariable [ARR_2(QUOTE(QGVAR(drawing_drawColor)),'ColorBlue')]);
};
class ColorYellow: RscButton {
idc = 36736;
x = "1.2 * (((safezoneW / safezoneH) min 1.2) / 40)";
y = "0.25 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
w = "0.3 * (((safezoneW / safezoneH) min 1.2) / 40)";
h = "1.00 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
colorBackground[] = {0.8,0.8,0.2,1};
colorBackgroundActive[] = {1,1,0,1};
colorFocused[] = {1,1,0,1};
onButtonClick = QUOTE(missionNamespace setVariable [ARR_2(QUOTE(QGVAR(drawing_drawColor)),'ColorYellow')]);
};
class ColorWhite: RscButton {
idc = 36737;
x = "1.5 * (((safezoneW / safezoneH) min 1.2) / 40)";
y = "0.25 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
w = "0.3 * (((safezoneW / safezoneH) min 1.2) / 40)";
h = "1.00 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
colorBackground[] = {0.8,0.8,0.8,1};
colorBackgroundActive[] = {1,1,1,1};
colorFocused[] = {1,1,1,1};
onButtonClick = QUOTE(missionNamespace setVariable [ARR_2(QUOTE(QGVAR(drawing_drawColor)),'ColorWhite')]);
};
};

View File

@ -1,20 +1,9 @@
PREP(addLineMarker);
PREP(calculateMapScale); PREP(calculateMapScale);
PREP(cancelDrawing);
PREP(canDraw);
PREP(canUseMapTools);
PREP(canUseMapGPS); PREP(canUseMapGPS);
PREP(copyMapReceiveMarkers); PREP(canUseMapTools);
PREP(copyMapRemoteSend);
PREP(copyMapStart);
PREP(handleKeyDown);
PREP(handleMouseButton); PREP(handleMouseButton);
PREP(handleMouseMove); PREP(handleMouseMove);
PREP(handleMouseZChanged);
PREP(isInsideMapTool); PREP(isInsideMapTool);
PREP(openMapGps); PREP(openMapGps);
PREP(openMapGpsUpdate); PREP(openMapGpsUpdate);
PREP(removeLineMarker);
PREP(updateMapToolMarkers); PREP(updateMapToolMarkers);
PREP(updateLineMarker);

View File

@ -5,7 +5,6 @@
if (!hasInterface) exitWith {}; if (!hasInterface) exitWith {};
// Init variables // Init variables
GVAR(mapVisableLastFrame) = false;
GVAR(mapGpsShow) = true; GVAR(mapGpsShow) = true;
GVAR(mapTool_Shown) = 0; GVAR(mapTool_Shown) = 0;
@ -14,57 +13,14 @@ GVAR(mapTool_angle) = 0;
GVAR(mapTool_isDragging) = false; GVAR(mapTool_isDragging) = false;
GVAR(mapTool_isRotating) = false; GVAR(mapTool_isRotating) = false;
GVAR(drawing_isDrawing) = false; //Install the event handers for the map tools on the main in-game map
GVAR(drawing_tempLineMarker) = []; [{!isNull findDisplay 12},
GVAR(drawing_lineMarkers) = [];
GVAR(drawing_drawColor) = "ColorBlack";
GVAR(drawing_controls) = [36732, 36733, 36734, 36735, 36736, 36737];
// This spawn is probably worth keeping, as pfh don't work natively on the briefing screen and IDK how reliable the hack we implemented for them is.
// The thread dies as soon as the mission start, so it's not really compiting for scheduler space.
[] spawn {
_fnc_installMapEvents = {
private "_d";
_d = _this;
((findDisplay _d) displayCtrl 51) ctrlAddEventHandler ["MouseMoving", {_this call FUNC(handleMouseMove);}];
((findDisplay _d) displayCtrl 51) ctrlAddEventHandler ["MouseButtonDown", {[1, _this] call FUNC(handleMouseButton);}];
((findDisplay _d) displayCtrl 51) ctrlAddEventHandler ["MouseButtonUp", {[0, _this] call FUNC(handleMouseButton)}];
((findDisplay _d) displayCtrl 51) ctrlAddEventHandler ["Draw", {_this call FUNC(updateMapToolMarkers);}];
(findDisplay _d) displayAddEventHandler ["KeyDown", {_this call FUNC(handleKeyDown);}];
};
// Wait until the briefing map is detected
// display = 37 for SP
// display = 52 for host server on MP;
// display = 53 for MP clients)
waitUntil {(!isNull findDisplay 37) || (!isNull findDisplay 52) || (!isNull findDisplay 53) || (!isNull findDisplay 12)};
if (isNull findDisplay 12) then {
// Install event handlers on the map control of the briefing screen (control = 51)
GVAR(drawing_syncMarkers) = true;
if (!isNull findDisplay 52) then {
52 call _fnc_installMapEvents;
} else {
if (!isNull findDisplay 53) then {
53 call _fnc_installMapEvents;
} else {
37 call _fnc_installMapEvents;
};
};
} else {
// Briefing screen was skipped; the player is JIP, create the markers defined during the briefing
GVAR(drawing_syncMarkers) = false;
{ {
_x call FUNC(addLineMarker); ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseMoving", {_this call FUNC(handleMouseMove);}];
} forEach GVAR(drawing_serverLineMarkers); ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseButtonDown", {[1, _this] call FUNC(handleMouseButton);}];
}; ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseButtonUp", {[0, _this] call FUNC(handleMouseButton)}];
((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["Draw", {_this call FUNC(updateMapToolMarkers);}];
// Wait until the main map display is detected (display = 12) }, []] call CBA_fnc_waitUntilAndExecute;
waitUntil { !isNull findDisplay 12 };
// Install event handlers on the map control and display (control = 51)
GVAR(drawing_syncMarkers) = false;
12 call _fnc_installMapEvents;
};
["ace_visibleMapChanged", { ["ace_visibleMapChanged", {
params ["", "_mapOn"]; params ["", "_mapOn"];
@ -74,7 +30,5 @@ GVAR(drawing_controls) = [36732, 36733, 36734, 36735, 36736, 36737];
} else { } else {
// Hide GPS // Hide GPS
[false] call FUNC(openMapGps); [false] call FUNC(openMapGps);
// Cancel drawing
call FUNC(cancelDrawing);
}; };
}] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler;

View File

@ -4,16 +4,4 @@ ADDON = false;
#include "XEH_PREP.hpp" #include "XEH_PREP.hpp"
if (isServer) then {
GVAR(drawing_serverLineMarkers) = [];
publicVariable QGVAR(drawing_serverLineMarkers);
};
//Add Event Handlers:
[QGVAR(removeLineMarker), FUNC(removeLineMarker)] call CBA_fnc_addEventHandler;
[QGVAR(addLineMarker), FUNC(addLineMarker)] call CBA_fnc_addEventHandler;
[QGVAR(requestMarkers), FUNC(copyMapRemoteSend)] call CBA_fnc_addEventHandler;
[QGVAR(sendbackMarkers), FUNC(copyMapReceiveMarkers)] call CBA_fnc_addEventHandler;
ADDON = true; ADDON = true;

View File

@ -12,8 +12,6 @@ class CfgPatches {
}; };
}; };
#include "ACE_Settings.hpp"
class RscControlsGroup; class RscControlsGroup;
class RscActiveText; class RscActiveText;
class RscPicture; class RscPicture;
@ -29,47 +27,3 @@ class RscEdit;
#include "CfgEventHandlers.hpp" #include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp" #include "CfgVehicles.hpp"
#include "CfgWeapons.hpp" #include "CfgWeapons.hpp"
// REGULAR MAP
class RscDisplayMainMap {
// Create the drawing color selector
class controls {
class TopRight: RscControlsGroup {
#include "MapControls.hpp"
};
};
};
// BRIEFING SCREEN
class RscDisplayGetReady: RscDisplayMainMap {
// Create the drawing color selector
class controls {
class TopRight: RscControlsGroup {
#include "MapControls.hpp"
};
};
};
class RscDisplayClientGetReady: RscDisplayGetReady {
// Create the drawing color selector
class controls {
class TopRight: RscControlsGroup {
#include "MapControls.hpp"
};
};
};
class RscDisplayServerGetReady: RscDisplayGetReady {
// Create the drawing color selector
class controls {
class TopRight: RscControlsGroup {
#include "MapControls.hpp"
};
};
};
class ACE_newEvents {
drawing_sendbackMarkers = QGVAR(sendbackMarkers);
drawing_requestMarkers = QGVAR(requestMarkers);
drawing_addLineMarker = QGVAR(addLineMarker);
drawing_removeLineMarker = QGVAR(removeLineMarker);
};

View File

@ -1,43 +0,0 @@
/*
* Author: esteldunedain
* Add the line marker
*
* Arguments:
* 0: Marker Name <STRING>
* 1: Marker start pos <ARRAY>
* 2: Marker end pos <ARRAY>
* 3: Color index <NUMBER>
*
* Return value:
* None
*
* Public: No
*/
#include "script_component.hpp"
params ["_name", "_startPos", "_endPos", "_color"];
private ["_marker", "_difPos", "_mag"];
_difPos = _endPos vectorDiff _startPos;
_marker = createMarkerLocal [_name, _startPos];
_name setMarkerShapeLocal "RECTANGLE";
_name setMarkerAlphaLocal 1;
_name setMarkerColorLocal _color;
_name setMarkerPosLocal (_startPos vectorAdd (_difPos vectorMultiply 0.5));
_mag = vectorMagnitude _difPos;
if (_mag > 0) then {
_name setMarkerSizeLocal [5, _mag / 2];
_name setMarkerDirLocal (180 + (_difPos select 0) atan2 (_difPos select 1) mod 360);
} else {
_name setMarkerSizeLocal [5, 5];
_name setMarkerDirLocal 0;
};
GVAR(drawing_lineMarkers) pushBack (+_this);
if (isServer && GVAR(drawing_syncMarkers)) then {
GVAR(drawing_serverLineMarkers) pushBack (+_this);
publicVariable QGVAR(drawing_serverLineMarkers);
};

View File

@ -12,9 +12,7 @@
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_screenOffset", "_pos"]; private _pos = ((findDisplay 12) displayCtrl 51) ctrlMapScreenToWorld [0.5, 0.5];
private _screenOffset = ((findDisplay 12) displayCtrl 51) posWorldToScreen [(_pos select 0) + 100, (_pos select 1)];
_pos = ((findDisplay 12) displayCtrl 51) ctrlMapScreenToWorld [0.5, 0.5];
_screenOffset = ((findDisplay 12) displayCtrl 51) posWorldToScreen [(_pos select 0) + 100, (_pos select 1)];
(_screenOffset select 0) - 0.5 (_screenOffset select 0) - 0.5

View File

@ -1,16 +0,0 @@
/*
* Author: esteldunedain
* canDraw
*
* Arguments:
* None
*
* Return value:
* <BOOL>
*
* Public: No
*/
#include "script_component.hpp"
(missionNameSpace getVariable [QGVAR(drawing_syncMarkers), true] && {GVAR(EveryoneCanDrawOnBriefing)}) ||
{(!isNull ACE_player) && {"ACE_MapTools" in items ACE_player}}

View File

@ -1,19 +0,0 @@
/*
* Author: esteldunedain
* Cancel the drawing of the current line marker
*
* Arguments:
* None
*
* Return value:
* None
*
* Public: No
*/
#include "script_component.hpp"
GVAR(drawing_isDrawing) = false;
if (count GVAR(drawing_tempLineMarker) > 0) then {
deleteMarkerLocal (GVAR(drawing_tempLineMarker) select 0);
};
GVAR(drawing_tempLineMarker) = [];

View File

@ -1,24 +0,0 @@
/*
* Author: esteldunedain
* Copy recieved markers to map
*
* Arguments:
* 0: Array of markers to copy <ARRAY>
*
* Return value:
* None
*
* Public: No
*/
#include "script_component.hpp"
params ["_lineMarkers"];
{
private "_marker";
_marker = _x;
//Add marker if we don't already have it
if (({(_x select 0) == (_marker select 0)} count GVAR(drawing_lineMarkers)) == 0) then {
_marker call FUNC(addLineMarker);
};
} forEach _lineMarkers;

View File

@ -1,17 +0,0 @@
/*
* Author: esteldunedain
*
* Send Map markers to other player
*
* Argument:
* 0: Target player (Unit)
*
* Return value:
* Return
*/
#include "script_component.hpp"
params ["_requester"];
[QGVAR(sendbackMarkers), [GVAR(drawing_lineMarkers)], _requester] call CBA_fnc_targetEvent;

View File

@ -1,22 +0,0 @@
/*
* Author: esteldunedain
* Send request to remote player
*
* Arguments:
* 0: Player <OBJECT>
* 0: Target player <OBJECT>
*
* Code Chain:
* START: copyMapStart: triggers event drawing_requestMarkers on remote
* handeled by: copyMapRemoteSend: triggers event "drawing_sendbackMarkers" on origin
* handeled by: copyMapReceiveMarkers
*
* Return value:
* Return
*/
#include "script_component.hpp"
params ["_player", "_target"];
[QGVAR(requestMarkers), [_player], _target] call CBA_fnc_targetEvent;

View File

@ -1,73 +0,0 @@
/*
* Author: esteldunedain
* Handle key down on map.
*
* Arguments:
* 0: Display (display)
* 1: Key code (number)
* 2: Shift Key (boolean)
* 3: Ctrl Key (boolean)
* 4: Alt Key (boolean)
*
* Return value:
* Boolean, true if event was handled
*/
#include "script_component.hpp"
params ["", "_code"];
TRACE_1("params",_code);
private ["_handled", "_relPos", "_diffVector", "_magDiffVector", "_lambdaLong", "_lambdaTrasAbs"];
_handled = false;
#define DIK_ESCAPE 0x01
#define DIK_DELETE 0xD3
// If pressed Esc while drawing
if (_code == DIK_ESCAPE) exitWith {
if (GVAR(drawing_isDrawing)) then {
call FUNC(cancelDrawing);
_handled = true;
};
_handled
};
if (_code == DIK_DELETE) exitWith {
if (GVAR(drawing_isDrawing)) then {
call FUNC(cancelDrawing);
_handled = true;
} else {
// Check if a line marker needs to be deleted
{
_relPos = GVAR(mousePosition) vectorDiff (_x select 1);
_diffVector = (_x select 2) vectorDiff (_x select 1);
_magDiffVector = vectorMagnitude _diffVector;
if (_magDiffVector == 0) then {
_diffVector = [10,0,0];
_magDiffVector = vectorMagnitude _diffVector;
};
_diffVector = _diffVector vectorMultiply (1/_magDiffVector);
// Projection of the relative position over the longitudinal axis
_lambdaLong = _diffVector vectorDotProduct _relPos;
// Projection of the relative position over the trasversal axis
_lambdaTrasAbs = vectorMagnitude (_relPos vectorDiff (_diffVector vectorMultiply _lambdaLong));
if (_lambdaLong >= 0 && _lambdaLong <= _magDiffVector && _lambdaTrasAbs <= 5) exitWith {
// Delete the line marker
if (GVAR(drawing_syncMarkers)) then {
[QGVAR(removeLineMarker), [_x select 0]] call CBA_fnc_globalEvent;
} else {
deleteMarkerLocal (_x select 0);
GVAR(drawing_lineMarkers) = GVAR(drawing_lineMarkers) - [_x];
};
_handled = true;
};
} forEach GVAR(drawing_lineMarkers);
};
_handled
};
_handled

View File

@ -9,16 +9,13 @@
* Return value: * Return value:
* Boolean, true if event was handled * Boolean, true if event was handled
*/ */
#include "script_component.hpp" #include "script_component.hpp"
params ["_dir", "_params"]; params ["_dir", "_params"];
_params params ["_control", "_button", "_screenPosX", "_screenPosY", "_shiftKey", "_ctrlKey", "_altKey"]; _params params ["_control", "_button", "_screenPosX", "_screenPosY", "_shiftKey", "_ctrlKey", "_altKey"];
TRACE_2("params",_dir,_params); TRACE_2("params",_dir,_params);
private["_gui", "_handled", "_marker", "_pos"]; private _handled = false;
_handled = false;
// If it's not a left button event, exit // If it's not a left button event, exit
if (_button != 0) exitWith {_handled}; if (_button != 0) exitWith {_handled};
@ -32,51 +29,24 @@ if (_dir != 1) then {
}; };
} else { } else {
// If clicking // If clicking
if !(call FUNC(canDraw)) exitWith {_handled = false;}; if !(call FUNC(canUseMapTools)) exitWith {};
// Transform mouse screen position to coordinates // Transform mouse screen position to coordinates
_pos = _control ctrlMapScreenToWorld [_screenPosX, _screenPosY]; private _pos = _control ctrlMapScreenToWorld [_screenPosX, _screenPosY];
_pos set [count _pos, 0]; _pos set [count _pos, 0];
if (GVAR(drawing_isDrawing)) exitWith {
// Already drawing -> Add tempLineMarker to permanent list
if (GVAR(drawing_syncMarkers)) then {
deleteMarkerLocal (GVAR(drawing_tempLineMarker) select 0);
[QGVAR(addLineMarker), GVAR(drawing_tempLineMarker)] call CBA_fnc_globalEvent;
// Log who drew on the briefing screen
[ACE_INFOFORMAT_1("Player %1 drew on the briefing screen", profileName)] call EFUNC(common,serverLog);
} else {
GVAR(drawing_tempLineMarker) call FUNC(updateLineMarker);
GVAR(drawing_lineMarkers) pushBack (+GVAR(drawing_tempLineMarker));
};
GVAR(drawing_tempLineMarker) = [];
GVAR(drawing_isDrawing) = false;
_handled = true;
};
if (_altKey) exitWith {
// Start drawing
GVAR(drawing_isDrawing) = true;
// Create tempLineMarker
_gui = format ["%1%2%3%4", random (100), random (100), random (100), random (100)];
GVAR(drawing_tempLineMarker) = [_gui, + _pos, + _pos, GVAR(drawing_drawColor)];
_marker = createMarkerLocal [_gui, [0,0]];
GVAR(drawing_tempLineMarker) call FUNC(updateLineMarker);
_handled = true;
};
GVAR(mapTool_isDragging) = false; GVAR(mapTool_isDragging) = false;
GVAR(mapTool_isRotating) = false; GVAR(mapTool_isRotating) = false;
// If no map tool marker then exit // If no map tool marker then exit
if (GVAR(mapTool_Shown) == 0) exitWith {_handled = false;}; if (GVAR(mapTool_Shown) == 0) exitWith {};
// Check if clicking the maptool // Check if clicking the maptool
if (_pos call FUNC(isInsideMapTool)) exitWith { if (_pos call FUNC(isInsideMapTool)) exitWith {
// Store data for dragging // Store data for dragging
GVAR(mapTool_startPos) = + GVAR(mapTool_pos); GVAR(mapTool_startPos) = + GVAR(mapTool_pos);
GVAR(mapTool_startDragPos) = + _pos; GVAR(mapTool_startDragPos) = + _pos;
if (_ctrlKey) then { if (_altKey) then {
// Store data for rotating // Store data for rotating
GVAR(mapTool_startAngle) = + GVAR(mapTool_angle); GVAR(mapTool_startAngle) = + GVAR(mapTool_angle);
GVAR(mapTool_startDragAngle) = (180 + ((GVAR(mapTool_startDragPos) select 0) - (GVAR(mapTool_startPos) select 0)) atan2 ((GVAR(mapTool_startDragPos) select 1) - (GVAR(mapTool_startPos) select 1)) mod 360); GVAR(mapTool_startDragAngle) = (180 + ((GVAR(mapTool_startDragPos) select 0) - (GVAR(mapTool_startPos) select 0)) atan2 ((GVAR(mapTool_startDragPos) select 1) - (GVAR(mapTool_startPos) select 1)) mod 360);
@ -88,7 +58,6 @@ if (_dir != 1) then {
}; };
_handled = true; _handled = true;
}; };
_handled
}; };
_handled _handled

View File

@ -15,44 +15,28 @@
params ["_control", "_mousePosX", "_mousePosY"]; params ["_control", "_mousePosX", "_mousePosY"];
TRACE_3("params",_control,_mousePosX,_mousePosY); TRACE_3("params",_control,_mousePosX,_mousePosY);
private ["_control", "_pos"]; // If have no map tools, then exit
if (((isNull ACE_player) || {!("ACE_MapTools" in items ACE_player)})) exitWith {
GVAR(mousePosition) = _control ctrlMapScreenToWorld [_mousePosX, _mousePosY];
GVAR(mousePosition) set [2, 0]; //convert 2d pos to 3d
// If cannot draw then exit
if !(call FUNC(canDraw)) exitWith {
// If was drawing, cancel
if (GVAR(drawing_isDrawing)) then {
call FUNC(cancelDrawing);
};
false false
}; };
// Handle drawing // If map tools not shown, then exit
if (GVAR(drawing_isDrawing)) exitWith {
GVAR(drawing_tempLineMarker) set [2, GVAR(mousePosition)];
TRACE_1("updating line pos",GVAR(mousePosition));
GVAR(drawing_tempLineMarker) call FUNC(updateLineMarker);
false
};
// Handle Map tools
if (GVAR(mapTool_Shown) == 0) exitWith {false}; if (GVAR(mapTool_Shown) == 0) exitWith {false};
private _mousePosition = _control ctrlMapScreenToWorld [_mousePosX, _mousePosY];
// Translation // Translation
if (GVAR(mapTool_isDragging)) exitWith { if (GVAR(mapTool_isDragging)) exitWith {
GVAR(mapTool_pos) set [0, (GVAR(mapTool_startPos) select 0) + (GVAR(mousePosition) select 0) - (GVAR(mapTool_startDragPos) select 0)]; GVAR(mapTool_pos) set [0, (GVAR(mapTool_startPos) select 0) + (_mousePosition select 0) - (GVAR(mapTool_startDragPos) select 0)];
GVAR(mapTool_pos) set [1, (GVAR(mapTool_startPos) select 1) + (GVAR(mousePosition) select 1) - (GVAR(mapTool_startDragPos) select 1)]; GVAR(mapTool_pos) set [1, (GVAR(mapTool_startPos) select 1) + (_mousePosition select 1) - (GVAR(mapTool_startDragPos) select 1)];
true true
}; };
// Rotation // Rotation
if (GVAR(mapTool_isRotating)) exitWith { if (GVAR(mapTool_isRotating)) exitWith {
private "_angle";
// Get new angle // Get new angle
_angle = (180 + ((GVAR(mousePosition) select 0) - (GVAR(mapTool_startPos) select 0)) atan2 ((GVAR(mousePosition) select 1) - (GVAR(mapTool_startPos) select 1)) mod 360); private _angle = (180 + ((_mousePosition select 0) - (GVAR(mapTool_startPos) select 0)) atan2 ((_mousePosition select 1) - (GVAR(mapTool_startPos) select 1)) mod 360);
GVAR(mapTool_angle) = GVAR(mapTool_startAngle) + _angle - GVAR(mapTool_startDragAngle); GVAR(mapTool_angle) = GVAR(mapTool_startAngle) + _angle - GVAR(mapTool_startDragAngle);
true true

View File

@ -1,42 +0,0 @@
/*
* Author: esteldunedain
*
* Handle mouse wheel.
*
* Argument:
* 0: Control
* 1: Scroll Amount
*
* Return value:
* Boolean, true if event was handled
*/
#include "script_component.hpp"
private ["_dir", "_params", "_control", "_button", "_screenPos", "_shiftKey", "_ctrlKey", "_handled", "_pos"];
_control = _this select 0;
_dir = _this select 1;
_handled = false;
_handled = true;
// If drawing, change line color
//@todo AGM bug:
// ACE_Map_drawColors is never defined
/* if (count GVAR(drawing_tempLineMarker) > 0) then {
ACE_Map_drawColor = if (_dir > 0) then {ACE_Map_drawColor + 1} else {ACE_Map_drawColor - 1};
if (ACE_Map_drawColor >= count ACE_Map_drawColors) then {
ACE_Map_drawColor = ACE_Map_drawColor - count ACE_Map_drawColors;
};
if (ACE_Map_drawColor < 0) then {
ACE_Map_drawColor = ACE_Map_drawColor + count ACE_Map_drawColors;
};
GVAR(drawing_tempLineMarker) set [3, ACE_Map_drawColor];
GVAR(drawing_tempLineMarker) call ACE_Map_fnc_updateLineMarker;
_handled = true;
}; */
_handled

View File

@ -16,21 +16,19 @@
#define DIST_TOP_TO_CENTER_PERC 0.65 #define DIST_TOP_TO_CENTER_PERC 0.65
#define DIST_LEFT_TO_CENTER_PERC 0.30 #define DIST_LEFT_TO_CENTER_PERC 0.30
private ["_textureWidth", "_relPos", "_dirVector", "_lambdaLong", "_lambdaTrasAbs", "_pos"];
if (GVAR(mapTool_Shown) == 0) exitWith {false}; if (GVAR(mapTool_Shown) == 0) exitWith {false};
_textureWidth = [TEXTURE_WIDTH_IN_M, TEXTURE_WIDTH_IN_M / 2] select (GVAR(mapTool_Shown) - 1); private _textureWidth = [TEXTURE_WIDTH_IN_M, TEXTURE_WIDTH_IN_M / 2] select (GVAR(mapTool_Shown) - 1);
_pos = [_this select 0, _this select 1, 0]; private _pos = [_this select 0, _this select 1, 0];
_relPos = _pos vectorDiff [GVAR(mapTool_pos) select 0, GVAR(mapTool_pos) select 1, 0]; private _relPos = _pos vectorDiff [GVAR(mapTool_pos) select 0, GVAR(mapTool_pos) select 1, 0];
_dirVector = [sin(GVAR(mapTool_angle)), cos(GVAR(mapTool_angle)), 0]; private _dirVector = [sin(GVAR(mapTool_angle)), cos(GVAR(mapTool_angle)), 0];
// Projection of the relative position over the longitudinal axis of the map tool // Projection of the relative position over the longitudinal axis of the map tool
_lambdaLong = _dirVector vectorDotProduct _relPos; private _lambdaLong = _dirVector vectorDotProduct _relPos;
if (_lambdaLong < DIST_BOTTOM_TO_CENTER_PERC * _textureWidth) exitWith {false}; if (_lambdaLong < DIST_BOTTOM_TO_CENTER_PERC * _textureWidth) exitWith {false};
// Projection of the relative position over the trasversal axis of the map tool // Projection of the relative position over the trasversal axis of the map tool
_lambdaTrasAbs = vectorMagnitude (_relPos vectorDiff (_dirVector vectorMultiply _lambdaLong)); private _lambdaTrasAbs = vectorMagnitude (_relPos vectorDiff (_dirVector vectorMultiply _lambdaLong));
if (_lambdaLong > DIST_TOP_TO_CENTER_PERC * _textureWidth) exitWith {false}; if (_lambdaLong > DIST_TOP_TO_CENTER_PERC * _textureWidth) exitWith {false};
if (_lambdaTrasAbs > DIST_LEFT_TO_CENTER_PERC * _textureWidth) exitWith {false}; if (_lambdaTrasAbs > DIST_LEFT_TO_CENTER_PERC * _textureWidth) exitWith {false};

View File

@ -14,9 +14,7 @@
params ["_shouldOpenGps"]; params ["_shouldOpenGps"];
private ["_isOpen"]; private _isOpen = !(isNull (uiNamespace getVariable [QGVAR(ui_mapGpsDisplay), displayNull]));
_isOpen = !(isNull (uiNamespace getVariable [QGVAR(ui_mapGpsDisplay), displayNull]));
if (_shouldOpenGps && {"ItemGPS" in assignedItems ACE_player} && {!_isOpen}) then { if (_shouldOpenGps && {"ItemGPS" in assignedItems ACE_player} && {!_isOpen}) then {
("RscACE_MapGps" call BIS_fnc_rscLayer) cutRsc ["RscACE_MapGps","PLAIN"]; ("RscACE_MapGps" call BIS_fnc_rscLayer) cutRsc ["RscACE_MapGps","PLAIN"];

View File

@ -3,16 +3,14 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_mapGpsDisplay", "_ctrl"];
if ((!("ItemGPS" in assigneditems ACE_player)) || {isNull (uiNamespace getVariable [QGVAR(ui_mapGpsDisplay), displayNull])}) exitWith { if ((!("ItemGPS" in assigneditems ACE_player)) || {isNull (uiNamespace getVariable [QGVAR(ui_mapGpsDisplay), displayNull])}) exitWith {
("RscACE_MapGps" call BIS_fnc_rscLayer) cutText ["","PLAIN"]; // Close GPS RSC ("RscACE_MapGps" call BIS_fnc_rscLayer) cutText ["","PLAIN"]; // Close GPS RSC
[(_this select 1)] call CBA_fnc_removePerFrameHandler; // Remove frameHandler [(_this select 1)] call CBA_fnc_removePerFrameHandler; // Remove frameHandler
}; };
disableSerialization; disableSerialization;
_mapGpsDisplay = uiNamespace getVariable [QGVAR(ui_mapGpsDisplay), displayNull]; private _mapGpsDisplay = uiNamespace getVariable [QGVAR(ui_mapGpsDisplay), displayNull];
_ctrl = _mapGpsDisplay displayCtrl 913590; private _ctrl = _mapGpsDisplay displayCtrl 913590;
_ctrl ctrlSetText str (round (getDir ACE_player)); // Set Heading _ctrl ctrlSetText str (round (getDir ACE_player)); // Set Heading
_ctrl = _mapGpsDisplay displayCtrl 913591; _ctrl = _mapGpsDisplay displayCtrl 913591;
_ctrl ctrlSetText str (round ((getPosASL ACE_player) select 2) + EGVAR(common,mapAltitude)); // Set Altitude _ctrl ctrlSetText str (round ((getPosASL ACE_player) select 2) + EGVAR(common,mapAltitude)); // Set Altitude

View File

@ -1,30 +0,0 @@
/*
* Author: esteldunedain
* Remove the line marker
*
* Arguments:
* 0: Marker Name <STRING>
*
* Return value:
* Return
*/
#include "script_component.hpp"
params ["_name"];
deleteMarkerLocal _name;
{
if ((_x select 0) == _name) exitWith {
GVAR(drawing_lineMarkers) = GVAR(drawing_lineMarkers) - [_x];
};
} forEach GVAR(drawing_lineMarkers);
if (isServer && GVAR(drawing_syncMarkers)) then {
{
if ((_x select 0) == _name) exitWith {
GVAR(drawing_serverLineMarkers) = GVAR(drawing_serverLineMarkers) - [_x];
publicVariable QGVAR(drawing_serverLineMarkers);
};
} forEach GVAR(drawing_serverLineMarkers);
};

View File

@ -1,34 +0,0 @@
/*
* Author: esteldunedain
* Updates the line marker position and scale
*
* Arguments:
* 0: Marker Name <STRING>
* 1: Marker start pos <ARRAY>
* 2: Marker end pos <ARRAY>
* 3: Color index <NUMBER>
*
* Return value:
* None
*/
#include "script_component.hpp"
params ["_name", "_startPos", "_endPos", "_color"];
TRACE_4("params",_name,_startPos,_endPos,_color);
private ["_difPos", "_mag"];
_difPos = _endPos vectorDiff _startPos;
_name setMarkerShapeLocal "RECTANGLE";
_name setMarkerAlphaLocal 1;
_name setMarkerColorLocal GVAR(drawing_drawColor);
_name setMarkerPosLocal (_startPos vectorAdd (_difPos vectorMultiply 0.5));
_mag = vectorMagnitude _difPos;
if (_mag > 0) then {
_name setMarkerSizeLocal [5, _mag / 2];
_name setMarkerDirLocal (180 + (_difPos select 0) atan2 (_difPos select 1) mod 360);
} else {
_name setMarkerSizeLocal [5, 5];
_name setMarkerDirLocal 0;
};

View File

@ -18,22 +18,10 @@
params ["_theMap"]; params ["_theMap"];
private ["_rotatingTexture", "_textureWidth", "_scaleX", "_scaleY", "_xPos", "_yPos"]; if ((GVAR(mapTool_Shown) == 0) || {!("ACE_MapTools" in items ACE_player)}) exitWith {};
// Show/Hide draw buttons private _rotatingTexture = "";
if ([] call FUNC(canDraw)) then { private _textureWidth = 0;
{ ((findDisplay 12) displayCtrl _x) ctrlShow true; } forEach GVAR(drawing_controls);
} else {
{ ((findDisplay 12) displayCtrl _x) ctrlShow false; } forEach GVAR(drawing_controls);
if (GVAR(drawing_isDrawing)) then {
call FUNC(cancelDrawing);
};
};
if (!("ACE_MapTools" in items ACE_player)|| {GVAR(mapTool_Shown) == 0}) exitWith {};
_rotatingTexture = "";
_textureWidth = 0;
if (GVAR(mapTool_Shown) == 1) then { if (GVAR(mapTool_Shown) == 1) then {
_rotatingTexture = QPATHTOF(data\mapToolRotatingNormal.paa); _rotatingTexture = QPATHTOF(data\mapToolRotatingNormal.paa);
_textureWidth = TEXTURE_WIDTH_IN_M; _textureWidth = TEXTURE_WIDTH_IN_M;
@ -44,12 +32,12 @@ if (GVAR(mapTool_Shown) == 1) then {
// Update scale of both parts // Update scale of both parts
getResolution params ["_resWidth", "_resHeight", "", "", "_aspectRatio"]; getResolution params ["_resWidth", "_resHeight", "", "", "_aspectRatio"];
_scaleX = 32 * _textureWidth * CONSTANT_SCALE * (call FUNC(calculateMapScale)); private _scaleX = 32 * _textureWidth * CONSTANT_SCALE * (call FUNC(calculateMapScale));
_scaleY = _scaleX * ((_resWidth / _resHeight) / _aspectRatio); //handle bad aspect ratios private _scaleY = _scaleX * ((_resWidth / _resHeight) / _aspectRatio); //handle bad aspect ratios
// Position of the fixed part // Position of the fixed part
_xPos = GVAR(mapTool_pos) select 0; private _xPos = GVAR(mapTool_pos) select 0;
_yPos = (GVAR(mapTool_pos) select 1) + _textureWidth * CENTER_OFFSET_Y_PERC; private _yPos = (GVAR(mapTool_pos) select 1) + _textureWidth * CENTER_OFFSET_Y_PERC;
_theMap drawIcon [QPATHTOF(data\mapToolFixed.paa), [1,1,1,1], [_xPos,_yPos], _scaleX, _scaleY, 0, "", 0]; _theMap drawIcon [QPATHTOF(data\mapToolFixed.paa), [1,1,1,1], [_xPos,_yPos], _scaleX, _scaleY, 0, "", 0];

View File

@ -121,18 +121,6 @@
<Czech>Schovat GPS na mapě</Czech> <Czech>Schovat GPS na mapě</Czech>
<Russian>Скрыть GPS на карте</Russian> <Russian>Скрыть GPS на карте</Russian>
</Key> </Key>
<Key ID="STR_ACE_MapTools_CopyMap">
<English>Copy Map</English>
<German>Karte kopieren</German>
<Spanish>Copiar mapa</Spanish>
<Russian>Скопировать карту</Russian>
<Polish>Kopiuj oznaczenia mapy</Polish>
<French>Copier la carte</French>
<Czech>Zkopírovat mapu</Czech>
<Italian>Copiare Carta</Italian>
<Hungarian>Térkép másolása</Hungarian>
<Portuguese>Copiar Mapa</Portuguese>
</Key>
<Key ID="STR_ACE_MapTools_MarkerDirection"> <Key ID="STR_ACE_MapTools_MarkerDirection">
<English>Direction: %1°</English> <English>Direction: %1°</English>
<German>Drehung: %1°</German> <German>Drehung: %1°</German>