示例#1
0
bool DrasculaEngine::confirmExit() {
	byte key = 0;

	color_abc(kColorRed);
	updateRoom();
	centerText(_textsys[1], 160, 87);
	updateScreen();

	delay(100);
	while (!shouldQuit()) {
		key = getScan();
		if (key != 0)
			break;

		// This gives a better feedback to the user when he is asked to
		// confirm whether he wants to quit. It now still updates the room and
		// shows mouse cursor movement. Hopefully it will work in all
		// locations of the game.
		updateRoom();
		color_abc(kColorRed);
		centerText(_textsys[1], 160, 87);
		updateScreen();
	}

	if (key == Common::KEYCODE_ESCAPE || shouldQuit()) {
		stopMusic();
		return false;
	}

	return true;
}
示例#2
0
cGame::~cGame()
{
	int playerindex = _index(_pplayer);
	if (playerindex == cBiota::NOINDEX) //player won't be deleted by cBiota destructor
	{
		delete _pplayer; /* I need to do this while the _pbiota is still good,
			as the delete _pplayer will call the ~cCritter, which will use
			_pbiota to find the pgame to call fixPointerRefs with. */
		_pplayer = NULL;
	}
	delete _pskybox;
	_pskybox = NULL;
	delete _pbiota;
	_pbiota = NULL;
	delete _pcollider;
	_pcollider = NULL;
	delete _pcontroller;
	_pcontroller = NULL;
	delete _plightingmodel;
	_plightingmodel = NULL;
/* At game exit, we release any of the shared cSpriteQuake model resources that we've
allocated from within the quakeMD2model.cpp file. I might have expected to
do this in the ~PopApp destructor in pop.cpp, but for some reason when I
get to that destructor, the information in the two static _map... fields has been
lost track of without being deleted. */
	cTextureInfo::_mapFilenameToTextureInfo.free();
	cMD2Model::_mapFilenameToMD2Info.free();
	stopMusic();
}
示例#3
0
void SoundProcessor::setSoundConfiguration(const boost::shared_ptr<const SoundConfiguration> soundConfiguration)
{
	this->soundConfiguration = soundConfiguration;

	// ------ SOUND ENGINE -------
	if((soundConfiguration->isSound() || soundConfiguration->isMusic()) && (!soundInitialized))
	{
		try {
			initSoundEngine();
		} catch(SDLException e) {
			soundInitialized = false;
			toInfoLog(TextStorage::instance().get(IDS::START_INIT_NOSOUND_TEXT_ID)->getText());
		}
	} else if(!soundConfiguration->isSound() && !soundConfiguration->isMusic() && soundInitialized) {
		// sound was deactivated
		releaseSoundEngine();
	} else 
		if(!soundInitialized) {
			if(!soundConfiguration->isMusic()) {
				stopMusic();
			}

			if(soundConfiguration->isSound()) {
				process();
			} else {
				clearSoundChannels();
			}
#ifdef _FMOD_SOUND
			soundEngine->update();
#endif
		}
		clearSoundsToPlay();
}
void Sounds::startMusicGameplay() {
	if(Settings::getInstance()->musicEnabled == false)
		return;
	if(s3eIOSBackgroundMusicAvailable() == S3E_TRUE)
		if(s3eIOSBackgroundMusicGetInt(S3E_IOSBACKGROUNDMUSIC_PLAYBACK_STATE) == S3E_IOSBACKGROUNDMUSIC_PLAYBACK_PLAYING)
			return;

	IGLog("Sounds starting gameplay music");
	
	// if gameplay music is already playing, only change song if it's been playing for a full minute
	if(gameplayPlaying) {
		if(s3eTimerGetMs() - gameplayStart <= 60000)
			return;
	}

	gameplayPlaying = true;
	gameplayStart = s3eTimerGetMs();
	stopMusic();
	char buffer[100];
	int randomSong = gameplayMusicNum;
	while(randomSong == gameplayMusicNum)
		randomSong = rand()%3;
	switch(randomSong) {
		default:
		case 0: sprintf(buffer, "gameplay1.mp3"); break;
		case 1: sprintf(buffer, "gameplay2.mp3"); break;
		case 2: sprintf(buffer, "gameplay3.mp3"); break;
	}
	if(s3eAudioIsCodecSupported(S3E_AUDIO_CODEC_MP3))
		s3eAudioPlay(buffer, 0);
}
示例#5
0
static void save_click_cb( button_t *button, void *userdata )
{
    check_assertion( userdata == NULL, "userdata is not null" );

    cur_sound = listbox_get_current_item( sound_listbox );
    int snd = *((int*) get_list_elem_data( cur_sound ));

    cur_video = listbox_get_current_item( video_listbox );
    int vid = *((int*) get_list_elem_data( cur_video ));

    setparam_sound_enabled(snd);

    if (getparam_music_enabled() == 1 && snd == 0)
        stopMusic();
    setparam_music_enabled (snd);
    
    saveparamSoundEnabled(snd);

    setparam_video_quality (vid);
    set_video_quality(vid);

    saveparamVideoQuality(vid);
    
    set_game_mode( GAME_TYPE_SELECT );
    
    ui_set_dirty();
}
示例#6
0
文件: mixer.cpp 项目: vanfanel/rawgl
	void stopAll() {
		for (int i = 0; i < 4; ++i) {
			stopSound(i);
		}
		stopMusic();
		stopSfxMusic();
	}
示例#7
0
/**
 * Play music.
 * @param file path to music file (i.e. *.ogg)
 * @param finished send this message when music is finished.
 * If finished is NULL, play music forever.
 */
void
SDLSoundAgent::playMusic(const Path &file,
        BaseMsg *finished)
{
    // The same music is not restarted when it is not needed.
    if (m_playingPath == file.getPosixName()
            && ms_finished == NULL && finished == NULL) {
        return;
    }

    stopMusic();
    m_playingPath = file.getPosixName();

    if (finished) {
        ms_finished = finished;
        m_music = Mix_LoadMUS(file.getNative().c_str());
        if (m_music && (0 == Mix_PlayMusic(m_music, 1))) {
            Mix_HookMusicFinished(musicFinished);
        }
        else {
            LOG_WARNING(ExInfo("cannot play music")
                    .addInfo("music", file.getNative())
                    .addInfo("Mix", Mix_GetError()));
        }
    }
    else {
        m_looper = new SDLMusicLooper(file);
        m_looper->setVolume(m_musicVolume);
        m_looper->start();
    }
}
示例#8
0
//-----------------------------------------------------------------
    void
SDLSoundAgent::own_shutdown()
{
    stopMusic();
    Mix_CloseAudio();
    SDL_QuitSubSystem(SDL_INIT_AUDIO);
}
示例#9
0
void Game::loadState(int slot, bool switchScene) {
	File f;
	char filePath[512];
	sprintf(filePath, _saveFileNameFormat, _savePath, slot);
	if (!f.open(filePath, "rb")) {
		warning("Unable to load game state to file '%s'", filePath);
		return;
	}
	_saveOrLoadStream = &f;
	_saveOrLoadMode = kLoadMode;

	stopMusic();

	int n = loadInt16();
	for (int i = 0; i < n; ++i) {
		_varsTable[i] = loadInt16();
	}
	saveOrLoadStr(_tempTextBuffer, -2);
	if (switchScene) {
		_switchScene = true;
		return;
	}
	_sceneObjectsCount = loadInt16();
	for (int i = 0; i < _sceneObjectsCount; ++i) {
		saveOrLoad_sceneObject(_sceneObjectsTable[i]);
	}
	n = loadInt16();
	for (int i = 0; i < n; ++i) {
		_boxesCountTable[i] = loadInt16();
	}
	n = loadInt16();
	assert((n % 10) == 0);
	for (int i = 0; i < n / 10; ++i) {
		for (int j = 0; j < 10; ++j) {
			saveOrLoad_box(_boxesTable[i][j]);
		}
	}
	n = loadInt16();
	for (int i = 0; i < n; ++i) {
		_varsTable[i] = loadInt16();
	}
	n = loadInt16();
	for (int i = 0; i < n; ++i) {
		saveOrLoad_sceneObjectStatus(_sceneObjectStatusTable[i]);
	}
	_bagPosX = loadInt16();
	_bagPosY = loadInt16();
	_currentBagObject = loadInt16();
	_previousBagObject = _currentBagObject;
	for (int i = 0; i < NUM_BAG_OBJECTS; ++i) {
		free(_bagObjectsTable[i].data);
		memset(&_bagObjectsTable[i], 0, sizeof(BagObject));
	}
	load_bagObjects(_bagObjectsTable, _bagObjectsCount);
	_currentBagAction = loadInt16();
	loadInt32();
	_musicTrack = loadInt32();
	saveOrLoadStr(_musicName);
	debug(DBG_INFO, "Loaded state from slot %d scene '%s'", slot, _tempTextBuffer);
}
示例#10
0
int initTitleAtr() {
  stopMusic();
  titleCnt = 0;
  slcStg = hiScore.stage;
  mnp = 0;
  return slcStg;
}
示例#11
0
    bool AudioHandler::setMusic(const std::string& musicKey)
    {
        //Set current music playing.
        stopMusic();

        if(musicList.find(musicKey) == musicList.end())
        {
            std::cout << "Music not found";
            return true;
        }

        if(song != NULL) safeDelete(song);
        song = new sbe::Music();
        if(!song->OpenFromFile(musicList[musicKey]))
        {
            Logger::writeMsg(1) << "Music could not be loaded!";
            safeDelete(song);
            return true;
        }
        song->SetVolume(mVol);
        song->Initialize(2, 44100);
        song->Play();
        Logger::writeMsg(1) << "Music \"" << musicKey << "\" now playing.";

        return false;
    }
示例#12
0
/**
 * Stop audio.
 */
void closeAudio () {

	int count;

	stopMusic();

#ifdef USE_XMP
	xmp_free_context(xmpC);
#endif

	SDL_CloseAudio();

	if (rawSounds) {

		for (count = 0; count < nRawSounds; count++) {

			delete[] rawSounds[count].data;
			delete[] rawSounds[count].name;

		}

		delete[] rawSounds;

	}

	if (sounds) {

		freeSounds();
		delete[] sounds;

	}

	return;

}
示例#13
0
bool Music::loadSong(int songNumber) {
	debugC(kDebugLevelMusic, "Music: loadSong()");

	if(songNumber == 100)
		songNumber = 55;
	else if(songNumber == 70)
		songNumber = 54;

	if((songNumber > 60) || (songNumber < 1))
		return false;

	songNumber = ROOM_SONG[songNumber];

	if(songNumber == 0)
		songNumber = 12;

	if((songNumber > NUM_SONGS) || (songNumber < 1))
		return false;

	Common::String songName = Common::String(SONG_NAMES[songNumber - 1]);

	freeSong();  // free any song that is currently loaded
	stopMusic();

	if (!playMusic(songName))
		return false;

	startSong();
	return true;
}
示例#14
0
void UIWindow::startMusic ()
{
	if (!_musicFile.empty())
		_music = SoundControl.playMusic(_musicFile);
	else
		stopMusic();
}
示例#15
0
void AudioManagerImpl::playMusic(MusicName musicName)
{
	stopMusic();

	auto music = MusicFilenames.find(musicName);
	if (music == MusicFilenames.end())
	{
		Debug::mention("Audio Manager", "Failed to lookup music ID " +
			std::to_string(static_cast<int>(musicName)) + ".");
		mCurrentSong = nullptr;
	}
	else if (!mFreeSources.empty())
	{
		if (MidiDevice::isInited())
			mCurrentSong = MidiDevice::get().open(music->second);
		if (!mCurrentSong)
		{
			Debug::mention("Audio Manager", "Failed to play " + music->second + ".");
			return;
		}

		mSongStream.reset(new OpenALStream(this, mCurrentSong.get()));
		if (mSongStream->init(mFreeSources.front(), mMusicVolume))
		{
			mFreeSources.pop_front();
			mSongStream->play();
			Debug::mention("Audio Manager", "Playing music " + music->second + ".");
		}
		else
			Debug::mention("Audio Manager", "Failed to init song stream.");
	}
}
示例#16
0
MidiPlayer::~MidiPlayer() {
	_driver->setTimerCallback(NULL, NULL);
	_parser->setMidiDriver(NULL);
	stopMusic();
	close();
	delete _parser;
	delete _midiData;
}
示例#17
0
文件: mixer.cpp 项目: argontus/3S3K3D
void Mixer::close()
{
    stopMusic();

    freeSounds();
    Mix_CloseAudio();
    Mix_Quit();
}
示例#18
0
void SoundSystem::enableMusic(bool enabled)
{
	m_enable_music = enabled;
	if (!enabled)
		stopMusic();
	else
		m_music.play();
}
示例#19
0
// ***************************************************************************
void		CMusicSoundManager::enable(bool enable)
{
	// if disabled, stop any music (without any fade)
	if(!enable)
		stopMusic(false);

	_Enabled= enable;
}
示例#20
0
void RosalilaSound::playMusic(std::string path,int loops)
{
    stopMusic();
    rosalila()->utility->writeLogLine("Playing music: "+path);
    music = Mix_LoadMUS(path.c_str());
    Mix_PlayMusic(music,loops);
    current_music=path;
}
示例#21
0
    void SoundManager::clear()
    {
        for (SoundMap::iterator iter (mActiveSounds.begin()); iter!=mActiveSounds.end(); ++iter)
            iter->first->stop();

        mActiveSounds.clear();
        stopMusic();
    }
示例#22
0
AmigaSoundMan_ns::~AmigaSoundMan_ns() {
	stopMusic();
	stopSfx(0);
	stopSfx(1);
	stopSfx(2);
	stopSfx(3);

	delete []beepSoundBuffer;
}
示例#23
0
/* ends the game*/
void endGame() {
    gamePaused = 0x01;                  // pauses the game
    stopMusic();                        // stops the music
    gameOver(displayField);             // shows the Game Over field
    rollNumber('l', level, 10, 1000);   // display the level
    rollNumber('p', score, 10, 1000);   // displays the score
    gamePaused = 0x00;                  // unpuse the game

}
示例#24
0
文件: title.cpp 项目: 33d/scummvm
void Title::play() {
	SEQFile::play(true, 0xFFFF, 15);

	// After playback, fade out and stop the music
	if (!_vm->shouldQuit())
		_vm->_palAnim->fade(0, 0, 0);

	stopMusic();
}
示例#25
0
SoundService::~SoundService()
{
	stopMusic();
	Mix_FreeMusic(_music);
	for (auto c : _chunks)
	{
		Mix_FreeChunk(c.second);
	}
}
示例#26
0
void Player_AD::startSound(int sound) {
	Common::StackLock lock(_mutex);

	// Setup the sound volume
	setupVolume();

	// Query the sound resource
	const byte *res = _vm->getResourceAddress(rtSound, sound);
	assert(res);

	if (res[2] == 0x80) {
		// Stop the current sounds
		stopMusic();

		// Lock the new music resource
		_musicResource = sound;
		_vm->_res->lock(rtSound, _musicResource);

		// Start the new music resource
		_musicData = res;
		startMusic();
	} else {
		const byte priority = res[0];
		// The original specified the channel to use in the sound
		// resource. However, since we play as much as possible we sill
		// ignore it and simply use the priority value to determine
		// whether the sfx can be played or not.
		//const byte channel  = res[1];

		// Try to allocate a sfx slot for playback.
		SfxSlot *sfx = allocateSfxSlot(priority);
		if (!sfx) {
			::debugC(3, DEBUG_SOUND, "AdLib: No free sfx slot for sound %d", sound);
			return;
		}

		// Try to start sfx playback
		sfx->resource = sound;
		sfx->priority = priority;
		if (startSfx(sfx, res)) {
			// Lock the new resource
			_vm->_res->lock(rtSound, sound);
		} else {
			// When starting the sfx failed we need to reset the slot.
			sfx->resource = -1;

			for (int i = 0; i < ARRAYSIZE(sfx->channels); ++i) {
				sfx->channels[i].state = kChannelStateOff;

				if (sfx->channels[i].hardwareChannel != -1) {
					freeHWChannel(sfx->channels[i].hardwareChannel);
					sfx->channels[i].hardwareChannel = -1;
				}
			}
		}
	}
}
示例#27
0
//-----------------------------------------------------------------
SDLSound::~SDLSound()
{
    stopMusic();
    Mix_CloseAudio();
    for (chunks_t::iterator i = m_chunks.begin(); i != m_chunks.end(); i++) {
        Mix_FreeChunk(i->second);
    }

    SDL_QuitSubSystem(SDL_INIT_AUDIO);
}
示例#28
0
文件: mixer.cpp 项目: vanfanel/rawgl
	void playMusic(const char *path) {
		stopMusic();
		_music = Mix_LoadMUS(path);
		if (_music) {
			Mix_VolumeMusic(MIX_MAX_VOLUME / 2);
			Mix_PlayMusic(_music, 0);
		} else {
			warning("Failed to load music '%s', %s", path, Mix_GetError());
		}
	}
示例#29
0
bool Music::loadSong(const Common::String &songName) {
	freeSong();  // free any song that is currently loaded
	stopMusic();

	if (!playMusic(songName))
		return false;

	startSong();
	return true;
}
示例#30
0
void testmusic(){
	while(1){		
		playMusic();
		for(int i=0;i<100000000;i++);	
		setMusicVolume(140);
		for(int i=0;i<100000000;i++);
		stopMusic();
		for(int i=0;i<100000000;i++);
	}
}