aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/director/lingo/lingo-builtins.cpp25
-rw-r--r--engines/director/lingo/lingo.h1
2 files changed, 20 insertions, 6 deletions
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index e4cd016df8..86f50a7dbf 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -1180,8 +1180,11 @@ void Lingo::b_installMenu(int nargs) {
Graphics::MacMenu *menu = g_director->_wm->addMenu();
int submenu = -1;
Common::String submenuText;
+ Common::String command;
int commandId = 100;
+ Common::String handlers;
+
for (const byte *s = (const byte *)menuStxt.c_str(); *s; s++) {
// Get next line
line.clear();
@@ -1209,8 +1212,9 @@ void Lingo::b_installMenu(int nargs) {
while (*p && (*p == ' ' || *p == '\t'))
p++;
- if (!submenuText.empty()) {
+ if (!submenuText.empty()) { // Adding submenu for previous menu
submenuText += Common::String::format("[%d]", commandId);
+ handlers += g_lingo->genMenuHandler(&commandId, command);
commandId++;
menu->createSubMenuFromString(submenu, submenuText.c_str(), 0);
@@ -1239,13 +1243,14 @@ void Lingo::b_installMenu(int nargs) {
}
Common::String text(line.c_str(), p);
- Common::String command(p + 1);
+ command = Common::String(p + 1);
text.trim();
command.trim();
if (!submenuText.empty()) {
submenuText += Common::String::format("[%d];", commandId);
+ handlers += g_lingo->genMenuHandler(&commandId, command);
commandId++;
}
@@ -1257,13 +1262,21 @@ void Lingo::b_installMenu(int nargs) {
if (!submenuText.empty()) {
submenuText += Common::String::format("[%d]", commandId);
-
+ handlers += g_lingo->genMenuHandler(&commandId, command);
menu->createSubMenuFromString(submenu, submenuText.c_str(), 0);
-
- commandId++;
}
+}
+
+Common::String Lingo::genMenuHandler(int *commandId, Common::String &command) {
+ Common::String name;
+
+ do {
+ (*commandId)++;
+
+ name = Common::String::format("scummvmMenu%d", *commandId);
+ } while (getHandler(name) != NULL);
- warning("STUB: b_installMenu(%d)", d.u.i);
+ return Common::String::format("on %s\n %s\nend %s\n\n", name.c_str(), command.c_str(), name.c_str());
}
void Lingo::b_label(int nargs) {
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index fd5d2f86e5..bca28773c9 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -592,6 +592,7 @@ public:
private:
int parse(const char *code);
void parseMenu(const char *code);
+ Common::String genMenuHandler(int *commandId, Common::String &command);
void push(Datum d);
Datum pop(void);