aboutsummaryrefslogtreecommitdiff
path: root/engines/neverhood
diff options
context:
space:
mode:
authorjohndoe1232012-10-25 13:14:26 +0000
committerWillem Jan Palenstijn2013-05-08 20:47:37 +0200
commiteecd9b8b2a2eda9641bf7bbd5bd5860123d102b4 (patch)
treeb44fbc503b986df2dfde2b4a57fa08b44bffa861 /engines/neverhood
parent228d9264c8e9f5e1930e8b69ce809783d303bbbc (diff)
downloadscummvm-rg350-eecd9b8b2a2eda9641bf7bbd5bd5860123d102b4.tar.gz
scummvm-rg350-eecd9b8b2a2eda9641bf7bbd5bd5860123d102b4.tar.bz2
scummvm-rg350-eecd9b8b2a2eda9641bf7bbd5bd5860123d102b4.zip
NEVERHOOD: Add TextLabelWidget (still doesn't do anything)
Diffstat (limited to 'engines/neverhood')
-rw-r--r--engines/neverhood/graphics.h1
-rw-r--r--engines/neverhood/menumodule.cpp48
-rw-r--r--engines/neverhood/menumodule.h22
3 files changed, 71 insertions, 0 deletions
diff --git a/engines/neverhood/graphics.h b/engines/neverhood/graphics.h
index 3ca3339585..d6808e37f5 100644
--- a/engines/neverhood/graphics.h
+++ b/engines/neverhood/graphics.h
@@ -149,6 +149,7 @@ public:
void drawChar(BaseSurface *destSurface, int16 x, int16 y, byte chr);
void drawString(BaseSurface *destSurface, int16 x, int16 y, const byte *string, int stringLen);
int16 getStringWidth(const byte *string, int stringLen);
+ uint16 getCharHeight() const { return _charHeight; }
protected:
uint16 _numRows;
byte _firstChar;
diff --git a/engines/neverhood/menumodule.cpp b/engines/neverhood/menumodule.cpp
index bec640e5d4..01fcd41d75 100644
--- a/engines/neverhood/menumodule.cpp
+++ b/engines/neverhood/menumodule.cpp
@@ -450,4 +450,52 @@ uint32 Widget::handleMessage(int messageNum, const MessageParam &param, Entity *
return messageResult;
}
+TextLabelWidget::TextLabelWidget(NeverhoodEngine *vm, int16 x, int16 y, int16 itemID, WidgetScene *parentScene,
+ int baseObjectPriority, int baseSurfacePriority, bool visible,
+ const byte *string, int stringLen, BaseSurface *drawSurface, int16 tx, int16 ty, TextSurface *textSurface)
+ : Widget(vm, x, y, itemID, parentScene, baseObjectPriority, baseSurfacePriority, visible),
+ _string(string), _stringLen(stringLen), _drawSurface(drawSurface), _tx(tx), _ty(ty), _textSurface(textSurface) {
+
+}
+
+void TextLabelWidget::addSprite() {
+ _parentScene->addSprite(this);
+ _vm->_collisionMan->addSprite(this);
+}
+
+int16 TextLabelWidget::getWidth() {
+ return _textSurface->getStringWidth(_string, _stringLen);
+}
+
+int16 TextLabelWidget::getHeight() {
+ return _textSurface->getCharHeight();
+}
+
+void TextLabelWidget::drawString(int maxStringLength) {
+ _textSurface->drawString(_drawSurface, _x, _y, _string, MIN(_stringLen, maxStringLength));
+ _visible = true;
+ _collisionBoundsOffset.set(_tx, _ty, getWidth(), getHeight());
+ updateBounds();
+}
+
+void TextLabelWidget::clear() {
+ _visible = false;
+ _collisionBoundsOffset.set(0, 0, 0, 0);
+ updateBounds();
+}
+
+void TextLabelWidget::onClick() {
+ Widget::onClick();
+ // TODO Click handler?
+}
+
+void TextLabelWidget::setString(const byte *string, int stringLen) {
+ _string = string;
+ _stringLen = stringLen;
+}
+
+void TextLabelWidget::setY(int16 y) {
+ _ty = y;
+}
+
} // End of namespace Neverhood
diff --git a/engines/neverhood/menumodule.h b/engines/neverhood/menumodule.h
index 1b6ba8a9f7..8381b4eb30 100644
--- a/engines/neverhood/menumodule.h
+++ b/engines/neverhood/menumodule.h
@@ -114,6 +114,28 @@ protected:
uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
};
+class TextLabelWidget : public Widget {
+public:
+ TextLabelWidget(NeverhoodEngine *vm, int16 x, int16 y, int16 itemID, WidgetScene *parentScene,
+ int baseObjectPriority, int baseSurfacePriority, bool visible,
+ const byte *string, int stringLen, BaseSurface *drawSurface, int16 tx, int16 ty, TextSurface *textSurface);
+ virtual void onClick();
+ virtual void addSprite();
+ virtual int16 getWidth();
+ virtual int16 getHeight();
+ void drawString(int maxStringLength);
+ void clear();
+ void setString(const byte *string, int stringLen);
+ TextSurface *getTextSurface() const { return _textSurface; }
+ void setY(int16 y);
+protected:
+ BaseSurface *_drawSurface;
+ int16 _tx, _ty;
+ TextSurface *_textSurface;
+ const byte *_string;
+ int _stringLen;
+};
+
} // End of namespace Neverhood
#endif /* NEVERHOOD_MENUMODULE_H */