You've already forked MicroPythonOS
mirror of
https://github.com/m5stack/MicroPythonOS.git
synced 2026-05-20 11:51:27 -07:00
Doom app: fix bugs
This commit is contained in:
@@ -88,8 +88,8 @@ class Doom(Activity):
|
||||
return ""
|
||||
|
||||
def refresh_wad_list(self):
|
||||
self.status_label.set_text(f"Listing files in: {self.bootfile_prefix + self.doomdir}")
|
||||
"""Scan for WAD files and populate the list"""
|
||||
self.status_label.set_text(f"Listing files in: {self.bootfile_prefix + self.doomdir}")
|
||||
print("refresh_wad_list: Clearing current list")
|
||||
self.wadlist.clean()
|
||||
|
||||
@@ -107,7 +107,7 @@ class Doom(Activity):
|
||||
self.status_label.set_text(f"Listed files in: {self.bootfile_prefix + self.doomdir}")
|
||||
for wad_file in all_wads:
|
||||
# Get file size warning if applicable
|
||||
warning = self.get_file_size_warning(self.doomdir + '/' + wad_file)
|
||||
warning = self.get_file_size_warning(self.bootfile_prefix + self.doomdir + '/' + wad_file)
|
||||
button_text = wad_file + warning
|
||||
button = self.wadlist.add_button(None, button_text)
|
||||
button.add_event_cb(lambda e, f=wad_file: self.start_wad_file(f), lv.EVENT.CLICKED, None)
|
||||
@@ -116,14 +116,17 @@ class Doom(Activity):
|
||||
if len(all_wads) == 1:
|
||||
print(f"refresh_wad_list: Only one WAD file found, auto-starting: {all_wads[0]}")
|
||||
self.start_wad_file(all_wads[0])
|
||||
return
|
||||
|
||||
def start_wad_file(self, wad_file):
|
||||
"""Start a WAD file (called from list selection or auto-start)"""
|
||||
print(f"start_wad_file: WAD file selected: {wad_file}")
|
||||
wadfile_path = self.doomdir + '/' + wad_file
|
||||
wadfile_path = self.bootfile_prefix + self.doomdir + '/' + wad_file
|
||||
# Do it in a separate task so the UI doesn't hang (shows progress, status_label) and the serial console keeps showing prints
|
||||
TaskManager.create_task(self.start_wad(self.bootfile_prefix, self.bootfile_to_write, wadfile_path))
|
||||
TaskManager.create_task(self._start_wad_task(self.bootfile_prefix, self.bootfile_to_write, wadfile_path))
|
||||
|
||||
async def _start_wad_task(self, bootfile_prefix, bootfile_to_write, wadfile):
|
||||
"""Wrapper to ensure start_wad is called as a coroutine"""
|
||||
await self.start_wad(bootfile_prefix, bootfile_to_write, wadfile)
|
||||
|
||||
def mkdir(self, dirname):
|
||||
# Would be better to only create it if it doesn't exist
|
||||
|
||||
Reference in New Issue
Block a user