123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- //-----------------------------------------------------------------------------
- // Copyright (c) 2013 GarageGames, LLC
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to
- // deal in the Software without restriction, including without limitation the
- // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- // sell copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- // IN THE SOFTWARE.
- //-----------------------------------------------------------------------------
- //------------------------------------------------------------------------------
- // initializeCanvas
- // Constructs and initializes the default canvas window.
- //------------------------------------------------------------------------------
- function AppCore::initializeCanvas(%this, %windowName)
- {
- // Don't duplicate the canvas.
- if(!isObject(Canvas))
- {
- videoSetGammaCorrection($pref::OpenGL::gammaCorrection);
- if ( !createCanvas(%windowName) )
- {
- error("Canvas creation failed. Shutting down.");
- quit();
- }
- if ($platform $= "iOS")
- {
- %resolution = $pref::iOS::Width SPC $pref::iOS::Height SPC $pref::iOS::ScreenDepth;
- }
- else if ($platform $= "Android")
- {
- %resolution = GetAndroidResolution();
- }
- else
- {
- if ( $pref::Video::windowedRes !$= "" )
- %resolution = $pref::Video::windowedRes;
- else
- %resolution = $pref::Video::defaultResolution;
- }
- if ($platform $= "windows" || $platform $= "macos")
- {
- setScreenMode( %resolution._0, %resolution._1, %resolution._2, $pref::Video::fullScreen );
- }
- else
- {
- setScreenMode( %resolution._0, %resolution._1, %resolution._2, false );
- }
- }
- else
- {
- setCanvasTitle(%windowName);
- Canvas.repaint();
- }
- Canvas.UseBackgroundColor = true;
- Canvas.BackgroundColor = "Black";
- }
- //------------------------------------------------------------------------------
- // iOSResolutionFromSetting
- // Helper function that grabs resolution strings based on device type
- //------------------------------------------------------------------------------
- function AppCore::iOSResolutionFromSetting( %this, %deviceType, %deviceScreenOrientation )
- {
- // A helper function to get a string based resolution from the settings given.
- %x = 0;
- %y = 0;
- %scaleFactor = $pref::iOS::RetinaEnabled ? 2 : 1;
- switch(%deviceType)
- {
- case $iOS::constant::iPhone:
- if(%deviceScreenOrientation == $iOS::constant::Landscape)
- {
- %x = $iOS::constant::iPhoneWidth * %scaleFactor;
- %y = $iOS::constant::iPhoneHeight * %scaleFactor;
- }
- else
- {
- %x = $iOS::constant::iPhoneHeight * %scaleFactor;
- %y = $iOS::constant::iPhoneWidth * %scaleFactor;
- }
- case $iOS::constant::iPad:
- if(%deviceScreenOrientation == $iOS::constant::Landscape)
- {
- %x = $iOS::constant::iPadWidth * %scaleFactor;
- %y = $iOS::constant::iPadHeight * %scaleFactor;
- }
- else
- {
- %x = $iOS::constant::iPadHeight * %scaleFactor;
- %y = $iOS::constant::iPadWidth * %scaleFactor;
- }
- case $iOS::constant::iPhone5:
- if(%deviceScreenOrientation == $iOS::constant::Landscape)
- {
- %x = $iOS::constant::iPhone5Width;
- %y = $iOS::constant::iPhone5Height;
- }
- else
- {
- %x = $iOS::constant::iPhone5Height;
- %y = $iOS::constant::iPhone5Width;
- }
- }
- return %x @ " " @ %y;
- }
|