fix dynamic items

pull/5/head
ChristopheSeux 2024-02-14 11:08:38 +01:00
parent e921dafb49
commit 9fc423d6be
2 changed files with 43 additions and 36 deletions

View File

@ -21,6 +21,8 @@ MOVIE_SUFFIXES = ['.mov', '.mp4']
SOUND_SUFFIXES = ['.eac3', '.mka', '.ogg', '.mp3', '.oga', '.ac3', '.flac', '.aiff', '.wav', '.wma', '.aac', '.m4a', '.aif', '.mp2']
ASSET_ITEMS = []
PROJECT_ITEMS = []
EPISODE_ITEMS = []
CONFIG_DIR = Path(appdirs.user_config_dir(__package__.split('.')[0]))
PREVIEWS_DIR = CONFIG_DIR / 'thumbnails'

View File

@ -19,43 +19,8 @@ from vse_toolbox.bl_utils import get_addon_prefs, get_scene_settings
from vse_toolbox.constants import ASSET_PREVIEWS, TRACKERS, PREVIEWS_DIR
from vse_toolbox.file_utils import norm_str, parse
from vse_toolbox.sequencer_utils import get_strip_sequence_name
def get_episodes_items(self, context):
settings = get_scene_settings()
project = settings.active_project
if not project:
return [('/', '/', '', 0)]
episodes = project.episodes
if not episodes:
return [('/', '/', '', 0)]
from vse_toolbox import constants
return [(e, e, '', i) for i, e in enumerate(episodes.keys())]
def get_project_items(self, context):
if not self.projects:
return [('/', '/', '', 0)]
return [(p, p, '', i) for i, p in enumerate(self.projects.keys())]
def on_project_updated(self, context):
settings = get_scene_settings()
settings['episodes'] = 0
#print('Update active Project')
bpy.ops.vse_toolbox.load_assets()
if settings.active_project:
settings.active_project.set_strip_metadata()
os.environ['TRACKER_PROJECT_ID'] = settings.active_project.id
def on_episode_updated(self, context):
settings = get_scene_settings()
os.environ['TRACKER_EPISODE_ID'] = settings.active_episode.id
def get_tracker_items(self, context):
return [(norm_str(a.__name__, format=str.upper), a.__name__, "", i) for i, a in enumerate(TRACKERS)]
@ -219,6 +184,23 @@ class SpreadsheetImport(PropertyGroup):
update_edit: BoolProperty(default=True)
def get_episodes_items(self, context):
settings = get_scene_settings()
project = settings.active_project
items = [('/', '/', '', 0)]
if project and project.episodes:
items = [(e, e, '', i) for i, e in enumerate(project.episodes.keys())]
constants.EPISODE_ITEMS[:] = items
return constants.EPISODE_ITEMS
def on_episode_updated(self, context):
settings = get_scene_settings()
os.environ['TRACKER_EPISODE_ID'] = settings.active_episode.id
class Project(PropertyGroup):
id : StringProperty(default='')
@ -494,6 +476,29 @@ class VSETB_UL_spreadsheet_export(UIList):
layout.prop(item, 'export_name', text='')
def get_project_items(self, context):
items = [('/', '/', '', 0)]
if self.projects:
items = [(p, p, '', i) for i, p in enumerate(self.projects.keys())]
constants.PROJECT_ITEMS[:] = items
return constants.PROJECT_ITEMS
def on_project_updated(self, context):
settings = get_scene_settings()
settings['episodes'] = 0
#print('Update active Project')
bpy.ops.vse_toolbox.load_assets()
if settings.active_project:
settings.active_project.set_strip_metadata()
os.environ['TRACKER_PROJECT_ID'] = settings.active_project.id
class VSETB_PGT_scene_settings(PropertyGroup):
projects : CollectionProperty(type=Project)