From f8da36d44f8564c55ea3a4fadd87f51f19b426f3 Mon Sep 17 00:00:00 2001 From: Heiko Koehn Date: Sat, 11 Jun 2011 18:54:06 +0200 Subject: [PATCH] finished sound support --- src/TLuaInterpreter.cpp | 5 +++-- src/TMap.cpp | 3 ++- src/TTrigger.cpp | 4 +--- src/mudlet.cpp | 32 ++++++++++++++++++++++++++++++-- src/mudlet.h | 7 ++++++- 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/TLuaInterpreter.cpp b/src/TLuaInterpreter.cpp index 6581264ee..b8e9b5340 100644 --- a/src/TLuaInterpreter.cpp +++ b/src/TLuaInterpreter.cpp @@ -3248,9 +3248,10 @@ int TLuaInterpreter::playSoundFile( lua_State * L ) sound.replace('/', "\\"); } else + { sound.replace('\\', "/"); - Phonon::MediaObject *music = Phonon::createPlayer(Phonon::MusicCategory, Phonon::MediaSource(sound.toLatin1().data())); - music->play(); + } + mudlet::self()->playSound( sound ); return 0; } diff --git a/src/TMap.cpp b/src/TMap.cpp index aa64b11ec..6ba9ef915 100644 --- a/src/TMap.cpp +++ b/src/TMap.cpp @@ -86,7 +86,7 @@ void TMap::deleteRoom( int id ) } qDebug()<<"====> finally remoning room ID:"< kL = hashTable.keys(id); @@ -114,6 +114,7 @@ void TMap::deleteArea( int id ) } areas.remove( id ); areaNamesMap.remove( id ); + mMapGraphNeedsUpdate = true; } } diff --git a/src/TTrigger.cpp b/src/TTrigger.cpp index 95113f89b..0e31b2dad 100644 --- a/src/TTrigger.cpp +++ b/src/TTrigger.cpp @@ -1447,9 +1447,7 @@ void TTrigger::execute() { if( mSoundTrigger ) { - //QSound::play( mSoundFile ); - Phonon::MediaObject * music = Phonon::createPlayer(Phonon::MusicCategory, Phonon::MediaSource( mSoundFile )); - music->play(); + mudlet::self()->playSound( mSoundFile ); } if( mCommand.size() > 0 ) { diff --git a/src/mudlet.cpp b/src/mudlet.cpp index ef358ce23..9fe49a097 100644 --- a/src/mudlet.cpp +++ b/src/mudlet.cpp @@ -92,6 +92,10 @@ mudlet::mudlet() , actionReplaySpeedDown( 0 ) , actionReplaySpeedUp( 0 ) , mpIRC( 0 ) +, mpMusicBox1(Phonon::createPlayer(Phonon::MusicCategory) ) +, mpMusicBox2(Phonon::createPlayer(Phonon::MusicCategory) ) +, mpMusicBox3(Phonon::createPlayer(Phonon::MusicCategory) ) +, mpMusicBox4(Phonon::createPlayer(Phonon::MusicCategory) ) #ifdef Q_OS_LINUX, , version( "Mudlet 2.0-rc7-Linux June 2011" ) #endif @@ -103,7 +107,6 @@ mudlet::mudlet() #endif { setupUi(this); - setUnifiedTitleAndToolBarOnMac( true ); setContentsMargins(0,0,0,0); mudlet::debugMode = false; @@ -958,6 +961,8 @@ bool mudlet::setConsoleBufferSize( Host * pHost, QString & name, int x1, int y1 return false; } + + bool mudlet::resetFormat( Host * pHost, QString & name ) { QMap & dockWindowConsoleMap = mHostConsoleMap[pHost]; @@ -1984,4 +1989,27 @@ void mudlet::slot_replaySpeedDown() replaySpeedDisplay->show(); } - +void mudlet::playSound( QString s ) +{ + if( mpMusicBox1->remainingTime() == 0 ) + { + mpMusicBox1->setCurrentSource( s ); + mpMusicBox1->play(); + } + else if( mpMusicBox2->remainingTime() == 0 ) + { + mpMusicBox2->setCurrentSource( s ); + mpMusicBox2->play(); + } + else if( mpMusicBox3->remainingTime() == 0 ) + { + mpMusicBox3->setCurrentSource( s ); + mpMusicBox3->play(); + } + else + { + mpMusicBox4->clear(); + mpMusicBox4->setCurrentSource( s ); + mpMusicBox4->play(); + } +} diff --git a/src/mudlet.h b/src/mudlet.h index 0f68ce729..18062fdd8 100644 --- a/src/mudlet.h +++ b/src/mudlet.h @@ -36,6 +36,7 @@ #include #include "TConsole.h" #include "ui_main_window.h" +#include class QAction; class QMenu; @@ -132,7 +133,7 @@ public: //QString readProfileData( QString profile, QString item ); void doAutoLogin( QString & ); void deselect( Host * pHost, QString & name ); - + void playSound( QString s ); QTime mReplayTime; int mReplaySpeed; QToolBar * mpMainToolBar; @@ -142,6 +143,10 @@ public: Host * mpCurrentActiveHost; bool mAutolog; QString mIrcNick; + Phonon::MediaObject * mpMusicBox1; + Phonon::MediaObject * mpMusicBox2; + Phonon::MediaObject * mpMusicBox3; + Phonon::MediaObject * mpMusicBox4;