aboutsummaryrefslogtreecommitdiff
path: root/engines/wage/dialog.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2016-01-19 18:16:36 +0100
committerEugene Sandulenko2016-02-14 17:12:48 +0100
commit876036230246418aa86711d33f485f5c83e769c4 (patch)
tree1b1efd0bd087b4496c741691244e30254deba8fd /engines/wage/dialog.cpp
parent5f5280d8cf1df16177f3920e6011401e8bff00a6 (diff)
downloadscummvm-rg350-876036230246418aa86711d33f485f5c83e769c4.tar.gz
scummvm-rg350-876036230246418aa86711d33f485f5c83e769c4.tar.bz2
scummvm-rg350-876036230246418aa86711d33f485f5c83e769c4.zip
WAGE: Draw dialog
Diffstat (limited to 'engines/wage/dialog.cpp')
-rw-r--r--engines/wage/dialog.cpp67
1 files changed, 65 insertions, 2 deletions
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