Update preferences to add override_splash prop

This commit is contained in:
Francesco Bellini 2024-08-18 16:57:06 +02:00
parent d3ed9be3b9
commit d6fa3dd76b

View File

@ -2,7 +2,7 @@ from .. import __package__ as base_package
import bpy
import json
from bpy.types import Operator, PropertyGroup, AddonPreferences
from bpy.props import StringProperty, CollectionProperty, IntProperty
from bpy.props import StringProperty, CollectionProperty, IntProperty, BoolProperty
# Preferences
class TemplateItem(PropertyGroup):
@ -13,18 +13,15 @@ class TemplateItem(PropertyGroup):
class CustomTemplatesPreferences(AddonPreferences):
bl_idname = base_package
override_splash: BoolProperty(default=True, name="Override Splash Screen's 'New File' list", description="Override splashscreen's 'New File' list")
projects: CollectionProperty(type=TemplateItem)
active_template_index: IntProperty(
description="Index of the selected template")
def draw(self, context):
layout = self.layout
layout.label(
text="Here you can setup your own .blend files that will be shown in the `File > New` menu.")
layout.label(
text="You can also use `File > Defaults > Select new custom template` and `File > Defaults > Use current as new template` to update this preferences.")
layout.label(text="Your custom templates:")
row = layout.row()
row.template_list("UI_UL_list", "custom_templates",
@ -43,7 +40,24 @@ class CustomTemplatesPreferences(AddonPreferences):
project = self.projects[self.active_template_index]
layout.prop(project, "name")
layout.prop(project, "path")
layout.prop(self, "override_splash")
box = layout.box()
if self.override_splash and len(self.projects) == 0:
box.label(text="There are currently no templates.")
box.label(text="The default Blender list will be shown in the Splash Screen.")
else:
box.label(text="The list 'New File' in the Splash Screen will be replaced with your templates.")
layout.separator()
layout.label(text="Note:")
box = layout.box()
box.label(text="This add-on override the entire Splash Screen (section under the image).")
box.label(text="Disabling this extension, will leave only the image.")
box.label(text="Use `Blender > System > Reload Scripts` or restart Blender to restore it.")
box.label(text="This is only needed after disabling this add-on.")
class CUSTOM_MT_Export_Menu(bpy.types.Menu):
bl_idname = "custom_templates.export_menu"
bl_label = "Import/Export custom templates"