MADS: Implement the dialog textNoun method

This commit is contained in:
Paul Gilbert 2014-05-11 22:41:01 -04:00
parent 5e13514d28
commit 604bca43de
3 changed files with 46 additions and 7 deletions

View File

@ -220,7 +220,7 @@ public:
virtual void showDialog() = 0;
virtual void showItem(int objectId, int messageId, int speech = 0) = 0;
virtual Common::String getVocab(int vocabId) = 0;
virtual bool show(int messageId, int objectId = -1) = 0;
};

View File

@ -195,10 +195,49 @@ Common::String DialogsNebular::getVocab(int vocabId) {
return vocab;
}
bool DialogsNebular::textNoun(Common::String &dialogText, int nounNum,
const Common::String &valStr) {
error("TODO: textNoun");
return false;
bool DialogsNebular::textNoun(Common::String &dest, int nounId, const Common::String &source) {
// Ensure the destination has parameter specifications
if (!source.hasPrefix(":"))
return false;
// Extract the first (singular) result value
Common::String param1 = Common::String(source.c_str() + 1);
Common::String param2;
const char *sepChar = strchr(source.c_str() + 1, ':');
if (sepChar) {
param1 = Common::String(source.c_str() + 1, sepChar);
// Get the second, plural form
param2 = Common::String(sepChar + 1);
}
// Get the vocab to use
MADSAction &action = _vm->_game->_scene._action;
Common::String vocab = _vm->_dialogs->getVocab(action._activeAction._verbId);
Common::String *str;
if (vocab.hasSuffix("s") || vocab.hasSuffix("S")) {
str = &param2;
} else {
str = &param1;
if (param1 == "a ") {
switch (toupper(vocab[0])) {
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
param1 = "an ";
break;
default:
break;
}
}
}
dest += *str;
return true;
}
bool DialogsNebular::commandCheck(const char *idStr, Common::String &valStr,

View File

@ -41,9 +41,9 @@ private:
DialogsNebular(MADSEngine *vm): Dialogs(vm) {}
Common::String getVocab(int vocabId);
virtual Common::String getVocab(int vocabId);
bool textNoun(Common::String &dialogText, int nounNum, const Common::String &valStr);
bool textNoun(Common::String &dest, int nounId, const Common::String &source);
bool commandCheck(const char *idStr, Common::String &valStr, const Common::String &command);
public: