aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/mads/dialogs.h2
-rw-r--r--engines/mads/nebular/dialogs_nebular.cpp47
-rw-r--r--engines/mads/nebular/dialogs_nebular.h4
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 = &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,
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: