~ubuntu-branches/ubuntu/maverick/ultrastar-ng/maverick

« back to all changes in this revision

Viewing changes to src/screenmanager.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Miriam Ruiz, Miriam Ruiz, Mario Bonino, Jon Dowland, Ansgar Burchardt
  • Date: 2008-06-07 16:43:18 UTC
  • mfrom: (1.1.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20080607164318-spq0cnpt8mjhg1pj
[ Miriam Ruiz ]
* New Upstream Release (Closes: #453132)
* Removed unneeded patches
* Added packages to build deps:
  + libtool
  + portaudio19-dev | portaudio-dev
  + libboost-dev, libboost-thread-dev, libboost-serialization-dev
  + libboost-program-options-dev, libboost-regex-dev
* Moved shared objects to private directory: /usr/lib/ultraster-ng
* Added rpath to binaries to search for shared objects in the private dir
* Uses ultrastar-ng-gstreamer as default, instead of ultrastar-ng-xine,
  since there are significantly less issues with GStreamer.
* Added patch to fix upstream desktop file
* Added -Wl,-as-needed to LDFLAGS
* Replaced fftw3-dev by libfftw3-dev in build dependencies.
* Standards-Version upgraded to 3.7.3

[ Mario Bonino ]
* Fixed data/Makefile.am to install .desktop file and icon

[ Jon Dowland ]
* add Homepage: control field to source stanza
* fix a bashism in debian/rules (Closes: #478634)

[ Ansgar Burchardt ]
* debian/control: Change XS-Vcs-* to Vcs-*
* Remove Homepage semi-field from description

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include <screen.h>
 
2
#include <stdexcept>
 
3
 
 
4
#ifndef THEMES_DIR
 
5
#define THEMES_DIR "/usr/local/share/ultrastar-ng/themes/"
 
6
#endif
 
7
 
2
8
 
3
9
template<> CScreenManager* CSingleton<CScreenManager>::ms_CSingleton = NULL;
4
10
 
5
 
CScreenManager::CScreenManager( int _width , int _height , char * _songs_dir , char * _theme_name )
6
 
{
7
 
        m_finished=false;
8
 
        audio = NULL;
9
 
        record = NULL;
10
 
        songs = NULL;
11
 
        currentScreen = NULL;
12
 
        songId = 0;
13
 
        width = _width;
14
 
        height = _height;
15
 
        m_songs_dir = _songs_dir;
16
 
        m_theme_name = _theme_name;
17
 
}
 
11
CScreenManager::CScreenManager(unsigned int width, unsigned int height, std::string const& theme):
 
12
  m_finished(false),
 
13
  currentScreen(),
 
14
  screen(),
 
15
  audio(),
 
16
  songs(),
 
17
  videoDriver(),
 
18
  m_fullscreen(),
 
19
  m_width(width),
 
20
  m_height(height),
 
21
  m_theme(theme)
 
22
{}
18
23
 
19
24
CScreenManager::~CScreenManager()
20
25
{
21
26
        delete audio;
22
 
        delete record;
23
27
        delete songs;
24
 
        for( unsigned int i = 0 ; i < screens.size() ; i++ )
25
 
                delete screens[i];
26
 
}
27
 
 
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();
35
 
                }
36
 
}
37
 
 
38
 
CScreen * CScreenManager::getScreen(char * name) {
39
 
        for( unsigned int i = 0 ; i < screens.size() ; i++ )
40
 
                if( !strcmp(screens[i]->getName(),name) )
41
 
                        return screens[i];
42
 
        return NULL;
43
 
}
44
 
 
45
 
void CScreenManager::getThemePathFile( char * dest , char * file)
46
 
{
47
 
        if( m_theme_name[0] == '/' )
48
 
                sprintf(dest,"%s/%s",m_theme_name,file);
49
 
        else
50
 
                sprintf(dest,"%s/%s/%s",THEMES_DIR,m_theme_name,file);
51
 
}
52
 
 
53
 
void CScreenManager::setPreviousSongId( void )
54
 
{
55
 
        if( songId >0 )
56
 
                songId--;
57
 
        else
58
 
                songId = songs->nbSongs()-1;
59
 
}
60
 
 
61
 
void CScreenManager::setNextSongId( void )
62
 
{
63
 
        if( songId > songs->nbSongs()-2 )
64
 
                songId = 0;
65
 
        else
66
 
                songId++;
67
 
}
 
28
}
 
29
 
 
30
void CScreenManager::activateScreen(std::string const& name) {
 
31
        CScreen* s = getScreen(name);
 
32
        if (currentScreen) currentScreen->exit();
 
33
        currentScreen = s;
 
34
        currentScreen->enter();
 
35
}
 
36
 
 
37
CScreen* CScreenManager::getScreen(std::string const& name) {
 
38
        try {
 
39
                return &screens.at(name);
 
40
        } catch (boost::bad_ptr_container_operation&) {
 
41
                throw std::invalid_argument("Screen " + name + " does not exist");
 
42
        }
 
43
}
 
44
 
 
45
std::string CScreenManager::getThemePathFile(std::string const& file)
 
46
{
 
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;
 
49
}
 
50