aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/supernova2/state.cpp92
-rw-r--r--engines/supernova2/state.h42
2 files changed, 134 insertions, 0 deletions
diff --git a/engines/supernova2/state.cpp b/engines/supernova2/state.cpp
index e2fc600a47..33a3d95351 100644
--- a/engines/supernova2/state.cpp
+++ b/engines/supernova2/state.cpp
@@ -92,6 +92,55 @@ Object *Inventory::get(ObjectId id) const {
return _nullObject;
}
+
+GuiElement::GuiElement()
+ : _isHighlighted(false)
+ , _bgColorNormal(kColorWhite25)
+ , _bgColorHighlighted(kColorWhite44)
+ , _bgColor(kColorWhite25)
+ , _textColorNormal(kColorGreen)
+ , _textColorHighlighted(kColorLightGreen)
+ , _textColor(kColorGreen)
+{
+ memset(_text, 0, sizeof(_text));
+}
+
+void GuiElement::setText(const char *text) {
+ strncpy(_text, text, sizeof(_text) - 1);
+}
+
+void GuiElement::setTextPosition(int x, int y) {
+ _textPosition = Common::Point(x, 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 = Common::Point(x1 + 1, 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;
+ }
+}
+
GameManager::GameManager(Supernova2Engine *vm)
: _inventory(&_nullObject, _inventoryScroll)
, _vm(vm)
@@ -99,6 +148,7 @@ GameManager::GameManager(Supernova2Engine *vm)
initRooms();
changeRoom(INTRO);
initState();
+ initGui();
}
GameManager::~GameManager() {
@@ -143,6 +193,48 @@ void GameManager::initRooms() {
_rooms[AIRPORT] = new Airport(_vm, this);
}
+void GameManager::initGui() {
+ int cmdCount = ARRAYSIZE(_guiCommandButton);
+ int cmdAvailableSpace = 320 - (cmdCount - 1) * 2;
+ for (int i = 0; i < cmdCount; ++i) {
+ const Common::String &text = _vm->getGameString(guiCommands[i]);
+ cmdAvailableSpace -= Screen::textWidth(text);
+ }
+
+ int commandButtonX = 0;
+ for (int i = 0; i < ARRAYSIZE(_guiCommandButton); ++i) {
+ const Common::String &text = _vm->getGameString(guiCommands[i]);
+ int width;
+ if (i < cmdCount - 1) {
+ int space = cmdAvailableSpace / (cmdCount - i);
+ cmdAvailableSpace -= space;
+ width = Screen::textWidth(text) + space;
+ } else
+ width = 320 - commandButtonX;
+
+ _guiCommandButton[i].setSize(commandButtonX, 150, commandButtonX + width, 159);
+ _guiCommandButton[i].setText(text.c_str());
+ _guiCommandButton[i].setColor(kColorWhite25, kColorDarkGreen, kColorWhite44, kColorGreen);
+ commandButtonX += width + 2;
+ }
+
+ for (int i = 0; i < ARRAYSIZE(_guiInventory); ++i) {
+ int inventoryX = 136 * (i % 2);
+ int inventoryY = 161 + 10 * (i / 2);
+
+ _guiInventory[i].setSize(inventoryX, inventoryY, inventoryX + 135, inventoryY + 9);
+ _guiInventory[i].setColor(kColorWhite25, kColorDarkRed, kColorWhite35, kColorRed);
+ }
+ _guiInventoryArrow[0].setSize(272, 161, 279, 180);
+ _guiInventoryArrow[0].setColor(kColorWhite25, kColorDarkRed, kColorWhite35, kColorRed);
+ _guiInventoryArrow[0].setText("\x82");
+ _guiInventoryArrow[0].setTextPosition(273, 166);
+ _guiInventoryArrow[1].setSize(272, 181, 279, 200);
+ _guiInventoryArrow[1].setColor(kColorWhite25, kColorDarkRed, kColorWhite35, kColorRed);
+ _guiInventoryArrow[1].setText("\x83");
+ _guiInventoryArrow[1].setTextPosition(273, 186);
+}
+
void GameManager::updateEvents() {
if (_animationEnabled && !_vm->_screen->isMessageShown() && _animationTimer == 0)
_currentRoom->animation();
diff --git a/engines/supernova2/state.h b/engines/supernova2/state.h
index 84e9f2c8b1..7ed65cc3a3 100644
--- a/engines/supernova2/state.h
+++ b/engines/supernova2/state.h
@@ -60,6 +60,44 @@ private:
int _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);
+
+ const char *getText() const {
+ return _text;
+ }
+ int getBackgroundColor() const {
+ return _bgColor;
+ }
+ int getTextColor() const {
+ return _textColor;
+ }
+ const Common::Point &getTextPos() const {
+ return _textPosition;
+ }
+ bool isHighlighted() const {
+ return _isHighlighted;
+ }
+
+private:
+ Common::Point _textPosition;
+ char _text[128];
+ int _bgColor;
+ int _textColor;
+ int _bgColorNormal;
+ int _bgColorHighlighted;
+ int _textColorNormal;
+ int _textColorHighlighted;
+ bool _isHighlighted;
+};
+
class GameManager {
public:
GameManager(Supernova2Engine *vm);
@@ -96,6 +134,9 @@ public:
int32 _animationTimer;
int _inventoryScroll;
int _exitList[25];
+ GuiElement _guiCommandButton[10];
+ GuiElement _guiInventory[8];
+ GuiElement _guiInventoryArrow[2];
// Dialog
int _currentSentence;
int _sentenceNumber[6];
@@ -105,6 +146,7 @@ public:
void initState();
void initRooms();
void destroyRooms();
+ void initGui();
void getInput();
void changeRoom(RoomId id);
void wait(int ticks);