Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions addons/common/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ class Extended_DisplayLoad_EventHandlers {
class RscUnitInfo {
ADDON = QUOTE([ARR_2('ace_infoDisplayChanged', [ARR_2(_this select 0, 'Any')])] call CBA_fnc_localEvent;);
};
class RscDiary {
ADDON = QUOTE([ARR_2('RscDiary', _this # 0)] call (uiNamespace getVariable 'FUNC(addMapEventHandler_init)'));
};
class RscCustomInfoMiniMap {
ADDON = QUOTE([ARR_2('RscCustomInfoMiniMap', _this # 0)] call (uiNamespace getVariable 'FUNC(addMapEventHandler_init)'));
};
};

class Extended_InitPost_EventHandlers {
Expand Down
2 changes: 2 additions & 0 deletions addons/common/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ PREP(readSettingsFromParamsArray);
PREP(actionKeysNamesConverted);
PREP(addCanInteractWithCondition);
PREP(addLineToDebugDraw);
PREP(addMapEventHandler);
PREP(addMapEventHandler_init);
PREP(addToInventory);
PREP(assignedItemFix);
PREP(assignObjectsInList);
Expand Down
12 changes: 12 additions & 0 deletions addons/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,15 @@ class ACE_Tests {
vehicleTransportInventory = QPATHTOF(dev\test_vehicleInventory.sqf);
mapConfigs = QPATHTOF(dev\test_mapConfigs.sqf);
};

class RscDisplayMainMap {
EGVAR(mapEventHandlers,IDCs)[] = {51};
EGVAR(mapEventHandlers,type) = QEGVAR(mapEventHandlers,main);
};
class RscDisplayGetReady: RscDisplayMainMap {
EGVAR(mapEventHandlers,type) = QEGVAR(mapEventHandlers,briefing);
};
class RscCustomInfoMiniMap {
EGVAR(mapEventHandlers,IDCs)[] = {101};
EGVAR(mapEventHandlers,type) = QEGVAR(mapEventHandlers,gps);
};
41 changes: 41 additions & 0 deletions addons/common/functions/fnc_addMapEventHandler.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#define DEBUG_MODE_FULL
#include "script_component.hpp"
/*
* Author: PabstMirror
* Helper for adding event handlers code to maps. Save/Load compatible.
*
* Arguments:
* 0: Event Type <STRING>
* 1: Code for a draw EH (map ctrl will be arg 0) <CODE>
* 2: Draw on Main Map <BOOL><OPTIONAL>
* 3: Draw on Briefing Map <BOOL><OPTIONAL>
* 4: Draw on GPS Maps (ItemGPS and MicroDagr) <BOOL><OPTIONAL>
*
* Return Value:
* None
*
* Example:
* ["Draw", {}, true] call ace_common_fnc_addMapEventHandler
*
* Public: Yes
*/

if (!hasInterface) exitWith {};

params [["_type", "", [""]], ["_func", {}, [{}]], ["_drawOnMainMap", false, [false]], ["_drawOnBriefingMap", false, [false]],["_drawOnGPS", false, [false]]];
TRACE_5("addMapEventHandler",_type,_func isEqualTo {},_drawOnMainMap,_drawOnBriefingMap,_drawOnGPS);

if ((ADDMAPEVENTHANDLER_EVENTS findIf {_x == _type}) == -1) exitWith { ERROR_1("amEH enum - %1",_this); };

private _mapVarNames = [];

if (_drawOnMainMap) then { _mapVarNames pushBack QEGVAR(mapEventHandlers,main); };
if (_drawOnBriefingMap) then { _mapVarNames pushBack QEGVAR(mapEventHandlers,briefing); };
if (_drawOnGPS) then { _mapVarNames pushBack QEGVAR(mapEventHandlers,gps); };

{
private _varName = format ["%1%2", _x, _type];
private _array = missionNamespace getVariable [_varName, []];
_array pushBack _func;
missionNamespace setVariable [_varName, _array];
} forEach _mapVarNames;
52 changes: 52 additions & 0 deletions addons/common/functions/fnc_addMapEventHandler_init.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#define DEBUG_MODE_FULL
#include "script_component.hpp"
/*
* Author: PabstMirror
* Handles DisplayLoaded event for various map displays. Save/Load compatible.
*
* Arguments:
* 0: DisplayType <STRING>
* 1: Display <DISPLAY>
*
* Return Value:
* None
*
* Example:
* ["RscDisplayMainMap", findDisplay 12] call ace_common_fnc_addMapEventHandler_init
*
* Public: No
*/

params ["_className", "_display"];
TRACE_2("addMapEventHandler_init",_className,_display);

if (_display getVariable [QGVAR(mapEventHandlers_init), false]) exitWith { WARNING("map already init"); };

if (_className == "RscDiary") then {
_className = switch (ctrlIDD _display) do {
case 12: { "RscDisplayMainMap" };
case 37: { "RscDisplayGetReady" };
case 52: { "RscDisplayServerGetReady" };
case 53: { "RscDisplayClientGetReady" };
default { "" };
};
};

private _eventVar = getText (configFile >> _className >> QEGVAR(mapEventHandlers,type));
private _mapIDCS = getArray (configFile >> _className >> QEGVAR(mapEventHandlers,IDCs));
if ((_eventVar == "") || {_mapIDCS isEqualTo []}) exitWith {
ERROR_2("addMapEventHandler_init - unknown display %1-%2",_this,_className);
};

TRACE_3("adding EHs",_className,_eventVar,_mapIDCS);
{
private _mapCtrl = _display displayCtrl _x;
if (isNull _mapCtrl) exitWith {ERROR_2("map is null %1-%2",_className,_x);};
{
private _code = format ['if ((_this#0) getVariable ["ace_mapEventHandlers_active", true]) then { {call _x} forEach (missionNamespace getVariable ["%1%2", []]) }', _eventVar, _x];
private _ret = _mapCtrl ctrlAddEventHandler [_x, _code];
TRACE_3("x",_x,_code,_ret);
} forEach ADDMAPEVENTHANDLER_EVENTS;
} forEach _mapIDCS;

_display setVariable [QGVAR(mapEventHandlers_init), true];
2 changes: 2 additions & 0 deletions addons/common/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@
]

#define DIG_SURFACE_WHITELIST ["grass", "grasstall_exp", "forest_exp"]

#define ADDMAPEVENTHANDLER_EVENTS ["Draw", "MouseMoving", "MouseButtonDown", "MouseButtonUp", "MouseMoving", "MouseHolding"]
3 changes: 0 additions & 3 deletions addons/interact_menu/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ class Extended_PostInit_EventHandlers {
};

class Extended_DisplayLoad_EventHandlers {
class RscDiary {
ADDON = QUOTE(call COMPILE_FILE(XEH_displayLoad));
};
class RscDisplayInterrupt {
ADDON = QUOTE(_this call FUNC(handleEscapeMenu));
};
Expand Down
2 changes: 2 additions & 0 deletions addons/interact_menu/XEH_clientInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,5 @@ format ["%1 (%2)", (localize LSTRING(SelfInteractKey)), localize ELSTRING(common
if (_menuBackgroundSetting == 1) exitWith {[QGVAR(menuBackground), false] call EFUNC(common,blurScreen);};
if (_menuBackgroundSetting == 2) exitWith {(uiNamespace getVariable [QGVAR(menuBackground), displayNull]) closeDisplay 0;};
}] call CBA_fnc_addEventHandler;

["Draw", {call FUNC(render)}, true] call EFUNC(common,addMapEventHandler);
9 changes: 0 additions & 9 deletions addons/interact_menu/XEH_displayLoad.sqf

This file was deleted.

5 changes: 5 additions & 0 deletions addons/map/CfgWeapons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ class CfgWeapons {
};
};
};
class ItemMap;
class ace_TopographicMap: ItemMap {
GVAR(MapTypeIDC) = IDC_MAP_TOPO;
displayName = "Topo test";
};
};
55 changes: 49 additions & 6 deletions addons/map/XEH_postInitClient.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,23 @@ call FUNC(determineZoom);
};
}] call CBA_fnc_addEventHandler;


// hide clock on map if player has no watch
GVAR(hasWatch) = true;

GVAR(updateActiveMap) = true;
GVAR(activeMapTypeIDC) = 51;
["loadout", {
params ["_unit"];
if (isNull _unit) exitWith {
GVAR(hasWatch) = true;
GVAR(activeMapTypeIDC) = 51;
};
GVAR(hasWatch) = false;
{
if (_x isKindOf ["ItemWatch", configFile >> "CfgWeapons"]) exitWith {GVAR(hasWatch) = true;};
false
} count (assignedItems _unit);
GVAR(hasWatch) = ((assignedItems _unit) findIf {_x isKindOf ["ItemWatch", configFile >> "CfgWeapons"]}) != -1;
GVAR(activeMapTypeIDC) = 51 max getNumber (configFile >> "CfgWeapons" >> ((assignedItems _unit) param [0, ""]) >> QGVAR(MapTypeIDC));
}, true] call CBA_fnc_addPlayerEventHandler;

["visibleMap", { GVAR(updateActiveMap) = true; }] call CBA_fnc_addPlayerEventHandler;
addMissionEventHandler ["Loaded", { GVAR(updateActiveMap) = true; }];

// Vehicle map lighting:
GVAR(vehicleLightCondition) = {true};
Expand Down Expand Up @@ -115,3 +117,44 @@ GVAR(vehicleLightColor) = [1,1,1,0];
};
};
}, true] call CBA_fnc_addPlayerEventHandler;

// Draw map effects
["Draw", {call FUNC(onDrawMap)}, true] call EFUNC(common,addMapEventHandler);
["Draw", {call FUNC(updateMapEffects)}, true] call EFUNC(common,addMapEventHandler);

["MouseMoving", {
params ["_control", "_x", "_y"];
if (GVAR(isShaking) && {count GVAR(rightMouseButtonLastPos) == 2}) then {
private _lastPos = _control ctrlMapScreenToWorld GVAR(rightMouseButtonLastPos);
private _newPos = _control ctrlMapScreenToWorld [_x, _y];
GVAR(lastStillPosition) set [0, (GVAR(lastStillPosition) select 0) + (_lastPos select 0) - (_newPos select 0)];
GVAR(lastStillPosition) set [1, (GVAR(lastStillPosition) select 1) + (_lastPos select 1) - (_newPos select 1)];
GVAR(rightMouseButtonLastPos) = [_x, _y];
TRACE_3("Mouse Move",_lastPos,_newPos,GVAR(rightMouseButtonLastPos));
};
}, true] call EFUNC(common,addMapEventHandler);

["MouseButtonDown", {
params ["", "_button", "_x", "_y"];
if (_button == 1) then {
GVAR(rightMouseButtonLastPos) = [_x, _y];
};
}, true] call EFUNC(common,addMapEventHandler);

["MouseButtonUp", {
params ["", "_button"];
if (_button == 1) then {
GVAR(rightMouseButtonLastPos) = [];
};
}, true] call EFUNC(common,addMapEventHandler);

//get mouse position on map
["MouseMoving", {
params ["_control", "_x", "_y"];
GVAR(mousePos) = _control ctrlMapScreenToWorld [_x, _y];
}, true] call EFUNC(common,addMapEventHandler);

["MouseHolding", {
params ["_control", "_x", "_y"];
GVAR(mousePos) = _control ctrlMapScreenToWorld [_x, _y];
}, true] call EFUNC(common,addMapEventHandler);
77 changes: 74 additions & 3 deletions addons/map/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class CfgPatches {
class ADDON {
name = COMPONENT_NAME;
units[] = {};
weapons[] = {};
weapons[] = {"ace_TopographicMap"};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"ace_interaction"};
author = ECSTRING(common,ACETeam);
Expand Down Expand Up @@ -65,6 +65,76 @@ class RscMapControl {
sizeExGrid = 0.032;
};


// Topographic Map:
class ctrlMap;
class GVAR(topographicCtrl): ctrlMap {
idc = IDC_MAP_TOPO;

// scaleMin = 0.005;
// scaleMax = 10; //Lets the mini display zoom out far enough
drawObjects = 0;
text = "#(argb,8,8,3)color(1,1,1,1)";
maxSatelliteAlpha = 0;

alphaFadeStartScale = 100;
alphaFadeEndScale = 100;
colorSea[] = {0.467,0.631,1,0.25};
colorCountlinesWater[] = {0.491,0.577,0.702,0.3};
colorMainCountlinesWater[] = {0.491,0.577,0.702,0.6};
colorGrid[] = {0,0,0,0.15};
colorGridMap[] = {0,0,0,0.2};

//Text sizes:
sizeExLabel = 0;
// sizeExGrid =
sizeExUnits = 0;
// sizeExNames = //Marker's Text
sizeExInfo = 0;
sizeExLevel = 0;
// sizeEx =

ptsPerSquareRoad = 0.75;
ptsPerSquareObj = 2000; //don't show buildings

showCountourInterval = 1;

colorTracks[] = {0.0,0.0,0.0,0.25};
colorTracksFill[] = {0.0,0.0,0.0,0.25};
colorRoads[] = {0.0,0.0,0.0,0.5};
colorRoadsFill[] = {1,1,0,0.5};
colorMainRoads[] = {0.0,0.0,0.0,1};
colorMainRoadsFill[] = {1,0.6,0.4,1};
colorRailWay[] = {0.8,0.2,0,1};

colorBackground[] = {0.929412, 0.929412, 0.929412, 1.0};
colorOutside[] = {0.929412, 0.929412, 0.929412, 1.0};
colorCountlines[] = {0.647059, 0.533333, 0.286275, 1};
colorMainCountlines[] = {0.858824, 0, 0,1};
colorForest[] = {0.6, 0.8, 0.2, 0.1};
colorForestBorder[] = {0,1,0,0.25};
colorLevels[] = {0.0, 0.0, 0.0, 0.5};
colorRocks[] = {0.50, 0.50, 0.50, 0};

class Legend {
x = SafeZoneX+SafeZoneW-.340;
y = SafeZoneY+SafeZoneH-.152;
font = "RobotoCondensed";
w = .340;
h = .152;
sizeEx = 0.039210;
colorBackground[] = {0.906000, 0.901000, 0.880000, 0.5};
color[] = {0, 0, 0, 0.75};
};
class LineMarker { // make line-drawings visable (but still can't draw our own?)
textureComboBoxColor = "#(argb,8,8,3)color(1,1,1,1)";
lineWidthThin = 0.008;
lineWidthThick = 0.014;
lineDistanceMin = 3e-005;
lineLengthMin = 5;
};
};

class RscMap;
class RscDisplayArcadeMap_Layout_2: RscMap { //"Traditional" Editor:
class controlsBackground {
Expand All @@ -83,12 +153,13 @@ class RscDisplayArcadeMap_Layout_6: RscMap { //"Streamlined" Editor:

// REGULAR MAP
class RscDisplayMainMap {
EGVAR(mapEventHandlers,IDCs)[] = {IDC_MAP_MAIN, IDC_MAP_TOPO};
// Tweak map styling
class controlsBackground {
class CA_Map: RscMapControl {
onDraw = QUOTE([ctrlParent (_this select 0)] call DFUNC(onDrawMap));
#include "MapTweaks.hpp"
};
class ACE_topoMap: GVAR(topographicCtrl) {};
};
// get rid of the "center to player position" - button (as it works even on elite)
class controls {
Expand Down Expand Up @@ -140,9 +211,9 @@ class RscDisplayGetReady: RscDisplayMainMap {
// Tweak map styling
class controlsBackground {
class CA_Map: RscMapControl {
onDraw = QUOTE([ctrlParent (_this select 0)] call DFUNC(onDrawMap));
#include "MapTweaks.hpp"
};
class ACE_topoMap: GVAR(topographicCtrl) {};
};
// get rid of the "center to player position" - button (as it works even on elite)
class controls {
Expand Down
Loading