2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-03-28 01:51:30 +00:00
|
|
|
/*
|
2018-09-17 18:52:24 +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
|
|
|
|
2021-02-27 17:05:05 +00:00
|
|
|
private _editingMarker = (GVAR(editingMarker) isNotEqualTo "");
|
2019-01-03 19:31:21 +00:00
|
|
|
|
2018-09-17 18:52:24 +00:00
|
|
|
if (_closeNum isEqualTo 1) then {
|
2019-01-03 19:31:21 +00:00
|
|
|
if (_editingMarker) then {
|
2018-09-17 18:52:24 +00:00
|
|
|
//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
|
|
|
[{
|
2019-01-03 19:31:21 +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;
|
2021-02-27 17:05:05 +00:00
|
|
|
|
2019-01-03 19:31:21 +00:00
|
|
|
// Add to list of user placed markers, and then filter for deleted
|
|
|
|
GVAR(userPlacedMarkers) pushBack _newestMarker;
|
2021-12-18 23:15:32 +00:00
|
|
|
GVAR(userPlacedMarkers) = GVAR(userPlacedMarkers) select {(getMarkerPos _x) isNotEqualTo [0,0,0]};
|
2019-01-03 19:31:21 +00:00
|
|
|
|
2015-03-28 01:51:30 +00:00
|
|
|
[QGVAR(setMarkerNetwork), [
|
2019-01-03 19:31:21 +00:00
|
|
|
_newestMarker, [
|
2015-12-10 14:32:31 +00:00
|
|
|
GETGVAR(currentMarkerConfigName,""),
|
|
|
|
GETGVAR(currentMarkerColorConfigName,""),
|
|
|
|
GETGVAR(currentMarkerPosition,[]),
|
2021-04-21 20:36:08 +00:00
|
|
|
GETGVAR(currentMarkerAngle,0),
|
|
|
|
GETGVAR(currentMarkerScale,1)
|
2015-12-10 14:32:31 +00:00
|
|
|
]
|
2016-05-22 15:29:05 +00:00
|
|
|
]] call CBA_fnc_globalEvent;
|
2015-03-28 04:24:11 +00:00
|
|
|
|
2019-01-03 19:31:21 +00:00
|
|
|
}, [allMapMarkers, _editingMarker]] call CBA_fnc_execNextFrame;
|
2018-09-17 18:52:24 +00:00
|
|
|
} else {
|
2019-01-03 19:31:21 +00:00
|
|
|
if (_editingMarker) then {
|
|
|
|
// editing was canceled show the original marker again
|
2018-09-17 18:52:24 +00:00
|
|
|
GVAR(editingMarker) setMarkerAlphaLocal 1;
|
|
|
|
};
|
2015-01-18 16:17:06 +00:00
|
|
|
};
|
2018-09-17 18:52:24 +00:00
|
|
|
|
|
|
|
GVAR(editingMarker) = "";
|