SCI: move textSize and textFonts and textColors inside gfxText16

svn-id: r49851
This commit is contained in:
Martin Kiewitz 2010-06-15 13:01:07 +00:00
parent 604f855889
commit 891b568fde
7 changed files with 46 additions and 56 deletions

View File

@ -48,6 +48,7 @@
#include "sci/graphics/paint16.h"
#include "sci/graphics/ports.h"
#include "sci/graphics/screen.h"
#include "sci/graphics/text16.h"
#include "sci/graphics/view.h"
namespace Sci {
@ -345,11 +346,12 @@ reg_t kTextSize(EngineState *s, int argc, reg_t *argv) {
textWidth = dest[3].toUint16(); textHeight = dest[2].toUint16();
#ifdef ENABLE_SCI32
if (g_sci->_gui32)
g_sci->_gui32->textSize(g_sci->strSplit(text.c_str(), sep).c_str(), font_nr, maxwidth, &textWidth, &textHeight);
else
if (!g_sci->_gfxText16) {
// TODO: Implement this
textWidth = 0; textHeight = 0;
} else
#endif
g_sci->_gui->textSize(g_sci->strSplit(text.c_str(), sep).c_str(), font_nr, maxwidth, &textWidth, &textHeight);
g_sci->_gfxText16->kernelTextSize(g_sci->strSplit(text.c_str(), sep).c_str(), font_nr, maxwidth, &textWidth, &textHeight);
debugC(2, kDebugLevelStrings, "GetTextSize '%s' -> %dx%d", text.c_str(), textWidth, textHeight);
dest[2] = make_reg(0, textHeight);
@ -1246,12 +1248,12 @@ reg_t kSetVideoMode(EngineState *s, int argc, reg_t *argv) {
// New calls for SCI11. Using those is only needed when using text-codes so that one is able to change
// font and/or color multiple times during kDisplay and kDrawControl
reg_t kTextFonts(EngineState *s, int argc, reg_t *argv) {
g_sci->_gui->textFonts(argc, argv);
g_sci->_gfxText16->kernelTextFonts(argc, argv);
return s->r_acc;
}
reg_t kTextColors(EngineState *s, int argc, reg_t *argv) {
g_sci->_gui->textColors(argc, argv);
g_sci->_gfxText16->kernelTextColors(argc, argv);
return s->r_acc;
}

View File

@ -68,6 +68,7 @@ SciGui::SciGui(EngineState *state, GfxScreen *screen, GfxPalette *palette, GfxCa
_animate = new GfxAnimate(_s, _cache, _ports, _paint16, _screen, _palette, _cursor, _transitions);
g_sci->_gfxAnimate = _animate;
_text16 = new GfxText16(g_sci->getResMan(), _cache, _ports, _paint16, _screen);
g_sci->_gfxText16 = _text16;
_controls = new GfxControls(_s->_segMan, _ports, _paint16, _text16, _screen);
g_sci->_gfxControls = _controls;
_menu = new GfxMenu(g_sci->getEventManager(), _s->_segMan, this, _ports, _paint16, _text16, _screen, _cursor);
@ -94,21 +95,4 @@ void SciGui::wait(int16 ticks) {
_s->wait(ticks);
}
void SciGui::textSize(const char *text, int16 font, int16 maxWidth, int16 *textWidth, int16 *textHeight) {
Common::Rect rect(0, 0, *textWidth, *textHeight);
_text16->Size(rect, text, font, maxWidth);
*textWidth = rect.width();
*textHeight = rect.height();
}
// Used SCI1+ for text codes
void SciGui::textFonts(int argc, reg_t *argv) {
_text16->CodeSetFonts(argc, argv);
}
// Used SCI1+ for text codes
void SciGui::textColors(int argc, reg_t *argv) {
_text16->CodeSetColors(argc, argv);
}
} // End of namespace Sci

View File

@ -53,10 +53,6 @@ public:
virtual void wait(int16 ticks);
virtual void textSize(const char *text, int16 font, int16 maxWidth, int16 *textWidth, int16 *textHeight);
virtual void textFonts(int argc, reg_t *argv);
virtual void textColors(int argc, reg_t *argv);
protected:
GfxCursor *_cursor;
EngineState *_s;

View File

@ -69,11 +69,6 @@ SciGui32::~SciGui32() {
void SciGui32::init() {
}
void SciGui32::textSize(const char *text, int16 font, int16 maxWidth, int16 *textWidth, int16 *textHeight) {
*textWidth = 0;
*textHeight = 0;
}
void SciGui32::drawRobot(GuiResourceId robotId) {
Robot *test = new Robot(g_sci->getResMan(), _screen, robotId);
test->draw();

View File

@ -73,28 +73,6 @@ void GfxText16::SetFont(GuiResourceId fontId) {
_ports->_curPort->fontHeight = _font->getHeight();
}
void GfxText16::CodeSetFonts(int argc, reg_t *argv) {
int i;
delete _codeFonts;
_codeFontsCount = argc;
_codeFonts = new GuiResourceId[argc];
for (i = 0; i < argc; i++) {
_codeFonts[i] = (GuiResourceId)argv[i].toUint16();
}
}
void GfxText16::CodeSetColors(int argc, reg_t *argv) {
int i;
delete _codeColors;
_codeColorsCount = argc;
_codeColors = new uint16[argc];
for (i = 0; i < argc; i++) {
_codeColors[i] = argv[i].toUint16();
}
}
void GfxText16::ClearChar(int16 chr) {
if (_ports->_curPort->penMode != 1)
return;
@ -488,4 +466,35 @@ bool GfxText16::SwitchToFont900OnSjis(const char *text) {
return false;
}
void GfxText16::kernelTextSize(const char *text, int16 font, int16 maxWidth, int16 *textWidth, int16 *textHeight) {
Common::Rect rect(0, 0, *textWidth, *textHeight);
Size(rect, text, font, maxWidth);
*textWidth = rect.width();
*textHeight = rect.height();
}
// Used SCI1+ for text codes
void GfxText16::kernelTextFonts(int argc, reg_t *argv) {
int i;
delete _codeFonts;
_codeFontsCount = argc;
_codeFonts = new GuiResourceId[argc];
for (i = 0; i < argc; i++) {
_codeFonts[i] = (GuiResourceId)argv[i].toUint16();
}
}
// Used SCI1+ for text codes
void GfxText16::kernelTextColors(int argc, reg_t *argv) {
int i;
delete _codeColors;
_codeColorsCount = argc;
_codeColors = new uint16[argc];
for (i = 0; i < argc; i++) {
_codeColors[i] = argv[i].toUint16();
}
}
} // End of namespace Sci

View File

@ -48,8 +48,6 @@ public:
GfxFont *GetFont();
void SetFont(GuiResourceId fontId);
void CodeSetFonts(int argc, reg_t *argv);
void CodeSetColors(int argc, reg_t *argv);
int16 CodeProcessing(const char *&text, GuiResourceId orgFontId, int16 orgPenColor);
void ClearChar(int16 chr);
@ -67,6 +65,10 @@ public:
GfxFont *_font;
void kernelTextSize(const char *text, int16 font, int16 maxWidth, int16 *textWidth, int16 *textHeight);
void kernelTextFonts(int argc, reg_t *argv);
void kernelTextColors(int argc, reg_t *argv);
private:
void init();
bool SwitchToFont900OnSjis(const char *text);

View File

@ -66,6 +66,7 @@ class GfxPaint16;
class GfxPalette;
class GfxPorts;
class GfxScreen;
class GfxText16;
class SciGui;
class GfxMacIconBar;
@ -205,6 +206,7 @@ public:
GfxPaint16 *_gfxPaint16; // Painting in 16-bit gfx
GfxPorts *_gfxPorts; // Port managment for 16-bit gfx
GfxScreen *_gfxScreen;
GfxText16 *_gfxText16;
SciGui *_gui; /* Currently active Gui */
GfxMacIconBar *_gfxMacIconBar; // Mac Icon Bar manager