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(camVision) = -2;
GVAR(camZoom) = 1.25; GVAR(camZoom) = 1.25;
SETUVAR(GVAR(display),nil); GVAR(open) = false;
GVAR(showComp) = true; GVAR(showComp) = true;
GVAR(showHelp) = true; GVAR(showHelp) = true;

View File

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