Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-addons
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-addons
Commits
fc9b2e7b
Commit
fc9b2e7b
authored
14 years ago
by
Campbell Barton
Browse files
Options
Downloads
Patches
Plain Diff
minor edits
parent
d5e4f9d8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
game_engine_save_as_runtime.py
+12
-7
12 additions, 7 deletions
game_engine_save_as_runtime.py
with
12 additions
and
7 deletions
game_engine_save_as_runtime.py
+
12
−
7
View file @
fc9b2e7b
...
@@ -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
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment