Skip to content

Commit 0743cce

Browse files
Simplify
1 parent c165d58 commit 0743cce

File tree

1 file changed

+4
-8
lines changed
  • internal_filesystem/apps/com.micropythonos.doom/assets

1 file changed

+4
-8
lines changed

internal_filesystem/apps/com.micropythonos.doom/assets/doom.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,23 +110,19 @@ def refresh_wad_list(self):
110110
warning = self.get_file_size_warning(self.bootfile_prefix + self.doomdir + '/' + wad_file)
111111
button_text = wad_file + warning
112112
button = self.wadlist.add_button(None, button_text)
113-
button.add_event_cb(lambda e, f=wad_file: self.start_wad_file(f), lv.EVENT.CLICKED, None)
113+
button.add_event_cb(lambda e, f=wad_file: TaskManager.create_task(self.start_wad_file(f)), lv.EVENT.CLICKED, None)
114114

115115
# If only one WAD file, auto-start it
116116
if len(all_wads) == 1:
117117
print(f"refresh_wad_list: Only one WAD file found, auto-starting: {all_wads[0]}")
118-
self.start_wad_file(all_wads[0])
118+
TaskManager.create_task(self.start_wad_file(all_wads[0]))
119119

120-
def start_wad_file(self, wad_file):
120+
async def start_wad_file(self, wad_file):
121121
"""Start a WAD file (called from list selection or auto-start)"""
122122
print(f"start_wad_file: WAD file selected: {wad_file}")
123123
wadfile_path = self.bootfile_prefix + self.doomdir + '/' + wad_file
124124
# Do it in a separate task so the UI doesn't hang (shows progress, status_label) and the serial console keeps showing prints
125-
TaskManager.create_task(self._start_wad_task(self.bootfile_prefix, self.bootfile_to_write, wadfile_path))
126-
127-
async def _start_wad_task(self, bootfile_prefix, bootfile_to_write, wadfile):
128-
"""Wrapper to ensure start_wad is called as a coroutine"""
129-
await self.start_wad(bootfile_prefix, bootfile_to_write, wadfile)
125+
await self.start_wad(self.bootfile_prefix, self.bootfile_to_write, wadfile_path)
130126

131127
def mkdir(self, dirname):
132128
# Would be better to only create it if it doesn't exist

0 commit comments

Comments
 (0)