Пример #1
0
void CSoundManager::StopAllSongs(bool Paused)
{
	for (int i = 0; i < MAX_SONGS; i++)
		if (its_Songs[i] != NULL &&
			FMUSIC_IsPlaying(its_Songs[i]->SongData))
			StopSong(i, Paused);
}
Пример #2
0
void RudeSound::Tick(float delta)
{
	if(m_bgmVolFadeEnabled && m_curBGM != kBGMNone)
	{
		m_bgmVol += m_bgmVolFade * delta;
		
		if(m_bgmVol > 1.0f)
		{
			m_bgmVol = 1.0f;
			m_bgmVolFade = 0.0f;
			m_bgmVolFadeEnabled = false;
		}
		else if(m_bgmVol < 0.0f)
		{
			m_bgmVol = 0.0f;
			m_bgmVolFade = 0.0f;
			m_bgmVolFadeEnabled = false;
			
			StopSong();
			return;
		}
		
#if defined(RUDE_IPHONE) || defined(RUDE_MACOS)
		SoundEngine_SetBackgroundMusicVolume(m_bgmVol);
#endif
		
	}
}
Пример #3
0
/**
 * Starts playing a new song.
 *
 * @param filename Path to a MIDI file.
 */
void MusicDriver_QtMidi::PlaySong(const MusicSongInfo &song)
{
	if (!_quicktime_started) return;

	std::string filename = MidiFile::GetSMFFile(song);
	if (filename.empty()) return;

	DEBUG(driver, 2, "qtmidi: trying to play '%s'", filename.c_str());
	switch (_quicktime_state) {
		case QT_STATE_PLAY:
			StopSong();
			DEBUG(driver, 3, "qtmidi: previous tune stopped");
			FALLTHROUGH;

		case QT_STATE_STOP:
			DisposeMovie(_quicktime_movie);
			DEBUG(driver, 3, "qtmidi: previous tune disposed");
			_quicktime_state = QT_STATE_IDLE;
			FALLTHROUGH;

		case QT_STATE_IDLE:
			LoadMovieForMIDIFile(filename.c_str(), &_quicktime_movie);
			SetMovieVolume(_quicktime_movie, VOLUME);
			StartMovie(_quicktime_movie);
			_quicktime_state = QT_STATE_PLAY;
	}
	DEBUG(driver, 3, "qtmidi: playing '%s'", filename.c_str());
}
Пример #4
0
void WinGame(){

	while(GetMasterVolume()){
		if(GetMasterVolume() > 4)
			SetMasterVolume(GetMasterVolume()-4);
		else{
			StopSong();
			break;
		}
		WaitVsync(1);
	}
	FadeOut(9,true);
	SetTileTable(font_tiles);
	ClearVram();
	WaitVsync(45);
	SetMasterVolume(BB_MASTER_VOLUME);
	//TriggerNote(4,24,8,255);//StartSong(main_song);
	FadeIn(2,false);
	TextWriter(1,0,epilogue_string);
	while(1){
		WaitVsync(1);
		if(padState & BTN_START && !(oldPadState & BTN_START))
			break;
	}
	FadeOut(7,true);
}
void ClientSongManager::Update()
{
    uint soundID;                       // song ID for the sound manager
    uint32 songID;                      // song ID for the server
    csArray<uint32> songsToDelete;      // ended songs

    iSoundManager* sndMngr = psengine->GetSoundManager();

    // checking main player song
    if(mainSongID != NO_SONG
       && mainSongID != (uint)PENDING
       && !sndMngr->IsSoundValid(mainSongID))
    {
        StopMainPlayerSong(false);
    }

    // detecting ended songs
    csHash<uint, uint32>::GlobalIterator songIter(songMap.GetIterator());
    while(songIter.HasNext())
    {
        soundID = songIter.Next(songID);

        if(!sndMngr->IsSoundValid(soundID))
        {
            songsToDelete.Push(songID);
            StopSong(soundID);
        }
    }

    // deleting ended songs
    for(size_t i = 0; i < songsToDelete.GetSize(); i++)
    {
        songMap.DeleteAll(songsToDelete[i]);
    }
}
Пример #6
0
void audio::AudioEngineFmod::PlaySong(const std::string& path /* TODO: Better parameter to identify which song to play? */)
{
	// Ignoring if this song is already playing
	CHECK_CONDITION_RETURN_VOID_ALWAYS_AUDIO(m_currentSongPath != path, utility::logging::DEBUG, "The song \"", m_currentSongPath, "\" is already playing");

	// If a song is playing stop then and set this as the next song
	if (m_currentSong != nullptr)
	{
		StopSong();
		m_nextSongPath = path;
		return;
	}

	// Find the song in the corresponding sound map
	const auto soundItr = m_sounds[categories::SONG].find(path);
	CHECK_CONDITION_RETURN_VOID_ALWAYS_AUDIO(soundItr != m_sounds[categories::SONG].end(), utility::logging::WARNING,
		"Cannot play the requested song \"", path, "\". It has not been loaded yet.");

	// Start playing song with volume set to 0 and fade in
	m_currentSongPath = path;
	m_system->playSound(soundItr->second, m_groups[categories::SONG], true, &m_currentSong);
	//m_currentSong->setChannelGroup
	m_currentSong->setVolume(0.0f);
	m_currentSong->setPaused(false);
	m_fade = fade_states::FADE_IN;
}
Пример #7
0
/**
 * \brief Setup for custom intro
 */
void initIntro(void)
{
	StopSong(); //don't play song during intro
	MapSprite2(0, player_sprites[0], 0); //setup blue ghost for drawing
	player_x = 0; //set ghost to far left
	player_y = 80; //center ghost vertically
	SetTileTable(logo_tileset); //setup tiles for drawing uzebox logo
}
Пример #8
0
void StartGame(void)
{	
	if (playstate!=EX_LOADGAME) {	/* Variables already preset */
		NewGame();				/* init basic game stuff */
	}
	SetupPlayScreen();
	GameLoop();			/* Play the game */
	StopSong();			/* Make SURE music is off */
}
Пример #9
0
//
// UnregisterSong
//
static void UnregisterSong()
{
    if (!music)
        return;

    StopSong();
    Mix_FreeMusic(music);
    rw = NULL;
    music = NULL;
}
Пример #10
0
void CDemo::Destroy (void)
{
    CModeScreen::Destroy();

    m_Font.Destroy();
    m_AiManager.Destroy();

    StopSong();
    DestroyHurryUpMessage();
    DestroyMainComponents();
}
Пример #11
0
void CMatch::Destroy (void)
{
    CModeScreen::Destroy();

    if ( computerPlayersPresent ) {
        m_AiManager.Destroy();
    }

    DestroyHurryUpMessage();
    DestroyPauseMessage();
    DestroyMainComponents();
    StopSong();
}
Пример #12
0
bool RudeSound::ToggleMusic()
{
	m_musicOn = !m_musicOn;
	
	if(!m_musicOn)
	{
		StopSong();
	}
	
	RudeRegistry *reg = RudeRegistry::GetSingleton();
	reg->SetByte("GOLF", "RS_MUSIC", &m_musicOn, sizeof(m_musicOn));
	
	return m_musicOn;
}
Пример #13
0
void PlayDifferentSong(){
#ifdef FASTDEBUG
return;
#endif
	if(music_off){
		StopSong();
		return;
	}
	if(current_song == 1){
		StartSong(Song1);
		current_song = 2;
	}else{
		StartSong(Song2);
		current_song = 1;
	}

}
Пример #14
0
/**
 * \brief Handles input for gameplay. Reads player 1 joypad and processes input for the main game.
 */
void processControls(void){
	//read current player 1 input, save in joy variable
	joy=ReadJoypad(0);

	if(joy) //if any button at is is being pressed
	{
		if(scrollingOn) //if we're scrolling the screen (player is alive)
		{
			if(lastbuttons!=joy) //if we're pressing a new button, not holding one
			{
				yspeed = -jumpspeed; //make player jump up
				TriggerFx(4,0x88,true);//play our bouncing sound effects
				TriggerFx(5,0x88,true);
				grav_tick=1; //reset gravity ticks. doing this ensures that no matter where the gravity timer was, we always get a consistent jump height
			}
		}
		else if(joy&BTN_START) //if player is dead and start was pressed
		{
			if(deathclock<105)
			game_state = HIGH_SCORES; //exit main game state, enter high score screen state (refer to main function)
		}

		if(joy&BTN_SELECT)//alive or note, if select was pressed...
		{
			if(lastbuttons!=joy) //if it was JUST pressed and not held
			{
				if(mute) //if volume is muted, unmute it
				{
					SetMasterVolume(0xff);
					mute=false;
					ResumeSong();
				}
				else //if volume is normal, mute it
				{
					StopSong();
					SetMasterVolume(0x00);
					mute=true;
				}
			}

		}
	}

	//save current input as lastbuttons so we can check if new buttons are pressed next time
	lastbuttons=joy;
}
void ClientSongManager::StopMainPlayerSong(bool notifyServer)
{
    // sending message
    if(notifyServer)
    {
        psStopSongMessage stopMessage;
        stopMessage.SendMessage();
    }

    // stopping song
    StopSong(mainSongID);
    mainSongID = NO_SONG;
    sheet.Empty();

    // updating listeners
    TriggerListeners();
}
Пример #16
0
void
MusicShutdown(void)
{
    int32_t status;

    // if they chose None lets return
    if (MusicDevice < 0)
        return;

    if (!MusicInitialized)
        return;

    StopSong();

    status = MUSIC_Shutdown();
    if (status != MUSIC_Ok)
    {
        buildprintf("Music error: %s\n",MUSIC_ErrorString(MUSIC_ErrorCode));
    }
}
Пример #17
0
/**
 * Stops the MIDI player.
 *
 * Stops playing and frees any used resources before returning. As it
 * deinitilizes QuickTime, the #_quicktime_started flag is set to @c false.
 */
void MusicDriver_QtMidi::Stop()
{
	if (!_quicktime_started) return;

	DEBUG(driver, 2, "qtmidi: stopping driver...");
	switch (_quicktime_state) {
		case QT_STATE_IDLE:
			DEBUG(driver, 3, "qtmidi: stopping not needed, already idle");
			/* Do nothing. */
			break;

		case QT_STATE_PLAY:
			StopSong();
			FALLTHROUGH;

		case QT_STATE_STOP:
			DisposeMovie(_quicktime_movie);
	}

	ExitMovies();
	_quicktime_started = false;
}
Пример #18
0
//
// MidiRPC_StopSong
//
// Stop the song.
//
void MidiRPC_StopSong()
{
    StopSong();
}
Пример #19
0
void CreditScreen()
{
#define MAX_DUTIES 21
#define MAX_CREDIT_LENGTH 400
	
#define CREDIT_REDFLASH 0
#define CREDIT_GREENFADE 1
	
	//#define PROMPT_TEXT_SPACE_X_OFFSETFROMLEFT 16
	//#define PROMPT_TEXT_SPACE_Y_OFFSETFROMTOP 4
	//#define PROMPT_TEXT_WIDTH	46
	//#define PROMPT_TEXT_HEIGHT 15
	
	RECT boxrect;
	int creditcounter;
	char duties[MAX_DUTIES][MAX_CREDIT_LENGTH] = {
		"THE AGENCY",
			"Based On \"The Agency\" Espionage Universe", 
			"Designer",
			"Lead Programmer",
			"Glamour Model",
			"Box / Manual Design",
			"Special Thanks To:", 
			"Special Thanks To:",
			"We Extend A Special Thank You To:",
			"We Extend A Special Thank You To:",
			"We Extend A Special Thank You To:",
			"Vorpal Design Group is a small west-coast game design group centered around the intelligence and military gaming enthusiast.",
			"The Agency is an original concept created by Charles Cox. For franchising information, and for info on how you can become a part of The Agency Universe, please contact Charles Cox, President of VDG at: [email protected]",
			"We will be bringing The Agency : Razor One to you in full 3d very soon. Please stay tuned to the company that brings the intelligence and military world to your computer:",
			"Vorpal",
			"VDG   ",
			"Charles Cox",
			"Wyatt Jackson",
			"Eddy Irwin",
			"Jennifer Dygert",
			"THANKS FOR PLAYING!"
	};
	
	char names[MAX_DUTIES][MAX_CREDIT_LENGTH] = {
		"RAZOR ONE",
			"By Charles Cox", 
			"Charles Cox",
			"Charles Cox",
			"Charlie \"Flowers\" From Jersey City",
			"Charles Cox",
			"Wyatt Jackson (Dr. J)",
			"\"Fast\" Eddy Irwin From Jersey City",
			"\"Big\" Bird",
			"Big \"Bird\"",
			"Bert \"and\" Ernie",
			"",
			"",
			"",
			"Design Group",
			"   IS",
			"President, CEO, Lead Designer",
			"Programmer",
			"Programmer / Designer",
			"Craft Services",
			"PRESS A KEY TO RETURN."
	} ; 
	
	int styles[MAX_DUTIES] = {
		CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_GREENFADE,
			CREDIT_GREENFADE,
			CREDIT_GREENFADE,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
			CREDIT_REDFLASH,
	};
	
	COORD dutydrawcoords;
	COORD namedrawcoords;
	COORD boxsize = {PROMPT_TEXT_WIDTH, PROMPT_TEXT_HEIGHT};
	COORD boxstart = {PROMPT_TEXT_SPACE_X_OFFSETFROMLEFT, PROMPT_TEXT_SPACE_Y_OFFSETFROMTOP};
	COORD zeroed = {0,0};
	
	
	boxrect.left = PROMPT_TEXT_SPACE_X_OFFSETFROMLEFT;
	boxrect.top = PROMPT_TEXT_SPACE_Y_OFFSETFROMTOP;
	boxrect.right = PROMPT_TEXT_SPACE_X_OFFSETFROMLEFT+PROMPT_TEXT_WIDTH;
	boxrect.bottom = PROMPT_TEXT_SPACE_Y_OFFSETFROMTOP + PROMPT_TEXT_HEIGHT;
	
	
	LoopSong(globals.musiclist.songs[CREDITS_SONG]);
	
	styles[MAX_DUTIES - 1] = CREDIT_REDFLASH; //THE LAST CREDIT MUST ALWAYS BE REDFLASH.
	
	GREEN;
	printgraphic(globals.graphicslist, zeroed,  PROMPT_GRAPHIC_ID);
	for (creditcounter = 0; creditcounter < MAX_DUTIES; creditcounter++){
		if (styles[creditcounter] == CREDIT_REDFLASH)
		{
			ClearRect(boxrect);
			dutydrawcoords = retrieveTextCenter(duties[creditcounter]);
			dutydrawcoords.Y --;
			namedrawcoords = retrieveTextCenter(names[creditcounter]);
			RED;
			setcursor(dutydrawcoords.X, dutydrawcoords.Y);
			bufferprint(1, duties[creditcounter]);
			setcursor(dutydrawcoords.X, dutydrawcoords.Y);
			LRED;
			bufferprint(1, duties[creditcounter]);
			Sleep(200);
			RED;
			setcursor(namedrawcoords.X, namedrawcoords.Y);
			bufferprint(1, names[creditcounter]);
			setcursor(namedrawcoords.X, namedrawcoords.Y);
			LRED;
			bufferprint(1, names[creditcounter]);
			if (creditcounter < MAX_DUTIES - 1)
			{
				Sleep(3500);
				
				RED;
				setcursor(dutydrawcoords.X, dutydrawcoords.Y);
				printf(duties[creditcounter]);
				setcursor(dutydrawcoords.X, dutydrawcoords.Y);
				RED;
				setcursor(namedrawcoords.X, namedrawcoords.Y);
				printf(names[creditcounter]);
				setcursor(namedrawcoords.X, namedrawcoords.Y);
				Sleep(80);
				setcursor(namedrawcoords.X, namedrawcoords.Y);
				cleartext(names[creditcounter]);
				setcursor(dutydrawcoords.X, dutydrawcoords.Y);
				cleartext(duties[creditcounter]);
				Sleep(1000);
			}
			else{
				FLUSH;
				clearinputrecords();
				waitforkey();
				StopSong();
				cls();
				return;
			}
		}
		else if (styles[creditcounter] == CREDIT_GREENFADE)
		{
			ClearRect(boxrect);
			GREEN;
			
			printwordwrapcoordinate(duties[creditcounter], boxsize, boxstart);
			Sleep(80);
			LGREEN;
			
			printwordwrapcoordinate(duties[creditcounter], boxsize, boxstart);
			Sleep(10000);
			GREEN;
			
			printwordwrapcoordinate(duties[creditcounter], boxsize, boxstart);
			Sleep(80);
			ClearRect(boxrect);
			Sleep(1000);
		}
	}
	
}
Пример #20
0
unsigned char processControls(void){
	static unsigned char ov=4,scroll=0;
	static int lastbuttons=0;
	unsigned int joy=ReadJoypad(0);


	if(joy&BTN_A){
		if(action!=ACTION_JUMP){
			action=ACTION_JUMP;
			frame=0;
			jmpPos=0;
		}
	
	}else if(joy&BTN_X){
		Scroll(0,1);	
	//	while(ReadJoypad(0)!=0);
	}else if(joy&BTN_Y){
		Scroll(0,-1);
	//	while(ReadJoypad(0)!=0);
	}else if(joy&BTN_SR){
	//	Scroll(1,0);
	//	while(ReadJoypad(0)!=0);
	}else if(joy&BTN_SL){
	//	Scroll(-1,0);
	//	while(ReadJoypad(0)!=0);
	}else if(joy&BTN_UP){
		//if(sy==0)sy=(VRAM_TILES_V*8);
		//sy--;
		//while(ReadJoypad(0)!=0);

	}else if(joy&BTN_DOWN){
		//sy++;
		//if(sy>=(VRAM_TILES_V*8))sy=0;
	//	while(ReadJoypad(0)!=0);
	
	}
	
	if(joy&BTN_LEFT){
		
		//while(ReadJoypad(0)!=0);
		
		if(action==ACTION_IDLE){
			action=ACTION_WALK;
			dx=-1;
			frame=0;
			stopping=false;
			walkFrame=0;
			lastWalkDir=BTN_LEFT;
			sprDir=-1;
		}
		
		
	}else if(joy&BTN_RIGHT){

		//while(ReadJoypad(0)!=0);

		
		if(action==ACTION_IDLE){
			action=ACTION_WALK;
			dx=1;
			frame=0;
			stopping=false;
			walkFrame=0;
			lastWalkDir=BTN_RIGHT;
			sprDir=1;
		}
		
		if(sx>=110){

			if(joy&BTN_B){
				Scroll(2,0);
				scroll+=2;
			}else{
				Scroll(1,0);
				scroll++;
			}
			
			if(scroll>=8){
				loadNextStripe();
				scroll=0;
			}
		}

	
	}

	if(joy&BTN_START){
		ov++;
		if(ov>OVERLAY_LINES)ov=0;

		Screen.overlayHeight=ov;
		while(ReadJoypad(0)!=0);
	}

	if(joy&BTN_SELECT){
		StopSong();
		while((ReadJoypad(0)&BTN_SELECT)!=0);
	}


	


	if(stopping==true && stopFrame==1){
		action=ACTION_IDLE;
		stopping=false;
		dx=0;
	}else if(lastWalkDir!= (joy & (BTN_LEFT+BTN_RIGHT)) && action==ACTION_WALK){
		
		if((joy & (BTN_LEFT+BTN_RIGHT))!=0 ){
			frame=17;
		}else{
			stopping=true;
			stopFrame=0;
		}
	}
	

	lastbuttons=joy;
	lastWalkDir= joy & (BTN_LEFT+BTN_RIGHT);


	return 0;
}
Пример #21
0
SWBOOL
PlaySong(char *song_file_name, int cdaudio_track, SWBOOL loop, SWBOOL restart)
{
    if (!gs.MusicOn)
    {
        return FALSE;
    }

    if (DemoMode)
        return FALSE;

    if (!restart)
    {
        if (SongType == SongTypeWave)
        {
            if (SongTrack > 0 && SongTrack == cdaudio_track)
            {
                // ogg replacement for a CD track
                return TRUE;
            }
            else if (SongName && song_file_name && !strcmp(SongName, song_file_name))
            {
                return TRUE;
            }
        }
        else if (SongType == SongTypeMIDI)
        {
            if (SongName && song_file_name && !strcmp(SongName, song_file_name))
            {
                return TRUE;
            }
        }
    }

    StopSong();

    if (!SW_SHAREWARE)
    {
        if (cdaudio_track >= 0)
        {
            char waveformtrack[MAXWAVEFORMTRACKLENGTH];
            Bstrncpy(waveformtrack, gs.WaveformTrackName, MAXWAVEFORMTRACKLENGTH - 1);

            char *numPos = Bstrstr(waveformtrack, "??");

            if (numPos && (numPos-waveformtrack) < MAXWAVEFORMTRACKLENGTH - 2)
            {
                static const char *tracktypes[] = { ".flac", ".ogg" };
                const size_t tracknamebaselen = Bstrlen(waveformtrack);
                size_t i;

                numPos[0] = '0' + (cdaudio_track / 10) % 10;
                numPos[1] = '0' + cdaudio_track % 10;

                for (i = 0; i < ARRAY_SIZE(tracktypes); ++i)
                {
                    waveformtrack[tracknamebaselen] = '\0';
                    Bstrncat(waveformtrack, tracktypes[i], MAXWAVEFORMTRACKLENGTH);

                    if (LoadSong(waveformtrack))
                    {
                        SongVoice = FX_PlayLoopedAuto(SongPtr, SongLength, 0, 0, 0,
                                                      255, 255, 255, FX_MUSIC_PRIORITY, MUSIC_ID);
                        if (SongVoice > FX_Ok)
                        {
                            SongType = SongTypeWave;
                            SongTrack = cdaudio_track;
                            SongName = Bstrdup(waveformtrack);
                            return TRUE;
                        }
                    }
                }

                buildprintf("Can't find CD track %i!\n", cdaudio_track);
            }
            else
            {
                buildprintf("Make sure to have \"??\" as a placeholder for the track number in your WaveformTrackName!\n");
                buildprintf("  e.g. WaveformTrackName = \"MUSIC/Track??\"\n");
            }
        }
    }

    if (!song_file_name || !LoadSong(song_file_name))
    {
        return FALSE;
    }

    if (!memcmp(SongPtr, "MThd", 4))
    {
        MUSIC_PlaySong(SongPtr, /*SongLength,*/  MUSIC_LoopSong);
        SongType = SongTypeMIDI;
        SongName = strdup(song_file_name);
        return TRUE;
    }
    else
    {
        SongVoice = FX_PlayLoopedAuto(SongPtr, SongLength, 0, 0, 0,
                                      255, 255, 255, FX_MUSIC_PRIORITY, MUSIC_ID);
        if (SongVoice > FX_Ok)
        {
            SongType = SongTypeWave;
            SongName = strdup(song_file_name);
            return TRUE;
        }
    }

    return FALSE;
}
Пример #22
0
void
StopSound(void)
{
    StopFX();
    StopSong();
}
Пример #23
0
void CharacterCast(void)
{
    Word Enemy,count, cycle;
    Word up;
    state_t *StatePtr;

    /* reload level and set things up */

    gamestate.mapon = 0;		/* First level again */
    PrepPlayLoop();				/* Prepare the system */
    viewx = actors[0].x;		/* Mark the starting x,y */
    viewy = actors[0].y;

    topspritescale = 32*2;

    /* go through the cast */

    Enemy = 0;
    cycle = 0;
    do {
        StatePtr = &states[caststate[Enemy]];		/* Init the state pointer */
        count = 1;			/* Force a fall through on first pass */
        up = FALSE;
        for (;;) {
            if (++cycle>=60*4) {		/* Time up? */
                cycle = 0;				/* Reset the clock */
                if (++Enemy>=NUMCAST) {	/* Next bad guy */
                    Enemy = 0;			/* Reset the bad guy */
                }
                break;
            }
            if (!--count) {
                count = StatePtr->tictime;
                StatePtr = &states[StatePtr->next];
            }
            topspritenum = StatePtr->shapenum;	/* Set the formost shape # */
            RenderView();		/* Show the 3d view */
            WaitTicks(1);		/* Limit to 15 frames a second */
            ReadSystemJoystick();	/* Read the joystick */
            if (!joystick1 && !up) {
                up = TRUE;
                continue;
            }
            if (!up) {
                continue;
            }
            if (!joystick1) {
                continue;
            }
            if (joystick1 & (JOYPAD_START|JOYPAD_A|JOYPAD_B|JOYPAD_X|JOYPAD_Y)) {
                Enemy = NUMCAST;
                break;
            }
            if ( (joystick1 & (JOYPAD_TL|JOYPAD_LFT)) && Enemy >0) {
                Enemy--;
                break;
            }
            if ( (joystick1 & (JOYPAD_TR|JOYPAD_RGT)) && Enemy <NUMCAST-1) {
                Enemy++;
                break;
            }
        }
    } while (Enemy < NUMCAST);	/* Still able to show */
    StopSong();		/* Stop the music */
    FadeToBlack();	/* Fade out */
}
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);
        }
    }
}
Пример #25
0
void CVictory::Destroy (void)
{
    CModeScreen::Destroy();
    StopSong();
}