update mapcopy module with CBA events
This commit is contained in:
@@ -99,7 +99,7 @@ This directory contains a number of hpp files used to define constants throughou
|
|||||||
- A subcomponent of `fbcb2_main`. Used to gather, display, and manage diary records as intel for assets near known bases.
|
- A subcomponent of `fbcb2_main`. Used to gather, display, and manage diary records as intel for assets near known bases.
|
||||||
- `init`:
|
- `init`:
|
||||||
- Contains core initialization functions. Both server and client inits across all modules are managed here.
|
- Contains core initialization functions. Both server and client inits across all modules are managed here.
|
||||||
- `map`:
|
- `mapcopy`:
|
||||||
- Gives players the ability to copy each other's maps.
|
- Gives players the ability to copy each other's maps.
|
||||||
- `performance`:
|
- `performance`:
|
||||||
- Contains functionality for monitoring and logging performance data.
|
- Contains functionality for monitoring and logging performance data.
|
||||||
|
|||||||
@@ -20,16 +20,6 @@ class CfgFunctions {
|
|||||||
class flakInitVehicle {};
|
class flakInitVehicle {};
|
||||||
class flakEH {};
|
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) {
|
class DOUBLES(PREFIX,client) {
|
||||||
@@ -42,7 +32,6 @@ class CfgFunctions {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class DOUBLES(PREFIX,common) {
|
class DOUBLES(PREFIX,common) {
|
||||||
class functions {
|
class functions {
|
||||||
file = "framework\common\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 DOUBLES(PREFIX,performance) {
|
||||||
class functions {
|
class functions {
|
||||||
file = "framework\performance\functions";
|
file = "framework\performance\functions";
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ waitUntil {!isNil QGVARMAIN(complete)};
|
|||||||
|
|
||||||
|
|
||||||
// initialize other modules
|
// initialize other modules
|
||||||
|
call EFUNC(mapcopy,initClient);
|
||||||
call EFUNC(reinsert,initClient);
|
call EFUNC(reinsert,initClient);
|
||||||
call EFUNC(resupply,initClient);
|
call EFUNC(resupply,initClient);
|
||||||
call EFUNC(triageIcons,initClient);
|
call EFUNC(triageIcons,initClient);
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
params ["_sourcePlayer","_destinationPlayer"];
|
|
||||||
|
|
||||||
hint format["Copying map markers from %1", name _sourcePlayer];
|
|
||||||
|
|
||||||
[_destinationPlayer] remoteExecCall ["milsim_fnc_getPlayerMapMarkers",_sourcePlayer];
|
|
||||||
@@ -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];
|
|
||||||
@@ -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;
|
|
||||||
@@ -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!"];
|
|
||||||
};
|
|
||||||
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;
|
||||||
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