# HG changeset patch # User bovi # Date 1326664669 -3600 # Node ID 0d0af531c1c7e4674bb724c55c24e417ac9d8174 # Parent da5cfded818b649978c23e46375601b4cf7a5fa6 GCI task: ping diff -r da5cfded818b -r 0d0af531c1c7 QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Sun Jan 15 22:48:34 2012 +0100 +++ b/QTfrontend/hwform.cpp Sun Jan 15 22:57:49 2012 +0100 @@ -43,6 +43,7 @@ #include #include #include +#include #include "hwform.h" #include "game.h" @@ -101,6 +102,9 @@ bool frontendEffects = true; QString playerHash; +GameUIConfig* HWForm::config = NULL; +QSettings* HWForm::gameSettings = NULL; + HWForm::HWForm(QWidget *parent, QString styleSheet) : QMainWindow(parent) , game(0) @@ -131,7 +135,6 @@ config = new GameUIConfig(this, cfgdir->absolutePath() + "/hedgewars.ini"); - #ifdef __APPLE__ panel = new M3Panel; diff -r da5cfded818b -r 0d0af531c1c7 QTfrontend/hwform.h --- a/QTfrontend/hwform.h Sun Jan 15 22:48:34 2012 +0100 +++ b/QTfrontend/hwform.h Sun Jan 15 22:57:49 2012 +0100 @@ -60,8 +60,8 @@ public: HWForm(QWidget *parent = 0, QString styleSheet = ""); Ui_HWForm ui; - GameUIConfig * config; - QSettings * gameSettings; // Same file GameUIConfig points to but without the baggage. Needs sync() calls if you want to get GameUIConfig changes though + static GameUIConfig * config; + static QSettings * gameSettings; // Same file GameUIConfig points to but without the baggage. Needs sync() calls if you want to get GameUIConfig changes though void updateXfire(); void PlayDemoQuick(const QString & demofilename); void exit(); diff -r da5cfded818b -r 0d0af531c1c7 QTfrontend/ui/page/AbstractPage.cpp --- a/QTfrontend/ui/page/AbstractPage.cpp Sun Jan 15 22:48:34 2012 +0100 +++ b/QTfrontend/ui/page/AbstractPage.cpp Sun Jan 15 22:57:49 2012 +0100 @@ -25,6 +25,8 @@ #include #include #include +#include +#include AbstractPage::AbstractPage(QWidget* parent) { @@ -71,7 +73,7 @@ QPushButton * AbstractPage::formattedButton(const QString & name, bool hasIcon) { - QPushButton * btn = new QPushButton(this); + QPushButtonWithSound * btn = new QPushButtonWithSound(this); if (hasIcon) { diff -r da5cfded818b -r 0d0af531c1c7 QTfrontend/ui/widget/qpushbuttonwithsound.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/widget/qpushbuttonwithsound.cpp Sun Jan 15 22:57:49 2012 +0100 @@ -0,0 +1,33 @@ +#include "qpushbuttonwithsound.h" +#include +#include +#include +#include +#include +#include +#include + +QPushButtonWithSound::QPushButtonWithSound(QWidget *parent) : + QPushButton(parent) +{ + connect(this, SIGNAL(clicked()), this, SLOT(buttonClicked())); +} + +void QPushButtonWithSound::buttonClicked() +{ + if (!HWForm::config->isFrontendSoundEnabled()) + return; + + HWDataManager & dataMgr = HWDataManager::instance(); + + QString soundsDir = QString("Sounds/"); + + QStringList list = dataMgr.entryList( + soundsDir, + QDir::Files, + QStringList() << + "shotgunreload.ogg" + ); + if(!list.empty()) + SDLInteraction::instance().playSoundFile(dataMgr.findFileForRead(soundsDir + "/" + list[0])); +} diff -r da5cfded818b -r 0d0af531c1c7 QTfrontend/ui/widget/qpushbuttonwithsound.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QTfrontend/ui/widget/qpushbuttonwithsound.h Sun Jan 15 22:57:49 2012 +0100 @@ -0,0 +1,20 @@ +#ifndef QPUSHBUTTONWITHSOUND_H +#define QPUSHBUTTONWITHSOUND_H + +#include + +class QPushButtonWithSound : public QPushButton +{ + Q_OBJECT +public: + explicit QPushButtonWithSound(QWidget *parent = 0); + +signals: + +public slots: +private slots: + void buttonClicked(); + +}; + +#endif // QPUSHBUTTONWITHSOUND_H diff -r da5cfded818b -r 0d0af531c1c7 project_files/hedgewars.pro --- a/project_files/hedgewars.pro Sun Jan 15 22:48:34 2012 +0100 +++ b/project_files/hedgewars.pro Sun Jan 15 22:57:49 2012 +0100 @@ -96,7 +96,9 @@ ../QTfrontend/KB.h \ ../QTfrontend/hwconsts.h \ ../QTfrontend/sdlkeys.h \ - ../QTfrontend/ui/mouseoverfilter.h + ../QTfrontend/ui/mouseoverfilter.h \ + ../QTfrontend/ui/qpushbuttonwithsound.h \ + ../QTfrontend/ui/widget/qpushbuttonwithsound.h SOURCES += ../QTfrontend/model/ammoSchemeModel.cpp \ ../QTfrontend/model/themesmodel.cpp \ @@ -171,7 +173,8 @@ ../QTfrontend/team.cpp \ ../QTfrontend/ui_hwform.cpp \ ../QTfrontend/hwconsts.cpp \ - ../QTfrontend/ui/mouseoverfilter.cpp + ../QTfrontend/ui/mouseoverfilter.cpp \ + ../QTfrontend/ui/widget/qpushbuttonwithsound.cpp win32 { SOURCES += ../QTfrontend/xfire.cpp