diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index b22dc3b0..68d63670 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -489,7 +489,8 @@ void CMenu::cleanup() { if(cleaned_up) return; - gprintf("MEM1_freesize(): %i\nMEM2_freesize(): %i\n", MEM1_freesize(), MEM2_freesize()); + //gprintf("MEM1_freesize(): %i\nMEM2_freesize(): %i\n", MEM1_freesize(), MEM2_freesize()); + m_btnMgr.hide(m_mainLblCurMusic); _cleanupDefaultFont(); m_banner->DeleteBanner(); m_plugin.Cleanup(); @@ -531,7 +532,7 @@ void CMenu::cleanup() theme.soundSet.clear(); cleaned_up = true; - gprintf(" \nMemory cleaned up\n"); + //gprintf(" \nMemory cleaned up\n"); gprintf("MEM1_freesize(): %i\nMEM2_freesize(): %i\n", MEM1_freesize(), MEM2_freesize()); } @@ -1905,6 +1906,18 @@ void CMenu::_mainLoopCommon(bool withCF, bool adjusting) m_music.Tick(m_video_playing || (m_gameSelected && m_gameSound.IsLoaded()) || m_gameSound.IsPlaying()); + if(m_music.SongChanged()) + { + m_btnMgr.setText(m_mainLblCurMusic, m_music.GetFileName(), true); + m_btnMgr.show(m_mainLblCurMusic); + m_music.DisplayTime = time(NULL); + } + else if(m_music.DisplayTime > 0 && time(NULL) - m_music.DisplayTime > 3) + { + m_music.DisplayTime = 0; + m_btnMgr.hide(m_mainLblCurMusic); + } + //Take Screenshot if(gc_btnsPressed & PAD_TRIGGER_Z) { diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index 81b2f4f5..533b268e 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -147,8 +147,9 @@ private: s16 m_mainBtnFavoritesOn; s16 m_mainBtnFavoritesOff; s16 m_mainLblLetter; + s16 m_mainLblCurMusic; #ifdef SHOWMEM - u32 m_mem2FreeSize; + s16 m_mem2FreeSize; #endif #ifdef SHOWMEMGECKO unsigned int mem1old; diff --git a/source/menu/menu_main.cpp b/source/menu/menu_main.cpp index 8d673102..28bf10f1 100644 --- a/source/menu/menu_main.cpp +++ b/source/menu/menu_main.cpp @@ -918,6 +918,7 @@ void CMenu::_initMainMenu(CMenu::SThemeData &theme) m_mainBtnFavoritesOff = _addPicButton(theme, "MAIN/FAVORITES_OFF", texFavOff, texFavOffS, 300, 400, 56, 56); m_mainLblLetter = _addLabel(theme, "MAIN/LETTER", theme.titleFont, L"", 540, 40, 80, 80, theme.titleFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, emptyTex); m_mainLblNotice = _addLabel(theme, "MAIN/NOTICE", theme.titleFont, L"", 340, 40, 280, 80, theme.titleFontColor, FTGX_JUSTIFY_RIGHT | FTGX_ALIGN_MIDDLE, emptyTex); + m_mainLblCurMusic = _addLabel(theme, "MAIN/MUSIC", theme.btnFont, L"", 0, 20, 640, 56, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, theme.btnTexC); #ifdef SHOWMEM m_mem2FreeSize = _addLabel(theme, "MEM2", theme.titleFont, L"", 40, 300, 480, 80, theme.titleFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, emptyTex); #endif @@ -970,6 +971,7 @@ void CMenu::_initMainMenu(CMenu::SThemeData &theme) _setHideAnim(m_mainLblInit, "MAIN/MESSAGE", 0, 0, 0.f, 0.f); _setHideAnim(m_mainLblLetter, "MAIN/LETTER", 0, 0, 0.f, 0.f); _setHideAnim(m_mainLblNotice, "MAIN/NOTICE", 0, 0, 0.f, 0.f); + _setHideAnim(m_mainLblCurMusic, "MAIN/MUSIC", 0, -100, 0.f, 0.f); #ifdef SHOWMEM _setHideAnim(m_mem2FreeSize, "MEM2", 0, 0, 0.f, 0.f); #endif diff --git a/source/music/gui_sound.cpp b/source/music/gui_sound.cpp index eb026924..b7ffcc19 100644 --- a/source/music/gui_sound.cpp +++ b/source/music/gui_sound.cpp @@ -174,7 +174,7 @@ bool GuiSound::Load(const char * filepath) fclose(f); SoundHandler::Instance()->AddDecoder(this->voice, filepath); - gprintf("gui_sound.cpp: Loading %s using voice %d\n", filepath, this->voice); + //gprintf("gui_sound.cpp: Loading %s using voice %d\n", filepath, this->voice); SoundDecoder * decoder = SoundHandler::Instance()->Decoder(this->voice); if(!decoder) { diff --git a/source/music/musicplayer.cpp b/source/music/musicplayer.cpp index 07cfadf9..c4177934 100644 --- a/source/music/musicplayer.cpp +++ b/source/music/musicplayer.cpp @@ -17,11 +17,15 @@ void MusicPlayer::cleanup() MusicFile.Stop(); MusicFile.FreeMemory(); m_music_files.clear(); + DisplayTime = 0; + m_changed = false; m_stopped = true; } void MusicPlayer::Init(Config &cfg, string musicDir, string themeMusicDir) { + DisplayTime = 0; + m_changed = false; m_stopped = true; CurrentPosition = 0; m_fade_rate = cfg.getInt("GENERAL", "music_fade_rate", 8); @@ -151,6 +155,25 @@ void MusicPlayer::Tick(bool attenuate) void MusicPlayer::LoadCurrentFile() { + m_changed = true; MusicFile.Load((*m_current_music).c_str()); Play(); } + +/* For our GUI */ +wstringEx MusicPlayer::GetFileName() +{ + wstringEx CurrentFile; + string CurrentFileStr((*m_current_music).begin()+(*m_current_music).find_last_of('/')+1, + (*m_current_music).begin()+(*m_current_music).find_last_of('.')); + CurrentFile.fromUTF8(CurrentFileStr.c_str()); + return CurrentFile; +} + +bool MusicPlayer::SongChanged() +{ + if(!m_changed) + return false; + m_changed = false; + return true; +} diff --git a/source/music/musicplayer.h b/source/music/musicplayer.h index 2950170d..d6d52b12 100644 --- a/source/music/musicplayer.h +++ b/source/music/musicplayer.h @@ -4,6 +4,7 @@ #include #include "gui_sound.h" #include "config/config.hpp" +#include "wstringEx/wstringEx.hpp" using namespace std; @@ -25,6 +26,10 @@ public: bool IsStopped() { return m_stopped; }; + /* For our GUI */ + wstringEx GetFileName(); + bool SongChanged(); + time_t DisplayTime; protected: void Play(); void Stop(); @@ -37,6 +42,7 @@ protected: u8 m_fade_rate; int CurrentPosition; bool m_stopped; + bool m_changed; GuiSound MusicFile; vector m_music_files;