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>2012-08-13 17:20:23 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-08-13 17:20:23 +0400
commite568fa921316e508a6441fc86a2bfe02f3d4aff3 (patch)
treef92cd3e26cc1d8de677a934add7c552038e0ae81 /system_demo_mode
parent6aeb74120ce436c42028369d5c77fdef3559b2a7 (diff)
Option to exit once demo loop plays through.
Diffstat (limited to 'system_demo_mode')
-rw-r--r--system_demo_mode/__init__.py13
-rw-r--r--system_demo_mode/config.py4
-rw-r--r--system_demo_mode/demo_mode.py13
3 files changed, 25 insertions, 5 deletions
diff --git a/system_demo_mode/__init__.py b/system_demo_mode/__init__.py
index d90c549c..39f72110 100644
--- a/system_demo_mode/__init__.py
+++ b/system_demo_mode/__init__.py
@@ -80,6 +80,11 @@ class DemoModeSetup(bpy.types.Operator):
description="Run demo immediately",
default=True,
)
+ exit = BoolProperty(
+ name="Exit",
+ description="Run once and exit",
+ default=False,
+ )
# these are mapped directly to the config!
#
@@ -134,8 +139,11 @@ class DemoModeSetup(bpy.types.Operator):
def execute(self, context):
from . import config
- keywords = self.as_keywords(ignore=("filepath", "random_order", "run"))
- cfg_str, dirpath = config.as_string(self.filepath, self.random_order, **keywords)
+ keywords = self.as_keywords(ignore=("filepath", "random_order", "run", "exit"))
+ cfg_str, dirpath = config.as_string(self.filepath,
+ self.random_order,
+ self.exit,
+ **keywords)
text = bpy.data.texts.get("demo.py")
if text:
text.name += ".back"
@@ -163,6 +171,7 @@ class DemoModeSetup(bpy.types.Operator):
box.label("Writes: demo.py config text")
layout.prop(self, "run")
+ layout.prop(self, "exit")
layout.label("Generate Settings:")
row = layout.row()
diff --git a/system_demo_mode/config.py b/system_demo_mode/config.py
index 6f31fbe8..93379061 100644
--- a/system_demo_mode/config.py
+++ b/system_demo_mode/config.py
@@ -36,7 +36,7 @@ def generate(dirpath, random_order, **kwargs):
return config, dirpath
-def as_string(dirpath, random_order, **kwargs):
+def as_string(dirpath, random_order, exit, **kwargs):
""" Config loader is in demo_mode.py
"""
cfg, dirpath = generate(dirpath, random_order, **kwargs)
@@ -51,6 +51,8 @@ def as_string(dirpath, random_order, **kwargs):
cfg_str += ["\n"]
cfg_str += ["search_path = %r\n" % dirpath]
cfg_str += ["\n"]
+ cfg_str += ["exit = %r\n" % exit]
+ cfg_str += ["\n"]
# All these work but use nicest formatting!
if 0: # works but not nice to edit.
diff --git a/system_demo_mode/demo_mode.py b/system_demo_mode/demo_mode.py
index 46c8ba5b..e3e26b87 100644
--- a/system_demo_mode/demo_mode.py
+++ b/system_demo_mode/demo_mode.py
@@ -44,7 +44,6 @@ DEMO_CFG = "demo.py"
# populate from script
global_config_files = []
-
global_config = dict(anim_cycles=1,
anim_render=False,
anim_screen_switch=0.0,
@@ -74,6 +73,7 @@ global_state = {
"timer": None,
"basedir": "", # demo.py is stored here
"demo_index": 0,
+ "exit": False,
}
@@ -138,7 +138,15 @@ def demo_mode_next_file(step=1):
global_state["demo_index"] -= 1
print(global_state["demo_index"])
- global_state["demo_index"] = (global_state["demo_index"] + step) % len(global_config_files)
+ demo_index_next = (global_state["demo_index"] + step) % len(global_config_files)
+
+ if global_state["exit"] and step > 0:
+ # check if we cycled
+ if demo_index_next < global_state["demo_index"]:
+ import sys
+ sys.exit(0)
+
+ global_state["demo_index"] = demo_index_next
print(global_state["demo_index"], "....")
print("func:demo_mode_next_file", global_state["demo_index"])
filepath = global_config_files[global_state["demo_index"]]["file"]
@@ -483,6 +491,7 @@ def load_config(cfg_name=DEMO_CFG):
demo_config = namespace["config"]
demo_search_path = namespace.get("search_path")
+ global_state["exit"] = namespace.get("exit", False)
if demo_search_path is None:
print("reading: %r, no search_path found, missing files wont be searched." % demo_path)