mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
99 lines
3.6 KiB
Plaintext
99 lines
3.6 KiB
Plaintext
/*
|
|
* Author: PabstMirror
|
|
* Changes the display mode of the microDAGR
|
|
*
|
|
* Arguments:
|
|
* 0: Display Mode to show the microDAGR in <NUMBER><OPTIONAL>
|
|
*
|
|
* Return Value:
|
|
* Nothing
|
|
*
|
|
* Example:
|
|
* [1] call ace_microdagr_fnc_openDisplay
|
|
*
|
|
* Public: No
|
|
*/
|
|
#include "script_component.hpp"
|
|
|
|
private ["_oldShowMode", "_args", "_pfID", "_player"];
|
|
|
|
DEFAULT_PARAM(0,_newDisplayShowMode,-1);
|
|
_oldShowMode = GVAR(currentShowMode);
|
|
|
|
if (_newDisplayShowMode == -1) then {
|
|
if (_oldShowMode in [DISPLAY_MODE_DISPLAY, DISPLAY_MODE_HIDDEN]) then {_newDisplayShowMode = DISPLAY_MODE_DIALOG};
|
|
if (_oldShowMode in [DISPLAY_MODE_DIALOG, DISPLAY_MODE_CLOSED]) then {_newDisplayShowMode = DISPLAY_MODE_DISPLAY};
|
|
};
|
|
|
|
if ((_newDisplayShowMode == DISPLAY_MODE_DISPLAY) && {!([DISPLAY_MODE_DISPLAY] call FUNC(canShow))}) then {_newDisplayShowMode = DISPLAY_MODE_HIDDEN};
|
|
if ((_newDisplayShowMode == DISPLAY_MODE_DIALOG) && {!([DISPLAY_MODE_DIALOG] call FUNC(canShow))}) then {_newDisplayShowMode = DISPLAY_MODE_HIDDEN};
|
|
|
|
|
|
|
|
//On first-startup
|
|
if (GVAR(currentApplicationPage) == APP_MODE_NULL) then {
|
|
GVAR(currentApplicationPage) = APP_MODE_INFODISPLAY;
|
|
GVAR(mapPosition) = getPos ace_player;
|
|
};
|
|
|
|
if (_newDisplayShowMode in [DISPLAY_MODE_CLOSED, DISPLAY_MODE_HIDDEN]) then {
|
|
|
|
//If Dialog is open, back it up before closing:
|
|
if (dialog && {!isNull (uiNamespace getVariable [QGVAR(DialogDisplay), displayNull])}) then {
|
|
[-1] call FUNC(saveCurrentAndSetNewMode);
|
|
closeDialog 0;
|
|
};
|
|
|
|
//Close the display:
|
|
(QGVAR(TheRscTitleDisplay) call BIS_fnc_rscLayer) cutText ["", "PLAIN"];
|
|
} else {
|
|
if (_newDisplayShowMode == DISPLAY_MODE_DISPLAY) then {
|
|
//If Dialog is open, back it up before closing:
|
|
if (dialog && {!isNull (uiNamespace getVariable [QGVAR(DialogDisplay), displayNull])}) then {
|
|
[-1] call FUNC(saveCurrentAndSetNewMode);
|
|
closeDialog 0;
|
|
};
|
|
//Open the display:
|
|
(QGVAR(TheRscTitleDisplay) call BIS_fnc_rscLayer) cutRsc [QGVAR(TheRscTitleDisplay), "PLAIN", 0, true];
|
|
} else { //DISPLAY_MODE_DIALOG
|
|
//Close the display:
|
|
(QGVAR(TheRscTitleDisplay) call BIS_fnc_rscLayer) cutText ["", "PLAIN"];
|
|
//Open the dialog:
|
|
createDialog QGVAR(TheDialog);
|
|
};
|
|
};
|
|
|
|
GVAR(currentShowMode) = _newDisplayShowMode;
|
|
//Update display applicaiton if open:
|
|
if (GVAR(currentShowMode) in [DISPLAY_MODE_DIALOG, DISPLAY_MODE_DISPLAY]) then {
|
|
[] call FUNC(showApplicationPage);
|
|
};
|
|
|
|
if ((_oldShowMode == DISPLAY_MODE_CLOSED) && {GVAR(currentShowMode) != DISPLAY_MODE_CLOSED}) then {
|
|
//Start a pfeh to update display and handle hiding display
|
|
|
|
[{
|
|
PARAMS_2(_args,_pfID);
|
|
EXPLODE_1_PVT(_args,_player);
|
|
|
|
if ((ace_player != _player) || {!("ACE_microDAGR" in (items ace_player))} || {GVAR(currentShowMode) == DISPLAY_MODE_CLOSED}) then {
|
|
GVAR(currentShowMode) = DISPLAY_MODE_CLOSED;
|
|
[_pfID] call CBA_fnc_removePerFrameHandler;
|
|
} else {
|
|
GVAR(gpsPositionASL) = getPosAsl ace_player;
|
|
if (GVAR(currentShowMode) == DISPLAY_MODE_HIDDEN) then {
|
|
//If display is hidden, and we can show, then swithc modes:
|
|
if ([DISPLAY_MODE_DISPLAY] call FUNC(canShow)) then {
|
|
[DISPLAY_MODE_DISPLAY] call FUNC(openDisplay);
|
|
};
|
|
} else {
|
|
if ([GVAR(currentShowMode)] call FUNC(canShow)) then {
|
|
[] call FUNC(updateDisplay);
|
|
} else {
|
|
[DISPLAY_MODE_HIDDEN] call FUNC(openDisplay);
|
|
};
|
|
};
|
|
};
|
|
}, 0.1, [ace_player]] call CBA_fnc_addPerFrameHandler;
|
|
};
|