5
#define THEMES_DIR "/usr/local/share/ultrastar-ng/themes/"
3
9
template<> CScreenManager* CSingleton<CScreenManager>::ms_CSingleton = NULL;
5
CScreenManager::CScreenManager( int _width , int _height , char * _songs_dir , char * _theme_name )
15
m_songs_dir = _songs_dir;
16
m_theme_name = _theme_name;
11
CScreenManager::CScreenManager(unsigned int width, unsigned int height, std::string const& theme):
19
24
CScreenManager::~CScreenManager()
24
for( unsigned int i = 0 ; i < screens.size() ; i++ )
28
void CScreenManager::activateScreen(char * name) {
29
for( unsigned int i = 0 ; i < screens.size() ; i++ )
30
if( !strcmp(screens[i]->getName(),name) ) {
31
if( currentScreen != NULL )
32
currentScreen->exit();
33
currentScreen=screens[i];
34
currentScreen->enter();
38
CScreen * CScreenManager::getScreen(char * name) {
39
for( unsigned int i = 0 ; i < screens.size() ; i++ )
40
if( !strcmp(screens[i]->getName(),name) )
45
void CScreenManager::getThemePathFile( char * dest , char * file)
47
if( m_theme_name[0] == '/' )
48
sprintf(dest,"%s/%s",m_theme_name,file);
50
sprintf(dest,"%s/%s/%s",THEMES_DIR,m_theme_name,file);
53
void CScreenManager::setPreviousSongId( void )
58
songId = songs->nbSongs()-1;
61
void CScreenManager::setNextSongId( void )
63
if( songId > songs->nbSongs()-2 )
30
void CScreenManager::activateScreen(std::string const& name) {
31
CScreen* s = getScreen(name);
32
if (currentScreen) currentScreen->exit();
34
currentScreen->enter();
37
CScreen* CScreenManager::getScreen(std::string const& name) {
39
return &screens.at(name);
40
} catch (boost::bad_ptr_container_operation&) {
41
throw std::invalid_argument("Screen " + name + " does not exist");
45
std::string CScreenManager::getThemePathFile(std::string const& file)
47
if (m_theme.empty()) throw std::logic_error("CScreenManager::getThemePathFile(): m_theme is empty");
48
return (*m_theme.rbegin() == '/' ? m_theme : THEMES_DIR + m_theme + "/") + file;