DIRECTOR: LINGO: Fix window fields

This commit is contained in:
djsrv 2020-07-09 20:15:38 -04:00
parent f04cd38da4
commit 0b82839b44
4 changed files with 49 additions and 18 deletions

View File

@ -324,34 +324,44 @@ bool Stage::hasProp(const Common::String &propName) {
}
Datum Stage::getProp(const Common::String &propName) {
if (g_lingo->_theEntityFields.contains(propName)) {
switch (g_lingo->_theEntityFields[propName]->field) {
case kTheVisible:
return isVisible();
default:
break;
}
if (g_lingo->_theEntityFields.contains(propName) && g_lingo->_theEntityFields[propName]->entity == kTheWindow) {
return getField(g_lingo->_theEntityFields[propName]->field);
}
warning("Stage::getProp: unhandled property '%s'", propName.c_str());
warning("Stage::getProp: unknown property '%s'", propName.c_str());
return Datum();
}
bool Stage::setProp(const Common::String &propName, const Datum &value) {
if (g_lingo->_theEntityFields.contains(propName)) {
switch (g_lingo->_theEntityFields[propName]->field) {
case kTheVisible:
setVisible(value.asInt());
return true;
default:
break;
}
if (g_lingo->_theEntityFields.contains(propName) && g_lingo->_theEntityFields[propName]->entity == kTheWindow) {
return setField(g_lingo->_theEntityFields[propName]->field, value);
}
warning("Stage::getProp: unhandled property '%s'", propName.c_str());
warning("Stage::setProp: unknown property '%s'", propName.c_str());
return false;
}
Datum Stage::getField(int field) {
switch (field) {
case kTheVisible:
return isVisible();
default:
warning("Stage::getField: unhandled field '%s'", g_lingo->field2str(field));
return Datum();
}
}
bool Stage::setField(int field, const Datum &value) {
switch (field) {
case kTheVisible:
setVisible(value.asInt());
return true;
default:
warning("Stage::setField: unhandled field '%s'", g_lingo->field2str(field));
return false;
}
}
void LM::m_close(int nargs) {
Stage *me = static_cast<Stage *>(g_lingo->_currentMe.u.obj);
me->setVisible(false);

View File

@ -56,6 +56,8 @@ public:
virtual bool hasProp(const Common::String &propName) = 0;
virtual Datum getProp(const Common::String &propName) = 0;
virtual bool setProp(const Common::String &propName, const Datum &value) = 0;
virtual Datum getField(int field) = 0;
virtual bool setField(int field, const Datum &value) = 0;
};
template <typename Derived>
@ -157,6 +159,12 @@ public:
virtual bool setProp(const Common::String &propName, const Datum &value) {
return false;
};
virtual Datum getField(int field) {
return Datum();
};
virtual bool setField(int field, const Datum &value) {
return false;
};
protected:
static SymbolHash *_methods;

View File

@ -32,6 +32,7 @@
#include "director/score.h"
#include "director/stage.h"
#include "director/lingo/lingo.h"
#include "director/lingo/lingo-builtins.h"
#include "director/lingo/lingo-code.h"
#include "director/lingo/lingo-object.h"
#include "director/lingo/lingo-the.h"
@ -149,7 +150,7 @@ TheEntity entities[] = {
{ kTheTraceLoad, "traceLoad", false, 4 }, // D4 p
{ kTheTraceLogFile, "traceLogFile", false, 4 }, // D4 p
{ kTheUpdateMovieEnabled,"updateMovieEnabled",false,4 },// D4 p
// { kTheWindow, "window", true, 4 }, // D4
{ kTheWindow, "window", true, 4 }, // D4
{ kTheWindowList, "windowList", false, 4 }, // D4 p
{ kTheNOEntity, NULL, false, 0 }
};
@ -578,6 +579,11 @@ Datum Lingo::getTheEntity(int entity, Datum &id, int field) {
d.type = INT;
d.u.i = _vm->getMacTicks() - _vm->getCurrentMovie()->_lastTimerReset;
break;
case kTheWindow:
g_lingo->push(id);
LB::b_window(1);
d = g_lingo->pop().u.obj->getField(field);
break;
case kTheWindowList:
d = g_lingo->_windowList;
break;
@ -666,6 +672,11 @@ void Lingo::setTheEntity(int entity, Datum &id, int field, Datum &d) {
case kTheTimeoutScript:
setPrimaryEventHandler(kEventTimeout, d.asString());
break;
case kTheWindow:
g_lingo->push(id);
LB::b_window(1);
g_lingo->pop().u.obj->setField(field, d);
break;
case kTheWindowList:
if (d.type == ARRAY) {
g_lingo->_windowList = d;

View File

@ -142,6 +142,8 @@ class Stage : public Graphics::MacWindow, public Object<Stage> {
virtual bool hasProp(const Common::String &propName);
virtual Datum getProp(const Common::String &propName);
virtual bool setProp(const Common::String &propName, const Datum &value);
virtual Datum getField(int field);
virtual bool setField(int field, const Datum &value);
public:
Common::List<Common::Rect> _dirtyRects;