ソースを参照

Added Game::getArguments().
It is now possible to get the command line arguments for all platforms except for Android. This can be updated later for Android is someone knows how to get the command line arguments.

Darryl Gough 13 年 前
コミット
8d4899ccec

+ 5 - 0
gameplay/src/Game.cpp

@@ -500,6 +500,11 @@ void Game::gamepadEvent(Gamepad::GamepadEvent evt, Gamepad* gamepad)
 {
 }
 
+void Game::getArguments(int* argc, char*** argv)
+{
+    Platform::getArguments(argc, argv);
+}
+
 void Game::schedule(float timeOffset, TimeListener* timeListener, void* cookie)
 {
     GP_ASSERT(_timeEvents);

+ 8 - 0
gameplay/src/Game.h

@@ -507,6 +507,14 @@ public:
      */
     inline void getAccelerometerValues(float* pitch, float* roll);
 
+    /**
+     * Gets the command line arguments.
+     * 
+     * @param argc The number of command line arguments.
+     * @param argv The array of command line arguments.
+     */
+    void getArguments(int* argc, char*** argv);
+
     /**
      * Schedules a time event to be sent to the given TimeListener a given number of game milliseconds from now.
      * Game time stops while the game is paused. A time offset of zero will fire the time event in the next frame.

+ 8 - 0
gameplay/src/Platform.h

@@ -207,6 +207,14 @@ private:
      * @param roll The accelerometer roll.
      */
     static void getAccelerometerValues(float* pitch, float* roll);
+
+    /**
+     * Gets the command line arguments.
+     * 
+     * @param argc The number of command line arguments.
+     * @param argv The array of command line arguments.
+     */
+    static void getArguments(int* argc, char*** argv);
     
     /**
      * Shows or hides the virtual keyboard (if supported).

+ 8 - 0
gameplay/src/PlatformAndroid.cpp

@@ -1217,6 +1217,14 @@ void Platform::getAccelerometerValues(float* pitch, float* roll)
     }
 }
 
+void Platform::getArguments(int* argc, char*** argv)
+{
+    if (argc)
+        *argc = 0;
+    if (argv)
+        *argv = 0;
+}
+
 bool Platform::hasMouse()
 {
     // not supported

+ 10 - 0
gameplay/src/PlatformBlackBerry.cpp

@@ -26,6 +26,8 @@
 
 using namespace std;
 
+int __argc = 0;
+char** __argv = 0;
 struct timespec __timespec;
 static double __timeStart;
 static double __timeAbsolute;
@@ -1472,6 +1474,14 @@ void Platform::getAccelerometerValues(float* pitch, float* roll)
     }
 }
 
+void Platform::getArguments(int* argc, char*** argv)
+{
+    if (argc)
+        *argc = __argc;
+    if (argv)
+        *argv = __argv;
+}
+
 bool Platform::hasMouse()
 {
     // not supported

+ 30 - 19
gameplay/src/PlatformLinux.cpp

@@ -25,6 +25,9 @@
 
 using namespace std;
 
+int __argc = 0;
+char** __argv = 0;
+
 enum GamepadAxisInfoFlags
 {
     GP_AXIS_SKIP = 0x1,
@@ -1398,21 +1401,21 @@ namespace gameplay
         usleep(ms * 1000);
     }
 
-    void Platform::setMultiSampling(bool enabled)
-    {
-        if (enabled == __multiSampling)
-        {
-            return;
-        }
-        
-            //todo
-            
-            __multiSampling = enabled;
-    }
-    
-        bool Platform::isMultiSampling()
-        {
-            return __multiSampling;
+    void Platform::setMultiSampling(bool enabled)
+    {
+        if (enabled == __multiSampling)
+        {
+            return;
+        }
+        
+            //todo
+            
+            __multiSampling = enabled;
+    }
+    
+        bool Platform::isMultiSampling()
+        {
+            return __multiSampling;
         }
 
     void Platform::setMultiTouch(bool enabled)
@@ -1434,6 +1437,14 @@ namespace gameplay
         *roll = __roll;
     }
 
+    void Platform::getArguments(int* argc, char*** argv)
+    {
+        if (argc)
+            *argc = __argc;
+        if (arv)
+            *argv = __argv;
+    }
+
     bool Platform::hasMouse()
     {
         return true;
@@ -1538,7 +1549,7 @@ namespace gameplay
             return Game::getInstance()->getScriptController()->mouseEvent(evt, x, y, wheelDelta);
         }
     }
-    
+    
         void Platform::gamepadEventConnectedInternal(GamepadHandle handle,  unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount,
                 unsigned int vendorId, unsigned int productId, const char* vendorString, const char* productString)
         {
@@ -1550,10 +1561,10 @@ namespace gameplay
         Gamepad::remove(handle);
     }
 
-    void Platform::shutdownInternal()
-    {
+    void Platform::shutdownInternal()
+    {
         closeAllGamepads();
-        Game::getInstance()->shutdown();
+        Game::getInstance()->shutdown();
     }
 
     bool Platform::isGestureSupported(Gesture::GestureEvent evt)

+ 9 - 0
gameplay/src/PlatformMacOSX.mm

@@ -30,6 +30,9 @@ using namespace gameplay;
 @class View;
 @class HIDGamepad;
 
+int __argc = 0;
+char** __argv = 0;
+
 // Default to 720p
 static int __width = 1280;
 static int __height = 720;
@@ -1789,6 +1792,12 @@ void Platform::getAccelerometerValues(float* pitch, float* roll)
     *roll = __roll;
 }
 
+void Platform::getArguments(int* argc, char*** argv)
+{
+    *argc = __argc;
+    *argv = __argv;
+}
+    
 bool Platform::hasMouse()
 {
     return true;

+ 8 - 0
gameplay/src/PlatformWindows.cpp

@@ -1112,6 +1112,14 @@ void Platform::getAccelerometerValues(float* pitch, float* roll)
     *roll = __roll;
 }
 
+void Platform::getArguments(int* argc, char*** argv)
+{
+    if (argc)
+        *argc = __argc;
+    if (argv)
+        *argv = __argv;
+}
+
 bool Platform::hasMouse()
 {
     return true;

+ 9 - 0
gameplay/src/PlatformiOS.mm

@@ -32,6 +32,9 @@ extern const int WINDOW_WIDTH  = [[UIScreen mainScreen] bounds].size.height * [[
 extern const int WINDOW_HEIGHT = [[UIScreen mainScreen] bounds].size.width * [[UIScreen mainScreen] scale];
 extern const int WINDOW_SCALE = [[UIScreen mainScreen] scale];
 
+int __argc = 0;
+char** __argv = 0;
+
 @class AppDelegate;
 @class View;
 
@@ -1381,6 +1384,12 @@ void Platform::getAccelerometerValues(float* pitch, float* roll)
 {
     [__appDelegate getAccelerometerPitch:pitch roll:roll];
 }
+    
+void Platform::getArguments(int* argc, char*** argv)
+{
+    argc = __argc;
+    argv = __argv;
+}
 
 bool Platform::hasMouse()
 {

+ 5 - 0
gameplay/src/gameplay-main-blackberry.cpp

@@ -4,11 +4,16 @@
 
 using namespace gameplay;
 
+extern int __argc;
+extern char** __argv;
+
 /**
  * Main entry point.
  */
 int main(int argc, char** argv)
 {
+    __argc = argc;
+    __argv = argv;
     Game* game = Game::getInstance();
     Platform* platform = Platform::create(game);
     GP_ASSERT(platform);

+ 6 - 1
gameplay/src/gameplay-main-ios.mm

@@ -5,11 +5,16 @@
 
 using namespace gameplay;
 
+extern int __argc;
+extern char** __argv;
+
 /**
  * Main entry point.
  */
 int main(int argc, char** argv)
-{   
+{
+    __argc = argc;
+    __argv = argv;
     NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init];
     Game* game = Game::getInstance();
     Platform* platform = Platform::create(game);

+ 5 - 0
gameplay/src/gameplay-main-linux.cpp

@@ -4,11 +4,16 @@
 
 using namespace gameplay;
 
+extern int __argc;
+extern char** __argv;
+
 /**
  * Main entry point.
  */
 int main(int argc, char** argv)
 {
+    __argc = argc;
+    __argv = argv;
     Game* game = Game::getInstance();
     Platform* platform = Platform::create(game);
     GP_ASSERT(platform);

+ 5 - 0
gameplay/src/gameplay-main-macosx.mm

@@ -5,11 +5,16 @@
 
 using namespace gameplay;
 
+extern int __argc;
+extern char** __argv;
+
 /**
  * Main entry point.
  */
 int main(int argc, char** argv)
 {
+    __argc = argc;
+    __argv = argv;
     NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init];
     Game* game = Game::getInstance();
     Platform* platform = Platform::create(game);