aboutsummaryrefslogtreecommitdiff
path: root/engines/director
diff options
context:
space:
mode:
authorEugene Sandulenko2017-04-14 18:48:20 +0200
committerEugene Sandulenko2017-04-14 18:49:01 +0200
commit4873330d239554b359564c8452a4fd2c6b7c5091 (patch)
tree7fb49ca1802eff31d4402a466ad29392288e28f3 /engines/director
parent1e38ca45cdec28a7a4041f2ec3bae716e6663cf4 (diff)
downloadscummvm-rg350-4873330d239554b359564c8452a4fd2c6b7c5091.tar.gz
scummvm-rg350-4873330d239554b359564c8452a4fd2c6b7c5091.tar.bz2
scummvm-rg350-4873330d239554b359564c8452a4fd2c6b7c5091.zip
DIRECTOR: Lingo: Added stub for generic event handlers
Diffstat (limited to 'engines/director')
-rw-r--r--engines/director/lingo/lingo-events.cpp174
-rw-r--r--engines/director/lingo/lingo.cpp103
-rw-r--r--engines/director/lingo/lingo.h19
-rw-r--r--engines/director/module.mk1
4 files changed, 191 insertions, 106 deletions
diff --git a/engines/director/lingo/lingo-events.cpp b/engines/director/lingo/lingo-events.cpp
new file mode 100644
index 0000000000..21758bcc54
--- /dev/null
+++ b/engines/director/lingo/lingo-events.cpp
@@ -0,0 +1,174 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "director/lingo/lingo.h"
+
+namespace Director {
+
+struct EventHandlerType {
+ LEvent handler;
+ const char *name;
+} static const eventHandlerDescs[] = {
+ { kEventPrepareMovie, "prepareMovie" },
+ { kEventStartMovie, "startMovie" }, // D3?
+ { kEventStepMovie, "stepMovie" }, // D3?
+ { kEventStopMovie, "stopMovie" }, // D3?
+
+ { kEventNew, "newSprite" },
+ { kEventBeginSprite, "beginSprite" },
+ { kEventEndSprite, "endSprite" },
+
+ { kEventEnterFrame, "enterFrame" }, // D4
+ { kEventPrepareFrame, "prepareFrame" },
+ { kEventIdle, "idle" },
+ { kEventStepFrame, "stepFrame"},
+ { kEventExitFrame, "exitFrame" }, // D4
+
+ { kEventActivateWindow, "activateWindow" },
+ { kEventDeactivateWindow, "deactivateWindow" },
+ { kEventMoveWindow, "moveWindow" },
+ { kEventResizeWindow, "resizeWindow" },
+ { kEventOpenWindow, "openWindow" },
+ { kEventCloseWindow, "closeWindow" },
+ { kEventStart, "start" },
+
+ { kEventKeyUp, "keyUp" }, // D4
+ { kEventKeyDown, "keyDown" }, // D2 w D4 (as when from D2)
+ { kEventMouseUp, "mouseUp" }, // D2 w D3?
+ { kEventMouseDown, "mouseDown" }, // D2 w D3?
+ { kEventRightMouseDown, "rightMouseDown" },
+ { kEventRightMouseUp, "rightMouseUp" },
+ { kEventMouseEnter, "mouseEnter" },
+ { kEventMouseLeave, "mouseLeave" },
+ { kEventMouseUpOutSide, "mouseUpOutSide" },
+ { kEventMouseWithin, "mouseWithin" },
+
+ { kEventTimeout, "timeout" }, // D2 as when
+
+ { kEventNone, 0 },
+};
+
+void Lingo::initEventHandlerTypes() {
+ for (const EventHandlerType *t = &eventHandlerDescs[0]; t->handler != kEventNone; ++t) {
+ _eventHandlerTypeIds[t->name] = t->handler;
+ _eventHandlerTypes[t->handler] = t->name;
+ }
+}
+
+ScriptType Lingo::event2script(LEvent ev) {
+ if (_vm->getVersion() < 4) {
+ switch (ev) {
+ //case kEventStartMovie: // We are precompiling it now
+ // return kMovieScript;
+ case kEventEnterFrame:
+ return kFrameScript;
+ default:
+ return kNoneScript;
+ }
+ }
+
+ return kNoneScript;
+}
+
+Symbol *Lingo::getHandler(Common::String &name) {
+ if (!_eventHandlerTypeIds.contains(name)) {
+ if (_builtins.contains(name))
+ return _builtins[name];
+
+ return NULL;
+ }
+
+ uint32 entityIndex = ENTITY_INDEX(_eventHandlerTypeIds[name], _currentEntityId);
+ if (!_handlers.contains(entityIndex))
+ return NULL;
+
+ return _handlers[entityIndex];
+}
+
+void Lingo::processInputEvent(LEvent event) {
+ // Primary Event handler
+ // Score Script
+ // Script of Cast Member
+ // Score Script
+ // Movie Script
+}
+
+void Lingo::processFrameEvent(LEvent event) {
+ // Primary Event handler
+ // Score Script
+ // Movie Script
+}
+
+void Lingo::processGenericEvent(LEvent event) {
+ // Primary Event handler
+ // Movie Script
+}
+
+void Lingo::processEvent(LEvent event) {
+ switch (event) {
+ case kEventKeyUp:
+ case kEventKeyDown:
+ case kEventMouseUp:
+ case kEventMouseDown:
+ processInputEvent(event);
+ break;
+
+ case kEventEnterFrame:
+ case kEventExitFrame:
+ processFrameEvent(event);
+ break;
+
+ case kEventStartMovie:
+ case kEventStopMovie:
+ case kEventIdle:
+ case kEventTimeout:
+ processGenericEvent(event);
+
+ default:
+ warning("processEvent: Unhandled event %s", _eventHandlerTypes[event]);
+ }
+}
+
+void Lingo::processEvent(LEvent event, ScriptType st, int entityId) {
+ if (entityId < 0)
+ return;
+
+ debugC(9, kDebugEvents, "Lingo::processEvent(%s, %s, %d)", _eventHandlerTypes[event], scriptType2str(st), entityId);
+
+ _currentEntityId = entityId;
+
+ if (!_eventHandlerTypes.contains(event))
+ error("processEvent: Unknown event %d for entity %d", event, entityId);
+
+ if (_handlers.contains(ENTITY_INDEX(event, entityId))) {
+ debugC(1, kDebugEvents, "Lingo::processEvent(%s, %s, %d), _eventHandler", _eventHandlerTypes[event], scriptType2str(st), entityId);
+ call(_eventHandlerTypes[event], 0); // D4+ Events
+ } else if (event == kEventNone && _scripts[st].contains(entityId)) {
+ debugC(1, kDebugEvents, "Lingo::processEvent(%s, %s, %d), script", _eventHandlerTypes[event], scriptType2str(st), entityId);
+
+ executeScript(st, entityId); // D3 list of scripts.
+ } else {
+ //debugC(3, kDebugLingoExec, "STUB: processEvent(%s) for %d", _eventHandlerTypes[event], entityId);
+ }
+}
+
+} // End of namespace Director
diff --git a/engines/director/lingo/lingo.cpp b/engines/director/lingo/lingo.cpp
index 482531d455..cb16431d77 100644
--- a/engines/director/lingo/lingo.cpp
+++ b/engines/director/lingo/lingo.cpp
@@ -31,49 +31,6 @@ namespace Director {
Lingo *g_lingo;
-struct EventHandlerType {
- LEvent handler;
- const char *name;
-} static const eventHandlerDescs[] = {
- { kEventPrepareMovie, "prepareMovie" },
- { kEventStartMovie, "startMovie" }, // D3?
- { kEventStepMovie, "stepMovie" }, // D3?
- { kEventStopMovie, "stopMovie" }, // D3?
-
- { kEventNew, "newSprite" },
- { kEventBeginSprite, "beginSprite" },
- { kEventEndSprite, "endSprite" },
-
- { kEventEnterFrame, "enterFrame" }, // D4
- { kEventPrepareFrame, "prepareFrame" },
- { kEventIdle, "idle" },
- { kEventStepFrame, "stepFrame"},
- { kEventExitFrame, "exitFrame" }, // D4
-
- { kEventActivateWindow, "activateWindow" },
- { kEventDeactivateWindow, "deactivateWindow" },
- { kEventMoveWindow, "moveWindow" },
- { kEventResizeWindow, "resizeWindow" },
- { kEventOpenWindow, "openWindow" },
- { kEventCloseWindow, "closeWindow" },
- { kEventStart, "start" },
-
- { kEventKeyUp, "keyUp" }, // D4
- { kEventKeyDown, "keyDown" }, // D2 w D4 (as when from D2)
- { kEventMouseUp, "mouseUp" }, // D2 w D3?
- { kEventMouseDown, "mouseDown" }, // D2 w D3?
- { kEventRightMouseDown, "rightMouseDown" },
- { kEventRightMouseUp, "rightMouseUp" },
- { kEventMouseEnter, "mouseEnter" },
- { kEventMouseLeave, "mouseLeave" },
- { kEventMouseUpOutSide, "mouseUpOutSide" },
- { kEventMouseWithin, "mouseWithin" },
-
- { kEventTimeout, "timeout" }, // D2 as when
-
- { kEventNone, 0 },
-};
-
Symbol::Symbol() {
type = VOID;
u.s = NULL;
@@ -86,11 +43,6 @@ Symbol::Symbol() {
Lingo::Lingo(DirectorEngine *vm) : _vm(vm) {
g_lingo = this;
- for (const EventHandlerType *t = &eventHandlerDescs[0]; t->handler != kEventNone; ++t) {
- _eventHandlerTypeIds[t->name] = t->handler;
- _eventHandlerTypes[t->handler] = t->name;
- }
-
_currentScript = 0;
_currentScriptType = kMovieScript;
_currentEntityId = 0;
@@ -115,6 +67,8 @@ Lingo::Lingo(DirectorEngine *vm) : _vm(vm) {
_localvars = NULL;
+ initEventHandlerTypes();
+
initBuiltIns();
initFuncs();
initTheEntities();
@@ -265,59 +219,6 @@ void Lingo::executeScript(ScriptType type, uint16 id) {
cleanLocalVars();
}
-ScriptType Lingo::event2script(LEvent ev) {
- if (_vm->getVersion() < 4) {
- switch (ev) {
- //case kEventStartMovie: // We are precompiling it now
- // return kMovieScript;
- case kEventEnterFrame:
- return kFrameScript;
- default:
- return kNoneScript;
- }
- }
-
- return kNoneScript;
-}
-
-Symbol *Lingo::getHandler(Common::String &name) {
- if (!_eventHandlerTypeIds.contains(name)) {
- if (_builtins.contains(name))
- return _builtins[name];
-
- return NULL;
- }
-
- uint32 entityIndex = ENTITY_INDEX(_eventHandlerTypeIds[name], _currentEntityId);
- if (!_handlers.contains(entityIndex))
- return NULL;
-
- return _handlers[entityIndex];
-}
-
-void Lingo::processEvent(LEvent event, ScriptType st, int entityId) {
- if (entityId < 0)
- return;
-
- debugC(9, kDebugEvents, "Lingo::processEvent(%s, %s, %d)", _eventHandlerTypes[event], scriptType2str(st), entityId);
-
- _currentEntityId = entityId;
-
- if (!_eventHandlerTypes.contains(event))
- error("processEvent: Unknown event %d for entity %d", event, entityId);
-
- if (_handlers.contains(ENTITY_INDEX(event, entityId))) {
- debugC(1, kDebugEvents, "Lingo::processEvent(%s, %s, %d), _eventHandler", _eventHandlerTypes[event], scriptType2str(st), entityId);
- call(_eventHandlerTypes[event], 0); // D4+ Events
- } else if (event == kEventNone && _scripts[st].contains(entityId)) {
- debugC(1, kDebugEvents, "Lingo::processEvent(%s, %s, %d), script", _eventHandlerTypes[event], scriptType2str(st), entityId);
-
- executeScript(st, entityId); // D3 list of scripts.
- } else {
- //debugC(3, kDebugLingoExec, "STUB: processEvent(%s) for %d", _eventHandlerTypes[event], entityId);
- }
-}
-
void Lingo::restartLingo() {
warning("STUB: restartLingo()");
diff --git a/engines/director/lingo/lingo.h b/engines/director/lingo/lingo.h
index 8475905690..15071b8699 100644
--- a/engines/director/lingo/lingo.h
+++ b/engines/director/lingo/lingo.h
@@ -181,11 +181,6 @@ public:
void printStack(const char *s);
Common::String decodeInstruction(uint pc, uint *newPC = NULL);
- ScriptType event2script(LEvent ev);
- Symbol *getHandler(Common::String &name);
-
- void processEvent(LEvent event, ScriptType st, int entityId);
-
void initBuiltIns();
void initFuncs();
void initTheEntities();
@@ -195,6 +190,20 @@ public:
private:
const char *findNextDefinition(const char *s);
+ // lingo-events.cpp
+private:
+ void initEventHandlerTypes();
+ void processInputEvent(LEvent event);
+ void processFrameEvent(LEvent event);
+ void processGenericEvent(LEvent event);
+
+public:
+ ScriptType event2script(LEvent ev);
+ Symbol *getHandler(Common::String &name);
+
+ void processEvent(LEvent event, ScriptType st, int entityId);
+ void processEvent(LEvent event);
+
public:
void execute(uint pc);
void pushContext();
diff --git a/engines/director/module.mk b/engines/director/module.mk
index 28260ea5c3..acfc4fdb53 100644
--- a/engines/director/module.mk
+++ b/engines/director/module.mk
@@ -20,6 +20,7 @@ MODULE_OBJS = \
lingo/lingo-builtins.o \
lingo/lingo-code.o \
lingo/lingo-codegen.o \
+ lingo/lingo-events.o \
lingo/lingo-funcs.o \
lingo/lingo-lex.o \
lingo/lingo-the.o