Przeglądaj źródła

Adds canExit to Platform and Game.

Ken Whatmough 13 lat temu
rodzic
commit
5ff256593e

+ 8 - 1
gameplay/src/Game.h

@@ -475,10 +475,17 @@ public:
     /**
      * Is multi-touch mode enabled.
      *
-     * @return true is multi-touch is enabled.
+     * @return true if multi-touch is enabled.
      */
     inline bool isMultiTouch() const;
 
+    /**
+     * Whether this game is allowed to exit programmatically.
+     *
+     * @return true if a programmatic exit is allowed.
+     */
+    inline bool canExit() const;
+
     /**
      * Gets the current accelerometer values.
      *

+ 5 - 0
gameplay/src/Game.inl

@@ -106,6 +106,11 @@ inline bool Game::isMultiTouch() const
     return Platform::isMultiTouch();
 }
 
+inline bool Game::canExit() const
+{
+    return Platform::canExit();
+}
+
 inline void Game::getAccelerometerValues(float* pitch, float* roll)
 {
     Platform::getAccelerometerValues(pitch, roll);

+ 8 - 0
gameplay/src/Platform.h

@@ -55,6 +55,14 @@ public:
      * This function is called automatically when the game shutdown function is called
      */
     static void signalShutdown();
+
+    /**
+     * Indicates whether a programmatic exit is allowed on this platform.
+     * Some platforms (eg. iOS) do not allow apps to exit programmatically.
+     *
+     * @return whether a programmatic exit is allowed on this platform.
+     */
+    static bool canExit();
     
     /**
      * Gets the display width.

+ 5 - 0
gameplay/src/PlatformAndroid.cpp

@@ -1037,6 +1037,11 @@ void Platform::signalShutdown()
 {
     // nothing to do  
 }
+
+bool Platform::canExit()
+{
+    return true;
+}
    
 unsigned int Platform::getDisplayWidth()
 {

+ 5 - 0
gameplay/src/PlatformLinux.cpp

@@ -702,6 +702,11 @@ void Platform::signalShutdown()
 { 
     // nothing to do  
 }
+
+bool Platform::canExit()
+{
+    return true;
+}
     
 unsigned int Platform::getDisplayWidth()
 {

+ 5 - 0
gameplay/src/PlatformMacOSX.mm

@@ -1397,6 +1397,11 @@ void Platform::signalShutdown()
     NSApplication* app = [NSApplication sharedApplication];
     [app performSelectorOnMainThread:@selector(terminate:) withObject:nil waitUntilDone:NO];
 }
+
+bool Platform::canExit()
+{
+    return true;
+}
     
 unsigned int Platform::getDisplayWidth()
 {

+ 6 - 1
gameplay/src/PlatformQNX.cpp

@@ -1141,7 +1141,12 @@ void Platform::signalShutdown()
 {
     // nothing to do  
 }
-    
+
+bool Platform::canExit()
+{
+    return true;
+}
+
 unsigned int Platform::getDisplayWidth()
 {
     return __screenWindowSize[0];

+ 5 - 0
gameplay/src/PlatformWin32.cpp

@@ -1083,6 +1083,11 @@ void Platform::signalShutdown()
     // nothing to do  
 }
 
+bool Platform::canExit()
+{
+    return true;
+}
+
 unsigned int Platform::getDisplayWidth()
 {
     static RECT rect;

+ 5 - 0
gameplay/src/PlatformiOS.mm

@@ -1094,6 +1094,11 @@ void Platform::signalShutdown()
     [__view stopUpdating];
     exit(0);
 }
+
+bool Platform::canExit()
+{
+    return false;
+}
 
 unsigned int Platform::getDisplayWidth()
 {