Demo Mode: port Demo Mode addon to Blender 2.8

Not sure if I fixed everything.. At least it runs again.
Might have to do more tests, never used this addon before.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D3729
This commit is contained in:
Jacques Lucke 2018-09-25 18:57:47 +02:00
parent ff7ded091b
commit b192f64fc3
2 changed files with 89 additions and 90 deletions

View File

@ -21,7 +21,7 @@
bl_info = {
"name": "Demo Mode",
"author": "Campbell Barton",
"blender": (2, 57, 0),
"blender": (2, 80, 0),
"location": "Demo Menu",
"description": "Demo mode lets you select multiple blend files and loop over them.",
"warning": "",
@ -39,12 +39,12 @@ if "bpy" in locals():
import bpy
from bpy.props import (
StringProperty,
BoolProperty,
IntProperty,
FloatProperty,
EnumProperty,
)
StringProperty,
BoolProperty,
IntProperty,
FloatProperty,
EnumProperty,
)
class DemoModeSetup(bpy.types.Operator):
@ -57,85 +57,84 @@ class DemoModeSetup(bpy.types.Operator):
# to the class instance from the operator settings before calling.
# these are used to create the file list.
directory = StringProperty(
name="Search Path",
description="Directory used for importing the file",
maxlen=1024,
subtype='DIR_PATH',
)
random_order = BoolProperty(
name="Random Order",
description="Select files randomly",
default=False,
)
mode = EnumProperty(
name="Method",
items=(('AUTO', "Auto", ""),
('PLAY', "Play", ""),
('RENDER', "Render", ""),
),
)
directory: StringProperty(
name="Search Path",
description="Directory used for importing the file",
maxlen=1024,
subtype='DIR_PATH',
)
random_order: BoolProperty(
name="Random Order",
description="Select files randomly",
default=False,
)
mode: EnumProperty(
name="Method",
items=(('AUTO', "Auto", ""),
('PLAY', "Play", ""),
('RENDER', "Render", ""))
)
run = BoolProperty(
name="Run Immediately!",
description="Run demo immediately",
default=True,
)
exit = BoolProperty(
name="Exit",
description="Run once and exit",
default=False,
)
run: BoolProperty(
name="Run Immediately!",
description="Run demo immediately",
default=True,
)
exit: BoolProperty(
name="Exit",
description="Run once and exit",
default=False,
)
# these are mapped directly to the config!
#
# anim
# ====
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 "
"(in case 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,
)
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 "
"(in case 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
# ======
display_render = FloatProperty(
name="Render Delay",
description="Time to display the rendered image before moving on "
"(in seconds)",
min=0.0, max=60.0,
default=4.0,
)
anim_render = BoolProperty(
name="Render Anim",
description="Render entire animation (render mode only)",
default=False,
)
display_render: FloatProperty(
name="Render Delay",
description="Time to display the rendered image before moving on "
"(in seconds)",
min=0.0, max=60.0,
default=4.0,
)
anim_render: BoolProperty(
name="Render Anim",
description="Render entire animation (render mode only)",
default=False,
)
def execute(self, context):
from . import config
@ -168,13 +167,13 @@ class DemoModeSetup(bpy.types.Operator):
layout = self.layout
box = layout.box()
box.label("Search *.blend recursively")
box.label("Writes: demo.py config text")
box.label(text="Search *.blend recursively")
box.label(text="Writes: demo.py config text")
layout.prop(self, "run")
layout.prop(self, "exit")
layout.label("Generate Settings:")
layout.label(text="Generate Settings:")
row = layout.row()
row.prop(self, "mode", expand=True)
layout.prop(self, "random_order")
@ -184,7 +183,7 @@ class DemoModeSetup(bpy.types.Operator):
layout.separator()
sub = layout.column()
sub.active = (mode in {'AUTO', 'PLAY'})
sub.label("Animate Settings:")
sub.label(text="Animate Settings:")
sub.prop(self, "anim_cycles")
sub.prop(self, "anim_time_min")
sub.prop(self, "anim_time_max")
@ -193,7 +192,7 @@ class DemoModeSetup(bpy.types.Operator):
layout.separator()
sub = layout.column()
sub.active = (mode in {'AUTO', 'RENDER'})
sub.label("Render Settings:")
sub.label(text="Render Settings:")
sub.prop(self, "display_render")

View File

@ -154,7 +154,7 @@ def demo_mode_next_file(step=1):
def demo_mode_timer_add():
global_state["timer"] = bpy.context.window_manager.event_timer_add(0.8, bpy.context.window)
global_state["timer"] = bpy.context.window_manager.event_timer_add(0.8, window=bpy.context.window)
def demo_mode_timer_remove():
@ -418,12 +418,12 @@ class DemoModeControl(bpy.types.Operator):
bl_idname = "wm.demo_mode_control"
bl_label = "Control"
mode = bpy.props.EnumProperty(items=(
('PREV', "Prev", ""),
('PAUSE', "Pause", ""),
('NEXT', "Next", ""),
),
name="Mode")
mode: bpy.props.EnumProperty(
items=(('PREV', "Prev", ""),
('PAUSE', "Pause", ""),
('NEXT', "Next", "")),
name="Mode"
)
def execute(self, context):
mode = self.mode
@ -441,7 +441,7 @@ def menu_func(self, context):
layout = self.layout
layout.operator_context = 'EXEC_DEFAULT'
row = layout.row(align=True)
row.label("Demo Mode:")
row.label(text="Demo Mode:")
if not DemoMode.enabled:
row.operator("wm.demo_mode", icon='PLAY', text="")
else: