This commit is contained in:
2025-10-13 11:34:22 +02:00
parent 2519b55f08
commit 065ab855c1
15 changed files with 427 additions and 47 deletions

View File

@@ -498,78 +498,104 @@ def draw_presets_section(layout, props):
draw_feature_lock_indicator(layout, 'presets')
return
# Save preset section - use safe operator calls
save_row = layout.row(align=True)
col = layout.column(align=True)
# Save preset controls
save_row = col.row(align=True)
save_row.prop(props, "new_preset_name", text="", placeholder="Preset Name")
premium_lock = create_premium_lock_function()
safe_operator_call(save_row, "text_texture.save_preset", premium_lock,
text="Save", icon='FILE_NEW')
# Save with blend file checkbox
layout.prop(props, "save_with_blend_file", text="Project-specific (only available in this .blend file)")
save_location_row = col.row(align=True)
save_location_row.prop(props, "save_with_blend_file", text="Project-specific (saved inside this .blend)")
layout.separator()
# Import/Export and refresh buttons - use safe operator calls
backup_row = layout.row(align=True)
col.separator()
# Import/export/refresh controls
backup_row = col.row(align=True)
export_lock = create_premium_lock_function()
import_lock = create_premium_lock_function()
safe_operator_call(backup_row, "text_texture.export_presets", export_lock,
text="Export Backup", icon='EXPORT')
safe_operator_call(backup_row, "text_texture.import_presets", import_lock,
text="Import Backup", icon='IMPORT')
utility_row = layout.row(align=True)
utility_row = col.row(align=True)
refresh_lock = create_premium_lock_function()
safe_operator_call(utility_row, "text_texture.refresh_presets", refresh_lock,
text="Refresh", icon='FILE_REFRESH')
text="Refresh List", icon='FILE_REFRESH')
layout.separator()
col.separator()
# Load presets section - unified list
if props.presets:
total_presets = len(props.presets)
if total_presets:
pass
layout.label(text="Presets", icon='PRESET')
blend_count = len([preset for preset in props.presets if preset.source == 'BLEND_FILE'])
persistent_count = total_presets - blend_count
# Sort presets alphabetically for consistent display
summary_row = col.row(align=True)
summary_row.label(text=f"{total_presets} presets", icon='PRESET_HLT')
summary_row.label(text=f"{blend_count} project", icon='FILE_BLEND')
summary_row.label(text=f"{persistent_count} global", icon='FILE_CACHE')
search_row = col.row(align=True)
search_row.prop(props, "preset_search_query", text="", icon='VIEWZOOM')
if getattr(props, "preset_search_query", "").strip():
search_row.operator("text_texture.clear_preset_search", text="", icon='PANEL_CLOSE')
# Prepare sorted and filtered presets for display
search_query = getattr(props, "preset_search_query", "").strip().lower()
sorted_presets = sorted(props.presets, key=lambda p: p.name.lower())
if search_query:
visible_presets = [preset for preset in sorted_presets if search_query in preset.name.lower()]
else:
visible_presets = sorted_presets
for preset in sorted_presets:
if visible_presets:
pass
row = layout.row(align=True)
row.scale_y = 0.9
# Load button - use safe operator call
load_lock = create_premium_lock_function()
load_btn = safe_operator_call(row, "text_texture.load_preset", load_lock,
text=preset.name)
if load_btn:
load_btn.preset_name = preset.name
# Quick overwrite button - use safe operator call
overwrite_lock = create_premium_lock_function()
overwrite_btn = safe_operator_call(row, "text_texture.save_preset", overwrite_lock,
text="", icon='FILE_REFRESH')
if overwrite_btn:
overwrite_btn.overwrite = True
overwrite_btn.preset_name = preset.name
# Delete button - use safe operator call
delete_lock = create_premium_lock_function()
delete_btn = safe_operator_call(row, "text_texture.delete_preset", delete_lock,
text="", icon='TRASH')
if delete_btn:
delete_btn.preset_name = preset.name
for preset in visible_presets:
pass
row = col.row(align=True)
row.scale_y = 0.95
is_active = getattr(props, "last_loaded_preset", "") == preset.name
load_icon = 'CHECKMARK' if is_active else 'PRESET'
load_lock = create_premium_lock_function()
load_btn = safe_operator_call(row, "text_texture.load_preset", load_lock,
text=preset.name, icon=load_icon)
if load_btn:
load_btn.preset_name = preset.name
source_icon = 'FILE_BLEND' if preset.source == 'BLEND_FILE' else 'FILE_CACHE'
source_label = "Project" if preset.source == 'BLEND_FILE' else "Global"
row.label(text=source_label, icon=source_icon)
actions = row.row(align=True)
actions.alignment = 'RIGHT'
overwrite_lock = create_premium_lock_function()
overwrite_btn = safe_operator_call(actions, "text_texture.save_preset", overwrite_lock,
text="", icon='FILE_REFRESH')
if overwrite_btn:
overwrite_btn.overwrite = True
overwrite_btn.preset_name = preset.name
delete_lock = create_premium_lock_function()
delete_btn = safe_operator_call(actions, "text_texture.delete_preset", delete_lock,
text="", icon='TRASH')
if delete_btn:
delete_btn.preset_name = preset.name
else:
pass
col.label(text="No presets match your search", icon='INFO')
else:
pass
layout.label(text="No presets yet")
layout.label(text="Save your settings above to create your first preset.")
col.label(text="No presets yet", icon='INFO')
col.label(text="Save your current settings to start your preset library.")
def draw_shader_section(layout, props):
pass