AVALANCHE: move some more functions to Graphics

This commit is contained in:
Strangerke 2013-09-29 12:13:06 +02:00
parent 1af03774cc
commit ffbe4646c1
5 changed files with 67 additions and 52 deletions

View file

@ -65,9 +65,7 @@ void Dialogs::setReadyLight(byte state) { // Sets "Ready" light to whatever
warning("STUB: Scrolls::state()"); warning("STUB: Scrolls::state()");
CursorMan.showMouse(false); CursorMan.showMouse(false);
_vm->_graphics->drawReadyLight(color);
_vm->_graphics->_surface.fillRect(Common::Rect(419, 195, 438, 197), color);
CursorMan.showMouse(true); CursorMan.showMouse(true);
_vm->_ledStatus = state; _vm->_ledStatus = state;
} }
@ -117,9 +115,8 @@ void Dialogs::scrollModeNormal() {
_vm->_seeScroll = true; _vm->_seeScroll = true;
_vm->_graphics->loadMouse(kCurFletch); _vm->_graphics->loadMouse(kCurFletch);
::Graphics::Surface temp; _vm->_graphics->saveScreen();
temp.copyFrom(_vm->_graphics->_surface); _vm->_graphics->showScroll();
_vm->_graphics->_surface.copyFrom(_vm->_graphics->_scrolls); // TODO: Rework it using getSubArea !!!!!!!
Common::Event event; Common::Event event;
while (!_vm->shouldQuit()) { while (!_vm->shouldQuit()) {
@ -134,8 +131,8 @@ void Dialogs::scrollModeNormal() {
break; break;
} }
_vm->_graphics->_surface.copyFrom(temp); _vm->_graphics->restoreScreen();
temp.free(); _vm->_graphics->removeBackup();
warning("STUB: scrollModeNormal() - Check Easter Egg trigger"); warning("STUB: scrollModeNormal() - Check Easter Egg trigger");
#if 0 #if 0
@ -184,9 +181,8 @@ void Dialogs::scrollModeDialogue() {
_vm->_graphics->loadMouse(kCurHand); _vm->_graphics->loadMouse(kCurHand);
::Graphics::Surface temp; _vm->_graphics->saveScreen();
temp.copyFrom(_vm->_graphics->_surface); _vm->_graphics->showScroll();
_vm->_graphics->_surface.copyFrom(_vm->_graphics->_scrolls); // TODO: Rework it using getSubArea !!!!!!!
Common::Event event; Common::Event event;
while (!_vm->shouldQuit()) { while (!_vm->shouldQuit()) {
@ -206,8 +202,8 @@ void Dialogs::scrollModeDialogue() {
} }
} }
_vm->_graphics->_surface.copyFrom(temp); _vm->_graphics->restoreScreen();
temp.free(); _vm->_graphics->removeBackup();
} }
void Dialogs::store(byte what, TuneType &played) { void Dialogs::store(byte what, TuneType &played) {
@ -239,9 +235,8 @@ void Dialogs::scrollModeMusic() {
_vm->_seeScroll = true; _vm->_seeScroll = true;
::Graphics::Surface temp; _vm->_graphics->saveScreen();
temp.copyFrom(_vm->_graphics->_surface); _vm->_graphics->showScroll();
_vm->_graphics->_surface.copyFrom(_vm->_graphics->_scrolls); // TODO: Rework it using getSubArea !!!!!!!
Common::Event event; Common::Event event;
while (!_vm->shouldQuit()) { while (!_vm->shouldQuit()) {
@ -328,8 +323,9 @@ void Dialogs::scrollModeMusic() {
} }
} }
_vm->_graphics->_surface.copyFrom(temp); _vm->_graphics->restoreScreen();
temp.free(); _vm->_graphics->removeBackup();
_vm->_seeScroll = false; _vm->_seeScroll = false;
CursorMan.showMouse(true); CursorMan.showMouse(true);
} }
@ -512,6 +508,7 @@ void Dialogs::drawBubble(DialogFunctionType modeFunc) {
if ((_vm->_talkX + xw) > 639) if ((_vm->_talkX + xw) > 639)
xc = 639 - (_vm->_talkX + xw); xc = 639 - (_vm->_talkX + xw);
// Compute triangle coords for the tail of the bubble
points[0].x = _vm->_talkX - 10; points[0].x = _vm->_talkX - 10;
points[0].y = yw; points[0].y = yw;
points[1].x = _vm->_talkX + 10; points[1].x = _vm->_talkX + 10;
@ -519,25 +516,7 @@ void Dialogs::drawBubble(DialogFunctionType modeFunc) {
points[2].x = _vm->_talkX; points[2].x = _vm->_talkX;
points[2].y = _vm->_talkY; points[2].y = _vm->_talkY;
// Backup the screen before drawing the bubble. _vm->_graphics->prepareBubble(xc, xw, my, points);
_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);
// Draw the text of the bubble. The centering of the text was improved here compared to Pascal's settextjustify(). // 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. // The font is not the same that outtextxy() uses in Pascal. I don't have that, so I used characters instead.

View file

@ -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) { 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) { 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) { 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; byte returnColor = 0;
for (int16 i = x1; i <= x2; i++) { for (int16 i = x1; i <= x2; i++) {
for (int16 j = y1; j <= y2; j++) { 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); 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() { void Graphics::refreshScreen() {
// These cycles are for doubling the screen height. // These cycles are for doubling the screen height.
for (uint16 y = 0; y < _screen.h / 2; y++) { for (uint16 y = 0; y < _screen.h / 2; y++) {
@ -548,9 +580,8 @@ void Graphics::zoomOut(int16 x, int16 y) {
removeBackup(); removeBackup();
} }
// Original name background() void Graphics::showScroll() {
void Graphics::setBackgroundColor(Color x) { _surface.copyFrom(_scrolls); // TODO: Rework it using getSubArea !!!!!!!
warning("STUB: setBackgroundColor(%d)", x);
} }
void Graphics::saveScreen() { void Graphics::saveScreen() {
@ -565,4 +596,10 @@ void Graphics::restoreScreen() {
_surface.copyFrom(_backup); _surface.copyFrom(_backup);
refreshScreen(); refreshScreen();
} }
// Original name background()
void Graphics::setBackgroundColor(Color x) {
warning("STUB: setBackgroundColor(%d)", x);
}
} // End of namespace Avalanche } // End of namespace Avalanche

View file

@ -98,6 +98,10 @@ public:
void drawThinkPic(Common::String filename, int id); void drawThinkPic(Common::String filename, int id);
void drawToolbar(); 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 refreshScreen();
void loadBackground(Common::File &file); void loadBackground(Common::File &file);
@ -106,6 +110,8 @@ public:
void zoomOut(int16 x, int16 y); // Only used when entering the map. void zoomOut(int16 x, int16 y); // Only used when entering the map.
void showScroll();
void saveScreen(); void saveScreen();
void removeBackup(); void removeBackup();
void restoreScreen(); void restoreScreen();

View file

@ -449,14 +449,14 @@ void Parser::plotText() {
void Parser::cursorOn() { void Parser::cursorOn() {
if (_cursorState == true) if (_cursorState == true)
return; return;
drawCursor(); _vm->_graphics->drawCursor(_inputTextPos);
_cursorState = true; _cursorState = true;
} }
void Parser::cursorOff() { void Parser::cursorOff() {
if (_cursorState == false) if (_cursorState == false)
return; return;
drawCursor(); _vm->_graphics->drawCursor(_inputTextPos);
_cursorState = false; _cursorState = false;
} }
@ -471,12 +471,6 @@ int16 Parser::getPos(const Common::String &crit, const Common::String &src) {
return -1; 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() { void Parser::wipeText() {
CursorMan.showMouse(false); CursorMan.showMouse(false);
cursorOff(); cursorOff();

View file

@ -147,7 +147,6 @@ private:
Common::String personSpeaks(); Common::String personSpeaks();
void heyThanks(); void heyThanks();
void drawCursor();
void wipeText(); void wipeText();
}; };