Converted to CBA style

This commit is contained in:
PabstMirror 2015-01-15 15:50:48 -06:00
parent f4c84182d4
commit b12844f175
23 changed files with 212 additions and 160 deletions

View File

@ -27,7 +27,7 @@ class controls {
colorBackground[] = {0.2,0.2,0.2,1};
colorBackgroundActive[] = {0,0,0,1};
colorFocused[] = {0,0,0,1};
onButtonClick = "missionNamespace setVariable [""AGM_Map_drawColor"", ""ColorBlack""]";
onButtonClick = QUOTE(missionNamespace setVariable [ARR_2(QGVAR(drawing_drawColor), "ColorBlack")]);
};
class ColorRed: RscButton {
idc = 36733;
@ -38,7 +38,8 @@ class controls {
colorBackground[] = {0.8,0.2,0.2,1};
colorBackgroundActive[] = {1,0,0,1};
colorFocused[] = {1,0,0,1};
onButtonClick = "missionNamespace setVariable [""AGM_Map_drawColor"", ""ColorRed""]";
// onButtonClick = "missionNamespace setVariable [""AGM_Map_drawColor"", ""ColorRed""]";
onButtonClick = QUOTE(missionNamespace setVariable [ARR_2(QGVAR(drawing_drawColor), "ColorRed")]);
};
class ColorGreen: RscButton {
idc = 36734;
@ -49,7 +50,8 @@ class controls {
colorBackground[] = {0.2,0.8,0.2,1};
colorBackgroundActive[] = {0,1,0,1};
colorFocused[] = {0,1,0,1};
onButtonClick = "missionNamespace setVariable [""AGM_Map_drawColor"", ""ColorGreen""]";
// onButtonClick = "missionNamespace setVariable [""AGM_Map_drawColor"", ""ColorGreen""]";
onButtonClick = QUOTE(missionNamespace setVariable [ARR_2(QGVAR(drawing_drawColor), "ColorGreen")]);
};
class ColorBlue: RscButton {
idc = 36735;
@ -60,7 +62,8 @@ class controls {
colorBackground[] = {0.2,0.2,0.8,1};
colorBackgroundActive[] = {0,0,1,1};
colorFocused[] = {0,0,1,1};
onButtonClick = "missionNamespace setVariable [""AGM_Map_drawColor"", ""ColorBlue""]";
// onButtonClick = "missionNamespace setVariable [""AGM_Map_drawColor"", ""ColorBlue""]";
onButtonClick = QUOTE(missionNamespace setVariable [ARR_2(QGVAR(drawing_drawColor), "ColorBlue")]);
};
class ColorYellow: RscButton {
idc = 36736;
@ -71,7 +74,8 @@ class controls {
colorBackground[] = {0.8,0.8,0.2,1};
colorBackgroundActive[] = {1,1,0,1};
colorFocused[] = {1,1,0,1};
onButtonClick = "missionNamespace setVariable [""AGM_Map_drawColor"", ""ColorYellow""]";
// onButtonClick = "missionNamespace setVariable [""AGM_Map_drawColor"", ""ColorYellow""]";
onButtonClick = QUOTE(missionNamespace setVariable [ARR_2(QGVAR(drawing_drawColor), "ColorYellow")]);
};
class ColorWhite: RscButton {
idc = 36737;
@ -82,6 +86,7 @@ class controls {
colorBackground[] = {0.8,0.8,0.8,1};
colorBackgroundActive[] = {1,1,1,1};
colorFocused[] = {1,1,1,1};
onButtonClick = "missionNamespace setVariable [""AGM_Map_drawColor"", ""ColorWhite""]";
// onButtonClick = "missionNamespace setVariable [""AGM_Map_drawColor"", ""ColorWhite""]";
onButtonClick = QUOTE(missionNamespace setVariable [ARR_2(QGVAR(drawing_drawColor), "ColorWhite")]);
};
};

View File

@ -19,7 +19,7 @@ class RscTitles {
duration = 3600;
fadein = 0;
fadeout = 0;
onLoad = QUOTE(uiNamespace setVariable [ARR_2(QGVAR(mapGpsDisplay), _this select 0)];);
onLoad = QUOTE(uiNamespace setVariable [ARR_2(QGVAR(ui_mapGpsDisplay), _this select 0)];);
//onUnLoad = "_this call onRscLoad";
class controls {
class back:RscPicture {

View File

@ -1,5 +1,7 @@
// by CAA-Picard
#include "script_component.hpp"
if (!hasInterface) exitWith{};
[] spawn {
@ -7,20 +9,20 @@ if (!hasInterface) exitWith{};
sleep 5;
_markers = [];
while {AGM_Map_BFT_Enabled and {(!isNil "AGM_player") and {alive AGM_player}}} do {
while {GVAR(BFT_Enabled) and {(!isNil "ACE_player") and {alive ACE_player}}} do {
_groups = [];
_playerSide = call AGM_Core_fnc_playerSide;
_playerSide = call EFUNC(common,playerSide);
if (AGM_Map_BFT_HideAiGroups) then {
_groups = [allGroups, {side _this == _playerSide}] call AGM_Core_fnc_filter;
if (GVAR(BFT_HideAiGroups)) then {
_groups = [allGroups, {side _this == _playerSide}] call EFUNC(common,filter);
} else {
_groups = [allGroups, {
_anyPlayers = {
[_x] call AGM_Core_fnc_isPlayer
[_x] call EFUNC(common,isPlayer);
} count units _this;
(side _this == _playerSide) && _anyPlayers > 0
}] call AGM_Core_fnc_filter;
}] call EFUNC(common,filter);
};
{
@ -31,11 +33,11 @@ if (!hasInterface) exitWith{};
for "_i" from 0 to (count _groups - 1) do {
_group1 = _groups select _i;
_markerType = [_group1] call AGM_Core_fnc_getMarkerType;
_markerType = [_group1] call EFUNC(common,getMarkerType);
_colour = format ["Color%1", side _group1];
_marker = createMarkerLocal [format ["AGM_BFT_%1", _i], [(getPos leader _group1) select 0, (getPos leader _group1) select 1]];
_marker = createMarkerLocal [format ["ACE_BFT_%1", _i], [(getPos leader _group1) select 0, (getPos leader _group1) select 1]];
_marker setMarkerTypeLocal _markerType;
_marker setMarkerColorLocal _colour;
_marker setMarkerTextLocal (groupID _group1);
@ -43,7 +45,7 @@ if (!hasInterface) exitWith{};
_markers pushBack _marker;
};
sleep AGM_Map_BFT_Interval;
sleep GVAR(BFT_Interval);
};
// Delete markers as soon as the player dies
@ -55,27 +57,28 @@ if (!hasInterface) exitWith{};
[] spawn {
// Init variables
GVAR(mapToolsShown) = 0;
AGM_Map_pos = [0,0];
AGM_Map_angle = 0;
GVAR(mapToolDragging) = false;
GVAR(mapToolRotating) = false;
AGM_Map_mapGpsShow = true;
GVAR(drawing) = false;
GVAR(tempLineMarker) = [];
GVAR(lineMarkers) = [];
GVAR(mapTool_Shown) = 0;
GVAR(mapTool_pos) = [0,0];
GVAR(mapTool_angle) = 0;
GVAR(mapTool_isDragging) = false;
GVAR(mapTool_isRotating) = false;
GVAR(mapGpsShow) = true;
GVAR(drawing_isDrawing) = false;
GVAR(drawing_tempLineMarker) = [];
GVAR(drawing_lineMarkers) = [];
GVAR(drawing_drawColor) = "ColorBlack";
GVAR(drawing_controls) = [36732, 36733, 36734, 36735, 36736, 36737];
AGM_Map_drawColor = "ColorBlack";
GVAR(drawing)Controls = [36732, 36733, 36734, 36735, 36736, 36737];
AGM_Map_fnc_installEvents = {
_fnc_installMapEvents = {
_d = _this;
diag_log format ["Installing EH in display %1", _d];
((finddisplay _d) displayctrl 51) ctrlAddEventHandler ["MouseMoving", {_this call AGM_Map_fnc_handleMouseMove;}];
((finddisplay _d) displayctrl 51) ctrlAddEventHandler ["MouseButtonDown", {[1, _this] call AGM_Map_fnc_handleMouseButton;}];
((finddisplay _d) displayctrl 51) ctrlAddEventHandler ["MouseButtonUp", {[0, _this] call AGM_Map_fnc_handleMouseButton}];
((finddisplay _d) displayctrl 51) ctrlAddEventHandler ["Draw", {[] call AGM_Map_fnc_updateMapToolMarkers;}];
(finddisplay _d) displayAddEventHandler ["KeyDown", {_this call AGM_Map_fnc_handleKeyDown;}];
((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", {[] call FUNC(updateMapToolMarkers);}];
(finddisplay _d) displayAddEventHandler ["KeyDown", {_this call FUNC(handleKeyDown);}];
};
// Wait until the briefing map is detected
@ -86,51 +89,51 @@ if (!hasInterface) exitWith{};
if (isNull findDisplay 12) then {
// Install event handlers on the map control of the briefing screen (control = 51)
GVAR(syncMarkers) = true;
GVAR(drawing_syncMarkers) = true;
if (!isNull findDisplay 52) then {
52 call AGM_Map_fnc_installEvents;
52 call _fnc_installMapEvents;
} else {
if (!isNull findDisplay 53) then {
53 call AGM_Map_fnc_installEvents;
53 call _fnc_installMapEvents;
} else {
37 call AGM_Map_fnc_installEvents;
37 call _fnc_installMapEvents;
};
};
} else {
// Briefing screen was skipped; the player is JIP, create the markers defined during the briefing
GVAR(syncMarkers) = false;
GVAR(drawing_syncMarkers) = false;
{
_x call FUNC(addLineMarker);
} forEach GVAR(serverLineMarkers);
} forEach GVAR(drawing_serverLineMarkers);
};
// Wait until the main map display is detected (display = 12)
waitUntil { !isNull findDisplay 12 };
// Install event handlers on the map control and display (control = 51)
GVAR(syncMarkers) = false;
12 call AGM_Map_fnc_installEvents;
GVAR(drawing_syncMarkers) = false;
12 call _fnc_installMapEvents;
// Update the size and rotation of map tools
[] call AGM_Map_fnc_updateMapToolMarkers;
[] call FUNC(updateMapToolMarkers);
while {true} do {
waitUntil {visibleMap};
// Show and update map tools if required
[] call AGM_Map_fnc_updateMapToolMarkers;
[] call FUNC(updateMapToolMarkers);
// Show GPS if required
[AGM_Map_mapGpsShow] call AGM_Map_fnc_openMapGps;
[GVAR(mapGpsShow)] call FUNC(openMapGps);
// Update visibility of maptools and gps, handling inventory changes
[] spawn {
while {visibleMap} do {
// Show/Hide draw buttons
if ("ACE_MapTools" in items player) then {
{ ((finddisplay 12) displayctrl _x) ctrlShow true; } forEach GVAR(drawing)Controls;
{ ((finddisplay 12) displayctrl _x) ctrlShow true; } forEach GVAR(drawing_controls);
} else {
{ ((finddisplay 12) displayctrl _x) ctrlShow false; } forEach GVAR(drawing)Controls;
if (GVAR(drawing)) then {
call AGM_Map_fnc_cancelDrawing;
{ ((finddisplay 12) displayctrl _x) ctrlShow false; } forEach GVAR(drawing_controls);
if (GVAR(drawing_isDrawing)) then {
call FUNC(cancelDrawing);
};
};
sleep 1;
@ -140,15 +143,15 @@ if (!hasInterface) exitWith{};
waitUntil {!visibleMap};
// Hide GPS
[false] call AGM_Map_fnc_openMapGps;
[false] call FUNC(openMapGps);
// Hide Map tools
deleteMarkerLocal MARKERNAME_MAPTOOL_FIXED;
deleteMarkerLocal MARKERNAME_MAPTOOL_ROTATINGNORMAL;
deleteMarkerLocal MARKERNAME_MAPTOOL_ROTATINGSMALL;
GVAR(mapToolFixed) = nil;
AGM_Map_mapToolRotatingNormal = nil;
AGM_Map_mapToolRotatingSmall = nil;
GVAR(mapTool_markerRotatingFixed) = nil;
GVAR(mapTool_markerRotatingNormal) = nil;
GVAR(mapTool_markerRotatingSmall) = nil;
// Cancel drawing
call AGM_Map_fnc_cancelDrawing;
call FUNC(cancelDrawing);
};
};

View File

@ -1,4 +1,6 @@
// by CAA-Picard
GVAR(serverLineMarkers) = [];
publicVariable QGVAR(serverLineMarkers);
#include "script_component.hpp"
GVAR(drawing_serverLineMarkers) = [];
publicVariable QGVAR(drawing_serverLineMarkers);

View File

@ -1,3 +1,5 @@
#include "script_component.hpp"
class CfgPatches {
class ADDON {
units[] = {};

View File

@ -13,6 +13,8 @@
* Return
*/
#include "script_component.hpp"
_name = _this select 0;
_startPos = _this select 1;
_difPos = (_this select 2) vectorDiff _startPos ;
@ -32,9 +34,9 @@ if (_mag > 0) then {
_name setMarkerDirLocal 0;
};
GVAR(lineMarkers) pushBack (+_this);
GVAR(drawing_lineMarkers) pushBack (+_this);
if (isServer && GVAR(syncMarkers)) then {
GVAR(serverLineMarkers) pushBack (+_this);
publicVariable QGVAR(serverLineMarkers);
if (isServer && GVAR(drawing_syncMarkers)) then {
GVAR(drawing_serverLineMarkers) pushBack (+_this);
publicVariable QGVAR(drawing_serverLineMarkers);
};

View File

@ -10,6 +10,8 @@
* None
*/
#include "script_component.hpp"
if !(hasInterface) exitWith {};
_logic = _this select 0;
@ -22,8 +24,8 @@ _logic spawn {
waitUntil {alive player};
GVAR(BFT_Enabled) = true;
[_this, QGVAR(BFT_Interval), "Interval"] call AGM_Core_fnc_readNumericParameterFromModule;
[_this, QGVAR(BFT_HideAiGroups), "HideAiGroups"] call AGM_Core_fnc_readBooleanParameterFromModule;
[_this, QGVAR(BFT_Interval), "Interval"] call EFUNC(common,readNumericParameterFromModule);
[_this, QGVAR(BFT_HideAiGroups), "HideAiGroups"] call EFUNC(common,readBooleanParameterFromModule);
diag_log text "[ACE]: Blue Force Tracking Module initialized.";
TRACE_2("[ACE]: Blue Force Tracking Module initialized.",GVAR(BFT_Interval), GVAR(BFT_HideAiGroups));

View File

@ -10,6 +10,8 @@
* Return
*/
#include "script_component.hpp"
_pos = ((finddisplay 12) displayctrl 51) ctrlMapScreenToWorld [0.5, 0.5];
_screenOffset = ((finddisplay 12) displayctrl 51) posWorldToScreen [(_pos select 0) + 100, (_pos select 1)];

View File

@ -1,4 +1,6 @@
// by CAA-Picard
(missionNameSpace getVariable [QGVAR(syncMarkers), true] && {GVAR(EveryoneCanDrawOnBriefing)}) ||
#include "script_component.hpp"
(missionNameSpace getVariable [QGVAR(drawing_syncMarkers), true] && {GVAR(EveryoneCanDrawOnBriefing)}) ||
{(!isNull player) && {"ACE_MapTools" in items player}}

View File

@ -1,5 +1,7 @@
// by CAA-Picard
#include "script_component.hpp"
visibleMap &&
{alive ACE_player} &&
{"ItemGPS" in (assignedItems ACE_player)}

View File

@ -1,8 +1,10 @@
// by CAA-Picard
#include "script_component.hpp"
visibleMap &&
{alive player} &&
{"ItemMap" in (assignedItems ACE_player)} &&
{"ACE_MapTools" in (items ACE_player)} &&
{!GVAR(mapToolDragging)} &&
{!GVAR(mapToolRotating)}
{!GVAR(mapTool_isDragging)} &&
{!GVAR(mapTool_isRotating)}

View File

@ -10,8 +10,10 @@
* Nothing
*/
GVAR(drawing) = false;
if (count GVAR(tempLineMarker) > 0) then {
deleteMarkerLocal (GVAR(tempLineMarker) select 0);
#include "script_component.hpp"
GVAR(drawing_isDrawing) = false;
if (count GVAR(drawing_tempLineMarker) > 0) then {
deleteMarkerLocal (GVAR(drawing_tempLineMarker) select 0);
};
GVAR(tempLineMarker) = [];
GVAR(drawing_tempLineMarker) = [];

View File

@ -10,12 +10,14 @@
* Return
*/
#include "script_component.hpp"
_lineMarkers = _this;
{
_marker = _x;
if (({(_x select 0) == (_marker select 0)} count GVAR(lineMarkers)) == 0) then {
if (({(_x select 0) == (_marker select 0)} count GVAR(drawing_lineMarkers)) == 0) then {
_marker call FUNC(addLineMarker);
};
} forEach _lineMarkers;

View File

@ -14,6 +14,8 @@
* Boolean, true if event was handled
*/
#include "script_component.hpp"
private ["_dir", "_params", "_control", "_button", "_screenPos", "_shiftKey", "_ctrlKey", "_handled", "_pos"];
_display = _this select 0;
@ -28,15 +30,15 @@ _handled = false;
// If pressed Esc while drawing
if (_code == DIK_ESCAPE) exitWith {
if (GVAR(drawing)) then {
call AGM_Map_fnc_cancelDrawing;
if (GVAR(drawing_isDrawing)) then {
call FUNC(cancelDrawing);
_handled = true;
};
};
if (_code == DIK_DELETE) exitWith {
if (GVAR(drawing)) then {
call AGM_Map_fnc_cancelDrawing;
if (GVAR(drawing_isDrawing)) then {
call FUNC(cancelDrawing);
_handled = true;
} else {
@ -57,16 +59,16 @@ if (_code == DIK_DELETE) exitWith {
_lambdaTrasAbs = vectorMagnitude (_relPos vectorDiff (_diffVector vectorMultiply _lambdaLong));
if (_lambdaLong >= 0 && _lambdaLong <= _magDiffVector && _lambdaTrasAbs <= 5) exitWith {
// Delete the line marker
if (GVAR(syncMarkers)) then {
[[_x select 0], "AGM_Map_fnc_removeLineMarker", 2] call AGM_Core_fnc_execRemoteFnc;
if (GVAR(drawing_syncMarkers)) then {
[[_x select 0], QFUNC(removeLineMarker), 2] call EFUNC(common,execRemoteFnc);
} else {
deleteMarkerLocal (_x select 0);
GVAR(lineMarkers) = GVAR(lineMarkers) - [_x];
GVAR(drawing_lineMarkers) = GVAR(drawing_lineMarkers) - [_x];
};
_handled = true;
};
} forEach GVAR(lineMarkers);
} forEach GVAR(drawing_lineMarkers);
};
};

View File

@ -11,6 +11,8 @@
* Boolean, true if event was handled
*/
#include "script_component.hpp"
private ["_dir", "_params", "_control", "_button", "_screenPos", "_shiftKey", "_ctrlKey", "_handled", "_pos"];
_dir = _this select 0;
@ -27,9 +29,9 @@ _handled = false;
if (_button != 0) exitWith {};
// If releasing
if (_dir != 1 && (GVAR(mapToolDragging) or GVAR(mapToolRotating))) exitWith {
GVAR(mapToolDragging) = false;
GVAR(mapToolRotating) = false;
if (_dir != 1 && (GVAR(mapTool_isDragging) or GVAR(mapTool_isRotating))) exitWith {
GVAR(mapTool_isDragging) = false;
GVAR(mapTool_isRotating) = false;
_handled = true;
_handled
};
@ -43,53 +45,53 @@ if (_dir == 1) exitWith {
_pos = _control ctrlMapScreenToWorld _screenPos;
_pos set [count _pos, 0];
if (GVAR(drawing)) exitWith {
if (GVAR(drawing_isDrawing)) exitWith {
// Already drawing -> Add tempLineMarker to permanent list
if (GVAR(syncMarkers)) then {
deleteMarkerLocal (GVAR(tempLineMarker) select 0);
[GVAR(tempLineMarker), "FUNC(addLineMarker)", 2] call AGM_Core_fnc_execRemoteFnc;
if (GVAR(drawing_syncMarkers)) then {
deleteMarkerLocal (GVAR(drawing_tempLineMarker) select 0);
[GVAR(drawing_tempLineMarker), "FUNC(addLineMarker)", 2] call EFUNC(common,execRemoteFnc);
// Log who drew on the briefing screen
(text format ["[AGM] Server: Player %1 drew on the briefing screen", name player]) call AGM_Core_fnc_serverLog;
(text format ["[ACE] Server: Player %1 drew on the briefing screen", name player]) call EFUNC(common,serverLog);
} else {
GVAR(tempLineMarker) call AGM_Map_fnc_updateLineMarker;
GVAR(lineMarkers) pushBack (+GVAR(tempLineMarker));
GVAR(drawing_tempLineMarker) call FUNC(updateLineMarker);
GVAR(drawing_lineMarkers) pushBack (+GVAR(drawing_tempLineMarker));
};
GVAR(tempLineMarker) = [];
GVAR(drawing) = false;
GVAR(drawing_tempLineMarker) = [];
GVAR(drawing_isDrawing) = false;
_handled = true;
};
if (_altKey) exitWith {
// Start drawing
GVAR(drawing) = true;
GVAR(drawing_isDrawing) = true;
// Create tempLineMarker
_gui = format ["%1%2%3%4", random (100), random (100), random (100), random (100)];
GVAR(tempLineMarker) = [_gui, + _pos, + _pos, AGM_Map_drawColor];
GVAR(drawing_tempLineMarker) = [_gui, + _pos, + _pos, GVAR(drawing_drawColor)];
_marker = createMarkerLocal [_gui, [0,0]];
GVAR(tempLineMarker) call AGM_Map_fnc_updateLineMarker;
GVAR(drawing_tempLineMarker) call FUNC(updateLineMarker);
_handled = true;
};
GVAR(mapToolDragging) = false;
GVAR(mapToolRotating) = false;
GVAR(mapTool_isDragging) = false;
GVAR(mapTool_isRotating) = false;
// If no map tool marker then exit
if (isNil QGVAR(mapToolFixed)) exitWith {_handled = false;};
if (isNil QGVAR(mapTool_markerRotatingFixed)) exitWith {_handled = false;};
// Check if clicking the maptool
if (_pos call AGM_Map_fnc_isInsideMapTool) exitWith {
if (_pos call FUNC(isInsideMapTool)) exitWith {
// Store data for dragging
AGM_Map_startPos = + AGM_Map_pos;
AGM_Map_startDragPos = + _pos;
GVAR(mapTool_startPos) = + GVAR(mapTool_pos);
GVAR(mapTool_startDragPos) = + _pos;
if (_ctrlKey) then {
// Store data for rotating
AGM_Map_startAngle = + AGM_Map_angle;
AGM_Map_startDragAngle = (180 + ((AGM_Map_startDragPos select 0) - (AGM_Map_startPos select 0)) atan2 ((AGM_Map_startDragPos select 1) - (AGM_Map_startPos select 1)) mod 360);
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);
// Start rotating
GVAR(mapToolRotating) = true;
GVAR(mapTool_isRotating) = true;
} else {
// Start dragging
GVAR(mapToolDragging) = true;
GVAR(mapTool_isDragging) = true;
};
_handled = true;
};

View File

@ -11,6 +11,8 @@
* Boolean, true if event was handled
*/
#include "script_component.hpp"
private ["_control", "_pos"];
_control = _this select 0;
@ -21,40 +23,40 @@ 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)) then {
call AGM_Map_fnc_cancelDrawing;
if (GVAR(drawing_isDrawing)) then {
call FUNC(cancelDrawing);
};
false
};
// Handle drawing
if (GVAR(drawing)) exitWith {
GVAR(tempLineMarker) set [2, GVAR(mousePosition)];
GVAR(tempLineMarker) call AGM_Map_fnc_updateLineMarker;
if (GVAR(drawing_isDrawing)) exitWith {
GVAR(drawing_tempLineMarker) set [2, GVAR(mousePosition)];
GVAR(drawing_tempLineMarker) call FUNC(updateLineMarker);
false
};
// Handle Map tools
if (isNil QGVAR(mapToolFixed)) exitWith {false};
if (isNil QGVAR(mapTool_markerRotatingFixed)) exitWith {false};
// Translation
if (GVAR(mapToolDragging)) exitWith {
AGM_Map_pos set [0, (AGM_Map_startPos select 0) + (GVAR(mousePosition) select 0) - (AGM_Map_startDragPos select 0)];
AGM_Map_pos set [1, (AGM_Map_startPos select 1) + (GVAR(mousePosition) select 1) - (AGM_Map_startDragPos select 1)];
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 [1, (GVAR(mapTool_startPos) select 1) + (GVAR(mousePosition) select 1) - (GVAR(mapTool_startDragPos) select 1)];
// Update the size and rotation of the maptool
[] call AGM_Map_fnc_updateMapToolMarkers;
[] call FUNC(updateMapToolMarkers);
true
};
// Rotation
if (GVAR(mapToolRotating)) exitWith {
if (GVAR(mapTool_isRotating)) exitWith {
// Get new angle
_angle = (180 + ((GVAR(mousePosition) select 0) - (AGM_Map_startPos select 0)) atan2 ((GVAR(mousePosition) select 1) - (AGM_Map_startPos select 1)) mod 360);
AGM_Map_angle = AGM_Map_startAngle + _angle - AGM_Map_startDragAngle;
_angle = (180 + ((GVAR(mousePosition) select 0) - (GVAR(mapTool_startPos) select 0)) atan2 ((GVAR(mousePosition) select 1) - (GVAR(mapTool_startPos) select 1)) mod 360);
GVAR(mapTool_angle) = GVAR(mapTool_startAngle) + _angle - GVAR(mapTool_startDragAngle);
// Update the size and rotation of the maptool
[] call AGM_Map_fnc_updateMapToolMarkers;
[] call FUNC(updateMapToolMarkers);
true
};

View File

@ -11,6 +11,8 @@
* Boolean, true if event was handled
*/
#include "script_component.hpp"
private ["_dir", "_params", "_control", "_button", "_screenPos", "_shiftKey", "_ctrlKey", "_handled", "_pos"];
_control = _this select 0;
@ -20,17 +22,22 @@ diag_log _this;
_handled = false;
// If drawing, change line color
if (count GVAR(tempLineMarker) > 0) then {
AGM_Map_drawColor = if (_dir > 0) then {AGM_Map_drawColor + 1} else {AGM_Map_drawColor - 1};
if (AGM_Map_drawColor >= count AGM_Map_drawColors) then {
AGM_Map_drawColor = AGM_Map_drawColor - count AGM_Map_drawColors;
//@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 (AGM_Map_drawColor < 0) then {
AGM_Map_drawColor = AGM_Map_drawColor + count AGM_Map_drawColors;
if (ACE_Map_drawColor < 0) then {
ACE_Map_drawColor = ACE_Map_drawColor + count ACE_Map_drawColors;
};
GVAR(tempLineMarker) set [3, AGM_Map_drawColor];
GVAR(tempLineMarker) call AGM_Map_fnc_updateLineMarker;
GVAR(drawing_tempLineMarker) set [3, ACE_Map_drawColor];
GVAR(drawing_tempLineMarker) call ACE_Map_fnc_updateLineMarker;
_handled = true;
};
}; */
_handled

View File

@ -11,6 +11,8 @@
* Boolean
*/
#include "script_component.hpp"
#define TEXTURE_WIDTH_IN_M 6205
#define DIST_BOTTOM_TO_CENTER_PERC -0.33
#define DIST_TOP_TO_CENTER_PERC 0.65
@ -20,8 +22,8 @@ if (GVAR(mapToolsShown) == 0) exitWith {false};
_textureWidth = [TEXTURE_WIDTH_IN_M, TEXTURE_WIDTH_IN_M / 2] select (GVAR(mapToolsShown) - 1);
_pos = [_this select 0, _this select 1, 0];
_relPos = _pos vectorDiff [AGM_Map_pos select 0, AGM_Map_pos select 1, 0];
_dirVector = [sin(AGM_Map_angle), cos(AGM_Map_angle), 0];
_relPos = _pos vectorDiff [GVAR(mapTool_pos) select 0, GVAR(mapTool_pos) select 1, 0];
_dirVector = [sin(GVAR(mapTool_angle)), cos(GVAR(mapTool_angle)), 0];
// Projection of the relative position over the longitudinal axis of the map tool
_lambdaLong = _dirVector vectorDotProduct _relPos;

View File

@ -10,20 +10,21 @@
* Nothing
*/
#include "script_component.hpp"
_open = _this select 0;
_isOpen = !(isNull (uiNamespace getVariable ['AGM_Map_mapGpsDisplay', displayNull]));
_isOpen = !(isNull (uiNamespace getVariable [QGVAR(ui_mapGpsDisplay), displayNull]));
if (_open && {"ItemGPS" in assignedItems player} && {!_isOpen}) then {
("AGM_mapGpsLayer" call BIS_fnc_rscLayer) cutRsc ["RscAGM_MapGps","PLAIN"];
("RscACE_MapGps" call BIS_fnc_rscLayer) cutRsc ["RscACE_MapGps","PLAIN"];
// Spawn a thread to update gps display
[] spawn {
disableSerialization;
while {!(isNull (uiNamespace getVariable ['AGM_Map_mapGpsDisplay', displayNull]))} do {
while {!(isNull (uiNamespace getVariable [QGVAR(ui_mapGpsDisplay), displayNull]))} do {
if !("ItemGPS" in assignedItems player) exitWith {};
_mapGpsDisplay = uiNamespace getVariable ['AGM_Map_mapGpsDisplay', displayNull];
_mapGpsDisplay = uiNamespace getVariable [QGVAR(ui_mapGpsDisplay), displayNull];
_ctrl = _mapGpsDisplay displayCtrl 913590;
_ctrl ctrlSetText str(round(getDir player));
_ctrl = _mapGpsDisplay displayCtrl 913591;
@ -33,10 +34,10 @@ if (_open && {"ItemGPS" in assignedItems player} && {!_isOpen}) then {
sleep 0.5;
};
("AGM_mapGpsLayer" call BIS_fnc_rscLayer) cutText ["","PLAIN"];
("RscACE_MapGps" call BIS_fnc_rscLayer) cutText ["","PLAIN"];
};
} else {
("AGM_mapGpsLayer" call BIS_fnc_rscLayer) cutText ["","PLAIN"];
("RscACE_MapGps" call BIS_fnc_rscLayer) cutText ["","PLAIN"];
};

View File

@ -10,20 +10,22 @@
* Return
*/
#include "script_component.hpp"
_name = _this select 0;
deleteMarkerLocal _name;
{
if ((_x select 0) == _name) exitWith {
GVAR(lineMarkers) = GVAR(lineMarkers) - [_x];
GVAR(drawing_lineMarkers) = GVAR(drawing_lineMarkers) - [_x];
};
} forEach GVAR(lineMarkers);
} forEach GVAR(drawing_lineMarkers);
if (isServer && GVAR(syncMarkers)) then {
if (isServer && GVAR(drawing_syncMarkers)) then {
{
if ((_x select 0) == _name) exitWith {
GVAR(serverLineMarkers) = GVAR(serverLineMarkers) - [_x];
publicVariable "GVAR(serverLineMarkers)";
GVAR(drawing_serverLineMarkers) = GVAR(drawing_serverLineMarkers) - [_x];
publicVariable QGVAR(drawing_serverLineMarkers);
};
} forEach GVAR(serverLineMarkers);
} forEach GVAR(drawing_serverLineMarkers);
};

View File

@ -10,4 +10,6 @@
* Return
*/
[GVAR(lineMarkers), "AGM_Map_fnc_copyMapMarkers", _this] call AGM_Core_fnc_execRemoteFnc;
#include "script_component.hpp"
[GVAR(drawing_lineMarkers), QFUNC(copyMapMarkers), _this] call EFUNC(common,execRemoteFnc);

View File

@ -13,6 +13,8 @@
* Return
*/
#include "script_component.hpp"
_name = _this select 0;
_startPos = _this select 1;
_difPos = (_this select 2) vectorDiff _startPos ;
@ -20,7 +22,7 @@
_name setMarkerShapeLocal "RECTANGLE";
_name setMarkerAlphaLocal 1;
_name setMarkerColorLocal AGM_Map_drawColor;
_name setMarkerColorLocal GVAR(drawing_drawColor);
_name setMarkerPosLocal (_startPos vectorAdd (_difPos vectorMultiply 0.5));
_mag = vectorMagnitude _difPos;
if (_mag > 0) then {

View File

@ -10,6 +10,8 @@
* Nothing
*/
#include "script_component.hpp"
#define TEXTURE_WIDTH_IN_M 6205
#define CENTER_OFFSET_Y_PERC 0.1606
#define CONSTANT_SCALE 0.2
@ -17,37 +19,37 @@
// If markers exist and they should'nt, delete them
if (!("ACE_MapTools" in items player) || {GVAR(mapToolsShown) == 0}) then {
// If markers exist, delete them
if (!isNil QGVAR(mapToolFixed)) then {
if (!isNil QGVAR(mapTool_markerRotatingFixed)) then {
deleteMarkerLocal MARKERNAME_MAPTOOL_FIXED;
GVAR(mapToolFixed) = nil;
GVAR(mapTool_markerRotatingFixed) = nil;
};
};
if (!("ACE_MapTools" in items player) || {GVAR(mapToolsShown) != 1}) then {
if (!isNil "AGM_Map_mapToolRotatingNormal") then {
if (!isNil "GVAR(mapTool_markerRotatingNormal)") then {
deleteMarkerLocal MARKERNAME_MAPTOOL_ROTATINGNORMAL;
AGM_Map_mapToolRotatingNormal = nil;
GVAR(mapTool_markerRotatingNormal) = nil;
};
};
if (!("ACE_MapTools" in items player) || {GVAR(mapToolsShown) != 2}) then {
if (!isNil "AGM_Map_mapToolRotatingSmall") then {
if (!isNil "GVAR(mapTool_markerRotatingSmall)") then {
deleteMarkerLocal MARKERNAME_MAPTOOL_ROTATINGSMALL;
AGM_Map_mapToolRotatingSmall = nil;
GVAR(mapTool_markerRotatingSmall) = nil;
};
};
if (!("ACE_MapTools" in items player)|| {GVAR(mapToolsShown) == 0}) exitWith {};
// If markers don't exist and should, create them
if (isNil QGVAR(mapToolFixed)) then {
GVAR(mapToolFixed) = createMarkerLocal [MARKERNAME_MAPTOOL_FIXED, AGM_Map_pos];
if (isNil QGVAR(mapTool_markerRotatingFixed)) then {
GVAR(mapTool_markerRotatingFixed) = createMarkerLocal [MARKERNAME_MAPTOOL_FIXED, GVAR(mapTool_pos)];
MARKERNAME_MAPTOOL_FIXED setMarkerType MARKERNAME_MAPTOOL_FIXED;
};
if ((isNil "AGM_Map_mapToolRotatingNormal") && {GVAR(mapToolsShown) == 1}) then {
AGM_Map_mapToolRotatingNormal = createMarkerLocal [MARKERNAME_MAPTOOL_ROTATINGNORMAL, AGM_Map_pos];
if ((isNil "GVAR(mapTool_markerRotatingNormal)") && {GVAR(mapToolsShown) == 1}) then {
GVAR(mapTool_markerRotatingNormal) = createMarkerLocal [MARKERNAME_MAPTOOL_ROTATINGNORMAL, GVAR(mapTool_pos)];
MARKERNAME_MAPTOOL_ROTATINGNORMAL setMarkerType MARKERNAME_MAPTOOL_ROTATINGNORMAL;
};
if ((isNil "AGM_Map_mapToolRotatingSmall") && {GVAR(mapToolsShown) == 2}) then {
AGM_Map_mapToolRotatingSmall = createMarkerLocal [MARKERNAME_MAPTOOL_ROTATINGSMALL, AGM_Map_pos];
if ((isNil "GVAR(mapTool_markerRotatingSmall)") && {GVAR(mapToolsShown) == 2}) then {
GVAR(mapTool_markerRotatingSmall) = createMarkerLocal [MARKERNAME_MAPTOOL_ROTATINGSMALL, GVAR(mapTool_pos)];
MARKERNAME_MAPTOOL_ROTATINGSMALL setMarkerType MARKERNAME_MAPTOOL_ROTATINGSMALL;
};
@ -55,17 +57,17 @@ _rotatingMarker = [MARKERNAME_MAPTOOL_ROTATINGNORMAL, MARKERNAME_MAPTOOL_ROTATIN
_textureWidth = [TEXTURE_WIDTH_IN_M, TEXTURE_WIDTH_IN_M / 2] select (GVAR(mapToolsShown) - 1);
// Update scale of both parts
_scale = _textureWidth * CONSTANT_SCALE * (call AGM_Map_fnc_calculateMapScale);
_scale = _textureWidth * CONSTANT_SCALE * (call FUNC(calculateMapScale));
MARKERNAME_MAPTOOL_FIXED setMarkerSizeLocal [_scale,_scale];
_rotatingMarker setMarkerSizeLocal [_scale,_scale];
// Position of the fixed part
_xPos = AGM_Map_pos select 0;
_yPos = (AGM_Map_pos select 1) + _textureWidth * CENTER_OFFSET_Y_PERC;
_xPos = GVAR(mapTool_pos) select 0;
_yPos = (GVAR(mapTool_pos) select 1) + _textureWidth * CENTER_OFFSET_Y_PERC;
MARKERNAME_MAPTOOL_FIXED setMarkerPosLocal [_xPos,_yPos];
// Position and rotation of the rotating part
_xPos = (AGM_Map_pos select 0) + sin(AGM_Map_angle) * _textureWidth * CENTER_OFFSET_Y_PERC;
_yPos = (AGM_Map_pos select 1) + cos(AGM_Map_angle) * _textureWidth * CENTER_OFFSET_Y_PERC;
_xPos = (GVAR(mapTool_pos) select 0) + sin(GVAR(mapTool_angle)) * _textureWidth * CENTER_OFFSET_Y_PERC;
_yPos = (GVAR(mapTool_pos) select 1) + cos(GVAR(mapTool_angle)) * _textureWidth * CENTER_OFFSET_Y_PERC;
_rotatingMarker setMarkerPosLocal [_xPos,_yPos];
_rotatingMarker setMarkerDirLocal AGM_Map_angle;
_rotatingMarker setMarkerDirLocal GVAR(mapTool_angle);