fix dynamic items
This commit is contained in:
		
							parent
							
								
									e921dafb49
								
							
						
					
					
						commit
						9fc423d6be
					
				| @ -21,6 +21,8 @@ MOVIE_SUFFIXES = ['.mov', '.mp4'] | |||||||
| SOUND_SUFFIXES = ['.eac3', '.mka', '.ogg', '.mp3', '.oga', '.ac3', '.flac', '.aiff', '.wav', '.wma', '.aac', '.m4a', '.aif', '.mp2'] | SOUND_SUFFIXES = ['.eac3', '.mka', '.ogg', '.mp3', '.oga', '.ac3', '.flac', '.aiff', '.wav', '.wma', '.aac', '.m4a', '.aif', '.mp2'] | ||||||
| 
 | 
 | ||||||
| ASSET_ITEMS = [] | ASSET_ITEMS = [] | ||||||
|  | PROJECT_ITEMS = [] | ||||||
|  | EPISODE_ITEMS = [] | ||||||
| 
 | 
 | ||||||
| CONFIG_DIR = Path(appdirs.user_config_dir(__package__.split('.')[0])) | CONFIG_DIR = Path(appdirs.user_config_dir(__package__.split('.')[0])) | ||||||
| PREVIEWS_DIR = CONFIG_DIR / 'thumbnails' | PREVIEWS_DIR = CONFIG_DIR / 'thumbnails' | ||||||
|  | |||||||
| @ -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.constants import ASSET_PREVIEWS, TRACKERS, PREVIEWS_DIR | ||||||
| from vse_toolbox.file_utils import norm_str, parse | from vse_toolbox.file_utils import norm_str, parse | ||||||
| from vse_toolbox.sequencer_utils import get_strip_sequence_name | from vse_toolbox.sequencer_utils import get_strip_sequence_name | ||||||
| 
 | from vse_toolbox import constants | ||||||
| 
 |  | ||||||
| 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)] |  | ||||||
|      |      | ||||||
|     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): | def get_tracker_items(self, context): | ||||||
|     return [(norm_str(a.__name__, format=str.upper), a.__name__, "", i) for i, a in enumerate(TRACKERS)] |     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) |     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): | class Project(PropertyGroup): | ||||||
|     id : StringProperty(default='') |     id : StringProperty(default='') | ||||||
| 
 | 
 | ||||||
| @ -494,6 +476,29 @@ class VSETB_UL_spreadsheet_export(UIList): | |||||||
|         layout.prop(item, 'export_name', text='') |         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): | class VSETB_PGT_scene_settings(PropertyGroup): | ||||||
| 
 | 
 | ||||||
|     projects : CollectionProperty(type=Project) |     projects : CollectionProperty(type=Project) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user