QTfrontend/util/SDLInteraction.h
changeset 6166 701c5b8fac56
parent 6165 6fe3e922246e
child 6167 728cabee2c9f
equal deleted inserted replaced
6165:6fe3e922246e 6166:701c5b8fac56
    43      * @see <a href="http://en.wikipedia.org/wiki/Singleton_pattern">singleton pattern</a>
    43      * @see <a href="http://en.wikipedia.org/wiki/Singleton_pattern">singleton pattern</a>
    44      */
    44      */
    45     SDLInteraction();
    45     SDLInteraction();
    46 
    46 
    47     /// Initializes SDL for sound output if needed.
    47     /// Initializes SDL for sound output if needed.
    48     void SDLSoundInit();
    48     void SDLAudioInit();
    49 
    49 
    50     Mix_Music *music;
    50     bool m_audioInitialized; ///< true if audio is initialized already
    51     int musicInitialized;
    51     Mix_Music * m_music; ///< pointer to the music channel of the mixer
       
    52     QString m_musicTrack; ///< path to the music track;
       
    53     bool m_isPlayingMusic; ///< true if music was started but not stopped again.
    52 
    54 
    53     QMap<QString,Mix_Chunk*> * soundMap; ///< maps sound file paths to channel
    55 
       
    56     QMap<QString,Mix_Chunk*> * soundMap; ///< maps sound file paths to channels
    54 
    57 
    55 public:
    58 public:
    56     /**
    59     /**
    57      * @brief Returns reference to the <i>singleton</i> instance of this class.
    60      * @brief Returns reference to the <i>singleton</i> instance of this class.
    58      * 
    61      *
    59      * @see <a href="http://en.wikipedia.org/wiki/Singleton_pattern">singleton pattern</a>
    62      * @see <a href="http://en.wikipedia.org/wiki/Singleton_pattern">singleton pattern</a>
    60      * 
    63      *
    61      * @return reference to the instance.
    64      * @return reference to the instance.
    62      */
    65      */
    63     static SDLInteraction & instance();
    66     static SDLInteraction & instance();
    64 
    67 
    65     /// Class Destructor.
    68     /// Class Destructor.
    75     /// Adds all available joystick controlls to the list of SDL keys.
    78     /// Adds all available joystick controlls to the list of SDL keys.
    76     void addGameControllerKeys() const;
    79     void addGameControllerKeys() const;
    77 
    80 
    78     /**
    81     /**
    79      * @brief Plays a sound file.
    82      * @brief Plays a sound file.
    80      * 
    83      *
    81      * @param soundFile path of the sound file.
    84      * @param soundFile path of the sound file.
    82      */
    85      */
    83     void playSoundFile(const QString & soundFile);
    86     void playSoundFile(const QString & soundFile);
    84 
    87 
    85     /// Starts the background music.
    88     /**
       
    89      * @brief Sets the music track to be played (or not).
       
    90      *
       
    91      * @param soundFile path of the music file.
       
    92      */
       
    93     void setMusicTrack(const QString & musicFile);
       
    94 
       
    95     /// Starts the background music if not already playing.
    86     void startMusic();
    96     void startMusic();
    87 
    97 
    88     /// Fades out and stops the background music.
    98     /// Fades out and stops the background music (if playing).
    89     void stopMusic();
    99     void stopMusic();
    90 };
   100 };
    91 
   101 
    92 
   102 
    93 #endif //HEDGEWARS_SDLINTERACTION_H
   103 #endif //HEDGEWARS_SDLINTERACTION_H