BGE Fix: [#32360] Standalone Player switches not working
authorDaniel Stokes <kupomail@gmail.com>
Thu, 5 Sep 2013 23:09:14 +0000 (23:09 +0000)
committerDaniel Stokes <kupomail@gmail.com>
Thu, 5 Sep 2013 23:09:14 +0000 (23:09 +0000)
Launching the player from the Blender UI now makes use of the "Debug Properties", "Framerate and Profile", and "Deprecation Warnings" options by setting the appropriate command line flags.

release/scripts/startup/bl_operators/wm.py

index d505aa36d1c36a8d9d82a455ec72869f02399cff..13ee0cc10663ce0eff816c36e0895449d2ca82fd 100644 (file)
@@ -1272,6 +1272,8 @@ class WM_OT_blenderplayer_start(Operator):
         import sys
         import subprocess
 
+        gs = context.scene.game_settings
+
         # these remain the same every execution
         blender_bin_path = bpy.app.binary_path
         blender_bin_dir = os.path.dirname(blender_bin_path)
@@ -1288,7 +1290,26 @@ class WM_OT_blenderplayer_start(Operator):
 
         filepath = bpy.data.filepath + '~' if bpy.data.is_saved else os.path.join(bpy.app.tempdir, "game.blend")
         bpy.ops.wm.save_as_mainfile('EXEC_DEFAULT', filepath=filepath, copy=True)
-        subprocess.call([player_path, filepath])
+
+        # start the command line call with the player path
+        args = []
+        args.append(player_path)
+
+        # handle some UI options as command line arguments
+        value = 1 if gs.show_framerate_profile else 0
+        args.extend(("-g show_framerate = %d"%value).split())
+        args.extend(("-g show_profile = %d"%value).split())
+
+        value = 1 if gs.show_debug_properties else 0
+        args.extend(("-g show_properties = %d"%value).split())
+
+        value = 1 if gs.use_deprecation_warnings else 0
+        args.extend(("-g ignore_deprecation_warnings = %d"%value).split())
+
+        # finish the call with the path to the blend file
+        args.append(filepath)
+
+        subprocess.call(args)
         os.remove(filepath)
         return {'FINISHED'}