Permalink
Browse files

SUPERNOVA: Adds GuiElement Class

  • Loading branch information...
Joefish committed Jul 17, 2017
1 parent a6371e2 commit c3143383c0c8e86e9a9e7fa2cae031cb751d9393
Showing with 75 additions and 0 deletions.
  1. +49 −0 engines/supernova/state.cpp
  2. +26 −0 engines/supernova/state.h
@@ -68,6 +68,55 @@ Object *Inventory::get(ObjectID id) const {
return NULL;
}
GuiElement::GuiElement()
: _text("")
, _isHighlighted(false)
, _isVisible(true)
, _bgColorNormal(kColorWhite25)
, _bgColorHighlighted(kColorWhite44)
, _bgColor(kColorWhite25)
, _textColorNormal(kColorGreen)
, _textColorHighlighted(kColorLightGreen)
, _textColor(kColorGreen)
{}
void GuiElement::setText(const char *text) {
strncpy(_text, text, sizeof(_text));
}
void GuiElement::setTextPosition(int x, int y) {
_textPosition.x = x;
_textPosition.y = y;
}
void GuiElement::setSize(int x1, int y1, int x2, int y2) {
this->left = x1;
this->top = y1;
this->right = x2;
this->bottom = y2;
_textPosition.x = x1 + 1;
_textPosition.y = y1 + 1;
}
void GuiElement::setColor(int bgColor, int textColor, int bgColorHighlighted, int textColorHightlighted) {
_bgColor = bgColor;
_textColor = textColor;
_bgColorNormal = bgColor;
_textColorNormal = textColor;
_bgColorHighlighted = bgColorHighlighted;
_textColorHighlighted = textColorHightlighted;
}
void GuiElement::setHighlight(bool isHighlighted) {
if (isHighlighted) {
_bgColor = _bgColorHighlighted;
_textColor = _textColorHighlighted;
} else {
_bgColor = _bgColorNormal;
_textColor = _textColorNormal;
}
}
static const char *timeToString(int t) {
// TODO: Does ScummVM emulate PIT timings for DOS?
View
@@ -73,6 +73,32 @@ class Inventory {
uint _numObjects;
};
class GuiElement : public Common::Rect {
public:
GuiElement();
void setSize(int x1, int y1, int x2, int y2);
void setText(const char *text);
void setTextPosition(int x, int y);
void setColor(int bgColor, int textColor, int bgColorHighlighted, int textColorHightlighted);
void setHighlight(bool isHighlighted);
// virtual void onMouseOver() {}
// virtual void onMouseOut() {}
// virtual void onMouseClick() {}
Common::Point _textPosition;
char _text[128];
int _bgColor;
int _textColor;
int _bgColorNormal;
int _bgColorHighlighted;
int _textColorNormal;
int _textColorHighlighted;
bool _isHighlighted;
bool _isVisible;
};
class GameManager {
public:
GameManager(SupernovaEngine *vm);

0 comments on commit c314338

Please sign in to comment.