-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
addon_prefs.py
98 lines (73 loc) · 2.88 KB
/
addon_prefs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import bpy
import os
addon_name = os.path.basename(os.path.dirname(__file__))
# addon preferences
class ANTEMPLATESAddonPrefs(bpy.types.AddonPreferences):
bl_idname = addon_name
custom_library : bpy.props.BoolProperty(
name = "Custom Library",
description = "Use Custom Library instead of Animation Nodes Templates Library",
)
manifest_url : bpy.props.StringProperty(
name = "Github Manifest URL",
default = "",
)
download_folder : bpy.props.StringProperty(
name = "Download Folder",
default = os.path.join(bpy.utils.user_resource('DATAFILES'), "an_templates"),
subtype = "DIR_PATH",
)
template_folder : bpy.props.StringProperty(
name="Output Manifest",
subtype="DIR_PATH"
)
output_manifest_file : bpy.props.StringProperty(
name="Output Manifest",
subtype="FILE_PATH"
)
output_newsfeed_file : bpy.props.StringProperty(
name="Output Newsfeed",
subtype="FILE_PATH"
)
display_developper_tools : bpy.props.BoolProperty(name = "Display Developper Tools")
def draw(self, context):
winman = context.window_manager
properties_coll = winman.an_templates_properties
layout = self.layout
layout.prop(self, "custom_library")
row = layout.row()
if not self.custom_library:
row.enabled=False
row.prop(self, "manifest_url")
layout.prop(self, "download_folder")
# DEV TOOLS
bigbox = layout.box()
if self.display_developper_tools:
icon = "DISCLOSURE_TRI_DOWN"
else:
icon = "DISCLOSURE_TRI_RIGHT"
row = bigbox.row(align=True)
row.prop(self, "display_developper_tools", text="", icon=icon, emboss=False)
row.label(text="Developpers", icon="FILE_SCRIPT")
if self.display_developper_tools:
box = bigbox.box()
col = box.column(align=True)
col.label(text="Manifest")
col.prop(self, "template_folder", text="Templates")
col.prop(self, "output_manifest_file", text="Manifest")
col.operator("antemplates.create_manifest")
box = bigbox.box()
col = box.column(align=True)
col.label(text="Nodetree Infos")
col.prop(properties_coll, "output_nodetree_info_file", text="")
col.operator("antemplates.create_nodetree_info")
col.operator("antemplates.edit_nodetree_info")
box = bigbox.box()
col = box.column(align=True)
col.label(text="Newsfeed")
col.prop(self, "output_newsfeed_file", text="")
col.operator("antemplates.create_newsfeed")
# get addon preferences
def get_addon_preferences():
addon = bpy.context.preferences.addons.get(addon_name)
return getattr(addon, "preferences", None)