change SDL.h/SDL.cpp to use HWDataManager instead of poking around on the harddrive - also I added doc/comments to the class
authorsheepluva
Fri, 21 Oct 2011 04:11:26 +0200
changeset 6164 62aa418ed214
parent 6163 fcb709d55413
child 6165 6fe3e922246e
change SDL.h/SDL.cpp to use HWDataManager instead of poking around on the harddrive - also I added doc/comments to the class
QTfrontend/SDLs.cpp
QTfrontend/SDLs.h
--- 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);
 }
--- 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 <QStringList>
 #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();
 };