aboutsummaryrefslogtreecommitdiff
path: root/engines/director/lingo/lingo-builtins.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2019-12-16 17:36:58 +0100
committerEugene Sandulenko2019-12-16 17:36:58 +0100
commitd62a589059bfd613e307cd771f073abd2194149e (patch)
treed022d8de28a7323a7601159f89a4010600a960be /engines/director/lingo/lingo-builtins.cpp
parenta6df004aac29c2f14c0d5002a8c4578b1cb283d6 (diff)
downloadscummvm-rg350-d62a589059bfd613e307cd771f073abd2194149e.tar.gz
scummvm-rg350-d62a589059bfd613e307cd771f073abd2194149e.tar.bz2
scummvm-rg350-d62a589059bfd613e307cd771f073abd2194149e.zip
DIRECTOR: LINGO: Generate code for menu actions
Diffstat (limited to 'engines/director/lingo/lingo-builtins.cpp')
-rw-r--r--engines/director/lingo/lingo-builtins.cpp25
1 files changed, 19 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) {