equal
deleted
inserted
replaced
28 #include "hwconsts.h" |
28 #include "hwconsts.h" |
29 #include "SDLs.h" |
29 #include "SDLs.h" |
30 #include "gameuiconfig.h" |
30 #include "gameuiconfig.h" |
31 #include "chatwidget.h" |
31 #include "chatwidget.h" |
32 |
32 |
33 HWChatWidget::HWChatWidget(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli) : |
33 HWChatWidget::HWChatWidget(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli, bool notify) : |
34 QWidget(parent), |
34 QWidget(parent), |
35 mainLayout(this) |
35 mainLayout(this) |
36 { |
36 { |
37 this->gameSettings = gameSettings; |
37 this->gameSettings = gameSettings; |
38 this->sdli = sdli; |
38 this->sdli = sdli; |
|
39 this->notify = notify; |
|
40 if(notify && gameSettings->value("audio/sound", true).toBool()) { |
|
41 QDir tmpdir; |
|
42 |
|
43 tmpdir.cd(datadir->absolutePath()); |
|
44 tmpdir.cd("Sounds/"); |
|
45 sdli->SDLMusicInit(); |
|
46 sound = Mix_LoadWAV(QString(tmpdir.absolutePath() + "/switchhog.ogg").toLocal8Bit().constData()); |
|
47 } |
39 |
48 |
40 mainLayout.setSpacing(1); |
49 mainLayout.setSpacing(1); |
41 mainLayout.setMargin(1); |
50 mainLayout.setMargin(1); |
42 mainLayout.setSizeConstraint(QLayout::SetMinimumSize); |
51 mainLayout.setSizeConstraint(QLayout::SetMinimumSize); |
43 mainLayout.setColumnStretch(0, 75); |
52 mainLayout.setColumnStretch(0, 75); |
117 chatText->moveCursor(QTextCursor::End); |
126 chatText->moveCursor(QTextCursor::End); |
118 } |
127 } |
119 |
128 |
120 void HWChatWidget::nickAdded(const QString& nick) |
129 void HWChatWidget::nickAdded(const QString& nick) |
121 { |
130 { |
122 Mix_Chunk *sound; |
|
123 QDir tmpdir; |
|
124 |
|
125 QListWidgetItem * item = new QListWidgetItem(nick); |
131 QListWidgetItem * item = new QListWidgetItem(nick); |
126 item->setIcon(QIcon(":/res/hh_small.png")); |
132 item->setIcon(QIcon(":/res/hh_small.png")); |
127 chatNicks->addItem(item); |
133 chatNicks->addItem(item); |
128 |
134 |
129 if(gameSettings->value("audio/sound", true).toBool()) { |
135 if(notify && gameSettings->value("audio/sound", true).toBool()) { |
130 sdli->SDLMusicInit(); |
|
131 tmpdir.cd(datadir->absolutePath()); |
|
132 tmpdir.cd("Sounds/"); |
|
133 sound = Mix_LoadWAV(QString(tmpdir.absolutePath() + "/switchhog.ogg").toLocal8Bit().constData()); |
|
134 Mix_PlayChannel(-1, sound, 0); |
136 Mix_PlayChannel(-1, sound, 0); |
135 } |
137 } |
136 } |
138 } |
137 |
139 |
138 void HWChatWidget::nickRemoved(const QString& nick) |
140 void HWChatWidget::nickRemoved(const QString& nick) |