ACE3/addons/microdagr/functions/fnc_openDisplay.sqf

98 lines
3.7 KiB
Plaintext
Raw Normal View History

#include "script_component.hpp"
2015-03-09 15:46:59 +00:00
/*
* Author: PabstMirror
* Changes the display mode of the MicroDAGR.
2015-03-09 15:46:59 +00:00
*
* Arguments:
* 0: Display Mode to show the microDAGR in <NUMBER> (default: -1)
2015-03-09 15:46:59 +00:00
*
* Return Value:
2015-08-26 03:31:33 +00:00
* None
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
*/
2015-08-26 03:31:33 +00:00
params [["_newDisplayShowMode", -1, [-1]]];
private _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-08-26 03:31:33 +00:00
GVAR(mapPosition) = getPos ACE_player;
2015-03-09 18:52:15 +00:00
};
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
[{
2015-08-26 03:31:33 +00:00
params ["_args", "_idPFH"];
_args params ["_player"];
if ((isNull ACE_player) || {!alive ACE_player} || {ACE_player != _player} || {!("ACE_microDAGR" in (ACE_player call EFUNC(common,uniqueItems)))} || {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-08-26 03:31:33 +00:00
[_idPFH] call CBA_fnc_removePerFrameHandler;
2015-03-09 18:52:15 +00:00
} 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);
};
};
};
2015-08-26 03:31:33 +00:00
}, 0.1, [ACE_player]] call CBA_fnc_addPerFrameHandler;
2015-03-09 15:46:59 +00:00
};