예제 #1
0
파일: scene.cpp 프로젝트: 86400/scummvm
bool BbvsEngine::changeScene() {

	writeContinueSavegame();

	if (_newSceneNum >= 27 && _newSceneNum <= 30) {
		// Run minigames
		stopSpeech();
		stopSounds();
		_sceneVisited[_currSceneNum] = 1;
		if (runMinigame(_newSceneNum - 27)) {
			SWAP(_currSceneNum, _newSceneNum);
		}
	} else if (_newSceneNum >= 31 && _newSceneNum <= 43) {
		// Play video
		stopSpeech();
		stopSounds();
		_sceneVisited[_currSceneNum] = 1;
		_playVideoNumber = _newSceneNum - 30;
		_currSceneNum = _newSceneNum;
		_newSceneNum = kAfterVideoSceneNum[_playVideoNumber];
	} else if (_newSceneNum >= 100 && _currSceneNum == kCredits) {
		// Play secret video
		stopSounds();
		_playVideoNumber = _newSceneNum;
		_currSceneNum = 49;
		_newSceneNum = kCredits;
	} else {
		// Normal scene
		initScene(true);
	}

	return true;

}
예제 #2
0
파일: sound.cpp 프로젝트: djkimgo/scummvm
void Sound::playSpeech(const Common::String &name) {
	Resources &res = *_vm->_res;
	Scene &scene = *_vm->_scene;
	stopSpeech();

	// TODO: Technically Scalpel has an sfx command which I've set to call this method because it sets the
	// _voice variable as if it were speech. Need to do a play-through of Scalpel and see if it's ever called.
	// If so, will need to enhance this method to handle the Serrated Scalpel voice resources
	assert(IS_ROSE_TATTOO);

	// Figure out which speech library to use
	Common::String libraryName = Common::String::format("speech%02d.lib", scene._currentScene);
	if ((!scumm_strnicmp(name.c_str(), "SLVE12S", 7)) || (!scumm_strnicmp(name.c_str(), "WATS12X", 7))
			|| (!scumm_strnicmp(name.c_str(), "HOLM12X", 7)))
		libraryName = "SPEECH12.LIB";

	// If the speech library file doesn't even exist, then we can't play anything
	Common::File f;
	if (!f.exists(libraryName))
		return;

	// Ensure the given library is in the cache
	res.addToCache(libraryName);

	if (playSoundResource(name, libraryName, Audio::Mixer::kSpeechSoundType, _speechHandle))
		_speechPlaying = true;
}
예제 #3
0
bool AudioSpeech::playSpeech(const Common::String &name, int pan) {
	if (isPlaying()) {
		stopSpeech();
	}

	// Audio cache is not usable as hash function is producing collision for speech lines.
	// It was not used in the original game either

	Common::ScopedPtr<Common::SeekableReadStream> r(_vm->getResourceStream(name));

	if (!r) {
		warning("AudioSpeech::playSpeech: AUD resource \"%s\" not found", name.c_str());
		return false;
	}

	if (r->size() > kBufferSize) {
		warning("AudioSpeech::playSpeech: AUD larger than buffer size (%d > %d)", r->size(), kBufferSize);
		return false;
	}

	if (isPlaying()) {
		stopSpeech();
	}

	r->read(_data, r->size());
	if (r->err()) {
		warning("AudioSpeech::playSpeech: Error reading resource \"%s\"", name.c_str());
		return false;
	}

	AudStream *audioStream = new AudStream(_data, _vm->_shortyMode ? 33000 : -1);

	_channel = _vm->_audioMixer->play(
		Audio::Mixer::kSpeechSoundType,
		audioStream,
		100,
		false,
		_speechVolume,
		pan,
		mixerChannelEnded,
		this);

	_isActive = true;

	return true;
}
예제 #4
0
AudioSpeech::~AudioSpeech() {
	stopSpeech();
	while (isPlaying()) {
		// wait for the mixer to finish
	}

	delete[] _data;
}
예제 #5
0
파일: sound.cpp 프로젝트: AReim1982/scummvm
void Sound::internalPlaySound(int16 resIndex, int16 type, int16 volume, int16 panning) {
	// Change the game's sound volume (0 - 100) to Scummvm's scale (0 - 255)
	volume = (volume == -1) ? 255 : volume * 255 / 100;

	if (resIndex == -1) {
		// Stop all sounds
		_vm->_mixer->stopAll();
		_vm->_screen->keepTalkTextItemsAlive();
		for (int i = 0; i < kMaxChannels; i++) {
			clearChannel(i);
		}
	} else if (type == -2) {
		// Stop sounds with specified resIndex
		for (int i = 0; i < kMaxChannels; i++) {
			if (channels[i].resIndex == resIndex) {
				_vm->_mixer->stopHandle(channels[i].handle);
				clearChannel(i);
			}
		}
	} else {
		if (type == kChannelTypeSpeech) {
			// Stop speech and play new sound
			stopSpeech();
		}

		// Play new sound in empty channel
		int freeChannel = -1;
		for (int i = 0; i < kMaxChannels; i++) {
			if (channels[i].type == kChannelTypeEmpty || !_vm->_mixer->isSoundHandleActive(channels[i].handle)) {
				freeChannel = i;
				break;
			}
		}

		// If all channels are in use no new sound will be played
		if (freeChannel >= 0) {
			Resource *soundResource = _vm->_res->load(resIndex);

			Audio::AudioStream *stream = Audio::makeLoopingAudioStream(
								Audio::makeRawStream(soundResource->data,
								soundResource->size, 22050, Audio::FLAG_UNSIGNED,
								DisposeAfterUse::NO),
								type == kChannelTypeBackground ? 0 : 1);

			channels[freeChannel].type = type;
			channels[freeChannel].resIndex = resIndex;
			channels[freeChannel].volume = volume;
			channels[freeChannel].panning = panning;

			Audio::Mixer::SoundType soundType = getScummVMSoundType((SoundChannelType)type);

			_vm->_mixer->playStream(soundType, &channels[freeChannel].handle,
			                        stream, -1, volume, panning);
		}	// if (freeChannel >= 0)
	}	// resIndex
}
예제 #6
0
Sound::~Sound() {
	_vm->_mixer->stopHandle(_mixerSoundHandle);

	clearFxQueue(true);
	stopMusic(true);
	stopSpeech();

	free(_mixBuffer);

	for (int i = 0; i < MAXMUS; i++) {
		if (_musicFile[i].file.isOpen())
			_musicFile[i].file.close();
		if (_speechFile[i].file.isOpen())
			_speechFile[i].file.close();

		free(_musicFile[i].idxTab);
		free(_speechFile[i].idxTab);
	}
}
예제 #7
0
bool AudioSpeech::playSpeech(const char *name, int balance) {
	// debug("AudioSpeech::playSpeech(\"%s\")", name);
	Common::ScopedPtr<Common::SeekableReadStream> r(_vm->getResourceStream(name));

	if (!r) {
		warning("AudioSpeech::playSpeech: AUD resource \"%s\" not found", name);
		return false;
	}

	if (r->size() > BUFFER_SIZE) {
		warning("AudioSpeech::playSpeech: AUD larger than buffer size (%d > %d)", r->size(), BUFFER_SIZE);
		return false;
	}

	if (isPlaying()) {
		stopSpeech();
	}

	r->read(_data, r->size());
	if (r->err()) {
		warning("AudioSpeech::playSpeech: Error reading resource \"%s\"", name);
		return false;
	}

	AudStream *audioStream = new AudStream(_data);

	_vm->_mixer->playStream(
		Audio::Mixer::kPlainSoundType,
		&_soundHandle,
		audioStream,
		-1,
		_volume * 255 / 100,
		balance);

	_isMaybeActive = true;

	return true;
}
예제 #8
0
파일: scene.cpp 프로젝트: 86400/scummvm
void BbvsEngine::initScene(bool sounds) {

	stopSpeech();
	stopSounds();
	_sound->unloadSounds();

	_gameState = kGSScene;
	_prevSceneNum = _currSceneNum;
	_sceneVisited[_currSceneNum] = 1;
	_mouseCursorSpriteIndex = 0;
	_verbPos.x = -1;
	_verbPos.y = -1;
	_activeItemType = kITEmpty;
	_activeItemIndex = 0;
	_cameraPos.x = 0;
	_cameraPos.y = 0;
	_newCameraPos.x = 0;
	_newCameraPos.y = 0;
	_inventoryButtonIndex = -1;
	_currTalkObjectIndex = -1;
	_currCameraNum = 0;
	_walkMousePos.x = -1;
	_walkMousePos.y = -1;
	_currAction = 0;
	_currActionCommandIndex = -1;
	_currActionCommandTimeStamp = 0;
	_dialogSlotCount = 0;
	_buttheadObject = 0;
	_beavisObject = 0;

	memset(_backgroundSoundsActive, 0, sizeof(_backgroundSoundsActive));

	memset(_sceneObjects, 0, sizeof(_sceneObjects));
	for (int i = 0; i < kSceneObjectsCount; ++i) {
		_sceneObjects[i].walkDestPt.x = -1;
		_sceneObjects[i].walkDestPt.y = -1;
	}

	memset(_dialogItemStatus, 0, sizeof(_dialogItemStatus));

	_sceneObjectActions.clear();

	loadScene(_newSceneNum);
	_currSceneNum = _newSceneNum;
	_newSceneNum = 0;

	for (int i = 0; i < _gameModule->getSceneObjectDefsCount(); ++i)
		_sceneObjects[i].sceneObjectDef = _gameModule->getSceneObjectDef(i);

	for (int i = 0; i < _gameModule->getSceneObjectInitsCount(); ++i) {
		SceneObjectInit *soInit = _gameModule->getSceneObjectInit(i);
		if (evalCondition(soInit->conditions)) {
			SceneObject *sceneObject = &_sceneObjects[soInit->sceneObjectIndex];
			sceneObject->anim = _gameModule->getAnimation(soInit->animIndex);
			sceneObject->animIndex = soInit->animIndex;
			sceneObject->frameIndex = sceneObject->anim->frameCount - 1;
			sceneObject->frameTicks = 1;
			sceneObject->x = soInit->x << 16;
			sceneObject->y = soInit->y << 16;
		}
	}

	if (_gameModule->getButtheadObjectIndex() >= 0) {
		_buttheadObject = &_sceneObjects[_gameModule->getButtheadObjectIndex()];
		// Search for the Beavis object
		for (int i = 0; i < _gameModule->getSceneObjectDefsCount(); ++i)
			if (!strcmp(_sceneObjects[i].sceneObjectDef->name, "Beavis")) {
				_beavisObject = &_sceneObjects[i];
				break;
			}
	}

	updateSceneObjectsTurnValue();

	updateWalkableRects();

	_currCameraNum = 0;
	if (_buttheadObject) {
		int minDistance = 0xFFFFFF;
		for (int cameraNum = 0; cameraNum < 4; ++cameraNum) {
			CameraInit *cameraInit = _gameModule->getCameraInit(cameraNum);
			int curDistance = ABS(cameraInit->cameraPos.x - (int)(_buttheadObject->x >> 16) + 160);
			if (curDistance < minDistance) {
				minDistance = curDistance;
				_currCameraNum = cameraNum;
			}
		}
	}

	_cameraPos = _gameModule->getCameraInit(_currCameraNum)->cameraPos;
	_newCameraPos = _cameraPos;

	_walkAreaActions.clear();
	for (int i = 0; i < _gameModule->getActionsCount(); ++i) {
		Action *action = _gameModule->getAction(i);
		for (int j = 0; j < 8; ++j)
			if (action->conditions.conditions[j].cond == kCondIsButtheadAtBgObject)
				_walkAreaActions.push_back(action);
	}

	_mouseCursorSpriteIndex = 0;

	_activeItemIndex = 0;
	_activeItemType = kITEmpty;

	for (int i = 0; i < _gameModule->getActionsCount(); ++i) {
		Action *action = _gameModule->getAction(i);
		if (evalCondition(action->conditions)) {
			_gameState = kGSWait;
			_currAction = action;
			for (uint j = 0; j < action->actionCommands.size(); ++j) {
				ActionCommand *actionCommand = &action->actionCommands[j];
				if (actionCommand->cmd == kActionCmdSetCameraPos) {
					_currCameraNum = actionCommand->param;
					_cameraPos = _gameModule->getCameraInit(_currCameraNum)->cameraPos;
					_newCameraPos = _cameraPos;
					break;
				}
			}
			break;
		}
	}

	if (sounds)
		updateBackgroundSounds();

}
예제 #9
0
void MainWindow::createShortcuts()
{
    m_LoadShortcut = new QShortcut(QKeySequence(ShortcutKeys::loadShortcutKey), this);
    connect(m_LoadShortcut, SIGNAL(activated()), this, SLOT(loadCrossword()));

    m_SaveShortcut = new QShortcut(QKeySequence(ShortcutKeys::saveShortcutKey), this);
    connect(m_SaveShortcut, SIGNAL(activated()), this, SLOT(saveCrossword()));

    m_HelpShortcut = new QShortcut(QKeySequence(ShortcutKeys::helpShortcutKey), this);
    connect(m_HelpShortcut, SIGNAL(activated()), this, SLOT(openHelp()));

    m_ExitShortcut = new QShortcut(QKeySequence(ShortcutKeys::exitShortcutKey), this);
    connect(m_ExitShortcut, SIGNAL(activated()), this, SLOT(exitConfirmation()));

    m_TutorialShortcut = new QShortcut(QKeySequence(ShortcutKeys::tutorialShortcutKey), this);
    connect(m_TutorialShortcut, SIGNAL(activated()), this, SLOT(openTutorial()));

    m_EmailAnswersShortcut = new QShortcut(QKeySequence(ShortcutKeys::emailAnswersKey), this);
    connect(m_EmailAnswersShortcut, SIGNAL(activated()), this, SLOT(emailAnswers()));

    m_EmailFeedbackShortcut = new QShortcut(QKeySequence(ShortcutKeys::emailFeedbackKey), this);
    connect(m_EmailFeedbackShortcut, SIGNAL(activated()), this, SLOT(emailFeedback()));

    m_PrintAnswersShortcut = new QShortcut(QKeySequence(ShortcutKeys::printAnswersKey), this);
    connect(m_PrintAnswersShortcut, SIGNAL(activated()), this, SLOT(printAnswers()));

    m_ScoreShortcut = new QShortcut(QKeySequence(ShortcutKeys::markShortcutKey), this);
    connect(m_ScoreShortcut, SIGNAL(activated()), this, SLOT(scoreCrossword()));

    m_FilePropertiesShortcut = new QShortcut(QKeySequence(ShortcutKeys::filePropertiesShortcutKey), this);
    connect(m_FilePropertiesShortcut, SIGNAL(activated()), this, SLOT(showFileProperties()));

    m_FilterTableViewShortcut = new QShortcut(QKeySequence(ShortcutKeys::filterTableViewShortcutKey), this);
    connect(m_FilterTableViewShortcut, SIGNAL(activated()), this, SLOT(cycleTableViewFilter()));

    m_CycleSpeechModeShortcut = new QShortcut(QKeySequence(ShortcutKeys::cycleSpeechModeShortcutKey), this);
    connect(m_CycleSpeechModeShortcut, SIGNAL(activated()), this, SLOT(cycleSpeechMode()));

    m_StopSpeechShortcut = new QShortcut(QKeySequence(ShortcutKeys::stopSpeechKey), this);
    connect(m_StopSpeechShortcut, SIGNAL(activated()), this, SLOT(stopSpeech()));

    m_ApplicationOpenReminderShortcut = new QShortcut(QKeySequence(ShortcutKeys::toggleApplicationOpenReminderKey), this);
    connect(m_ApplicationOpenReminderShortcut, SIGNAL(activated()), this, SLOT(toggleApplicationOpenReminder()));

    m_ReadCurrentClueWordShortcut = new QShortcut(QKeySequence(ShortcutKeys::readCurrentClueWordKey), this);
    connect(m_ReadCurrentClueWordShortcut, SIGNAL(activated()), this, SLOT(readCurrentWordInClue()));

    m_AdvanceCurrentClueWordShortcut = new QShortcut(QKeySequence(ShortcutKeys::advanceClueWordKey), this);
    connect(m_AdvanceCurrentClueWordShortcut, SIGNAL(activated()), this, SLOT(advanceToNextWordInClue()));

    m_IncreaseSpeechRateShortcut = new QShortcut(QKeySequence(ShortcutKeys::increaseSpeechRateKey), this);
    connect(m_IncreaseSpeechRateShortcut, SIGNAL(activated()), this, SLOT(increaseSpeechRate()));

    m_DecreaseSpeechRateShortcut = new QShortcut(QKeySequence(ShortcutKeys::decreaseSpeechRateKey), this);
    connect(m_DecreaseSpeechRateShortcut, SIGNAL(activated()), this, SLOT(decreaseSpeechRate()));

    m_ReadLastSpokenPhraseShortcut = new QShortcut(QKeySequence(ShortcutKeys::readLastSpokenPhraseKey), this);
    connect(m_ReadLastSpokenPhraseShortcut, SIGNAL(activated()), this, SLOT(readLastSpokenPhrase()));

    m_CycleViewVisibilityShortcut = new QShortcut(QKeySequence(ShortcutKeys::cycleViewVisibilityKey), this);
    connect(m_CycleViewVisibilityShortcut, SIGNAL(activated()), this, SLOT(cycleViewVisibility()));
}