mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-23 12:44:02 +00:00
o All fonts were mapped. Introduced new FONT_DONTMAP flag
o Implemented and tested converse drawing. Still some features like arrows and hardcoded values are present, and it is not used in scripts svn-id: r16536
This commit is contained in:
parent
2dd88384a1
commit
133ff34cb4
@ -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
|
||||
|
13
saga/font.h
13
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];
|
||||
|
@ -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) {
|
||||
|
@ -295,6 +295,8 @@ private:
|
||||
int _converseStartPos;
|
||||
int _converseEndPos;
|
||||
int _conversePos;
|
||||
|
||||
byte _converseLastColors[2][CONVERSE_TEXT_LINES];
|
||||
};
|
||||
|
||||
} // End of namespace Saga
|
||||
|
Loading…
x
Reference in New Issue
Block a user