diff --git a/src/GlobalVariables.as b/src/GlobalVariables.as index 06507782..a6ff2de0 100644 --- a/src/GlobalVariables.as +++ b/src/GlobalVariables.as @@ -108,6 +108,7 @@ package public var air_useWebsockets:Boolean = false; public var air_saveWindowPosition:Boolean = false; public var air_saveWindowSize:Boolean = false; + public var air_useFullScreen:Boolean = false; public var air_windowProperties:Object; public var file_replay_cache:FileCache = new FileCache("replays/cache.json", 1); @@ -140,6 +141,7 @@ package air_useWebsockets = LocalOptions.getVariable("use_websockets", false); air_saveWindowPosition = LocalOptions.getVariable("save_window_position", false); air_saveWindowSize = LocalOptions.getVariable("save_window_size", false); + air_useFullScreen = LocalOptions.getVariable("save_usefullscreen", false); air_windowProperties = LocalOptions.getVariable("window_properties", {"x": 0, "y": 0, "width": 0, "height": 0}); @@ -693,6 +695,16 @@ package } } + public function isFullScreen():Boolean + { + if (gameMain.stage) + { + return gameMain.stage.displayState == StageDisplayState.FULL_SCREEN_INTERACTIVE; + } + + return false; + } + public function unlockTokenById(type:String, id:String):void { try diff --git a/src/Main.as b/src/Main.as index 58a9c50b..6f780f86 100644 --- a/src/Main.as +++ b/src/Main.as @@ -166,6 +166,10 @@ package window.width = Math.max(100, _gvars.air_windowProperties.width + WINDOW_WIDTH_EXTRA); window.height = Math.max(100, _gvars.air_windowProperties.height + WINDOW_HEIGHT_EXTRA); } + if (_gvars.air_useFullScreen) + { + _gvars.toggleFullScreen(); + } ignoreWindowChanges = false; //- Load Menu Music diff --git a/src/popups/settings/SettingsTabMisc.as b/src/popups/settings/SettingsTabMisc.as index 819618e1..c9bad742 100644 --- a/src/popups/settings/SettingsTabMisc.as +++ b/src/popups/settings/SettingsTabMisc.as @@ -19,6 +19,8 @@ package popups.settings import flash.net.navigateToURL; import flash.system.Capabilities; import menu.MainMenu; + import flash.events.KeyboardEvent; + import flash.ui.Keyboard; public class SettingsTabMisc extends SettingsTabBase { @@ -55,6 +57,8 @@ package popups.settings private var windowPositionSet:BoxButton; private var windowPositionReset:BoxButton; private var windowSavePositionCheck:BoxCheck; + private var windowFullscreen:BoxCheck; + private var windowSaveFullscreen:BoxCheck; public function SettingsTabMisc(settingsWindow:SettingsWindow):void { @@ -71,6 +75,8 @@ package popups.settings Main.window.addEventListener(NativeWindowBoundsEvent.MOVE, e_windowPropertyChange); Main.window.addEventListener(NativeWindowBoundsEvent.RESIZE, e_windowPropertyChange); + container.stage.addEventListener(KeyboardEvent.KEY_DOWN, e_onKeyDownMenu, true, int.MAX_VALUE - 10, true); + container.graphics.lineStyle(1, 0xFFFFFF, 0.35); container.graphics.moveTo(295, 15); container.graphics.lineTo(295, 405); @@ -211,6 +217,13 @@ package popups.settings windowSavePositionCheck = new BoxCheck(container, xOff + 3, yOff + 3, clickHandler); yOff += 30; + new Text(container, xOff + 23, yOff, _lang.string("air_options_fullscreen")); + windowFullscreen = new BoxCheck(container, xOff + 3, yOff + 3, clickHandler); + + new Text(container, xOff + 133, yOff, _lang.string("air_options_launch_fullscreen")); + windowSaveFullscreen = new BoxCheck(container, xOff + 113, yOff + 3, clickHandler); + yOff += 30; + setTextMaxWidth(245); } @@ -218,6 +231,7 @@ package popups.settings { Main.window.removeEventListener(NativeWindowBoundsEvent.MOVE, e_windowPropertyChange); Main.window.removeEventListener(NativeWindowBoundsEvent.RESIZE, e_windowPropertyChange); + container.stage.removeEventListener(KeyboardEvent.KEY_DOWN, e_onKeyDownMenu); } override public function setValues():void @@ -243,6 +257,8 @@ package popups.settings windowSavePositionCheck.checked = _gvars.air_saveWindowPosition; windowSaveSizeCheck.checked = _gvars.air_saveWindowSize; + windowSaveFullscreen.checked = _gvars.air_useFullScreen; + windowFullscreen.checked = _gvars.isFullScreen(); } override public function clickHandler(e:MouseEvent):void @@ -332,12 +348,14 @@ package popups.settings _gvars.air_windowProperties["x"] = windowXBox.validate(Math.round((Capabilities.screenResolutionX - Main.window.width) * 0.5)); _gvars.air_windowProperties["y"] = windowYBox.validate(Math.round((Capabilities.screenResolutionY - Main.window.height) * 0.5)); e_windowSetUpdate(); + windowFullscreen.checked = _gvars.isFullScreen(); } else if (e.target == windowPositionReset) { _gvars.air_windowProperties["x"] = Math.round((Capabilities.screenResolutionX - Main.window.width) * 0.5); _gvars.air_windowProperties["y"] = Math.round((Capabilities.screenResolutionY - Main.window.height) * 0.5); e_windowSetUpdate(); + windowFullscreen.checked = _gvars.isFullScreen(); } // Window Size @@ -354,12 +372,25 @@ package popups.settings _gvars.air_windowProperties["width"] = windowWidthBox.validate(Main.GAME_WIDTH); _gvars.air_windowProperties["height"] = windowHeightBox.validate(Main.GAME_HEIGHT); e_windowSetUpdate(); + windowFullscreen.checked = _gvars.isFullScreen(); } else if (e.target == windowSizeReset) { _gvars.air_windowProperties["width"] = Main.GAME_WIDTH; _gvars.air_windowProperties["height"] = Main.GAME_HEIGHT; e_windowSetUpdate(); + windowFullscreen.checked = _gvars.isFullScreen(); + } + else if (e.target == windowSaveFullscreen) + { + e.target.checked = !e.target.checked; + _gvars.air_useFullScreen = !_gvars.air_useFullScreen; + LocalOptions.setVariable("save_usefullscreen", _gvars.air_useFullScreen); + } + else if (e.target == windowFullscreen) + { + _gvars.toggleFullScreen(); + windowFullscreen.checked = _gvars.isFullScreen(); } } @@ -372,6 +403,23 @@ package popups.settings } } + public function e_onKeyDownMenu(e:KeyboardEvent):void + { + var keyCode:int = e.keyCode; + + if (keyCode == Keyboard.ESCAPE) + { + windowFullscreen.checked = false; //ESC exits fullscreen + return; + } + + if (e.ctrlKey && keyCode == Keyboard.S) + { + windowFullscreen.checked = false; //CTRL+S also exits fullscreen + return; + } + } + private function e_windowPropertyChange(e:Event):void { windowWidthBox.text = _gvars.air_windowProperties["width"];