diff options
author | Johannes Schickel | 2006-05-21 15:02:12 +0000 |
---|---|---|
committer | Johannes Schickel | 2006-05-21 15:02:12 +0000 |
commit | 3af8e4ea4ac455d00f0f9da3ad89ba16572cd524 (patch) | |
tree | e15aa2628eb0a63b66081465f765651425aca592 /engines | |
parent | d7296ae6667d0bfde089344c75caba6630757dcb (diff) | |
download | scummvm-rg350-3af8e4ea4ac455d00f0f9da3ad89ba16572cd524.tar.gz scummvm-rg350-3af8e4ea4ac455d00f0f9da3ad89ba16572cd524.tar.bz2 scummvm-rg350-3af8e4ea4ac455d00f0f9da3ad89ba16572cd524.zip |
Implements kyra3 main menu drawing.
svn-id: r22556
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/kyra.h | 3 | ||||
-rw-r--r-- | engines/kyra/kyra3.cpp | 107 | ||||
-rw-r--r-- | engines/kyra/screen.cpp | 19 | ||||
-rw-r--r-- | engines/kyra/screen.h | 4 |
4 files changed, 96 insertions, 37 deletions
diff --git a/engines/kyra/kyra.h b/engines/kyra/kyra.h index 21b85ff5c4..6c03bbeccd 100644 --- a/engines/kyra/kyra.h +++ b/engines/kyra/kyra.h @@ -1044,6 +1044,9 @@ private: static const char *_mainMenuStrings[]; int handleMainMenu(WSAMovieV3 *logo); void drawMainMenu(const char * const *strings, int unk1); + void drawMainBox(int x, int y, int w, int h, int fill); + + void gui_printString(const char *string, int x, int y, int col1, int col2, int flags, ...); }; } // End of namespace Kyra diff --git a/engines/kyra/kyra3.cpp b/engines/kyra/kyra3.cpp index 3f2d2189da..4fc7ca45b3 100644 --- a/engines/kyra/kyra3.cpp +++ b/engines/kyra/kyra3.cpp @@ -116,6 +116,27 @@ int KyraEngine_v3::go() { return 0; } +void KyraEngine_v3::playVQA(const char *filename) { + VQAMovie vqa(this, _system); + + uint8 pal[768]; + memcpy(pal, _screen->_currentPalette, sizeof(pal)); + if (_screen->_curPage == 0) + _screen->copyCurPageBlock(0, 0, 320, 200, _screen->getPagePtr(3)); + + vqa.open(filename, 0, NULL); + if (vqa.opened()) { + vqa.setX(0); vqa.setY(0); + vqa.setDrawPage(0); + vqa.play(); + vqa.close(); + } + + if (_screen->_curPage == 0) + _screen->copyBlockToPage(0, 0, 0, 320, 200, _screen->getPagePtr(3)); + _screen->setScreenPalette(pal); +} + void KyraEngine_v3::playMenuAudioFile() { if (_soundDigital->isPlaying(_musicSoundChannel)) return; @@ -131,6 +152,10 @@ void KyraEngine_v3::playMenuAudioFile() { int KyraEngine_v3::handleMainMenu(WSAMovieV3 *logo) { int command = -1; + uint8 colorMap[16]; + memset(colorMap, 0, sizeof(colorMap)); + _screen->setTextColorMap(colorMap); + const char * const *strings = &_mainMenuStrings[/*_lang*4*/0]; Screen::FontId oldFont = _screen->setFont(Screen::FID_8_FNT); int charWidthBackUp = _screen->_charWidth; @@ -138,14 +163,13 @@ int KyraEngine_v3::handleMainMenu(WSAMovieV3 *logo) { _screen->setScreenDim(3); _screen->copyCurPageBlock(_screen->_curDim->sx, _screen->_curDim->sy, _screen->_curDim->w, _screen->_curDim->h, _screen->getPagePtr(3)); -// int left = _screen->_curDim->sx << 3; -// int top = _screen->_curDim->sy; -// int right = left + (_screen->_curDim->w << 3); -// int bottom = top + _screen->_curDim->h; + int x = _screen->_curDim->sx << 3; + int y = _screen->_curDim->sy; + int width = _screen->_curDim->w << 3; + int height = _screen->_curDim->h; - // XXX - // gui_unk1(left, top, right, bottom, 1, 0); - // gui_unk1(left + 1, top + 1, right - 1, bottom - 1, 0, 0); + drawMainBox(x, y, width, height, 1); + drawMainBox(x + 1, y + 1, width - 2, height - 2, 0); int curFrame = 29, frameAdd = 1; uint32 nextRun = 0; @@ -191,40 +215,59 @@ int KyraEngine_v3::handleMainMenu(WSAMovieV3 *logo) { } void KyraEngine_v3::drawMainMenu(const char * const *strings, int unk1) { -#if 0 - static const uint16 _menuTable[] = { 0x01, 0x04, 0x0C, 0x04, 0x00, 0xFF, 0x00, 0x01, 0x02, 0x03 }; + static const uint16 menuTable[] = { 0x01, 0x04, 0x0C, 0x04, 0x00, 0x80, 0xFF, 0x00, 0x01, 0x02, 0x03 }; - int left = _screen->_curDim->sx << 3; int top = _screen->_curDim->sy; - int width = _screen->_curDim->w << 3; int height = _screen->_curDim->h; + int top = _screen->_curDim->sy; + top += menuTable[1]; - top += _menuTable[1]; - - for (int i = 0; i < _menuTable[3]; ++i) { + for (int i = 0; i < menuTable[3]; ++i) { int curY = top + i * _screen->getFontHeight(); - // XXX + gui_printString(strings[i], ((_screen->_curDim->w >> 1) + _screen->_curDim->sx) << 3, curY, menuTable[5], 0, 5); } -#endif } -void KyraEngine_v3::playVQA(const char *filename) { - VQAMovie vqa(this, _system); - - uint8 pal[768]; - memcpy(pal, _screen->_currentPalette, sizeof(pal)); - if (_screen->_curPage == 0) - _screen->copyCurPageBlock(0, 0, 320, 200, _screen->getPagePtr(3)); +void KyraEngine_v3::drawMainBox(int x, int y, int w, int h, int fill) { + static const uint8 colorTable[] = { 0x16, 0x19, 0x1A, 0x16 }; + --w; --h; - vqa.open(filename, 0, NULL); - if (vqa.opened()) { - vqa.setX(0); vqa.setY(0); - vqa.setDrawPage(0); - vqa.play(); - vqa.close(); + if (fill) { + _screen->fillRect(x, y, x+w, y+h, colorTable[0]); } + + _screen->drawClippedLine(x, y+h, x+w, y+h, colorTable[1]); + _screen->drawClippedLine(x+w, y, x+w, y+h, colorTable[1]); + _screen->drawClippedLine(x, y, x+w, y, colorTable[2]); + _screen->drawClippedLine(x, y, x, y+h, colorTable[2]); + + _screen->drawPixel(x, y+h, colorTable[3]); + _screen->drawPixel(x+w, y, colorTable[3]); +} - if (_screen->_curPage == 0) - _screen->copyBlockToPage(0, 0, 0, 320, 200, _screen->getPagePtr(3)); - _screen->setScreenPalette(pal); +void KyraEngine_v3::gui_printString(const char *string, int x, int y, int col1, int col2, int flags, ...) { + if (!string) + return; + + // XXX + + if (flags & 1) { + x -= _screen->getTextWidth(string) >> 1; + } + + if (flags & 2) { + x -= _screen->getTextWidth(string); + } + + if (flags & 4) { + _screen->printText(string, x - 1, y, 240, col2); + _screen->printText(string, x, y + 1, 240, col2); + } + + if (flags & 8) { + _screen->printText(string, x - 1, y, 227, col2); + _screen->printText(string, x, y + 1, 227, col2); + } + + _screen->printText(string, x, y, col1, col2); } } // end of namespace Kyra diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp index bc3f4bf115..d31278e355 100644 --- a/engines/kyra/screen.cpp +++ b/engines/kyra/screen.cpp @@ -494,6 +494,12 @@ void Screen::drawBox(int x1, int y1, int x2, int y2, int color) { drawClippedLine(x1, y2, x2, y2, color); } +void Screen::drawPixel(int x, int y, int color, int pageNum) { + debugC(9, kDebugLevelScreen, "Screen::drawPixel(%i, %i, %i, %i)", x, y, color, pageNum); + uint8 *dst = getPagePtr((pageNum != -1) ? pageNum : 0) + y * SCREEN_W + x; + *dst = color; +} + void Screen::drawShadedBox(int x1, int y1, int x2, int y2, int color1, int color2) { debugC(9, kDebugLevelScreen, "Screen::drawShadedBox(%i, %i, %i, %i, %i, %i)", x1, y1, x2, y2, color1, color2); assert(x1 > 0 && y1 > 0); @@ -595,7 +601,7 @@ void Screen::loadFont(FontId fontId, uint8 *fontData) { error("Invalid font data"); } fnt->charWidthTable = fontData + READ_LE_UINT16(fontData + 8); - fnt->charBoxHeight = READ_LE_UINT16(fontData + 4); + fnt->charSizeOffset = READ_LE_UINT16(fontData + 4); fnt->charBitmapOffset = READ_LE_UINT16(fontData + 6); fnt->charWidthTableOffset = READ_LE_UINT16(fontData + 8); fnt->charHeightTableOffset = READ_LE_UINT16(fontData + 0xC); @@ -609,7 +615,11 @@ Screen::FontId Screen::setFont(FontId fontId) { } int Screen::getFontHeight() const { - return (int)(_fonts[_currentFont].charBoxHeight); + return *(_fonts[_currentFont].fontData + _fonts[_currentFont].charSizeOffset + 4); +} + +int Screen::getFontWidth() const { + return *(_fonts[_currentFont].fontData + _fonts[_currentFont].charSizeOffset + 5); } int Screen::getCharWidth(uint8 c) const { @@ -646,7 +656,7 @@ void Screen::printText(const char *str, int x, int y, uint8 color1, uint8 color2 setTextColor(cmap, 0, 1); Font *fnt = &_fonts[_currentFont]; - uint8 charHeight = *(fnt->fontData + fnt->charBoxHeight + 4); + uint8 charHeight = *(fnt->fontData + fnt->charSizeOffset + 4); if (x < 0) { x = 0; @@ -694,8 +704,9 @@ void Screen::drawChar(uint8 c, int x, int y) { if (charWidth + x > SCREEN_W) { return; } - uint8 charH0 = *(fnt->fontData + fnt->charBoxHeight + 4); + uint8 charH0 = *(fnt->fontData + fnt->charSizeOffset + 4); if (charH0 + y > SCREEN_H) { + printf("charH0 + y: %d + %d: %d ('%c')\n", charH0, y, charH0 + y, c); return; } uint8 charH1 = *(fnt->fontData + fnt->charHeightTableOffset + c * 2); diff --git a/engines/kyra/screen.h b/engines/kyra/screen.h index 6810ad7389..5853eef7bf 100644 --- a/engines/kyra/screen.h +++ b/engines/kyra/screen.h @@ -47,7 +47,7 @@ struct ScreenDim { struct Font { uint8 *fontData; uint8 *charWidthTable; - uint16 charBoxHeight; + uint16 charSizeOffset; uint16 charBitmapOffset; uint16 charWidthTableOffset; uint16 charHeightTableOffset; @@ -115,12 +115,14 @@ public: void drawClippedLine(int x1, int y1, int x2, int y2, int color); void drawShadedBox(int x1, int y1, int x2, int y2, int color1, int color2); void drawBox(int x1, int y1, int x2, int y2, int color); + void drawPixel(int x, int y, int color, int pageNum = -1); void setAnimBlockPtr(int size); void setTextColorMap(const uint8 *cmap); void setTextColor(const uint8 *cmap, int a, int b); void loadFont(FontId fontId, uint8 *fontData); FontId setFont(FontId fontId); int getFontHeight() const; + int getFontWidth() const; int getCharWidth(uint8 c) const; int getTextWidth(const char *str) const; void printText(const char *str, int x, int y, uint8 color1, uint8 color2); |