40 lines
1.6 KiB
Python
40 lines
1.6 KiB
Python
from .. import __name__ as base_package
|
|
from .ots import name_from_path
|
|
import bpy
|
|
|
|
def draw_file_new_templates(self, context):
|
|
layout = self.layout
|
|
|
|
prefs = context.preferences.addons[base_package].preferences
|
|
if len(prefs.projects) > 0:
|
|
layout.separator()
|
|
draw_templates(layout, context)
|
|
|
|
def draw_templates(layout, context, splash_mode=False):
|
|
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]
|
|
if project.path:
|
|
layout.operator(
|
|
"wm.read_homefile", text=(project.name if project.name else name_from_path(project.path)), icon="FILE_NEW" if splash_mode else "NONE").filepath = project.path
|
|
|
|
def draw_file_default_operators(self, context):
|
|
layout = self.layout
|
|
layout.separator()
|
|
layout.operator("ct.open_preferences",
|
|
text="Manage templates")
|
|
layout.operator("ct.add_templates_from_folder",
|
|
text="Add from folder", icon="ADD")
|
|
layout.operator("ct.clear", text="Clear current templates", icon="TRASH")
|
|
layout.separator()
|
|
layout.operator("ct.import_templates",
|
|
text="Import templates", icon="IMPORT")
|
|
layout.operator("ct.export_templates",
|
|
text="Export templates", icon="EXPORT")
|
|
layout.separator()
|
|
layout.operator("ct.select_template_popup",
|
|
text="Select new template")
|
|
if bpy.data.filepath != "":
|
|
layout.operator("ct.add_template_popup",
|
|
text="Use current file as template")
|