Blender_bevy_components_wor.../tools/blenvy/blueprints/blueprints_registry.py
kaosat.dev a0b1959a43 feat(Blenvy): fixed all broken/ missing auto export elements
* fixed overhauled, cleaned up and improved settings change detection
 * serialize_scene now generate a hash per object instead of keeping the details (useless)
 * changed handling of gltf settings, so that only the actual non default, changed settings are saved
 * a ton of minor changes & cleanups to get export working correctly: it works !
 * started adding materials_in_depth_scan (wip) to be able to control more detailed (but costly) materials diffing for change detection
2024-05-28 16:56:28 +02:00

78 lines
2.4 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 ..core.scene_helpers import get_main_and_library_scenes
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
[main_scene_names, level_scenes, library_scene_names, library_scenes] = get_main_and_library_scenes(settings)
blueprints_data = blueprints_scan(level_scenes, library_scenes, settings)
self.blueprints_data = blueprints_data
return blueprints_data
#print("bla", self.blueprints_data)
"""for blueprint in blueprints_data.blueprints:
self.add_blueprint(blueprint)"""