sdlplayer reads qt resources ;)
This commit is contained in:
+6
-6
@@ -13,10 +13,10 @@ INCLUDEPATH += . \
|
|||||||
src/engine/network_engine \
|
src/engine/network_engine \
|
||||||
src/config \
|
src/config \
|
||||||
src/core/tinyxml \
|
src/core/tinyxml \
|
||||||
src/sound \
|
|
||||||
src/gui/qt \
|
src/gui/qt \
|
||||||
src/gui/qt/connecttoserverdialog \
|
src/gui/qt/connecttoserverdialog \
|
||||||
src/core \
|
src/core \
|
||||||
|
src/gui/qt/sound \
|
||||||
src/gui/qt/qttools \
|
src/gui/qt/qttools \
|
||||||
src/gui/qt/qttools/qthelper \
|
src/gui/qt/qttools/qthelper \
|
||||||
src/gui/qt/mainwindow \
|
src/gui/qt/mainwindow \
|
||||||
@@ -36,7 +36,6 @@ INCLUDEPATH += . \
|
|||||||
DEPENDPATH += . \
|
DEPENDPATH += . \
|
||||||
src \
|
src \
|
||||||
src/config \
|
src/config \
|
||||||
src/sound \
|
|
||||||
src/core \
|
src/core \
|
||||||
src/engine \
|
src/engine \
|
||||||
src/gui \
|
src/gui \
|
||||||
@@ -47,6 +46,7 @@ DEPENDPATH += . \
|
|||||||
src/engine/network_engine \
|
src/engine/network_engine \
|
||||||
src/gui/qt \
|
src/gui/qt \
|
||||||
src/net/common \
|
src/net/common \
|
||||||
|
src/gui/qt/sound \
|
||||||
src/gui/qt/mainwindow \
|
src/gui/qt/mainwindow \
|
||||||
src/gui/qt/mainwindow/startsplash \
|
src/gui/qt/mainwindow/startsplash \
|
||||||
src/gui/qt/mainwindow/log \
|
src/gui/qt/mainwindow/log \
|
||||||
@@ -113,6 +113,7 @@ HEADERS += src/game.h \
|
|||||||
src/engine/network_engine/clientpreflop.h \
|
src/engine/network_engine/clientpreflop.h \
|
||||||
src/engine/network_engine/clientriver.h \
|
src/engine/network_engine/clientriver.h \
|
||||||
src/engine/network_engine/clientturn.h \
|
src/engine/network_engine/clientturn.h \
|
||||||
|
src/gui/qt/sound/sdlplayer.h \
|
||||||
src/gui/qt/mainwindow/mainwindowimpl.h \
|
src/gui/qt/mainwindow/mainwindowimpl.h \
|
||||||
src/gui/qt/mainwindow/mycardspixmaplabel.h \
|
src/gui/qt/mainwindow/mycardspixmaplabel.h \
|
||||||
src/gui/qt/mainwindow/mysetlabel.h \
|
src/gui/qt/mainwindow/mysetlabel.h \
|
||||||
@@ -135,8 +136,7 @@ HEADERS += src/game.h \
|
|||||||
src/gui/qttoolsinterface.h \
|
src/gui/qttoolsinterface.h \
|
||||||
src/gui/qt/qttools/qttoolswrapper.h \
|
src/gui/qt/qttools/qttoolswrapper.h \
|
||||||
src/gui/qt/qttools/qthelper/qthelper.h \
|
src/gui/qt/qttools/qthelper/qthelper.h \
|
||||||
src/gui/generic/serverguiwrapper.h \
|
src/gui/generic/serverguiwrapper.h
|
||||||
src/sound/sdlplayer.h
|
|
||||||
FORMS += src/gui/qt/mainwindow.ui \
|
FORMS += src/gui/qt/mainwindow.ui \
|
||||||
src/gui/qt/aboutpokerth.ui \
|
src/gui/qt/aboutpokerth.ui \
|
||||||
src/gui/qt/connecttoserverdialog.ui \
|
src/gui/qt/connecttoserverdialog.ui \
|
||||||
@@ -206,6 +206,7 @@ SOURCES += src/game.cpp \
|
|||||||
src/net/common/netcontext.cpp \
|
src/net/common/netcontext.cpp \
|
||||||
src/net/common/netexception.cpp \
|
src/net/common/netexception.cpp \
|
||||||
src/net/common/receiverhelper.cpp \
|
src/net/common/receiverhelper.cpp \
|
||||||
|
src/gui/qt/sound/sdlplayer.cpp \
|
||||||
src/gui/qt/guiwrapper.cpp \
|
src/gui/qt/guiwrapper.cpp \
|
||||||
src/gui/qt/mainwindow/mainwindowimpl.cpp \
|
src/gui/qt/mainwindow/mainwindowimpl.cpp \
|
||||||
src/gui/qt/mainwindow/mycardspixmaplabel.cpp \
|
src/gui/qt/mainwindow/mycardspixmaplabel.cpp \
|
||||||
@@ -228,8 +229,7 @@ SOURCES += src/game.cpp \
|
|||||||
src/gui/qttoolsinterface.cpp \
|
src/gui/qttoolsinterface.cpp \
|
||||||
src/gui/qt/qttools/qttoolswrapper.cpp \
|
src/gui/qt/qttools/qttoolswrapper.cpp \
|
||||||
src/gui/qt/qttools/qthelper/qthelper.cpp \
|
src/gui/qt/qttools/qthelper/qthelper.cpp \
|
||||||
src/gui/generic/serverguiwrapper.cpp \
|
src/gui/generic/serverguiwrapper.cpp
|
||||||
src/sound/sdlplayer.cpp
|
|
||||||
RESOURCES += src/gui/qt/resources.qrc
|
RESOURCES += src/gui/qt/resources.qrc
|
||||||
TRANSLATIONS = ts/pokerth_de.ts \
|
TRANSLATIONS = ts/pokerth_de.ts \
|
||||||
ts/pokerth_es.ts \
|
ts/pokerth_es.ts \
|
||||||
|
|||||||
@@ -2499,7 +2499,7 @@ void mainWindowImpl::keyPressEvent ( QKeyEvent * event ) {
|
|||||||
if (event->key() == Qt::Key_F11) { switchRightToolBox(); }
|
if (event->key() == Qt::Key_F11) { switchRightToolBox(); }
|
||||||
if (event->key() == Qt::Key_D) { setLabelArray[0]->startTimeOutAnimation(myConfig->readConfigInt("NetTimeOutPlayerAction")); } //f
|
if (event->key() == Qt::Key_D) { setLabelArray[0]->startTimeOutAnimation(myConfig->readConfigInt("NetTimeOutPlayerAction")); } //f
|
||||||
if (event->key() == Qt::Key_E) { setLabelArray[0]->stopTimeOutAnimation(); } //f
|
if (event->key() == Qt::Key_E) { setLabelArray[0]->stopTimeOutAnimation(); } //f
|
||||||
if (event->key() == Qt::Key_S) { if(myConfig->readConfigInt("PlaySoundEffects")) mySDLPlayer->playSound("beep"); } //s
|
if (event->key() == Qt::Key_S) { if(myConfig->readConfigInt("PlaySoundEffects")) mySDLPlayer->playSound("dealtwocards"); } //s
|
||||||
// if (event->key() == Qt::Key_W) { qApp->quit(); } //s
|
// if (event->key() == Qt::Key_W) { qApp->quit(); } //s
|
||||||
if (event->key() == 16777249) {
|
if (event->key() == 16777249) {
|
||||||
pushButton_break->click();
|
pushButton_break->click();
|
||||||
|
|||||||
@@ -72,7 +72,9 @@
|
|||||||
<qresource prefix="/data" >
|
<qresource prefix="/data" >
|
||||||
<file>resources/data/preflopValues</file>
|
<file>resources/data/preflopValues</file>
|
||||||
<file>resources/data/flopValues</file>
|
<file>resources/data/flopValues</file>
|
||||||
<file>resources/data/beep.ogg</file>
|
</qresource>
|
||||||
|
<qresource prefix="/sounds" >
|
||||||
|
<file>resources/sounds/dealtwocards.wav</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="/fonts" >
|
<qresource prefix="/fonts" >
|
||||||
<file>resources/fonts/VeraBd.ttf</file>
|
<file>resources/fonts/VeraBd.ttf</file>
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -15,8 +15,9 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
SDLPlayer::SDLPlayer()
|
SDLPlayer::SDLPlayer():QObject()
|
||||||
{
|
{
|
||||||
|
currentChannel = 0;
|
||||||
initAudio();
|
initAudio();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -32,7 +33,7 @@ void SDLPlayer::initAudio() {
|
|||||||
audio_format = AUDIO_S16; /* 16-bit stereo */
|
audio_format = AUDIO_S16; /* 16-bit stereo */
|
||||||
audio_channels = 2;
|
audio_channels = 2;
|
||||||
audio_buffers = 4096;
|
audio_buffers = 4096;
|
||||||
music = NULL;
|
sound = NULL;
|
||||||
|
|
||||||
SDL_Init(SDL_INIT_AUDIO);
|
SDL_Init(SDL_INIT_AUDIO);
|
||||||
|
|
||||||
@@ -44,37 +45,33 @@ void SDLPlayer::playSound(string audioString) {
|
|||||||
|
|
||||||
audioDone();
|
audioDone();
|
||||||
|
|
||||||
cout << "play now" << endl;
|
QFile myFile(":sounds/resources/sounds/"+QString::fromStdString(audioString)+".wav");
|
||||||
/* Actually loads up the music */
|
if(!myFile.open(QIODevice::ReadOnly)) cout << "could not load wav" << endl;
|
||||||
string completeAudioString = audioString + ".wav";
|
|
||||||
music = Mix_LoadMUS(completeAudioString.c_str());
|
QDataStream in(&myFile);
|
||||||
|
Uint8 *myMem = new Uint8[(int)myFile.size()];
|
||||||
|
in.readRawData( (char*)myMem, (int)myFile.size() );
|
||||||
|
|
||||||
|
sound = Mix_QuickLoad_WAV( myMem );
|
||||||
|
|
||||||
/* This begins playing the music - the first argument is a
|
currentChannel = Mix_PlayChannel(0, sound,0);
|
||||||
pointer to Mix_Music structure, and the second is how many
|
|
||||||
times you want it to loop (use -1 for infinite, and 0 to
|
|
||||||
have it just play once) */
|
|
||||||
Mix_PlayMusic(music, 0);
|
|
||||||
|
|
||||||
/* We want to know when our music has stopped playing so we
|
delete[] myMem;
|
||||||
can free it up and set 'music' back to NULL. SDL_Mixer
|
|
||||||
provides us with a callback routine we can use to do
|
|
||||||
exactly that */
|
|
||||||
// Mix_HookMusicFinished(mainWindowImpl::musicDone());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLPlayer::audioDone() {
|
void SDLPlayer::audioDone() {
|
||||||
|
|
||||||
Mix_HaltMusic();
|
Mix_HaltChannel(currentChannel);
|
||||||
Mix_FreeMusic(music);
|
Mix_FreeChunk(sound);
|
||||||
music = NULL;
|
sound = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLPlayer::closeAudio() {
|
void SDLPlayer::closeAudio() {
|
||||||
|
|
||||||
Mix_HaltMusic();
|
Mix_HaltChannel(currentChannel);
|
||||||
Mix_FreeMusic(music);
|
Mix_FreeChunk(sound);
|
||||||
music = NULL;
|
sound = NULL;
|
||||||
Mix_CloseAudio();
|
Mix_CloseAudio();
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
// Copyright: See COPYING file that comes with this distribution
|
// Copyright: See COPYING file that comes with this distribution
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
#include <QtCore>
|
||||||
|
|
||||||
#ifndef SDLPLAYER_H
|
#ifndef SDLPLAYER_H
|
||||||
#define SDLPLAYER_H
|
#define SDLPLAYER_H
|
||||||
|
|
||||||
@@ -25,7 +27,9 @@
|
|||||||
/**
|
/**
|
||||||
@author FThauer FHammer <webmaster@pokerth.net>
|
@author FThauer FHammer <webmaster@pokerth.net>
|
||||||
*/
|
*/
|
||||||
class SDLPlayer{
|
class SDLPlayer : public QObject{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SDLPlayer();
|
SDLPlayer();
|
||||||
|
|
||||||
@@ -42,7 +46,8 @@ private:
|
|||||||
Uint16 audio_format;
|
Uint16 audio_format;
|
||||||
int audio_channels;
|
int audio_channels;
|
||||||
int audio_buffers;
|
int audio_buffers;
|
||||||
Mix_Music *music;
|
Mix_Chunk *sound;
|
||||||
|
int currentChannel;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user