bool CMusicConsoleButton::LeaveViewMsg(CLeaveViewMsg *msg) { if (_isActive) { CStopMusicMsg stopMsg(this); stopMsg.execute(this); stopMovie(); loadFrame(0); } return true; }
bool CMusicConsoleButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { if (_isActive) { CStopMusicMsg stopMsg(this); stopMsg.execute(this); stopMovie(); loadFrame(0); } else { CStartMusicMsg startMsg(this); startMsg.execute(this); playMovie(MOVIE_REPEAT); CMusicHasStartedMsg startedMsg; startedMsg.execute("Music Room Phonograph"); if (CMusicRoom::_musicHandler->checkSound(1) && CMusicRoom::_musicHandler->checkSound(2) && CMusicRoom::_musicHandler->checkSound(3)) { CCorrectMusicPlayedMsg correctMsg; correctMsg.execute(findRoom()); } } return true; }
void ClientSongManager::HandleMessage(MsgEntry* message) { uint8_t msgType = message->GetType(); // Playing if(msgType == MSGTYPE_PLAY_SONG) { uint songHandleID; csVector3 playerPos; iSoundManager* sndMngr; psPlaySongMessage playMsg(message); // getting player's position playerPos = psengine->GetCelClient()->FindObject(playMsg.songID)->GetMesh()->GetMovable()->GetFullPosition(); // if sounds are not active the song will still be heard by players around sndMngr = psengine->GetSoundManager(); if(sndMngr->IsSoundActive(iSoundManager::INSTRUMENT_SNDCTRL)) { // playing if(playMsg.toPlayer) { songHandleID = PlaySong(sheet, playMsg.instrName, playerPos); } else { // decompressing score csString uncompressedScore; psMusic::ZDecompressSong(playMsg.musicalScore, uncompressedScore); songHandleID = PlaySong(uncompressedScore, playMsg.instrName, playerPos); } // handling instrument not defined if(songHandleID == 0) { // stopping song, informing server and player if(playMsg.toPlayer) { // noticing server StopMainPlayerSong(true); // noticing user psSystemMessage msg(0, MSG_ERROR, PawsManager::GetSingleton().Translate("You cannot play this song!")); msg.FireEvent(); } return; } // saving song ID if(playMsg.toPlayer) { mainSongID = songHandleID; } else { songMap.Put(playMsg.songID, songHandleID); } } else { mainSongID = NO_SONG; } } // Stopping else if(msgType == MSGTYPE_STOP_SONG) { psStopSongMessage stopMsg(message); if(stopMsg.toPlayer) { csString errorStr; if(mainSongID == (uint)PENDING) // no instrument equipped, invalid MusicXML or low skill { // updating mainSongId mainSongID = NO_SONG; // updating listeners TriggerListeners(); } else if(mainSongID == NO_SONG) // sound are deactivated or song has ended { TriggerListeners(); } else // player's mode has changed { StopMainPlayerSong(false); } // noticing user switch(stopMsg.errorCode) { case psStopSongMessage::ILLEGAL_SCORE: errorStr = "Illegal musical score!"; break; case psStopSongMessage::NO_INSTRUMENT: errorStr = "You do not have an equipped musical instrument!"; break; } if(!errorStr.IsEmpty()) { psSystemMessage msg(0, MSG_ERROR, PawsManager::GetSingleton().Translate(errorStr)); msg.FireEvent(); } } else if(songMap.Contains(stopMsg.songID)) { StopSong(songMap.Get(stopMsg.songID, 0)); songMap.DeleteAll(stopMsg.songID); } } }