diff options
author | Paul Gilbert | 2014-05-11 22:41:01 -0400 |
---|---|---|
committer | Paul Gilbert | 2014-05-11 22:41:01 -0400 |
commit | 604bca43de0c19e64689ce6e12ad3f854549100c (patch) | |
tree | 3eface0c5e991c6e523ece3d0bffc9649d18cac8 | |
parent | 5e13514d28df811dfcd4f1829b327ce8606ed5ee (diff) | |
download | scummvm-rg350-604bca43de0c19e64689ce6e12ad3f854549100c.tar.gz scummvm-rg350-604bca43de0c19e64689ce6e12ad3f854549100c.tar.bz2 scummvm-rg350-604bca43de0c19e64689ce6e12ad3f854549100c.zip |
MADS: Implement the dialog textNoun method
-rw-r--r-- | engines/mads/dialogs.h | 2 | ||||
-rw-r--r-- | engines/mads/nebular/dialogs_nebular.cpp | 47 | ||||
-rw-r--r-- | engines/mads/nebular/dialogs_nebular.h | 4 |
3 files changed, 46 insertions, 7 deletions
diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h index aa635768a1..078415bad9 100644 --- a/engines/mads/dialogs.h +++ b/engines/mads/dialogs.h @@ -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; }; diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp index 8b6418e928..ff2249a3b3 100644 --- a/engines/mads/nebular/dialogs_nebular.cpp +++ b/engines/mads/nebular/dialogs_nebular.cpp @@ -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 = ¶m2; + } else { + str = ¶m1; + + 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, diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h index 60a215197f..643d440d67 100644 --- a/engines/mads/nebular/dialogs_nebular.h +++ b/engines/mads/nebular/dialogs_nebular.h @@ -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: |