diff --git a/data/images/background.jpg b/data/images/background.jpg index f5a620a2..60ebf8af 100644 Binary files a/data/images/background.jpg and b/data/images/background.jpg differ diff --git a/data/images/flatnopic.png b/data/images/flatnopic.png index 304cffe7..46175806 100644 Binary files a/data/images/flatnopic.png and b/data/images/flatnopic.png differ diff --git a/data/sounds/gc.ogg b/data/sounds/gc.ogg index c2506797..11973ae5 100644 Binary files a/data/sounds/gc.ogg and b/data/sounds/gc.ogg differ diff --git a/source/fileOps/fileOps.c b/source/fileOps/fileOps.c index 2fc089c9..b33cccbf 100644 --- a/source/fileOps/fileOps.c +++ b/source/fileOps/fileOps.c @@ -328,7 +328,7 @@ bool fsop_CopyFolder(char *source, char *target, progress_callback_t spinner, vo return doCopyFolder(source, target, spinner, spinner_data); } -void fsop_deleteFolder(char *source) +void fsop_deleteFolder(const char *source) { DIR *pdir; struct dirent *pent; diff --git a/source/fileOps/fileOps.h b/source/fileOps/fileOps.h index 70e3b36d..77f16852 100644 --- a/source/fileOps/fileOps.h +++ b/source/fileOps/fileOps.h @@ -18,7 +18,7 @@ void fsop_MakeFolder(char *path); bool fsop_CopyFile(char *source, char *target, progress_callback_t spinner, void *spinner_data); bool fsop_CopyFolder(char *source, char *target, progress_callback_t spinner, void *spinner_data); void fsop_deleteFile(const char *source); -void fsop_deleteFolder(char *source); +void fsop_deleteFolder(const char *source); #endif diff --git a/source/gui/coverflow.cpp b/source/gui/coverflow.cpp index 8e3fb0af..296ad914 100644 --- a/source/gui/coverflow.cpp +++ b/source/gui/coverflow.cpp @@ -1286,7 +1286,9 @@ void CCoverFlow::_drawCover(int i, bool mirror, CCoverFlow::DrawMode dm) STexture &CCoverFlow::_coverTexture(int i) { - return m_noCoverTexture; + if (!m_items[i].texture.data) + return m_items[i].state == CCoverFlow::STATE_Loading ? m_loadingTexture : m_noCoverTexture; + return m_items[i].texture; } void CCoverFlow::_drawCoverFlat(int i, bool mirror, CCoverFlow::DrawMode dm) @@ -1845,7 +1847,24 @@ bool CCoverFlow::start(const char *id) return false; m_dvdskin_loaded = true; } - m_noCoverTexture.fromPNG(flatnopic_png, GX_TF_CMPR, ALLOC_MEM2, 32, 512); + + if(m_box) + { + if (m_pngLoadCover.empty() || STexture::TE_OK != m_loadingTexture.fromImageFile(m_pngLoadCover.c_str(), GX_TF_CMPR, ALLOC_MEM2, 32, 512)) + if (STexture::TE_OK != m_loadingTexture.fromPNG(loading_png, GX_TF_CMPR, ALLOC_MEM2, 32, 512)) return false; + + if (m_pngNoCover.empty() || STexture::TE_OK != m_noCoverTexture.fromImageFile(m_pngNoCover.c_str(), GX_TF_CMPR, ALLOC_MEM2, 32, 512)) + if (STexture::TE_OK != m_noCoverTexture.fromPNG(nopic_png, GX_TF_CMPR, ALLOC_MEM2, 32, 512)) return false; + } + else + { + if (m_pngLoadCoverFlat.empty() || STexture::TE_OK != m_loadingTexture.fromImageFile(m_pngLoadCoverFlat.c_str(), GX_TF_CMPR, ALLOC_MEM2, 32, 512)) + if (STexture::TE_OK != m_loadingTexture.fromJPG(flatloading_jpg, flatloading_jpg_size, GX_TF_CMPR, ALLOC_MEM2, 32, 512)) return false; + + if (m_pngNoCoverFlat.empty() || STexture::TE_OK != m_noCoverTexture.fromImageFile(m_pngNoCoverFlat.c_str(), GX_TF_CMPR, ALLOC_MEM2, 32, 512)) + if (STexture::TE_OK != m_noCoverTexture.fromPNG(flatnopic_png, GX_TF_CMPR, ALLOC_MEM2, 32, 512)) return false; + } + m_covers.clear(); m_covers.resize(m_range); m_jump = 0; diff --git a/source/list/list.cpp b/source/list/list.cpp index 7ff5e6a3..9fd34127 100644 --- a/source/list/list.cpp +++ b/source/list/list.cpp @@ -44,28 +44,22 @@ void CList::GetPaths(vector &pathlist, string containing, string dire } closedir(dir_itr); - bool FoundFile; while(temp_pathlist.size()) { while((dir_itr = opendir(temp_pathlist[0].c_str())) && !dir_itr) temp_pathlist.erase(temp_pathlist.begin()); - FoundFile = false; - /* Read subdirectory */ while((ent = readdir(dir_itr)) != NULL) { if(ent->d_name[0] == '.') continue; - if(dml && FoundFile) - break; if(ent->d_type == DT_REG) { for(vector::iterator compare = compares.begin(); compare != compares.end(); compare++) { if(strcasestr(ent->d_name, (*compare).c_str()) != NULL) { - FoundFile = true; //gprintf("Pushing %s to the list.\n", sfmt("%s/%s", temp_pathlist[0].c_str(), ent->d_name).c_str()); pathlist.push_back(sfmt("%s/%s", temp_pathlist[0].c_str(), ent->d_name)); break; @@ -76,11 +70,8 @@ void CList::GetPaths(vector &pathlist, string containing, string dire { if(!depth_limit) temp_pathlist.push_back(sfmt("%s/%s", temp_pathlist[0].c_str(), ent->d_name)); - else if(dml && !FoundFile && strncasecmp(ent->d_name, "sys", 3) == 0 && - fsop_FileExist(fmt("%s/%s/boot.bin", temp_pathlist[0].c_str(), ent->d_name)) && - !fsop_FileExist(fmt("%s/game.iso", temp_pathlist[0].c_str()))) + else if(dml && strncasecmp(ent->d_name, "sys", 3) == 0 && fsop_DirExist(fmt("%s/root", temp_pathlist[0].c_str()))) { - FoundFile = true; //gprintf("Pushing %s to the list.\n", sfmt("%s/%s/boot.bin", temp_pathlist[0].c_str(), ent->d_name).c_str()); pathlist.push_back(sfmt("%s/%s/boot.bin", temp_pathlist[0].c_str(), ent->d_name)); } @@ -107,20 +98,6 @@ void CList::GetPaths(vector &pathlist, string containing, string dire } } -template <> -void CList::GetHeaders(vector pathlist, vector &headerlist, string, string, string, Config&) -{ - //gprintf("Getting headers for CList\n"); - - if(pathlist.size() < 1) - return; - - headerlist.reserve(pathlist.size() + headerlist.size()); - - for(vector::iterator itr = pathlist.begin(); itr != pathlist.end(); itr++) - headerlist.push_back((*itr).c_str()); -} - template <> void CList::GetHeaders(vector pathlist, vector &headerlist, string settingsDir, string curLanguage, string DMLgameUSBDir, Config &plugin) { @@ -133,6 +110,7 @@ void CList::GetHeaders(vector pathlist, vector vector GC_SD_IDs; bool GC_SD_IDs_loaded = false; + discHdr gc_hdr; dir_discHdr tmp; u32 count = 0; string GTitle; @@ -200,7 +178,7 @@ void CList::GetHeaders(vector pathlist, vector { char* filename = &(*itr)[(*itr).find_last_of('/')+1]; const char* dml_partition = DeviceName[DeviceHandler::Instance()->PathToDriveType((*itr).c_str())]; - if((strcasecmp(filename, "game.iso") == 0 || strcasecmp(filename, "boot.bin") == 0) && strstr((*itr).c_str(), sfmt((strncmp(dml_partition, "sd", 2) != 0) ? DMLgameUSBDir.c_str() : DML_DIR, dml_partition).c_str()) != NULL) + if(strcasecmp(filename, "game.iso") == 0 || strcasecmp(filename, "gam1.iso") == 0 || strcasecmp(filename, "boot.bin") == 0) { FILE *fp = fopen((*itr).c_str(), "rb"); if(fp) @@ -209,7 +187,7 @@ void CList::GetHeaders(vector pathlist, vector fseek(fp, 6, SEEK_SET); fread(gc_disc, 1, 1, fp); - discHdr gc_hdr; + memset(&gc_hdr, 0, sizeof(discHdr)); fseek(fp, 0, SEEK_SET); fread(&gc_hdr, sizeof(discHdr), 1, fp); fclose(fp); diff --git a/source/menu/menu_wbfs.cpp b/source/menu/menu_wbfs.cpp index b06f2dbf..99b51c89 100644 --- a/source/menu/menu_wbfs.cpp +++ b/source/menu/menu_wbfs.cpp @@ -377,14 +377,17 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op) case CMenu::WO_REMOVE_GAME: if(m_cf.getHdr()->type == TYPE_GC_GAME) { - char source[300]; - snprintf(source, sizeof(source), "%s/%s", fmt((currentPartition != SD) ? m_DMLgameDir.c_str() : DML_DIR, DeviceName[currentPartition]), (char *)m_cf.getHdr()->path); - fsop_deleteFolder(source); + string GC_Path(m_cf.getHdr()->path); + if(strcasestr(GC_Path.c_str(), "boot.bin") != NULL) + GC_Path.erase(GC_Path.end() - 13, GC_Path.end()); + else + GC_Path.erase(GC_Path.end() - 9, GC_Path.end()); + fsop_deleteFolder(GC_Path.c_str()); upd_dml = true; } else if(m_cf.getHdr()->type == TYPE_PLUGIN) { - fsop_deleteFile((char*)m_cf.getHdr()->path); + fsop_deleteFile(m_cf.getHdr()->path); upd_emu = true; } else if(m_cf.getHdr()->type == TYPE_WII_GAME) diff --git a/source/music/musicplayer.cpp b/source/music/musicplayer.cpp index bbf9b8b5..a35884c1 100644 --- a/source/music/musicplayer.cpp +++ b/source/music/musicplayer.cpp @@ -7,15 +7,13 @@ #include "gui/text.hpp" MusicPlayer m_music; -extern const u8 gc_ogg[]; -extern const u32 gc_ogg_size; void MusicPlayer::cleanup() { MusicFile.FreeMemory(); } -void MusicPlayer::Init(Config &cfg, string, string) +void MusicPlayer::Init(Config &cfg, string musicDir, string themeMusicDir) { m_stopped = true; m_fade_rate = cfg.getInt("GENERAL", "music_fade_rate", 8); @@ -23,6 +21,33 @@ void MusicPlayer::Init(Config &cfg, string, string) SetVolume(0); MusicFile.SetVoice(0); + m_music_files.clear(); + ScanDirectories(themeMusicDir.c_str()); + ScanDirectories(musicDir.c_str()); + + if(cfg.getBool("GENERAL", "randomize_music", true) && m_music_files.size() > 0) + { + srand(unsigned(time(NULL))); + random_shuffle(m_music_files.begin(), m_music_files.end()); + } + m_current_music = m_music_files.begin(); +} + +void MusicPlayer::ScanDirectories(const char *directory) +{ + struct dirent *pent = NULL; + DIR *pdir = opendir(directory); + while((pent = readdir(pdir)) != NULL) + { + if(strcmp(pent->d_name, ".") == 0 || strcmp(pent->d_name, "..") == 0) + continue; + string CurrentItem = sfmt("%s/%s", directory, pent->d_name); + if(fsop_DirExist(CurrentItem.c_str())) + ScanDirectories(CurrentItem.c_str()); + else if(strcasestr(pent->d_name, ".mp3") != NULL || strcasestr(pent->d_name, ".ogg") != NULL) + m_music_files.push_back(CurrentItem); + } + closedir(pdir); } void MusicPlayer::SetVolume(u8 volume) @@ -33,11 +58,25 @@ void MusicPlayer::SetVolume(u8 volume) void MusicPlayer::Previous() { + if(m_music_files.empty()) + return; + if(m_current_music == m_music_files.begin()) + m_current_music = m_music_files.end(); + + m_current_music--; + LoadCurrentFile(); } void MusicPlayer::Next() { + if(m_music_files.empty()) + return; + + m_current_music++; + if (m_current_music == m_music_files.end()) + m_current_music = m_music_files.begin(); + LoadCurrentFile(); } @@ -57,6 +96,8 @@ void MusicPlayer::Stop() void MusicPlayer::Tick(bool attenuate) { + if(m_music_files.empty()) + return; if(!attenuate && m_music_current_volume < m_music_volume) { SetVolume(m_music_current_volume + m_fade_rate > m_music_volume ? m_music_volume @@ -73,6 +114,6 @@ void MusicPlayer::Tick(bool attenuate) void MusicPlayer::LoadCurrentFile() { - MusicFile.Load(gc_ogg, gc_ogg_size, false); + MusicFile.Load((*m_current_music).c_str()); Play(); } diff --git a/source/music/musicplayer.h b/source/music/musicplayer.h index 80857b93..c666183d 100644 --- a/source/music/musicplayer.h +++ b/source/music/musicplayer.h @@ -35,6 +35,8 @@ protected: bool m_stopped; GuiSound MusicFile; + vector m_music_files; + vector::iterator m_current_music; }; extern MusicPlayer m_music;