diff options
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/gui/gui.cpp | 2 | ||||
-rw-r--r-- | engines/sci/gui/gui_gfx.cpp | 83 | ||||
-rw-r--r-- | engines/sci/gui/gui_gfx.h | 16 |
3 files changed, 75 insertions, 26 deletions
diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp index fe3d6f00d5..e0fd24471f 100644 --- a/engines/sci/gui/gui.cpp +++ b/engines/sci/gui/gui.cpp @@ -218,10 +218,12 @@ void SciGUI::textSize(const char *text, int16 font, int16 maxWidth, int16 *textW // Used SCI1+ for text codes void SciGUI::textFonts(int argc, reg_t *argv) { + _gfx->SetTextFonts(argc, argv); } // Used SCI1+ for text codes void SciGUI::textColors(int argc, reg_t *argv) { + _gfx->SetTextColors(argc, argv); } void SciGUI::drawPicture(sciResourceId pictureId, uint16 style, uint16 flags, int16 EGApaletteNo) { diff --git a/engines/sci/gui/gui_gfx.cpp b/engines/sci/gui/gui_gfx.cpp index e616fcc004..f34907e37f 100644 --- a/engines/sci/gui/gui_gfx.cpp +++ b/engines/sci/gui/gui_gfx.cpp @@ -54,6 +54,8 @@ void SciGUIgfx::init() { uint16 a = 0; _font = NULL; + _textFonts = NULL; _textFontsCount = 0; + _textColors = NULL; _textColorsCount = 0; _mainPort = mallocPort(); SetPort(_mainPort); @@ -158,11 +160,16 @@ void SciGUIgfx::CreatePaletteFromData(byte *data, sciPalette *paletteOut) { int colorNo = 0; memset(paletteOut, 0, sizeof(sciPalette)); + // Setup default mapping + for (colorNo = 0; colorNo < 256; colorNo++) { + paletteOut->mapping[colorNo] = colorNo; + } if (data[0] == 0 && data[1] == 1) { // SCI0/SCI1 palette palFormat = SCI_PAL_FORMAT_VARIABLE; // CONSTANT; palOffset = 260; palColorStart = 0; palColorCount = 256; + //memcpy(&paletteOut->mapping, data, 256); } else { // SCI1.1 palette palFormat = data[32]; @@ -496,18 +503,7 @@ byte SciGUIgfx::CharWidth(int16 ch) { SciGUIfont *font = GetFont(); return font ? font->getCharWidth(ch) : 0; } -//----------------------------- -int16 SciGUIgfx::TextWidth(const char *text, int16 from, int16 len) { - SciGUIfont *font = GetFont(); - if (font) { - int16 width = 0; - for (int i = from; i < len; i++) - width += _font->getCharWidth(text[i]); - return width; - } - return 0; -} -//----------------------------- + void SciGUIgfx::ClearChar(int16 chr) { if (_curPort->penMode != 1) return; @@ -536,6 +532,44 @@ void SciGUIgfx::StdChar(int16 chr) { #endif } +void SciGUIgfx::SetTextFonts(int argc, reg_t *argv) { + int i; + + if (_textFonts) { + delete _textFonts; + } + _textFontsCount = argc; + _textFonts = new sciResourceId[argc]; + for (i = 0; i < argc; i++) { + _textFonts[i] = (sciResourceId)argv[i].toUint16(); + } +} + +void SciGUIgfx::SetTextColors(int argc, reg_t *argv) { + int i; + + if (_textColors) { + delete _textColors; + } + _textColorsCount = argc; + _textColors = new uint16[argc]; + for (i = 0; i < argc; i++) { + _textColors[i] = argv[i].toUint16(); + } +} + +// TODO: implement codes +int16 SciGUIgfx::TextWidth(const char *text, int16 from, int16 len) { + SciGUIfont *font = GetFont(); + if (font) { + int16 width = 0; + for (int i = from; i < len; i++) + width += _font->getCharWidth(text[i]); + return width; + } + return 0; +} + // TODO: implement codes int16 SciGUIgfx::TextSize(Common::Rect &rect, const char *str, int16 fontId, int16 maxwidth) { char buff[1000] = { 0 }; @@ -612,16 +646,23 @@ void SciGUIgfx::DrawText(const char *text, int16 from, int16 len) { rect.bottom = rect.top + _curPort->fontH; while (len--) { chr = (*text++) & 0xFF; - width = font->getCharWidth(chr); - // clear char - if (_curPort->penMode == 1) { - rect.left = _curPort->curLeft; - rect.right = rect.left + width; - EraseRect(rect); + switch (chr) { + case 0x7C: + while ((len--) && (*text++ != 0x7C)) { } + break; + + default: + width = font->getCharWidth(chr); + // clear char + if (_curPort->penMode == 1) { + rect.left = _curPort->curLeft; + rect.right = rect.left + width; + EraseRect(rect); + } + // CharStd + font->draw(chr, _curPort->top + _curPort->curTop, _curPort->left + _curPort->curLeft, _curPort->penClr, _curPort->textFace); + _curPort->curLeft += width; } - // CharStd - font->draw(chr, _curPort->top + _curPort->curTop, _curPort->left + _curPort->curLeft, _curPort->penClr, _curPort->textFace); - _curPort->curLeft += width; } } diff --git a/engines/sci/gui/gui_gfx.h b/engines/sci/gui/gui_gfx.h index f86a62f157..23d4616751 100644 --- a/engines/sci/gui/gui_gfx.h +++ b/engines/sci/gui/gui_gfx.h @@ -79,13 +79,16 @@ public: byte CharHeight(int16 ch); byte CharWidth(int16 ch); + void ClearChar(int16 chr); + void DrawChar(int16 chr); + void StdChar(int16 chr); + + void SetTextFonts(int argc, reg_t *argv); + void SetTextColors(int argc, reg_t *argv); int16 TextWidth(const char*text, int16 from, int16 len); int16 StringWidth(const char*str) { return TextWidth(str, 0, (int16)strlen(str)); } - void ClearChar(int16 chr); - void DrawChar(int16 chr); - void StdChar(int16 chr); int16 TextSize(Common::Rect &rect, const char *str, int16 fontId, int16 maxwidth); int16 GetLongest(const char *str, int16 maxwidth); void DrawText(const char *str, int16 from, int16 len); @@ -133,14 +136,17 @@ private: Common::Rect _bounds; sciPort *_mainPort; sciPort *_curPort; -// byte *_visualScreen; -// byte *_pcSeg; uint16 _clrPowers[256]; byte bMapColors; sciPalette *pPicPal; Common::Array<sciPalSched> _palSchedules; + int _textFontsCount; + sciResourceId *_textFonts; + int _textColorsCount; + uint16 *_textColors; + SciGUIfont *_font; }; |