Cleanup / Headers

This commit is contained in:
PabstMirror 2015-04-07 15:01:44 -05:00
parent 2ad9193475
commit 6b0fb84f65
21 changed files with 203 additions and 213 deletions

View File

@ -1,26 +0,0 @@
// MARKERS
class CfgMarkers {
class ACE_MapToolFixed {
name = "MapToolFixed";
icon = PATHTOF(data\mapToolFixed.paa);
scope = 0;
color[] = {1,1,1,1};
size = 32;
};
class ACE_MapToolRotatingNormal {
name = "MapToolRotating";
icon = PATHTOF(data\mapToolRotatingNormal.paa);
scope = 0;
color[] = {1,1,1,1};
size = 32;
};
class ACE_MapToolRotatingSmall {
name = "MapToolRotating";
icon = PATHTOF(data\mapToolRotatingSmall.paa);
scope = 0;
color[] = {1,1,1,1};
size = 32;
};
};

View File

@ -32,7 +32,6 @@ class RscEdit;
#include "MapGpsUI.hpp"
#include "CfgEventHandlers.hpp"
#include "CfgMarkers.hpp"
#include "CfgVehicles.hpp"
#include "CfgWeapons.hpp"

View File

@ -1,18 +1,18 @@
/*
* Author: esteldunedain
*
* Add the line marker
*
* Argument:
* 0: Marker Name (string)
* 1: Marker start pos (array)
* 2: Marker end pos (array)
* 3: Color index (Number)
* Arguments:
* 0: Marker Name <STRING>
* 1: Marker start pos <ARRAY>
* 2: Marker end pos <ARRAY>
* 3: Color index <NUMBER>
*
* Return value:
* Return
* None
*
* Public: No
*/
#include "script_component.hpp"
_name = _this select 0;
@ -27,16 +27,16 @@ _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);
_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;
_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);
GVAR(drawing_serverLineMarkers) pushBack (+_this);
publicVariable QGVAR(drawing_serverLineMarkers);
};

View File

@ -1,15 +1,15 @@
/*
* Author: esteldunedain
*
* Returns the equivalent of 100m in screen coordinates
*
* Argument:
* Arguments:
* None
*
* Return value:
* Return
* No
*
* Public: No
*/
#include "script_component.hpp"
_pos = ((finddisplay 12) displayctrl 51) ctrlMapScreenToWorld [0.5, 0.5];

View File

@ -1,5 +1,15 @@
// by esteldunedain
/*
* Author: esteldunedain
* canDraw
*
* Arguments:
* None
*
* Return value:
* <BOOL>
*
* Public: No
*/
#include "script_component.hpp"
(missionNameSpace getVariable [QGVAR(drawing_syncMarkers), true] && {GVAR(EveryoneCanDrawOnBriefing)}) ||

View File

@ -1,5 +1,15 @@
// by esteldunedain
/*
* Author: esteldunedain
* canUseMapGPS
*
* Arguments:
* None
*
* Return value:
* <BOOL>
*
* Public: No
*/
#include "script_component.hpp"
visibleMap &&

View File

@ -1,5 +1,15 @@
// by esteldunedain
/*
* Author: esteldunedain
* canUseMapTools
*
* Arguments:
* None
*
* Return value:
* <BOOL>
*
* Public: No
*/
#include "script_component.hpp"
visibleMap &&

View File

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

View File

@ -1,23 +1,23 @@
/*
* Author: esteldunedain
*
* Copy recieved markers to map
*
* Argument:
* 0: Array of markers to copy (Array)
* Arguments:
* 0: Array of markers to copy <ARRAY>
*
* Return value:
* Return
* None
*
* Public: No
*/
#include "script_component.hpp"
PARAMS_1(_lineMarkers);
{
_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);
};
_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,11 +1,10 @@
/*
* Author: esteldunedain
*
* Send request to remote player
*
* Argument:
* 0: Player (Unit)
* 0: Target player (Unit)
* Arguments:
* 0: Player <OBJECT>
* 0: Target player <OBJECT>
*
* Code Chain:
* START: copyMapStart: triggers event drawing_requestMarkers on remote

View File

@ -1,9 +1,8 @@
/*
* Author: esteldunedain
*
* Handle key down on map.
*
* Argument:
* Arguments:
* 0: Display (display)
* 1: Key code (number)
* 2: Shift Key (boolean)
@ -30,45 +29,45 @@ _handled = false;
// If pressed Esc while drawing
if (_code == DIK_ESCAPE) exitWith {
if (GVAR(drawing_isDrawing)) then {
call FUNC(cancelDrawing);
_handled = true;
};
if (GVAR(drawing_isDrawing)) then {
call FUNC(cancelDrawing);
_handled = true;
};
};
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 {
["drawing_removeLineMarker", [_x select 0]] call EFUNC(common,globalEvent);
} else {
deleteMarkerLocal (_x select 0);
GVAR(drawing_lineMarkers) = GVAR(drawing_lineMarkers) - [_x];
};
if (GVAR(drawing_isDrawing)) then {
call FUNC(cancelDrawing);
_handled = true;
};
} forEach GVAR(drawing_lineMarkers);
};
} 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 {
["drawing_removeLineMarker", [_x select 0]] call EFUNC(common,globalEvent);
} else {
deleteMarkerLocal (_x select 0);
GVAR(drawing_lineMarkers) = GVAR(drawing_lineMarkers) - [_x];
};
_handled = true;
};
} forEach GVAR(drawing_lineMarkers);
};
};
_handled

View File

@ -22,18 +22,18 @@ 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
// If was drawing, cancel
if (GVAR(drawing_isDrawing)) then {
call FUNC(cancelDrawing);
};
false
};
// Handle drawing
if (GVAR(drawing_isDrawing)) exitWith {
GVAR(drawing_tempLineMarker) set [2, GVAR(mousePosition)];
GVAR(drawing_tempLineMarker) call FUNC(updateLineMarker);
false
GVAR(drawing_tempLineMarker) set [2, GVAR(mousePosition)];
GVAR(drawing_tempLineMarker) call FUNC(updateLineMarker);
false
};
// Handle Map tools
@ -41,23 +41,23 @@ if (GVAR(mapTool_Shown) == 0) exitWith {false};
// Translation
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)];
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 FUNC(updateMapToolMarkers);
true
// Update the size and rotation of the maptool
[] call FUNC(updateMapToolMarkers);
true
};
// Rotation
if (GVAR(mapTool_isRotating)) exitWith {
// 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);
GVAR(mapTool_angle) = GVAR(mapTool_startAngle) + _angle - GVAR(mapTool_startDragAngle);
// 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);
GVAR(mapTool_angle) = GVAR(mapTool_startAngle) + _angle - GVAR(mapTool_startDragAngle);
// Update the size and rotation of the maptool
[] call FUNC(updateMapToolMarkers);
true
// Update the size and rotation of the maptool
[] call FUNC(updateMapToolMarkers);
true
};
false

View File

@ -29,16 +29,16 @@ _handled = true;
// 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 = 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 {
};
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;
};
GVAR(drawing_tempLineMarker) set [3, ACE_Map_drawColor];
GVAR(drawing_tempLineMarker) call ACE_Map_fnc_updateLineMarker;
_handled = true;
_handled = true;
}; */
_handled

View File

@ -1,16 +1,14 @@
/*
* Author: esteldunedain
*
* Return true if the position is inside the map marker (to allow dragging).
*
* Argument:
* 0: x Position (in meters)
* 1: y Position (in meters)
* Arguments:
* 0: x Position (in meters) <NUMBER>
* 1: y Position (in meters) <NUMBER>
*
* Return value:
* Boolean
*/
#include "script_component.hpp"
#define TEXTURE_WIDTH_IN_M 6205
@ -19,7 +17,6 @@
#define DIST_LEFT_TO_CENTER_PERC 0.30
if (GVAR(mapTool_Shown) == 0) exitWith {false};
_textureWidth = [TEXTURE_WIDTH_IN_M, TEXTURE_WIDTH_IN_M / 2] select (GVAR(mapTool_Shown) - 1);

View File

@ -2,32 +2,32 @@
#include "script_component.hpp"
if (visibleMap) then {
// Show/Hide draw buttons
if ("ACE_MapTools" in items ACE_player) then {
{ ((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);
// Show/Hide draw buttons
if ("ACE_MapTools" in items ACE_player) then {
{ ((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);
};
};
};
};
//When Map is Closed:
if (GVAR(mapVisableLastFrame) && (!visibleMap)) then {
GVAR(mapVisableLastFrame) = false;
// Hide GPS
[false] call FUNC(openMapGps);
// Cancel drawing
call FUNC(cancelDrawing);
GVAR(mapVisableLastFrame) = false;
// Hide GPS
[false] call FUNC(openMapGps);
// Cancel drawing
call FUNC(cancelDrawing);
};
//When Map is Opened:
if ((!GVAR(mapVisableLastFrame)) && (visibleMap)) then {
//todo: "mapOpened" Event????
GVAR(mapVisableLastFrame) = true;
// Show and update map tools if required
[] call FUNC(updateMapToolMarkers);
// Show GPS if required
[GVAR(mapGpsShow)] call FUNC(openMapGps);
//todo: "mapOpened" Event????
GVAR(mapVisableLastFrame) = true;
// Show and update map tools if required
[] call FUNC(updateMapToolMarkers);
// Show GPS if required
[GVAR(mapGpsShow)] call FUNC(openMapGps);
};

View File

@ -1,25 +1,24 @@
/*
* Author: esteldunedain
*
* Opens or closes the gps on the map screen, showing coordinates
*
* Argument:
* 0: Open GPS? (Boolean)
*
* Return value:
* Nothing
*/
* Author: esteldunedain
* Opens or closes the gps on the map screen, showing coordinates
*
* Arguments:
* 0: Open GPS? <BOOL>
*
* Return value:
* Nothing
*
* Public: No
*/
#include "script_component.hpp"
_shouldOpenGps = _this select 0;
_isOpen = !(isNull (uiNamespace getVariable [QGVAR(ui_mapGpsDisplay), displayNull]));
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"];
[FUNC(openMapGpsUpdate), 0.5, []] call CBA_fnc_addPerFrameHandler; //update bearing/altitude every 0.5 sec (ticktime)
[FUNC(openMapGpsUpdate), 0.5, []] call CBA_fnc_addPerFrameHandler; //update bearing/altitude every 0.5 sec (ticktime)
} else {
("RscACE_MapGps" call BIS_fnc_rscLayer) cutText ["","PLAIN"];
("RscACE_MapGps" call BIS_fnc_rscLayer) cutText ["","PLAIN"];
};

View File

@ -11,8 +11,8 @@ disableSerialization;
_mapGpsDisplay = uiNamespace getVariable [QGVAR(ui_mapGpsDisplay), displayNull];
_ctrl = _mapGpsDisplay displayCtrl 913590;
_ctrl ctrlSetText str(round(getDir player)); //set Heading
_ctrl ctrlSetText str(round(getDir ACE_player)); //set Heading
_ctrl = _mapGpsDisplay displayCtrl 913591;
_ctrl ctrlSetText str(round((getPosASL player) select 2)); //set Altitude
_ctrl ctrlSetText str(round((getPosASL ACE_player) select 2)); //set Altitude
_ctrl = _mapGpsDisplay displayCtrl 913592;
_ctrl ctrlSetText mapGridPosition player; //set grid cords
_ctrl ctrlSetText mapGridPosition ACE_player; //set grid cords

View File

@ -1,10 +1,9 @@
/*
* Author: esteldunedain
*
* Remove the line marker
*
* Argument:
* 0: Marker Name (string)
* Arguments:
* 0: Marker Name <STRING>
*
* Return value:
* Return
@ -12,20 +11,20 @@
#include "script_component.hpp"
_name = _this select 0;
_name = _this select 0;
deleteMarkerLocal _name;
deleteMarkerLocal _name;
{
if ((_x select 0) == _name) exitWith {
GVAR(drawing_lineMarkers) = GVAR(drawing_lineMarkers) - [_x];
};
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);
{
if ((_x select 0) == _name) exitWith {
GVAR(drawing_serverLineMarkers) = GVAR(drawing_serverLineMarkers) - [_x];
publicVariable QGVAR(drawing_serverLineMarkers);
};
} forEach GVAR(drawing_serverLineMarkers);
};

View File

@ -1,24 +1,22 @@
/*
* Author: esteldunedain
*
* Updates the line marker position and scale
*
* Argument:
* 0: Marker Name (string)
* 1: Marker start pos (array)
* 2: Marker end pos (array)
* 3: Color index (Number)
* Arguments:
* 0: Marker Name <STRING>
* 1: Marker start pos <ARRAY>
* 2: Marker end pos <ARRAY>
* 3: Color index <NUMBER>
*
* Return value:
* Return
* None
*/
#include "script_component.hpp"
_name = _this select 0;
_startPos = _this select 1;
_difPos = (_this select 2) vectorDiff _startPos ;
_color = _this select 3;
_name = _this select 0;
_startPos = _this select 1;
_difPos = (_this select 2) vectorDiff _startPos ;
_color = _this select 3;
_name setMarkerShapeLocal "RECTANGLE";
_name setMarkerAlphaLocal 1;
@ -26,9 +24,9 @@ _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);
_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;
_name setMarkerSizeLocal [5, 5];
_name setMarkerDirLocal 0;
};

View File

@ -7,8 +7,9 @@
*
* Return value:
* Nothing
*
* Public: No
*/
#include "script_component.hpp"
#define TEXTURE_WIDTH_IN_M 6205

View File

@ -10,8 +10,3 @@
#endif
#include "\z\ace\Addons\main\script_macros.hpp"
#define MARKERNAME_MAPTOOL_FIXED "ACE_MapToolFixed"
#define MARKERNAME_MAPTOOL_ROTATINGNORMAL "ACE_MapToolRotatingNormal"
#define MARKERNAME_MAPTOOL_ROTATINGSMALL "ACE_MapToolRotatingSmall"