ACE3/addons/markers/functions/fnc_placeMarker.sqf

75 lines
2.3 KiB
Plaintext
Raw Permalink Normal View History

#include "..\script_component.hpp"
2015-03-28 01:51:30 +00:00
/*
* Author: commy2, Timi007
2015-03-28 01:51:30 +00:00
* MarkerPlacement closed
*
* Arguments:
* 0: RscDisplayInsertMarker <DISPLAY>
* 1: CloseNumber (1 = ButtonOk) <NUMBER>
*
* Return Value:
2015-08-22 12:08:35 +00:00
* None
2015-03-28 01:51:30 +00:00
*
* Example:
* [onUnloadEvent] call ace_markers_fnc_placeMarker;
*
* Public: No
*/
2015-01-18 16:17:06 +00:00
2015-08-22 12:08:35 +00:00
params ["_display", "_closeNum"];
2015-08-23 19:25:41 +00:00
TRACE_2("params",_display,_closeNum);
2015-03-28 01:51:30 +00:00
private _editingMarker = (GVAR(editingMarker) isNotEqualTo "");
if (_closeNum isEqualTo 1) then {
if (_editingMarker) then {
//delete "old" marker
deleteMarker GVAR(editingMarker);
};
2015-01-18 16:17:06 +00:00
// set and send marker data the next frame. the actual marker isn't created yet
2015-03-28 03:55:19 +00:00
[{
params ["_startingMarkers", "_editingMarker"];
private _newMarkers = allMapMarkers - _startingMarkers;
private _newestMarker = "";
private _newestMarkerDist = 1e10;
{
private _distX = GVAR(currentMarkerPosition) distance2d (getMarkerPos _x);
if (_distX < _newestMarkerDist) then {
_newestMarker = _x;
_newestMarkerDist = _distX;
};
} forEach _newMarkers;
TRACE_3("",_newestMarker,_newestMarkerDist,_newMarkers);
if (_newestMarker == "") exitWith {ERROR_1("could not find user placed marker from %1",_newMarkers);};
// provide hook for external scripts
[QGVAR(markerPlaced),[_newestMarker, _editingMarker]] call CBA_fnc_localEvent;
// Add to list of user placed markers, and then filter for deleted
GVAR(userPlacedMarkers) pushBack _newestMarker;
GVAR(userPlacedMarkers) = GVAR(userPlacedMarkers) select {(getMarkerPos _x) isNotEqualTo [0,0,0]};
2015-03-28 01:51:30 +00:00
[QGVAR(setMarkerNetwork), [
_newestMarker, [
2015-12-10 14:32:31 +00:00
GETGVAR(currentMarkerConfigName,""),
GETGVAR(currentMarkerColorConfigName,""),
GETGVAR(currentMarkerPosition,[]),
GETGVAR(currentMarkerAngle,0),
GETGVAR(currentMarkerScale,1)
2015-12-10 14:32:31 +00:00
]
]] call CBA_fnc_globalEvent;
2015-03-28 04:24:11 +00:00
}, [allMapMarkers, _editingMarker]] call CBA_fnc_execNextFrame;
} else {
if (_editingMarker) then {
// editing was canceled show the original marker again
GVAR(editingMarker) setMarkerAlphaLocal 1;
};
2015-01-18 16:17:06 +00:00
};
GVAR(editingMarker) = "";