@@ -22,59 +22,30 @@ var file_exists_checker = File.new()
2222
2323func start (mapPath ):
2424 var CODETIME_LOADCFG_START = OS .get_ticks_msec ()
25- clear_stuff ()
26- load_classic_or_kfx_format (mapPath )
27- print ('Loaded all .cfg and .toml files: ' + str (OS .get_ticks_msec () - CODETIME_LOADCFG_START ) + 'ms' )
28- if oConfigFilesListWindow .visible :
29- Utils .popup_centered (oConfigFilesListWindow )
30- oCustomSlabSystem .load_unearth_custom_slabs_file ()
31-
32-
33- func clear_stuff ():
3425 Things .clear_dynamic_lists ()
3526 Things .reset_thing_data_to_default ()
3627 Slabs .reset_slab_data_to_default ()
3728 Slabset .clear_all_slabset_data ()
3829 Columnset .clear_all_column_data ()
3930 Cube .clear_all_cube_data ()
40-
41-
42- func load_classic_or_kfx_format (mapPath ):
43- if oCurrentFormat .selected == Constants .ClassicFormat or oGame .keeperfx_is_installed () == false :
44- load_classic_format ()
45- else :
46- load_kfx_format (mapPath )
47-
48-
49- func load_classic_format ():
50- # Load configuration for classic Dungeon Keeper format
51- # Uses Unearth defaults and scans DATA directory for TMAP files
52- Cube .load_dk_original_cubes ()
53- Slabset .load_default_original_slabset ()
54- Columnset .load_default_original_columnset ()
5531
56- # Populate default spellbooks for Classic format
57- for subtype in [11 ,12 ,13 ,14 ,15 ,16 ,17 ,18 ,19 ,20 ,21 ,22 ,23 ,45 ,46 ,47 ,48 ,134 ,135 ]:
58- Things .LIST_OF_SPELLBOOKS .append (subtype )
32+ if oCurrentFormat .selected == Constants .ClassicFormat or oGame .keeperfx_is_installed () == false :
33+ Cube .load_dk_original_cubes ()
34+ Slabset .load_default_original_slabset ()
35+ Columnset .load_default_original_columnset ()
36+ load_classic_tmap_files ()
37+ Things .LIST_OF_SPELLBOOKS = [11 ,12 ,13 ,14 ,15 ,16 ,17 ,18 ,19 ,20 ,21 ,22 ,23 ,45 ,46 ,47 ,48 ,134 ,135 ]
38+ Things .LIST_OF_HEROGATES = [49 ]
5939
60- # Populate default Hero Gate for Classic format
61- Things .LIST_OF_HEROGATES .append (49 )
40+ load_cfgs (mapPath )
6241
63- # Load TMAP files for classic format
64- load_classic_tmap_files ()
65-
66-
67- func load_classic_tmap_files ():
68- oConfigFileManager .clear_paths ()
69- # Scan DATA directory for TMAP files
70- var data_directory = oGame .DK_DATA_DIRECTORY
71- var tmap_files = Utils .get_filetype_in_directory (data_directory , "dat" )
72- for fullPath in tmap_files :
73- if "tmap" in fullPath .to_lower ():
74- oConfigFileManager .paths_loaded [oConfigFileManager .LOAD_CFG_DATA ].append (fullPath )
42+ print ('Loaded all .cfg and .toml files: ' + str (OS .get_ticks_msec () - CODETIME_LOADCFG_START ) + 'ms' )
43+ if oConfigFilesListWindow .visible :
44+ Utils .popup_centered (oConfigFilesListWindow )
45+ oCustomSlabSystem .load_unearth_custom_slabs_file ()
7546
7647
77- func load_kfx_format (mapPath ):
48+ func load_cfgs (mapPath ):
7849 # Load configuration for KeeperFX format
7950 # Processes .cfg and .toml files from multiple directories
8051 oConfigFileManager .clear_paths ()
@@ -317,7 +288,7 @@ func load_campaign_boss_file(mapPath):
317288 return {}
318289 var list_of_main_campaign_files = Utils .get_filetype_in_directory (levelsDirPath , "cfg" )
319290 for campaignPath in list_of_main_campaign_files :
320- var cfgDictionary = oReadCfg .read_dkcfg_file (campaignPath )
291+ var cfgDictionary = oReadCfg .read_dkcfg_file (campaignPath )[ "config" ]
321292 var levelsLocation = cfgDictionary .get ("common" , {}).get ("LEVELS_LOCATION" , null )
322293 if levelsLocation and oGame .GAME_DIRECTORY .plus_file (levelsLocation ).to_lower () == mapPath .get_base_dir ().to_lower ():
323294 # print(oGame.GAME_DIRECTORY.plus_file(levelsLocation).to_lower())
@@ -366,3 +337,12 @@ func remove_path_from_loaded(file_path):
366337 if oConfigFileManager .paths_loaded [load_cfg_type ].has (file_path ):
367338 oConfigFileManager .paths_loaded [load_cfg_type ].erase (file_path )
368339 break
340+
341+ func load_classic_tmap_files ():
342+ oConfigFileManager .clear_paths ()
343+ # Scan DATA directory for TMAP files
344+ var data_directory = oGame .DK_DATA_DIRECTORY
345+ var tmap_files = Utils .get_filetype_in_directory (data_directory , "dat" )
346+ for fullPath in tmap_files :
347+ if "tmap" in fullPath .to_lower ():
348+ oConfigFileManager .paths_loaded [oConfigFileManager .LOAD_CFG_DATA ].append (fullPath )
0 commit comments