Ejemplo n.º 1
0
	virtual void OnClick(Point pt, int widget, int click_count)
	{
		switch (widget) {
			case MTSW_LIST_LEFT: { // add to playlist
				int y = this->GetRowFromWidget(pt.y, widget, 0, FONT_HEIGHT_SMALL);

				if (_msf.playlist < 4) return;
				if (!IsInsideMM(y, 0, BaseMusic::GetUsedSet()->num_available)) return;

				byte *p = _playlists[_msf.playlist];
				for (uint i = 0; i != NUM_SONGS_PLAYLIST - 1; i++) {
					if (p[i] == 0) {
						/* Find the actual song number */
						for (uint j = 0; j < NUM_SONGS_AVAILABLE; j++) {
							if (GetTrackNumber(j) == y + 1) {
								p[i] = j + 1;
								break;
							}
						}
						p[i + 1] = 0;
						this->SetDirty();
						SelectSongToPlay();
						break;
					}
				}
				break;
			}

			case MTSW_LIST_RIGHT: { // remove from playlist
				int y = this->GetRowFromWidget(pt.y, widget, 0, FONT_HEIGHT_SMALL);

				if (_msf.playlist < 4) return;
				if (!IsInsideMM(y, 0, NUM_SONGS_PLAYLIST)) return;

				byte *p = _playlists[_msf.playlist];
				for (uint i = y; i != NUM_SONGS_PLAYLIST - 1; i++) {
					p[i] = p[i + 1];
				}

				this->SetDirty();
				SelectSongToPlay();
				break;
			}

			case MTSW_CLEAR: // clear
				for (uint i = 0; _playlists[_msf.playlist][i] != 0; i++) _playlists[_msf.playlist][i] = 0;
				this->SetDirty();
				StopMusic();
				SelectSongToPlay();
				break;

			case MTSW_ALL: case MTSW_OLD: case MTSW_NEW:
			case MTSW_EZY: case MTSW_CUSTOM1: case MTSW_CUSTOM2: // set playlist
				SelectPlaylist(widget - MTSW_ALL);
				StopMusic();
				SelectSongToPlay();
				break;
		}
	}
Ejemplo n.º 2
0
void
StopDitty (void)
{
	if (dittyIsPlaying)
		StopMusic ();
	dittyIsPlaying = FALSE;
}
Ejemplo n.º 3
0
/**
**  Exit the game.
**
**  @param err  Error code to pass to shell.
*/
void Exit(int err)
{
	if (GameRunning) {
		StopGame(GameExit);
		return;
	}
	
	StopMusic();
	QuitSound();
	NetworkQuitGame();

	ExitNetwork1();
	CleanModules();
	FreeBurningBuildingFrames();
	FreeSounds();
	FreeGraphics();
	FreePlayerColors();
	FreeButtonStyles();
	FreeAllContainers();
	freeGuichan();
	DebugPrint("Frames %lu, Slow frames %d = %ld%%\n" _C_
			   FrameCounter _C_ SlowFrameCounter _C_
			   (SlowFrameCounter * 100) / (FrameCounter ? FrameCounter : 1));
	lua_settop(Lua, 0);
	lua_close(Lua);
	DeInitVideo();
#ifdef USE_PHYSFS
	if (PHYSFS_isInit()) {
		PHYSFS_deinit();
	}
#endif

	fprintf(stdout, "%s", _("Thanks for playing Stratagus.\n"));
	exit(err);
}
Ejemplo n.º 4
0
 void SoundHubObject::ToggleMusic()
 {
     if( Mix_PlayingMusic() )
         StopMusic();
     else
         PlayMusic( "", true );
 }
Ejemplo n.º 5
0
void Game::Go(){
	//pWnd->ShowMouseCursor(false);

	//objeto para recibir eventos
	Event evt;

	//Inicializa los objetos del juego
	Init();
	
	if(pWnd->IsOpened())
	{
		Intro();
		ShowMenu();		
	}
	while(pWnd->IsOpened()){
		//procesar eventos
		while (pWnd->GetEvent(evt))
			ProcessEvent(evt);

		//procesar colisiones
		ProcessCollisions();
		
		//actualizar estados de objetos
		UpdateGame();
		
		pWnd->Clear();
		
		DrawGame();
		
		pWnd->Display();
	}
	StopMusic();	
}
Ejemplo n.º 6
0
/**
**  Exit the game.
**
**  @param err  Error code to pass to shell.
*/
void Exit(int err)
{
	if (GameRunning) {
		StopGame(GameExit);
		return;
	}

	StopMusic();
	QuitSound();
	NetworkQuit();

	ExitNetwork1();
#ifdef DEBUG
	CleanModules();
	FreeBurningBuildingFrames();
	FreeSounds();
	FreeGraphics();
	FreePlayerColors();
	FreeButtonStyles();
	for (size_t i = 0; i < Containers.size(); ++i) {
		delete Containers[i];
	}
	freeGuichan();
	DebugPrint("Frames %lu, Slow frames %d = %ld%%\n" _C_
			   FrameCounter _C_ SlowFrameCounter _C_
			   (SlowFrameCounter * 100) / (FrameCounter ? FrameCounter : 1));
	lua_settop(Lua, 0);
	lua_close(Lua);
	DeInitVideo();
#endif

	fprintf(stdout, "%s", _("Thanks for playing Stratagus.\n"));
	exit(err);
}
Ejemplo n.º 7
0
/**
 * @brief Plays each note for its specified duration
 * @retval None
 */
void NoteHandler(void){
		
		durCount++;  //increment duration counter
		durCount2++;
		
		if(score1note->duration <= durCount)  //see if note has completed its duration
		  {
		    durCount = 0;
		    score1note++;       //go to next note
			CCR1_Val = score1note->noteName; 
			Blox_Timer_Modify_IRQ(score1ID, CCR1_Val);
			attack1 = 0; 
			decay1 = CCR1_Val;
			Out = 1024;
		  }
		  
		if(score2note->duration <= durCount2)  //see if note has completed its duration
		  {
		    durCount2 = 0;
		    score2note++;       //go to next note
			CCR2_Val = score2note->noteName; 
			Blox_Timer_Modify_IRQ(score2ID, CCR2_Val);
			attack2 = 0; 
			decay2 = CCR1_Val;
		    Out2 = 1024;
		  }
		  
		if((score1note->duration==0) ||( score2note->duration==0))
		  {
		    StopMusic();       //stop if score reaches end (should occur at the same time)
		  }  
}
Ejemplo n.º 8
0
void ALSound::CleanUp()
{
    if (m_enabled)
    {
        GetLogger()->Info("Unloading files and closing device...\n");
        StopAll();
        StopMusic();

        m_channels.clear();

        m_currentMusic.reset();

        m_oldMusic.clear();

        m_previousMusic.music.reset();

        m_sounds.clear();

        m_music.clear();

        m_enabled = false;

        alcDestroyContext(m_context);
        alcCloseDevice(m_device);
    }
}
Ejemplo n.º 9
0
void Audio::PlayMusic( std::string Filename, bool Loop )
{
	if( audioVoice == 0 || audioMixer == 0 )
	{
		return;
	}

	if( musicStream != nullptr )
	{
		StopMusic();
	}

	// Only play if Music is set
	if( FRAMEWORK->Settings->GetQuickBooleanValue( "Audio.Music", true ) )
	{

#ifdef WRITE_LOG
		fprintf( FRAMEWORK->LogFile, "Framework: Start audio file %s\n", Filename.c_str() );
#endif
		musicStream = al_load_audio_stream( Filename.c_str(), 4, 2048 );
		if( musicStream != nullptr )
		{
			al_attach_audio_stream_to_mixer( musicStream, audioMixer );
			al_set_audio_stream_playmode( musicStream, ( Loop ? ALLEGRO_PLAYMODE_LOOP : ALLEGRO_PLAYMODE_ONCE ) );
			FRAMEWORK->RegisterEventSource( al_get_audio_stream_event_source( musicStream ) );
			al_set_audio_stream_playing( musicStream, true );
		} else {
#ifdef WRITE_LOG
			fprintf( FRAMEWORK->LogFile, "Framework: Could not load music '%s'\n", Filename.c_str() );
#endif
		}

	}
}
Ejemplo n.º 10
0
/**
 * Change the configured music set and reset playback
 * @param index Index of music set to switch to
 */
void ChangeMusicSet(int index)
{
	if (BaseMusic::GetIndexOfUsedSet() == index) return;

	/* Resume playback after switching?
	 * Always if music is already playing, and also if the user is switching
	 * away from an empty music set.
	 * If the user switches away from an empty set, assume it's because they
	 * want to hear music now. */
	bool shouldplay = _song_is_active || (BaseMusic::GetUsedSet()->num_available == 0);
	StopMusic();

	const char *name = BaseMusic::GetSet(index)->name;
	BaseMusic::SetSet(name);
	free(BaseMusic::ini_set);
	BaseMusic::ini_set = stredup(name);

	InitializeMusic();
	ResetPlaylist();
	_settings_client.music.playing = shouldplay;

	InvalidateWindowData(WC_MUSIC_TRACK_SELECTION, 0);
	InvalidateWindowData(WC_MUSIC_WINDOW, 0);
	InvalidateWindowData(WC_GAME_OPTIONS, WN_GAME_OPTIONS_GAME_OPTIONS, 0, true);
}
Ejemplo n.º 11
0
void Quit()
{
	StopMusic();
    alureUpdateInterval(0);
	alureSleep(0.1f);
	alureShutdownDevice();
}
Ejemplo n.º 12
0
/**
**  Show the title screens
*/
void ShowTitleScreens()
{
	if (!TitleScreens || !CliMapName.empty()) {
		return;
	}

	SetVideoSync();

	for (int i = 0; TitleScreens[i]; ++i) {
		if ((Editor.Running && !TitleScreens[i]->Editor) || (!Editor.Running && TitleScreens[i]->Editor)) {
			continue;
		}

		if (!TitleScreens[i]->Music.empty()) {
			if (TitleScreens[i]->Music == "none" || PlayMusic(TitleScreens[i]->Music) == -1) {
				StopMusic();
			}
		}

		if (!TitleScreens[i]->File.empty() && PlayMovie(TitleScreens[i]->File)) {
			TitleScreens[i]->ShowTitleImage();
		}

		Video.ClearScreen();
	}
	Invalidate();
}
void AudioManagerSDL::Update()
{
	if (g_MusicHasFinished)
	{
		g_MusicHasFinished = false;
		StopMusic();
	}
}
Ejemplo n.º 14
0
/**
**  Set music enabled
*/
void SetMusicEnabled(bool enabled)
{
	if (enabled) {
		MusicEnabled = true;
	} else {
		MusicEnabled = false;
		StopMusic();
	}
}
Ejemplo n.º 15
0
CSoundPlayer::~CSoundPlayer()
{
	DEBUG0("CSoundPlayer::~CSoundPlayer()\n");

	StopMusic();
	Mix_FreeMusic(iMusic);
	
	Mix_CloseAudio();
}
Ejemplo n.º 16
0
void PlayDemo (int demonumber)
{
	int length;

#ifdef DEMOSEXTERN
// debug: load chunk
#ifndef SPEARDEMO
	int dems[4]={T_DEMO0,T_DEMO1,T_DEMO2,T_DEMO3};
#else
	int dems[1]={T_DEMO0};
#endif

	CA_CacheGrChunk(dems[demonumber]);
	demoptr = grsegs[dems[demonumber]];
	MM_SetLock (&grsegs[dems[demonumber]],true);
#else
	demoname[4] = '0'+demonumber;
	CA_LoadFile (demoname,&demobuffer);
	MM_SetLock (&demobuffer,true);
	demoptr = (char far *)demobuffer;
#endif

	NewGame (1,0);
	gamestate.mapon = *demoptr++;
	gamestate.difficulty = gd_hard;
	length = *((unsigned far *)demoptr)++;
	demoptr++;
	lastdemoptr = demoptr-4+length;

	VW_FadeOut ();

	SETFONTCOLOR(0,15);
	DrawPlayScreen ();
	VW_FadeIn ();

	startgame = false;
	demoplayback = true;

	SetupGameLevel ();
	StartMusic ();
	PM_CheckMainMem ();
	fizzlein = true;

	PlayLoop ();

#ifdef DEMOSEXTERN
	UNCACHEGRCHUNK(dems[demonumber]);
#else
	MM_FreePtr (&demobuffer);
#endif

	demoplayback = false;

	StopMusic ();
	VW_FadeOut ();
	ClearMemory ();
}
Ejemplo n.º 17
0
void CSoundLibrary::PlayMusic(const tstring& sFilename, bool bLoop)
{
	if (g_pMusic)
		StopMusic();

	g_pMusic = Mix_LoadMUS(sFilename.c_str());

	Mix_PlayMusic(g_pMusic, bLoop?-1:0);
}
Ejemplo n.º 18
0
void CSoundPlayer::PlayMusic(int aLooping)
{
	if (!iInitialized)
		return;

	StopMusic();
	Mix_FadeInMusic(iMusic,aLooping, KFadeInTime );
	SetMusicVolume(iMusicVolume);
}
Ejemplo n.º 19
0
void Widget::CreateButton()
{
    ButtonLayout = new QHBoxLayout;

    QSize iconSize(40,40);//设置图标大小
    StartButton = new QToolButton;
    StartButton->setIcon(QPixmap(":/image/3.png"));
    StartButton->setAutoRaise(true);//鼠标放在按钮上面才显示按钮阴影框
    StartButton->setIconSize(iconSize);
    connect(StartButton,SIGNAL(clicked()),this,SLOT(StartMusic()));

    StopButton = new QToolButton;
    StopButton->setIcon(QPixmap(":/image/2.png"));
    StopButton->setVisible(false);//隐藏按钮
    StopButton->setAutoRaise(true);
    StopButton->setIconSize(iconSize);
    connect(StopButton,SIGNAL(clicked()),this,SLOT(StopMusic()));

    NextButton = new QToolButton;
    NextButton->setIcon(QPixmap(":/image/1.png"));
    NextButton->setAutoRaise(true);
    NextButton->setIconSize(iconSize);
    connect(NextButton,SIGNAL(clicked()),this,SLOT(NextMusic()));

    LastButton = new QToolButton;
    LastButton->setIcon(QPixmap(":/image/4.png"));
    LastButton->setAutoRaise(true);
    LastButton->setIconSize(iconSize);
    connect(LastButton,SIGNAL(clicked()),this,SLOT(LastMusic()));

    OpenButton = new QToolButton;
    OpenButton->setIcon(QPixmap(":/image/6.png"));
    OpenButton->setAutoRaise(true);
    OpenButton->setIconSize(iconSize);
    connect(OpenButton,SIGNAL(clicked()),this,SLOT(OpenFile()));

    ButtonLayout->addWidget(LastButton,0,0);
    ButtonLayout->addWidget(StartButton,1,0);
    ButtonLayout->addWidget(StopButton,1,0);
    ButtonLayout->addWidget(NextButton,2,0);
    ButtonLayout->addWidget(OpenButton,3,0);

    LabelLayout = new QHBoxLayout;

    timeLabel= new QLabel;//显示播放时间
    timeLabel->setText("00:00");
    TotaltimeLabel= new QLabel;//显示歌曲时间长度
    TotaltimeLabel->setText("00:00");

    TitleLabel= new QLabel;//显示歌曲名字
    TitleLabel->setText(tr("Music Title"));

    LabelLayout->addWidget(timeLabel);
    LabelLayout->addStretch();//中间空开
    LabelLayout->addWidget(TotaltimeLabel);
}
Ejemplo n.º 20
0
void CSoundPlayer::MenuMusic() 
{	
	DEBUG0("CSoundPlayer::MenuMusic()\n");
	if (!iInitialized)
		return;

	StopMusic();
	LoadMusic("music/menu.ogg");
	PlayMusic(-1);
}
Ejemplo n.º 21
0
void
vsSoundSystem::Deinit()
{
	StopMusic();
#if !TARGET_OS_IPHONE
	Mix_HaltChannel(-1);
#endif
	vsLog(" ++ Sound channels in use: %d", m_channelsInUse);
	vsLog(" ++ Max sound channels in use: %d", m_maxChannelsInUse);
}
Ejemplo n.º 22
0
void MusicLoop()
{
	if (!_msf.playing && _song_is_active) {
		StopMusic();
	} else if (_msf.playing && !_song_is_active) {
		PlayPlaylistSong();
	}

	if (!_song_is_active) return;

	if (!_music_driver->IsSongPlaying()) {
		if (_game_mode != GM_MENU) {
			StopMusic();
			SkipToNextSong();
			PlayPlaylistSong();
		} else {
			ResetMusic();
		}
	}
}
Ejemplo n.º 23
0
void Music::PlayMusic(eMusic musicID) {
	printf("Playing Music:%i\n", musicID);
	if(musicID != mNOTHING) {
		Mix_PlayMusic(vMusic[musicID - 1], -1);
		musicStopped = false;
		currentMusic = musicID;
	} else {
		StopMusic();
		currentMusic = mNOTHING;
	}
}
Ejemplo n.º 24
0
void MusicLoop()
{
	if (!_settings_client.music.playing && _song_is_active) {
		StopMusic();
	} else if (_settings_client.music.playing && !_song_is_active) {
		PlayPlaylistSong();
	}

	if (!_song_is_active) return;

	if (!MusicDriver::GetInstance()->IsSongPlaying()) {
		if (_game_mode != GM_MENU) {
			StopMusic();
			SkipToNextSong();
			PlayPlaylistSong();
		} else {
			ResetMusic();
		}
	}
}
Ejemplo n.º 25
0
void Music::PlayMusic() {
	printf("Playing current Music:%i at %p\n", (currentMusic - 1), vMusic[currentMusic - 1]);
	if(currentMusic != mNOTHING) {
		if(Mix_PlayMusic(vMusic[currentMusic - 1], -1) == - 1)
			printf("Error playing music: %s", Mix_GetError() );
		
        printf("Music stopped = false\n");
		musicStopped = false;
	} else {
		StopMusic();
	}
}
Ejemplo n.º 26
0
void PlayMusic(const std::string& name)
{
	StopMusic();
	size_t length;
	ALubyte* data = GetSoundData("Music/" + name, length);
	currentMusicName = name;
	currentMusicStream = alureCreateStreamFromStaticMemory(data, length, CHUNK_LENGTH, 2, musicBufs);
	alurePlaySourceStream(musicSource, currentMusicStream, 2, 1, MusicEndCallback, data);
	LOG("Sound", LOG_MESSAGE, "Music: %s", name.c_str());
	if (!data)
		LOG("Sound", LOG_WARNING, "failed to find music");
}
Ejemplo n.º 27
0
char CFMOD::PlayMusic(char* szFilename)
{
    if(!bfmod) return 0;
    StopMusic();
    fmusic=FMUSIC_LoadSong(szFilename);
    if(fmusic)
    {
        FMUSIC_SetMasterVolume(fmusic,mvol);
        return FMUSIC_PlaySong(fmusic);
    }
    return 0;
}
Ejemplo n.º 28
0
void CIwGameAudio::Release()
{
	// Stop sound and music
	StopMusic();
	StopAllSounds();

	// Clean-up sound collection
	SAFE_DELETE(SoundCollection)

	// Cleanup IwSound
	IwSoundTerminate();
}
Ejemplo n.º 29
0
/**
**  Play a music file.
**
**  @param sample  Music sample.
**
**  @return        0 if music is playing, -1 if not.
*/
int PlayMusic(CSample *sample)
{
	if (sample) {
		StopMusic();
		MusicChannel.Sample = sample;
		MusicPlaying = true;
		return 0;
	} else {
		DebugPrint("Could not play sample\n");
		return -1;
	}
}
Ejemplo n.º 30
0
void Game::ShowMenu()
{
	bool salir = false;
	Event evt;
	Image img;
	img.LoadFromFile("..//Imagenes//Menu.png");
	Sprite menu;
	menu.SetImage(img);
	menu.SetPosition(200,200);
	
	while(pWnd->IsOpened() && !salir){	
		
		while (pWnd->GetEvent(evt))
		{
			if(evt.Type == Event::Closed)
			{	
				Creditos();
				pWnd->Close();
			}
			if(evt.Type == Event::KeyPressed)
			{
				if(evt.Key.Code == Key::Escape)
				{	
					Creditos();
					pWnd->Close();
				}else if(evt.Key.Code == Key::Space)
				{
					salir = true;
					isGame = true;
					break;
				}
			}
		}

		pWnd->Clear();
			
			zone->Draw(pWnd);	
			hud->Draw(pWnd);		
			letra->Draw(pWnd);

			pWnd->Draw(menu);

		pWnd->Display();
				
	}

	if(pWnd->IsOpened())
	{
		StopMusic();
		MusicGame();
	}
}