Compare commits

..

1 Commits

Author SHA1 Message Date
magical 07faf6bd11 update README 2024-02-03 19:59:37 -08:00
1 changed files with 66 additions and 70 deletions

134
GUI.py
View File

@ -231,78 +231,74 @@ def main_window(debug):
fileName = str() fileName = str()
finishGenerating = False finishGenerating = False
oldNum = str() oldNum = str()
while True: (event, values) = window.read()
(event, values) = window.read() if event == ui.WINDOW_CLOSED:
if event == ui.WINDOW_CLOSED: pass
break elif event == 'Num':
if len(values['Num']) > 3:
elif event == 'Num': window['Num'].update(oldNum)
if len(values['Num']) > 3: for x in range(4):
if x < len(values['Num']) or values['Num'][x] not in '0123456789':
window['Num'].update(oldNum) window['Num'].update(oldNum)
for x in range(4):
if x < len(values['Num']):
if values['Num'][x] not in '0123456789':
window['Num'].update(oldNum)
break
else:
oldNum = values['Num']
elif event == 'Generate': oldNum = values['Num']
basegame = ui.popup_get_file('Choose base game', no_titlebar=True, file_types=[('GBA File', '*.gba')], history=True, history_setting_filename=os.path.join('.', 'settings.json')) # continue
if basegame == '': if event == 'Generate':
ui.popup('Please select a Metroid Fusion (U) rom.', title='No source rom selected') basegame = ui.popup_get_file('Choose base game', no_titlebar=True, file_types=[('GBA File', '*.gba')], history=True, history_setting_filename=os.path.join('.', 'settings.json'))
if basegame != None and basegame != '': if basegame == '':
checksum = fileHash(basegame) ui.popup('Please select a Metroid Fusion (U) rom.', title='No source rom selected')
if checksum != 1819625372: if basegame != None and basegame != '':
ui.popup('Only Metroid Fusion (U) is supported.\nCheck the CRC32 value: it should be 6C75479C', title='Bad Checksum') checksum = fileHash(basegame)
else: if checksum != 1819625372:
values.update({ ui.popup('Only Metroid Fusion (U) is supported.\nCheck the CRC32 value: it should be 6C75479C', title='Bad Checksum')
'Debug': debug }) else:
threading.Thread(target=rando_thread, args=[window, values], daemon=True).start() values.update({
window['Difficulty'].update(disabled=True) 'Debug': debug })
window['MajorMinor'].update(disabled=True) threading.Thread(target=rando_thread, args=[window, values], daemon=True).start()
window['MissilesWithoutMainData'].update(disabled=True) window['Difficulty'].update(disabled=True)
window['PowerBombsWithoutBombs'].update(disabled=True) window['MajorMinor'].update(disabled=True)
window['DamageRuns'].update(disabled=True) window['MissilesWithoutMainData'].update(disabled=True)
window['SplitSecurity'].update(disabled=True) window['PowerBombsWithoutBombs'].update(disabled=True)
window['SectorShuffle'].update(disabled=True) window['DamageRuns'].update(disabled=True)
window['HideItems'].update(disabled=True) window['SplitSecurity'].update(disabled=True)
window['Seed'].update(disabled=True) window['SectorShuffle'].update(disabled=True)
window['RaceSeed'].update(disabled=True) window['HideItems'].update(disabled=True)
window['Num'].update(disabled=True) window['Seed'].update(disabled=True)
window['Patch'].update(disabled=True) window['RaceSeed'].update(disabled=True)
window['Generate'].update(disabled=True) window['Num'].update(disabled=True)
window['Patch'].update(disabled=True)
if generating: window['Generate'].update(disabled=True)
ui.popup_animated(ui.DEFAULT_BASE64_LOADING_GIF, 'Generating game, please wait...', time_between_frames=20) if generating:
window.Refresh() ui.popup_animated(ui.DEFAULT_BASE64_LOADING_GIF, 'Generating game, please wait...', time_between_frames=20)
window.Refresh()
elif finishGenerating: # continue
ui.popup_animated(None) if finishGenerating:
if failedgen: ui.popup_animated(None)
ui.popup('Could not generate a game with the current settings. Try changing your settings.', title='Metroid Fusion Open Randomizer') if failedgen:
elif randoerror: ui.popup('Could not generate a game with the current settings. Try changing your settings.', title='Metroid Fusion Open Randomizer')
ui.popup('An error occurred, no game was generated.', title='Error') elif randoerror:
elif ui.Input.get(window['Num']) != '': ui.popup('An error occurred, no game was generated.', title='Error')
if int(ui.Input.get(window['Num'])) > 1: elif ui.Input.get(window['Num']) != '':
ui.popup('Multiple games have been added to the seeds folder.', title='Success!') if int(ui.Input.get(window['Num'])) > 1:
else: ui.popup('Multiple games have been added to the seeds folder.', title='Success!')
ui.popup('{}\nhas been added to the seeds folder.'.format(fileName), title='Success!')
else: else:
ui.popup('{}\nhas been added to the seeds folder.'.format(fileName), title='Success!') ui.popup('{}\nhas been added to the seeds folder.'.format(fileName), title='Success!')
window['Difficulty'].update(disabled=False) else:
window['MajorMinor'].update(disabled=False) ui.popup('{}\nhas been added to the seeds folder.'.format(fileName), title='Success!')
window['MissilesWithoutMainData'].update(disabled=False) window['Difficulty'].update(disabled=False)
window['PowerBombsWithoutBombs'].update(disabled=False) window['MajorMinor'].update(disabled=False)
window['DamageRuns'].update(disabled=False) window['MissilesWithoutMainData'].update(disabled=False)
window['SplitSecurity'].update(disabled=False) window['PowerBombsWithoutBombs'].update(disabled=False)
window['SectorShuffle'].update(disabled=False) window['DamageRuns'].update(disabled=False)
window['HideItems'].update(disabled=False) window['SplitSecurity'].update(disabled=False)
window['Seed'].update(disabled=False) window['SectorShuffle'].update(disabled=False)
window['RaceSeed'].update(disabled=False) window['HideItems'].update(disabled=False)
window['Num'].update(disabled=False) window['Seed'].update(disabled=False)
window['Patch'].update(disabled=False) window['RaceSeed'].update(disabled=False)
window['Generate'].update(disabled=False) window['Num'].update(disabled=False)
finishGenerating = False window['Patch'].update(disabled=False)
window['Generate'].update(disabled=False)
finishGenerating = False
# continue
window.close() window.close()