9 #include <sys/types.h> // For MacOS <dirent.h> dependency
15 //Need 4 buttons, one scrollbar...
16 FileList::FileList(uint32 x, uint32 y, uint32 w, uint32 h): Window(x, y, w, h)
18 files = new ListBox(8, 8, w - 16, h - 32);
20 load = new Button(8, h - 16, " Load ");
22 load->SetNotificationElement(this);
24 #warning !!! FIX !!! Directory might not exist--this shouldn't cause VJ to crash!
25 DIR * dp = opendir(vjs.ROMPath);
30 while ((de = readdir(dp)) != NULL)
32 char * ext = strrchr(de->d_name, '.');
35 if (strcasecmp(ext, ".zip") == 0 || strcasecmp(ext, ".j64") == 0
36 || strcasecmp(ext, ".abs") == 0 || strcasecmp(ext, ".jag") == 0
37 || strcasecmp(ext, ".rom") == 0)
38 files->AddItem(std::string(de->d_name));
45 //Give a diagnostic message here so that the (l)user can figure out what went wrong. !!! FIX !!!
49 void FileList::HandleKey(SDLKey key)
51 if (key == SDLK_RETURN)
54 Window::HandleKey(key);
57 void FileList::HandleMouseMove(uint32 x, uint32 y)
59 Window::HandleMouseMove(x, y);
62 void FileList::HandleMouseButton(uint32 x, uint32 y, bool mouseDown)
64 Window::HandleMouseButton(x, y, mouseDown);
67 void FileList::Draw(uint32 offsetX/*= 0*/, uint32 offsetY/*= 0*/)
69 Window::Draw(offsetX, offsetY);
72 extern Window * ResetJaguar(void);
73 #warning ICKY KLUDGE--FIX THIS MESS!!!
74 void FileList::Notify(Element * e)
78 char filename[MAX_PATH];
79 strcpy(filename, vjs.ROMPath);
81 if (strlen(filename) > 0)
82 if (filename[strlen(filename) - 1] != '/')
83 strcat(filename, "/");
85 strcat(filename, files->GetSelectedItem().c_str());
87 // uint32 romSize = JaguarLoadROM(jaguar_mainRom, filename);
88 // JaguarLoadCart(jaguar_mainRom, filename);
89 if (JaguarLoadFile(filename))
92 event.type = SDL_USEREVENT, event.user.code = WINDOW_CLOSE;
93 SDL_PushEvent(&event);
95 event.type = SDL_USEREVENT, event.user.code = MENU_ITEM_CHOSEN;
96 event.user.data1 = (void *)ResetJaguar;
97 SDL_PushEvent(&event);
102 event.type = SDL_USEREVENT, event.user.code = WINDOW_CLOSE;
103 SDL_PushEvent(&event);
105 // Handle the error, but don't run...
106 // Tell the user that we couldn't run their file for some reason... !!! FIX !!!
107 //how to kludge: Make a function like ResetJaguar which creates the dialog window