@@ -24,18 +24,24 @@ def onCreate(self):
2424 screen = lv .obj ()
2525 screen .set_style_pad_all (15 , 0 )
2626
27+ # Create title label
28+ title_label = lv .label (screen )
29+ title_label .set_text ("Choose your DOOM:" )
30+ title_label .align (lv .ALIGN .TOP_LEFT , 0 , 0 )
31+
2732 # Create list widget for WAD files
2833 self .wadlist = lv .list (screen )
29- self .wadlist .set_size (lv .pct (100 ), lv .pct (85 ))
30- self .wadlist .align ( lv . ALIGN . TOP_MID , 0 , 0 )
31-
34+ self .wadlist .set_size (lv .pct (100 ), lv .pct (70 ))
35+ self .wadlist .center ( )
36+
3237 # Create status label for messages
3338 self .status_label = lv .label (screen )
3439 self .status_label .set_width (lv .pct (90 ))
3540 self .status_label .set_long_mode (lv .label .LONG_MODE .WRAP )
36- self .status_label .align_to (self .wadlist , lv .ALIGN .OUT_BOTTOM_MID , 0 , 0 )
37- self .status_label .add_flag (lv .obj .FLAG .HIDDEN )
38-
41+ self .status_label .align (lv .ALIGN .BOTTOM_LEFT , 0 , 0 )
42+ # Set default green color for status label
43+ self .status_label .set_style_text_color (lv .color_hex (0x00FF00 ), 0 )
44+
3945 self .setContentView (screen )
4046
4147 def onResume (self , screen ):
@@ -69,40 +75,47 @@ def scan_wad_files(self, directory):
6975
7076 return wad_files
7177
78+ def get_file_size_warning (self , filepath ):
79+ """Get file size warning suffix if file is too small or empty"""
80+ try :
81+ size = os .stat (filepath )[6 ] # Get file size
82+ if size == 0 :
83+ return " (EMPTY FILE)" # Red
84+ elif size < 80 * 1024 : # 80KB
85+ return " (TOO SMALL)" # Orange
86+ except Exception as e :
87+ print (f"Error checking file size for { filepath } : { e } " )
88+ return ""
89+
7290 def refresh_wad_list (self ):
91+ self .status_label .set_text (f"Listing files in: { self .bootfile_prefix + self .doomdir } " )
7392 """Scan for WAD files and populate the list"""
7493 print ("refresh_wad_list: Clearing current list" )
7594 self .wadlist .clean ()
76-
77- # Scan both internal storage and SD card
78- internal_wads = self .scan_wad_files (self .doomdir )
79- sdcard_wads = []
80- if self .bootfile_prefix :
81- sdcard_wads = self .scan_wad_files (self .bootfile_prefix + self .doomdir )
82-
83- # Combine and deduplicate
84- all_wads = list (set (internal_wads + sdcard_wads ))
95+
96+ # Scan internal storage or SD card
97+ all_wads = self .scan_wad_files (self .bootfile_prefix + self .doomdir )
8598 all_wads .sort ()
86-
99+
87100 if len (all_wads ) == 0 :
88101 self .status_label .set_text (f"No .wad or .zip files found in { self .doomdir } " )
89- self .status_label .remove_flag (lv .obj .FLAG .HIDDEN )
90102 print ("No WAD files found" )
91103 return
92-
93- # Hide status label if we have files
94- self .status_label .add_flag (lv .obj .FLAG .HIDDEN )
95-
104+
96105 # If only one WAD file, auto-start it
97106 if len (all_wads ) == 1 :
98107 print (f"refresh_wad_list: Only one WAD file found, auto-starting: { all_wads [0 ]} " )
99108 self .start_wad_file (all_wads [0 ])
100109 return
101-
110+
102111 # Populate list with WAD files
103112 print (f"refresh_wad_list: Populating list with { len (all_wads )} WAD files" )
113+ self .status_label .set_text (f"Listed files in: { self .bootfile_prefix + self .doomdir } " )
104114 for wad_file in all_wads :
105- button = self .wadlist .add_button (None , wad_file )
115+ # Get file size warning if applicable
116+ warning = self .get_file_size_warning (self .doomdir + '/' + wad_file )
117+ button_text = wad_file + warning
118+ button = self .wadlist .add_button (None , button_text )
106119 button .add_event_cb (lambda e , f = wad_file : self .start_wad_file (f ), lv .EVENT .CLICKED , None )
107120
108121 def start_wad_file (self , wad_file ):
0 commit comments