mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-12-24 02:41:55 +01:00
-smalled down the search for music files alot (dol = 5kb smaller)
This commit is contained in:
parent
5cef9d88e6
commit
f7929f2838
@ -123,7 +123,7 @@ bool fsop_FileExist(const char *fn)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool fsop_DirExist(char *path)
|
||||
bool fsop_DirExist(const char *path)
|
||||
{
|
||||
DIR *dir;
|
||||
|
||||
|
@ -13,7 +13,7 @@ u64 fsop_GetFolderBytes(char *source);
|
||||
u32 fsop_GetFolderKb(char *source);
|
||||
u32 fsop_GetFreeSpaceKb(char *path);
|
||||
bool fsop_FileExist(const char *fn);
|
||||
bool fsop_DirExist(char *path);
|
||||
bool fsop_DirExist(const char *path);
|
||||
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);
|
||||
|
@ -1,6 +1,10 @@
|
||||
#include "musicplayer.h"
|
||||
|
||||
using namespace std;
|
||||
#include <dirent.h>
|
||||
#include <cstdio>
|
||||
|
||||
#include "musicplayer.h"
|
||||
#include "fileOps/fileOps.h"
|
||||
#include "gui/text.hpp"
|
||||
|
||||
MusicPlayer m_music;
|
||||
|
||||
@ -17,15 +21,9 @@ void MusicPlayer::Init(Config &cfg, string musicDir, string themeMusicDir)
|
||||
|
||||
SetVolume(0);
|
||||
MusicFile.SetVoice(0);
|
||||
|
||||
MusicDirectory dir = (MusicDirectory)cfg.getInt("GENERAL", "music_directories", NORMAL_MUSIC | THEME_MUSIC);
|
||||
m_music_files.Init(cfg.getString("GENERAL", "dir_list_cache"), std::string(), std::string(), std::string(), false);
|
||||
|
||||
if(dir & THEME_MUSIC)
|
||||
m_music_files.Load(themeMusicDir, ".ogg|.mp3", "EN", cfg); //|.mod|.xm|.s3m|.wav|.aiff");
|
||||
|
||||
if(dir & NORMAL_MUSIC)
|
||||
m_music_files.Load(musicDir, ".ogg|.mp3", "EN", cfg); //|.mod|.xm|.s3m|.wav|.aiff");
|
||||
m_music_files.clear();
|
||||
ScanDirectories(themeMusicDir.c_str());
|
||||
ScanDirectories(musicDir.c_str());
|
||||
|
||||
if(cfg.getBool("GENERAL", "randomize_music", true) && m_music_files.size() > 0)
|
||||
{
|
||||
@ -35,6 +33,23 @@ void MusicPlayer::Init(Config &cfg, string musicDir, string themeMusicDir)
|
||||
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)
|
||||
{
|
||||
m_music_current_volume = volume;
|
||||
|
@ -4,19 +4,14 @@
|
||||
#include <string>
|
||||
#include "gui_sound.h"
|
||||
#include "config/config.hpp"
|
||||
#include "list/cachedlist.hpp"
|
||||
|
||||
enum MusicDirectory
|
||||
{
|
||||
NORMAL_MUSIC = 1,
|
||||
THEME_MUSIC = 2
|
||||
};
|
||||
using namespace std;
|
||||
|
||||
class MusicPlayer
|
||||
{
|
||||
public:
|
||||
void cleanup();
|
||||
void Init(Config &cfg, std::string musicDir, std::string themeMusicDir);
|
||||
void Init(Config &cfg, string musicDir, string themeMusicDir);
|
||||
void Tick(bool attenuate);
|
||||
|
||||
void SetVolume(u8 volume);
|
||||
@ -32,6 +27,7 @@ public:
|
||||
|
||||
protected:
|
||||
void LoadCurrentFile();
|
||||
void ScanDirectories(const char *directory);
|
||||
|
||||
u8 m_music_volume;
|
||||
u8 m_music_current_volume;
|
||||
@ -39,8 +35,8 @@ protected:
|
||||
bool m_stopped;
|
||||
|
||||
GuiSound MusicFile;
|
||||
CachedList<std::string> m_music_files;
|
||||
vector<std::string>::iterator m_current_music;
|
||||
vector<string> m_music_files;
|
||||
vector<string>::iterator m_current_music;
|
||||
};
|
||||
|
||||
extern MusicPlayer m_music;
|
||||
|
Loading…
Reference in New Issue
Block a user