From efdf51d3ddbb89f2fc1858c9f13ee6bb1a8b005a Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 20 Jan 2016 22:36:36 +0100 Subject: WAGE: Draw gameover dialog --- engines/wage/dialog.cpp | 29 ++++++++++++++++++----------- engines/wage/dialog.h | 10 +++++----- engines/wage/wage.cpp | 3 +-- 3 files changed, 24 insertions(+), 18 deletions(-) (limited to 'engines/wage') diff --git a/engines/wage/dialog.cpp b/engines/wage/dialog.cpp index abd4d1b1c4..a02058c331 100644 --- a/engines/wage/dialog.cpp +++ b/engines/wage/dialog.cpp @@ -56,8 +56,8 @@ namespace Wage { enum { - kDialogWidth = 292, - kDialogHeight = 114 + kDialogWidth = 199, + kDialogHeight = 113 }; Dialog::Dialog(Gui *gui, const char *text, DialogButtonArray *buttons) : _gui(gui), _text(text), _buttons(buttons) { @@ -73,10 +73,17 @@ Dialog::Dialog(Gui *gui, const char *text, DialogButtonArray *buttons) : _gui(gu _bbox.right = (_gui->_screen.w + kDialogWidth) / 2; _bbox.bottom = (_gui->_screen.h + kDialogHeight) / 2; - _defaultButton = NULL; - _pressedButton = NULL; + _defaultButton = -1; + _pressedButton = -1; _mouseOverPressedButton = false; + + // Adjust button positions + for (int i = 0; i < _buttons->size(); i++) + _buttons->operator[](i)->bounds.translate(_bbox.left, _bbox.top); + + if (_buttons->size() == 1) + _defaultButton = 0; } Dialog::~Dialog() { @@ -88,7 +95,7 @@ const Graphics::Font *Dialog::getDialogFont() { void Dialog::paint() { Design::drawFilledRect(&_gui->_screen, _bbox, kColorWhite, _gui->_patterns, kPatternSolid); - _font->drawString(&_gui->_screen, _text, _bbox.left + 24, _bbox.right + 32, _bbox.width(), kColorBlack); + _font->drawString(&_gui->_screen, _text, _bbox.left + 24, _bbox.top + 16, _bbox.width(), kColorBlack); static int boxOutline[] = { 1, 0, 0, 1, 1 }; drawOutline(_bbox, boxOutline, ARRAYSIZE(boxOutline)); @@ -97,7 +104,7 @@ void Dialog::paint() { DialogButton *button = _buttons->operator[](i); static int buttonOutline[] = { 0, 0, 0, 0, 1 }; - if (button == _defaultButton) { + if (i == _defaultButton) { buttonOutline[0] = buttonOutline[1] = 1; } else { buttonOutline[0] = buttonOutline[1] = 0; @@ -105,7 +112,7 @@ void Dialog::paint() { int color = kColorBlack; - if (_pressedButton == button && _mouseOverPressedButton) { + if (i == _pressedButton && _mouseOverPressedButton) { Common::Rect bb(button->bounds.left + 5, button->bounds.top + 5, button->bounds.right - 5, button->bounds.bottom - 5); @@ -115,21 +122,21 @@ void Dialog::paint() { } int w = _font->getStringWidth(button->text); int x = button->bounds.left + (button->bounds.width() - w) / 2; - int y = button->bounds.top + 19; + int y = button->bounds.top + 6; - _font->drawString(&_gui->_screen, button->text, _bbox.left + x, _bbox.right + y, _bbox.width(), color); + _font->drawString(&_gui->_screen, button->text, x, y, _bbox.width(), color); drawOutline(button->bounds, buttonOutline, ARRAYSIZE(buttonOutline)); } g_system->copyRectToScreen(_gui->_screen.getBasePtr(_bbox.left, _bbox.top), _gui->_screen.pitch, - _bbox.left, _bbox.top, _bbox.width(), _bbox.height()); + _bbox.left, _bbox.top, _bbox.width() + 1, _bbox.height() + 1); } void Dialog::drawOutline(Common::Rect &bounds, int *spec, int speclen) { for (int i = 0; i < speclen; i++) if (spec[i] != 0) - Design::drawRect(&_gui->_screen, bounds.left + i, bounds.top + i, bounds.right - 1 - 2*i, bounds.bottom - 1 - 2*i, + Design::drawRect(&_gui->_screen, bounds.left + i, bounds.top + i, bounds.right - i, bounds.bottom - i, 1, kColorBlack, _gui->_patterns, kPatternSolid); } diff --git a/engines/wage/dialog.h b/engines/wage/dialog.h index 7983417b47..6e972e252b 100644 --- a/engines/wage/dialog.h +++ b/engines/wage/dialog.h @@ -54,12 +54,12 @@ struct DialogButton { Common::String text; Common::Rect bounds; - DialogButton(const char *t, int x1, int y1, int x2, int y2) { + DialogButton(const char *t, int x1, int y1, int w, int h) { text = t; bounds.left = x1; bounds.top = y1; - bounds.right = x2; - bounds.bottom = y2; + bounds.right = x1 + w - 1; + bounds.bottom = y1 + h - 1; } }; @@ -80,8 +80,8 @@ private: const Graphics::Font *_font; DialogButtonArray *_buttons; - DialogButton *_pressedButton; - DialogButton *_defaultButton; + int _pressedButton; + int _defaultButton; bool _mouseOverPressedButton; private: diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp index b8d0977853..9cb3a01739 100644 --- a/engines/wage/wage.cpp +++ b/engines/wage/wage.cpp @@ -140,7 +140,6 @@ void WageEngine::processEvents() { while (_eventMan->pollEvent(event)) { switch (event.type) { case Common::EVENT_QUIT: - gameOver(); _shouldQuit = true; break; case Common::EVENT_MOUSEMOVE: @@ -221,7 +220,7 @@ void WageEngine::appendText(char *str) { void WageEngine::gameOver() { DialogButtonArray buttons; - buttons.push_back(new DialogButton("OK", 112, 67, 68, 28)); + buttons.push_back(new DialogButton("OK", 66, 67, 68, 28)); Dialog gameOver(_gui, _world->_gameOverMessage->c_str(), &buttons); -- cgit v1.2.3