-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
151 lines (115 loc) · 4.43 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
import bpy
import bpy.utils.previews
from bpy.props import (
StringProperty,
BoolProperty,
IntProperty,
FloatProperty,
FloatVectorProperty,
EnumProperty,
PointerProperty,
)
from . import modifiers
from . import operators
from . import settings
from .settings import mode_bundle_types, mode_pivot_types
from . import addon_updater_ops
bl_info = {
"name": "Bundle Exporter",
"description": "Export objects in bundles",
"author": "AquaticNightmare",
"blender": (2, 82, 0),
"version": (2, 3, 5),
"category": "3D View",
"location": "3D View > Tools Panel > Bundle Exporter",
"warning": "",
"wiki_url": "https://gitlab.com/AquaticNightmare/bundle_exporter",
"doc_url": "https://gitlab.com/AquaticNightmare/bundle_exporter",
"tracker_url": "https://gitlab.com/AquaticNightmare/bundle_exporter/-/issues",
}
preset_enum_items = []
# https://blender.stackexchange.com/questions/118118/blender-2-8-field-property-declaration-and-dynamic-class-creation
def export_presets_getter(self, context):
global preset_enum_items
preset_enum_items = settings.get_presets_enum(bpy.context.preferences.addons[__name__.split('.')[0]].preferences.export_format)
return preset_enum_items
class BGE_preferences(bpy.types.AddonPreferences):
bl_idname = __name__
mode_bundle: bpy.props.EnumProperty(items=mode_bundle_types, name="Bundle Mode", default='COLLECTION')
mode_pivot: bpy.props.EnumProperty(items=mode_pivot_types, name="Pivot From", default='OBJECT_FIRST')
export_format: bpy.props.EnumProperty(items=settings.export_formats)
def default_export_preset_changed(self, value):
self.internal_export_preset = preset_enum_items[value][0]
def get_export_preset(self):
try:
return next(i for i, x in enumerate(preset_enum_items) if x[0] == self.internal_export_preset)
except StopIteration:
return 0
internal_export_preset: bpy.props.StringProperty(default='BGE_unreal')
export_preset: bpy.props.EnumProperty(items=export_presets_getter, get=get_export_preset, set=default_export_preset_changed)
# 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=True,
)
updater_intrval_months: bpy.props.IntProperty(
name='Months',
description="Number of months between checking for updates",
default=0,
min=0
)
updater_intrval_days: bpy.props.IntProperty(
name='Days',
description="Number of days between checking for updates",
default=7,
min=0,
max=31
)
updater_intrval_hours: bpy.props.IntProperty(
name='Hours',
description="Number of hours between checking for updates",
default=0,
min=0,
max=23
)
updater_intrval_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
addon_updater_ops.update_settings_ui(self, context)
box = layout.box()
row = box.row(align=True)
row.label(text='Default Settings (manually save preferences after changing values please)', icon='PREFERENCES')
col = box.column(align=True)
col.prop(self, 'export_format', text="Export Format")
col.prop(self, 'export_preset', text="Export Preset")
col.prop(self, "mode_bundle", text="Bundle by")
col.prop(self, "mode_pivot", text="Bundle by", icon='OUTLINER_DATA_EMPTY')
col.operator('bge.save_preferences', text='Save User Preferences', icon='FILE_TICK')
def register():
print('--> REGISTER INIT')
from bpy.utils import register_class
addon_updater_ops.register(bl_info)
register_class(BGE_preferences)
modifiers.register()
operators.register()
# we need to load core after the addon preferences have been registered, because classes in this module reference them
from . import core
import imp
imp.reload(core)
core.register()
def unregister():
print('### UNREGISTER INIT')
from bpy.utils import unregister_class
from . import core
core.unregister()
modifiers.unregister()
operators.unregister()
unregister_class(BGE_preferences)
addon_updater_ops.unregister()