[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1121] contrib/py/scripts/addons/ game_engine_save_as_runtime.py: game_engine_save_as_runtime.py:

Mitchell Stokes mogurijin at gmail.com
Tue Oct 26 07:01:36 CEST 2010


Revision: 1121
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=1121
Author:   moguri
Date:     2010-10-26 07:01:30 +0200 (Tue, 26 Oct 2010)

Log Message:
-----------
game_engine_save_as_runtime.py:
  * Cleaning up default_path with better cross-platform code (using os.path.join())
  * Adding timings
  * Fixed a saving bug

Modified Paths:
--------------
    contrib/py/scripts/addons/game_engine_save_as_runtime.py

Modified: contrib/py/scripts/addons/game_engine_save_as_runtime.py
===================================================================
--- contrib/py/scripts/addons/game_engine_save_as_runtime.py	2010-10-25 22:50:46 UTC (rev 1120)
+++ contrib/py/scripts/addons/game_engine_save_as_runtime.py	2010-10-26 05:01:30 UTC (rev 1121)
@@ -19,7 +19,7 @@
 bl_addon_info = {
     "name": "Save As Runtime",
     "author": "Mitchell Stokes (Moguri)",
-    "version": (0,2),
+    "version": (0,2b),
     "blender": (2, 5, 4),
     "api": 31667,
     "location": "File > Export",
@@ -35,6 +35,7 @@
 import struct
 import os
 import sys
+import time
 
 def WriteAppleRuntime(player_path, output_path):
     # Use the system's cp command to preserve some meta-data
@@ -61,8 +62,8 @@
     file.close()
     
     # Create a tmp blend file
-    blend_path = output_path+'__'
-    bpy.ops.wm.save_as_mainfile(filepath=blend_path, check_existing=False, copy=True)
+    blend_path = bpy.path.clean_name(output_path)
+    bpy.ops.wm.save_as_mainfile(filepath=blend_path, copy=True)
     blend_path += '.blend'
     
     
@@ -107,16 +108,17 @@
         ext = ".exe"
     elif os.name == "mac":
         ext = ".app"
-    
-    if not ext:
-        player_path = StringProperty(name="Player Path", description="The path to the player to use", default=sys.argv[0]+'player')
-    else:
-        player_path = StringProperty(name="Player Path", description="The path to the player to use", default=sys.argv[0].replace("blender"+ext, "blenderplayer"+ext))
+
+    default_path = os.path.join(os.path.dirname(sys.argv[0]), 'blenderplayer'+ext)
+    player_path = StringProperty(name="Player Path", description="The path to the player to use", default=default_path)
     filepath = StringProperty(name="Output Path", description="Where to save the runtime", default="")
     
     def execute(self, context):
+        print("Saving runtime to", self.properties.filepath)
+        start_time = time.clock()
         WriteRuntime(self.properties.player_path,
                     self.properties.filepath)
+        print("Finished in %.4fs" % (time.clock()-start_time))
         return {'FINISHED'}
                     
     def invoke(self, context, event):




More information about the Bf-extensions-cvs mailing list