DIRECTOR: Initial code for Lingo keyboard handling

This commit is contained in:
Eugene Sandulenko 2016-09-02 09:30:37 +02:00
parent 82e0ad732e
commit 18af5ea5da
7 changed files with 22 additions and 7 deletions

View File

@ -72,6 +72,7 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam
SearchMan.addSubDirectoryMatching(gameDataDir, "install");
_colorDepth = 8; // FIXME. Check if it is 8-bit
_keyCode = 0;
}
DirectorEngine::~DirectorEngine() {

View File

@ -98,6 +98,7 @@ public:
public:
int _colorDepth;
int _keyCode;
protected:
virtual Common::Error run();

View File

@ -756,14 +756,14 @@ void Lingo::c_whencode() {
Datum d;
int start = g_lingo->_pc;
int end = READ_UINT32(&(*g_lingo->_currentScript)[start]);
Common::String eventname((char *)&(*g_lingo->_currentScript)[start]);
Common::String eventname((char *)&(*g_lingo->_currentScript)[start + 1]);
start += g_lingo->calcStringAlignment(eventname.c_str());
g_lingo->define(eventname, start, 0, NULL, end);
debugC(3, kDebugLingoExec, "c_whencode([%5d][%5d], %s)", start, end, eventname.c_str());
g_lingo->define(eventname, start, 0, NULL, end);
g_lingo->_pc = end;
}
@ -833,7 +833,7 @@ void Lingo::c_call() {
g_lingo->call(name, nargs);
}
void Lingo::call(Common::String &name, int nargs) {
void Lingo::call(Common::String name, int nargs) {
bool drop = false;
Symbol *sym;

View File

@ -365,6 +365,10 @@ Datum Lingo::getTheEntity(int entity, Datum &id, int field) {
d.type = FLOAT;
d.u.f = sqrt(id.u.f);
break;
case kTheKeyCode:
d.type = INT;
d.u.i = _vm->_keyCode;
break;
case kTheColorQD:
d.type = INT;
d.u.i = 1;

View File

@ -273,10 +273,14 @@ void Lingo::processEvent(LEvent event, int entityId) {
ScriptType st = event2script(event);
if (st != kNoneScript)
if (st != kNoneScript) {
executeScript(st, entityId + 1);
else
} else if (_handlers.contains(_eventHandlerTypes[event])) {
call(_eventHandlerTypes[event], 0);
} else {
warning("---- Handler %s is not set", _eventHandlerTypes[event]);
debugC(8, kDebugLingoExec, "STUB: processEvent(%s) for %d", _eventHandlerTypes[event], entityId);
}
}
int Lingo::alignTypes(Datum &d1, Datum &d2) {

View File

@ -275,7 +275,7 @@ public:
static void c_le();
static void c_call();
void call(Common::String &name, int nargs);
void call(Common::String name, int nargs);
static void c_procret();

View File

@ -839,6 +839,11 @@ void Score::processEvents() {
_lingo->processEvent(kEventMouseUp, _frames[_currentFrame]->getSpriteIDFromPos(pos));
}
if (event.type == Common::EVENT_KEYDOWN) {
_vm->_keyCode = event.kbd.keycode;
_lingo->processEvent(kEventKeyDown, 0);
}
}
g_system->updateScreen();