update mapcopy module with CBA events

This commit is contained in:
2024-02-08 12:47:51 -08:00
parent 7268d8fd50
commit fba423e38d
14 changed files with 112 additions and 60 deletions

View File

@@ -20,16 +20,6 @@ class CfgFunctions {
class flakInitVehicle {};
class flakEH {};
};
class map {
file = "framework\map";
class initMapCopy { postInit = 1; };
class copyMapFromPlayer {}; //needs refactor
class getPlayerMapMarkers {}; //needs refactor
class loadMapMarkers {}; //needs refactor
class mapMarkerToString {}; //needs refactor
class stringToMapMarker {}; //needs refactor
};
};
class DOUBLES(PREFIX,client) {
@@ -42,7 +32,6 @@ class CfgFunctions {
};
};
class DOUBLES(PREFIX,common) {
class functions {
file = "framework\common\functions";
@@ -101,6 +90,18 @@ class CfgFunctions {
};
};
class DOUBLES(PREFIX,mapcopy) {
class functions {
file = "framework\mapcopy\functions";
class addCBASettings {preInit=1;};
class initClient {};
class getMapMarkers {};
class loadMapMarkers {};
class mapMarkerToString {};
class stringToMapMarker {};
};
};
class DOUBLES(PREFIX,performance) {
class functions {
file = "framework\performance\functions";

View File

@@ -16,6 +16,7 @@ waitUntil {!isNil QGVARMAIN(complete)};
// initialize other modules
call EFUNC(mapcopy,initClient);
call EFUNC(reinsert,initClient);
call EFUNC(resupply,initClient);
call EFUNC(triageIcons,initClient);

View File

@@ -1,5 +0,0 @@
params ["_sourcePlayer","_destinationPlayer"];
hint format["Copying map markers from %1", name _sourcePlayer];
[_destinationPlayer] remoteExecCall ["milsim_fnc_getPlayerMapMarkers",_sourcePlayer];

View File

@@ -1,16 +0,0 @@
params ["_destinationPlayer"];
_markerData = [];
hint format["Your map is being copied by %1", name _destinationPlayer];
{
_marker = toArray _x;
_marker resize 15;
if ( toString _marker == "_USER_DEFINED #" ) then {
_marker = _x call milsim_fnc_mapMarkerToString;
_markerData pushBack _marker;
};
} forEach allMapMarkers;
[_markerData] remoteExecCall ["milsim_fnc_loadMapMarkers",_destinationPlayer];

View File

@@ -1,17 +0,0 @@
_map_copy_condition =
{
('ItemMap' in (assignedItems _player)) && ('ItemMap' in (assignedItems _target)) && ([_player, _target, []] call ace_common_fnc_canInteractWith)
};
_map_copy_action =
[
"MilSimCopyMap",
"Copy Map",
"\a3\ui_f\data\igui\cfg\actions\talk_ca.paa",
{
[_target,_player] call milsim_fnc_copyMapFromPlayer
},
_map_copy_condition
] call ace_interact_menu_fnc_createAction;
["Man", 0, ["ACE_MainActions"], _map_copy_action, true] call ace_interact_menu_fnc_addActionToClass;

View File

@@ -1,10 +0,0 @@
params ["_markerList"];
if ('ItemMap' in (assignedItems player)) then {
{
_x call milsim_fnc_stringToMapMarker;
} foreach _markerList;
hint format["Map copied!"];
} else {
hint format["You need a map to copy onto!"];
};

View 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);

View 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;

View 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;

View 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;

View File

@@ -0,0 +1,3 @@
#define COMPONENT mapcopy
#define COMPONENT_BEAUTIFIED Map Copy
#include "../script_mod.hpp"