Export_3ds: Improved distance cue node search
[blender-addons.git] / storypencil / __init__.py
blob72641c98bc679ef195c3bbc31a15ab608ab02d8e
1 # SPDX-FileCopyrightText: 2022-2023 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 # ----------------------------------------------
6 # Define Addon info
7 # ----------------------------------------------
8 bl_info = {
9 "name": "Storypencil - Storyboard Tools",
10 "description": "Storyboard tools",
11 "author": "Antonio Vazquez, Matias Mendiola, Daniel Martinez Lara, Rodrigo Blaas, Samuel Bernou",
12 "version": (1, 1, 4),
13 "blender": (3, 3, 0),
14 "location": "",
15 "warning": "",
16 "category": "Sequencer",
19 # ----------------------------------------------
20 # Import modules
21 # ----------------------------------------------
22 if "bpy" in locals():
23 import importlib
25 importlib.reload(utils)
26 importlib.reload(synchro)
27 importlib.reload(dopesheet_overlay)
28 importlib.reload(scene_tools)
29 importlib.reload(sound)
30 importlib.reload(render)
31 importlib.reload(ui)
32 else:
33 from . import utils
34 from . import synchro
35 from . import dopesheet_overlay
36 from . import scene_tools
37 from . import sound
38 from . import render
39 from . import ui
41 import bpy
42 from bpy.types import (
43 Scene,
44 WindowManager,
45 WorkSpace,
47 from bpy.props import (
48 BoolProperty,
49 IntProperty,
50 PointerProperty,
51 StringProperty,
52 EnumProperty,
55 # --------------------------------------------------------------
56 # Register all operators, props and panels
57 # --------------------------------------------------------------
58 classes = (
59 synchro.STORYPENCIL_PG_Settings,
60 scene_tools.STORYPENCIL_OT_Setup,
61 scene_tools.STORYPENCIL_OT_NewScene,
62 synchro.STORYPENCIL_OT_WindowBringFront,
63 synchro.STORYPENCIL_OT_WindowCloseOperator,
64 synchro.STORYPENCIL_OT_SyncToggleSecondary,
65 synchro.STORYPENCIL_OT_SetSyncMainOperator,
66 synchro.STORYPENCIL_OT_AddSecondaryWindowOperator,
67 synchro.STORYPENCIL_OT_Switch,
68 synchro.STORYPENCIL_OT_TabSwitch,
69 sound.STORYPENCIL_OT_duplicate_sound_in_edit_scene,
70 render.STORYPENCIL_OT_RenderAction,
71 ui.STORYPENCIL_PT_Settings,
72 ui.STORYPENCIL_PT_ModePanel,
73 ui.STORYPENCIL_PT_SettingsNew,
74 ui.STORYPENCIL_PT_RenderPanel,
75 ui.STORYPENCIL_PT_General,
79 def save_mode(self, context):
80 wm = context.window_manager
81 if context.scene.storypencil_mode == 'WINDOW':
82 context.scene.storypencil_use_new_window = True
83 else:
84 context.scene.storypencil_use_new_window = False
86 wm['storypencil_use_new_window'] = context.scene.storypencil_use_new_window
87 # Close all secondary windows
88 if context.scene.storypencil_use_new_window is False:
89 c = context.copy()
90 for win in context.window_manager.windows:
91 # Don't close actual window
92 if win == context.window:
93 continue
94 win_id = str(win.as_pointer())
95 if win_id != wm.storypencil_settings.main_window_id and win.parent is None:
96 c["window"] = win
97 bpy.ops.wm.window_close(c)
100 addon_keymaps = []
101 def register_keymaps():
102 kc = bpy.context.window_manager.keyconfigs.addon
103 if kc is None:
104 return
105 km = kc.keymaps.new(name="Sequencer", space_type="SEQUENCE_EDITOR")
106 kmi = km.keymap_items.new(
107 idname="storypencil.tabswitch",
108 type="TAB",
109 value="PRESS",
110 shift=False, ctrl=False, alt = False, oskey=False,
113 addon_keymaps.append((km, kmi))
115 def unregister_keymaps():
116 for km, kmi in addon_keymaps:
117 km.keymap_items.remove(kmi)
118 addon_keymaps.clear()
120 def register():
121 from bpy.utils import register_class
122 for cls in classes:
123 register_class(cls)
124 register_keymaps()
126 Scene.storypencil_scene_duration = IntProperty(
127 name="Scene Duration",
128 description="Default Duration for new Scene",
129 default=48,
130 min=1,
131 soft_max=250,
134 Scene.storypencil_use_new_window = BoolProperty(name="Open in new window",
135 description="Use secondary main window to edit scenes",
136 default=False)
138 Scene.storypencil_main_workspace = PointerProperty(type=WorkSpace,
139 description="Main Workspace used for editing Storyboard")
140 Scene.storypencil_main_scene = PointerProperty(type=Scene,
141 description="Main Scene used for editing Storyboard")
142 Scene.storypencil_edit_workspace = PointerProperty(type=WorkSpace,
143 description="Workspace used for changing drawings")
145 Scene.storypencil_base_scene = PointerProperty(type=Scene,
146 description="Template Scene used for creating new scenes")
148 Scene.storypencil_render_render_path = StringProperty(name="Output Path", subtype='FILE_PATH', maxlen=256,
149 description="Directory/name to save files")
151 Scene.storypencil_name_prefix = StringProperty(name="Scene Name Prefix", maxlen=20, default="")
153 Scene.storypencil_name_suffix = StringProperty(name="Scene Name Suffix", maxlen=20, default="")
155 Scene.storypencil_render_onlyselected = BoolProperty(name="Render only Selected Strips",
156 description="Render only the selected strips",
157 default=True)
159 Scene.storypencil_render_channel = IntProperty(name="Channel",
160 description="Channel to set the new rendered video",
161 default=5, min=1, max=128)
163 Scene.storypencil_add_render_strip = BoolProperty(name="Import Rendered Strips",
164 description="Add a Strip with the render",
165 default=True)
167 Scene.storypencil_render_step = IntProperty(name="Image Steps",
168 description="Minimum frames number to generate images between keyframes (0 to disable)",
169 default=0, min=0, max=128)
171 Scene.storypencil_render_numbering = EnumProperty(name="Image Numbering",
172 items=(
173 ('FRAME', "Frame", "Use real frame number"),
174 ('CONSECUTIVE', "Consecutive", "Use sequential numbering"),
176 description="Defines how frame is named")
178 Scene.storypencil_add_render_byfolder = BoolProperty(name="Folder by Strip",
179 description="Create a separated folder for each strip",
180 default=True)
182 Scene.storypencil_copy_sounds = BoolProperty(name="Copy Sounds",
183 description="Copy automatically the sounds from VSE to edit scene",
184 default=True)
186 Scene.storypencil_mode = EnumProperty(name="Mode",
187 items=(
188 ('SWITCH', "Switch", "Use same window and switch scene"),
189 ('WINDOW', "New Window", "Use a new window for editing"),
191 update=save_mode,
192 description="Defines how frame is named")
193 Scene.storypencil_selected_scn_only = BoolProperty(name='Selected Scene Only',
194 default=False,
195 description='Selected Scenes only')
196 Scene.storypencil_skip_sound_mute = BoolProperty(name='Ignore Muted Sound',
197 default=True,
198 description='Skip muted sound')
200 WindowManager.storypencil_settings = PointerProperty(
201 type=synchro.STORYPENCIL_PG_Settings,
202 name="Storypencil settings",
203 description="Storypencil tool settings",
206 # Append Handlers
207 bpy.app.handlers.frame_change_post.append(synchro.on_frame_changed)
208 bpy.app.handlers.load_post.append(synchro.sync_autoconfig)
210 bpy.context.window_manager.storypencil_settings.active = False
211 bpy.context.window_manager.storypencil_settings.main_window_id = ""
212 bpy.context.window_manager.storypencil_settings.secondary_windows_ids = ""
214 # UI integration in dopesheet header
215 bpy.types.DOPESHEET_HT_header.append(synchro.draw_sync_header)
216 dopesheet_overlay.register()
218 synchro.sync_autoconfig()
220 # UI integration in VSE header
221 bpy.types.SEQUENCER_HT_header.remove(synchro.draw_sync_sequencer_header)
222 bpy.types.SEQUENCER_HT_header.append(synchro.draw_sync_sequencer_header)
224 bpy.types.SEQUENCER_MT_add.append(scene_tools.draw_new_scene)
225 bpy.types.VIEW3D_MT_draw_gpencil.append(scene_tools.setup_storyboard)
228 def unregister():
229 unregister_keymaps()
231 from bpy.utils import unregister_class
232 for cls in reversed(classes):
233 unregister_class(cls)
235 # Remove Handlers
236 bpy.app.handlers.frame_change_post.remove(synchro.on_frame_changed)
237 bpy.app.handlers.load_post.remove(synchro.sync_autoconfig)
239 # remove UI integration
240 bpy.types.DOPESHEET_HT_header.remove(synchro.draw_sync_header)
241 dopesheet_overlay.unregister()
242 bpy.types.SEQUENCER_HT_header.remove(synchro.draw_sync_sequencer_header)
244 bpy.types.SEQUENCER_MT_add.remove(scene_tools.draw_new_scene)
245 bpy.types.VIEW3D_MT_draw_gpencil.remove(scene_tools.setup_storyboard)
247 del Scene.storypencil_scene_duration
248 del WindowManager.storypencil_settings
250 del Scene.storypencil_base_scene
251 del Scene.storypencil_main_workspace
252 del Scene.storypencil_main_scene
253 del Scene.storypencil_edit_workspace
255 del Scene.storypencil_render_render_path
256 del Scene.storypencil_name_prefix
257 del Scene.storypencil_name_suffix
258 del Scene.storypencil_render_onlyselected
259 del Scene.storypencil_render_channel
260 del Scene.storypencil_render_step
261 del Scene.storypencil_add_render_strip
262 del Scene.storypencil_render_numbering
263 del Scene.storypencil_add_render_byfolder
264 del Scene.storypencil_copy_sounds
265 del Scene.storypencil_mode
266 del Scene.storypencil_selected_scn_only
267 del Scene.storypencil_skip_sound_mute
269 if __name__ == '__main__':
270 register()