mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-24 04:09:15 +01:00
-fixed last game you played was not selected
-fixed random codedumps when wiiflow loads a game banner -gave the cover loader a higher priority
This commit is contained in:
parent
484b8f3909
commit
6b47640bfb
@ -655,8 +655,7 @@ void CCoverFlow::startCoverLoader(void)
|
||||
m_loadingCovers = true;
|
||||
m_moved = true;
|
||||
|
||||
unsigned int stack_size = (unsigned int)8192;
|
||||
LWP_CreateThread(&coverLoaderThread, (void *(*)(void *))CCoverFlow::_coverLoader, (void *)this, 0, stack_size, 20);
|
||||
LWP_CreateThread(&coverLoaderThread, (void*(*)(void*))CCoverFlow::_coverLoader, (void*)this, NULL, 0, 30);
|
||||
//gprintf("Coverflow started!\n");
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ CMenu::CMenu()
|
||||
m_mutex = 0;
|
||||
m_showtimer = 0;
|
||||
m_gameSoundThread = LWP_THREAD_NULL;
|
||||
m_gameSoundHdr = NULL;
|
||||
m_soundThrdBusy = false;
|
||||
m_numCFVersions = 0;
|
||||
m_bgCrossFade = 0;
|
||||
m_bnrSndVol = 0;
|
||||
@ -498,7 +498,6 @@ void CMenu::cleanup()
|
||||
_Theme_Cleanup();
|
||||
MusicPlayer.Cleanup();
|
||||
m_gameSound.FreeMemory();
|
||||
ClearGameSoundThreadStack();
|
||||
SoundHandle.Cleanup();
|
||||
soundDeinit();
|
||||
|
||||
@ -648,10 +647,10 @@ void CMenu::_loadCFCfg()
|
||||
m_cf.setBufferSize(m_cfg.getInt("GENERAL", "cover_buffer", 20));
|
||||
// Coverflow Sounds
|
||||
m_cf.setSounds(
|
||||
new GuiSound(sfmt("%s/%s", m_themeDataDir.c_str(), m_theme.getString(domain, "sound_flip").c_str())),
|
||||
_sound(theme.soundSet, domain, "sound_hover", hover_wav, hover_wav_size, string("default_btn_hover"), false),
|
||||
_sound(theme.soundSet, domain, "sound_select", click_wav, click_wav_size, string("default_btn_click"), false),
|
||||
new GuiSound(sfmt("%s/%s", m_themeDataDir.c_str(), m_theme.getString(domain, "sound_cancel").c_str()))
|
||||
new GuiSound(fmt("%s/%s", m_themeDataDir.c_str(), m_theme.getString(domain, "sound_flip").c_str())),
|
||||
_sound(theme.soundSet, domain, "sound_hover", hover_wav, hover_wav_size, "default_btn_hover", false),
|
||||
_sound(theme.soundSet, domain, "sound_select", click_wav, click_wav_size, "default_btn_click", false),
|
||||
new GuiSound(fmt("%s/%s", m_themeDataDir.c_str(), m_theme.getString(domain, "sound_cancel").c_str()))
|
||||
);
|
||||
// Textures
|
||||
string texLoading = sfmt("%s/%s", m_themeDataDir.c_str(), m_theme.getString(domain, "loading_cover_box").c_str());
|
||||
@ -956,9 +955,9 @@ void CMenu::_buildMenus(void)
|
||||
theme.selubtnFontColor = m_theme.getColor("GENERAL", "selubtn_font_color", 0xD0BFDFFF);
|
||||
|
||||
// Default Sounds
|
||||
theme.clickSound = _sound(theme.soundSet, "GENERAL", "click_sound", click_wav, click_wav_size, string("default_btn_click"), false);
|
||||
theme.hoverSound = _sound(theme.soundSet, "GENERAL", "hover_sound", hover_wav, hover_wav_size, string("default_btn_hover"), false);
|
||||
theme.cameraSound = _sound(theme.soundSet, "GENERAL", "camera_sound", camera_wav, camera_wav_size, string("default_camera"), false);
|
||||
theme.clickSound = _sound(theme.soundSet, "GENERAL", "click_sound", click_wav, click_wav_size, "default_btn_click", false);
|
||||
theme.hoverSound = _sound(theme.soundSet, "GENERAL", "hover_sound", hover_wav, hover_wav_size, "default_btn_hover", false);
|
||||
theme.cameraSound = _sound(theme.soundSet, "GENERAL", "camera_sound", camera_wav, camera_wav_size, "default_camera", false);
|
||||
|
||||
// Default textures
|
||||
theme.btnTexL.fromPNG(butleft_png);
|
||||
@ -1284,39 +1283,40 @@ STexture CMenu::_texture(const char *domain, const char *key, STexture &def, boo
|
||||
}
|
||||
|
||||
// Only for loading defaults and GENERAL domains!!
|
||||
GuiSound *CMenu::_sound(CMenu::SoundSet &soundSet, const char *domain, const char *key, const u8 * snd, u32 len, string name, bool isAllocated)
|
||||
GuiSound *CMenu::_sound(CMenu::SoundSet &soundSet, const char *domain, const char *key, const u8 * snd, u32 len, const char *name, bool isAllocated)
|
||||
{
|
||||
string filename = m_theme.getString(domain, key, "");
|
||||
if (filename.empty()) filename = name;
|
||||
const char *filename = m_theme.getString(domain, key, "").c_str();
|
||||
if(filename == NULL)
|
||||
filename = name;
|
||||
|
||||
CMenu::SoundSet::iterator i = soundSet.find(upperCase(filename.c_str()));
|
||||
CMenu::SoundSet::iterator i = soundSet.find(upperCase(filename));
|
||||
if(i == soundSet.end())
|
||||
{
|
||||
if(strncmp(filename.c_str(), name.c_str(), name.size()) != 0)
|
||||
soundSet[upperCase(filename.c_str())] = new GuiSound(fmt("%s/%s", m_themeDataDir.c_str(), filename.c_str()));
|
||||
if(strncmp(filename, name, strlen(name) != 0))
|
||||
soundSet[upperCase(filename)] = new GuiSound(fmt("%s/%s", m_themeDataDir.c_str(), filename));
|
||||
else
|
||||
soundSet[upperCase(filename.c_str())] = new GuiSound(snd, len, filename, isAllocated);
|
||||
return soundSet[upperCase(filename.c_str())];
|
||||
soundSet[upperCase(filename)] = new GuiSound(snd, len, filename, isAllocated);
|
||||
return soundSet[upperCase(filename)];
|
||||
}
|
||||
return i->second;
|
||||
}
|
||||
|
||||
//For buttons and labels only!!
|
||||
GuiSound *CMenu::_sound(CMenu::SoundSet &soundSet, const char *domain, const char *key, string name)
|
||||
GuiSound *CMenu::_sound(CMenu::SoundSet &soundSet, const char *domain, const char *key, const char *name)
|
||||
{
|
||||
string filename = m_theme.getString(domain, key);
|
||||
if (filename.empty())
|
||||
const char *filename = m_theme.getString(domain, key).c_str();
|
||||
if(filename == NULL)
|
||||
{
|
||||
if(name.find_last_of('/') != string::npos)
|
||||
name = name.substr(name.find_last_of('/')+1);
|
||||
return soundSet[upperCase(name.c_str())]; // General/Default are already cached!
|
||||
if(strrchr(name, '/') != NULL)
|
||||
name = strrchr(name, '/') + 1;
|
||||
return soundSet[upperCase(name)]; // General/Default are already cached!
|
||||
}
|
||||
|
||||
SoundSet::iterator i = soundSet.find(upperCase(filename.c_str()));
|
||||
SoundSet::iterator i = soundSet.find(upperCase(filename));
|
||||
if(i == soundSet.end())
|
||||
{
|
||||
soundSet[upperCase(filename.c_str())] = new GuiSound(fmt("%s/%s", m_themeDataDir.c_str(), filename.c_str()));
|
||||
return soundSet[upperCase(filename.c_str())];
|
||||
soundSet[upperCase(filename)] = new GuiSound(fmt("%s/%s", m_themeDataDir.c_str(), filename));
|
||||
return soundSet[upperCase(filename)];
|
||||
}
|
||||
return i->second;
|
||||
}
|
||||
@ -1907,9 +1907,10 @@ void CMenu::_initCF(void)
|
||||
m_cf.setBufferSize(m_cfg.getInt("GENERAL", "cover_buffer", 20));
|
||||
m_cf.setSorting((Sorting)m_cfg.getInt(domain, "sort", 0));
|
||||
m_cf.setHQcover(m_cfg.getBool("GENERAL", "cover_use_hq", false));
|
||||
|
||||
m_cf.start();
|
||||
if (m_curGameId.empty() || !m_cf.findId(m_curGameId.c_str(), true))
|
||||
m_cf.findId(m_cfg.getString(domain, "current_item").c_str(), true);
|
||||
m_cf.start();
|
||||
}
|
||||
|
||||
void CMenu::_mainLoopCommon(bool withCF, bool adjusting)
|
||||
@ -1975,7 +1976,7 @@ void CMenu::_mainLoopCommon(bool withCF, bool adjusting)
|
||||
if(Sys_Exiting())
|
||||
exitHandler(BUTTON_CALLBACK);
|
||||
|
||||
if(withCF && m_gameSelected && m_gamesound_changed && (m_gameSoundHdr == NULL) && !m_gameSound.IsPlaying() && MusicPlayer.GetVolume() == 0)
|
||||
if(withCF && m_gameSelected && m_gamesound_changed && !m_soundThrdBusy && !m_gameSound.IsPlaying() && MusicPlayer.GetVolume() == 0)
|
||||
{
|
||||
CheckGameSoundThread();
|
||||
m_gameSound.Play(m_bnrSndVol);
|
||||
|
@ -63,7 +63,6 @@ private:
|
||||
Config m_theme;
|
||||
Config m_titles;
|
||||
Config m_version;
|
||||
Plugin m_plugin;
|
||||
vector<string> m_homebrewArgs;
|
||||
u8 *m_base_font;
|
||||
u32 m_base_font_size;
|
||||
@ -661,7 +660,7 @@ private:
|
||||
volatile bool m_thrdMessageAdded;
|
||||
volatile bool m_gameSelected;
|
||||
GuiSound m_gameSound;
|
||||
dir_discHdr *m_gameSoundHdr;
|
||||
volatile bool m_soundThrdBusy;
|
||||
lwp_t m_gameSoundThread;
|
||||
bool m_gamesound_changed;
|
||||
u8 m_bnrSndVol;
|
||||
@ -1004,8 +1003,8 @@ public:
|
||||
void _hideWaitMessage();
|
||||
bool m_Emulator_boot;
|
||||
private:
|
||||
GuiSound *_sound(CMenu::SoundSet &soundSet, const char *domain, const char *key, const u8 * snd, u32 len, string name, bool isAllocated);
|
||||
GuiSound *_sound(CMenu::SoundSet &soundSet, const char *domain, const char *key, string name);
|
||||
GuiSound *_sound(CMenu::SoundSet &soundSet, const char *domain, const char *key, const u8 * snd, u32 len, const char *name, bool isAllocated);
|
||||
GuiSound *_sound(CMenu::SoundSet &soundSet, const char *domain, const char *key, const char *name);
|
||||
u16 _textStyle(const char *domain, const char *key, u16 def);
|
||||
s16 _addButton(const char *domain, SFont font, const wstringEx &text, int x, int y, u32 width, u32 height, const CColor &color);
|
||||
s16 _addSelButton(const char *domain, SFont font, const wstringEx &text, int x, int y, u32 width, u32 height, const CColor &color);
|
||||
@ -1065,7 +1064,6 @@ private:
|
||||
|
||||
void _playGameSound(void);
|
||||
void CheckGameSoundThread(void);
|
||||
void ClearGameSoundThreadStack(void);
|
||||
static void _gameSoundThread(CMenu *m);
|
||||
|
||||
static void _load_installed_cioses();
|
||||
|
@ -421,7 +421,6 @@ void CMenu::_game(bool launch)
|
||||
{
|
||||
m_gameSound.FreeMemory();
|
||||
CheckGameSoundThread();
|
||||
ClearGameSoundThreadStack();
|
||||
m_banner.DeleteBanner();
|
||||
break;
|
||||
}
|
||||
@ -509,7 +508,6 @@ void CMenu::_game(bool launch)
|
||||
{
|
||||
m_gameSound.FreeMemory();
|
||||
CheckGameSoundThread();
|
||||
ClearGameSoundThreadStack();
|
||||
m_banner.DeleteBanner();
|
||||
break;
|
||||
}
|
||||
@ -527,7 +525,6 @@ void CMenu::_game(bool launch)
|
||||
{
|
||||
m_gameSound.FreeMemory();
|
||||
CheckGameSoundThread();
|
||||
ClearGameSoundThreadStack();
|
||||
m_banner.DeleteBanner();
|
||||
break;
|
||||
}
|
||||
@ -556,7 +553,6 @@ void CMenu::_game(bool launch)
|
||||
MusicPlayer.Stop();
|
||||
m_gameSound.FreeMemory();
|
||||
CheckGameSoundThread();
|
||||
ClearGameSoundThreadStack();
|
||||
m_banner.DeleteBanner();
|
||||
dir_discHdr *hdr = m_cf.getHdr();
|
||||
m_gcfg2.load(fmt("%s/" GAME_SETTINGS2_FILENAME, m_settingsDir.c_str()));
|
||||
@ -1466,19 +1462,20 @@ struct IMD5Header
|
||||
u8 crypto[16];
|
||||
} __attribute__((packed));
|
||||
|
||||
u8 *gameSoundThreadStack;
|
||||
u32 gameSoundThreadStackSize = (u32)32768;
|
||||
void CMenu::_gameSoundThread(CMenu *m)
|
||||
{
|
||||
CurrentBanner.ClearBanner();
|
||||
m->m_gameSoundHdr = m->m_cf.getHdr();
|
||||
m->m_soundThrdBusy = true;
|
||||
m->m_gamesound_changed = false;
|
||||
if(m->m_cf.getHdr()->type == TYPE_PLUGIN)
|
||||
CurrentBanner.ClearBanner();
|
||||
|
||||
dir_discHdr *GameHdr = m->m_cf.getHdr();
|
||||
if(GameHdr->type == TYPE_PLUGIN)
|
||||
{
|
||||
m_banner.DeleteBanner();
|
||||
m->m_gameSound.Load(m->m_plugin.GetBannerSound(m->m_cf.getHdr()->settings[0]), m->m_plugin.GetBannerSoundSize());
|
||||
m->m_gameSound.Load(m_plugin.GetBannerSound(GameHdr->settings[0]), m_plugin.GetBannerSoundSize());
|
||||
if(m->m_gameSound.IsLoaded())
|
||||
m->m_gamesound_changed = true;
|
||||
m->m_gameSoundHdr = NULL;
|
||||
m->m_soundThrdBusy = false;
|
||||
return;
|
||||
}
|
||||
bool custom = false;
|
||||
@ -1491,7 +1488,7 @@ void CMenu::_gameSoundThread(CMenu *m)
|
||||
|
||||
char cached_banner[256];
|
||||
cached_banner[255] = '\0';
|
||||
strncpy(cached_banner, fmt("%s/%.6s.bnr", m->m_bnrCacheDir.c_str(), m->m_cf.getHdr()->id), 255);
|
||||
strncpy(cached_banner, fmt("%s/%.6s.bnr", m->m_bnrCacheDir.c_str(), GameHdr->id), 255);
|
||||
FILE *fp = fopen(cached_banner, "rb");
|
||||
if(fp)
|
||||
{
|
||||
@ -1504,7 +1501,7 @@ void CMenu::_gameSoundThread(CMenu *m)
|
||||
{
|
||||
m->m_gameSound.FreeMemory();
|
||||
m_banner.DeleteBanner();
|
||||
m->m_gameSoundHdr = NULL;
|
||||
m->m_soundThrdBusy = false;
|
||||
return;
|
||||
}
|
||||
fread(cached_bnr_file, 1, cached_bnr_size, fp);
|
||||
@ -1514,11 +1511,11 @@ void CMenu::_gameSoundThread(CMenu *m)
|
||||
{
|
||||
char custom_banner[256];
|
||||
custom_banner[255] = '\0';
|
||||
strncpy(custom_banner, fmt("%s/%.6s.bnr", m->m_customBnrDir.c_str(), m->m_cf.getHdr()->id), 255);
|
||||
strncpy(custom_banner, fmt("%s/%.6s.bnr", m->m_customBnrDir.c_str(), GameHdr->id), 255);
|
||||
FILE *fp = fopen(custom_banner, "rb");
|
||||
if(!fp)
|
||||
{
|
||||
strncpy(custom_banner, fmt("%s/%.3s.bnr", m->m_customBnrDir.c_str(), m->m_cf.getHdr()->id), 255);
|
||||
strncpy(custom_banner, fmt("%s/%.3s.bnr", m->m_customBnrDir.c_str(), GameHdr->id), 255);
|
||||
fp = fopen(custom_banner, "rb");
|
||||
}
|
||||
if(fp)
|
||||
@ -1532,23 +1529,25 @@ void CMenu::_gameSoundThread(CMenu *m)
|
||||
{
|
||||
m->m_gameSound.FreeMemory();
|
||||
m_banner.DeleteBanner();
|
||||
m->m_gameSoundHdr = NULL;
|
||||
m->m_soundThrdBusy = false;
|
||||
return;
|
||||
}
|
||||
fread(custom_bnr_file, 1, custom_bnr_size, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
if(!fp && m->m_cf.getHdr()->type == TYPE_GC_GAME)
|
||||
if(!fp && GameHdr->type == TYPE_GC_GAME)
|
||||
{
|
||||
GC_Disc disc;
|
||||
disc.init(m->m_cf.getHdr()->path);
|
||||
disc.init(GameHdr->path);
|
||||
u8 *opening_bnr = disc.GetGameCubeBanner();
|
||||
if(opening_bnr != NULL)
|
||||
m_banner.CreateGCBanner(opening_bnr, m->m_wbf1_font, m->m_wbf2_font, m->m_cf.getHdr()->title);
|
||||
m->m_gameSound.Load(gc_ogg, gc_ogg_size, false);
|
||||
m->m_gamesound_changed = true;
|
||||
m->m_gameSoundHdr = NULL;
|
||||
m_banner.CreateGCBanner(opening_bnr, m->m_wbf1_font, m->m_wbf2_font, GameHdr->title);
|
||||
disc.clear();
|
||||
|
||||
m->m_gameSound.Load(gc_ogg, gc_ogg_size, false);
|
||||
if(m->m_gameSound.IsLoaded())
|
||||
m->m_gamesound_changed = true;
|
||||
m->m_soundThrdBusy = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1559,17 +1558,17 @@ void CMenu::_gameSoundThread(CMenu *m)
|
||||
CurrentBanner.SetBanner(cached_bnr_file, cached_bnr_size);
|
||||
else if(custom)
|
||||
CurrentBanner.SetBanner(custom_bnr_file, custom_bnr_size, 0, true);
|
||||
else if(m->m_gameSoundHdr->type == TYPE_WII_GAME)
|
||||
_extractBnr(m->m_gameSoundHdr);
|
||||
else if(m->m_gameSoundHdr->type == TYPE_CHANNEL)
|
||||
_extractChannelBnr(TITLE_ID(m->m_gameSoundHdr->settings[0],
|
||||
m->m_gameSoundHdr->settings[1]));
|
||||
else if(GameHdr->type == TYPE_WII_GAME)
|
||||
_extractBnr(GameHdr);
|
||||
else if(GameHdr->type == TYPE_CHANNEL)
|
||||
_extractChannelBnr(TITLE_ID(GameHdr->settings[0],
|
||||
GameHdr->settings[1]));
|
||||
if(!CurrentBanner.IsValid())
|
||||
{
|
||||
m->m_gameSound.FreeMemory();
|
||||
m_banner.DeleteBanner();
|
||||
m->m_gameSoundHdr = NULL;
|
||||
CurrentBanner.ClearBanner();
|
||||
m->m_soundThrdBusy = false;
|
||||
return;
|
||||
}
|
||||
if(!custom && !cached && CurrentBanner.GetBannerFileSize() > 0)
|
||||
@ -1592,7 +1591,7 @@ void CMenu::_gameSoundThread(CMenu *m)
|
||||
{
|
||||
m->m_gameSound.FreeMemory();
|
||||
m_banner.DeleteBanner();
|
||||
m->m_gameSoundHdr = NULL;
|
||||
m->m_soundThrdBusy = false;
|
||||
return;
|
||||
}
|
||||
free(soundBin);
|
||||
@ -1614,7 +1613,7 @@ void CMenu::_gameSoundThread(CMenu *m)
|
||||
m->m_gamesound_changed = true;
|
||||
m->m_gameSound.FreeMemory();
|
||||
}
|
||||
m->m_gameSoundHdr = NULL;
|
||||
m->m_soundThrdBusy = false;
|
||||
}
|
||||
|
||||
void CMenu::_playGameSound(void)
|
||||
@ -1625,9 +1624,7 @@ void CMenu::_playGameSound(void)
|
||||
|
||||
if(m_gameSoundThread != LWP_THREAD_NULL)
|
||||
CheckGameSoundThread();
|
||||
if(gameSoundThreadStack == NULL)
|
||||
gameSoundThreadStack = (u8*)MEM2_alloc(gameSoundThreadStackSize);
|
||||
LWP_CreateThread(&m_gameSoundThread, (void *(*)(void *))CMenu::_gameSoundThread, (void *)this, gameSoundThreadStack, gameSoundThreadStackSize, 60);
|
||||
LWP_CreateThread(&m_gameSoundThread, (void *(*)(void *))CMenu::_gameSoundThread, (void *)this, NULL, 0, 60);
|
||||
}
|
||||
|
||||
void CMenu::CheckGameSoundThread()
|
||||
@ -1638,18 +1635,9 @@ void CMenu::CheckGameSoundThread()
|
||||
if(LWP_ThreadIsSuspended(m_gameSoundThread))
|
||||
LWP_ResumeThread(m_gameSoundThread);
|
||||
|
||||
while(m_gameSoundHdr != NULL)
|
||||
while(m_soundThrdBusy)
|
||||
usleep(50);
|
||||
|
||||
LWP_JoinThread(m_gameSoundThread, NULL);
|
||||
m_gameSoundThread = LWP_THREAD_NULL;
|
||||
}
|
||||
|
||||
void CMenu::ClearGameSoundThreadStack()
|
||||
{
|
||||
if(gameSoundThreadStack != NULL)
|
||||
{
|
||||
free(gameSoundThreadStack);
|
||||
gameSoundThreadStack = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -82,19 +82,25 @@ GuiSound::GuiSound()
|
||||
Init();
|
||||
}
|
||||
|
||||
GuiSound::GuiSound(string filepath, int v)
|
||||
GuiSound::GuiSound(const char *path, int v)
|
||||
{
|
||||
if(path == NULL)
|
||||
return;
|
||||
this->voice = v;
|
||||
Init();
|
||||
Load(filepath.c_str());
|
||||
Load(path);
|
||||
}
|
||||
|
||||
GuiSound::GuiSound(const u8 * snd, u32 len, string name, bool isallocated, int v)
|
||||
GuiSound::GuiSound(const u8 * snd, u32 len, const char *name, bool isallocated, int v)
|
||||
{
|
||||
this->voice = v;
|
||||
Init();
|
||||
Load(snd, len, isallocated);
|
||||
this->filepath = name;
|
||||
if(name != NULL)
|
||||
{
|
||||
strncpy(this->filepath, name, 255);
|
||||
this->filepath[255] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
GuiSound::GuiSound(GuiSound *g)
|
||||
@ -112,7 +118,7 @@ GuiSound::GuiSound(GuiSound *g)
|
||||
Load(snd, g->length, true);
|
||||
}
|
||||
else
|
||||
Load(g->filepath.c_str());
|
||||
Load(g->filepath);
|
||||
}
|
||||
|
||||
GuiSound::~GuiSound()
|
||||
@ -123,6 +129,7 @@ GuiSound::~GuiSound()
|
||||
|
||||
void GuiSound::Init()
|
||||
{
|
||||
memset(this->filepath, 0, 256);
|
||||
sound = NULL;
|
||||
length = 0;
|
||||
|
||||
@ -148,29 +155,29 @@ void GuiSound::FreeMemory()
|
||||
if(allocated && sound != NULL)
|
||||
free(sound);
|
||||
allocated = false;
|
||||
memset(this->filepath, 0, 256);
|
||||
sound = NULL;
|
||||
length = 0;
|
||||
filepath = "";
|
||||
|
||||
SoundEffectLength = 0;
|
||||
}
|
||||
|
||||
bool GuiSound::Load(const char * filepath)
|
||||
bool GuiSound::Load(const char *path)
|
||||
{
|
||||
FreeMemory();
|
||||
|
||||
if(!filepath || filepath[strlen(filepath)-1] == '/' || strlen(filepath) < 4)
|
||||
if(path == NULL || path[strlen(path)-1] == '/')
|
||||
return false;
|
||||
|
||||
FILE * f = fopen(filepath, "rb");
|
||||
FILE *f = fopen(path, "rb");
|
||||
if(!f)
|
||||
{
|
||||
gprintf("gui_sound.cpp: Failed to load file %s!!\n", filepath);
|
||||
gprintf("gui_sound.cpp: Failed to load file %s!!\n", path);
|
||||
return false;
|
||||
}
|
||||
|
||||
SoundHandle.AddDecoder(this->voice, filepath);
|
||||
//gprintf("gui_sound.cpp: Loading %s using voice %d\n", filepath, this->voice);
|
||||
SoundHandle.AddDecoder(this->voice, path);
|
||||
//gprintf("gui_sound.cpp: Loading %s using voice %d\n", path, this->voice);
|
||||
SoundDecoder *decoder = SoundHandle.Decoder(this->voice);
|
||||
if(!decoder)
|
||||
{
|
||||
@ -185,7 +192,8 @@ bool GuiSound::Load(const char * filepath)
|
||||
return false;
|
||||
}
|
||||
|
||||
this->filepath = filepath;
|
||||
strncpy(this->filepath, path, 255);
|
||||
this->filepath[255] = '\0'; SetLoop(loop);
|
||||
SetLoop(loop);
|
||||
|
||||
return true;
|
||||
|
@ -40,14 +40,14 @@ public:
|
||||
//!Constructor
|
||||
//!\param sound Pointer to the sound data
|
||||
//!\param filesize Length of sound data
|
||||
GuiSound(std::string filepath, int voice = -1);
|
||||
GuiSound(const u8 * snd, u32 len, std::string name, bool allocated = false, int voice = -1);
|
||||
GuiSound(const char *path, int voice = -1);
|
||||
GuiSound(const u8 * snd, u32 len, const char *name, bool allocated = false, int voice = -1);
|
||||
//!Stops sound and frees all memory/closes files
|
||||
void FreeMemory();
|
||||
//!Destructor
|
||||
~GuiSound();
|
||||
//!Load a file and replace the old one
|
||||
bool Load(const char * filepath);
|
||||
bool Load(const char *path);
|
||||
//!Load a file and replace the old one
|
||||
bool Load(const u8 * snd, u32 len, bool allocated = true);
|
||||
//!For quick playback of the internal soundeffects
|
||||
@ -67,7 +67,7 @@ public:
|
||||
bool IsLoaded() { return sound != NULL; };
|
||||
//!Get the filepath for finding sounds which already have an instance.
|
||||
//!\return the current instance's filepath
|
||||
std::string GetName() { return filepath; };
|
||||
const char *GetName() { return filepath; };
|
||||
//!Checks if the sound is currently playing
|
||||
//!\return true if sound is playing, false otherwise
|
||||
bool IsPlaying();
|
||||
@ -89,7 +89,7 @@ private:
|
||||
//!Initializes the GuiSound object by setting the default values
|
||||
void Init();
|
||||
protected:
|
||||
std::string filepath;
|
||||
char filepath[256];
|
||||
u8 *sound; //!< Pointer to the sound data
|
||||
u32 length; //!< Length of sound data
|
||||
s8 voice; //!< Currently assigned ASND voice channel
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "types.h"
|
||||
#include "crc32.h"
|
||||
|
||||
Plugin m_plugin;
|
||||
void Plugin::init(const string& m_pluginsDir)
|
||||
{
|
||||
PluginMagicWord[8] = '\0';
|
||||
|
@ -79,4 +79,7 @@ private:
|
||||
string pluginsDir;
|
||||
bool adding;
|
||||
};
|
||||
|
||||
extern Plugin m_plugin;
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user