diff options
Diffstat (limited to 'gui/console.cpp')
-rw-r--r-- | gui/console.cpp | 54 |
1 files changed, 8 insertions, 46 deletions
diff --git a/gui/console.cpp b/gui/console.cpp index 4f43b5a6df..57c374ddef 100644 --- a/gui/console.cpp +++ b/gui/console.cpp @@ -114,10 +114,7 @@ void ConsoleDialog::slideUpAndClose() { } void ConsoleDialog::open() { - // This dialog will be redrawn a lot, so we store a copy of the blended - // background in a separate "canvas", just like in the About dialog. - _canvas.pixels = NULL; - + // TODO: find a new way to do this // Initiate sliding the console down. We do a very simple trick to achieve // this effect: we simply move the console dialog just above (outside) the // visible screen area, then shift it down in handleTickle() over a @@ -135,36 +132,16 @@ void ConsoleDialog::open() { } void ConsoleDialog::close() { - free(_canvas.pixels); Dialog::close(); } void ConsoleDialog::drawDialog() { - if (!_canvas.pixels) { - // Blend over the background. Don't count the time used for - // this when timing the slide action. - - uint32 now = g_system->getMillis(); - uint32 delta; - - g_gui.blendRect(0, 0, _w, _h, g_gui._bgcolor, 2); - g_gui.copyToSurface(&_canvas, 0, 0, _w, _h); - - delta = g_system->getMillis() - now; - - if (_slideTime) - _slideTime += delta; - } - - g_gui.drawSurface(_canvas, 0, 0); - - // Draw a border - g_gui.hLine(_x, _y + _h - 1, _x + _w - 1, g_gui._color); - // Draw text int start = _scrollLine - _linesPerPage + 1; int y = _y + 2; + g_gui.theme()->drawDialogBackground(Common::Rect(_x, _y, _x+_w, _y+_h)); + for (int line = 0; line < _linesPerPage; line++) { int x = _x + 1; for (int column = 0; column < _lineWidth; column++) { @@ -174,7 +151,7 @@ void ConsoleDialog::drawDialog() { #else byte c = buffer((start + line) * _lineWidth + column); #endif - g_gui.drawChar(c, x, y, g_gui._textcolor, _font); + g_gui.theme()->drawChar(Common::Rect(x, y, x+kConsoleCharWidth, y+kConsoleLineHeight), c, _font); x += kConsoleCharWidth; } y += kConsoleLineHeight; @@ -182,21 +159,14 @@ void ConsoleDialog::drawDialog() { // Draw the scrollbar _scrollBar->draw(); - - // Finally blit it all to the screen - g_gui.addDirtyRect(_x, _y, _w, _h); } void ConsoleDialog::handleScreenChanged() { - free(_canvas.pixels); - _canvas.pixels = NULL; + Dialog::handleScreenChanged(); draw(); } void ConsoleDialog::handleTickle() { - if (!_canvas.pixels) - return; - uint32 time = g_system->getMillis(); if (_caretTime < time) { _caretTime = time + kCaretBlinkTime; @@ -219,7 +189,7 @@ void ConsoleDialog::handleTickle() { draw(); } else if (_slideMode == kUpSlideMode && _y <= -_h) { // End the slide - _slideMode = kNoSlideMode; + //_slideMode = kNoSlideMode; close(); } else draw(); @@ -614,6 +584,7 @@ void ConsoleDialog::print(const char *str) { } void ConsoleDialog::drawCaret(bool erase) { + // TODO: use code from EditableWidget::drawCaret here int line = _currentPos / _lineWidth; int displayLine = line - _scrollLine + _linesPerPage - 1; @@ -626,17 +597,8 @@ void ConsoleDialog::drawCaret(bool erase) { int x = _x + 1 + (_currentPos % _lineWidth) * kConsoleCharWidth; int y = _y + displayLine * kConsoleLineHeight; - char c = buffer(_currentPos); - if (erase) { - g_gui.fillRect(x, y, kConsoleCharWidth, kConsoleLineHeight, g_gui._bgcolor); - g_gui.drawChar(c, x, y + 2, g_gui._textcolor, _font); - } else { - g_gui.fillRect(x, y, kConsoleCharWidth, kConsoleLineHeight, g_gui._textcolor); - g_gui.drawChar(c, x, y + 2, g_gui._bgcolor, _font); - } - g_gui.addDirtyRect(x, y, kConsoleCharWidth, kConsoleLineHeight); - _caretVisible = !erase; + g_gui.theme()->drawCaret(Common::Rect(x, y, x+kConsoleCharWidth, y+kConsoleLineHeight), erase); } void ConsoleDialog::scrollToCurrent() { |