# HG changeset patch # User sheepluva # Date 1319163086 -7200 # Node ID 62aa418ed214bc4ad85a32ede692a3e6d14ab5e3 # Parent fcb709d5541392f64a15aefa56ab049c31ad0af8 change SDL.h/SDL.cpp to use HWDataManager instead of poking around on the harddrive - also I added doc/comments to the class diff -r fcb709d55413 -r 62aa418ed214 QTfrontend/SDLs.cpp --- a/QTfrontend/SDLs.cpp Fri Oct 21 01:47:53 2011 +0200 +++ b/QTfrontend/SDLs.cpp Fri Oct 21 04:11:26 2011 +0200 @@ -20,7 +20,9 @@ #include "SDL.h" #include "SDL_mixer.h" -#include "hwconsts.h" + +#include "HWDataManager.h" + #include "HWApplication.h" @@ -29,7 +31,6 @@ extern char xb360dpad[128]; extern char xbox360axes[][128]; - SDLInteraction::SDLInteraction() { @@ -159,18 +160,17 @@ } } - void SDLInteraction::StartMusic() { SDLMusicInit(); - QFile tmpfile; + QFile * tmpFile = HWDataManager::instance().findFileForRead("Music/main_theme.ogg"); - tmpfile.setFileName(cfgdir->absolutePath() + "/Data/Music/main_theme.ogg"); - if (!tmpfile.exists()) tmpfile.setFileName(datadir->absolutePath() + "/Music/main_theme.ogg"); - if (music == NULL) { - music = Mix_LoadMUS(QFileInfo(tmpfile).absoluteFilePath().toLocal8Bit().constData()); + if (music == NULL) + music = Mix_LoadMUS(tmpFile->fileName().toLocal8Bit().constData()); - } + // this QFile isn't needed any further + delete tmpFile; + Mix_VolumeMusic(MIX_MAX_VOLUME - 28); Mix_FadeInMusic(music, -1, 1750); } diff -r fcb709d55413 -r 62aa418ed214 QTfrontend/SDLs.h --- a/QTfrontend/SDLs.h Fri Oct 21 01:47:53 2011 +0200 +++ b/QTfrontend/SDLs.h Fri Oct 21 04:11:26 2011 +0200 @@ -23,7 +23,7 @@ #include #include "SDL_mixer.h" - +/// Class for interacting with SDL (used for music and keys) class SDLInteraction : public QObject { Q_OBJECT @@ -33,12 +33,29 @@ int musicInitialized; public: + /// Class Constructor. SDLInteraction(); + + /// Class Destructor. ~SDLInteraction(); + + /** + * @brief Returns available (screen) resolutions. + * + * @return list of resolutions in the format WIDTHxHEIGHT. + */ QStringList getResolutions() const; + + /// Adds all available joystick controlls to the list of SDL keys. void addGameControllerKeys() const; + + /// Starts the background music. void StartMusic(); + + /// Fades out and stops the background music. void StopMusic(); + + /// Initializes SDL for playing music. void SDLMusicInit(); };