41 lines
1.6 KiB
Python
41 lines
1.6 KiB
Python
from .. import __package__ as base_package
|
|
|
|
def draw_addon_separator(layout):
|
|
layout.separator()
|
|
layout.label(text="Custom Templates")
|
|
layout.separator()
|
|
|
|
def draw_file_new_templates(self, context):
|
|
layout = self.layout
|
|
|
|
prefs = context.preferences.addons[base_package].preferences
|
|
if len(prefs.projects) > 0:
|
|
draw_addon_separator(layout)
|
|
draw_templates_on_col(layout, context)
|
|
|
|
def draw_templates_on_col(layout, context, splash_mode = False):
|
|
layout.operator_context = 'INVOKE_DEFAULT'
|
|
|
|
prefs = context.preferences.addons[base_package].preferences
|
|
for i in range(min(5, len(prefs.projects)) if splash_mode else len(prefs.projects)):
|
|
project = prefs.projects[i]
|
|
layout.operator(
|
|
"wm.read_homefile", text=project.name, icon="FILE_NEW" if splash_mode else "NONE").filepath = project.path
|
|
|
|
def draw_file_default_operators(self, context):
|
|
layout = self.layout
|
|
draw_addon_separator(layout)
|
|
# Manage Template
|
|
layout.operator("custom_templates.open_preferences",
|
|
text="Manage templates")
|
|
# Import/Export
|
|
layout.menu("custom_templates.export_menu", text="Import/Export")
|
|
layout.separator()
|
|
# Select new custom template
|
|
layout.operator("custom_templates.select_template_popup",
|
|
text="Select new custom template")
|
|
# Use current as new template (only with an active saved .blend file opened)
|
|
if bpy.data.filepath != "":
|
|
layout.operator("custom_templates.add_template_popup",
|
|
text="Use current as new template")
|
|
|