@@ -1555,40 +1555,67 @@ def _command_edit_launcher(self, categoryID, launcherID):
15551555 log_info('No duplicated asset dirs found')
15561556
15571557 # >> Traverse ROM list and check local asset/artwork
1558+ pDialog = xbmcgui.DialogProgress()
1559+ pDialog.create('Advanced Emulator Launcher', 'Searching for local assets/artwork ...')
15581560 roms_base_noext = self.launchers[launcherID]['roms_base_noext']
15591561 roms = fs_load_ROMs_JSON(ROMS_DIR, roms_base_noext)
1562+ num_items = len(roms)
1563+ item_counter = 0
15601564 for rom_id in roms:
15611565 rom = roms[rom_id]
15621566 ROMFile = FileName(rom['filename'])
15631567 rom_basename_noext = ROMFile.getBase_noext()
1564- log_info ('Checking ROM "{0}"'.format(ROMFile.getBase()))
1568+ log_verb ('Checking ROM "{0}"'.format(ROMFile.getBase()))
15651569 for i, asset in enumerate(ROM_ASSET_LIST):
15661570 AInfo = assets_get_info_scheme(asset)
15671571 if not enabled_asset_list[i]: continue
15681572 asset_path = FileName(launcher[AInfo.path_key])
15691573 local_asset = misc_look_for_file(asset_path, rom_basename_noext, AInfo.exts)
15701574 if local_asset:
15711575 rom[AInfo.key] = local_asset.getOriginalPath()
1572- log_verb ('Found {0:<10} "{1}"'.format(AInfo.name, local_asset.getPath()))
1576+ log_debug ('Found {0:<10} "{1}"'.format(AInfo.name, local_asset.getPath()))
15731577 else:
15741578 rom[AInfo.key] = ''
1575- log_verb('Missing {0:<10}'.format(AInfo.name))
1579+ log_debug('Missing {0:<10}'.format(AInfo.name))
1580+ item_counter += 1
1581+ pDialog.update((item_counter*100)/num_items)
1582+ pDialog.update(100)
1583+ pDialog.close()
1584+
1585+ # --- If there is a No-Intro XML configured audit ROMs ---
1586+ if launcher['nointro_xml_file']:
1587+ log_info('No-Intro/Redump DAT configured. Starting ROM audit ...')
1588+ nointro_xml_FN = FileName(launcher['nointro_xml_file'])
1589+ if not self._roms_update_NoIntro_status(launcher, roms, nointro_xml_FN):
1590+ self.launchers[launcherID]['nointro_xml_file'] = ''
1591+ self.launchers[launcherID]['pclone_launcher'] = False
1592+ kodi_dialog_OK('Error auditing ROMs. XML DAT file unset.')
15761593
15771594 # ~~~ Save ROMs XML file ~~~
15781595 fs_write_ROMs_JSON(ROMS_DIR, roms_base_noext, roms, self.launchers[launcherID])
15791596 kodi_notify('Rescaning of local artwork finished')
15801597
15811598 # --- Remove Remove dead/missing ROMs ROMs ---
15821599 elif type2 == 3:
1583- ret = kodi_dialog_yesno('Are you sure you want to remove missing/dead ROMs?')
1600+ if self.launchers[launcherID]['nointro_xml_file']:
1601+ ret = kodi_dialog_yesno('This launcher has an XML DAT configured. Removing '
1602+ 'dead ROMs will disable the DAT file. '
1603+ 'Are you sure you want to remove missing/dead ROMs?')
1604+ else:
1605+ ret = kodi_dialog_yesno('Are you sure you want to remove missing/dead ROMs?')
15841606 if not ret: return
15851607
15861608 # --- Load ROMs for this launcher ---
15871609 roms = fs_load_ROMs_JSON(ROMS_DIR, self.launchers[launcherID]['roms_base_noext'])
15881610
15891611 # --- Remove dead ROMs ---
15901612 num_removed_roms = self._roms_delete_missing_ROMs(roms)
1591- kodi_notify('Removed {0} dead ROMs'.format(num_removed_roms))
1613+
1614+ # --- If there is a No-Intro XML DAT configured remove it ---
1615+ if self.launchers[launcherID]['nointro_xml_file']:
1616+ log_info('Deleting XML DAT file and forcing launcher to Normal view mode.')
1617+ self.launchers[launcherID]['nointro_xml_file'] = ''
1618+ self.launchers[launcherID]['pclone_launcher'] = False
15921619
15931620 # ~~~ Save ROMs XML file ~~~
15941621 # >> Launcher saved at the end of the function / launcher timestamp updated.
@@ -1669,6 +1696,12 @@ def _command_edit_launcher(self, categoryID, launcherID):
16691696 "from AEL database?".format(self.launchers[launcherID]['m_name'], num_roms))
16701697 if not ret: return
16711698
1699+ # --- If there is a No-Intro XML DAT configured remove it ---
1700+ if self.launchers[launcherID]['nointro_xml_file']:
1701+ log_info('Deleting XML DAT file and forcing launcher to Normal view mode.')
1702+ self.launchers[launcherID]['nointro_xml_file'] = ''
1703+ self.launchers[launcherID]['pclone_launcher'] = False
1704+
16721705 # Just remove ROMs database files. Keep the value of roms_base_noext to be reused
16731706 # when user add more ROMs.
16741707 fs_unlink_ROMs_database(ROMS_DIR, self.launchers[launcherID]['roms_base_noext'])
@@ -1760,10 +1793,8 @@ def _command_edit_launcher(self, categoryID, launcherID):
17601793 ret = dialog.yesno('Advanced Emulator Launcher', 'Delete No-Intro/Redump XML DAT file?')
17611794 if not ret: return
17621795 self.launchers[launcherID]['nointro_xml_file'] = ''
1763- kodi_dialog_OK('No-Intro DAT deleted. No-Intro Missing ROMs will be removed now.')
1764-
1765- # >> If Parent/Clone view display mode is on set display mode to normal
17661796 self.launchers[launcherID]['pclone_launcher'] = False
1797+ kodi_dialog_OK('No-Intro DAT deleted. No-Intro Missing ROMs will be removed now.')
17671798
17681799 # --- Remove No-Intro status and delete missing/dead ROMs to revert launcher to normal ---
17691800 # Note that roms dictionary is updated using Python pass by assigment.
@@ -1800,6 +1831,7 @@ def _command_edit_launcher(self, categoryID, launcherID):
18001831 else:
18011832 # >> ERROR when auditing the ROMs. Unset nointro_xml_file
18021833 self.launchers[launcherID]['nointro_xml_file'] = ''
1834+ self.launchers[launcherID]['pclone_launcher'] = False
18031835 kodi_notify_warn('Error auditing ROMs. XML DAT file not set.')
18041836 launcher['num_roms'] = len(roms)
18051837
@@ -1837,6 +1869,7 @@ def _command_edit_launcher(self, categoryID, launcherID):
18371869 else:
18381870 # >> ERROR when auditing the ROMs. Unset nointro_xml_file
18391871 self.launchers[launcherID]['nointro_xml_file'] = ''
1872+ self.launchers[launcherID]['pclone_launcher'] = False
18401873 kodi_notify_warn('Error auditing ROMs. XML DAT file unset.')
18411874 launcher['num_roms'] = len(roms)
18421875
@@ -2372,21 +2405,41 @@ def _command_edit_rom(self, categoryID, launcherID, romID):
23722405
23732406 # --- Delete ROM ---
23742407 elif type == 4:
2408+ is_Normal_Launcher = True
23752409 if categoryID == VCATEGORY_FAVOURITES_ID and launcherID == VLAUNCHER_FAVOURITES_ID:
23762410 log_info('_command_remove_rom() Deleting ROM from Favourites (id {0})'.format(romID))
23772411 msg_str = 'Are you sure you want to delete it from Favourites?'
2412+ is_Normal_Launcher = False
23782413 elif categoryID == VCATEGORY_COLLECTIONS_ID:
23792414 log_info('_command_remove_rom() Deleting ROM from Collection (id {0})'.format(romID))
23802415 msg_str = 'Are you sure you want to delete it from Collection "{0}"?'.format(collection['m_name'])
2416+ is_Normal_Launcher = False
23812417 else:
2382- log_info('_command_remove_rom() Deleting ROM from Launcher (id {0})'.format(romID))
2383- msg_str = 'Are you sure you want to delete it from Launcher "{0}"?'.format(launcher['m_name'])
2418+ if launcher['nointro_xml_file'] and roms[romID]['nointro_status'] == NOINTRO_STATUS_MISS:
2419+ kodi_dialog_OK('You are trying to remove a Missing ROM. You cannot delete '
2420+ 'a ROM that does not exist! If you want to get rid of all missing '
2421+ 'ROMs then delete the XML DAT file.')
2422+ return
2423+ else:
2424+ log_info('_command_remove_rom() Deleting ROM from Launcher (id {0})'.format(romID))
2425+ msg_str = 'Are you sure you want to delete it from Launcher "{0}"?'.format(launcher['m_name'])
23842426
23852427 # --- Confirm deletion ---
23862428 rom_name = roms[romID]['m_name']
23872429 ret = kodi_dialog_yesno('ROM "{0}". '.format(rom_name) + msg_str)
23882430 if not ret: return
23892431 roms.pop(romID)
2432+
2433+ # --- If there is a No-Intro XML configured audit ROMs ---
2434+ if is_Normal_Launcher and launcher['nointro_xml_file']:
2435+ log_info('No-Intro/Redump DAT configured. Starting ROM audit ...')
2436+ nointro_xml_FN = FileName(launcher['nointro_xml_file'])
2437+ if not self._roms_update_NoIntro_status(launcher, roms, nointro_xml_FN):
2438+ self.launchers[launcherID]['nointro_xml_file'] = ''
2439+ self.launchers[launcherID]['pclone_launcher'] = False
2440+ kodi_notify_warn('Error auditing ROMs. XML DAT file unset.')
2441+
2442+ # --- Notify user ---
23902443 kodi_notify('Deleted ROM {0}'.format(rom_name))
23912444
23922445 # --- Manage Favourite/Collection ROM object (ONLY for Favourite/Collection ROMs) ---
@@ -2739,17 +2792,13 @@ def _command_edit_rom(self, categoryID, launcherID, romID):
27392792 fs_write_Collection_ROMs_JSON(json_file_path, collection_rom_list)
27402793 else:
27412794 # >> Save categories/launchers to update timestamp
2742- # >> Also update changed launcher timestamp
2795+ # Also update changed launcher timestamp
2796+ self.launchers[launcherID]['num_roms'] = len(roms)
27432797 self.launchers[launcherID]['timestamp_launcher'] = _t = time.time()
27442798 roms_base_noext = self.launchers[launcherID]['roms_base_noext']
27452799 fs_write_ROMs_JSON(ROMS_DIR, roms_base_noext, roms, self.launchers[launcherID])
27462800 fs_write_catfile(CATEGORIES_FILE_PATH, self.categories, self.launchers)
27472801
2748- # >> ROMs in launcher have changed.
2749- # >> If DAT is available update No-Intro status?
2750- # >> If PCLone display mode update PClone database.
2751-
2752-
27532802 # It seems that updating the container does more harm than good... specially when having many ROMs
27542803 # By the way, what is the difference between Container.Refresh() and Container.Update()?
27552804 kodi_refresh_container()
@@ -7443,17 +7492,19 @@ def _roms_add_new_rom(self, launcherID):
74437492 nointro_xml_FN = FileName(launcher['nointro_xml_file'])
74447493 if not self._roms_update_NoIntro_status(launcher, roms, nointro_xml_FN):
74457494 self.launchers[launcherID]['nointro_xml_file'] = ''
7446- kodi_notify_warn('Error auditing ROMs. XML DAT file unset.')
7495+ self.launchers[launcherID]['pclone_launcher'] = False
7496+ kodi_dialog_OK('Error auditing ROMs. XML DAT file unset.')
74477497 else:
74487498 log_info('No No-Intro/Redump DAT configured. Do not audit ROMs.')
7449- kodi_notify('Added ROMs. Launcher has now {0} ROMs'.format(len(roms)))
74507499
74517500 # ~~~ Save ROMs XML file ~~~
74527501 # >> Also save categories/launchers to update timestamp
74537502 self.launchers[launcherID]['num_roms'] = len(roms)
74547503 launcher['timestamp_launcher'] = time.time()
74557504 fs_write_ROMs_JSON(ROMS_DIR, launcher['roms_base_noext'], roms, self.launchers[launcherID])
74567505 fs_write_catfile(CATEGORIES_FILE_PATH, self.categories, self.launchers)
7506+ kodi_refresh_container()
7507+ kodi_notify('Added ROM. Launcher has now {0} ROMs'.format(len(roms)))
74577508
74587509 #
74597510 # ROM scanner. Called when user chooses "Add items" -> "Scan items"
@@ -7731,6 +7782,7 @@ def _roms_import_roms(self, launcherID):
77317782 else:
77327783 # >> ERROR when auditing the ROMs. Unset nointro_xml_file
77337784 self.launchers[launcherID]['nointro_xml_file'] = ''
7785+ self.launchers[launcherID]['pclone_launcher'] = False
77347786 kodi_notify_warn('Error auditing ROMs. XML DAT file unset.')
77357787 else:
77367788 log_info('No No-Intro/Redump DAT configured. Do not audit ROMs.')
0 commit comments