diff options
-rw-r--r-- | saga/font.cpp | 15 | ||||
-rw-r--r-- | saga/font.h | 13 | ||||
-rw-r--r-- | saga/interface.cpp | 75 | ||||
-rw-r--r-- | saga/interface.h | 2 |
4 files changed, 90 insertions, 15 deletions
diff --git a/saga/font.cpp b/saga/font.cpp index 0b0bc67608..aca642b064 100644 --- a/saga/font.cpp +++ b/saga/font.cpp @@ -379,20 +379,20 @@ int Font::draw(int font_id, SURFACE *ds, const char *draw_str, size_t draw_str_c font = _fonts[font_id]; if (flags & FONT_OUTLINE) { - outFont(font->outline, ds, draw_str, draw_str_ct, text_x - 1, text_y - 1, effect_color); - outFont(font->normal, ds, draw_str, draw_str_ct, text_x, text_y, color); + outFont(font->outline, ds, draw_str, draw_str_ct, text_x - 1, text_y - 1, effect_color, flags); + outFont(font->normal, ds, draw_str, draw_str_ct, text_x, text_y, color, flags); } else if (flags & FONT_SHADOW) { - outFont(font->normal, ds, draw_str, draw_str_ct, text_x - 1, text_y + 1, effect_color); - outFont(font->normal, ds, draw_str, draw_str_ct, text_x, text_y, color); + outFont(font->normal, ds, draw_str, draw_str_ct, text_x - 1, text_y + 1, effect_color, flags); + outFont(font->normal, ds, draw_str, draw_str_ct, text_x, text_y, color, flags); } else { // FONT_NORMAL - outFont(font->normal, ds, draw_str, draw_str_ct, text_x, text_y, color); + outFont(font->normal, ds, draw_str, draw_str_ct, text_x, text_y, color, flags); } return SUCCESS; } int Font::outFont(FONT_STYLE * draw_font, SURFACE * ds, const char *draw_str, size_t draw_str_ct, - int text_x, int text_y, int color) { + int text_x, int text_y, int color, int flags) { const byte *draw_str_p; byte *c_data_ptr; int c_code; @@ -424,7 +424,8 @@ int Font::outFont(FONT_STYLE * draw_font, SURFACE * ds, const char *draw_str, si c_code = *draw_str_p & 0xFFU; // Translate character - c_code = _charMap[c_code]; + if (!(flags & FONT_DONTMAP)) + c_code = _charMap[c_code]; assert(c_code < FONT_CHARCOUNT); // Check if character is defined diff --git a/saga/font.h b/saga/font.h index a3aec4b962..8e7947ee3d 100644 --- a/saga/font.h +++ b/saga/font.h @@ -55,11 +55,12 @@ enum FONT_ID { }; enum FONT_EFFECT_FLAGS { - FONT_NORMAL = 0x00, - FONT_OUTLINE = 0x01, - FONT_SHADOW = 0x02, - FONT_BOLD = 0x04, - FONT_CENTERED = 0x08 + FONT_NORMAL = 0, + FONT_OUTLINE = 1 << 0, + FONT_SHADOW = 1 << 1, + FONT_BOLD = 1 << 2, + FONT_CENTERED = 1 << 3, + FONT_DONTMAP = 1 << 4 }; struct FONT_HEADER { @@ -110,7 +111,7 @@ class Font { int loadFont(uint32 font_rn, int font_id); FONT_STYLE *createOutline(FONT_STYLE * src_font); int outFont(FONT_STYLE *font, SURFACE * ds, const char *draw_str, size_t draw_str_ct, - int text_x, int text_y, int color); + int text_x, int text_y, int color, int flags); int getByteLen(int num_bits); static const int _charMap[256]; diff --git a/saga/interface.cpp b/saga/interface.cpp index 58aa52d1e9..72a9781828 100644 --- a/saga/interface.cpp +++ b/saga/interface.cpp @@ -808,6 +808,11 @@ void Interface::converseClear(void) { _converseStartPos = 0; _converseEndPos = 0; _conversePos = -1; + + for (int i = 0; i < CONVERSE_TEXT_LINES; i++) { + _converseLastColors[0][i] = 0; + _converseLastColors[1][i] = 0; + } } bool Interface::converseAddText(const char *text, int replyId, byte replyFlags, int replyBit) { @@ -862,8 +867,8 @@ bool Interface::converseAddText(const char *text, int replyId, byte replyFlags, enum converseColors { kColorBrightWhite = 0x2, - kColorDarkGrey = 0xa, - kColorGrey = 0xb, + kColorGrey = 0xa, + kColorDarkGrey = 0xb, kColorGreen = 0xba, kColorBlack = 0xf, kColorBlue = 0x93 @@ -899,6 +904,72 @@ void Interface::converseSetTextLines(int row, int textcolor, bool btnDown) { } void Interface::converseDisplayTextLine(int textcolor, bool btnDown, bool rebuild) { + int x = 52; // FIXME: remove hardcoded value + int y = 6; // FIXME: remove hardcoded value + int pos = _converseStartPos; + byte textcolors[2][CONVERSE_TEXT_LINES]; + SURFACE *ds; + + ds = _vm->_gfx->getBackBuffer(); // FIXME: probably best to move this out + + for (int i = 0; i < CONVERSE_TEXT_LINES; i++) { + int relpos = pos + i; + + if (_conversePos >= 0 + && _converseText[_conversePos].stringNum + == _converseText[relpos].stringNum) { + textcolors[0][i] = textcolor; + textcolors[1][i] = (!btnDown) ? kColorDarkGrey : kColorGrey; + } else { + textcolors[0][i] = kColorBlue; + textcolors[1][i] = kColorDarkGrey; + } + } + // if no colors have changed, exit + if (!rebuild && memcmp(textcolors, _converseLastColors, sizeof(textcolors)) == 0) + return; + + memcpy(_converseLastColors, textcolors, sizeof(textcolors)); + + Rect rect(8, CONVERSE_TEXT_LINES * CONVERSE_TEXT_HEIGHT); + int scrx = _conversePanel.x + x; + + rect.moveTo(_conversePanel.x + x, _conversePanel.y + y); + + drawRect(ds, &rect, kColorDarkGrey); + + rect.top = rect.left = 0; + rect.right = CONVERSE_MAX_TEXT_WIDTH; + rect.bottom = CONVERSE_TEXT_HEIGHT; + + for (int i = 0; i < CONVERSE_TEXT_LINES; i++) { + byte foregnd = textcolors[0][i]; + byte backgnd = textcolors[1][i]; + int relpos = pos + i; + + rect.moveTo(_conversePanel.x + x + 7 + 1, + _conversePanel.y + y + i * CONVERSE_TEXT_HEIGHT); + + drawRect(ds, &rect, backgnd); + + if (_converseTextCount > i) { + const char *str = _converseText[relpos].text; + char bullet[] = { 0xb7, 0 }; + int scry = i * CONVERSE_TEXT_HEIGHT + _conversePanel.y + y; + byte tcolor, bcolor; + + if (_converseText[relpos].textNum == 0) { // first entry + tcolor = kColorGreen; + bcolor = kColorBlack; + _vm->_font->draw(SMALL_FONT_ID, ds, bullet, strlen(bullet), + scrx + 2, scry, tcolor, bcolor, FONT_SHADOW | FONT_DONTMAP); + } + _vm->_font->draw(SMALL_FONT_ID, ds, str, strlen(str), + scrx + 9, scry, foregnd, kColorBlack, FONT_SHADOW); + } + } + + // FIXME: TODO: arrows } void Interface::converseChangePos(int chg) { diff --git a/saga/interface.h b/saga/interface.h index 67a1931af5..84e4be2d59 100644 --- a/saga/interface.h +++ b/saga/interface.h @@ -295,6 +295,8 @@ private: int _converseStartPos; int _converseEndPos; int _conversePos; + + byte _converseLastColors[2][CONVERSE_TEXT_LINES]; }; } // End of namespace Saga |