PARALLACTION: Simplify text comparisons in dialogue code.

Encapsulate text comparison into string owners and removed some ugly
double negative logic.

svn-id: r55605
This commit is contained in:
Nicola Mettifogo 2011-01-29 07:21:31 +00:00
parent c3698a2cd5
commit e1046d3eae
3 changed files with 13 additions and 3 deletions

View File

@ -214,7 +214,7 @@ void DialogueManager::displayAnswers() {
}
int16 DialogueManager::selectAnswer1() {
if (!_visAnswers[0]._a->_text.compareToIgnoreCase("null")) {
if (_visAnswers[0]._a->textIsNull()) {
return _visAnswers[0]._index;
}
@ -250,7 +250,7 @@ int16 DialogueManager::selectAnswerN() {
}
bool DialogueManager::displayQuestion() {
if (!_q->_text.compareToIgnoreCase("NULL")) return false;
if (_q->textIsNull()) return false;
_vm->_balloonMan->setSingleBalloon(_q->_text, _ballonPos._questionBalloon.x, _ballonPos._questionBalloon.y, _q->_mood & 0x10, BalloonManager::kNormalColor);
_faceId = _vm->_gfx->setItem(_questioner, _ballonPos._questionChar.x, _ballonPos._questionChar.y);
@ -283,7 +283,7 @@ void DialogueManager::nextAnswer() {
return;
}
if (!_visAnswers[0]._a->_text.compareToIgnoreCase("NULL")) {
if (_visAnswers[0]._a->textIsNull()) {
// if the first answer is null (it's implied that it's the
// only one because we already called addVisibleAnswers),
// then jump to the next question

View File

@ -258,6 +258,10 @@ Answer::Answer() {
_hasCounterCondition = false;
}
bool Answer::textIsNull() {
return (_text.equalsIgnoreCase("NULL"));
}
Question::Question(const Common::String &name) : _name(name), _mood(0) {
memset(_answers, 0, sizeof(_answers));
}
@ -268,6 +272,10 @@ Question::~Question() {
}
}
bool Question::textIsNull() {
return (_text.equalsIgnoreCase("NULL"));
}
Instruction::Instruction() {
_index = 0;
_flags = 0;

View File

@ -163,6 +163,7 @@ struct Answer {
int _counterOp;
Answer();
bool textIsNull();
};
struct Question {
@ -173,6 +174,7 @@ struct Question {
Question(const Common::String &name);
~Question();
bool textIsNull();
};
struct Dialogue {