Improve spectator GUI reopening prevention

Using boolean instead of simply checking for the display. Checking for diplay was unreliable since it can be technically closed while theoretically open during the escape menu and such.
This commit is contained in:
SilentSpike 2015-08-03 00:22:50 +01:00
parent 9b764bbba4
commit b87b4ea16a
2 changed files with 6 additions and 8 deletions

View File

@ -38,7 +38,7 @@ GVAR(camUnit) = objNull;
GVAR(camVision) = -2;
GVAR(camZoom) = 1.25;
SETUVAR(GVAR(display),nil);
GVAR(open) = false;
GVAR(showComp) = true;
GVAR(showHelp) = true;

View File

@ -23,7 +23,8 @@ switch (toLower _mode) do {
// Safely open/close the interface
case "open": {
// Prevent reopening
if !(isNull (GETUVAR(GVAR(display),displayNull))) exitWith {};
if (GVAR(open)) exitWith {};
GVAR(open) = true;
// Initalize camera variables
GVAR(camBoom) = 0;
@ -57,13 +58,13 @@ switch (toLower _mode) do {
};
case "close": {
// Can't close a second time
if (isNull (GETUVAR(GVAR(display),displayNull))) exitWith {};
if !(GVAR(open)) exitWith {};
GVAR(open) = false;
// Terminate interface
while {dialog} do {
closeDialog 0;
};
GETUVAR(GVAR(display),displayNull) closeDisplay 0;
// Terminate camera
GVAR(camera) cameraEffect ["terminate", "back"];
@ -95,8 +96,6 @@ switch (toLower _mode) do {
case "onload": {
_args params ["_display"];
SETUVAR(GVAR(display),_display);
// Always show interface and hide map upon opening
[_display,nil,nil,!GVAR(showInterface),GVAR(showMap)] call FUNC(toggleInterface);
@ -149,8 +148,7 @@ switch (toLower _mode) do {
//_display displayAddEventHandler ["KeyDown", {[_this,'keydown'] call CBA_events_fnc_keyHandler}];
};
case "onunload": {
SETUVAR(GVAR(display),nil);
// Kill GUI PFHs
GVAR(camHandler) = nil;
GVAR(compHandler) = nil;
GVAR(iconHandler) = nil;