aboutsummaryrefslogtreecommitdiff
path: root/engines/mohawk
diff options
context:
space:
mode:
authorAlyssa Milburn2011-04-07 23:05:22 +0200
committerAlyssa Milburn2011-04-07 23:05:22 +0200
commitf65840feef59557d3c759e7fa44996ae76d199be (patch)
treedef1d0059f961e5efc0b958adb84d871afe3a72f /engines/mohawk
parentbe09bef7f7c8fc6f6f8a3c9a9b3534a54c8a41e4 (diff)
downloadscummvm-rg350-f65840feef59557d3c759e7fa44996ae76d199be.tar.gz
scummvm-rg350-f65840feef59557d3c759e7fa44996ae76d199be.tar.bz2
scummvm-rg350-f65840feef59557d3c759e7fa44996ae76d199be.zip
MOHAWK: Add some more LBValue helpers.
Diffstat (limited to 'engines/mohawk')
-rw-r--r--engines/mohawk/livingbooks.h1
-rw-r--r--engines/mohawk/livingbooks_code.cpp43
-rw-r--r--engines/mohawk/livingbooks_code.h11
3 files changed, 55 insertions, 0 deletions
diff --git a/engines/mohawk/livingbooks.h b/engines/mohawk/livingbooks.h
index 123c2501c2..90540d2c9d 100644
--- a/engines/mohawk/livingbooks.h
+++ b/engines/mohawk/livingbooks.h
@@ -386,6 +386,7 @@ public:
uint16 getId() { return _itemId; }
const Common::String &getName() { return _desc; }
+ const Common::Rect &getRect() { return _rect; }
uint16 getSoundPriority() { return _soundMode; }
bool isAmbient() { return _isAmbient; }
diff --git a/engines/mohawk/livingbooks_code.cpp b/engines/mohawk/livingbooks_code.cpp
index 78345ab43e..dc72b2f974 100644
--- a/engines/mohawk/livingbooks_code.cpp
+++ b/engines/mohawk/livingbooks_code.cpp
@@ -71,6 +71,19 @@ bool LBValue::isZero() const {
return toInt() == 0; // FIXME
}
+Common::String LBValue::toString() const {
+ switch (type) {
+ case kLBValueString:
+ return string;
+ case kLBValueInteger:
+ return Common::String::format("%d", integer);
+ case kLBValueReal:
+ return Common::String::format("%f", real);
+ default:
+ return string; // FIXME
+ }
+}
+
int LBValue::toInt() const {
return integer; // FIXME
}
@@ -79,6 +92,36 @@ double LBValue::toDouble() const {
return real; // FIXME
}
+Common::Point LBValue::toPoint() const {
+ switch (type) {
+ case kLBValueString:
+ // FIXME
+ return Common::Point();
+ case kLBValueInteger:
+ return Common::Point(integer, integer);
+ case kLBValuePoint:
+ return point;
+ default:
+ error("failed to convert to point");
+ }
+}
+
+Common::Rect LBValue::toRect() const {
+ switch (type) {
+ case kLBValueString:
+ // FIXME
+ return Common::Rect();
+ case kLBValueInteger:
+ return Common::Rect(integer, integer, integer, integer);
+ case kLBValueRect:
+ return rect;
+ case kLBValueItemPtr:
+ return item->getRect();
+ default:
+ error("failed to convert to rect");
+ }
+}
+
LBCode::LBCode(MohawkEngine_LivingBooks *vm) : _vm(vm) {
Common::SeekableSubReadStreamEndian *bcodStream = _vm->wrapStreamEndian(ID_BCOD, 1000);
diff --git a/engines/mohawk/livingbooks_code.h b/engines/mohawk/livingbooks_code.h
index 71174cc09e..50b5783bbf 100644
--- a/engines/mohawk/livingbooks_code.h
+++ b/engines/mohawk/livingbooks_code.h
@@ -57,6 +57,14 @@ struct LBValue {
type = kLBValueString;
string = str;
}
+ LBValue(const Common::Point &p) {
+ type = kLBValuePoint;
+ point = p;
+ }
+ LBValue(const Common::Rect &r) {
+ type = kLBValueRect;
+ rect = r;
+ }
LBValue(LBItem *itm) {
type = kLBValueItemPtr;
item = itm;
@@ -99,8 +107,11 @@ struct LBValue {
bool isNumeric() const;
bool isZero() const;
+ Common::String toString() const;
int toInt() const;
double toDouble() const;
+ Common::Point toPoint() const;
+ Common::Rect toRect() const;
};
enum {