diff --git a/addons/common/CfgEventHandlers.hpp b/addons/common/CfgEventHandlers.hpp index fa4f3dcacd4..b6c473631de 100644 --- a/addons/common/CfgEventHandlers.hpp +++ b/addons/common/CfgEventHandlers.hpp @@ -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 { diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp index 4b547655394..b72cffe0fdf 100644 --- a/addons/common/XEH_PREP.hpp +++ b/addons/common/XEH_PREP.hpp @@ -10,6 +10,8 @@ PREP(readSettingsFromParamsArray); PREP(actionKeysNamesConverted); PREP(addCanInteractWithCondition); PREP(addLineToDebugDraw); +PREP(addMapEventHandler); +PREP(addMapEventHandler_init); PREP(addToInventory); PREP(assignedItemFix); PREP(assignObjectsInList); diff --git a/addons/common/config.cpp b/addons/common/config.cpp index 557b45b7329..d554dc35eb5 100644 --- a/addons/common/config.cpp +++ b/addons/common/config.cpp @@ -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); +}; diff --git a/addons/common/functions/fnc_addMapEventHandler.sqf b/addons/common/functions/fnc_addMapEventHandler.sqf new file mode 100644 index 00000000000..d506f9fa20c --- /dev/null +++ b/addons/common/functions/fnc_addMapEventHandler.sqf @@ -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 + * 1: Code for a draw EH (map ctrl will be arg 0) + * 2: Draw on Main Map + * 3: Draw on Briefing Map + * 4: Draw on GPS Maps (ItemGPS and MicroDagr) + * + * 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; diff --git a/addons/common/functions/fnc_addMapEventHandler_init.sqf b/addons/common/functions/fnc_addMapEventHandler_init.sqf new file mode 100644 index 00000000000..58f73c84eb9 --- /dev/null +++ b/addons/common/functions/fnc_addMapEventHandler_init.sqf @@ -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 + * 1: 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]; diff --git a/addons/common/script_component.hpp b/addons/common/script_component.hpp index 5eb318a9bf7..0712c486b44 100644 --- a/addons/common/script_component.hpp +++ b/addons/common/script_component.hpp @@ -30,3 +30,5 @@ ] #define DIG_SURFACE_WHITELIST ["grass", "grasstall_exp", "forest_exp"] + +#define ADDMAPEVENTHANDLER_EVENTS ["Draw", "MouseMoving", "MouseButtonDown", "MouseButtonUp", "MouseMoving", "MouseHolding"] diff --git a/addons/interact_menu/CfgEventHandlers.hpp b/addons/interact_menu/CfgEventHandlers.hpp index b5880fb05b2..94651d9ed29 100644 --- a/addons/interact_menu/CfgEventHandlers.hpp +++ b/addons/interact_menu/CfgEventHandlers.hpp @@ -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)); }; diff --git a/addons/interact_menu/XEH_clientInit.sqf b/addons/interact_menu/XEH_clientInit.sqf index bc4870ef544..a2a23794717 100644 --- a/addons/interact_menu/XEH_clientInit.sqf +++ b/addons/interact_menu/XEH_clientInit.sqf @@ -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); diff --git a/addons/interact_menu/XEH_displayLoad.sqf b/addons/interact_menu/XEH_displayLoad.sqf deleted file mode 100644 index 5d190e3d745..00000000000 --- a/addons/interact_menu/XEH_displayLoad.sqf +++ /dev/null @@ -1,9 +0,0 @@ -#include "script_component.hpp" - -disableSerialization; - -params ["_display"]; - -if (ctrlIDD _display == 12) then { // RscDisplayMainMap - (_display displayCtrl 51) ctrlAddEventHandler ["Draw", {_this call FUNC(render)}]; -}; diff --git a/addons/map/CfgWeapons.hpp b/addons/map/CfgWeapons.hpp index a9188159a31..a59d5c8f798 100644 --- a/addons/map/CfgWeapons.hpp +++ b/addons/map/CfgWeapons.hpp @@ -23,4 +23,9 @@ class CfgWeapons { }; }; }; + class ItemMap; + class ace_TopographicMap: ItemMap { + GVAR(MapTypeIDC) = IDC_MAP_TOPO; + displayName = "Topo test"; + }; }; diff --git a/addons/map/XEH_postInitClient.sqf b/addons/map/XEH_postInitClient.sqf index 6cf08cc7f3d..459848bd04b 100644 --- a/addons/map/XEH_postInitClient.sqf +++ b/addons/map/XEH_postInitClient.sqf @@ -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}; @@ -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); diff --git a/addons/map/config.cpp b/addons/map/config.cpp index aab52c35361..5c609538714 100644 --- a/addons/map/config.cpp +++ b/addons/map/config.cpp @@ -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); @@ -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 { @@ -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 { @@ -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 { diff --git a/addons/map/functions/fnc_initMainMap.sqf b/addons/map/functions/fnc_initMainMap.sqf index 1617be33db0..61531eaa5b6 100644 --- a/addons/map/functions/fnc_initMainMap.sqf +++ b/addons/map/functions/fnc_initMainMap.sqf @@ -2,6 +2,7 @@ #include "\a3\ui_f\hpp\defineResincl.inc" params ["_display"]; +TRACE_1("initMainMap",_display); if (ctrlIDD _display != IDD_MAIN_MAP) exitWith {}; private _control = _display displayCtrl IDC_MAP; @@ -22,41 +23,3 @@ GVAR(mousePos) = [0.5, 0.5]; //Allow panning the lastStillPosition while mapShake is active GVAR(rightMouseButtonLastPos) = []; - -_control ctrlAddEventHandler ["Draw", {_this call FUNC(updateMapEffects)}]; -_control ctrlAddEventHandler ["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)); - }; -}]; - -_control ctrlAddEventHandler ["MouseButtonDown", { - params ["", "_button", "_x", "_y"]; - if (_button == 1) then { - GVAR(rightMouseButtonLastPos) = [_x, _y]; - }; -}]; - -_control ctrlAddEventHandler ["MouseButtonUp", { - params ["", "_button"]; - if (_button == 1) then { - GVAR(rightMouseButtonLastPos) = []; - }; -}]; - -//get mouse position on map -_control ctrlAddEventHandler ["MouseMoving", { - params ["_control", "_x", "_y"]; - GVAR(mousePos) = _control ctrlMapScreenToWorld [_x, _y]; -}]; - -_control ctrlAddEventHandler ["MouseHolding", { - params ["_control", "_x", "_y"]; - GVAR(mousePos) = _control ctrlMapScreenToWorld [_x, _y]; -}]; diff --git a/addons/map/functions/fnc_onDrawMap.sqf b/addons/map/functions/fnc_onDrawMap.sqf index 5ad3d42fe00..1c93a87e1b0 100644 --- a/addons/map/functions/fnc_onDrawMap.sqf +++ b/addons/map/functions/fnc_onDrawMap.sqf @@ -1,10 +1,10 @@ #include "script_component.hpp" /* * Author: commy2 - * + * On map main draw (may be any of the map controls) * * Arguments: - * Something + * 0: Map control * * Return Value: * None @@ -15,7 +15,39 @@ * Public: No */ -((_this select 0) displayCtrl 1016) ctrlShow GVAR(mapShowCursorCoordinates); +params ["_mapCtrl"]; +private _display = ctrlParent _mapCtrl; + +(_display displayCtrl 1016) ctrlShow GVAR(mapShowCursorCoordinates); // hide clock when no watch in inventory, or whatever never ever -((_this select 0) displayCtrl 101) ctrlShow GVAR(hasWatch); +(_display displayCtrl 101) ctrlShow GVAR(hasWatch); + +if (GVAR(updateActiveMap)) then { + { + TRACE_2("update",GVAR(activeMapTypeIDC),_x); + private _ctrlMap = _display displayCtrl _x; + if (_x == GVAR(activeMapTypeIDC)) then { + _ctrlMap ctrlShow true; + _ctrlMap setVariable [QEGVAR(mapEventHandlers,active), true]; + } else { + _ctrlMap ctrlShow false; + _ctrlMap setVariable [QEGVAR(mapEventHandlers,active), false]; + }; + } forEach getArray (configFile >> "RscDisplayMainMap" >> QEGVAR(mapEventHandlers,IDCs)); + GVAR(updateActiveMap) = false; +}; + +if (GVAR(activeMapTypeIDC) != 51) then { + // update default map to the new maps position and scale to ensure marker placement works + private _ctrlVanillaMap = _display displayCtrl 51; + private _ctrlActiveMap = _display displayCtrl GVAR(activeMapTypeIDC); // the currently active map + if (ctrlMapAnimDone _ctrlVanillaMap) then { + private _ctrlPos = ctrlPosition _ctrlVanillaMap; + private _centerScreen = [_ctrlPos#0 + _ctrlPos#2 / 2, _ctrlPos#1 + _ctrlPos#3 / 2]; + private _centerPos = _ctrlActiveMap ctrlMapScreenToWorld _centerScreen; + private _scale = ctrlMapScale _ctrlActiveMap; + _ctrlVanillaMap ctrlMapAnimAdd [0.01, _scale, _centerPos]; + ctrlMapAnimCommit _ctrlVanillaMap; + }; +}; diff --git a/addons/map/functions/fnc_updateMapEffects.sqf b/addons/map/functions/fnc_updateMapEffects.sqf index 4e8d65bee20..7675b69aa4f 100644 --- a/addons/map/functions/fnc_updateMapEffects.sqf +++ b/addons/map/functions/fnc_updateMapEffects.sqf @@ -4,7 +4,7 @@ * On map draw, updates the effects * * Arguments: - * None + * 0: Map Control * * Return Value: * None diff --git a/addons/map/script_component.hpp b/addons/map/script_component.hpp index 432622f632d..2c2ca29dd3e 100644 --- a/addons/map/script_component.hpp +++ b/addons/map/script_component.hpp @@ -21,3 +21,6 @@ #define MARKERNAME_MAPTOOL_ROTATINGSMALL "ACE_MapToolRotatingSmall" #define DEFAULT_FLASHLIGHT_SIZE 2.75 + +#define IDC_MAP_MAIN 51 +#define IDC_MAP_TOPO 95101 diff --git a/addons/map_gestures/XEH_postInit.sqf b/addons/map_gestures/XEH_postInit.sqf index cc3daf6a06c..f8b49c95cee 100644 --- a/addons/map_gestures/XEH_postInit.sqf +++ b/addons/map_gestures/XEH_postInit.sqf @@ -8,10 +8,10 @@ if (!hasInterface) exitWith {}; ["ace_settingsInitialized", { if (!GVAR(enabled)) exitWith {}; - + // This will set QEGVAR(common,playerOwner) var on player objects [] call EFUNC(common,setPlayerOwner); - + GVAR(pointPosition) = [0,0,0]; [QGVAR(syncPos), { diff --git a/addons/map_gestures/functions/fnc_drawMapGestures.sqf b/addons/map_gestures/functions/fnc_drawMapGestures.sqf index 2aecd2388fd..6374755b7e7 100644 --- a/addons/map_gestures/functions/fnc_drawMapGestures.sqf +++ b/addons/map_gestures/functions/fnc_drawMapGestures.sqf @@ -50,7 +50,7 @@ params ["_mapHandle"]; }; TRACE_2("",_colorMap,_color); - + // Render icon and player name _mapHandle drawIcon ["\a3\ui_f\data\gui\cfg\Hints\icon_text\group_1_ca.paa", _color, _pos, ICON_RENDER_SIZE, ICON_RENDER_SIZE, ICON_ANGLE, "", ICON_SHADOW, TEXT_SIZE, TEXT_FONT, ICON_TEXT_ALIGN]; _mapHandle drawIcon ["#(argb,8,8,3)color(0,0,0,0)", GVAR(nameTextColor), _pos, TEXT_ICON_RENDER_SIZE, TEXT_ICON_RENDER_SIZE, ICON_ANGLE, name _x, TEXT_SHADOW, TEXT_SIZE, TEXT_FONT, ICON_TEXT_ALIGN]; diff --git a/addons/map_gestures/functions/fnc_receiverInit.sqf b/addons/map_gestures/functions/fnc_receiverInit.sqf index 0effb9a7d58..d02dd36c580 100644 --- a/addons/map_gestures/functions/fnc_receiverInit.sqf +++ b/addons/map_gestures/functions/fnc_receiverInit.sqf @@ -15,11 +15,9 @@ * Public: No */ +TRACE_1("receiverInit",_this); + ACE_player setVariable [QGVAR(Transmit), false, true]; GVAR(EnableTransmit) = false; -if (!isNil QGVAR(DrawMapHandlerID)) then { - (findDisplay 12 displayCtrl 51) ctrlRemoveEventHandler ["Draw", GVAR(DrawMapHandlerID)]; - GVAR(DrawMapHandlerID) = nil; -}; -GVAR(DrawMapHandlerID) = findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", {call FUNC(drawMapGestures)}]; +["Draw", {call FUNC(drawMapGestures)}, true] call EFUNC(common,addMapEventHandler); diff --git a/addons/map_gestures/functions/fnc_transmitterInit.sqf b/addons/map_gestures/functions/fnc_transmitterInit.sqf index a081ef5b149..9ea036c7804 100644 --- a/addons/map_gestures/functions/fnc_transmitterInit.sqf +++ b/addons/map_gestures/functions/fnc_transmitterInit.sqf @@ -15,34 +15,23 @@ * Public: No */ -disableSerialization; - -private _mapCtrl = findDisplay 12 displayCtrl 51; +TRACE_1("transmitterInit",_this); // MouseMoving EH. -if (!isNil QGVAR(MouseMoveHandlerID)) then { - _mapCtrl ctrlRemoveEventHandler ["MouseMoving", GVAR(MouseMoveHandlerID)]; - GVAR(MouseMoveHandlerID) = nil; -}; -GVAR(MouseMoveHandlerID) = _mapCtrl ctrlAddEventHandler ["MouseMoving", { +["MouseMoving", { // Don't transmit any data if we're using the map tools if (!GVAR(EnableTransmit) || {(["ace_maptools"] call EFUNC(common,isModLoaded)) && {EGVAR(maptools,mapTool_isDragging) || EGVAR(maptools,mapTool_isRotating)}}) exitWith {}; params ["_control", "_posX", "_posY"]; - if (!(ACE_player getVariable QGVAR(Transmit))) then { ACE_player setVariable [QGVAR(Transmit), true, true]; }; GVAR(pointPosition) = _control ctrlMapScreenToWorld [_posX, _posY]; -}]; +}, true] call EFUNC(common,addMapEventHandler); // MouseDown EH -if (!isNil QGVAR(MouseDownHandlerID)) then { - _mapCtrl ctrlRemoveEventHandler ["MouseButtonDown",GVAR(MouseDownHandlerID)]; - GVAR(MouseDownHandlerID) = nil; -}; -GVAR(MouseDownHandlerID) = _mapCtrl ctrlAddEventHandler ["MouseButtonDown", { +["MouseButtonDown", { if (!GVAR(enabled)) exitWith {}; params ["", "_button", "_x", "_y", "_shift", "_ctrl", "_alt"]; @@ -50,14 +39,10 @@ GVAR(MouseDownHandlerID) = _mapCtrl ctrlAddEventHandler ["MouseButtonDown", { if (_button == 0 && {[_shift, _ctrl, _alt] isEqualTo [false, false, false]}) then { call FUNC(initTransmit); }; -}]; +}, true] call EFUNC(common,addMapEventHandler); // MouseUp EH -if (!isNil QGVAR(MouseUpHandlerID)) then { - _mapCtrl ctrlRemoveEventHandler ["MouseButtonUp", GVAR(MouseUpHandlerID)]; - GVAR(MouseUpHandlerID) = nil; -}; -GVAR(MouseUpHandlerID) = _mapCtrl ctrlAddEventHandler ["MouseButtonUp", { +["MouseButtonUp", { if (!GVAR(enabled)) exitWith {}; params ["", "_button"]; @@ -65,4 +50,4 @@ GVAR(MouseUpHandlerID) = _mapCtrl ctrlAddEventHandler ["MouseButtonUp", { if (_button == 0) then { call FUNC(endTransmit); }; -}]; +}, true] call EFUNC(common,addMapEventHandler); diff --git a/addons/maptools/XEH_postInitClient.sqf b/addons/maptools/XEH_postInitClient.sqf index c7dceacd759..bc901b4b651 100644 --- a/addons/maptools/XEH_postInitClient.sqf +++ b/addons/maptools/XEH_postInitClient.sqf @@ -15,13 +15,10 @@ GVAR(mapTool_isDragging) = false; GVAR(mapTool_isRotating) = false; //Install the event handers for the map tools on the main in-game map -[{!isNull findDisplay 12}, -{ - ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseMoving", {_this call FUNC(handleMouseMove);}]; - ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseButtonDown", {[1, _this] call FUNC(handleMouseButton);}]; - ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseButtonUp", {[0, _this] call FUNC(handleMouseButton)}]; - ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["Draw", {call FUNC(updateMapToolMarkers); call FUNC(openMapGpsUpdate);}]; -}, []] call CBA_fnc_waitUntilAndExecute; +["Draw", {call FUNC(updateMapToolMarkers); call FUNC(openMapGpsUpdate);}, true] call EFUNC(common,addMapEventHandler); +["MouseMoving", {call FUNC(handleMouseMove);}, true] call EFUNC(common,addMapEventHandler); +["MouseButtonDown", {[1, _this] call FUNC(handleMouseButton);}, true] call EFUNC(common,addMapEventHandler); +["MouseButtonUp", {[0, _this] call FUNC(handleMouseButton)}, true] call EFUNC(common,addMapEventHandler); ["visibleMap", { params ["", "_mapOn"]; @@ -34,4 +31,3 @@ GVAR(mapTool_isRotating) = false; GVAR(freeDrawingData) = []; GVAR(freedrawing) = false; - diff --git a/addons/markers/XEH_postInit.sqf b/addons/markers/XEH_postInit.sqf index 7f644691d3f..b051ac6f094 100644 --- a/addons/markers/XEH_postInit.sqf +++ b/addons/markers/XEH_postInit.sqf @@ -12,7 +12,13 @@ if (isMultiplayer && {!isServer} && {hasInterface}) then { [QGVAR(sendMarkersJIP), CBA_clientID] call CBA_fnc_serverEvent; }; -GVAR(mapDisplaysWithDrawEHs) = []; +// Run MapDrawEH on main and briefing maps +["Draw", {call FUNC(mapDrawEH)}, true, true] call EFUNC(common,addMapEventHandler); + +// movable markers (add on main and briefing maps) +["MouseButtonDown", {_this call FUNC(onMouseButtonDown)}, true, true] call EFUNC(common,addMapEventHandler); +["MouseButtonUp", {_this call FUNC(onMouseButtonUp)}, true, true] call EFUNC(common,addMapEventHandler); + GVAR(currentMarkerPosition) = []; GVAR(currentMarkerAngle) = 0; GVAR(currentMarkerColorConfigName) = ""; diff --git a/addons/markers/functions/fnc_initInsertMarker.sqf b/addons/markers/functions/fnc_initInsertMarker.sqf index 8a7a5f21fb1..7d41e3c999f 100644 --- a/addons/markers/functions/fnc_initInsertMarker.sqf +++ b/addons/markers/functions/fnc_initInsertMarker.sqf @@ -62,13 +62,6 @@ }; }; - //////////////////// - // Install MapDrawEH on current map - if !((ctrlIDD _mapDisplay) in GVAR(mapDisplaysWithDrawEHs)) then { - GVAR(mapDisplaysWithDrawEHs) pushBack (ctrlIDD _mapDisplay); - _mapCtrl ctrlAddEventHandler ["Draw", {_this call FUNC(mapDrawEH)}]; // @todo check if persistent - }; - //////////////////// // Calculate center position of the marker placement ctrl if !(GVAR(editingMarker) isEqualTo "") then { diff --git a/addons/markers/functions/fnc_mapDisplayInitEH.sqf b/addons/markers/functions/fnc_mapDisplayInitEH.sqf index 3ab874c445c..9d4331a8272 100644 --- a/addons/markers/functions/fnc_mapDisplayInitEH.sqf +++ b/addons/markers/functions/fnc_mapDisplayInitEH.sqf @@ -16,7 +16,7 @@ */ params ["_display"]; -TRACE_1("params",_display); +TRACE_1("mapDisplayInitEH",_display); private _bisShapeLB = _display displayctrl 1091; private _curSelShape = missionNamespace getVariable [QGVAR(curSelMarkerShape), 0]; @@ -30,8 +30,3 @@ private _curSelColor = missionNamespace getVariable [QGVAR(curSelMarkerColor), 0 TRACE_2("color",_bisColorLB,_curSelColor); _bisColorLB ctrlAddEventHandler ["LBSelChanged", {_this call FUNC(onLBSelChangedColor)}]; _bisColorLB lbSetCurSel _curSelColor; - -// movable markers -private _ctrlMap = _display displayCtrl 51; -_ctrlMap ctrlAddEventHandler ["MouseButtonDown", {_this call FUNC(onMouseButtonDown)}]; -_ctrlMap ctrlAddEventHandler ["MouseButtonUp", {_this call FUNC(onMouseButtonUp)}]; diff --git a/addons/microdagr/gui.hpp b/addons/microdagr/gui.hpp index 1404f6b81db..d1146a70195 100644 --- a/addons/microdagr/gui.hpp +++ b/addons/microdagr/gui.hpp @@ -19,7 +19,6 @@ class RscEdit; class RscButton; class RscListBox; - class GVAR(RscActiveTextPicture): RscActiveText { style = 48; colorText[] = {1,1,1,1}; @@ -46,12 +45,14 @@ class GVAR(RscText): RscText { #define H_PART(num) QUOTE((num) * (safeZoneH / 36)) class GVAR(TheDialog) { + EGVAR(mapEventHandlers,IDCs)[] = {IDC_MAPPLAIN, IDC_MAPDETAILS}; + EGVAR(mapEventHandlers,type) = QEGVAR(mapEventHandlers,gps); idd = -1; movingEnable = 1; duration = 9999999; fadein = 0; fadeout = 0; - onLoad = QUOTE(uiNamespace setVariable [ARR_2(QUOTE(QGVAR(DialogDisplay)),_this select 0)];); + onLoad = QUOTE([ARR_2(QUOTE(QGVAR(TheDialog)), _this # 0)] call EFUNC(common,addMapEventHandler_init); uiNamespace setVariable [ARR_2(QUOTE(QGVAR(DialogDisplay)),_this # 0)];); onUnload = QUOTE([] call FUNC(dialogClosedEH)); #include "gui_controls.hpp" @@ -81,7 +82,7 @@ class RscTitles { duration = 9999999; fadein = 0; fadeout = 0; - onLoad = QUOTE(uiNamespace setVariable [ARR_2(QUOTE(QGVAR(RscTitleDisplay)),_this select 0)];); + onLoad = QUOTE([ARR_2(QUOTE(QGVAR(TheDialog)), _this # 0)] call EFUNC(common,addMapEventHandler_init); uiNamespace setVariable [ARR_2(QUOTE(QGVAR(RscTitleDisplay)),_this # 0)];); #include "gui_controls.hpp" };