UI for paths fixed
This commit is contained in:
File diff suppressed because it is too large
Load Diff
12
__init__.py
12
__init__.py
@@ -31,13 +31,25 @@ from bpy.types import Panel, Operator, PropertyGroup
|
|||||||
from . import operators
|
from . import operators
|
||||||
from . import ui
|
from . import ui
|
||||||
|
|
||||||
|
def ensure_default_search_path():
|
||||||
|
"""Ensure there's always at least one search path"""
|
||||||
|
prefs = bpy.context.preferences.addons.get(__name__)
|
||||||
|
if prefs and len(prefs.preferences.search_paths) == 0:
|
||||||
|
new_path = prefs.preferences.search_paths.add()
|
||||||
|
new_path.path = "//" # Default to relative path
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
operators.register()
|
operators.register()
|
||||||
ui.register()
|
ui.register()
|
||||||
|
# Ensure default search path exists
|
||||||
|
bpy.app.handlers.load_post.append(ensure_default_search_path)
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
ui.unregister()
|
ui.unregister()
|
||||||
operators.unregister()
|
operators.unregister()
|
||||||
|
# Remove the handler
|
||||||
|
if ensure_default_search_path in bpy.app.handlers.load_post:
|
||||||
|
bpy.app.handlers.load_post.remove(ensure_default_search_path)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
register()
|
register()
|
||||||
|
|||||||
159
operators.py
159
operators.py
@@ -3,9 +3,9 @@ import os
|
|||||||
from bpy.types import Operator
|
from bpy.types import Operator
|
||||||
from bpy.props import StringProperty, BoolProperty, EnumProperty, IntProperty
|
from bpy.props import StringProperty, BoolProperty, EnumProperty, IntProperty
|
||||||
|
|
||||||
class DYNAMICLINK_OT_replace_linked_asset(Operator):
|
class DLM_OT_replace_linked_asset(Operator):
|
||||||
"""Replace a linked asset with a new file"""
|
"""Replace a linked asset with a new file"""
|
||||||
bl_idname = "dynamiclink.replace_linked_asset"
|
bl_idname = "dlm.replace_linked_asset"
|
||||||
bl_label = "Replace Linked Asset"
|
bl_label = "Replace Linked Asset"
|
||||||
bl_options = {'REGISTER', 'UNDO'}
|
bl_options = {'REGISTER', 'UNDO'}
|
||||||
|
|
||||||
@@ -79,9 +79,9 @@ class DYNAMICLINK_OT_replace_linked_asset(Operator):
|
|||||||
context.window_manager.fileselect_add(self)
|
context.window_manager.fileselect_add(self)
|
||||||
return {'RUNNING_MODAL'}
|
return {'RUNNING_MODAL'}
|
||||||
|
|
||||||
class DYNAMICLINK_OT_scan_linked_assets(Operator):
|
class DLM_OT_scan_linked_assets(Operator):
|
||||||
"""Scan scene for all linked assets"""
|
"""Scan scene for all linked assets"""
|
||||||
bl_idname = "dynamiclink.scan_linked_assets"
|
bl_idname = "dlm.scan_linked_assets"
|
||||||
bl_label = "Scan Linked Assets"
|
bl_label = "Scan Linked Assets"
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
@@ -196,9 +196,9 @@ class DYNAMICLINK_OT_scan_linked_assets(Operator):
|
|||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
class DYNAMICLINK_OT_fmt_style_find(Operator):
|
class DLM_OT_fmt_style_find(Operator):
|
||||||
"""Find missing libraries in search folders using FMT-style approach"""
|
"""Find missing libraries in search folders using FMT-style approach"""
|
||||||
bl_idname = "dynamiclink.fmt_style_find"
|
bl_idname = "dlm.fmt_style_find"
|
||||||
bl_label = "FMT-Style Find"
|
bl_label = "FMT-Style Find"
|
||||||
bl_options = {'REGISTER', 'UNDO'}
|
bl_options = {'REGISTER', 'UNDO'}
|
||||||
|
|
||||||
@@ -243,15 +243,7 @@ class DYNAMICLINK_OT_fmt_style_find(Operator):
|
|||||||
found_count += 1
|
found_count += 1
|
||||||
break
|
break
|
||||||
|
|
||||||
# Extension replacement (FMT-style)
|
|
||||||
elif context.scene.dynamic_link_manager.search_different_extensions:
|
|
||||||
base_name = os.path.splitext(lib_filename)[0]
|
|
||||||
for filename in filenames:
|
|
||||||
if base_name == os.path.splitext(filename)[0]:
|
|
||||||
new_path = os.path.join(dirpath, filename)
|
|
||||||
self.report({'INFO'}, f"Found {lib_filename} (as {filename}) at: {new_path}")
|
|
||||||
found_count += 1
|
|
||||||
break
|
|
||||||
|
|
||||||
# FMT-style reporting
|
# FMT-style reporting
|
||||||
if found_count > 0:
|
if found_count > 0:
|
||||||
@@ -262,12 +254,12 @@ class DYNAMICLINK_OT_fmt_style_find(Operator):
|
|||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
bpy.utils.register_class(DYNAMICLINK_OT_replace_linked_asset)
|
bpy.utils.register_class(DLM_OT_replace_linked_asset)
|
||||||
bpy.utils.register_class(DYNAMICLINK_OT_scan_linked_assets)
|
bpy.utils.register_class(DLM_OT_scan_linked_assets)
|
||||||
|
|
||||||
class DYNAMICLINK_OT_open_linked_file(Operator):
|
class DLM_OT_open_linked_file(Operator):
|
||||||
"""Open the linked file in a new Blender instance"""
|
"""Open the linked file in a new Blender instance"""
|
||||||
bl_idname = "dynamiclink.open_linked_file"
|
bl_idname = "dlm.open_linked_file"
|
||||||
bl_label = "Open Linked File"
|
bl_label = "Open Linked File"
|
||||||
bl_options = {'REGISTER'}
|
bl_options = {'REGISTER'}
|
||||||
|
|
||||||
@@ -293,33 +285,23 @@ class DYNAMICLINK_OT_open_linked_file(Operator):
|
|||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
class DYNAMICLINK_OT_add_search_path(Operator):
|
class DLM_OT_add_search_path(Operator):
|
||||||
"""Add a new search path for missing libraries"""
|
"""Add a new search path for missing libraries"""
|
||||||
bl_idname = "dynamiclink.add_search_path"
|
bl_idname = "dlm.add_search_path"
|
||||||
bl_label = "Add Search Path"
|
bl_label = "Add Search Path"
|
||||||
bl_options = {'REGISTER'}
|
bl_options = {'REGISTER'}
|
||||||
|
|
||||||
filepath: StringProperty(
|
|
||||||
name="Search Path",
|
|
||||||
description="Path to search for missing linked libraries",
|
|
||||||
subtype='DIR_PATH'
|
|
||||||
)
|
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
prefs = context.preferences.addons.get(__package__)
|
prefs = context.preferences.addons.get(__package__)
|
||||||
if prefs:
|
if prefs:
|
||||||
new_path = prefs.preferences.search_paths.add()
|
new_path = prefs.preferences.search_paths.add()
|
||||||
new_path.path = self.filepath if self.filepath else "//"
|
new_path.path = "//" # Default to relative path
|
||||||
self.report({'INFO'}, f"Added search path: {new_path.path}")
|
self.report({'INFO'}, f"Added search path: {new_path.path}")
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
def invoke(self, context, event):
|
class DLM_OT_remove_search_path(Operator):
|
||||||
context.window_manager.fileselect_add(self)
|
|
||||||
return {'RUNNING_MODAL'}
|
|
||||||
|
|
||||||
class DYNAMICLINK_OT_remove_search_path(Operator):
|
|
||||||
"""Remove a search path"""
|
"""Remove a search path"""
|
||||||
bl_idname = "dynamiclink.remove_search_path"
|
bl_idname = "dlm.remove_search_path"
|
||||||
bl_label = "Remove Search Path"
|
bl_label = "Remove Search Path"
|
||||||
bl_options = {'REGISTER'}
|
bl_options = {'REGISTER'}
|
||||||
|
|
||||||
@@ -339,9 +321,9 @@ class DYNAMICLINK_OT_remove_search_path(Operator):
|
|||||||
self.report({'ERROR'}, f"Invalid index: {self.index}")
|
self.report({'ERROR'}, f"Invalid index: {self.index}")
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
class DYNAMICLINK_OT_attempt_relink(Operator):
|
class DLM_OT_attempt_relink(Operator):
|
||||||
"""Attempt to relink missing libraries using search paths"""
|
"""Attempt to relink missing libraries using search paths"""
|
||||||
bl_idname = "dynamiclink.attempt_relink"
|
bl_idname = "dlm.attempt_relink"
|
||||||
bl_label = "Attempt Relink"
|
bl_label = "Attempt Relink"
|
||||||
bl_options = {'REGISTER'}
|
bl_options = {'REGISTER'}
|
||||||
|
|
||||||
@@ -400,25 +382,6 @@ class DYNAMICLINK_OT_attempt_relink(Operator):
|
|||||||
else:
|
else:
|
||||||
print(f"Error relinking {lib_item.filepath}: {e}")
|
print(f"Error relinking {lib_item.filepath}: {e}")
|
||||||
|
|
||||||
# FMT-style extension replacement
|
|
||||||
if not found and context.scene.dynamic_link_manager.search_different_extensions:
|
|
||||||
base_name = os.path.splitext(lib_filename)[0]
|
|
||||||
for filename in filenames:
|
|
||||||
if base_name == os.path.splitext(filename)[0]:
|
|
||||||
new_path = os.path.join(dirpath, filename)
|
|
||||||
try:
|
|
||||||
bpy.ops.file.find_missing_files()
|
|
||||||
found = True
|
|
||||||
relinked_count += 1
|
|
||||||
break
|
|
||||||
except Exception as e:
|
|
||||||
error_msg = str(e)
|
|
||||||
if "unable to relocate indirectly linked library" in error_msg:
|
|
||||||
indirect_errors.append(lib_item.filepath)
|
|
||||||
print(f"Indirect link detected for: {lib_item.filepath}")
|
|
||||||
else:
|
|
||||||
print(f"Error relinking {lib_item.filepath}: {e}")
|
|
||||||
|
|
||||||
if found:
|
if found:
|
||||||
break
|
break
|
||||||
|
|
||||||
@@ -437,9 +400,9 @@ class DYNAMICLINK_OT_attempt_relink(Operator):
|
|||||||
self.report({'INFO'}, f"Relink attempt complete. Relinked: {relinked_count}, Indirect: {len(indirect_errors)}")
|
self.report({'INFO'}, f"Relink attempt complete. Relinked: {relinked_count}, Indirect: {len(indirect_errors)}")
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
class DYNAMICLINK_OT_find_in_folders(Operator):
|
class DLM_OT_find_in_folders(Operator):
|
||||||
"""Find missing libraries in search folders and subfolders"""
|
"""Find missing libraries in search folders and subfolders"""
|
||||||
bl_idname = "dynamiclink.find_in_folders"
|
bl_idname = "dlm.find_in_folders"
|
||||||
bl_label = "Find in Folders"
|
bl_label = "Find in Folders"
|
||||||
bl_options = {'REGISTER', 'UNDO'}
|
bl_options = {'REGISTER', 'UNDO'}
|
||||||
|
|
||||||
@@ -487,16 +450,7 @@ class DYNAMICLINK_OT_find_in_folders(Operator):
|
|||||||
found = True
|
found = True
|
||||||
break
|
break
|
||||||
|
|
||||||
# FMT-style extension replacement
|
|
||||||
if context.scene.dynamic_link_manager.search_different_extensions:
|
|
||||||
base_name = os.path.splitext(lib_filename)[0]
|
|
||||||
for filename in filenames:
|
|
||||||
if base_name == os.path.splitext(filename)[0]:
|
|
||||||
new_path = os.path.join(dirpath, filename)
|
|
||||||
self.report({'INFO'}, f"Found {lib_filename} (as {filename}) at: {new_path}")
|
|
||||||
found_count += 1
|
|
||||||
found = True
|
|
||||||
break
|
|
||||||
|
|
||||||
if found:
|
if found:
|
||||||
break
|
break
|
||||||
@@ -511,22 +465,61 @@ class DYNAMICLINK_OT_find_in_folders(Operator):
|
|||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
class DLM_OT_browse_search_path(Operator):
|
||||||
|
"""Browse for a search path directory"""
|
||||||
|
bl_idname = "dlm.browse_search_path"
|
||||||
|
bl_label = "Browse Search Path"
|
||||||
|
bl_options = {'REGISTER'}
|
||||||
|
|
||||||
|
index: IntProperty(
|
||||||
|
name="Index",
|
||||||
|
description="Index of the search path to browse for",
|
||||||
|
default=0
|
||||||
|
)
|
||||||
|
|
||||||
|
filepath: StringProperty(
|
||||||
|
name="Search Path",
|
||||||
|
description="Path to search for missing linked libraries",
|
||||||
|
subtype='DIR_PATH'
|
||||||
|
)
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
prefs = context.preferences.addons.get(__package__)
|
||||||
|
if prefs and prefs.preferences.search_paths:
|
||||||
|
if 0 <= self.index < len(prefs.preferences.search_paths):
|
||||||
|
prefs.preferences.search_paths[self.index].path = self.filepath
|
||||||
|
self.report({'INFO'}, f"Updated search path {self.index + 1}: {self.filepath}")
|
||||||
|
else:
|
||||||
|
self.report({'ERROR'}, f"Invalid index: {self.index}")
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
def invoke(self, context, event):
|
||||||
|
prefs = context.preferences.addons.get(__package__)
|
||||||
|
if prefs and prefs.preferences.search_paths:
|
||||||
|
if 0 <= self.index < len(prefs.preferences.search_paths):
|
||||||
|
# Set the current path as default
|
||||||
|
self.filepath = prefs.preferences.search_paths[self.index].path
|
||||||
|
context.window_manager.fileselect_add(self)
|
||||||
|
return {'RUNNING_MODAL'}
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
bpy.utils.register_class(DYNAMICLINK_OT_replace_linked_asset)
|
bpy.utils.register_class(DLM_OT_replace_linked_asset)
|
||||||
bpy.utils.register_class(DYNAMICLINK_OT_scan_linked_assets)
|
bpy.utils.register_class(DLM_OT_scan_linked_assets)
|
||||||
bpy.utils.register_class(DYNAMICLINK_OT_open_linked_file)
|
bpy.utils.register_class(DLM_OT_open_linked_file)
|
||||||
bpy.utils.register_class(DYNAMICLINK_OT_add_search_path)
|
bpy.utils.register_class(DLM_OT_add_search_path)
|
||||||
bpy.utils.register_class(DYNAMICLINK_OT_remove_search_path)
|
bpy.utils.register_class(DLM_OT_remove_search_path)
|
||||||
bpy.utils.register_class(DYNAMICLINK_OT_attempt_relink)
|
bpy.utils.register_class(DLM_OT_browse_search_path)
|
||||||
bpy.utils.register_class(DYNAMICLINK_OT_find_in_folders)
|
bpy.utils.register_class(DLM_OT_attempt_relink)
|
||||||
bpy.utils.register_class(DYNAMICLINK_OT_fmt_style_find)
|
bpy.utils.register_class(DLM_OT_find_in_folders)
|
||||||
|
bpy.utils.register_class(DLM_OT_fmt_style_find)
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
bpy.utils.unregister_class(DYNAMICLINK_OT_fmt_style_find)
|
bpy.utils.unregister_class(DLM_OT_fmt_style_find)
|
||||||
bpy.utils.unregister_class(DYNAMICLINK_OT_find_in_folders)
|
bpy.utils.unregister_class(DLM_OT_find_in_folders)
|
||||||
bpy.utils.unregister_class(DYNAMICLINK_OT_attempt_relink)
|
bpy.utils.unregister_class(DLM_OT_attempt_relink)
|
||||||
bpy.utils.unregister_class(DYNAMICLINK_OT_remove_search_path)
|
bpy.utils.unregister_class(DLM_OT_browse_search_path)
|
||||||
bpy.utils.unregister_class(DYNAMICLINK_OT_add_search_path)
|
bpy.utils.unregister_class(DLM_OT_remove_search_path)
|
||||||
bpy.utils.unregister_class(DYNAMICLINK_OT_open_linked_file)
|
bpy.utils.unregister_class(DLM_OT_add_search_path)
|
||||||
bpy.utils.unregister_class(DYNAMICLINK_OT_scan_linked_assets)
|
bpy.utils.unregister_class(DLM_OT_open_linked_file)
|
||||||
bpy.utils.unregister_class(DYNAMICLINK_OT_replace_linked_asset)
|
bpy.utils.unregister_class(DLM_OT_scan_linked_assets)
|
||||||
|
bpy.utils.unregister_class(DLM_OT_replace_linked_asset)
|
||||||
|
|||||||
129
ui.py
129
ui.py
@@ -80,13 +80,6 @@ class DynamicLinkManagerProperties(PropertyGroup):
|
|||||||
default=""
|
default=""
|
||||||
)
|
)
|
||||||
|
|
||||||
# FMT-inspired settings
|
|
||||||
search_different_extensions: BoolProperty(
|
|
||||||
name="Search for libraries with different extensions",
|
|
||||||
description="Look for .blend files with different extensions (e.g., .blend1, .blend2)",
|
|
||||||
default=False
|
|
||||||
)
|
|
||||||
|
|
||||||
# Addon preferences for search paths
|
# Addon preferences for search paths
|
||||||
class DynamicLinkManagerPreferences(AddonPreferences):
|
class DynamicLinkManagerPreferences(AddonPreferences):
|
||||||
bl_idname = __package__
|
bl_idname = __package__
|
||||||
@@ -100,20 +93,23 @@ class DynamicLinkManagerPreferences(AddonPreferences):
|
|||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
|
||||||
# Search paths section
|
# Search paths section (FMT-style)
|
||||||
box = layout.box()
|
box = layout.box()
|
||||||
box.label(text="Search Paths for Missing Libraries")
|
box.label(text="Default Search Paths for Missing Libraries")
|
||||||
|
|
||||||
# Add/remove search paths
|
# Add button - right-justified
|
||||||
row = box.row()
|
row = box.row()
|
||||||
row.operator("dynamiclink.add_search_path", text="Add Search Path", icon='ADD')
|
row.alignment = 'RIGHT'
|
||||||
row.operator("dynamiclink.remove_search_path", text="Remove Selected", icon='REMOVE')
|
row.operator("dlm.add_search_path", text="Add search path", icon='ADD')
|
||||||
|
|
||||||
# List search paths
|
# List search paths (FMT-style)
|
||||||
for i, path_item in enumerate(self.search_paths):
|
for i, path_item in enumerate(self.search_paths):
|
||||||
row = box.row()
|
row = box.row()
|
||||||
row.prop(path_item, "path", text=f"Path {i+1}")
|
row.prop(path_item, "path", text=f"Search path {i+1}")
|
||||||
row.operator("dynamiclink.remove_search_path", text="", icon='X').index = i
|
# Folder icon for browsing (FMT-style)
|
||||||
|
row.operator("dlm.browse_search_path", text="", icon='FILE_FOLDER').index = i
|
||||||
|
# Remove button (FMT-style)
|
||||||
|
row.operator("dlm.remove_search_path", text="", icon='REMOVE').index = i
|
||||||
|
|
||||||
class DYNAMICLINK_PT_main_panel(Panel):
|
class DYNAMICLINK_PT_main_panel(Panel):
|
||||||
bl_space_type = 'VIEW_3D'
|
bl_space_type = 'VIEW_3D'
|
||||||
@@ -129,7 +125,7 @@ class DYNAMICLINK_PT_main_panel(Panel):
|
|||||||
box = layout.box()
|
box = layout.box()
|
||||||
box.label(text="Linked Libraries Analysis")
|
box.label(text="Linked Libraries Analysis")
|
||||||
row = box.row()
|
row = box.row()
|
||||||
row.operator("dynamiclink.scan_linked_assets", text="Scan Linked Assets", icon='FILE_REFRESH')
|
row.operator("dlm.scan_linked_assets", text="Scan Linked Assets", icon='FILE_REFRESH')
|
||||||
row.label(text=f"({props.linked_assets_count} libraries)")
|
row.label(text=f"({props.linked_assets_count} libraries)")
|
||||||
|
|
||||||
# Show more detailed info if we have results
|
# Show more detailed info if we have results
|
||||||
@@ -156,12 +152,12 @@ class DYNAMICLINK_PT_main_panel(Panel):
|
|||||||
row.scale_x = 0.3
|
row.scale_x = 0.3
|
||||||
if props.linked_libraries and 0 <= props.linked_libraries_index < len(props.linked_libraries):
|
if props.linked_libraries and 0 <= props.linked_libraries_index < len(props.linked_libraries):
|
||||||
selected_lib = props.linked_libraries[props.linked_libraries_index]
|
selected_lib = props.linked_libraries[props.linked_libraries_index]
|
||||||
open_op = row.operator("dynamiclink.open_linked_file", text="Open Selected", icon='FILE_BLEND')
|
open_op = row.operator("dlm.open_linked_file", text="Open Selected", icon='FILE_BLEND')
|
||||||
open_op.filepath = selected_lib.filepath
|
open_op.filepath = selected_lib.filepath
|
||||||
else:
|
else:
|
||||||
row.operator("dynamiclink.open_linked_file", text="Open Selected", icon='FILE_BLEND')
|
row.operator("dlm.open_linked_file", text="Open Selected", icon='FILE_BLEND')
|
||||||
row.scale_x = 0.7
|
row.scale_x = 0.7
|
||||||
row.operator("dynamiclink.scan_linked_assets", text="Refresh", icon='FILE_REFRESH')
|
row.operator("dlm.scan_linked_assets", text="Refresh", icon='FILE_REFRESH')
|
||||||
|
|
||||||
# Show details of selected item (FMT-style info display)
|
# Show details of selected item (FMT-style info display)
|
||||||
if props.linked_libraries and 0 <= props.linked_libraries_index < len(props.linked_libraries):
|
if props.linked_libraries and 0 <= props.linked_libraries_index < len(props.linked_libraries):
|
||||||
@@ -178,6 +174,32 @@ class DYNAMICLINK_PT_main_panel(Panel):
|
|||||||
|
|
||||||
info_box.label(text=f"Path: {selected_lib.filepath}", icon='FILE_FOLDER')
|
info_box.label(text=f"Path: {selected_lib.filepath}", icon='FILE_FOLDER')
|
||||||
|
|
||||||
|
# Search Paths Management (FMT-style) - integrated into Linked Libraries Analysis
|
||||||
|
if props.linked_assets_count > 0:
|
||||||
|
# Get preferences for search paths
|
||||||
|
prefs = context.preferences.addons.get(__package__)
|
||||||
|
|
||||||
|
# Search paths list (FMT-style) - Each path gets its own row with folder icon
|
||||||
|
if prefs and prefs.preferences.search_paths:
|
||||||
|
for i, path_item in enumerate(prefs.preferences.search_paths):
|
||||||
|
row = box.row()
|
||||||
|
row.prop(path_item, "path", text=f"Search path {i+1}")
|
||||||
|
# Folder icon for browsing (FMT-style)
|
||||||
|
row.operator("dlm.browse_search_path", text="", icon='FILE_FOLDER').index = i
|
||||||
|
# Remove button (FMT-style)
|
||||||
|
row.operator("dlm.remove_search_path", text="", icon='REMOVE').index = i
|
||||||
|
|
||||||
|
# Add button (FMT-style) - Just the + button, right-justified
|
||||||
|
row = box.row()
|
||||||
|
row.alignment = 'RIGHT'
|
||||||
|
row.operator("dlm.add_search_path", text="", icon='ADD')
|
||||||
|
|
||||||
|
# Main action button (FMT-style)
|
||||||
|
missing_count = sum(1 for lib in props.linked_libraries if lib.is_missing)
|
||||||
|
if missing_count > 0:
|
||||||
|
row = box.row()
|
||||||
|
row.operator("dlm.fmt_style_find", text="Find libraries in these folders", icon='VIEWZOOM')
|
||||||
|
|
||||||
# Asset replacement section (FMT-style)
|
# Asset replacement section (FMT-style)
|
||||||
box = layout.box()
|
box = layout.box()
|
||||||
box.label(text="Asset Replacement")
|
box.label(text="Asset Replacement")
|
||||||
@@ -190,85 +212,22 @@ class DYNAMICLINK_PT_main_panel(Panel):
|
|||||||
if obj.library:
|
if obj.library:
|
||||||
box.label(text=f"Linked from: {obj.library.filepath}")
|
box.label(text=f"Linked from: {obj.library.filepath}")
|
||||||
row = box.row()
|
row = box.row()
|
||||||
row.operator("dynamiclink.replace_linked_asset", text="Replace Asset")
|
row.operator("dlm.replace_linked_asset", text="Replace Asset")
|
||||||
# Check if object's data is linked
|
# Check if object's data is linked
|
||||||
elif obj.data and obj.data.library:
|
elif obj.data and obj.data.library:
|
||||||
box.label(text=f"Data linked from: {obj.data.library.filepath}")
|
box.label(text=f"Data linked from: {obj.data.library.filepath}")
|
||||||
row = box.row()
|
row = box.row()
|
||||||
row.operator("dynamiclink.replace_linked_asset", text="Replace Asset")
|
row.operator("dlm.replace_linked_asset", text="Replace Asset")
|
||||||
# Check if it's a linked armature
|
# Check if it's a linked armature
|
||||||
elif obj.type == 'ARMATURE' and obj.data and hasattr(obj.data, 'library') and obj.data.library:
|
elif obj.type == 'ARMATURE' and obj.data and hasattr(obj.data, 'library') and obj.data.library:
|
||||||
box.label(text=f"Armature linked from: {obj.data.library.filepath}")
|
box.label(text=f"Armature linked from: {obj.data.library.filepath}")
|
||||||
row = box.row()
|
row = box.row()
|
||||||
row.operator("dynamiclink.replace_linked_asset", text="Replace Asset")
|
row.operator("dlm.replace_linked_asset", text="Replace Asset")
|
||||||
else:
|
else:
|
||||||
box.label(text="Not a linked asset")
|
box.label(text="Not a linked asset")
|
||||||
else:
|
else:
|
||||||
box.label(text="No object selected")
|
box.label(text="No object selected")
|
||||||
|
|
||||||
# Search Paths section (FMT-style)
|
|
||||||
box = layout.box()
|
|
||||||
box.label(text="Search Paths for Missing Libraries")
|
|
||||||
|
|
||||||
# Get preferences
|
|
||||||
prefs = context.preferences.addons.get(__package__)
|
|
||||||
if prefs:
|
|
||||||
# Show current search paths with FMT-style management
|
|
||||||
if prefs.preferences.search_paths:
|
|
||||||
for i, path_item in enumerate(prefs.preferences.search_paths):
|
|
||||||
row = box.row()
|
|
||||||
row.prop(path_item, "path", text=f"Search path {i+1}")
|
|
||||||
row.operator("dynamiclink.remove_search_path", text="", icon='X').index = i
|
|
||||||
|
|
||||||
# Add new search path
|
|
||||||
row = box.row()
|
|
||||||
row.operator("dynamiclink.add_search_path", text="Add Search Path", icon='ADD')
|
|
||||||
|
|
||||||
# FMT-inspired settings
|
|
||||||
if len(prefs.preferences.search_paths) > 0:
|
|
||||||
row = box.row()
|
|
||||||
row.prop(props, "search_different_extensions", text="Search for libraries with different extensions")
|
|
||||||
|
|
||||||
# Find and relink buttons (FMT-style button layout)
|
|
||||||
if props.linked_assets_count > 0:
|
|
||||||
missing_count = sum(1 for lib in props.linked_libraries if lib.is_missing)
|
|
||||||
if missing_count > 0:
|
|
||||||
row = box.row()
|
|
||||||
row.operator("dynamiclink.find_in_folders", text="Find libraries in these folders", icon='VIEWZOOM')
|
|
||||||
row = box.row()
|
|
||||||
row.operator("dynamiclink.attempt_relink", text="Attempt to relink found libraries", icon='FILE_REFRESH')
|
|
||||||
|
|
||||||
# FMT-Style Search Paths Management (Direct Copy)
|
|
||||||
box = layout.box()
|
|
||||||
box.label(text="FMT-Style Search Paths")
|
|
||||||
|
|
||||||
# Get preferences
|
|
||||||
prefs = context.preferences.addons.get(__package__)
|
|
||||||
if prefs:
|
|
||||||
# Extension replacement option (FMT-style)
|
|
||||||
if len(prefs.preferences.search_paths) > 0:
|
|
||||||
row = box.row()
|
|
||||||
row.prop(props, "search_different_extensions", text="Search for libraries with different extensions")
|
|
||||||
|
|
||||||
# Search paths list (FMT-style)
|
|
||||||
if prefs.preferences.search_paths:
|
|
||||||
for i, path_item in enumerate(prefs.preferences.search_paths):
|
|
||||||
row = box.row()
|
|
||||||
row.prop(path_item, "path", text=f"Search path {i+1}")
|
|
||||||
row.operator("dynamiclink.remove_search_path", text="", icon='REMOVE').index = i
|
|
||||||
|
|
||||||
# Add/remove buttons (FMT-style)
|
|
||||||
row = box.row()
|
|
||||||
row.operator("dynamiclink.add_search_path", text="Add Search Path", icon='ADD')
|
|
||||||
row.operator("dynamiclink.remove_search_path", text="Remove Selected", icon='REMOVE')
|
|
||||||
|
|
||||||
# Main action button (FMT-style)
|
|
||||||
if props.linked_assets_count > 0:
|
|
||||||
missing_count = sum(1 for lib in props.linked_libraries if lib.is_missing)
|
|
||||||
if missing_count > 0:
|
|
||||||
row = box.row()
|
|
||||||
row.operator("dynamiclink.fmt_style_find", text="Find libraries in these folders", icon='VIEWZOOM')
|
|
||||||
|
|
||||||
# Settings section (FMT-style)
|
# Settings section (FMT-style)
|
||||||
box = layout.box()
|
box = layout.box()
|
||||||
box.label(text="Settings")
|
box.label(text="Settings")
|
||||||
|
|||||||
Reference in New Issue
Block a user