@@ -19,6 +19,8 @@ package popups.settings
1919 import flash.net.navigateToURL ;
2020 import flash.system.Capabilities ;
2121 import menu.MainMenu ;
22+ import flash.events.KeyboardEvent ;
23+ import flash.ui.Keyboard ;
2224
2325 public class SettingsTabMisc extends SettingsTabBase
2426 {
@@ -55,6 +57,8 @@ package popups.settings
5557 private var windowPositionSet: BoxButton;
5658 private var windowPositionReset: BoxButton;
5759 private var windowSavePositionCheck: BoxCheck;
60+ private var windowFullscreen: BoxCheck;
61+ private var windowSaveFullscreen: BoxCheck;
5862
5963 public function SettingsTabMisc (settingsWindow :SettingsWindow ):void
6064 {
@@ -71,6 +75,8 @@ package popups.settings
7175 Main. window . addEventListener (NativeWindowBoundsEvent. MOVE , e_windowPropertyChange);
7276 Main. window . addEventListener (NativeWindowBoundsEvent. RESIZE , e_windowPropertyChange);
7377
78+ container . stage . addEventListener (KeyboardEvent . KEY_DOWN , e_onKeyDownMenu, true , int . MAX_VALUE - 10 , true );
79+
7480 container . graphics . lineStyle (1 , 0xFFFFFF , 0.35 );
7581 container . graphics . moveTo (295 , 15 );
7682 container . graphics . lineTo (295 , 405 );
@@ -211,13 +217,21 @@ package popups.settings
211217 windowSavePositionCheck = new BoxCheck(container , xOff + 3 , yOff + 3 , clickHandler);
212218 yOff += 30 ;
213219
220+ new Text (container , xOff + 23 , yOff, _lang . string("air_options_fullscreen" ));
221+ windowFullscreen = new BoxCheck(container , xOff + 3 , yOff + 3 , clickHandler);
222+
223+ new Text (container , xOff + 133 , yOff, _lang . string("air_options_launch_fullscreen" ));
224+ windowSaveFullscreen = new BoxCheck(container , xOff + 113 , yOff + 3 , clickHandler);
225+ yOff += 30 ;
226+
214227 setTextMaxWidth(245 );
215228 }
216229
217230 override public function closeTab ():void
218231 {
219232 Main. window . removeEventListener (NativeWindowBoundsEvent. MOVE , e_windowPropertyChange);
220233 Main. window . removeEventListener (NativeWindowBoundsEvent. RESIZE , e_windowPropertyChange);
234+ container . stage . removeEventListener (KeyboardEvent . KEY_DOWN , e_onKeyDownMenu);
221235 }
222236
223237 override public function setValues ():void
@@ -243,6 +257,8 @@ package popups.settings
243257
244258 windowSavePositionCheck. checked = _gvars . air_saveWindowPosition;
245259 windowSaveSizeCheck. checked = _gvars . air_saveWindowSize;
260+ windowSaveFullscreen. checked = _gvars . air_useFullScreen;
261+ windowFullscreen. checked = _gvars . isFullScreen();
246262 }
247263
248264 override public function clickHandler (e :MouseEvent ):void
@@ -332,12 +348,14 @@ package popups.settings
332348 _gvars . air_windowProperties[ "x" ] = windowXBox. validate (Math . round ((Capabilities . screenResolutionX - Main. window . width ) * 0.5 ));
333349 _gvars . air_windowProperties[ "y" ] = windowYBox. validate (Math . round ((Capabilities . screenResolutionY - Main. window . height ) * 0.5 ));
334350 e_windowSetUpdate();
351+ windowFullscreen. checked = _gvars . isFullScreen();
335352 }
336353 else if (e. target == windowPositionReset)
337354 {
338355 _gvars . air_windowProperties[ "x" ] = Math . round ((Capabilities . screenResolutionX - Main. window . width ) * 0.5 );
339356 _gvars . air_windowProperties[ "y" ] = Math . round ((Capabilities . screenResolutionY - Main. window . height ) * 0.5 );
340357 e_windowSetUpdate();
358+ windowFullscreen. checked = _gvars . isFullScreen();
341359 }
342360
343361 // Window Size
@@ -354,12 +372,25 @@ package popups.settings
354372 _gvars . air_windowProperties[ "width" ] = windowWidthBox. validate (Main. GAME_WIDTH );
355373 _gvars . air_windowProperties[ "height" ] = windowHeightBox. validate (Main. GAME_HEIGHT );
356374 e_windowSetUpdate();
375+ windowFullscreen. checked = _gvars . isFullScreen();
357376 }
358377 else if (e. target == windowSizeReset)
359378 {
360379 _gvars . air_windowProperties[ "width" ] = Main. GAME_WIDTH ;
361380 _gvars . air_windowProperties[ "height" ] = Main. GAME_HEIGHT ;
362381 e_windowSetUpdate();
382+ windowFullscreen. checked = _gvars . isFullScreen();
383+ }
384+ else if (e. target == windowSaveFullscreen)
385+ {
386+ e. target . checked = ! e. target . checked;
387+ _gvars . air_useFullScreen = ! _gvars . air_useFullScreen;
388+ LocalOptions. setVariable("save_usefullscreen" , _gvars . air_useFullScreen);
389+ }
390+ else if (e. target == windowFullscreen)
391+ {
392+ _gvars . toggleFullScreen();
393+ windowFullscreen. checked = _gvars . isFullScreen();
363394 }
364395 }
365396
@@ -372,6 +403,23 @@ package popups.settings
372403 }
373404 }
374405
406+ public function e_onKeyDownMenu (e :KeyboardEvent ):void
407+ {
408+ var keyCode : int = e. keyCode ;
409+
410+ if (keyCode == Keyboard . ESCAPE )
411+ {
412+ windowFullscreen. checked = false ; //ESC exits fullscreen
413+ return ;
414+ }
415+
416+ if (e. ctrlKey && keyCode == Keyboard . S )
417+ {
418+ windowFullscreen. checked = false ; //CTRL+S also exits fullscreen
419+ return ;
420+ }
421+ }
422+
375423 private function e_windowPropertyChange (e :Event ):void
376424 {
377425 windowWidthBox. text = _gvars . air_windowProperties[ "width" ];
0 commit comments