-
Notifications
You must be signed in to change notification settings - Fork 1
/
__init__.py
152 lines (112 loc) · 4.23 KB
/
__init__.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
bl_info = {
"name": "OpenMaya",
"description": "Level editing tools for the OpenGoal version of the Jak and Daxter series.",
"author": "himham, tripp, kuitar",
"version": (0, 0, 2),
"blender": (3, 3, 0),
"location": "View3D > N-Toolbar > Level Info",
"warning": "Alpha Build",
"doc_url": "https://github.com/himham-jak/OpenMaya",
"tracker_url": "https://github.com/himham-jak/OpenMaya/issues",
"support": "COMMUNITY",
"category": "Development",
}
import bpy
# Updater ops import, all setup in this file.
from . import addon_updater_ops
modules = [
"level_menu",
"actor_menu",
"add_actor",
"export",
"gizmos",
] # <module_name>.py
##############################################################################
# Imports Order: 3rd Party Imports, Python Built-ins, Custom Modules
##############################################################################
for module in modules: # Import all modules listed in the modules array
try:
exec(f"from . import {module}")
except Exception as e:
print(f"Error importing {module}.py")
print(e)
##############################################################################
# Preferences
##############################################################################
@addon_updater_ops.make_annotations
class DemoPreferences(bpy.types.AddonPreferences):
"""Demo bare-bones preferences"""
bl_idname = __package__
# Addon updater preferences.
auto_check_update = bpy.props.BoolProperty(
name="Auto-check for Update",
description="If enabled, auto-check for updates using an interval",
default=False,
)
updater_interval_months = bpy.props.IntProperty(
name="Months",
description="Number of months between checking for updates",
default=0,
min=0,
)
updater_interval_days = bpy.props.IntProperty(
name="Days",
description="Number of days between checking for updates",
default=7,
min=0,
max=31,
)
updater_interval_hours = bpy.props.IntProperty(
name="Hours",
description="Number of hours between checking for updates",
default=0,
min=0,
max=23,
)
updater_interval_minutes = bpy.props.IntProperty(
name="Minutes",
description="Number of minutes between checking for updates",
default=0,
min=0,
max=59,
)
def draw(self, context):
layout = self.layout
# Works best if a column, or even just self.layout.
mainrow = layout.row()
col = mainrow.column()
# Updater draw function, could also pass in col as third arg.
addon_updater_ops.update_settings_ui(self, context)
# Alternate draw function, which is more condensed and can be
# placed within an existing draw function. Only contains:
# 1) check for update/update now buttons
# 2) toggle for auto-check (interval will be equal to what is set above)
# addon_updater_ops.update_settings_ui_condensed(self, context, col)
# Adding another column to help show the above condensed ui as one column
# col = mainrow.column()
# col.scale_y = 2
# ops = col.operator("wm.url_open","Open webpage ")
# ops.url=addon_updater_ops.updater.website
##############################################################################
# Registration
##############################################################################
def register():
addon_updater_ops.register(bl_info)
bpy.utils.register_class(DemoPreferences)
for module in modules: # Register all the modules
try:
exec(f"{module}.register()")
except Exception as e:
print(f"Error registering {module}.py")
print(e)
def unregister():
for module in reversed(modules): # Unregister all the modules
try:
exec(f"{module}.unregister()")
except Exception as e:
print(f"Error unregistering {module}.py")
print(e)
bpy.utils.unregister_class(DemoPreferences)
addon_updater_ops.unregister()
# if __name__ == "__main__": # For internal Blender script testing
# register()