diff options
author | Eugene Sandulenko | 2016-01-19 18:16:36 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2016-02-14 17:12:48 +0100 |
commit | 876036230246418aa86711d33f485f5c83e769c4 (patch) | |
tree | 1b1efd0bd087b4496c741691244e30254deba8fd /engines/wage | |
parent | 5f5280d8cf1df16177f3920e6011401e8bff00a6 (diff) | |
download | scummvm-rg350-876036230246418aa86711d33f485f5c83e769c4.tar.gz scummvm-rg350-876036230246418aa86711d33f485f5c83e769c4.tar.bz2 scummvm-rg350-876036230246418aa86711d33f485f5c83e769c4.zip |
WAGE: Draw dialog
Diffstat (limited to 'engines/wage')
-rw-r--r-- | engines/wage/design.cpp | 8 | ||||
-rw-r--r-- | engines/wage/design.h | 1 | ||||
-rw-r--r-- | engines/wage/dialog.cpp | 67 | ||||
-rw-r--r-- | engines/wage/dialog.h | 17 |
4 files changed, 86 insertions, 7 deletions
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp index 3db9d27f4c..8e5c753321 100644 --- a/engines/wage/design.cpp +++ b/engines/wage/design.cpp @@ -443,11 +443,11 @@ void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in) { } void Design::drawRect(Graphics::Surface *surface, Common::Rect &rect, int thickness, int color, Patterns &patterns, byte fillType) { + drawRect(surface, rect.left, rect.top, rect.right, rect.bottom, thickness, color, patterns, fillType); +} + +void Design::drawRect(Graphics::Surface *surface, int x1, int y1, int x2, int y2, int thickness, int color, Patterns &patterns, byte fillType) { plotData pd(surface, &patterns, fillType, thickness); - int x1 = rect.left; - int y1 = rect.top; - int x2 = rect.right; - int y2 = rect.bottom; Graphics::drawLine(x1, y1, x2, y1, kColorBlack, drawPixel, &pd); Graphics::drawLine(x2, y1, x2, y2, kColorBlack, drawPixel, &pd); diff --git a/engines/wage/design.h b/engines/wage/design.h index 26f832e767..d98d30ce93 100644 --- a/engines/wage/design.h +++ b/engines/wage/design.h @@ -70,6 +70,7 @@ public: void paint(Graphics::Surface *canvas, Patterns &patterns, int x, int y); bool isPointOpaque(int x, int y); static void drawRect(Graphics::Surface *surface, Common::Rect &rect, int thickness, int color, Patterns &patterns, byte fillType); + static void drawRect(Graphics::Surface *surface, int x1, int y1, int x2, int y2, int thickness, int color, Patterns &patterns, byte fillType); static void drawFilledRect(Graphics::Surface *surface, Common::Rect &rect, int color, Patterns &patterns, byte fillType); static void drawFilledRoundRect(Graphics::Surface *surface, Common::Rect &rect, int arc, int color, Patterns &patterns, byte fillType); static void drawHLine(Graphics::Surface *surface, int x1, int x2, int y, int thickness, int color, Patterns &patterns, byte fillType); diff --git a/engines/wage/dialog.cpp b/engines/wage/dialog.cpp index 665bf52d3b..eb29f80cff 100644 --- a/engines/wage/dialog.cpp +++ b/engines/wage/dialog.cpp @@ -48,18 +48,34 @@ #include "common/system.h" #include "wage/wage.h" +#include "wage/design.h" #include "wage/gui.h" #include "wage/dialog.h" namespace Wage { -Dialog::Dialog(Gui *gui) : _gui(gui) { +enum { + kDialogWidth = 292, + kDialogHeight = 114 +}; + +Dialog::Dialog(Gui *gui, const char *text, DialogButtonArray *buttons) : _gui(gui), _text(text), _buttons(buttons) { assert(_gui->_engine); assert(_gui->_engine->_world); _font = getDialogFont(); - _tempSurface.create(_gui->_screen.w, _font->getFontHeight(), Graphics::PixelFormat::createFormatCLUT8()); + _tempSurface.create(kDialogWidth, kDialogHeight, Graphics::PixelFormat::createFormatCLUT8()); + + _bbox.left = (_gui->_screen.w - kDialogWidth) / 2; + _bbox.top = (_gui->_screen.h - kDialogHeight) / 2; + _bbox.right = (_gui->_screen.w + kDialogWidth) / 2; + _bbox.bottom = (_gui->_screen.h + kDialogHeight) / 2; + + _defaultButton = NULL; + _pressedButton = NULL; + + _mouseOverPressedButton = false; } Dialog::~Dialog() { @@ -69,4 +85,51 @@ const Graphics::Font *Dialog::getDialogFont() { return _gui->getFont("Chicago-12", Graphics::FontManager::kBigGUIFont); } +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); + + static int boxOutline[] = { 1, 0, 0, 1, 1 }; + drawOutline(_bbox, boxOutline, ARRAYSIZE(boxOutline)); + + for (int i = 0; i < _buttons->size(); i++) { + DialogButton *button = _buttons->operator[](i); + static int buttonOutline[] = { 0, 0, 0, 0, 1 }; + + if (button == _defaultButton) { + buttonOutline[0] = buttonOutline[1] = 1; + } else { + buttonOutline[0] = buttonOutline[1] = 0; + } + + int color = kColorBlack; + + if (_pressedButton == button && _mouseOverPressedButton) { + Common::Rect bb(button->bounds.left + 5, button->bounds.top + 5, + button->bounds.right - 5, button->bounds.bottom - 5); + + Design::drawFilledRect(&_gui->_screen, bb, kColorBlack, _gui->_patterns, kPatternSolid); + + color = kColorWhite; + } + int w = _font->getStringWidth(button->text); + int x = button->bounds.left + (button->bounds.width() - w) / 2; + int y = button->bounds.top + 19; + + _font->drawString(&_gui->_screen, button->text, _bbox.left + x, _bbox.right + 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()); +} + +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, + 1, kColorBlack, _gui->_patterns, kPatternSolid); +} + } // End of namespace Wage diff --git a/engines/wage/dialog.h b/engines/wage/dialog.h index 63f7dedf61..747d9dea05 100644 --- a/engines/wage/dialog.h +++ b/engines/wage/dialog.h @@ -50,19 +50,34 @@ namespace Wage { +struct DialogButton { + Common::String text; + Common::Rect bounds; +}; + +typedef Common::Array<DialogButton *> DialogButtonArray; + class Dialog { public: - Dialog(Gui *gui); + Dialog(Gui *gui, const char *text, DialogButtonArray *buttons); ~Dialog(); private: Gui *_gui; Graphics::Surface _tempSurface; + Common::Rect _bbox; + Common::String _text; const Graphics::Font *_font; + DialogButtonArray *_buttons; + DialogButton *_pressedButton; + DialogButton *_defaultButton; + bool _mouseOverPressedButton; private: const Graphics::Font *getDialogFont(); + void drawOutline(Common::Rect &bounds, int *spec, int speclen); + void paint(); }; } // End of namespace Wage |