Skip to content

Commit

Permalink
Fix map icons not showing after closing display (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
Timi007 authored Mar 9, 2022
1 parent 2b4e14a commit 517bee4
Show file tree
Hide file tree
Showing 8 changed files with 214 additions and 165 deletions.
4 changes: 2 additions & 2 deletions addons/zeus/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
PREP(add3DENCommentsDrawEH);
PREP(addACEUnconsciousIconDrawEH);
PREP(moduleArtillery);
PREP(artyFireMissionHE);
PREP(artyFireMissionSMOKE);
PREP(artyFireMissionILLUM);
PREP(execArtyStrike);
PREP(artyAirburst);
PREP(drawACEUnconsciousIcon);
PREP(initDrawCommentsEH);
PREP(initDrawIconEH);
PREP(moduleUnflipVehicle);
PREP(on3DENMissionSave);
PREP(onZeusDisplayOpen);
Expand Down
7 changes: 6 additions & 1 deletion addons/zeus/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@
CHECK(!hasinterface);

GVAR(moduleDestination_running) = false;
GVAR(drawCommentEhAdded) = false;

GVAR(3DENComments_drawEHAdded) = false;
GVAR(3DENComments_data) = getMissionConfigValue [QGVAR(3denComments), []];
TRACE_1("3DEN Comments", GVAR(3DENComments_data));

GVAR(ACEIcon_drawEHAdded) = false;

player addEventHandler ["killed", {
params ["_unit"];
Expand Down
1 change: 1 addition & 0 deletions addons/zeus/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ADDON = true;

#include "initSettings.hpp"

// For 3DEN comments in Zeus
if (is3DEN) then {
add3DENEventHandler ["OnMissionSave", {[false] call FUNC(on3DENMissionSave)}];
add3DENEventHandler ["OnMissionAutosave", {[true] call FUNC(on3DENMissionSave)}];
Expand Down
96 changes: 96 additions & 0 deletions addons/zeus/functions/fnc_add3DENCommentsDrawEH.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#include "script_component.hpp"
/**
* Author: Timi007
*
* Description:
* Draws 3DEN comments in zeus.
*
* Parameter(s):
* None.
*
* Returns:
* Nothing.
*
* Example:
* [_display] call mts_enhanced_fnc_add3DENCommentsDrawEH
*
*/

params ["_display"];

CHECK(!GVAR(enable3DENComments));

if (!GVAR(3DENComments_drawEHAdded)) then {
LOG("Adding 3DENComments draw3D");
[missionNamespace, "draw3D", {
_thisArgs params ["_3denComments"];

CHECK(isNull (findDisplay ZEUS_DISPLAY));

if (!GVAR(enable3DENComments)) exitWith {
removeMissionEventHandler [_thisType, _thisId];
GVAR(3DENComments_drawEHAdded) = false;
};

{
_x params ["_id", "_name", "_description", "_posASL"];

private _camPosASL = getPosASLVisual curatorCamera;
private _d = _posASL distance _camPosASL;
private _scale = linearConversion [300, 750, _d, 0.8, 0, true]; // 300m => 1.5, 730m => 0

if (_scale < 0.01) then {
continue;
};

private _color = [0.2,0.8,0.6,1];

drawIcon3D [
"a3\3den\Data\Cfg3DEN\Comment\texture_ca.paa",
_color,
ASLToAGL _posASL,
_scale, // Width
_scale, // Height
0, // Angle
_name, // Text
1 // Shadow
];

drawLine3D [
ASLToAGL _posASL,
[_posASL select 0, _posASL select 1, 0],
_color
];
} count _3denComments;
}, [GVAR(3DENComments_data)]] call CBA_fnc_addBISEventHandler;
};

// MapDraw EH needs to be readded every time the zeus display is opened.
LOG("Adding 3DENComments map draw");
[_display displayCtrl ZEUS_MAP_CTRL, "draw", {
params ["_mapCtrl"];
_thisArgs params ["_3denComments"];

if (!GVAR(enable3DENComments)) exitWith {
_mapCtrl ctrlRemoveEventHandler [_thisType, _thisId];
};

{
_x params ["_id", "_name", "_description", "_posASL"];

private _color = [0.2,0.8,0.6,1];

_mapCtrl drawIcon [
"a3\3den\Data\Cfg3DEN\Comment\texture_ca.paa",
_color,
_posASL,
24,
24,
0,
_name,
1
];
} count _3denComments;
}, [GVAR(3DENComments_data)]] call CBA_fnc_addBISEventHandler;

GVAR(3DENComments_drawEHAdded) = true;
107 changes: 107 additions & 0 deletions addons/zeus/functions/fnc_addACEUnconsciousIconDrawEH.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#include "script_component.hpp"
/**
* Author: PhILoX, Timi007
*
* Description:
* Adds an eventhandler on initialization of the zeus interface.
* The eventhandler adds an icon on unconscious players.
*
* Parameter(s):
* None.
*
* Returns:
* Nothing.
*
* Example:
* [_display] call mts_zeus_fnc_addACEUnconsciousIconDrawEH
*
*/

params ["_display"];

CHECK(!GVAR(enableACEUnconsciousIcon));

private _curatorModule = getAssignedCuratorLogic player;

// Only do this if zeus display is opened for the first time
if (isNil {(_curatorModule getVariable QGVAR(unconsciousPlayers))}) then {
LOG("Init ACEUnconsciousIcon killed EH");
_curatorModule setVariable [QGVAR(unconsciousPlayers), []];

{
if (_x getVariable ["ACE_isUnconscious", false]) then {
[_x, true] call FUNC(drawACEUnconsciousIcon);
};
} count (call CBA_fnc_players);

["ace_unconscious", LINKFUNC(drawACEUnconsciousIcon)] call CBA_fnc_addEventHandler;
[QGVAR(killed), LINKFUNC(drawACEUnconsciousIcon)] call CBA_fnc_addEventHandler;
};

if (!GVAR(ACEIcon_drawEHAdded)) then {
LOG("Adding ACEUnconsciousIcon draw3D");
[missionNamespace, "draw3D", {
_thisArgs params ["_curatorModule"];

CHECK(isNull (findDisplay ZEUS_DISPLAY));

if (!GVAR(enableACEUnconsciousIcon)) exitWith {
removeMissionEventHandler [_thisType, _thisId];
GVAR(ACEIcon_drawEHAdded) = false;
};

private _unconsciousPlayers = _curatorModule getVariable [QGVAR(unconsciousPlayers), []];

{
private _pos = ASLToAGL (getPosASLVisual _x);
private _camPos = ASLToAGL (getPosASLVisual curatorCamera);
private _d = _pos distance _camPos;
private _scale = linearConversion [300, 730, _d, 1.5, 0, true]; // 300m => 1.5, 730m => 0

if (_scale < 0.01) then {
continue;
};

drawIcon3D [
"z\ace\addons\zeus\ui\Icon_Module_Zeus_Unconscious_ca.paa",
[0.9, 0, 0, 1],
[_pos select 0, _pos select 1, (_pos select 2) + 2],
_scale, // Width
_scale, // Height
0, // Angle
"", // Text
1 // Shadow
];
} count _unconsciousPlayers;
}, [_curatorModule]] call CBA_fnc_addBISEventHandler;
};

// MapDraw EH needs to be readded every time the zeus display is opened.
LOG("Adding ACEUnconsciousIcon map draw");
[_display displayCtrl ZEUS_MAP_CTRL, "draw", {
params ["_mapCtrl"];
_thisArgs params ["_curatorModule"];

if (!GVAR(enableACEUnconsciousIcon)) exitWith {
_mapCtrl ctrlRemoveEventHandler [_thisType, _thisId];
};

private _unconsciousPlayers = _curatorModule getVariable [QGVAR(unconsciousPlayers), []];

{
private _pos = getPosASLVisual _x;

_mapCtrl drawIcon [
"z\ace\addons\zeus\ui\Icon_Module_Zeus_Unconscious_ca.paa",
[0.9, 0, 0, 1],
_pos,
30,
30,
0,
"",
1
];
} count _unconsciousPlayers;
}, [_curatorModule]] call CBA_fnc_addBISEventHandler;

GVAR(ACEIcon_drawEHAdded) = true;
96 changes: 0 additions & 96 deletions addons/zeus/functions/fnc_initDrawCommentsEH.sqf

This file was deleted.

Loading

0 comments on commit 517bee4

Please sign in to comment.