139 lines
3.6 KiB
Python
139 lines
3.6 KiB
Python
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||
|
|
||
|
import bpy
|
||
|
import os
|
||
|
|
||
|
from bpy.props import (
|
||
|
BoolProperty,
|
||
|
CollectionProperty,
|
||
|
EnumProperty,
|
||
|
IntProperty,
|
||
|
PointerProperty,
|
||
|
StringProperty,
|
||
|
)
|
||
|
from bpy.types import PropertyGroup
|
||
|
from pprint import pprint as pp
|
||
|
from vse_toolbox.bl_utils import get_addon_prefs, get_settings
|
||
|
from vse_toolbox.constants import TRACKERS
|
||
|
from vse_toolbox.file_utils import norm_str
|
||
|
|
||
|
def get_episodes_items(self, context):
|
||
|
settings = get_settings()
|
||
|
|
||
|
project = settings.active_project
|
||
|
if not project:
|
||
|
return [('NONE', 'None', '', 0)]
|
||
|
|
||
|
episodes = project.episodes
|
||
|
if not episodes:
|
||
|
return [('NONE', 'None', '', 0)]
|
||
|
|
||
|
return [(e, e, '', i) for i, e in enumerate(episodes.keys())]
|
||
|
|
||
|
def get_project_items(self, context):
|
||
|
if not self.projects:
|
||
|
return [('NONE', 'None', '', 0)]
|
||
|
|
||
|
return [(p, p, '', i) for i, p in enumerate(self.projects.keys())]
|
||
|
|
||
|
def update_episodes(self, context):
|
||
|
settings = get_settings()
|
||
|
settings['episodes'] = 0
|
||
|
|
||
|
def get_tracker_items(self, context):
|
||
|
return [(norm_str(a.name, format=str.upper), a.name, "", i) for i, a in enumerate(TRACKERS)]
|
||
|
|
||
|
|
||
|
class Episode(PropertyGroup):
|
||
|
id : StringProperty(default='')
|
||
|
|
||
|
@property
|
||
|
def active(self):
|
||
|
settings = get_settings()
|
||
|
return self.get(settings.project_name)
|
||
|
|
||
|
|
||
|
class Project(PropertyGroup):
|
||
|
id : StringProperty(default='')
|
||
|
|
||
|
sequence_increment : IntProperty(
|
||
|
name="Sequence Increment", default=10, min=0, step=10)
|
||
|
|
||
|
shot_increment : IntProperty(
|
||
|
name="Shot Increment", default=10, min=0, step=10)
|
||
|
|
||
|
sequence_template : StringProperty(
|
||
|
name="Sequence Name", default="sq{index:03d}")
|
||
|
|
||
|
episode_template : StringProperty(
|
||
|
name="Episode Name", default="e{index:03d}")
|
||
|
|
||
|
shot_template : StringProperty(
|
||
|
name="Shot Name", default="{episode}_sh{index:04d}")
|
||
|
|
||
|
episode_name : EnumProperty(items=get_episodes_items)
|
||
|
episodes : CollectionProperty(type=Episode)
|
||
|
|
||
|
#FIXME Trouver une solution pour mettre des method dans les CollectionProperty
|
||
|
class Projects(PropertyGroup):
|
||
|
pass
|
||
|
# @property
|
||
|
# def active(self):
|
||
|
# settings = get_settings()
|
||
|
# return self.get(settings.project_name)
|
||
|
|
||
|
|
||
|
class VSETB_PGT_settings(PropertyGroup):
|
||
|
_projects = []
|
||
|
|
||
|
projects : CollectionProperty(type=Project)
|
||
|
project_name : EnumProperty(items=get_project_items, update=update_episodes)
|
||
|
tracker_name : EnumProperty(items=get_tracker_items)
|
||
|
toogle_prefs : BoolProperty(description='Toogle VSE ToolBox Preferences')
|
||
|
|
||
|
channels : EnumProperty(
|
||
|
items=[
|
||
|
('AUDIO', 'Audio', '', 0),
|
||
|
('MOVIE', 'Movie', '', 1),
|
||
|
('SHOTS', 'Shots', '', 2),
|
||
|
('SEQUENCES', 'Sequences', '', 3),
|
||
|
]
|
||
|
)
|
||
|
|
||
|
sequence_channel_name : StringProperty(
|
||
|
name="Sequences Channel Name", default="Sequences")
|
||
|
|
||
|
shot_channel_name : StringProperty(
|
||
|
name="Shot Channel Name", default="Shots")
|
||
|
|
||
|
@property
|
||
|
def active_project(self):
|
||
|
settings = get_settings()
|
||
|
return settings.projects.get(settings.project_name)
|
||
|
|
||
|
@property
|
||
|
def active_episode(self):
|
||
|
project = self.active_project
|
||
|
if project:
|
||
|
return project.episodes.get(project.episode_name)
|
||
|
|
||
|
classes=(
|
||
|
Episode,
|
||
|
Project,
|
||
|
Projects,
|
||
|
VSETB_PGT_settings,
|
||
|
)
|
||
|
|
||
|
|
||
|
def register():
|
||
|
for cls in classes:
|
||
|
bpy.utils.register_class(cls)
|
||
|
|
||
|
bpy.types.WindowManager.vsetb_settings = PointerProperty(type=VSETB_PGT_settings)
|
||
|
|
||
|
def unregister():
|
||
|
for cls in reversed(classes):
|
||
|
bpy.utils.unregister_class(cls)
|
||
|
|
||
|
del bpy.types.WindowManager.vsetb_settings
|