MTROPOLIS: Add width/height read attribs, fix up some error messages

This commit is contained in:
elasota 2022-05-02 02:00:22 -04:00 committed by Eugene Sandulenko
parent 5e9f44d731
commit d966b988b7
2 changed files with 8 additions and 2 deletions

View File

@ -1261,13 +1261,13 @@ MiniscriptInstructionOutcome GetChild::execute(MiniscriptThread *thread) const {
if (indexableValueSlot.value.getType() == DynamicValueTypes::kObject) {
Common::SharedPtr<RuntimeObject> obj = indexableValueSlot.value.getObject().object.lock();
if (!obj) {
thread->error("Tried to read '" + attrib + "' to an invalid object reference");
thread->error("Tried to indirect '" + attrib + "' using an invalid object reference");
return kMiniscriptInstructionOutcomeFailed;
}
DynamicValueWriteProxy writeProxy;
if (!obj->writeRefAttribute(thread, writeProxy, attrib)) {
thread->error("Failed to read attribute '" + attrib + "'");
thread->error("Failed to get a writeable reference to attribute '" + attrib + "'");
return kMiniscriptInstructionOutcomeFailed;
}

View File

@ -4330,6 +4330,12 @@ bool VisualElement::readAttribute(MiniscriptThread *thread, DynamicValue &result
} else if (attrib == "position") {
result.setPoint(Point16::create(_rect.left, _rect.top));
return true;
} else if (attrib == "width") {
result.setInt(_rect.right - _rect.left);
return true;
} else if (attrib == "height") {
result.setInt(_rect.bottom - _rect.top);
return true;
}
return Element::readAttribute(thread, result, attrib);