[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3677] trunk/py/scripts/addons/ system_demo_mode: Option to exit once demo loop plays through.
Campbell Barton
ideasman42 at gmail.com
Mon Aug 13 15:20:23 CEST 2012
Revision: 3677
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3677
Author: campbellbarton
Date: 2012-08-13 13:20:23 +0000 (Mon, 13 Aug 2012)
Log Message:
-----------
Option to exit once demo loop plays through.
Modified Paths:
--------------
trunk/py/scripts/addons/system_demo_mode/__init__.py
trunk/py/scripts/addons/system_demo_mode/config.py
trunk/py/scripts/addons/system_demo_mode/demo_mode.py
Modified: trunk/py/scripts/addons/system_demo_mode/__init__.py
===================================================================
--- trunk/py/scripts/addons/system_demo_mode/__init__.py 2012-08-10 11:41:28 UTC (rev 3676)
+++ trunk/py/scripts/addons/system_demo_mode/__init__.py 2012-08-13 13:20:23 UTC (rev 3677)
@@ -80,6 +80,11 @@
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 @@
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 @@
box.label("Writes: demo.py config text")
layout.prop(self, "run")
+ layout.prop(self, "exit")
layout.label("Generate Settings:")
row = layout.row()
Modified: trunk/py/scripts/addons/system_demo_mode/config.py
===================================================================
--- trunk/py/scripts/addons/system_demo_mode/config.py 2012-08-10 11:41:28 UTC (rev 3676)
+++ trunk/py/scripts/addons/system_demo_mode/config.py 2012-08-13 13:20:23 UTC (rev 3677)
@@ -36,7 +36,7 @@
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 @@
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.
Modified: trunk/py/scripts/addons/system_demo_mode/demo_mode.py
===================================================================
--- trunk/py/scripts/addons/system_demo_mode/demo_mode.py 2012-08-10 11:41:28 UTC (rev 3676)
+++ trunk/py/scripts/addons/system_demo_mode/demo_mode.py 2012-08-13 13:20:23 UTC (rev 3677)
@@ -44,7 +44,6 @@
# populate from script
global_config_files = []
-
global_config = dict(anim_cycles=1,
anim_render=False,
anim_screen_switch=0.0,
@@ -74,6 +73,7 @@
"timer": None,
"basedir": "", # demo.py is stored here
"demo_index": 0,
+ "exit": False,
}
@@ -138,7 +138,15 @@
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 @@
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)
More information about the Bf-extensions-cvs
mailing list