2024-05-15 21:32:01 +00:00
|
|
|
from types import SimpleNamespace
|
2024-05-12 09:05:11 +00:00
|
|
|
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)
|
|
|
|
|
2024-05-15 21:32:01 +00:00
|
|
|
from ..settings import load_settings
|
2024-05-25 08:46:14 +00:00
|
|
|
from ..core.scene_helpers import get_main_and_library_scenes
|
2024-05-15 21:32:01 +00:00
|
|
|
from .blueprints_scan import blueprints_scan
|
|
|
|
|
2024-05-25 08:46:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
def refresh_blueprints():
|
|
|
|
try:
|
|
|
|
blueprints_registry = bpy.context.window_manager.blueprints_registry
|
|
|
|
blueprints_registry.refresh_blueprints()
|
|
|
|
except:pass
|
|
|
|
|
|
|
|
return 3
|
|
|
|
|
2024-05-12 09:05:11 +00:00
|
|
|
# this is where we store the information for all available Blueprints
|
|
|
|
class BlueprintsRegistry(PropertyGroup):
|
2024-05-28 14:56:28 +00:00
|
|
|
blueprints_data = None
|
2024-05-12 09:05:11 +00:00
|
|
|
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)
|
2024-05-25 08:46:14 +00:00
|
|
|
bpy.app.timers.register(refresh_blueprints)
|
2024-05-12 09:05:11 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def unregister(cls):
|
2024-05-25 08:46:14 +00:00
|
|
|
try:
|
|
|
|
bpy.app.timers.unregister(refresh_blueprints)
|
|
|
|
except: pass
|
|
|
|
|
2024-05-12 09:05:11 +00:00
|
|
|
del bpy.types.WindowManager.blueprints_registry
|
|
|
|
|
2024-05-25 08:46:14 +00:00
|
|
|
|
2024-05-12 09:05:11 +00:00
|
|
|
def add_blueprint(self, blueprint):
|
|
|
|
self.blueprints_list.append(blueprint)
|
|
|
|
|
2024-05-25 08:46:14 +00:00
|
|
|
def refresh_blueprints(self):
|
2024-05-28 14:56:28 +00:00
|
|
|
#print("titi", self)
|
2024-05-19 09:04:34 +00:00
|
|
|
blenvy = bpy.context.window_manager.blenvy
|
2024-05-25 08:46:14 +00:00
|
|
|
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)
|
2024-05-19 09:04:34 +00:00
|
|
|
self.blueprints_data = blueprints_data
|
2024-05-28 14:56:28 +00:00
|
|
|
return blueprints_data
|