Blender_bevy_components_wor.../tools/blenvy/blueprints/blueprints_registry.py
kaosat.dev 6f6b813474 feat(Blenvy): total overhaul of main/library scene handling
* main/library/nothing is now an enumProperty on scenes themselves
 * main/library scene listing is a dynamic property of the Blenvy core class instead of CollectionProperties
 * this means that removing / renaming scenes using the normal blender workflow automatically changes things for Blenvy as well !
 * overhauled & simplified main/library scenes ui accordingly
 * same for all the code that needed access to the main/library scenes
 * added main/library scene NAMES computed property for convenience
2024-06-07 14:08:28 +02:00

73 lines
2.1 KiB
Python

from types import SimpleNamespace
import bpy
import json
import os
import uuid
from pathlib import Path
from bpy_types import (PropertyGroup)
from bpy.props import (StringProperty, BoolProperty, FloatProperty, FloatVectorProperty, IntProperty, IntVectorProperty, EnumProperty, PointerProperty, CollectionProperty)
from ..settings import load_settings
from .blueprints_scan import blueprints_scan
def refresh_blueprints():
try:
blueprints_registry = bpy.context.window_manager.blueprints_registry
blueprints_registry.refresh_blueprints()
except:pass
return 3
# this is where we store the information for all available Blueprints
class BlueprintsRegistry(PropertyGroup):
blueprints_data = None
blueprints_list = []
asset_name_selector: StringProperty(
name="asset name",
description="name of asset to add",
) # type: ignore
asset_type_selector: EnumProperty(
name="asset type",
description="type of asset to add",
items=(
('MODEL', "Model", ""),
('AUDIO', "Audio", ""),
('IMAGE', "Image", ""),
)
) # type: ignore
asset_path_selector: StringProperty(
name="asset path",
description="path of asset to add",
subtype='FILE_PATH'
) # type: ignore
@classmethod
def register(cls):
bpy.types.WindowManager.blueprints_registry = PointerProperty(type=BlueprintsRegistry)
bpy.app.timers.register(refresh_blueprints)
@classmethod
def unregister(cls):
try:
bpy.app.timers.unregister(refresh_blueprints)
except: pass
del bpy.types.WindowManager.blueprints_registry
def add_blueprint(self, blueprint):
self.blueprints_list.append(blueprint)
def refresh_blueprints(self):
#print("titi", self)
blenvy = bpy.context.window_manager.blenvy
settings = blenvy
blueprints_data = blueprints_scan(settings.main_scenes, settings.library_scenes, settings)
self.blueprints_data = blueprints_data
return blueprints_data