update mapcopy module with CBA events
This commit is contained in:
24
framework/mapcopy/functions/fn_addCBASettings.sqf
Normal file
24
framework/mapcopy/functions/fn_addCBASettings.sqf
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "..\script_component.hpp"
|
||||
|
||||
[
|
||||
QGVAR(setting_enable),
|
||||
"CHECKBOX",
|
||||
"Allow Map Copying",
|
||||
[QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)],
|
||||
true, // default value
|
||||
true, // is global
|
||||
{
|
||||
params ["_value"];
|
||||
[
|
||||
QGVAR(setting_enable),
|
||||
_value
|
||||
] call EFUNC(common,logSettingChanged);
|
||||
}
|
||||
] call CBA_fnc_addSetting;
|
||||
|
||||
[
|
||||
LEVEL_INFO,
|
||||
QUOTE(COMPONENT),
|
||||
"CREATED SETTINGS",
|
||||
[]
|
||||
] call EFUNC(common,log);
|
||||
15
framework/mapcopy/functions/fn_getMapMarkers.sqf
Normal file
15
framework/mapcopy/functions/fn_getMapMarkers.sqf
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "..\script_component.hpp"
|
||||
// serializes markers on local machine and returns them as array
|
||||
|
||||
_markerData = [];
|
||||
|
||||
{
|
||||
_marker = toArray _x;
|
||||
_marker resize 15;
|
||||
if ( toString _marker == "_USER_DEFINED #" ) then {
|
||||
_marker = _x call FUNC(mapMarkerToString);
|
||||
_markerData pushBack _marker;
|
||||
};
|
||||
} forEach allMapMarkers;
|
||||
|
||||
_markerData;
|
||||
48
framework/mapcopy/functions/fn_initClient.sqf
Normal file
48
framework/mapcopy/functions/fn_initClient.sqf
Normal file
@@ -0,0 +1,48 @@
|
||||
#include "..\script_component.hpp"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Create action to copy map markers on all inheritors of CAManBase
|
||||
////////////////////////////////////////////////////////////////////
|
||||
private _mapCopyAction =
|
||||
[
|
||||
QGVAR(actionID),
|
||||
"Copy Map",
|
||||
"\a3\ui_f\data\igui\cfg\actions\talk_ca.paa",
|
||||
{
|
||||
params ["_target", "_player", "_params"];
|
||||
format["Copying map markers from %1", name _target] call CBA_fnc_notify;
|
||||
[QGVAR(mapCopyRequest), _this, _target] call CBA_fnc_targetEvent;
|
||||
},
|
||||
{
|
||||
params ["_target", "_player", "_params"];
|
||||
[QGVAR(setting_enable)] call CBA_settings_fnc_get && {
|
||||
('ItemMap' in (assignedItems _player)) &&
|
||||
('ItemMap' in (assignedItems _target)) &&
|
||||
([_player, _target, []] call ace_common_fnc_canInteractWith)
|
||||
};
|
||||
}
|
||||
] call ace_interact_menu_fnc_createAction;
|
||||
["CAManBase", 0, ["ACE_MainActions"], _mapCopyAction, true] call ace_interact_menu_fnc_addActionToClass;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Create CBA event to receive requests
|
||||
////////////////////////////////////////////////////////////////////
|
||||
[QGVAR(mapCopyRequest), {
|
||||
params ["_me", "_requester", "_params"];
|
||||
format["Your map is being copied by %1", name _requester] call CBA_fnc_notify;
|
||||
private _myMarkers = _this call FUNC(getMapMarkers);
|
||||
[QGVAR(mapCopyResponse), [_me, _myMarkers], _requester] call CBA_fnc_targetEvent;
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Create CBA event to receive responses
|
||||
////////////////////////////////////////////////////////////////////
|
||||
[QGVAR(mapCopyResponse), {
|
||||
params [["_responder", objNull, [objNull]], ["_markerList", [], [[]]]];
|
||||
if ('ItemMap' in (assignedItems player)) then {
|
||||
[_markerList] call FUNC(loadMapMarkers);
|
||||
format["Copied %1 markers from %2", count _markerList, name _responder] call CBA_fnc_notify;
|
||||
} else {
|
||||
format["You need a map to copy onto!"] call CBA_fnc_notify;
|
||||
};
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
8
framework/mapcopy/functions/fn_loadMapMarkers.sqf
Normal file
8
framework/mapcopy/functions/fn_loadMapMarkers.sqf
Normal file
@@ -0,0 +1,8 @@
|
||||
#include "..\script_component.hpp"
|
||||
// accepts an array of serialized markers and adds them to local map
|
||||
|
||||
params [["_markerList", [], [[]]]];
|
||||
|
||||
{
|
||||
_x call FUNC(stringToMapMarker);
|
||||
} foreach _markerList;
|
||||
52
framework/mapcopy/functions/fn_mapMarkerToString.sqf
Normal file
52
framework/mapcopy/functions/fn_mapMarkerToString.sqf
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
Author:
|
||||
Killzone_Kid, modified by LAxemann
|
||||
|
||||
Description:
|
||||
Serializes marker to string for storage
|
||||
|
||||
Parameter(s):
|
||||
0: STRING - existing marker name
|
||||
1: STRING (Optional) - a single data delimiter character. Default "|"
|
||||
|
||||
Returns:
|
||||
STRING - serialized marker to be used with BIS_fnc_stringToMarker or BIS_fnc_stringToMarkerLocal
|
||||
or
|
||||
"" on error
|
||||
|
||||
Example:
|
||||
["marker_0"] call RR_mapStuff_fnc_markerToString;
|
||||
["marker_1", ":"] call RR_mapStuff_fnc_markerToString;
|
||||
*/
|
||||
|
||||
params [["_markerName", "", [""]], ["_delimiter", "|", [""]]];
|
||||
|
||||
private _markerShape = markerShape _markerName;
|
||||
private _polyLineArray = [];
|
||||
private _markerType = "none";
|
||||
if (_markerShape isEqualTo "POLYLINE") then {
|
||||
_polyLineArray = markerPolyline _markerName;
|
||||
} else {
|
||||
_markerType = markerType _markerName;
|
||||
};
|
||||
|
||||
|
||||
|
||||
toFixed 4;
|
||||
private _markerPosition = str markerPos [_markerName, true];
|
||||
toFixed -1;
|
||||
|
||||
[
|
||||
"",
|
||||
_markerName,
|
||||
_markerPosition,
|
||||
_markerType,
|
||||
_markerShape,
|
||||
markerSize _markerName,
|
||||
markerDir _markerName,
|
||||
markerBrush _markerName,
|
||||
markerColor _markerName,
|
||||
markerAlpha _markerName,
|
||||
str _polyLineArray,
|
||||
markerText _markerName
|
||||
] joinString _delimiter;
|
||||
70
framework/mapcopy/functions/fn_stringToMapMarker.sqf
Normal file
70
framework/mapcopy/functions/fn_stringToMapMarker.sqf
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
Author:
|
||||
Killzone_Kid, modified by LAxemann
|
||||
|
||||
Description:
|
||||
Creates marker from serialized data
|
||||
|
||||
Parameter(s):
|
||||
0: STRING - marker data from BIS_fnc_markerToString
|
||||
|
||||
Returns:
|
||||
STRING - created marker
|
||||
or
|
||||
"" on error or if marker exists
|
||||
|
||||
Example:
|
||||
["|marker_0|[4359.1,4093.51,0]|mil_objective|ICON|[1,1]|0|Solid|Default|1|An objective"] call RR_mapStuff_fnc_stringToMarker;
|
||||
*/
|
||||
|
||||
params [["_markerData","",[""]]];
|
||||
|
||||
if (_markerData isEqualTo "") exitWith
|
||||
{
|
||||
["Marker data is empty"] call BIS_fnc_error;
|
||||
""
|
||||
};
|
||||
|
||||
_markerData splitString (_markerData select [0,1]) params
|
||||
[
|
||||
"_markerName",
|
||||
"_markerPos",
|
||||
"_markerType",
|
||||
"_markerShape",
|
||||
"_markerSize",
|
||||
"_markerDir",
|
||||
"_markerBrush",
|
||||
"_markerColor",
|
||||
"_markerAlpha",
|
||||
"_polyLineArray",
|
||||
["_markerText",""]
|
||||
];
|
||||
|
||||
if ((count _polyLineArray) > 0) then {
|
||||
_polyLineArray = parseSimpleArray _polyLineArray;
|
||||
};
|
||||
|
||||
_markerNameData = _markerName splitString "#" select 1;
|
||||
_markerNameData splitString "/" params ["_markerCreator", "_markerID", "_markerChannel"];
|
||||
|
||||
_markerName = "_USER_DEFINED #" + _markerCreator + "/" + _markerCreator + _markerID + "/" + _markerChannel;
|
||||
|
||||
|
||||
private _marker = createMarkerLocal [_markerName, parseSimpleArray _markerPos];
|
||||
|
||||
_marker setMarkerColorLocal _markerColor;
|
||||
_marker setMarkerShapeLocal _markerShape;
|
||||
_marker setMarkerAlphaLocal parseNumber _markerAlpha;
|
||||
|
||||
|
||||
if ((count _polyLineArray) > 0) then {
|
||||
_marker setMarkerPolylineLocal _polyLineArray;
|
||||
} else {
|
||||
_marker setMarkerTypeLocal _markerType;
|
||||
_marker setMarkerSizeLocal parseSimpleArray _markerSize;
|
||||
_marker setMarkerBrushLocal _markerBrush;
|
||||
_marker setMarkerTextLocal _markerText;
|
||||
_marker setMarkerDirLocal parseNumber _markerDir;
|
||||
};
|
||||
|
||||
_marker
|
||||
3
framework/mapcopy/script_component.hpp
Normal file
3
framework/mapcopy/script_component.hpp
Normal file
@@ -0,0 +1,3 @@
|
||||
#define COMPONENT mapcopy
|
||||
#define COMPONENT_BEAUTIFIED Map Copy
|
||||
#include "../script_mod.hpp"
|
||||
Reference in New Issue
Block a user