22 "name" : "Arma 3 Object Builder" ,
33 "description" : "Collection of tools for editing Arma 3 content" ,
44 "author" : "MrClock (present add-on), Hans-Joerg \" Alwarren\" Frieden (original ArmaToolbox add-on)" ,
5- "version" : (2 , 4 , 0 ),
5+ "version" : (2 , 4 , 1 ),
66 "blender" : (2 , 90 , 0 ),
77 "location" : "Object Builder panels" ,
8- "warning" : "" ,
8+ "warning" : "Development " ,
99 "doc_url" : "https://mrcmodding.gitbook.io/arma-3-object-builder/home" ,
1010 "tracker_url" : "https://github.com/MrClock8163/Arma3ObjectBuilder/issues" ,
1111 "category" : "Import-Export"
1212}
1313
1414
15+ import os
16+
1517if "bpy" in locals ():
16- import importlib
18+ from importlib import reload
1719
18- importlib . reload ( props )
19- importlib . reload (ui )
20- importlib . reload ( flagutils )
21-
22- else :
23- from . import props
24- from . import ui
25- from . utilities import flags as flagutils
20+ if "utilities" in locals ():
21+ reload (utilities )
22+ if "io" in locals ():
23+ reload ( io )
24+ if "props" in locals () :
25+ reload ( props )
26+ if "ui" in locals ():
27+ reload ( ui )
2628
2729import bpy
2830
2931
32+ addon_prefs = None
33+ addon_dir = os .path .abspath (os .path .dirname (os .path .realpath (__file__ )))
34+ addon_icons = {}
35+
36+ def get_icon (name ):
37+ icon = 0
38+ try :
39+ icon = addon_icons [addon_prefs .icon_theme .lower ()][name ].icon_id
40+ except Exception :
41+ pass
42+
43+ return icon
44+
45+ def get_prefs ():
46+ return addon_prefs
47+
48+
49+ from . import utilities
50+ from . import io
51+ from . import props
52+ from . import ui
53+
54+
3055def outliner_enable_update (self , context ):
3156 if self .outliner == 'ENABLED' and ui .tool_outliner .depsgraph_update_post_handler not in bpy .app .handlers .depsgraph_update_post :
3257 bpy .app .handlers .depsgraph_update_post .append (ui .tool_outliner .depsgraph_update_post_handler )
@@ -52,8 +77,7 @@ def execute(self, context):
5277 from winreg import OpenKey , QueryValueEx , HKEY_CURRENT_USER
5378 key = OpenKey (HKEY_CURRENT_USER , r"software\bohemia interactive\arma 3 tools" )
5479 value , _type = QueryValueEx (key , "path" )
55- prefs = context .preferences .addons [__package__ ].preferences
56- prefs .a3_tools = value
80+ addon_prefs .a3_tools = value
5781
5882 except Exception :
5983 self .report ({'ERROR' }, "The Arma 3 Tools installation could not be found, it has to be set manually" )
@@ -124,13 +148,13 @@ def poll(cls, context):
124148
125149 def invoke (self , context , event ):
126150 prefs = context .preferences .addons [__package__ ].preferences
127- flagutils .set_flag_vertex (self , prefs .flag_vertex )
151+ utilities . flags .set_flag_vertex (self , prefs .flag_vertex )
128152
129153 return context .window_manager .invoke_props_dialog (self )
130154
131155 def execute (self , context ):
132156 prefs = context .preferences .addons [__package__ ].preferences
133- prefs .flag_vertex = flagutils .get_flag_vertex (self )
157+ prefs .flag_vertex = utilities . flags .get_flag_vertex (self )
134158
135159 return {'FINISHED' }
136160
@@ -176,13 +200,13 @@ def poll(cls, context):
176200
177201 def invoke (self , context , event ):
178202 prefs = context .preferences .addons [__package__ ].preferences
179- flagutils .set_flag_face (self , prefs .flag_face )
203+ utilities . flags .set_flag_face (self , prefs .flag_face )
180204
181205 return context .window_manager .invoke_props_dialog (self )
182206
183207 def execute (self , context ):
184208 prefs = context .preferences .addons [__package__ ].preferences
185- prefs .flag_face = flagutils .get_flag_face (self )
209+ prefs .flag_face = utilities . flags .get_flag_face (self )
186210
187211 return {'FINISHED' }
188212
@@ -345,30 +369,54 @@ def draw(self, context):
345369)
346370
347371
372+ def register_icons ():
373+ import bpy .utils .previews
374+
375+ themes_dir = os .path .join (addon_dir , "icons" )
376+ for theme in os .listdir (themes_dir ):
377+ theme_icons = bpy .utils .previews .new ()
378+
379+ icons_dir = os .path .join (themes_dir , theme )
380+ for filename in os .listdir (icons_dir ):
381+ theme_icons .load (os .path .splitext (os .path .basename (filename ))[0 ].lower (), os .path .join (icons_dir , filename ), 'IMAGE' )
382+
383+ addon_icons [theme .lower ()] = theme_icons
384+
385+
386+ def unregister_icons ():
387+ import bpy .utils .previews
388+
389+ for icon in addon_icons .values ():
390+ bpy .utils .previews .remove (icon )
391+
392+ addon_icons .clear ()
393+
394+
348395def register ():
349396 from bpy .utils import register_class
350- from .utilities import generic
351-
397+
352398 print ("Registering Arma 3 Object Builder ( '" + __package__ + "' )" )
353399
354400 for cls in classes :
355401 register_class (cls )
356402
403+ global addon_prefs
404+ addon_prefs = bpy .context .preferences .addons [__package__ ].preferences
405+
357406 for mod in modules :
358407 mod .register ()
359408
360- generic . register_icons ()
361-
409+ register_icons ()
410+
362411 print ("Register done" )
363412
364413
365414def unregister ():
366415 from bpy .utils import unregister_class
367- from .utilities import generic
368416
369417 print ("Unregistering Arma 3 Object Builder ( '" + __package__ + "' )" )
370418
371- generic . unregister_icons ()
419+ unregister_icons ()
372420
373421 for mod in reversed (modules ):
374422 mod .unregister ()
0 commit comments