Skip to content

Commit

Permalink
#17 Move beep to last in reset
Browse files Browse the repository at this point in the history
  • Loading branch information
jramboz committed Jul 1, 2024
1 parent 3ae6554 commit 4521699
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ def _upload_default_files(self):
self.log.info('Uploading default sound font.')
files = glob.glob(os.path.join(resourcedir, 'OpenCore_OEM', '*.RAW'))
files.sort()
files = self.move_beep_to_last(files)
self.uc = Upload_Controller(files, self.sc, set_effects=False, reload_config=False, autoclose=True, parent=self)
self.uc.finished_action = self._send_reset_cmd
try:
Expand Down Expand Up @@ -576,23 +577,31 @@ def r(obj: object):
pd.show()
self.threadpool.start(worker)

@staticmethod
def move_beep_to_last(files: list[str]) -> list[str]:
'''If the list of files contains 'BEEP.RAW', move it to last. Otherwise return the list unchanged.'''
log = logging.getLogger()
beep_files = [file for file in files if "BEEP.RAW" in file]
# if a BEEP.RAW is specified, move it to the end of the list.
# NXTs seem to do better if BEEP.RAW is the last file uploaded
if beep_files:
for file in beep_files:
log.debug(f'Moving BEEP file {file} to end of upload list.')
files.remove(file)
files.append(file)
return files

uc: Upload_Controller = None
def upload_button_handler(self):
# Get a list of files to upload. Can be one file or multiple files
files = QFileDialog.getOpenFileNames(self, filter="RAW Sound File (*.RAW)")[0]
if(files):
files.sort()
if self.anima_is_NXT():
beep_files = [file for file in files if "BEEP.RAW" in file]
# if a BEEP.RAW is specified, move it to the end of the list.
# NXTs seem to do better if BEEP.RAW is the last file uploaded
if beep_files:
for file in beep_files:
self.log.debug(f'Moving BEEP file {file} to end of upload list.')
files.remove(file)
files.append(file)
else:
if 'BEEP.RAW' not in self.files_dict.keys():
# move any BEEP.RAW files to last
files = self.move_beep_to_last(files)
if not files[-1].endswith('BEEP.RAW'): # if a BEEP.RAW is not included in the list to upload
if 'BEEP.RAW' not in self.files_dict.keys(): # and there's not already a BEEP.RAW on the saber
self.log.info('NXT saber detected and no BEEP.RAW provided. Adding default BEEP.RAW.')
files.append(os.path.join(resourcedir, 'OpenCore_OEM', 'BEEP.RAW'))
self.log.debug(f'List of files to upload: {files}')
Expand Down

0 comments on commit 4521699

Please sign in to comment.