|
@@ -49,35 +49,35 @@ iOSPlatState platState;
|
|
|
|
|
|
iOSPlatState::iOSPlatState()
|
|
iOSPlatState::iOSPlatState()
|
|
{
|
|
{
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
captureDisplay = true;
|
|
captureDisplay = true;
|
|
fadeWindows = true;
|
|
fadeWindows = true;
|
|
backgrounded = false;
|
|
backgrounded = false;
|
|
minimized = false;
|
|
minimized = false;
|
|
-
|
|
|
|
|
|
+
|
|
quit = false;
|
|
quit = false;
|
|
-
|
|
|
|
|
|
+
|
|
portrait = true;//-Mat iOS is in portrait mode by default
|
|
portrait = true;//-Mat iOS is in portrait mode by default
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
// start with something reasonable.
|
|
// start with something reasonable.
|
|
desktopBitsPixel = IOS_DEFAULT_RESOLUTION_BIT_DEPTH;
|
|
desktopBitsPixel = IOS_DEFAULT_RESOLUTION_BIT_DEPTH;
|
|
desktopWidth = IOS_DEFAULT_RESOLUTION_X;
|
|
desktopWidth = IOS_DEFAULT_RESOLUTION_X;
|
|
desktopHeight = IOS_DEFAULT_RESOLUTION_Y;
|
|
desktopHeight = IOS_DEFAULT_RESOLUTION_Y;
|
|
fullscreen = true;
|
|
fullscreen = true;
|
|
-
|
|
|
|
|
|
+
|
|
osVersion = 0;
|
|
osVersion = 0;
|
|
-
|
|
|
|
|
|
+
|
|
dStrcpy(appWindowTitle, "iOS Torque Game Engine");
|
|
dStrcpy(appWindowTitle, "iOS Torque Game Engine");
|
|
-
|
|
|
|
|
|
+
|
|
// Semaphore for alerts. We put the app in a modal state by blocking the main
|
|
// Semaphore for alerts. We put the app in a modal state by blocking the main
|
|
alertSemaphore = Semaphore::createSemaphore(0);
|
|
alertSemaphore = Semaphore::createSemaphore(0);
|
|
-
|
|
|
|
|
|
+
|
|
// directory that contains main.cs . This will help us detect whether we are
|
|
// directory that contains main.cs . This will help us detect whether we are
|
|
// running with the scripts in the bundle or not.
|
|
// running with the scripts in the bundle or not.
|
|
mainDotCsDir = NULL;
|
|
mainDotCsDir = NULL;
|
|
-
|
|
|
|
|
|
+
|
|
mainLoopTimer = NULL;
|
|
mainLoopTimer = NULL;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -127,7 +127,7 @@ void Platform::init()
|
|
Con::setBoolVariable("$pref::iOS::RetinaEnabled", true);
|
|
Con::setBoolVariable("$pref::iOS::RetinaEnabled", true);
|
|
else
|
|
else
|
|
Con::setBoolVariable("$pref::iOS::RetinaEnabled", false);
|
|
Con::setBoolVariable("$pref::iOS::RetinaEnabled", false);
|
|
-
|
|
|
|
|
|
+
|
|
// Set the platform variable for the scripts
|
|
// Set the platform variable for the scripts
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
|
|
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
|
|
{
|
|
{
|
|
@@ -147,16 +147,16 @@ void Platform::init()
|
|
Con::setIntVariable("$pref::iOS::DeviceType", 0);
|
|
Con::setIntVariable("$pref::iOS::DeviceType", 0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
iOSConsole::create();
|
|
iOSConsole::create();
|
|
-
|
|
|
|
|
|
+
|
|
//if ( !iOSConsole::isEnabled() )
|
|
//if ( !iOSConsole::isEnabled() )
|
|
Input::init();
|
|
Input::init();
|
|
-
|
|
|
|
|
|
+
|
|
// allow users to specify whether to capture the display or not when going fullscreen
|
|
// allow users to specify whether to capture the display or not when going fullscreen
|
|
Con::addVariable("pref::mac::captureDisplay", TypeBool, &platState.captureDisplay);
|
|
Con::addVariable("pref::mac::captureDisplay", TypeBool, &platState.captureDisplay);
|
|
Con::addVariable("pref::mac::fadeWindows", TypeBool, &platState.fadeWindows);
|
|
Con::addVariable("pref::mac::fadeWindows", TypeBool, &platState.fadeWindows);
|
|
-
|
|
|
|
|
|
+
|
|
// create the opengl display device
|
|
// create the opengl display device
|
|
DisplayDevice *dev = NULL;
|
|
DisplayDevice *dev = NULL;
|
|
Con::printf("Video Init:");
|
|
Con::printf("Video Init:");
|
|
@@ -166,7 +166,7 @@ void Platform::init()
|
|
Con::printf(" Accelerated OpenGL display device detected.");
|
|
Con::printf(" Accelerated OpenGL display device detected.");
|
|
else
|
|
else
|
|
Con::printf(" Accelerated OpenGL display device not detected.");
|
|
Con::printf(" Accelerated OpenGL display device not detected.");
|
|
-
|
|
|
|
|
|
+
|
|
// and now we can install the device.
|
|
// and now we can install the device.
|
|
Video::installDevice(dev);
|
|
Video::installDevice(dev);
|
|
Con::printf("");
|
|
Con::printf("");
|
|
@@ -196,12 +196,12 @@ void Platform::initWindow(const Point2I &initialSize, const char *name)
|
|
{
|
|
{
|
|
S32 resolutionWidth = IOS_DEFAULT_RESOLUTION_X;
|
|
S32 resolutionWidth = IOS_DEFAULT_RESOLUTION_X;
|
|
S32 resolutionHeight = IOS_DEFAULT_RESOLUTION_Y;
|
|
S32 resolutionHeight = IOS_DEFAULT_RESOLUTION_Y;
|
|
-
|
|
|
|
|
|
+
|
|
// First fetch the values from the prefs.
|
|
// First fetch the values from the prefs.
|
|
U32 iDeviceType = (U32) Con::getIntVariable("$pref::iOS::DeviceType");
|
|
U32 iDeviceType = (U32) Con::getIntVariable("$pref::iOS::DeviceType");
|
|
U32 iDeviceOrientation = (U32) Con::getIntVariable("$pref::iOS::ScreenOrientation");
|
|
U32 iDeviceOrientation = (U32) Con::getIntVariable("$pref::iOS::ScreenOrientation");
|
|
bool retinaEnabled = Con::getBoolVariable("$pref::iOS::RetinaEnabled");
|
|
bool retinaEnabled = Con::getBoolVariable("$pref::iOS::RetinaEnabled");
|
|
-
|
|
|
|
|
|
+
|
|
// 0: iPhone
|
|
// 0: iPhone
|
|
// 1: iPad
|
|
// 1: iPad
|
|
// 2: iPhone 5
|
|
// 2: iPhone 5
|
|
@@ -213,13 +213,13 @@ void Platform::initWindow(const Point2I &initialSize, const char *name)
|
|
else
|
|
else
|
|
{
|
|
{
|
|
U32 scaleFactor = retinaEnabled ? 2 : 1;
|
|
U32 scaleFactor = retinaEnabled ? 2 : 1;
|
|
-
|
|
|
|
|
|
+
|
|
resolutionWidth = iDeviceType ? (1024 * scaleFactor) : (480 * scaleFactor);
|
|
resolutionWidth = iDeviceType ? (1024 * scaleFactor) : (480 * scaleFactor);
|
|
resolutionHeight = iDeviceType ? (768 * scaleFactor) : (320 * scaleFactor);
|
|
resolutionHeight = iDeviceType ? (768 * scaleFactor) : (320 * scaleFactor);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
Point2I startRes;
|
|
Point2I startRes;
|
|
-
|
|
|
|
|
|
+
|
|
if (!iDeviceOrientation)
|
|
if (!iDeviceOrientation)
|
|
{
|
|
{
|
|
startRes.x = resolutionWidth;
|
|
startRes.x = resolutionWidth;
|
|
@@ -231,35 +231,35 @@ void Platform::initWindow(const Point2I &initialSize, const char *name)
|
|
startRes.x = resolutionHeight;
|
|
startRes.x = resolutionHeight;
|
|
startRes.y = resolutionWidth;
|
|
startRes.y = resolutionWidth;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
dSprintf(platState.appWindowTitle, sizeof(platState.appWindowTitle), name);
|
|
dSprintf(platState.appWindowTitle, sizeof(platState.appWindowTitle), name);
|
|
-
|
|
|
|
|
|
+
|
|
platState.windowSize.x = startRes.x;
|
|
platState.windowSize.x = startRes.x;
|
|
platState.windowSize.y = startRes.y;
|
|
platState.windowSize.y = startRes.y;
|
|
-
|
|
|
|
|
|
+
|
|
//Get screen orientation prefs //Based on 0 Landscape, 1 Portrait
|
|
//Get screen orientation prefs //Based on 0 Landscape, 1 Portrait
|
|
gScreenOrientation = iDeviceOrientation;
|
|
gScreenOrientation = iDeviceOrientation;
|
|
gScreenUpsideDown = Con::getBoolVariable("$pref::iOS::ScreenUpsideDown");
|
|
gScreenUpsideDown = Con::getBoolVariable("$pref::iOS::ScreenUpsideDown");
|
|
-
|
|
|
|
|
|
+
|
|
//Default to landscape, and run into portrait if requested.
|
|
//Default to landscape, and run into portrait if requested.
|
|
platState.portrait = false;
|
|
platState.portrait = false;
|
|
-
|
|
|
|
|
|
+
|
|
if (gScreenOrientation != 0) //fuzzytodo :add a constant
|
|
if (gScreenOrientation != 0) //fuzzytodo :add a constant
|
|
{
|
|
{
|
|
//Could handle other options here, later.
|
|
//Could handle other options here, later.
|
|
platState.portrait = true;
|
|
platState.portrait = true;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
//We should now have a good windowSize, it will be default if initial size was bad
|
|
//We should now have a good windowSize, it will be default if initial size was bad
|
|
T2DView * glView;
|
|
T2DView * glView;
|
|
CGRect rect;
|
|
CGRect rect;
|
|
-
|
|
|
|
|
|
+
|
|
rect.origin.x = 0;
|
|
rect.origin.x = 0;
|
|
rect.origin.y = 0;
|
|
rect.origin.y = 0;
|
|
-
|
|
|
|
|
|
+
|
|
rect.size.width = platState.windowSize.x;
|
|
rect.size.width = platState.windowSize.x;
|
|
rect.size.height = platState.windowSize.y;
|
|
rect.size.height = platState.windowSize.y;
|
|
-
|
|
|
|
|
|
+
|
|
glView = (T2DView *) platState.Window;
|
|
glView = (T2DView *) platState.Window;
|
|
|
|
|
|
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2)
|
|
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2)
|
|
@@ -319,7 +319,7 @@ bool Platform::openWebBrowser(const char *webAddress)
|
|
NSString *string = [[NSString alloc] initWithUTF8String:webAddress];
|
|
NSString *string = [[NSString alloc] initWithUTF8String:webAddress];
|
|
NSURL *url = [[NSURL alloc] initWithString:string];
|
|
NSURL *url = [[NSURL alloc] initWithString:string];
|
|
bool ret = [platState.application openURL:url];
|
|
bool ret = [platState.application openURL:url];
|
|
-
|
|
|
|
|
|
+
|
|
return ret;// this bails on the application, switching to Safari
|
|
return ret;// this bails on the application, switching to Safari
|
|
}
|
|
}
|
|
|
|
|
|
@@ -341,14 +341,14 @@ bool setStatusBarHidden(bool hidden)
|
|
{
|
|
{
|
|
platState.application.statusBarHidden = YES;
|
|
platState.application.statusBarHidden = YES;
|
|
gStatusBarHidden = true;
|
|
gStatusBarHidden = true;
|
|
-
|
|
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
platState.application.statusBarHidden = NO;
|
|
platState.application.statusBarHidden = NO;
|
|
gStatusBarHidden = false;
|
|
gStatusBarHidden = false;
|
|
-
|
|
|
|
|
|
+
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -371,7 +371,7 @@ void setStatusBarType(S32 type)
|
|
default:
|
|
default:
|
|
platState.application.statusBarStyle = UIStatusBarStyleDefault;
|
|
platState.application.statusBarStyle = UIStatusBarStyleDefault;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
gStatusBarType = type;
|
|
gStatusBarType = type;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -379,7 +379,7 @@ void setStatusBarType(S32 type)
|
|
bool setScreenOrientation(bool portrait, bool upsidedown)
|
|
bool setScreenOrientation(bool portrait, bool upsidedown)
|
|
{
|
|
{
|
|
bool success = false;
|
|
bool success = false;
|
|
-
|
|
|
|
|
|
+
|
|
CGPoint point;
|
|
CGPoint point;
|
|
|
|
|
|
// Is the iOS version less than 8?
|
|
// Is the iOS version less than 8?
|
|
@@ -439,18 +439,18 @@ bool setScreenOrientation(bool portrait, bool upsidedown)
|
|
}
|
|
}
|
|
|
|
|
|
ConsoleFunction(setScreenOrientation, bool, 3, 3, "Sets the orientation of the screen ( portrait/landscape, upside down or right-side up )\n"
|
|
ConsoleFunction(setScreenOrientation, bool, 3, 3, "Sets the orientation of the screen ( portrait/landscape, upside down or right-side up )\n"
|
|
- "@(bool portrait, bool upside_down)"){
|
|
|
|
|
|
+ "@(bool portrait, bool upside_down)"){
|
|
return setScreenOrientation(dAtob(argv[1]), dAtob(argv[2]));
|
|
return setScreenOrientation(dAtob(argv[1]), dAtob(argv[2]));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
ConsoleFunction(getStatusBarHidden, bool, 1, 1, " Checks whether the status bar is hidden\n"
|
|
ConsoleFunction(getStatusBarHidden, bool, 1, 1, " Checks whether the status bar is hidden\n"
|
|
- "@return Returns true if hidden and false if not"){
|
|
|
|
|
|
+ "@return Returns true if hidden and false if not"){
|
|
return isStatusBarHidden();
|
|
return isStatusBarHidden();
|
|
}
|
|
}
|
|
|
|
|
|
ConsoleFunction(setStatusBarHidden, bool, 2, 2, " Hides/unhides the iOS status bar \n"
|
|
ConsoleFunction(setStatusBarHidden, bool, 2, 2, " Hides/unhides the iOS status bar \n"
|
|
- "@return true == status bar is hidden, false == status bar is visible"){
|
|
|
|
|
|
+ "@return true == status bar is hidden, false == status bar is visible"){
|
|
return setStatusBarHidden(dAtob(argv[1]));
|
|
return setStatusBarHidden(dAtob(argv[1]));
|
|
}
|
|
}
|
|
|
|
|