- Set frontend's music volume level to 50%
authorunc0rr
Fri, 29 Aug 2008 19:40:37 +0000
changeset 1235 070629f3902d
parent 1234 1091e2f12751
child 1236 f9110fd03754
- Set frontend's music volume level to 50% - Aware frontend of "Enable music" checkbox state - Don't load soundtrack if music is off
QTfrontend/SDLs.cpp
QTfrontend/gameuiconfig.cpp
QTfrontend/hwform.cpp
QTfrontend/hwform.h
share/hedgewars/Data/Maps/Sheep/CMakeLists.txt
--- a/QTfrontend/SDLs.cpp	Mon Aug 25 18:30:06 2008 +0000
+++ b/QTfrontend/SDLs.cpp	Fri Aug 29 19:40:37 2008 +0000
@@ -23,12 +23,13 @@
 
 SDLInteraction::SDLInteraction()
 {
+	music = NULL;
+
 	SDL_Init(SDL_INIT_VIDEO);
 	SDL_Init(SDL_INIT_AUDIO);
 	Mix_OpenAudio(22050, 0x8010, 2, 512);
 	
-	Mix_Volume(-1, 50);
-	music = Mix_LoadMUS(QString(datadir->absolutePath() + "/Music/main theme.ogg").toAscii().constData());
+	Mix_VolumeMusic(50);
 }
 
 SDLInteraction::~SDLInteraction()
@@ -58,6 +59,9 @@
 }
 void SDLInteraction::StartMusic()
 {
+	if (!music)
+		music = Mix_LoadMUS(QString(datadir->absolutePath() + "/Music/main theme.ogg").toAscii().constData());
+
 	Mix_FadeInMusic(music, -1, 3000);
 }
 
--- a/QTfrontend/gameuiconfig.cpp	Mon Aug 25 18:30:06 2008 +0000
+++ b/QTfrontend/gameuiconfig.cpp	Fri Aug 29 19:40:37 2008 +0000
@@ -33,6 +33,8 @@
 {
 	Form = FormWidgets;
 
+	connect(Form->ui.pageOptions->CBEnableMusic, SIGNAL(toggled(bool)), Form, SLOT(Music(bool)));
+
 	//Form->resize(value("window/width", 640).toUInt(), value("window/height", 450).toUInt());
 	resizeToConfigValues();
 
--- a/QTfrontend/hwform.cpp	Mon Aug 25 18:30:06 2008 +0000
+++ b/QTfrontend/hwform.cpp	Fri Aug 29 19:40:37 2008 +0000
@@ -27,6 +27,7 @@
 #include <QRadioButton>
 #include <QSpinBox>
 #include <QCloseEvent>
+#include <QCheckBox>
 
 #include "hwform.h"
 #include "game.h"
@@ -131,8 +132,6 @@
 		this, SLOT(GoBack())); // executed third
 
 	GoToPage(ID_PAGE_MAIN);
-
-	sdli.StartMusic();
 }
 
 void HWForm::onFrontendFullscreen(bool value)
@@ -688,3 +687,11 @@
 	config->SaveOptions();
 	event->accept();
 }
+
+void HWForm::Music(bool checked)
+{
+	if (checked)
+		sdli.StartMusic();
+	else
+		sdli.StopMusic();
+}
--- a/QTfrontend/hwform.h	Mon Aug 25 18:30:06 2008 +0000
+++ b/QTfrontend/hwform.h	Fri Aug 29 19:40:37 2008 +0000
@@ -85,6 +85,7 @@
 	void UpdateWeapons();
 	void NetWeaponNameChanged(const QString& name);
 	void onFrontendFullscreen(bool value);
+	void Music(bool checked);
 
 private:
 	void _NetConnect(const QString & hostName, quint16 port, const QString & nick);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Maps/Sheep/CMakeLists.txt	Fri Aug 29 19:40:37 2008 +0000
@@ -0,0 +1,5 @@
+install(FILES
+	map.png
+	map.cfg
+	DESTINATION ${SHAREPATH}Data/Maps/Sheep)
+