Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-03-29 12:16:09 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-03-29 12:16:09 +0400
commitad974de4793a7714e9e77f50dd216eab9bb9ebeb (patch)
tree6590af170a389b3cf98ea7994971a85b4dca41d3 /system_demo_mode/__init__.py
parent58c2bec4eb2d8c4f2a29a37179fbd3d050814f79 (diff)
Many small improvements, its generally usable now.
Diffstat (limited to 'system_demo_mode/__init__.py')
-rw-r--r--system_demo_mode/__init__.py86
1 files changed, 73 insertions, 13 deletions
diff --git a/system_demo_mode/__init__.py b/system_demo_mode/__init__.py
index 18b8b676..e70da0ee 100644
--- a/system_demo_mode/__init__.py
+++ b/system_demo_mode/__init__.py
@@ -40,14 +40,14 @@ if "bpy" in locals():
import bpy
-from bpy.props import StringProperty, BoolProperty, FloatProperty, EnumProperty
+from bpy.props import StringProperty, BoolProperty, IntProperty, FloatProperty, EnumProperty
from io_utils import ImportHelper
class DemoModeSetup(bpy.types.Operator):
'''Creates a demo script and optionally executes'''
bl_idname = "wm.demo_mode_setup"
- bl_label = "Demo Mode"
+ bl_label = "Demo Mode (Setup)"
bl_options = {'PRESET'}
# List of operator properties, the attributes will be assigned
@@ -57,7 +57,7 @@ class DemoModeSetup(bpy.types.Operator):
filepath = StringProperty(name="File Path", description="Filepath used for importing the file", maxlen=1024, default="", subtype='FILE_PATH')
random_order = BoolProperty(name="Random Order", description="Select files randomly", default=False)
mode = EnumProperty(items=(
- ('AUTO', "Automatic", ""),
+ ('AUTO', "Auto", ""),
('PLAY', "Play", ""),
('RENDER', "Render", ""),
),
@@ -69,9 +69,9 @@ class DemoModeSetup(bpy.types.Operator):
#
# anim
# ====
- anim_cycles = FloatProperty(name="Cycles", description="Number of times to play the animation", min=0.1, max=1000.0, soft_min=1.0, soft_max=1000.0, default=1.0)
+ anim_cycles = IntProperty(name="Cycles", description="Number of times to play the animation", min=1, max=1000, default=2)
anim_time_min = FloatProperty(name="Time Min", description="Minimum number of seconds to show the animation for (for small loops)", min=0.0, max=1000.0, soft_min=1.0, soft_max=1000.0, default=4.0)
- anim_time_max = FloatProperty(name="Time Max", description="Maximum number of seconds to show the animation for (incase the end frame is very high for no reason)", min=0.0, max=100000000.0, soft_min=1.0, soft_max=100000000.0, default=60.0)
+ anim_time_max = FloatProperty(name="Time Max", description="Maximum number of seconds to show the animation for (incase the end frame is very high for no reason)", min=0.0, max=100000000.0, soft_min=1.0, soft_max=100000000.0, default=8.0)
anim_screen_switch = FloatProperty(name="Screen Switch", description="Time between switching screens (in seconds) or 0 to disable", min=0.0, max=100000000.0, soft_min=1.0, soft_max=60.0, default=0.0)
#
# render
@@ -91,6 +91,10 @@ class DemoModeSetup(bpy.types.Operator):
text = bpy.data.texts.new("demo.py")
text.from_string(cfg_str)
+
+ if self.run:
+ extern_demo_mode_run()
+
return {'FINISHED'}
def invoke(self, context, event):
@@ -102,44 +106,100 @@ class DemoModeSetup(bpy.types.Operator):
def draw(self, context):
layout = self.layout
+
+ box = layout.box()
+ box.label("Search *.blend recursively")
+ box.label("Writes: demo.py config text.")
+
col = layout.column()
col.prop(self, "run")
col.label("Generate Settings:")
- col.prop(self, "mode")
+ row = col.row()
+ row.prop(self, "mode", expand=True)
col.prop(self, "random_order")
-
+
mode = self.mode
-
+
col.separator()
colsub = col.column()
- colsub.active = (mode in ('AUTO', 'ANIMATE'))
+ colsub.active = (mode in ('AUTO', 'PLAY'))
colsub.label("Animate Settings:")
colsub.prop(self, "anim_cycles")
colsub.prop(self, "anim_time_min")
colsub.prop(self, "anim_time_max")
+ colsub.prop(self, "anim_screen_switch")
col.separator()
colsub = col.column()
colsub.active = (mode in ('AUTO', 'RENDER'))
colsub.label("Render Settings:")
- colsub.prop(self, "render_anim")
+ colsub.prop(self, "display_render")
+
+
+class DemoModeRun(bpy.types.Operator):
+ bl_idname = "wm.demo_mode_run"
+ bl_label = "Demo Mode (Start)"
+
+ def execute(self, context):
+ if extern_demo_mode_run():
+ return {'FINISHED'}
+ else:
+ self.report({'ERROR'}, "Cant load demo.py config, run: File -> Demo Mode (Setup)")
+ return {'CANCELLED'}
+
+
+# --- call demo_mode.py funcs
+def extern_demo_mode_run():
+ # this accesses demo_mode.py which is kept standalone
+ # and can be run direct.
+ from . import demo_mode
+ if demo_mode.load_config():
+ demo_mode.demo_mode_load_file() # kick starts the modal operator
+ return True
+ else:
+ return False
+
+
+def extern_demo_mode_register():
+ # this accesses demo_mode.py which is kept standalone
+ # and can be run direct.
+ from . import demo_mode
+ demo_mode.register()
+
+
+def extern_demo_mode_unregister():
+ # this accesses demo_mode.py which is kept standalone
+ # and can be run direct.
+ from . import demo_mode
+ demo_mode.unregister()
+
+# --- intergration
def menu_func(self, context):
- self.layout.operator(DemoModeSetup.bl_idname)
+ layout = self.layout
+ layout.operator(DemoModeSetup.bl_idname, icon='PREFERENCES')
+ layout.operator(DemoModeRun.bl_idname, icon='PLAY')
+ layout.separator()
def register():
bpy.utils.register_class(DemoModeSetup)
+ bpy.utils.register_class(DemoModeRun)
- bpy.types.INFO_MT_file_import.append(menu_func)
+ bpy.types.INFO_MT_file.prepend(menu_func)
+
+ extern_demo_mode_register()
def unregister():
bpy.utils.unregister_class(DemoModeSetup)
+ bpy.utils.unregister_class(DemoModeRun)
+
+ bpy.types.INFO_MT_file.remove(menu_func)
- bpy.types.INFO_MT_file_import.remove(menu_func)
+ extern_demo_mode_unregister()
if __name__ == "__main__":
register()