-
Notifications
You must be signed in to change notification settings - Fork 5
/
__init__.py
executable file
·120 lines (99 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
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
bl_info = {
"name": "KotORBlender",
"author": "Attila Gyoerkoes & J.W. Brandon",
"version": (1, 0, 2),
"blender": (2, 71, 0),
"location": "File > Import-Export, Object Properties",
"description": "Import, export and edit Odyssey (KotOR) ASCII MDL format",
'warning': "cannot be used with Neverblender enabled",
"wiki_url": ""
"",
"tracker_url": "",
"category": "Import-Export"}
if 'bpy' in locals():
import importlib
importlib.reload(nvb.nvb_def)
importlib.reload(nvb.nvb_utils)
importlib.reload(nvb.nvb_io)
importlib.reload(nvb.nvb_mdl)
importlib.reload(nvb.nvb_node)
importlib.reload(nvb.nvb_anim)
importlib.reload(nvb.nvb_animnode)
importlib.reload(nvb.nvb_props)
importlib.reload(nvb.nvb_ops)
importlib.reload(nvb.nvb_ops_anim)
importlib.reload(nvb.nvb_ui)
else:
from kotorblender.nvb import nvb_def
from kotorblender.nvb import nvb_utils
from kotorblender.nvb import nvb_io
from kotorblender.nvb import nvb_mdl
from kotorblender.nvb import nvb_node
from kotorblender.nvb import nvb_anim
from kotorblender.nvb import nvb_animnode
from kotorblender.nvb import nvb_props
from kotorblender.nvb import nvb_ops
from kotorblender.nvb import nvb_ops_anim
from kotorblender.nvb import nvb_ui
import bpy
import addon_utils
#import bpy_extras
def menu_func_export(self, context):
self.layout.operator(nvb_ops.NVB_OP_Export.bl_idname, text="Odyssey (KotOR) (.mdl)")
def menu_func_import(self, context):
self.layout.operator(nvb_ops.NVB_OP_Import.bl_idname, text="Odyssey (KotOR) (.mdl)")
def register():
(load_dflt, nvb_loaded) = addon_utils.check('neverblender')
if nvb_loaded:
raise Exception('Do not enable both KotORBlender and Neverblender at the same time!')
bpy.utils.register_module(__name__)
bpy.types.Object.nvb = bpy.props.PointerProperty(type=nvb_props.KB_PG_OBJECT)
bpy.types.ImageTexture.nvb = bpy.props.PointerProperty(type=nvb_props.KB_PG_TEXTURE)
bpy.types.INFO_MT_file_import.append(menu_func_import)
bpy.types.INFO_MT_file_export.append(menu_func_export)
def unregister():
bpy.types.INFO_MT_file_export.remove(menu_func_export)
bpy.types.INFO_MT_file_import.remove(menu_func_import)
# gracefully co-exist with neverblender, within reason.
# if neverblender is enabled and disabled while kotorblender
# is enabled, kotorblender will be left in an error state
# and must be re-enabled to resume normal functionality
try:
(load_dflt, nvb_loaded) = addon_utils.check('neverblender')
if nvb_loaded:
# this will cleanly reload neverblender so that nvb
# will function after kotorblender has been disabled
# NOTE: the user was warned not to do this, but help anyway
import neverblender
neverblender.unregister()
# these are the attributes we share with nvb,
# we could rename, but it would change a great deal of code,
# it is better to keep the code similar enough to contribute
if 'nvb' in dir(bpy.types.Object):
del bpy.types.Object.nvb
if 'nvb' in dir(bpy.types.ImageTexture):
del bpy.types.ImageTexture.nvb
neverblender.register()
except:
del bpy.types.Object.nvb
del bpy.types.ImageTexture.nvb
bpy.utils.unregister_module(__name__)
if __name__ == "__main__":
register()