aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2013-09-29 12:13:06 +0200
committerStrangerke2013-09-29 12:13:06 +0200
commitffbe4646c16b7620040c6b63d20779d5fa50bd6b (patch)
tree8eb7074e4e5139c4717aaee1be52679af02c9121
parent1af03774ccda57e153b3d3664613818645f5f4ff (diff)
downloadscummvm-rg350-ffbe4646c16b7620040c6b63d20779d5fa50bd6b.tar.gz
scummvm-rg350-ffbe4646c16b7620040c6b63d20779d5fa50bd6b.tar.bz2
scummvm-rg350-ffbe4646c16b7620040c6b63d20779d5fa50bd6b.zip
AVALANCHE: move some more functions to Graphics
-rw-r--r--engines/avalanche/dialogs.cpp53
-rw-r--r--engines/avalanche/graphics.cpp49
-rw-r--r--engines/avalanche/graphics.h6
-rw-r--r--engines/avalanche/parser.cpp10
-rw-r--r--engines/avalanche/parser.h1
5 files changed, 67 insertions, 52 deletions
diff --git a/engines/avalanche/dialogs.cpp b/engines/avalanche/dialogs.cpp
index d2c413163b..9868c772e1 100644
--- a/engines/avalanche/dialogs.cpp
+++ b/engines/avalanche/dialogs.cpp
@@ -65,9 +65,7 @@ void Dialogs::setReadyLight(byte state) { // Sets "Ready" light to whatever
warning("STUB: Scrolls::state()");
CursorMan.showMouse(false);
-
- _vm->_graphics->_surface.fillRect(Common::Rect(419, 195, 438, 197), color);
-
+ _vm->_graphics->drawReadyLight(color);
CursorMan.showMouse(true);
_vm->_ledStatus = state;
}
@@ -117,9 +115,8 @@ void Dialogs::scrollModeNormal() {
_vm->_seeScroll = true;
_vm->_graphics->loadMouse(kCurFletch);
- ::Graphics::Surface temp;
- temp.copyFrom(_vm->_graphics->_surface);
- _vm->_graphics->_surface.copyFrom(_vm->_graphics->_scrolls); // TODO: Rework it using getSubArea !!!!!!!
+ _vm->_graphics->saveScreen();
+ _vm->_graphics->showScroll();
Common::Event event;
while (!_vm->shouldQuit()) {
@@ -134,8 +131,8 @@ void Dialogs::scrollModeNormal() {
break;
}
- _vm->_graphics->_surface.copyFrom(temp);
- temp.free();
+ _vm->_graphics->restoreScreen();
+ _vm->_graphics->removeBackup();
warning("STUB: scrollModeNormal() - Check Easter Egg trigger");
#if 0
@@ -184,9 +181,8 @@ void Dialogs::scrollModeDialogue() {
_vm->_graphics->loadMouse(kCurHand);
- ::Graphics::Surface temp;
- temp.copyFrom(_vm->_graphics->_surface);
- _vm->_graphics->_surface.copyFrom(_vm->_graphics->_scrolls); // TODO: Rework it using getSubArea !!!!!!!
+ _vm->_graphics->saveScreen();
+ _vm->_graphics->showScroll();
Common::Event event;
while (!_vm->shouldQuit()) {
@@ -206,8 +202,8 @@ void Dialogs::scrollModeDialogue() {
}
}
- _vm->_graphics->_surface.copyFrom(temp);
- temp.free();
+ _vm->_graphics->restoreScreen();
+ _vm->_graphics->removeBackup();
}
void Dialogs::store(byte what, TuneType &played) {
@@ -239,9 +235,8 @@ void Dialogs::scrollModeMusic() {
_vm->_seeScroll = true;
- ::Graphics::Surface temp;
- temp.copyFrom(_vm->_graphics->_surface);
- _vm->_graphics->_surface.copyFrom(_vm->_graphics->_scrolls); // TODO: Rework it using getSubArea !!!!!!!
+ _vm->_graphics->saveScreen();
+ _vm->_graphics->showScroll();
Common::Event event;
while (!_vm->shouldQuit()) {
@@ -328,8 +323,9 @@ void Dialogs::scrollModeMusic() {
}
}
- _vm->_graphics->_surface.copyFrom(temp);
- temp.free();
+ _vm->_graphics->restoreScreen();
+ _vm->_graphics->removeBackup();
+
_vm->_seeScroll = false;
CursorMan.showMouse(true);
}
@@ -512,6 +508,7 @@ void Dialogs::drawBubble(DialogFunctionType modeFunc) {
if ((_vm->_talkX + xw) > 639)
xc = 639 - (_vm->_talkX + xw);
+ // Compute triangle coords for the tail of the bubble
points[0].x = _vm->_talkX - 10;
points[0].y = yw;
points[1].x = _vm->_talkX + 10;
@@ -519,25 +516,7 @@ void Dialogs::drawBubble(DialogFunctionType modeFunc) {
points[2].x = _vm->_talkX;
points[2].y = _vm->_talkY;
- // Backup the screen before drawing the bubble.
- _vm->_graphics->_scrolls.copyFrom(_vm->_graphics->_surface);
-
- // The body of the bubble.
- _vm->_graphics->_scrolls.fillRect(Common::Rect(xc + _vm->_talkX - xw + 9, 7, _vm->_talkX + xw - 8 + xc, my + 1), _vm->_talkBackgroundColor);
- _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(xc + _vm->_talkX + xw - 10, 11, 0, 90, 9, _vm->_talkBackgroundColor);
- // Bottom right corner of the bubble.
- _vm->_graphics->drawPieSlice(xc + _vm->_talkX + xw - 10, my - 4, 270, 360, 9, _vm->_talkBackgroundColor);
- // Top left corner of the bubble.
- _vm->_graphics->drawPieSlice(xc + _vm->_talkX - xw + 10, 11, 90, 180, 9, _vm->_talkBackgroundColor);
- // Bottom left corner of the bubble.
- _vm->_graphics->drawPieSlice(xc + _vm->_talkX - xw + 10, my - 4, 180, 270, 9, _vm->_talkBackgroundColor);
-
- // "Tail" of the speech bubble.
- _vm->_graphics->drawTriangle(points, _vm->_talkBackgroundColor);
-
+ _vm->_graphics->prepareBubble(xc, xw, my, points);
// Draw the text of the bubble. The centering of the text was improved here compared to Pascal's settextjustify().
// The font is not the same that outtextxy() uses in Pascal. I don't have that, so I used characters instead.
diff --git a/engines/avalanche/graphics.cpp b/engines/avalanche/graphics.cpp
index 2d0a45eaa0..f39cd6acc3 100644
--- a/engines/avalanche/graphics.cpp
+++ b/engines/avalanche/graphics.cpp
@@ -325,11 +325,11 @@ 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);
+ 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);
+ drawText(_scrolls, text, font, fontHeight, x, y, color);
}
void Graphics::drawDigit(int index, int x, int y) {
@@ -467,7 +467,7 @@ byte Graphics::getAlsoColor(int x1, int y1, int x2, int y2) {
byte returnColor = 0;
for (int16 i = x1; i <= x2; i++) {
for (int16 j = y1; j <= y2; j++) {
- byte actColor = *(byte *)_vm->_graphics->_magics.getBasePtr(i, j);
+ byte actColor = *(byte *)_magics.getBasePtr(i, j);
returnColor = MAX(returnColor, actColor);
}
}
@@ -508,6 +508,38 @@ void Graphics::drawPicture(::Graphics::Surface &target, const ::Graphics::Surfac
}
}
+void Graphics::drawCursor(byte pos) {
+ int pixPos = 24 + (pos * 8);
+ // Draw the '_' character.
+ for (int i = 0; i < 8; i++)
+ *(byte *)_surface.getBasePtr(pixPos + i, 168) = kColorWhite;
+}
+
+void Graphics::drawReadyLight(Color color) {
+ _surface.fillRect(Common::Rect(419, 195, 438, 197), color);
+}
+
+void Graphics::prepareBubble(int xc, int xw, int my, Common::Point points[3]) {
+ // Backup the screen before drawing the bubble.
+ _scrolls.copyFrom(_surface);
+
+ // The body of the bubble.
+ _scrolls.fillRect(Common::Rect(xc + _vm->_talkX - xw + 9, 7, _vm->_talkX + xw - 8 + xc, my + 1), _vm->_talkBackgroundColor);
+ _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.
+ drawPieSlice(xc + _vm->_talkX + xw - 10, 11, 0, 90, 9, _vm->_talkBackgroundColor);
+ // Bottom right corner of the bubble.
+ drawPieSlice(xc + _vm->_talkX + xw - 10, my - 4, 270, 360, 9, _vm->_talkBackgroundColor);
+ // Top left corner of the bubble.
+ drawPieSlice(xc + _vm->_talkX - xw + 10, 11, 90, 180, 9, _vm->_talkBackgroundColor);
+ // Bottom left corner of the bubble.
+ drawPieSlice(xc + _vm->_talkX - xw + 10, my - 4, 180, 270, 9, _vm->_talkBackgroundColor);
+
+ // "Tail" of the speech bubble.
+ drawTriangle(points, _vm->_talkBackgroundColor);
+}
+
void Graphics::refreshScreen() {
// These cycles are for doubling the screen height.
for (uint16 y = 0; y < _screen.h / 2; y++) {
@@ -548,9 +580,8 @@ void Graphics::zoomOut(int16 x, int16 y) {
removeBackup();
}
-// Original name background()
-void Graphics::setBackgroundColor(Color x) {
- warning("STUB: setBackgroundColor(%d)", x);
+void Graphics::showScroll() {
+ _surface.copyFrom(_scrolls); // TODO: Rework it using getSubArea !!!!!!!
}
void Graphics::saveScreen() {
@@ -565,4 +596,10 @@ void Graphics::restoreScreen() {
_surface.copyFrom(_backup);
refreshScreen();
}
+
+// Original name background()
+void Graphics::setBackgroundColor(Color x) {
+ warning("STUB: setBackgroundColor(%d)", x);
+}
+
} // End of namespace Avalanche
diff --git a/engines/avalanche/graphics.h b/engines/avalanche/graphics.h
index c6f1f6059e..fbedf4c4d8 100644
--- a/engines/avalanche/graphics.h
+++ b/engines/avalanche/graphics.h
@@ -98,6 +98,10 @@ public:
void drawThinkPic(Common::String filename, int id);
void drawToolbar();
+ void drawCursor(byte pos);
+ void drawReadyLight(Color color);
+
+ void prepareBubble(int xc, int xw, int my, Common::Point points[3]);
void refreshScreen();
void loadBackground(Common::File &file);
@@ -106,6 +110,8 @@ public:
void zoomOut(int16 x, int16 y); // Only used when entering the map.
+ void showScroll();
+
void saveScreen();
void removeBackup();
void restoreScreen();
diff --git a/engines/avalanche/parser.cpp b/engines/avalanche/parser.cpp
index 8d01996800..f2bea80c26 100644
--- a/engines/avalanche/parser.cpp
+++ b/engines/avalanche/parser.cpp
@@ -449,14 +449,14 @@ void Parser::plotText() {
void Parser::cursorOn() {
if (_cursorState == true)
return;
- drawCursor();
+ _vm->_graphics->drawCursor(_inputTextPos);
_cursorState = true;
}
void Parser::cursorOff() {
if (_cursorState == false)
return;
- drawCursor();
+ _vm->_graphics->drawCursor(_inputTextPos);
_cursorState = false;
}
@@ -471,12 +471,6 @@ int16 Parser::getPos(const Common::String &crit, const Common::String &src) {
return -1;
}
-void Parser::drawCursor() {
- // Draw the '_' character.
- for (int bit = 0; bit < 8; bit++)
- *(byte *)_vm->_graphics->_surface.getBasePtr(24 + _inputTextPos * 8 + 7 - bit, 168) = kColorWhite;
-}
-
void Parser::wipeText() {
CursorMan.showMouse(false);
cursorOff();
diff --git a/engines/avalanche/parser.h b/engines/avalanche/parser.h
index 4d5889388c..f7d3eb1d3c 100644
--- a/engines/avalanche/parser.h
+++ b/engines/avalanche/parser.h
@@ -147,7 +147,6 @@ private:
Common::String personSpeaks();
void heyThanks();
- void drawCursor();
void wipeText();
};