ACE3/addons/microdagr/functions/fnc_openDisplay.sqf

101 lines
3.8 KiB
Plaintext
Raw Normal View History

2015-03-09 15:46:59 +00:00
/*
* Author: PabstMirror
2015-03-11 07:06:07 +00:00
* Changes the display mode of the microDAGR
2015-03-09 15:46:59 +00:00
*
* Arguments:
2015-03-11 07:06:07 +00:00
* 0: Display Mode to show the microDAGR in <NUMBER><OPTIONAL>
2015-03-09 15:46:59 +00:00
*
* Return Value:
2015-03-11 07:06:07 +00:00
* Nothing
2015-03-09 15:46:59 +00:00
*
* Example:
2015-03-11 07:06:07 +00:00
* [1] call ace_microdagr_fnc_openDisplay
2015-03-09 15:46:59 +00:00
*
2015-03-11 07:06:07 +00:00
* Public: No
2015-03-09 15:46:59 +00:00
*/
#include "script_component.hpp"
2015-03-11 07:06:07 +00:00
private ["_oldShowMode", "_args", "_pfID", "_player"];
2015-03-09 18:52:15 +00:00
DEFAULT_PARAM(0,_newDisplayShowMode,-1);
_oldShowMode = GVAR(currentShowMode);
2015-03-09 15:46:59 +00:00
2015-03-09 18:52:15 +00:00
if (_newDisplayShowMode == -1) then {
//Toggle mode button:
2015-03-09 18:52:15 +00:00
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};
};
2015-03-09 15:46:59 +00:00
2015-03-09 18:52:15 +00:00
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};
2015-03-09 15:46:59 +00:00
2015-03-12 17:16:33 +00:00
2015-03-09 18:52:15 +00:00
//On first-startup
if (GVAR(currentApplicationPage) == APP_MODE_NULL) then {
2015-03-09 21:09:00 +00:00
GVAR(currentApplicationPage) = APP_MODE_INFODISPLAY;
2015-03-09 18:52:15 +00:00
GVAR(mapPosition) = getPos ace_player;
};
2015-03-09 15:46:59 +00:00
2015-03-12 17:16:33 +00:00
if (_newDisplayShowMode in [DISPLAY_MODE_CLOSED, DISPLAY_MODE_HIDDEN]) then {
2015-03-11 07:06:07 +00:00
2015-03-09 18:52:15 +00:00
//If Dialog is open, back it up before closing:
if (dialog && {!isNull (uiNamespace getVariable [QGVAR(DialogDisplay), displayNull])}) then {
[-1] call FUNC(saveCurrentAndSetNewMode);
closeDialog 0;
};
2015-03-11 07:06:07 +00:00
2015-03-09 18:52:15 +00:00
//Close the display:
(QGVAR(TheRscTitleDisplay) call BIS_fnc_rscLayer) cutText ["", "PLAIN"];
} else {
2015-03-12 17:16:33 +00:00
if (_newDisplayShowMode == DISPLAY_MODE_DISPLAY) then {
2015-03-09 18:52:15 +00:00
//If Dialog is open, back it up before closing:
if (dialog && {!isNull (uiNamespace getVariable [QGVAR(DialogDisplay), displayNull])}) then {
2015-03-09 15:46:59 +00:00
[-1] call FUNC(saveCurrentAndSetNewMode);
closeDialog 0;
};
2015-03-09 18:52:15 +00:00
//Open the display:
(QGVAR(TheRscTitleDisplay) call BIS_fnc_rscLayer) cutRsc [QGVAR(TheRscTitleDisplay), "PLAIN", 0, true];
2015-03-12 17:16:33 +00:00
} else { //DISPLAY_MODE_DIALOG
2015-03-09 18:52:15 +00:00
//Close the display:
(QGVAR(TheRscTitleDisplay) call BIS_fnc_rscLayer) cutText ["", "PLAIN"];
//Open the dialog:
createDialog QGVAR(TheDialog);
2015-03-09 15:46:59 +00:00
};
2015-03-09 18:52:15 +00:00
};
2015-03-09 15:46:59 +00:00
2015-03-12 17:16:33 +00:00
GVAR(currentShowMode) = _newDisplayShowMode;
2015-03-12 18:02:04 +00:00
//Update display applicaiton if open:
if (GVAR(currentShowMode) in [DISPLAY_MODE_DIALOG, DISPLAY_MODE_DISPLAY]) then {
[] call FUNC(showApplicationPage);
};
2015-03-09 15:46:59 +00:00
2015-03-09 18:52:15 +00:00
if ((_oldShowMode == DISPLAY_MODE_CLOSED) && {GVAR(currentShowMode) != DISPLAY_MODE_CLOSED}) then {
//Start a pfeh to update display and handle hiding display
2015-03-11 07:06:07 +00:00
2015-03-09 18:52:15 +00:00
[{
PARAMS_2(_args,_pfID);
EXPLODE_1_PVT(_args,_player);
2015-03-23 22:34:40 +00:00
if ((isNull ace_player) || {!alive ace_player} || {ace_player != _player} || {!("ACE_microDAGR" in (items ace_player))} || {GVAR(currentShowMode) == DISPLAY_MODE_CLOSED}) then {
2015-03-23 20:02:20 +00:00
//Close Display if still open:
if (GVAR(currentShowMode) != DISPLAY_MODE_CLOSED) then {
[DISPLAY_MODE_CLOSED] call FUNC(openDisplay);
};
2015-03-09 18:52:15 +00:00
[_pfID] call CBA_fnc_removePerFrameHandler;
} else {
if (GVAR(currentShowMode) == DISPLAY_MODE_HIDDEN) then {
2015-03-18 18:46:39 +00:00
//If display is hidden, and we can show, then swithc modes:
2015-03-09 18:52:15 +00:00
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;
2015-03-09 15:46:59 +00:00
};