preliminary sound support
This commit is contained in:
parent
19ae32f330
commit
c67bc65762
16 changed files with 106 additions and 4 deletions
|
@ -5,7 +5,7 @@ INCLUDEPATH += . src ../common
|
||||||
MOC_DIR = build
|
MOC_DIR = build
|
||||||
OBJECTS_DIR = build
|
OBJECTS_DIR = build
|
||||||
RESOURCES = cockatrice.qrc
|
RESOURCES = cockatrice.qrc
|
||||||
QT += network svg
|
QT += network svg multimedia
|
||||||
|
|
||||||
HEADERS += src/abstractcounter.h \
|
HEADERS += src/abstractcounter.h \
|
||||||
src/counter_general.h \
|
src/counter_general.h \
|
||||||
|
@ -71,6 +71,7 @@ HEADERS += src/abstractcounter.h \
|
||||||
src/localserverinterface.h \
|
src/localserverinterface.h \
|
||||||
src/localclient.h \
|
src/localclient.h \
|
||||||
src/translation.h \
|
src/translation.h \
|
||||||
|
src/soundengine.h \
|
||||||
../common/color.h \
|
../common/color.h \
|
||||||
../common/serializable_item.h \
|
../common/serializable_item.h \
|
||||||
../common/decklist.h \
|
../common/decklist.h \
|
||||||
|
@ -153,6 +154,7 @@ SOURCES += src/abstractcounter.cpp \
|
||||||
src/localserver.cpp \
|
src/localserver.cpp \
|
||||||
src/localserverinterface.cpp \
|
src/localserverinterface.cpp \
|
||||||
src/localclient.cpp \
|
src/localclient.cpp \
|
||||||
|
src/soundengine.cpp \
|
||||||
../common/serializable_item.cpp \
|
../common/serializable_item.cpp \
|
||||||
../common/decklist.cpp \
|
../common/decklist.cpp \
|
||||||
../common/protocol.cpp \
|
../common/protocol.cpp \
|
||||||
|
|
|
@ -97,6 +97,13 @@
|
||||||
<file>resources/counters/general.svg</file>
|
<file>resources/counters/general.svg</file>
|
||||||
<file>resources/counters/general_highlight.svg</file>
|
<file>resources/counters/general_highlight.svg</file>
|
||||||
|
|
||||||
|
<file>resources/sounds/draw.raw</file>
|
||||||
|
<file>resources/sounds/notification.raw</file>
|
||||||
|
<file>resources/sounds/playcard.raw</file>
|
||||||
|
<file>resources/sounds/shuffle.raw</file>
|
||||||
|
<file>resources/sounds/tap.raw</file>
|
||||||
|
<file>resources/sounds/untap.raw</file>
|
||||||
|
|
||||||
<file>resources/userlevels/normal.svg</file>
|
<file>resources/userlevels/normal.svg</file>
|
||||||
<file>resources/userlevels/registered.svg</file>
|
<file>resources/userlevels/registered.svg</file>
|
||||||
<file>resources/userlevels/judge.svg</file>
|
<file>resources/userlevels/judge.svg</file>
|
||||||
|
|
|
@ -360,7 +360,7 @@ void CardItem::resetState()
|
||||||
annotation.clear();
|
annotation.clear();
|
||||||
attachedTo = 0;
|
attachedTo = 0;
|
||||||
attachedCards.clear();
|
attachedCards.clear();
|
||||||
setTapped(false);
|
setTapped(false, false);
|
||||||
setDoesntUntap(false);
|
setDoesntUntap(false);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
|
@ -377,6 +377,8 @@ void AppearanceSettingsPage::cardBackPicturePathButtonClicked()
|
||||||
|
|
||||||
UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||||
{
|
{
|
||||||
|
QIcon deleteIcon(":/resources/icon_delete.svg");
|
||||||
|
|
||||||
doubleClickToPlayCheckBox = new QCheckBox;
|
doubleClickToPlayCheckBox = new QCheckBox;
|
||||||
doubleClickToPlayCheckBox->setChecked(settingsCache->getDoubleClickToPlay());
|
doubleClickToPlayCheckBox->setChecked(settingsCache->getDoubleClickToPlay());
|
||||||
connect(doubleClickToPlayCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setDoubleClickToPlay(int)));
|
connect(doubleClickToPlayCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setDoubleClickToPlay(int)));
|
||||||
|
@ -391,6 +393,28 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||||
tapAnimationCheckBox->setChecked(settingsCache->getTapAnimation());
|
tapAnimationCheckBox->setChecked(settingsCache->getTapAnimation());
|
||||||
connect(tapAnimationCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setTapAnimation(int)));
|
connect(tapAnimationCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setTapAnimation(int)));
|
||||||
|
|
||||||
|
soundEnabledCheckBox = new QCheckBox;
|
||||||
|
soundEnabledCheckBox->setChecked(settingsCache->getSoundEnabled());
|
||||||
|
connect(soundEnabledCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setSoundEnabled(int)));
|
||||||
|
|
||||||
|
soundPathLabel = new QLabel;
|
||||||
|
soundPathEdit = new QLineEdit(settingsCache->getSoundPath());
|
||||||
|
soundPathEdit->setReadOnly(true);
|
||||||
|
QPushButton *soundPathClearButton = new QPushButton(deleteIcon, QString());
|
||||||
|
connect(soundPathClearButton, SIGNAL(clicked()), this, SLOT(soundPathClearButtonClicked()));
|
||||||
|
QPushButton *soundPathButton = new QPushButton("...");
|
||||||
|
connect(soundPathButton, SIGNAL(clicked()), this, SLOT(soundPathButtonClicked()));
|
||||||
|
|
||||||
|
QGridLayout *soundGrid = new QGridLayout;
|
||||||
|
soundGrid->addWidget(soundEnabledCheckBox, 0, 0, 1, 4);
|
||||||
|
soundGrid->addWidget(soundPathLabel, 1, 0);
|
||||||
|
soundGrid->addWidget(soundPathEdit, 1, 1);
|
||||||
|
soundGrid->addWidget(soundPathClearButton, 1, 2);
|
||||||
|
soundGrid->addWidget(soundPathButton, 1, 3);
|
||||||
|
|
||||||
|
soundGroupBox = new QGroupBox;
|
||||||
|
soundGroupBox->setLayout(soundGrid);
|
||||||
|
|
||||||
QGridLayout *animationGrid = new QGridLayout;
|
QGridLayout *animationGrid = new QGridLayout;
|
||||||
animationGrid->addWidget(tapAnimationCheckBox, 0, 0);
|
animationGrid->addWidget(tapAnimationCheckBox, 0, 0);
|
||||||
|
|
||||||
|
@ -400,6 +424,7 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addWidget(generalGroupBox);
|
mainLayout->addWidget(generalGroupBox);
|
||||||
mainLayout->addWidget(animationGroupBox);
|
mainLayout->addWidget(animationGroupBox);
|
||||||
|
mainLayout->addWidget(soundGroupBox);
|
||||||
|
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
}
|
}
|
||||||
|
@ -410,6 +435,24 @@ void UserInterfaceSettingsPage::retranslateUi()
|
||||||
doubleClickToPlayCheckBox->setText(tr("&Double-click cards to play them (instead of single-click)"));
|
doubleClickToPlayCheckBox->setText(tr("&Double-click cards to play them (instead of single-click)"));
|
||||||
animationGroupBox->setTitle(tr("Animation settings"));
|
animationGroupBox->setTitle(tr("Animation settings"));
|
||||||
tapAnimationCheckBox->setText(tr("&Tap/untap animation"));
|
tapAnimationCheckBox->setText(tr("&Tap/untap animation"));
|
||||||
|
soundEnabledCheckBox->setText(tr("Enable &sounds"));
|
||||||
|
soundPathLabel->setText(tr("Path to sounds directory:"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void UserInterfaceSettingsPage::soundPathClearButtonClicked()
|
||||||
|
{
|
||||||
|
soundPathEdit->setText(QString());
|
||||||
|
settingsCache->setSoundPath(QString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void UserInterfaceSettingsPage::soundPathButtonClicked()
|
||||||
|
{
|
||||||
|
QString path = QFileDialog::getExistingDirectory(this, tr("Choose path"));
|
||||||
|
if (path.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
soundPathEdit->setText(path);
|
||||||
|
settingsCache->setSoundPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
MessagesSettingsPage::MessagesSettingsPage()
|
MessagesSettingsPage::MessagesSettingsPage()
|
||||||
|
|
|
@ -76,10 +76,18 @@ public:
|
||||||
|
|
||||||
class UserInterfaceSettingsPage : public AbstractSettingsPage {
|
class UserInterfaceSettingsPage : public AbstractSettingsPage {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
private slots:
|
||||||
|
void soundPathClearButtonClicked();
|
||||||
|
void soundPathButtonClicked();
|
||||||
|
signals:
|
||||||
|
void soundPathChanged();
|
||||||
private:
|
private:
|
||||||
QCheckBox *doubleClickToPlayCheckBox;
|
QCheckBox *doubleClickToPlayCheckBox;
|
||||||
QCheckBox *tapAnimationCheckBox;
|
QCheckBox *tapAnimationCheckBox;
|
||||||
QGroupBox *generalGroupBox, *animationGroupBox;
|
QCheckBox *soundEnabledCheckBox;
|
||||||
|
QLabel *soundPathLabel;
|
||||||
|
QLineEdit *soundPathEdit;
|
||||||
|
QGroupBox *generalGroupBox, *animationGroupBox, *soundGroupBox;
|
||||||
public:
|
public:
|
||||||
UserInterfaceSettingsPage();
|
UserInterfaceSettingsPage();
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "settingscache.h"
|
#include "settingscache.h"
|
||||||
#include "pixmapgenerator.h"
|
#include "pixmapgenerator.h"
|
||||||
#include "rng_sfmt.h"
|
#include "rng_sfmt.h"
|
||||||
|
#include "soundengine.h"
|
||||||
|
|
||||||
//Q_IMPORT_PLUGIN(qjpeg)
|
//Q_IMPORT_PLUGIN(qjpeg)
|
||||||
|
|
||||||
|
@ -43,6 +44,7 @@ CardDatabase *db;
|
||||||
QTranslator *translator, *qtTranslator;
|
QTranslator *translator, *qtTranslator;
|
||||||
SettingsCache *settingsCache;
|
SettingsCache *settingsCache;
|
||||||
RNG_Abstract *rng;
|
RNG_Abstract *rng;
|
||||||
|
SoundEngine *soundEngine;
|
||||||
|
|
||||||
void myMessageOutput(QtMsgType /*type*/, const char *msg)
|
void myMessageOutput(QtMsgType /*type*/, const char *msg)
|
||||||
{
|
{
|
||||||
|
@ -114,6 +116,8 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startMainProgram) {
|
if (startMainProgram) {
|
||||||
|
soundEngine = new SoundEngine;
|
||||||
|
|
||||||
MainWindow ui;
|
MainWindow ui;
|
||||||
qDebug("main(): MainWindow constructor finished");
|
qDebug("main(): MainWindow constructor finished");
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
class CardDatabase;
|
class CardDatabase;
|
||||||
class QTranslator;
|
class QTranslator;
|
||||||
|
class SoundEngine;
|
||||||
|
|
||||||
extern CardDatabase *db;
|
extern CardDatabase *db;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "cardzone.h"
|
#include "cardzone.h"
|
||||||
#include "cardinfowidget.h"
|
#include "cardinfowidget.h"
|
||||||
#include "protocol_items.h"
|
#include "protocol_items.h"
|
||||||
|
#include "soundengine.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QTextBlock>
|
#include <QTextBlock>
|
||||||
|
@ -60,6 +61,7 @@ void MessageLogWidget::logGameJoined(int gameId)
|
||||||
|
|
||||||
void MessageLogWidget::logJoin(Player *player)
|
void MessageLogWidget::logJoin(Player *player)
|
||||||
{
|
{
|
||||||
|
soundEngine->notification();
|
||||||
append(tr("%1 has joined the game.").arg(sanitizeHtml(player->getName())));
|
append(tr("%1 has joined the game.").arg(sanitizeHtml(player->getName())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,6 +125,7 @@ void MessageLogWidget::logSpectatorSay(QString spectatorName, QString message)
|
||||||
|
|
||||||
void MessageLogWidget::logShuffle(Player *player)
|
void MessageLogWidget::logShuffle(Player *player)
|
||||||
{
|
{
|
||||||
|
soundEngine->shuffle();
|
||||||
append(tr("%1 shuffles his library.").arg(sanitizeHtml(player->getName())));
|
append(tr("%1 shuffles his library.").arg(sanitizeHtml(player->getName())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,6 +136,7 @@ void MessageLogWidget::logRollDie(Player *player, int sides, int roll)
|
||||||
|
|
||||||
void MessageLogWidget::logDrawCards(Player *player, int number)
|
void MessageLogWidget::logDrawCards(Player *player, int number)
|
||||||
{
|
{
|
||||||
|
soundEngine->draw();
|
||||||
append(tr("%1 draws %n card(s).", "", number).arg(sanitizeHtml(player->getName())));
|
append(tr("%1 draws %n card(s).", "", number).arg(sanitizeHtml(player->getName())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,6 +216,7 @@ void MessageLogWidget::doMoveCard(LogMoveCard &attributes)
|
||||||
|
|
||||||
QString finalStr;
|
QString finalStr;
|
||||||
if (targetName == "table") {
|
if (targetName == "table") {
|
||||||
|
soundEngine->playCard();
|
||||||
if (moveCardTapped.value(attributes.card))
|
if (moveCardTapped.value(attributes.card))
|
||||||
finalStr = tr("%1 puts %2 into play tapped%3.");
|
finalStr = tr("%1 puts %2 into play tapped%3.");
|
||||||
else
|
else
|
||||||
|
@ -233,8 +238,10 @@ void MessageLogWidget::doMoveCard(LogMoveCard &attributes)
|
||||||
finalStr = tr("%1 puts %2%3 into his library at position %4.");
|
finalStr = tr("%1 puts %2%3 into his library at position %4.");
|
||||||
} else if (targetName == "sb")
|
} else if (targetName == "sb")
|
||||||
finalStr = tr("%1 moves %2%3 to sideboard.");
|
finalStr = tr("%1 moves %2%3 to sideboard.");
|
||||||
else if (targetName == "stack")
|
else if (targetName == "stack") {
|
||||||
|
soundEngine->playCard();
|
||||||
finalStr = tr("%1 plays %2%3.");
|
finalStr = tr("%1 plays %2%3.");
|
||||||
|
}
|
||||||
|
|
||||||
append(finalStr.arg(sanitizeHtml(attributes.player->getName())).arg(cardStr).arg(fromStr).arg(attributes.newX));
|
append(finalStr.arg(sanitizeHtml(attributes.player->getName())).arg(cardStr).arg(fromStr).arg(attributes.newX));
|
||||||
}
|
}
|
||||||
|
@ -317,6 +324,11 @@ void MessageLogWidget::logSetCardCounter(Player *player, QString cardName, int c
|
||||||
|
|
||||||
void MessageLogWidget::logSetTapped(Player *player, CardItem *card, bool tapped)
|
void MessageLogWidget::logSetTapped(Player *player, CardItem *card, bool tapped)
|
||||||
{
|
{
|
||||||
|
if (tapped)
|
||||||
|
soundEngine->tap();
|
||||||
|
else
|
||||||
|
soundEngine->untap();
|
||||||
|
|
||||||
if (currentContext == MessageContext_MoveCard)
|
if (currentContext == MessageContext_MoveCard)
|
||||||
moveCardTapped.insert(card, tapped);
|
moveCardTapped.insert(card, tapped);
|
||||||
else {
|
else {
|
||||||
|
@ -409,6 +421,7 @@ void MessageLogWidget::logRevealCards(Player *player, CardZone *zone, int cardId
|
||||||
|
|
||||||
void MessageLogWidget::logSetActivePlayer(Player *player)
|
void MessageLogWidget::logSetActivePlayer(Player *player)
|
||||||
{
|
{
|
||||||
|
soundEngine->notification();
|
||||||
append(QString());
|
append(QString());
|
||||||
append("<font color=\"green\"><b>" + tr("It is now %1's turn.").arg(player->getName()) + "</b></font>");
|
append("<font color=\"green\"><b>" + tr("It is now %1's turn.").arg(player->getName()) + "</b></font>");
|
||||||
append(QString());
|
append(QString());
|
||||||
|
@ -416,6 +429,7 @@ void MessageLogWidget::logSetActivePlayer(Player *player)
|
||||||
|
|
||||||
void MessageLogWidget::logSetActivePhase(int phase)
|
void MessageLogWidget::logSetActivePhase(int phase)
|
||||||
{
|
{
|
||||||
|
soundEngine->notification();
|
||||||
QString phaseName;
|
QString phaseName;
|
||||||
switch (phase) {
|
switch (phase) {
|
||||||
case 0: phaseName = tr("untap step"); break;
|
case 0: phaseName = tr("untap step"); break;
|
||||||
|
|
|
@ -27,6 +27,9 @@ SettingsCache::SettingsCache()
|
||||||
|
|
||||||
zoneViewSortByName = settings->value("zoneview/sortbyname", true).toBool();
|
zoneViewSortByName = settings->value("zoneview/sortbyname", true).toBool();
|
||||||
zoneViewSortByType = settings->value("zoneview/sortbytype", true).toBool();
|
zoneViewSortByType = settings->value("zoneview/sortbytype", true).toBool();
|
||||||
|
|
||||||
|
soundEnabled = settings->value("sound/enabled", false).toBool();
|
||||||
|
soundPath = settings->value("sound/path").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsCache::setLang(const QString &_lang)
|
void SettingsCache::setLang(const QString &_lang)
|
||||||
|
@ -148,3 +151,16 @@ void SettingsCache::setZoneViewSortByType(int _zoneViewSortByType)
|
||||||
zoneViewSortByType = _zoneViewSortByType;
|
zoneViewSortByType = _zoneViewSortByType;
|
||||||
settings->setValue("zoneview/sortbytype", zoneViewSortByType);
|
settings->setValue("zoneview/sortbytype", zoneViewSortByType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsCache::setSoundEnabled(int _soundEnabled)
|
||||||
|
{
|
||||||
|
soundEnabled = _soundEnabled;
|
||||||
|
settings->setValue("sound/enabled", soundEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsCache::setSoundPath(const QString &_soundPath)
|
||||||
|
{
|
||||||
|
soundPath = _soundPath;
|
||||||
|
settings->setValue("sound/path", soundPath);
|
||||||
|
emit soundPathChanged();
|
||||||
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ signals:
|
||||||
void displayCardNamesChanged();
|
void displayCardNamesChanged();
|
||||||
void horizontalHandChanged();
|
void horizontalHandChanged();
|
||||||
void invertVerticalCoordinateChanged();
|
void invertVerticalCoordinateChanged();
|
||||||
|
void soundPathChanged();
|
||||||
private:
|
private:
|
||||||
QSettings *settings;
|
QSettings *settings;
|
||||||
|
|
||||||
|
@ -34,6 +35,8 @@ private:
|
||||||
bool invertVerticalCoordinate;
|
bool invertVerticalCoordinate;
|
||||||
bool tapAnimation;
|
bool tapAnimation;
|
||||||
bool zoneViewSortByName, zoneViewSortByType;
|
bool zoneViewSortByName, zoneViewSortByType;
|
||||||
|
bool soundEnabled;
|
||||||
|
QString soundPath;
|
||||||
public:
|
public:
|
||||||
SettingsCache();
|
SettingsCache();
|
||||||
QString getLang() const { return lang; }
|
QString getLang() const { return lang; }
|
||||||
|
@ -54,6 +57,8 @@ public:
|
||||||
bool getTapAnimation() const { return tapAnimation; }
|
bool getTapAnimation() const { return tapAnimation; }
|
||||||
bool getZoneViewSortByName() const { return zoneViewSortByName; }
|
bool getZoneViewSortByName() const { return zoneViewSortByName; }
|
||||||
bool getZoneViewSortByType() const { return zoneViewSortByType; }
|
bool getZoneViewSortByType() const { return zoneViewSortByType; }
|
||||||
|
bool getSoundEnabled() const { return soundEnabled; }
|
||||||
|
QString getSoundPath() const { return soundPath; }
|
||||||
public slots:
|
public slots:
|
||||||
void setLang(const QString &_lang);
|
void setLang(const QString &_lang);
|
||||||
void setDeckPath(const QString &_deckPath);
|
void setDeckPath(const QString &_deckPath);
|
||||||
|
@ -73,6 +78,8 @@ public slots:
|
||||||
void setTapAnimation(int _tapAnimation);
|
void setTapAnimation(int _tapAnimation);
|
||||||
void setZoneViewSortByName(int _zoneViewSortByName);
|
void setZoneViewSortByName(int _zoneViewSortByName);
|
||||||
void setZoneViewSortByType(int _zoneViewSortByType);
|
void setZoneViewSortByType(int _zoneViewSortByType);
|
||||||
|
void setSoundEnabled(int _soundEnabled);
|
||||||
|
void setSoundPath(const QString &_soundPath);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern SettingsCache *settingsCache;
|
extern SettingsCache *settingsCache;
|
||||||
|
|
BIN
sounds/draw.raw
Normal file
BIN
sounds/draw.raw
Normal file
Binary file not shown.
BIN
sounds/notification.raw
Normal file
BIN
sounds/notification.raw
Normal file
Binary file not shown.
BIN
sounds/playcard.raw
Normal file
BIN
sounds/playcard.raw
Normal file
Binary file not shown.
BIN
sounds/shuffle.raw
Normal file
BIN
sounds/shuffle.raw
Normal file
Binary file not shown.
BIN
sounds/tap.raw
Normal file
BIN
sounds/tap.raw
Normal file
Binary file not shown.
BIN
sounds/untap.raw
Normal file
BIN
sounds/untap.raw
Normal file
Binary file not shown.
Loading…
Reference in a new issue