Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/GlobalVariables.as
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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});

Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/Main.as
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 48 additions & 0 deletions src/popups/settings/SettingsTabMisc.as
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand All @@ -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);
Expand Down Expand Up @@ -211,13 +217,21 @@ 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);
}

override public function closeTab():void
{
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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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();
}
}

Expand All @@ -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"];
Expand Down
Loading