# HG changeset patch # User nemo # Date 1265680070 0 # Node ID e94f240a8a412c37c6851944cd2b608a8177dc8a # Parent 1965eba10be63cd2fb91437bb80afa99ce3620e8 Have game beep when someone joins lobby/room. Controlled by Sound option diff -r 1965eba10be6 -r e94f240a8a41 QTfrontend/chatwidget.cpp --- a/QTfrontend/chatwidget.cpp Mon Feb 08 21:49:52 2010 +0000 +++ b/QTfrontend/chatwidget.cpp Tue Feb 09 01:47:50 2010 +0000 @@ -22,13 +22,21 @@ #include #include #include +#include +#include +#include "hwconsts.h" +#include "SDLs.h" +#include "gameuiconfig.h" #include "chatwidget.h" -HWChatWidget::HWChatWidget(QWidget* parent) : +HWChatWidget::HWChatWidget(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli) : QWidget(parent), mainLayout(this) { + this->gameSettings = gameSettings; + this->sdli = sdli; + mainLayout.setSpacing(1); mainLayout.setMargin(1); mainLayout.setSizeConstraint(QLayout::SetMinimumSize); @@ -111,9 +119,20 @@ void HWChatWidget::nickAdded(const QString& nick) { + Mix_Music *sound; + QDir tmpdir; + QListWidgetItem * item = new QListWidgetItem(nick); item->setIcon(QIcon(":/res/hh_small.png")); chatNicks->addItem(item); + + if(gameSettings->value("audio/sound", true).toBool()) { + sdli->SDLMusicInit(); + tmpdir.cd(datadir->absolutePath()); + tmpdir.cd("Sounds/"); + sound = Mix_LoadMUS(QString(tmpdir.absolutePath() + "/switchhog.ogg").toLocal8Bit().constData()); + Mix_PlayMusic(sound, 0); + } } void HWChatWidget::nickRemoved(const QString& nick) diff -r 1965eba10be6 -r e94f240a8a41 QTfrontend/chatwidget.h --- a/QTfrontend/chatwidget.h Mon Feb 08 21:49:52 2010 +0000 +++ b/QTfrontend/chatwidget.h Tue Feb 09 01:47:50 2010 +0000 @@ -27,13 +27,16 @@ class QTextBrowser; class QLineEdit; class QListWidget; +class QSettings; +class SDLInteraction; class HWChatWidget : public QWidget { Q_OBJECT public: - HWChatWidget(QWidget* parent=0); +// HWChatWidget(QWidget* parent=0); + HWChatWidget(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli); public slots: void onChatString(const QString& str); @@ -61,6 +64,9 @@ QAction * acKick; QAction * acBan; QAction * acFollow; + QSettings * gameSettings; + SDLInteraction * sdli; + private slots: void returnPressed(); diff -r 1965eba10be6 -r e94f240a8a41 QTfrontend/gameuiconfig.cpp --- a/QTfrontend/gameuiconfig.cpp Mon Feb 08 21:49:52 2010 +0000 +++ b/QTfrontend/gameuiconfig.cpp Tue Feb 09 01:47:50 2010 +0000 @@ -147,6 +147,7 @@ #ifdef SPARKLE_ENABLED setValue("misc/autoUpdate", isAutoUpdateEnabled()); #endif + Form->gameSettings->sync(); } QRect GameUIConfig::vid_Resolution() diff -r 1965eba10be6 -r e94f240a8a41 QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Mon Feb 08 21:49:52 2010 +0000 +++ b/QTfrontend/hwform.cpp Tue Feb 09 01:47:50 2010 +0000 @@ -71,8 +71,8 @@ HWForm::HWForm(QWidget *parent) : QMainWindow(parent), pnetserver(0), pRegisterServer(0), editedTeam(0), hwnet(0) { - QSettings settings(cfgdir->absolutePath() + "/hedgewars.ini", QSettings::IniFormat); - frontendEffects = settings.value("video/frontendeffects", true).toBool(); + gameSettings = new QSettings(cfgdir->absolutePath() + "/hedgewars.ini", QSettings::IniFormat); + frontendEffects = gameSettings->value("video/frontendeffects", true).toBool(); ui.setupUi(this); diff -r 1965eba10be6 -r e94f240a8a41 QTfrontend/hwform.h --- a/QTfrontend/hwform.h Mon Feb 08 21:49:52 2010 +0000 +++ b/QTfrontend/hwform.h Tue Feb 09 01:47:50 2010 +0000 @@ -41,6 +41,7 @@ class HWNetRegisterServer; class QCloseEvent; class AmmoSchemeModel; +class QSettings; extern bool frontendEffects; @@ -52,6 +53,8 @@ HWForm(QWidget *parent = 0); Ui_HWForm ui; SDLInteraction sdli; + GameUIConfig * config; + QSettings * gameSettings; // Same file GameUIConfig points to but without the baggage. Needs sync() calls if you want to get GameUIConfig changes though private slots: void GoToMain(); @@ -144,7 +147,6 @@ HWNetRegisterServer* pRegisterServer; HWTeam * editedTeam; HWNewNet * hwnet; - GameUIConfig * config; HWNamegen * namegen; AmmoSchemeModel * ammoSchemeModel; QStack PagesStack; diff -r 1965eba10be6 -r e94f240a8a41 QTfrontend/pages.cpp --- a/QTfrontend/pages.cpp Mon Feb 08 21:49:52 2010 +0000 +++ b/QTfrontend/pages.cpp Tue Feb 09 01:47:50 2010 +0000 @@ -632,7 +632,7 @@ sbPort->setValue(46631); } -PageNetGame::PageNetGame(QWidget* parent) : AbstractPage(parent) +PageNetGame::PageNetGame(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli) : AbstractPage(parent) { QGridLayout * pageLayout = new QGridLayout(this); pageLayout->setSizeConstraint(QLayout::SetMinimumSize); @@ -641,7 +641,7 @@ pageLayout->setColumnStretch(1, 50); // chatwidget - pChatWidget = new HWChatWidget(this); + pChatWidget = new HWChatWidget(this, gameSettings, sdli); pageLayout->addWidget(pChatWidget, 1, 0, 1, 2); pageLayout->setRowStretch(1, 100); @@ -796,7 +796,7 @@ label->setText("In game..."); } -PageRoomsList::PageRoomsList(QWidget* parent) : +PageRoomsList::PageRoomsList(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli) : AbstractPage(parent) { QGridLayout * pageLayout = new QGridLayout(this); @@ -818,7 +818,7 @@ pageLayout->addWidget(roomsList, 1, 0, 3, 1); pageLayout->setRowStretch(2, 100); - chatWidget = new HWChatWidget(this); + chatWidget = new HWChatWidget(this, gameSettings, sdli); pageLayout->addWidget(chatWidget, 4, 0, 1, 2); pageLayout->setRowStretch(4, 350); diff -r 1965eba10be6 -r e94f240a8a41 QTfrontend/pages.h --- a/QTfrontend/pages.h Mon Feb 08 21:49:52 2010 +0000 +++ b/QTfrontend/pages.h Tue Feb 09 01:47:50 2010 +0000 @@ -47,6 +47,7 @@ class QAction; class QDataWidgetMapper; class QAbstractItemModel; +class QSettings; class GameCFGWidget; class TeamSelWidget; @@ -288,7 +289,7 @@ Q_OBJECT public: - PageNetGame(QWidget* parent = 0); + PageNetGame(QWidget* parent, QSettings * config, SDLInteraction * sdli); QPushButton *BtnBack; QPushButton *BtnGo; @@ -374,7 +375,7 @@ Q_OBJECT public: - PageRoomsList(QWidget* parent = 0); + PageRoomsList(QWidget* parent, QSettings * config, SDLInteraction * sdli); QLineEdit * roomName; QTableWidget * roomsList; diff -r 1965eba10be6 -r e94f240a8a41 QTfrontend/ui_hwform.cpp --- a/QTfrontend/ui_hwform.cpp Mon Feb 08 21:49:52 2010 +0000 +++ b/QTfrontend/ui_hwform.cpp Tue Feb 09 01:47:50 2010 +0000 @@ -72,7 +72,7 @@ pageNet = new PageNet(); Pages->addWidget(pageNet); - pageNetGame = new PageNetGame(); + pageNetGame = new PageNetGame(Parent, HWForm->gameSettings, &HWForm->sdli); Pages->addWidget(pageNetGame); pageInfo = new PageInfo(); @@ -99,7 +99,7 @@ pageInGame = new PageInGame(); Pages->addWidget(pageInGame); - pageRoomsList = new PageRoomsList(); + pageRoomsList = new PageRoomsList(Parent, HWForm->gameSettings, &HWForm->sdli); Pages->addWidget(pageRoomsList); pageConnecting = new PageConnecting();