Skip to content
Snippets Groups Projects
Commit fc9b2e7b authored by Campbell Barton's avatar Campbell Barton
Browse files

minor edits

parent d5e4f9d8
No related branches found
No related tags found
No related merge requests found
...@@ -32,10 +32,8 @@ bl_addon_info = { ...@@ -32,10 +32,8 @@ bl_addon_info = {
'category': 'Game Engine'} 'category': 'Game Engine'}
import bpy import bpy
import struct
import os import os
import sys
import time
def WriteAppleRuntime(player_path, output_path): def WriteAppleRuntime(player_path, output_path):
# Use the system's cp command to preserve some meta-data # Use the system's cp command to preserve some meta-data
...@@ -43,7 +41,9 @@ def WriteAppleRuntime(player_path, output_path): ...@@ -43,7 +41,9 @@ def WriteAppleRuntime(player_path, output_path):
bpy.ops.save_as_mainfile(filepath=output_path+"/Contents/Resources/game.blend", copy=True) bpy.ops.save_as_mainfile(filepath=output_path+"/Contents/Resources/game.blend", copy=True)
def WriteRuntime(player_path, output_path): def WriteRuntime(player_path, output_path):
import struct
# Check the paths # Check the paths
if not os.path.isfile(player_path): if not os.path.isfile(player_path):
...@@ -96,7 +96,7 @@ def WriteRuntime(player_path, output_path): ...@@ -96,7 +96,7 @@ def WriteRuntime(player_path, output_path):
output.write(struct.pack('B', (offset>>0)&0xFF)) output.write(struct.pack('B', (offset>>0)&0xFF))
# Stuff for the runtime # Stuff for the runtime
output.write("BRUNTIME".encode()) output.write(b'BRUNTIME')
output.close() output.close()
# Make the runtime executable on Linux # Make the runtime executable on Linux
...@@ -106,6 +106,7 @@ def WriteRuntime(player_path, output_path): ...@@ -106,6 +106,7 @@ def WriteRuntime(player_path, output_path):
from bpy.props import * from bpy.props import *
class SaveAsRuntime(bpy.types.Operator): class SaveAsRuntime(bpy.types.Operator):
bl_idname = "wm.save_as_runtime" bl_idname = "wm.save_as_runtime"
bl_label = "Save As Runtime" bl_label = "Save As Runtime"
...@@ -120,8 +121,9 @@ class SaveAsRuntime(bpy.types.Operator): ...@@ -120,8 +121,9 @@ class SaveAsRuntime(bpy.types.Operator):
filepath = StringProperty(name="Output Path", description="Where to save the runtime", default="") filepath = StringProperty(name="Output Path", description="Where to save the runtime", default="")
def execute(self, context): def execute(self, context):
print("Saving runtime to", self.properties.filepath) import time
start_time = time.clock() start_time = time.clock()
print("Saving runtime to", self.properties.filepath)
WriteRuntime(self.properties.player_path, WriteRuntime(self.properties.player_path,
self.properties.filepath) self.properties.filepath)
print("Finished in %.4fs" % (time.clock()-start_time)) print("Finished in %.4fs" % (time.clock()-start_time))
...@@ -132,6 +134,7 @@ class SaveAsRuntime(bpy.types.Operator): ...@@ -132,6 +134,7 @@ class SaveAsRuntime(bpy.types.Operator):
wm.add_fileselect(self) wm.add_fileselect(self)
return {'RUNNING_MODAL'} return {'RUNNING_MODAL'}
def menu_func(self, context): def menu_func(self, context):
ext = os.path.splitext(bpy.app.binary_path)[-1] ext = os.path.splitext(bpy.app.binary_path)[-1]
...@@ -141,9 +144,11 @@ def menu_func(self, context): ...@@ -141,9 +144,11 @@ def menu_func(self, context):
def register(): def register():
bpy.types.INFO_MT_file_export.append(menu_func) bpy.types.INFO_MT_file_export.append(menu_func)
def unregister(): def unregister():
bpy.types.INFO_MT_file_export.remove(menu_func) bpy.types.INFO_MT_file_export.remove(menu_func)
if __name__ == "__main__": if __name__ == "__main__":
register() register()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment