restore GUI event loop

master
magical 2024-02-03 20:21:29 -08:00
parent 2f2c281265
commit 3c7ae38f81
1 changed files with 70 additions and 66 deletions

20
GUI.py
View File

@ -231,19 +231,23 @@ def main_window(debug):
fileName = str()
finishGenerating = False
oldNum = str()
while True:
(event, values) = window.read()
if event == ui.WINDOW_CLOSED:
pass
break
elif event == 'Num':
if len(values['Num']) > 3:
window['Num'].update(oldNum)
for x in range(4):
if x < len(values['Num']) or values['Num'][x] not in '0123456789':
if x < len(values['Num']):
if values['Num'][x] not in '0123456789':
window['Num'].update(oldNum)
break
else:
oldNum = values['Num']
# continue
if event == 'Generate':
elif event == 'Generate':
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 == '':
ui.popup('Please select a Metroid Fusion (U) rom.', title='No source rom selected')
@ -268,11 +272,12 @@ def main_window(debug):
window['Num'].update(disabled=True)
window['Patch'].update(disabled=True)
window['Generate'].update(disabled=True)
if generating:
ui.popup_animated(ui.DEFAULT_BASE64_LOADING_GIF, 'Generating game, please wait...', time_between_frames=20)
window.Refresh()
# continue
if finishGenerating:
elif finishGenerating:
ui.popup_animated(None)
if failedgen:
ui.popup('Could not generate a game with the current settings. Try changing your settings.', title='Metroid Fusion Open Randomizer')
@ -299,6 +304,5 @@ def main_window(debug):
window['Patch'].update(disabled=False)
window['Generate'].update(disabled=False)
finishGenerating = False
# continue
window.close()