Exemple #1
0
void DialogPlayer::update() {
	if (_singleSpeech || !_currentDialog || !_currentReply) {
		return; // Nothing to do
	}

	//TODO: Complete

	Resources::Speech *speech = _currentReply->getCurrentSpeech();
	if (speech && _speechReady) {
		// A new line is already ready, no need to prepare another one
		return;
	}

	if (!speech || !speech->isPlaying()) {
		// A line has ended, play the next one
		_currentReply->goToNextLine();
		speech = _currentReply->getCurrentSpeech();
		if (speech) {
			StarkDiary->logSpeech(speech->getPhrase(), speech->getCharacterId());

			_speechReady = true;
		} else {
			onReplyEnd();
		}
	}
}
Exemple #2
0
void DialogPlayer::selectOption(uint32 index) {
	_optionsAvailable = false;

	Option &option = _options[index];

	//TODO: Complete

	switch (option._type) {
	case kOptionTypeAsk: {
		Resources::Dialog::Topic *topic = option._topic;

		// Set the current reply
		_currentReply = topic->startReply(option._replyIndex);

		Resources::Speech *speech = _currentReply->getCurrentSpeech();
		if (speech) {
			StarkDiary->logSpeech(speech->getPhrase(), speech->getCharacterId());

			_speechReady = true;
		} else {
			onReplyEnd();
		}
		break;
	}
	default:
		error("Unhandled option type %d", option._type);
	}
}