3131from .BattleMapBlenderImporter import BattleMapBlenderImporter
3232from .LightmapData import LightmapData
3333
34+ from os .path import isdir
3435from time import time
3536
3637'''
3940class Preferences (AddonPreferences ):
4041 bl_idname = __package__
4142
42- propLibrarySourcePath : StringProperty (name = "Prop library source path" , subtype = 'FILE_PATH ' )
43+ propLibrarySourcePath : StringProperty (name = "Prop library source path" , subtype = 'DIR_PATH ' )
4344
4445 def draw (self , context ):
4546 layout = self .layout
@@ -74,7 +75,7 @@ def execute(self, context):
7475
7576 objects = []
7677 for file in self .files :
77- filepath = self .directory + file .name
78+ filepath = f" { self .directory } / { file .name } "
7879 # Read the file
7980 print (f"Reading A3D data from { filepath } " )
8081 modelData = A3D ()
@@ -122,7 +123,6 @@ def invoke(self, context, event):
122123
123124 def execute (self , context ):
124125 print (f"Reading BattleMap data from { self .filepath } " )
125-
126126 importStartTime = time ()
127127
128128 # lightmapdata files only exist for remaster maps
@@ -134,12 +134,15 @@ def execute(self, context):
134134 print ("Couldn't open lightmapdata file, ignoring" )
135135 self .import_lightmapdata = False
136136
137+ # read map data
137138 mapData = BattleMap ()
138139 with open (self .filepath , "rb" ) as file :
139140 mapData .read (file )
140141
141142 # Import data into blender
142- preferences = context .preferences .addons [__package__ ].preferences # TODO: check if this is set before proceeding
143+ preferences = context .preferences .addons [__package__ ].preferences
144+ if not isdir (preferences .propLibrarySourcePath ):
145+ raise RuntimeError ("Please set a valid prop library folder in addon properties!" )
143146 mapImporter = BattleMapBlenderImporter (mapData , lightmapData , preferences .propLibrarySourcePath , self .map_scale_factor , self .import_static_geom , self .import_collision_geom , self .import_spawn_points , self .import_lightmapdata )
144147 objects = mapImporter .importData ()
145148
0 commit comments