From f3884d1a98c19134514a1fca6af48a59f3b57e91 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Mon, 5 Dec 2011 20:59:51 +0100 Subject: CGE: Better handling of the wide 'space' character --- engines/cge/cge.h | 2 +- engines/cge/snail.cpp | 2 +- engines/cge/talk.cpp | 42 ++++++++++++++++++++++++++++-------------- engines/cge/talk.h | 3 ++- engines/cge/text.cpp | 4 ++-- 5 files changed, 34 insertions(+), 19 deletions(-) (limited to 'engines') diff --git a/engines/cge/cge.h b/engines/cge/cge.h index d494af0700..d324b293fa 100644 --- a/engines/cge/cge.h +++ b/engines/cge/cge.h @@ -225,7 +225,7 @@ public: void runGame(); bool showTitle(const char *name); void movie(const char *ext); - void inf(const char *text); + void inf(const char *text, bool wideSpace = false); void selectSound(); void dummy() {} void NONE(); diff --git a/engines/cge/snail.cpp b/engines/cge/snail.cpp index f50f66942b..c26f68fa7b 100644 --- a/engines/cge/snail.cpp +++ b/engines/cge/snail.cpp @@ -194,7 +194,7 @@ void CommandHandler::runCommand() { break; case kCmdInf: if (_talkEnable) { - _vm->inf(_vm->_text->getText(tailCmd->_val)); + _vm->inf(_vm->_text->getText(tailCmd->_val), true); _vm->_sys->_funDel = kHeroFun0; } break; diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp index d9be56e798..5a39228968 100644 --- a/engines/cge/talk.cpp +++ b/engines/cge/talk.cpp @@ -73,8 +73,8 @@ uint16 Font::width(const char *text) { return w; } -Talk::Talk(CGEEngine *vm, const char *text, TextBoxStyle mode) - : Sprite(vm, NULL), _mode(mode), _vm(vm) { +Talk::Talk(CGEEngine *vm, const char *text, TextBoxStyle mode, bool wideSpace) + : Sprite(vm, NULL), _mode(mode), _wideSpace(wideSpace), _vm(vm) { _ts = NULL; _flags._syst = true; update(text); @@ -85,6 +85,7 @@ Talk::Talk(CGEEngine *vm) : Sprite(vm, NULL), _mode(kTBPure), _vm(vm) { _ts = NULL; _flags._syst = true; + _wideSpace = false; } void Talk::update(const char *text) { @@ -103,7 +104,9 @@ void Talk::update(const char *text) { if (k > mw) mw = k; k = 2 * hmarg; - } else + } else if ((*p == 0x20) && (_vm->_font->_widthArr[(unsigned char)*p] > 4) && (!_wideSpace)) + k += _vm->_font->_widthArr[(unsigned char)*p] - 2; + else k += _vm->_font->_widthArr[(unsigned char)*p]; } if (k > mw) @@ -122,7 +125,14 @@ void Talk::update(const char *text) { } else { int cw = _vm->_font->_widthArr[(unsigned char)*text]; uint8 *f = _vm->_font->_map + _vm->_font->_pos[(unsigned char)*text]; - for (int i = 0; i < cw; i++) { + + // Handle properly space size, after it was enlarged to display properly + // 'F1' text. + int8 fontStart = 0; + if ((*text == 0x20) && (cw > 4) && (!_wideSpace)) + fontStart = 2; + + for (int i = fontStart; i < cw; i++) { uint8 *pp = m; uint16 n; uint16 b = *(f++); @@ -211,10 +221,16 @@ void Talk::putLine(int line, const char *text) { uint8 *q = v + size; while (*text) { - uint16 cw = _vm->_font->_widthArr[(unsigned char)*text], i; + uint16 cw = _vm->_font->_widthArr[(unsigned char)*text]; uint8 *fp = _vm->_font->_map + _vm->_font->_pos[(unsigned char)*text]; - for (i = 0; i < cw; i++) { + // Handle properly space size, after it was enlarged to display properly + // 'F1' text. + int8 fontStart = 0; + if ((*text == 0x20) && (cw > 4) && (!_wideSpace)) + fontStart = 2; + + for (int i = fontStart; i < cw; i++) { uint16 b = fp[i]; uint16 n; for (n = 0; n < kFontHigh; n++) { @@ -271,15 +287,13 @@ void InfoLine::update(const char *text) { uint16 cw = _vm->_font->_widthArr[(unsigned char)*text]; uint8 *fp = _vm->_font->_map + _vm->_font->_pos[(unsigned char)*text]; - // This hack compensates the font modification done to fix the display - // of the 'F1' text. Specifically, it reduces the width of the space - // character when it has been enlarged. - // This hack fixes bug #3450423. - int8 hackStart = 0; - if ((*text == 0x20) && (cw > 4)) - hackStart = 2; + // Handle properly space size, after it was enlarged to display properly + // 'F1' text. + int8 fontStart = 0; + if ((*text == 0x20) && (cw > 4) && (!_wideSpace)) + fontStart = 2; - for (uint16 i = hackStart; i < cw; i++) { + for (int i = fontStart; i < cw; i++) { uint16 b = fp[i]; for (uint16 n = 0; n < kFontHigh; n++) { if (b & 1) diff --git a/engines/cge/talk.h b/engines/cge/talk.h index 55c529b7ea..b292cf702e 100644 --- a/engines/cge/talk.h +++ b/engines/cge/talk.h @@ -52,8 +52,9 @@ protected: TextBoxStyle _mode; BitmapPtr *_ts; Bitmap *box(uint16 w, uint16 h); + bool _wideSpace; public: - Talk(CGEEngine *vm, const char *text, TextBoxStyle mode); + Talk(CGEEngine *vm, const char *text, TextBoxStyle mode, bool wideSpace = false); Talk(CGEEngine *vm); virtual void update(const char *text); diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index d426787ed4..331dc8ac2d 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -182,7 +182,7 @@ void Text::say(const char *text, Sprite *spr) { _vm->_vga->_showQ->insert(speaker, _vm->_vga->_showQ->last()); } -void CGEEngine::inf(const char *text) { +void CGEEngine::inf(const char *text, bool wideSpace) { debugC(1, kCGEDebugEngine, "CGEEngine::inf(%s)", text); if (!text) return; @@ -191,7 +191,7 @@ void CGEEngine::inf(const char *text) { return; killText(); - _talk = new Talk(this, text, kTBRect); + _talk = new Talk(this, text, kTBRect, wideSpace); if (!_talk) return; -- cgit v1.2.3