sdlplayer reads qt resources ;)
This commit is contained in:
+6
-6
@@ -13,10 +13,10 @@ INCLUDEPATH += . \
|
||||
src/engine/network_engine \
|
||||
src/config \
|
||||
src/core/tinyxml \
|
||||
src/sound \
|
||||
src/gui/qt \
|
||||
src/gui/qt/connecttoserverdialog \
|
||||
src/core \
|
||||
src/gui/qt/sound \
|
||||
src/gui/qt/qttools \
|
||||
src/gui/qt/qttools/qthelper \
|
||||
src/gui/qt/mainwindow \
|
||||
@@ -36,7 +36,6 @@ INCLUDEPATH += . \
|
||||
DEPENDPATH += . \
|
||||
src \
|
||||
src/config \
|
||||
src/sound \
|
||||
src/core \
|
||||
src/engine \
|
||||
src/gui \
|
||||
@@ -47,6 +46,7 @@ DEPENDPATH += . \
|
||||
src/engine/network_engine \
|
||||
src/gui/qt \
|
||||
src/net/common \
|
||||
src/gui/qt/sound \
|
||||
src/gui/qt/mainwindow \
|
||||
src/gui/qt/mainwindow/startsplash \
|
||||
src/gui/qt/mainwindow/log \
|
||||
@@ -113,6 +113,7 @@ HEADERS += src/game.h \
|
||||
src/engine/network_engine/clientpreflop.h \
|
||||
src/engine/network_engine/clientriver.h \
|
||||
src/engine/network_engine/clientturn.h \
|
||||
src/gui/qt/sound/sdlplayer.h \
|
||||
src/gui/qt/mainwindow/mainwindowimpl.h \
|
||||
src/gui/qt/mainwindow/mycardspixmaplabel.h \
|
||||
src/gui/qt/mainwindow/mysetlabel.h \
|
||||
@@ -135,8 +136,7 @@ HEADERS += src/game.h \
|
||||
src/gui/qttoolsinterface.h \
|
||||
src/gui/qt/qttools/qttoolswrapper.h \
|
||||
src/gui/qt/qttools/qthelper/qthelper.h \
|
||||
src/gui/generic/serverguiwrapper.h \
|
||||
src/sound/sdlplayer.h
|
||||
src/gui/generic/serverguiwrapper.h
|
||||
FORMS += src/gui/qt/mainwindow.ui \
|
||||
src/gui/qt/aboutpokerth.ui \
|
||||
src/gui/qt/connecttoserverdialog.ui \
|
||||
@@ -206,6 +206,7 @@ SOURCES += src/game.cpp \
|
||||
src/net/common/netcontext.cpp \
|
||||
src/net/common/netexception.cpp \
|
||||
src/net/common/receiverhelper.cpp \
|
||||
src/gui/qt/sound/sdlplayer.cpp \
|
||||
src/gui/qt/guiwrapper.cpp \
|
||||
src/gui/qt/mainwindow/mainwindowimpl.cpp \
|
||||
src/gui/qt/mainwindow/mycardspixmaplabel.cpp \
|
||||
@@ -228,8 +229,7 @@ SOURCES += src/game.cpp \
|
||||
src/gui/qttoolsinterface.cpp \
|
||||
src/gui/qt/qttools/qttoolswrapper.cpp \
|
||||
src/gui/qt/qttools/qthelper/qthelper.cpp \
|
||||
src/gui/generic/serverguiwrapper.cpp \
|
||||
src/sound/sdlplayer.cpp
|
||||
src/gui/generic/serverguiwrapper.cpp
|
||||
RESOURCES += src/gui/qt/resources.qrc
|
||||
TRANSLATIONS = ts/pokerth_de.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_D) { setLabelArray[0]->startTimeOutAnimation(myConfig->readConfigInt("NetTimeOutPlayerAction")); } //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() == 16777249) {
|
||||
pushButton_break->click();
|
||||
|
||||
@@ -72,7 +72,9 @@
|
||||
<qresource prefix="/data" >
|
||||
<file>resources/data/preflopValues</file>
|
||||
<file>resources/data/flopValues</file>
|
||||
<file>resources/data/beep.ogg</file>
|
||||
</qresource>
|
||||
<qresource prefix="/sounds" >
|
||||
<file>resources/sounds/dealtwocards.wav</file>
|
||||
</qresource>
|
||||
<qresource prefix="/fonts" >
|
||||
<file>resources/fonts/VeraBd.ttf</file>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -15,8 +15,9 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
SDLPlayer::SDLPlayer()
|
||||
SDLPlayer::SDLPlayer():QObject()
|
||||
{
|
||||
currentChannel = 0;
|
||||
initAudio();
|
||||
|
||||
}
|
||||
@@ -32,7 +33,7 @@ void SDLPlayer::initAudio() {
|
||||
audio_format = AUDIO_S16; /* 16-bit stereo */
|
||||
audio_channels = 2;
|
||||
audio_buffers = 4096;
|
||||
music = NULL;
|
||||
sound = NULL;
|
||||
|
||||
SDL_Init(SDL_INIT_AUDIO);
|
||||
|
||||
@@ -44,37 +45,33 @@ void SDLPlayer::playSound(string audioString) {
|
||||
|
||||
audioDone();
|
||||
|
||||
cout << "play now" << endl;
|
||||
/* Actually loads up the music */
|
||||
string completeAudioString = audioString + ".wav";
|
||||
music = Mix_LoadMUS(completeAudioString.c_str());
|
||||
QFile myFile(":sounds/resources/sounds/"+QString::fromStdString(audioString)+".wav");
|
||||
if(!myFile.open(QIODevice::ReadOnly)) cout << "could not load wav" << endl;
|
||||
|
||||
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
|
||||
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);
|
||||
currentChannel = Mix_PlayChannel(0, sound,0);
|
||||
|
||||
/* We want to know when our music has stopped playing so we
|
||||
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());
|
||||
delete[] myMem;
|
||||
|
||||
}
|
||||
|
||||
void SDLPlayer::audioDone() {
|
||||
|
||||
Mix_HaltMusic();
|
||||
Mix_FreeMusic(music);
|
||||
music = NULL;
|
||||
Mix_HaltChannel(currentChannel);
|
||||
Mix_FreeChunk(sound);
|
||||
sound = NULL;
|
||||
}
|
||||
|
||||
void SDLPlayer::closeAudio() {
|
||||
|
||||
Mix_HaltMusic();
|
||||
Mix_FreeMusic(music);
|
||||
music = NULL;
|
||||
Mix_HaltChannel(currentChannel);
|
||||
Mix_FreeChunk(sound);
|
||||
sound = NULL;
|
||||
Mix_CloseAudio();
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
#include <QtCore>
|
||||
|
||||
#ifndef SDLPLAYER_H
|
||||
#define SDLPLAYER_H
|
||||
|
||||
@@ -25,7 +27,9 @@
|
||||
/**
|
||||
@author FThauer FHammer <webmaster@pokerth.net>
|
||||
*/
|
||||
class SDLPlayer{
|
||||
class SDLPlayer : public QObject{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SDLPlayer();
|
||||
|
||||
@@ -42,7 +46,8 @@ private:
|
||||
Uint16 audio_format;
|
||||
int audio_channels;
|
||||
int audio_buffers;
|
||||
Mix_Music *music;
|
||||
Mix_Chunk *sound;
|
||||
int currentChannel;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user