asset_library/preferences.py

60 lines
1.5 KiB
Python
Raw Permalink Normal View History

2024-05-27 17:22:45 +02:00
import bpy
from bpy.types import AddonPreferences
from bpy.props import (CollectionProperty, StringProperty)
from . properties import AssetLibrary
from . core.bl_utils import get_addon_prefs
2024-07-04 11:53:58 +02:00
from . core.lib_utils import update_library_path
2024-05-27 17:22:45 +02:00
class AssetLibraryPrefs(AddonPreferences):
bl_idname = __package__
2024-07-04 11:53:58 +02:00
config_path : StringProperty(subtype="FILE_PATH")
2024-05-27 17:22:45 +02:00
libraries : CollectionProperty(type=AssetLibrary)
bundle_directory : StringProperty(
name="Path",
subtype='DIR_PATH',
default='',
2024-07-04 11:53:58 +02:00
update=lambda s, c: update_library_path()
2024-05-27 17:22:45 +02:00
)
def draw(self, context):
prefs = get_addon_prefs()
layout = self.layout
col = layout.column(align=False)
2024-07-04 11:53:58 +02:00
col.prop(self, "config_path", text='Config')
2024-05-27 17:22:45 +02:00
col.prop(self, "bundle_directory", text='Bundle Directory')
col.separator()
row = col.row()
row.label(text='Libraries:')
#row.alignment = 'RIGHT'
row.separator_spacer()
row.operator("assetlibrary.reload_addon", icon='FILE_REFRESH', text='')
row.operator("assetlibrary.add_library", icon="ADD", text='', emboss=False)
for lib in self.libraries:# list(self.env_libraries) + list(self.user_libraries):
lib.draw(col)
classes = (
AssetLibraryPrefs,
)
def register():
for cls in classes:
bpy.utils.register_class(cls)
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)