diff options
author | Strangerke | 2013-09-28 15:08:41 +0200 |
---|---|---|
committer | Strangerke | 2013-09-28 15:08:41 +0200 |
commit | 6a7326ec26b4882061a17cf399fa2f685c3d776e (patch) | |
tree | 69922d50b87272f69dd9af533e55e7453e8baa11 /engines | |
parent | 0edb0e0434359d5ced78fa4f0a32ed1dafc51103 (diff) | |
download | scummvm-rg350-6a7326ec26b4882061a17cf399fa2f685c3d776e.tar.gz scummvm-rg350-6a7326ec26b4882061a17cf399fa2f685c3d776e.tar.bz2 scummvm-rg350-6a7326ec26b4882061a17cf399fa2f685c3d776e.zip |
AVALANCHE: More rework on Graphic code
Diffstat (limited to 'engines')
-rw-r--r-- | engines/avalanche/avalot.cpp | 4 | ||||
-rw-r--r-- | engines/avalanche/dialogs.cpp | 50 | ||||
-rw-r--r-- | engines/avalanche/dialogs.h | 2 | ||||
-rw-r--r-- | engines/avalanche/graphics.cpp | 48 | ||||
-rw-r--r-- | engines/avalanche/graphics.h | 15 | ||||
-rw-r--r-- | engines/avalanche/menu.cpp | 2 | ||||
-rw-r--r-- | engines/avalanche/parser.cpp | 4 |
7 files changed, 70 insertions, 55 deletions
diff --git a/engines/avalanche/avalot.cpp b/engines/avalanche/avalot.cpp index 7527bb6371..6622a8d4e8 100644 --- a/engines/avalanche/avalot.cpp +++ b/engines/avalanche/avalot.cpp @@ -548,14 +548,14 @@ void AvalancheEngine::loadAlso(byte num) { for (int i = 0; i < size; i++) _listen += file.readByte(); - _graphics->prepareAlsoDisplay(); + _graphics->clearAlso(); CursorMan.showMouse(false); for (int i = 0; i < _lineNum; i++) { // We had to check if the lines are within the borders of the screen. if ((_lines[i]._x1 >= 0) && (_lines[i]._x1 < kScreenWidth) && (_lines[i]._y1 >= 0) && (_lines[i]._y1 < kScreenHeight) && (_lines[i]._x2 >= 0) && (_lines[i]._x2 < kScreenWidth) && (_lines[i]._y2 >= 0) && (_lines[i]._y2 < kScreenHeight)) - _graphics->drawAlsoLines(_lines[i]._x1, _lines[i]._y1, _lines[i]._x2, _lines[i]._y2, _lines[i]._color); + _graphics->setAlsoLine(_lines[i]._x1, _lines[i]._y1, _lines[i]._x2, _lines[i]._y2, _lines[i]._color); } CursorMan.showMouse(true); diff --git a/engines/avalanche/dialogs.cpp b/engines/avalanche/dialogs.cpp index 32bf369068..9367c072c2 100644 --- a/engines/avalanche/dialogs.cpp +++ b/engines/avalanche/dialogs.cpp @@ -99,7 +99,7 @@ void Dialogs::say(int16 x, int16 y, Common::String z) { // We have to draw the characters one-by-one because of the accidental font changes. i++; Common::String chr(z[xx]); - _vm->_graphics->drawText(_vm->_graphics->_scrolls, chr, itw, 12, (x - 1) * 8 + offset * 4 + i * 8, y, kColorBlack); + _vm->_graphics->drawScrollText(chr, itw, 12, (x - 1) * 8 + offset * 4 + i * 8, y, kColorBlack); } } } @@ -178,30 +178,6 @@ void Dialogs::scrollModeNormal() { warning("STUB: Scrolls::scrollModeNormal()"); } -void Dialogs::drawShadow(int16 x1, int16 y1, int16 x2, int16 y2) { - for (byte i = 0; i < 2; i ++) { - _vm->_graphics->_scrolls.fillRect(Common::Rect(x1 + i, y1 + i, x1 + i + 1, y2 - i), kColorWhite); - _vm->_graphics->_scrolls.fillRect(Common::Rect(x1 + i, y1 + i, x2 - i, y1 + i + 1), kColorWhite); - - _vm->_graphics->_scrolls.fillRect(Common::Rect(x2 - i, y1 + i, x2 - i + 1, y2 - i + 1), kColorDarkgray); - _vm->_graphics->_scrolls.fillRect(Common::Rect(x1 + i, y2 - i, x2 - i, y2 - i + 1), kColorDarkgray); - } -} - -void Dialogs::drawShadowBox(int16 x1, int16 y1, int16 x2, int16 y2, Common::String text) { - CursorMan.showMouse(false); - - drawShadow(x1, y1, x2, y2); - - bool offset = text.size() % 2; - x1 = (x2 - x1) / 2 + x1 - text.size() / 2 * 8 - offset * 3; - y1 = (y2 - y1) / 2 + y1 - 4; - _vm->_graphics->drawText(_vm->_graphics->_scrolls, text, _vm->_font, 8, x1, y1, kColorBlue); - _vm->_graphics->drawText(_vm->_graphics->_scrolls, Common::String('_'), _vm->_font, 8, x1, y1, kColorBlue); - - CursorMan.showMouse(true); -} - void Dialogs::scrollModeDialogue() { warning("STUB: Scrolls::scrollModeDialogue()"); // It should work with keypresses too! TODO: Implement it! @@ -448,8 +424,8 @@ void Dialogs::drawScroll(DialogFunctionType modeFunc) { CursorMan.showMouse(false); // The right corners of the scroll. - _vm->_graphics->drawPieSlice(_vm->_graphics->_scrolls, mx + lx, my - ly, 0, 90, 15, kColorLightgray); - _vm->_graphics->drawPieSlice(_vm->_graphics->_scrolls, mx + lx, my + ly, 270, 360, 15, kColorLightgray); + _vm->_graphics->drawPieSlice(mx + lx, my - ly, 0, 90, 15, kColorLightgray); + _vm->_graphics->drawPieSlice(mx + lx, my + ly, 270, 360, 15, kColorLightgray); _vm->_graphics->drawArc(_vm->_graphics->_scrolls, mx + lx, my - ly, 0, 90, 15, kColorRed); _vm->_graphics->drawArc(_vm->_graphics->_scrolls, mx + lx, my + ly, 270, 360, 15, kColorRed); @@ -459,10 +435,10 @@ void Dialogs::drawScroll(DialogFunctionType modeFunc) { _vm->_graphics->_scrolls.fillRect(Common::Rect(mx - lx - 15, my - ly, mx + lx + 15, my + ly + 1), kColorLightgray); // The left corners of the scroll. - _vm->_graphics->drawPieSlice(_vm->_graphics->_scrolls, mx - lx - 31, my - ly, 0, 180, 15, kColorDarkgray); + _vm->_graphics->drawPieSlice(mx - lx - 31, my - ly, 0, 180, 15, kColorDarkgray); _vm->_graphics->drawArc(_vm->_graphics->_scrolls, mx - lx - 31, my - ly, 0, 180, 15, kColorRed); _vm->_graphics->_scrolls.drawLine(mx - lx - 31 - 15, my - ly, mx - lx - 31 + 15, my - ly, kColorRed); - _vm->_graphics->drawPieSlice(_vm->_graphics->_scrolls, mx - lx - 31, my + ly, 180, 360, 15, kColorDarkgray); + _vm->_graphics->drawPieSlice(mx - lx - 31, my + ly, 180, 360, 15, kColorDarkgray); _vm->_graphics->drawArc(_vm->_graphics->_scrolls, mx - lx - 31, my + ly, 180, 360, 15, kColorRed); _vm->_graphics->_scrolls.drawLine(mx - lx - 31 - 15, my + ly, mx - lx - 31 + 15, my + ly, kColorRed); @@ -512,8 +488,8 @@ void Dialogs::drawScroll(DialogFunctionType modeFunc) { _shadowBoxX = mx + lx; _shadowBoxY = my + ly; _vm->_scroll[i].setChar(' ', 0); - drawShadowBox(_shadowBoxX - 65, _shadowBoxY - 24, _shadowBoxX - 5, _shadowBoxY - 10, "Yes."); - drawShadowBox(_shadowBoxX + 5, _shadowBoxY - 24, _shadowBoxX + 65, _shadowBoxY - 10, "No."); + _vm->_graphics->drawShadowBox(_shadowBoxX - 65, _shadowBoxY - 24, _shadowBoxX - 5, _shadowBoxY - 10, "Yes."); + _vm->_graphics->drawShadowBox(_shadowBoxX + 5, _shadowBoxY - 24, _shadowBoxX + 65, _shadowBoxY - 10, "No."); break; } @@ -577,16 +553,16 @@ void Dialogs::drawBubble(DialogFunctionType modeFunc) { _vm->_graphics->_scrolls.fillRect(Common::Rect(xc + _vm->_talkX - xw - 1, 12, _vm->_talkX + xw + xc + 2, my - 4), _vm->_talkBackgroundColor); // Top right corner of the bubble. - _vm->_graphics->drawPieSlice(_vm->_graphics->_scrolls, xc + _vm->_talkX + xw - 10, 11, 0, 90, 9, _vm->_talkBackgroundColor); + _vm->_graphics->drawPieSlice(xc + _vm->_talkX + xw - 10, 11, 0, 90, 9, _vm->_talkBackgroundColor); // Bottom right corner of the bubble. - _vm->_graphics->drawPieSlice(_vm->_graphics->_scrolls, xc + _vm->_talkX + xw - 10, my - 4, 270, 360, 9, _vm->_talkBackgroundColor); + _vm->_graphics->drawPieSlice(xc + _vm->_talkX + xw - 10, my - 4, 270, 360, 9, _vm->_talkBackgroundColor); // Top left corner of the bubble. - _vm->_graphics->drawPieSlice(_vm->_graphics->_scrolls, xc + _vm->_talkX - xw + 10, 11, 90, 180, 9, _vm->_talkBackgroundColor); + _vm->_graphics->drawPieSlice(xc + _vm->_talkX - xw + 10, 11, 90, 180, 9, _vm->_talkBackgroundColor); // Bottom left corner of the bubble. - _vm->_graphics->drawPieSlice(_vm->_graphics->_scrolls, xc + _vm->_talkX - xw + 10, my - 4, 180, 270, 9, _vm->_talkBackgroundColor); + _vm->_graphics->drawPieSlice(xc + _vm->_talkX - xw + 10, my - 4, 180, 270, 9, _vm->_talkBackgroundColor); // "Tail" of the speech bubble. - _vm->_graphics->drawTriangle(_vm->_graphics->_scrolls, points, _vm->_talkBackgroundColor); + _vm->_graphics->drawTriangle(points, _vm->_talkBackgroundColor); // Draw the text of the bubble. The centering of the text was improved here compared to Pascal's settextjustify(). @@ -595,7 +571,7 @@ void Dialogs::drawBubble(DialogFunctionType modeFunc) { for (int i = 0; i < _vm->_scrollNum; i++) { int16 x = xc + _vm->_talkX - _vm->_scroll[i].size() / 2 * 8; bool offset = _vm->_scroll[i].size() % 2; - _vm->_graphics->drawText(_vm->_graphics->_scrolls, _vm->_scroll[i], _vm->_font, 8, x - offset * 4, (i * 10) + 12, _vm->_talkFontColor); + _vm->_graphics->drawScrollText(_vm->_scroll[i], _vm->_font, 8, x - offset * 4, (i * 10) + 12, _vm->_talkFontColor); } ringBell(); diff --git a/engines/avalanche/dialogs.h b/engines/avalanche/dialogs.h index 9904ec6b8b..d3088ec35b 100644 --- a/engines/avalanche/dialogs.h +++ b/engines/avalanche/dialogs.h @@ -104,8 +104,6 @@ private: // These 3 "Mode" functions are always passed as ScrollsFunctionType parameters. void scrollModeNormal(); // The "asking" scroll. Used indirectly in diplayQuestion(). - void drawShadow(int16 x1, int16 y1, int16 x2, int16 y2); - void drawShadowBox(int16 x1, int16 y1, int16 x2, int16 y2, Common::String text); void scrollModeDialogue(); // Part of the harp mini-game. void scrollModeMusic(); diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp index 12e43671ee..007c5101f3 100644 --- a/engines/avalanche/graphics.cpp +++ b/engines/avalanche/graphics.cpp @@ -268,12 +268,12 @@ Common::Point Graphics::drawArc(::Graphics::Surface &surface, int16 x, int16 y, return endPoint; } -void Graphics::drawPieSlice(::Graphics::Surface &surface, int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color) { +void Graphics::drawPieSlice(int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color) { while (radius > 0) - drawArc(surface, x, y, stAngle, endAngle, radius--, color); + drawArc(_scrolls, x, y, stAngle, endAngle, radius--, color); } -void Graphics::drawTriangle(::Graphics::Surface &surface, Common::Point *p, Color color) { +void Graphics::drawTriangle(Common::Point *p, Color color) { // Draw the borders with a marking color. _scrolls.drawLine(p[0].x, p[0].y, p[1].x, p[1].y, 255); _scrolls.drawLine(p[1].x, p[1].y, p[2].x, p[2].y, 255); @@ -310,7 +310,7 @@ void Graphics::drawTriangle(::Graphics::Surface &surface, Common::Point *p, Colo _scrolls.drawLine(p[2].x, p[2].y, p[0].x, p[0].y, color); } -void Graphics::drawText(::Graphics::Surface &surface, const Common::String &text, FontType font, byte fontHeight, int16 x, int16 y, Color color) { +void Graphics::drawText(::Graphics::Surface &surface, const Common::String text, FontType font, byte fontHeight, int16 x, int16 y, Color color) { for (uint i = 0; i < text.size(); i++) { for (int j = 0; j < fontHeight; j++) { byte pixel = font[(byte)text[i]][j]; @@ -323,6 +323,14 @@ void Graphics::drawText(::Graphics::Surface &surface, const Common::String &text } } +void Graphics::drawNormalText(const Common::String text, FontType font, byte fontHeight, int16 x, int16 y, Color color) { + _vm->_graphics->drawText(_surface, text, font, fontHeight, x, y, color); +} + +void Graphics::drawScrollText(const Common::String text, FontType font, byte fontHeight, int16 x, int16 y, Color color) { + _vm->_graphics->drawText(_scrolls, text, font, fontHeight, x, y, color); +} + void Graphics::drawDigit(int index, int x, int y) { drawPicture(_surface, _digits[index], x, y); } @@ -331,6 +339,30 @@ void Graphics::drawDirection(int index, int x, int y) { drawPicture(_surface, _directions[index], x, y); } +void Graphics::drawScrollShadow(int16 x1, int16 y1, int16 x2, int16 y2) { + for (byte i = 0; i < 2; i ++) { + _scrolls.fillRect(Common::Rect(x1 + i, y1 + i, x1 + i + 1, y2 - i), kColorWhite); + _scrolls.fillRect(Common::Rect(x1 + i, y1 + i, x2 - i, y1 + i + 1), kColorWhite); + + _scrolls.fillRect(Common::Rect(x2 - i, y1 + i, x2 - i + 1, y2 - i + 1), kColorDarkgray); + _scrolls.fillRect(Common::Rect(x1 + i, y2 - i, x2 - i, y2 - i + 1), kColorDarkgray); + } +} + +void Graphics::drawShadowBox(int16 x1, int16 y1, int16 x2, int16 y2, Common::String text) { + CursorMan.showMouse(false); + + drawScrollShadow(x1, y1, x2, y2); + + bool offset = text.size() % 2; + x1 = (x2 - x1) / 2 + x1 - text.size() / 2 * 8 - offset * 3; + y1 = (y2 - y1) / 2 + y1 - 4; + drawScrollText(text, _vm->_font, 8, x1, y1, kColorBlue); + drawScrollText(Common::String('_'), _vm->_font, 8, x1, y1, kColorBlue); + + CursorMan.showMouse(true); +} + ::Graphics::Surface Graphics::loadPictureGraphic(Common::File &file) { // This function mimics Pascal's getimage(). // The height and the width are stored in 2-2 bytes. We have to add 1 to each because Pascal stores the value of them -1. @@ -379,12 +411,16 @@ void Graphics::drawDirection(int index, int x, int y) { return picture; } -void Graphics::prepareAlsoDisplay() { +void Graphics::clearAlso() { _magics.fillRect(Common::Rect(0, 0, 640, 200), 0); _magics.frameRect(Common::Rect(0, 45, 640, 161), 15); } -void Graphics::drawAlsoLines(int x1, int y1, int x2, int y2, Color color) { +void Graphics::clearTextBar() { + _surface.fillRect(Common::Rect(24, 161, 640, 169), kColorBlack); // Black out the line of the text. +} + +void Graphics::setAlsoLine(int x1, int y1, int x2, int y2, Color color) { _magics.drawLine(x1, y1, x2, y2, color); } diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h index b1b65edf84..de2723115d 100644 --- a/engines/avalanche/graphics.h +++ b/engines/avalanche/graphics.h @@ -73,13 +73,17 @@ public: // TODO: Make it more accurate later. Common::Point drawArc(::Graphics::Surface &surface, int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color); - void drawPieSlice(::Graphics::Surface &surface, int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color); - void drawTriangle(::Graphics::Surface &surface, Common::Point *p, Color color); - void drawText(::Graphics::Surface &surface, const Common::String &text, FontType font, byte fontHeight, int16 x, int16 y, Color color); + void drawPieSlice(int16 x, int16 y, int16 stAngle, int16 endAngle, uint16 radius, Color color); + void drawTriangle(Common::Point *p, Color color); + void drawNormalText(const Common::String text, FontType font, byte fontHeight, int16 x, int16 y, Color color); + void drawScrollText(const Common::String text, FontType font, byte fontHeight, int16 x, int16 y, Color color); void drawDigit(int index, int x, int y); void drawDirection(int index, int x, int y); - void prepareAlsoDisplay(); - void drawAlsoLines(int x1, int y1, int x2, int y2, Color color); + void drawScrollShadow(int16 x1, int16 y1, int16 x2, int16 y2); + void drawShadowBox(int16 x1, int16 y1, int16 x2, int16 y2, Common::String text); + void clearAlso(); + void clearTextBar(); + void setAlsoLine(int x1, int y1, int x2, int y2, Color color); byte getAlsoColor(int x1, int y1, int x2, int y2); // The caller has to .free() the returned Surfaces!!! @@ -114,6 +118,7 @@ private: AvalancheEngine *_vm; ::Graphics::Surface loadPictureGraphic(Common::File &file); // Reads Graphic-planar EGA data. + void drawText(::Graphics::Surface &surface, const Common::String text, FontType font, byte fontHeight, int16 x, int16 y, Color color); }; } // End of namespace Avalanche diff --git a/engines/avalanche/menu.cpp b/engines/avalanche/menu.cpp index 7beacc86b2..24183f8efc 100644 --- a/engines/avalanche/menu.cpp +++ b/engines/avalanche/menu.cpp @@ -317,7 +317,7 @@ void Menu::drawMenuText(int16 x, int16 y, char trigger, Common::String text, boo } } - _vm->_graphics->drawText(_vm->_graphics->_surface, text, font, 8, x * 8, y, fontColor); + _vm->_graphics->drawNormalText(text, font, 8, x * 8, y, fontColor); // Underline the selected character. if ((trigger == 0) || !text.contains(trigger) ) diff --git a/engines/avalanche/parser.cpp b/engines/avalanche/parser.cpp index 95bf535f8c..b86cc636de 100644 --- a/engines/avalanche/parser.cpp +++ b/engines/avalanche/parser.cpp @@ -439,8 +439,8 @@ void Parser::plotText() { CursorMan.showMouse(false); cursorOff(); - _vm->_graphics->_surface.fillRect(Common::Rect(24, 161, 640, 169), kColorBlack); // Black out the line of the text. - _vm->_graphics->drawText(_vm->_graphics->_surface, _inputText, _vm->_font, 8, 24, 161, kColorWhite); + _vm->_graphics->clearTextBar(); + _vm->_graphics->drawNormalText(_inputText, _vm->_font, 8, 24, 161, kColorWhite); cursorOn(); CursorMan.showMouse(true); |