fix a bug that prevented from hearing team voicepacks if frontend started with music disabled
authorkoda
Sun, 27 Sep 2009 22:25:27 +0000
changeset 2399 ddde0ac1472b
parent 2398 1b8dde74880c
child 2400 2422ea85d100
fix a bug that prevented from hearing team voicepacks if frontend started with music disabled
QTfrontend/CMakeLists.txt
QTfrontend/SDLs.cpp
QTfrontend/SDLs.h
QTfrontend/hwform.cpp
QTfrontend/hwform.h
--- a/QTfrontend/CMakeLists.txt	Sun Sep 27 20:25:49 2009 +0000
+++ b/QTfrontend/CMakeLists.txt	Sun Sep 27 22:25:27 2009 +0000
@@ -191,7 +191,7 @@
 		)
         if (SPARKLE_FOUND)
                 set(HW_LINK_LIBS ${HW_LINK_LIBS} ${SPARKLE_LIBRARY})
-                set(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS} "-DSPARKLE_ENABLED")
+                set(CMAKE_CXX_FLAGS -DSPARKLE_ENABLED)
         endif()
 endif()
 
--- a/QTfrontend/SDLs.cpp	Sun Sep 27 20:25:49 2009 +0000
+++ b/QTfrontend/SDLs.cpp	Sun Sep 27 22:25:27 2009 +0000
@@ -21,11 +21,12 @@
 #include "SDL.h"
 #include "hwconsts.h"
 
-SDLInteraction::SDLInteraction()
+SDLInteraction::SDLInteraction(bool hardware_snd)
 {
 	music = -1;
 
 	SDL_Init(SDL_INIT_VIDEO);
+        openal_init(hardware_snd ? 1 : 0, 5);
 
 }
 
@@ -56,10 +57,9 @@
 	return result;
 }
 
-void SDLInteraction::StartMusic(bool hardware)
+void SDLInteraction::StartMusic()
 {
 	if (music < 0) {
-		openal_init(hardware ? 1 : 0, 5);
 		music = openal_loadfile(QString(datadir->absolutePath() + "/Music/main theme.ogg").toLocal8Bit().constData());
 		openal_toggleloop(music);
 	
--- a/QTfrontend/SDLs.h	Sun Sep 27 20:25:49 2009 +0000
+++ b/QTfrontend/SDLs.h	Sun Sep 27 22:25:27 2009 +0000
@@ -44,10 +44,10 @@
 	int music;
 
 public:
-	SDLInteraction();
+	SDLInteraction(bool);
 	~SDLInteraction();
 	QStringList getResolutions() const;
-	void StartMusic(bool);
+	void StartMusic();
 	void StopMusic();
 };
 
--- a/QTfrontend/hwform.cpp	Sun Sep 27 20:25:49 2009 +0000
+++ b/QTfrontend/hwform.cpp	Sun Sep 27 22:25:27 2009 +0000
@@ -73,8 +73,10 @@
 	ui.setupUi(this);
 
 	CustomizePalettes();
-
-	ui.pageOptions->CBResolution->addItems(sdli.getResolutions());
+        
+        sdli = new SDLInteraction(ui.pageOptions->CBHardwareSound->isChecked());
+        
+	ui.pageOptions->CBResolution->addItems(sdli->getResolutions());
 
 	config = new GameUIConfig(this, cfgdir->absolutePath() + "/hedgewars.ini");
 
@@ -876,9 +878,9 @@
 void HWForm::Music(bool checked)
 {
 	if (checked)
-		sdli.StartMusic(ui.pageOptions->CBHardwareSound->isChecked());
+		sdli->StartMusic();
 	else
-		sdli.StopMusic();
+		sdli->StopMusic();
 }
 
 void HWForm::NetGameChangeStatus(bool isMaster)
--- a/QTfrontend/hwform.h	Sun Sep 27 20:25:49 2009 +0000
+++ b/QTfrontend/hwform.h	Sun Sep 27 22:25:27 2009 +0000
@@ -144,7 +144,7 @@
 	AmmoSchemeModel * ammoSchemeModel;
 	QStack<quint8> PagesStack;
 	QTime eggTimer;
-	SDLInteraction sdli;
+	SDLInteraction * sdli;
 	BGWidget * wBackground;
 	void OnPageShown(quint8 id, quint8 lastid=0);
 };