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
|
||||
OBJECTS_DIR = build
|
||||
RESOURCES = cockatrice.qrc
|
||||
QT += network svg
|
||||
QT += network svg multimedia
|
||||
|
||||
HEADERS += src/abstractcounter.h \
|
||||
src/counter_general.h \
|
||||
|
@ -71,6 +71,7 @@ HEADERS += src/abstractcounter.h \
|
|||
src/localserverinterface.h \
|
||||
src/localclient.h \
|
||||
src/translation.h \
|
||||
src/soundengine.h \
|
||||
../common/color.h \
|
||||
../common/serializable_item.h \
|
||||
../common/decklist.h \
|
||||
|
@ -153,6 +154,7 @@ SOURCES += src/abstractcounter.cpp \
|
|||
src/localserver.cpp \
|
||||
src/localserverinterface.cpp \
|
||||
src/localclient.cpp \
|
||||
src/soundengine.cpp \
|
||||
../common/serializable_item.cpp \
|
||||
../common/decklist.cpp \
|
||||
../common/protocol.cpp \
|
||||
|
|
|
@ -97,6 +97,13 @@
|
|||
<file>resources/counters/general.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/registered.svg</file>
|
||||
<file>resources/userlevels/judge.svg</file>
|
||||
|
|
|
@ -360,7 +360,7 @@ void CardItem::resetState()
|
|||
annotation.clear();
|
||||
attachedTo = 0;
|
||||
attachedCards.clear();
|
||||
setTapped(false);
|
||||
setTapped(false, false);
|
||||
setDoesntUntap(false);
|
||||
update();
|
||||
}
|
||||
|
|
|
@ -377,6 +377,8 @@ void AppearanceSettingsPage::cardBackPicturePathButtonClicked()
|
|||
|
||||
UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||
{
|
||||
QIcon deleteIcon(":/resources/icon_delete.svg");
|
||||
|
||||
doubleClickToPlayCheckBox = new QCheckBox;
|
||||
doubleClickToPlayCheckBox->setChecked(settingsCache->getDoubleClickToPlay());
|
||||
connect(doubleClickToPlayCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setDoubleClickToPlay(int)));
|
||||
|
@ -391,6 +393,28 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
|||
tapAnimationCheckBox->setChecked(settingsCache->getTapAnimation());
|
||||
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;
|
||||
animationGrid->addWidget(tapAnimationCheckBox, 0, 0);
|
||||
|
||||
|
@ -400,6 +424,7 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
|||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addWidget(generalGroupBox);
|
||||
mainLayout->addWidget(animationGroupBox);
|
||||
mainLayout->addWidget(soundGroupBox);
|
||||
|
||||
setLayout(mainLayout);
|
||||
}
|
||||
|
@ -410,6 +435,24 @@ void UserInterfaceSettingsPage::retranslateUi()
|
|||
doubleClickToPlayCheckBox->setText(tr("&Double-click cards to play them (instead of single-click)"));
|
||||
animationGroupBox->setTitle(tr("Animation settings"));
|
||||
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()
|
||||
|
|
|
@ -76,10 +76,18 @@ public:
|
|||
|
||||
class UserInterfaceSettingsPage : public AbstractSettingsPage {
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void soundPathClearButtonClicked();
|
||||
void soundPathButtonClicked();
|
||||
signals:
|
||||
void soundPathChanged();
|
||||
private:
|
||||
QCheckBox *doubleClickToPlayCheckBox;
|
||||
QCheckBox *tapAnimationCheckBox;
|
||||
QGroupBox *generalGroupBox, *animationGroupBox;
|
||||
QCheckBox *soundEnabledCheckBox;
|
||||
QLabel *soundPathLabel;
|
||||
QLineEdit *soundPathEdit;
|
||||
QGroupBox *generalGroupBox, *animationGroupBox, *soundGroupBox;
|
||||
public:
|
||||
UserInterfaceSettingsPage();
|
||||
void retranslateUi();
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "settingscache.h"
|
||||
#include "pixmapgenerator.h"
|
||||
#include "rng_sfmt.h"
|
||||
#include "soundengine.h"
|
||||
|
||||
//Q_IMPORT_PLUGIN(qjpeg)
|
||||
|
||||
|
@ -43,6 +44,7 @@ CardDatabase *db;
|
|||
QTranslator *translator, *qtTranslator;
|
||||
SettingsCache *settingsCache;
|
||||
RNG_Abstract *rng;
|
||||
SoundEngine *soundEngine;
|
||||
|
||||
void myMessageOutput(QtMsgType /*type*/, const char *msg)
|
||||
{
|
||||
|
@ -114,6 +116,8 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
if (startMainProgram) {
|
||||
soundEngine = new SoundEngine;
|
||||
|
||||
MainWindow ui;
|
||||
qDebug("main(): MainWindow constructor finished");
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
class CardDatabase;
|
||||
class QTranslator;
|
||||
class SoundEngine;
|
||||
|
||||
extern CardDatabase *db;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "cardzone.h"
|
||||
#include "cardinfowidget.h"
|
||||
#include "protocol_items.h"
|
||||
#include "soundengine.h"
|
||||
#include <QDebug>
|
||||
#include <QMouseEvent>
|
||||
#include <QTextBlock>
|
||||
|
@ -60,6 +61,7 @@ void MessageLogWidget::logGameJoined(int gameId)
|
|||
|
||||
void MessageLogWidget::logJoin(Player *player)
|
||||
{
|
||||
soundEngine->notification();
|
||||
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)
|
||||
{
|
||||
soundEngine->shuffle();
|
||||
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)
|
||||
{
|
||||
soundEngine->draw();
|
||||
append(tr("%1 draws %n card(s).", "", number).arg(sanitizeHtml(player->getName())));
|
||||
}
|
||||
|
||||
|
@ -212,6 +216,7 @@ void MessageLogWidget::doMoveCard(LogMoveCard &attributes)
|
|||
|
||||
QString finalStr;
|
||||
if (targetName == "table") {
|
||||
soundEngine->playCard();
|
||||
if (moveCardTapped.value(attributes.card))
|
||||
finalStr = tr("%1 puts %2 into play tapped%3.");
|
||||
else
|
||||
|
@ -233,8 +238,10 @@ void MessageLogWidget::doMoveCard(LogMoveCard &attributes)
|
|||
finalStr = tr("%1 puts %2%3 into his library at position %4.");
|
||||
} else if (targetName == "sb")
|
||||
finalStr = tr("%1 moves %2%3 to sideboard.");
|
||||
else if (targetName == "stack")
|
||||
else if (targetName == "stack") {
|
||||
soundEngine->playCard();
|
||||
finalStr = tr("%1 plays %2%3.");
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (tapped)
|
||||
soundEngine->tap();
|
||||
else
|
||||
soundEngine->untap();
|
||||
|
||||
if (currentContext == MessageContext_MoveCard)
|
||||
moveCardTapped.insert(card, tapped);
|
||||
else {
|
||||
|
@ -409,6 +421,7 @@ void MessageLogWidget::logRevealCards(Player *player, CardZone *zone, int cardId
|
|||
|
||||
void MessageLogWidget::logSetActivePlayer(Player *player)
|
||||
{
|
||||
soundEngine->notification();
|
||||
append(QString());
|
||||
append("<font color=\"green\"><b>" + tr("It is now %1's turn.").arg(player->getName()) + "</b></font>");
|
||||
append(QString());
|
||||
|
@ -416,6 +429,7 @@ void MessageLogWidget::logSetActivePlayer(Player *player)
|
|||
|
||||
void MessageLogWidget::logSetActivePhase(int phase)
|
||||
{
|
||||
soundEngine->notification();
|
||||
QString phaseName;
|
||||
switch (phase) {
|
||||
case 0: phaseName = tr("untap step"); break;
|
||||
|
|
|
@ -27,6 +27,9 @@ SettingsCache::SettingsCache()
|
|||
|
||||
zoneViewSortByName = settings->value("zoneview/sortbyname", 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)
|
||||
|
@ -148,3 +151,16 @@ void SettingsCache::setZoneViewSortByType(int _zoneViewSortByType)
|
|||
zoneViewSortByType = _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 horizontalHandChanged();
|
||||
void invertVerticalCoordinateChanged();
|
||||
void soundPathChanged();
|
||||
private:
|
||||
QSettings *settings;
|
||||
|
||||
|
@ -34,6 +35,8 @@ private:
|
|||
bool invertVerticalCoordinate;
|
||||
bool tapAnimation;
|
||||
bool zoneViewSortByName, zoneViewSortByType;
|
||||
bool soundEnabled;
|
||||
QString soundPath;
|
||||
public:
|
||||
SettingsCache();
|
||||
QString getLang() const { return lang; }
|
||||
|
@ -54,6 +57,8 @@ public:
|
|||
bool getTapAnimation() const { return tapAnimation; }
|
||||
bool getZoneViewSortByName() const { return zoneViewSortByName; }
|
||||
bool getZoneViewSortByType() const { return zoneViewSortByType; }
|
||||
bool getSoundEnabled() const { return soundEnabled; }
|
||||
QString getSoundPath() const { return soundPath; }
|
||||
public slots:
|
||||
void setLang(const QString &_lang);
|
||||
void setDeckPath(const QString &_deckPath);
|
||||
|
@ -73,6 +78,8 @@ public slots:
|
|||
void setTapAnimation(int _tapAnimation);
|
||||
void setZoneViewSortByName(int _zoneViewSortByName);
|
||||
void setZoneViewSortByType(int _zoneViewSortByType);
|
||||
void setSoundEnabled(int _soundEnabled);
|
||||
void setSoundPath(const QString &_soundPath);
|
||||
};
|
||||
|
||||
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