diff --git a/pokerth_game.pro b/pokerth_game.pro index 54017fa7..4fc0c3b5 100644 --- a/pokerth_game.pro +++ b/pokerth_game.pro @@ -157,8 +157,7 @@ HEADERS += src/engine/game.h \ src/engine/network_engine/clienthand.h \ src/engine/network_engine/clientplayer.h \ src/engine/network_engine/clientbero.h \ - src/gui/qt/chattools/chattools.h \ - src/gui/qt/sound/sdlplayer.h \ + src/gui/qt/chattools/chattools.h \ src/gui/qt/gametable/gametableimpl.h \ src/gui/qt/gametable/mycardspixmaplabel.h \ src/gui/qt/gametable/mysetlabel.h \ @@ -236,8 +235,7 @@ HEADERS += src/engine/game.h \ } SOURCES += src/pokerth.cpp \ - src/gui/qt/chattools/chattools.cpp \ - src/gui/qt/sound/sdlplayer.cpp \ + src/gui/qt/chattools/chattools.cpp \ src/gui/qt/guiwrapper.cpp \ src/gui/qt/qttools/qttoolswrapper.cpp \ src/gui/qt/qttools/qthelper/qthelper.cpp \ @@ -636,6 +634,11 @@ android{ src/gui/qt/sound/androidsoundeffect.cpp } +!android{ + HEADERS += src/gui/qt/sound/sdlplayer.h + SOURCES += src/gui/qt/sound/sdlplayer.cpp +} + maemo{ DEFINES += MAEMO } diff --git a/src/gui/qt/gametable/gametableimpl.cpp b/src/gui/qt/gametable/gametableimpl.cpp index f77ade8e..9b33cc63 100755 --- a/src/gui/qt/gametable/gametableimpl.cpp +++ b/src/gui/qt/gametable/gametableimpl.cpp @@ -42,7 +42,6 @@ #include "cardsvalue.h" #include "configfile.h" -#include "sdlplayer.h" #include "soundevents.h" #include "gametablestylereader.h" #include "carddeckstylereader.h" @@ -690,7 +689,6 @@ void gameTableImpl::applySettings(settingsDialogImpl* mySettingsDialog) //apply game table style myGameTableStyle->readStyleFile(QString::fromUtf8(myConfig->readConfigString("CurrentGameTableStyle").c_str())); - #ifdef GUI_800x480 //cardschancemonitor show/hide if (!myConfig->readConfigInt("ShowCardsChanceMonitor")) { @@ -838,6 +836,8 @@ void gameTableImpl::applySettings(settingsDialogImpl* mySettingsDialog) refreshGroupbox(); provideMyActions(); } + + mySoundEventHandler->reInitSoundEngine(); } void gameTableImpl::initGui(int speed) diff --git a/src/gui/qt/gui_800x480/createinternetgamedialog_800x480.ui b/src/gui/qt/gui_800x480/createinternetgamedialog_800x480.ui index b1a6800a..fcd091ac 100644 --- a/src/gui/qt/gui_800x480/createinternetgamedialog_800x480.ui +++ b/src/gui/qt/gui_800x480/createinternetgamedialog_800x480.ui @@ -50,7 +50,7 @@ - QObject {font: bold 20px} + QObject {font: bold 30px} Create Game @@ -159,7 +159,7 @@ Registered players only - + :/gfx/registered.png:/gfx/registered.png @@ -168,7 +168,7 @@ Invited players only - + :/gfx/list_add_user.png:/gfx/list_add_user.png @@ -177,7 +177,7 @@ Ranking game - + :/gfx/cup.png:/gfx/cup.png @@ -441,7 +441,7 @@ pushButton_createGame - + diff --git a/src/gui/qt/gui_800x480/createnetworkgamedialog_800x480.ui b/src/gui/qt/gui_800x480/createnetworkgamedialog_800x480.ui index 8c19b065..cfb7c78d 100644 --- a/src/gui/qt/gui_800x480/createnetworkgamedialog_800x480.ui +++ b/src/gui/qt/gui_800x480/createnetworkgamedialog_800x480.ui @@ -255,6 +255,19 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -265,6 +278,8 @@ spinBox_startCash radioButton_useSavedBlindsSettings radioButton_changeBlindsSettings + spinBox_netTimeOutPlayerAction + spinBox_netDelayBetweenHands pushButton_createGame diff --git a/src/gui/qt/gui_800x480/internetgamelogindialog_800x480.ui b/src/gui/qt/gui_800x480/internetgamelogindialog_800x480.ui index 88206036..fcfec0a3 100644 --- a/src/gui/qt/gui_800x480/internetgamelogindialog_800x480.ui +++ b/src/gui/qt/gui_800x480/internetgamelogindialog_800x480.ui @@ -58,6 +58,9 @@ Username: + + lineEdit_username + @@ -72,6 +75,9 @@ Password: + + lineEdit_password + @@ -131,6 +137,9 @@ Login + + false + diff --git a/src/gui/qt/gui_800x480/logfiledialog_800x480.ui b/src/gui/qt/gui_800x480/logfiledialog_800x480.ui index 8faaaf24..8f582f29 100644 --- a/src/gui/qt/gui_800x480/logfiledialog_800x480.ui +++ b/src/gui/qt/gui_800x480/logfiledialog_800x480.ui @@ -185,7 +185,7 @@ - + diff --git a/src/gui/qt/gui_800x480/newgamedialog_800x480.ui b/src/gui/qt/gui_800x480/newgamedialog_800x480.ui index e3d9ec2a..83655758 100755 --- a/src/gui/qt/gui_800x480/newgamedialog_800x480.ui +++ b/src/gui/qt/gui_800x480/newgamedialog_800x480.ui @@ -233,6 +233,19 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + diff --git a/src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.cpp b/src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.cpp index 1221b444..c17d6a9d 100644 --- a/src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.cpp +++ b/src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.cpp @@ -19,11 +19,13 @@ #include "configfile.h" #include #include +#include internetGameLoginDialogImpl::internetGameLoginDialogImpl(QWidget *parent, ConfigFile *c) : QDialog(parent), myConfig(c) { setupUi(this); + this->installEventFilter(this); //html stuff QString createAccount(QString("%1").arg(tr("Create new user account"))); @@ -147,3 +149,27 @@ void internetGameLoginDialogImpl::okButtonCheck() } } + +bool internetGameLoginDialogImpl::eventFilter(QObject *obj, QEvent *event) +{ + QKeyEvent *keyEvent = static_cast(event); + +#ifdef ANDROID + //androi hack for crash bug (hopefully useless from necessitas beta2) + if (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Return) { + if(lineEdit_username->hasFocus()) { + lineEdit_password->setFocus(); + } + if(lineEdit_password->hasFocus()) { + QTimer::singleShot(1000, this, SLOT(clickLoginButton())); + } + event->ignore(); + return false; + } else { + // pass the event on to the parent class + return QDialog::eventFilter(obj, event); + } +#else + return QDialog::eventFilter(obj, event); +#endif +} diff --git a/src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.h b/src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.h index c267c174..c1a52494 100644 --- a/src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.h +++ b/src/gui/qt/internetgamelogindialog/internetgamelogindialogimpl.h @@ -35,11 +35,13 @@ public: void exec(); void accept(); + bool eventFilter(QObject *obj, QEvent *event); public slots: void regUserToggled(bool); void guestUserToggled(bool); void okButtonCheck(); + void clickLoginButton() { pushButton_login->click(); } private: diff --git a/src/gui/qt/sound/androidaudio.cpp b/src/gui/qt/sound/androidaudio.cpp index 1bd81fc7..a4858bb7 100644 --- a/src/gui/qt/sound/androidaudio.cpp +++ b/src/gui/qt/sound/androidaudio.cpp @@ -1,25 +1,47 @@ #include "androidaudio.h" #include "androidsoundeffect.h" +#include "configfile.h" #include -AndroidAudio::AndroidAudio(QObject *parent) : - QObject(parent), mEngineObject(NULL), mEngineEngine(NULL), mOutputMixObject(NULL), mSounds(), mSoundCount(0), mPlayerObject(NULL) +AndroidAudio::AndroidAudio(ConfigFile *c, QObject *parent) : + QObject(parent), mEngineObject(NULL), mEngineEngine(NULL), mOutputMixObject(NULL), mSounds(), mSoundCount(0), mPlayerObject(NULL), myConfig(c), audioEnabled(FALSE) { - createEngine(); - startSoundPlayer(); + initAudio(); } AndroidAudio::~AndroidAudio() { - destroyEngine(); - - for (int32_t i = 0; i < mSoundCount; ++i) { - qDeleteAll(mSounds); + closeAudio(); +} +void AndroidAudio::initAudio() +{ + if (!audioEnabled && myConfig->readConfigInt("PlaySoundEffects")) { + createEngine(); + startSoundPlayer(); + audioEnabled = TRUE; } } +void AndroidAudio::closeAudio() +{ + + if(audioEnabled) { + destroyEngine(); + + for (int32_t i = 0; i < mSoundCount; ++i) { + qDeleteAll(mSounds); + } + audioEnabled = FALSE; + } +} + +void AndroidAudio::reInit() +{ + initAudio(); +} + // create the engine and output mix objects void AndroidAudio::createEngine() { @@ -73,19 +95,19 @@ void AndroidAudio::destroyEngine() void AndroidAudio::registerSound(const QString& path, const QString& name) { - qDebug() << "registerSound:" << path << name; +// qDebug() << "registerSound:" << path << name; AndroidSoundEffect *lSound = new AndroidSoundEffect(path, this); - qDebug() << "registerSound:created"; +// qDebug() << "registerSound:created"; mSounds[name] = lSound; - qDebug() << "registerSound:loading"; +// qDebug() << "registerSound:loading"; lSound->load(); - qDebug() << "registerSound:loaded"; +// qDebug() << "registerSound:loaded"; } void AndroidAudio::startSoundPlayer() { - qDebug() << "Starting Sound Player"; +// qDebug() << "Starting Sound Player"; SLresult lRes; @@ -121,12 +143,12 @@ void AndroidAudio::startSoundPlayer() const SLInterfaceID lSoundPlayerIIDs[] = { SL_IID_PLAY, SL_IID_BUFFERQUEUE }; const SLboolean lSoundPlayerReqs[] = { SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE }; - qDebug() << "Configured Sound Player"; +// qDebug() << "Configured Sound Player"; lRes = (*mEngineEngine)->CreateAudioPlayer(mEngineEngine, &mPlayerObject, &lDataSource, &lDataSink, lSoundPlayerIIDCount, lSoundPlayerIIDs, lSoundPlayerReqs); Q_ASSERT(SL_RESULT_SUCCESS == lRes); - qDebug() << "Created Sound Player"; +// qDebug() << "Created Sound Player"; lRes = (*mPlayerObject)->Realize(mPlayerObject, SL_BOOLEAN_FALSE); Q_ASSERT(SL_RESULT_SUCCESS == lRes); @@ -141,13 +163,16 @@ void AndroidAudio::startSoundPlayer() lRes = (*mPlayerPlay)->SetPlayState(mPlayerPlay, SL_PLAYSTATE_PLAYING); Q_ASSERT(SL_RESULT_SUCCESS == lRes); - qDebug() << "Created Buffer Player"; +// qDebug() << "Created Buffer Player"; } void AndroidAudio::playSound(const std::string& name, int i) { - this->registerSound(QString(":/android/android-data/sounds/default/"+QString::fromStdString(name)+".wav"), QString::fromStdString(name)); - this->reallyPlaySound(QString::fromStdString(name)); + if(audioEnabled && myConfig->readConfigInt("PlaySoundEffects")) { + + this->registerSound(QString(":/android/android-data/sounds/default/"+QString::fromStdString(name)+".wav"), QString::fromStdString(name)); + this->reallyPlaySound(QString::fromStdString(name)); + } } void AndroidAudio::reallyPlaySound(const QString& name) diff --git a/src/gui/qt/sound/androidaudio.h b/src/gui/qt/sound/androidaudio.h index fdcb90fe..725d473a 100644 --- a/src/gui/qt/sound/androidaudio.h +++ b/src/gui/qt/sound/androidaudio.h @@ -13,11 +13,13 @@ #include #include +class ConfigFile; + class AndroidAudio : public QObject { Q_OBJECT public: - explicit AndroidAudio(QObject *parent = 0); + explicit AndroidAudio(ConfigFile *c, QObject *parent = 0); ~AndroidAudio(); signals: @@ -27,6 +29,9 @@ public slots: void registerSound(const QString& path, const QString &name); void reallyPlaySound(const QString& name); void playSound(const std::string& name, int i); + void initAudio(); + void closeAudio(); + void reInit(); private: void createEngine(); @@ -48,6 +53,8 @@ private: QMap mSounds; int32_t mSoundCount; + ConfigFile *myConfig; + bool audioEnabled; }; #endif // ANDROIDAUDIO_H diff --git a/src/gui/qt/sound/androidsoundeffect.cpp b/src/gui/qt/sound/androidsoundeffect.cpp index 3e8b9f73..4d82bba0 100644 --- a/src/gui/qt/sound/androidsoundeffect.cpp +++ b/src/gui/qt/sound/androidsoundeffect.cpp @@ -19,7 +19,7 @@ bool AndroidSoundEffect::load() { QFile lSoundFile(mPath); - qDebug() << "opening:" << mPath; +// qDebug() << "opening:" << mPath; if (!lSoundFile.open(QIODevice::ReadOnly)) { qDebug() << "Could not open: " << mPath; @@ -27,7 +27,7 @@ bool AndroidSoundEffect::load() } // parse WAV file - qDebug() << " reading header:"; +// qDebug() << " reading header:"; char id[4]; lSoundFile.read(id, 4); @@ -39,7 +39,7 @@ bool AndroidSoundEffect::load() int size = 0; lSoundFile.read((char *)&size, 4); - qDebug() << " size:" << size; +// qDebug() << " size:" << size; lSoundFile.read(id, 4); if( strncmp(id, "WAVE", 4) != 0 ) { @@ -52,29 +52,29 @@ bool AndroidSoundEffect::load() int format_length = 0; lSoundFile.read((char *)&format_length, 4); - qDebug() << " format_length:" << format_length; +// qDebug() << " format_length:" << format_length; short format_tag = 0; lSoundFile.read((char *)&format_tag, 2); short n_channels = 0; lSoundFile.read((char *)&n_channels, 2); - qDebug() << " n_channels:" << n_channels; +// qDebug() << " n_channels:" << n_channels; int sample_rate = 0; lSoundFile.read((char *)&sample_rate, 4); - qDebug() << " sample_rate:" << sample_rate; +// qDebug() << " sample_rate:" << sample_rate; int avg_bytes_sec = 0; lSoundFile.read((char *)&avg_bytes_sec, 4); - qDebug() << " avg_bytes_sec:" << avg_bytes_sec; +// qDebug() << " avg_bytes_sec:" << avg_bytes_sec; short block_align = 0; lSoundFile.read((char *)&block_align, 2); short bits_per_sample = 0; lSoundFile.read((char *)&bits_per_sample, 2); - qDebug() << " bits_per_sample:" << bits_per_sample; +// qDebug() << " bits_per_sample:" << bits_per_sample; lSoundFile.read(id, 4); if( strncmp(id, "data", 4) != 0 ) { @@ -85,7 +85,7 @@ bool AndroidSoundEffect::load() lSoundFile.read((char *)&mLength, 4); - qDebug() << " reading data:" << mLength; +// qDebug() << " reading data:" << mLength; mBuffer = (char*)malloc((mLength)); @@ -98,7 +98,7 @@ bool AndroidSoundEffect::load() return false; } - qDebug() << " closing:"; +// qDebug() << " closing:"; lSoundFile.close(); return true; } diff --git a/src/gui/qt/sound/sdlplayer.cpp b/src/gui/qt/sound/sdlplayer.cpp index 0f2776ea..a9beea86 100644 --- a/src/gui/qt/sound/sdlplayer.cpp +++ b/src/gui/qt/sound/sdlplayer.cpp @@ -17,40 +17,31 @@ *****************************************************************************/ #include "sdlplayer.h" -#ifndef ANDROID #if (defined __APPLE__) #include #else #include #endif -#endif using namespace std; SDLPlayer::SDLPlayer(ConfigFile *c) -#ifndef ANDROID : sound(NULL), soundData(NULL), currentChannel(0), audioEnabled(FALSE), myConfig(c) -#endif { -#ifndef ANDROID myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); SDL_Init(SDL_INIT_AUDIO); initAudio(); -#endif } SDLPlayer::~SDLPlayer() { -#ifndef ANDROID closeAudio(); SDL_Quit(); -#endif } void SDLPlayer::initAudio() { -#ifndef ANDROID if (!audioEnabled && myConfig->readConfigInt("PlaySoundEffects")) { int audio_rate = 44100; Uint16 audio_format = AUDIO_S16; /* 16-bit stereo */ @@ -66,12 +57,10 @@ void SDLPlayer::initAudio() qDebug() << "Mix_OpenAudio() was not successfull, no sound possible :("; } } -#endif } void SDLPlayer::playSound(string audioString, int playerID) { -#ifndef ANDROID if(audioEnabled && myConfig->readConfigInt("PlaySoundEffects")) { QFile myFile(myAppDataPath + "sounds/default/" + QString::fromStdString(audioString)+".wav"); @@ -142,13 +131,10 @@ void SDLPlayer::playSound(string audioString, int playerID) currentChannel = Mix_PlayChannel(-1, sound,0); } } -#endif } void SDLPlayer::closeAudio() -{ -#ifndef ANDROID - if(audioEnabled) { +{ if(audioEnabled) { Mix_HaltChannel(currentChannel); Mix_FreeChunk(sound); sound = NULL; @@ -158,5 +144,10 @@ void SDLPlayer::closeAudio() qDebug() << "Mix_CloseAudio()"; audioEnabled = false; } -#endif +} + +void SDLPlayer::reInitAudio() +{ + closeAudio(); + initAudio(); } diff --git a/src/gui/qt/sound/sdlplayer.h b/src/gui/qt/sound/sdlplayer.h index fae84e1b..c2530880 100644 --- a/src/gui/qt/sound/sdlplayer.h +++ b/src/gui/qt/sound/sdlplayer.h @@ -23,12 +23,10 @@ #include "configfile.h" #include -#ifndef ANDROID #ifdef __APPLE__ #include #else #include -#endif #endif struct Mix_Chunk; @@ -48,18 +46,15 @@ public: void initAudio(); void playSound(std::string, int playerID); void closeAudio(); + void reInitAudio(); private: - -#ifndef ANDROID Mix_Chunk *sound; unsigned char *soundData; int currentChannel; bool audioEnabled; ConfigFile *myConfig; QString myAppDataPath; - -#endif }; #endif diff --git a/src/gui/qt/sound/soundevents.cpp b/src/gui/qt/sound/soundevents.cpp index 01c1c5d8..a7cfd1fd 100644 --- a/src/gui/qt/sound/soundevents.cpp +++ b/src/gui/qt/sound/soundevents.cpp @@ -18,7 +18,7 @@ SoundEvents::SoundEvents(ConfigFile *c): myConfig(c), lastSBValue(0), lastSBLeve { #ifdef ANDROID - myPlayer = new AndroidAudio(); + myPlayer = new AndroidAudio(myConfig); #else myPlayer = new SDLPlayer(myConfig); #endif @@ -30,6 +30,11 @@ SoundEvents::~SoundEvents() myPlayer->deleteLater(); } +void SoundEvents::reInitSoundEngine() +{ + myPlayer->reInit(); +} + void SoundEvents::blindsWereSet(int sB) { if(newGameNow) { diff --git a/src/gui/qt/sound/soundevents.h b/src/gui/qt/sound/soundevents.h index 15980e12..d559625a 100644 --- a/src/gui/qt/sound/soundevents.h +++ b/src/gui/qt/sound/soundevents.h @@ -21,6 +21,7 @@ public: void blindsWereSet(int sB); void newGameStarts(); void playSound(std::string audioString, int playerID); + void reInitSoundEngine(); protected: // Prevent copy construction.