[Scummvm-cvs-logs] SF.net SVN: scummvm:[47780] scummvm/trunk/engines/sci

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Sun Jan 31 22:54:50 CET 2010


Revision: 47780
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47780&view=rev
Author:   m_kiewitz
Date:     2010-01-31 21:54:43 +0000 (Sun, 31 Jan 2010)

Log Message:
-----------
SCI: renamed Text class to GfxText16

Modified Paths:
--------------
    scummvm/trunk/engines/sci/graphics/controls.cpp
    scummvm/trunk/engines/sci/graphics/controls.h
    scummvm/trunk/engines/sci/graphics/gui.cpp
    scummvm/trunk/engines/sci/graphics/gui.h
    scummvm/trunk/engines/sci/graphics/gui32.cpp
    scummvm/trunk/engines/sci/graphics/menu.cpp
    scummvm/trunk/engines/sci/graphics/menu.h
    scummvm/trunk/engines/sci/graphics/paint16.cpp
    scummvm/trunk/engines/sci/graphics/paint16.h
    scummvm/trunk/engines/sci/graphics/ports.cpp
    scummvm/trunk/engines/sci/graphics/ports.h
    scummvm/trunk/engines/sci/module.mk

Added Paths:
-----------
    scummvm/trunk/engines/sci/graphics/text16.cpp
    scummvm/trunk/engines/sci/graphics/text16.h

Removed Paths:
-------------
    scummvm/trunk/engines/sci/graphics/text.cpp
    scummvm/trunk/engines/sci/graphics/text.h

Modified: scummvm/trunk/engines/sci/graphics/controls.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/controls.cpp	2010-01-31 21:31:11 UTC (rev 47779)
+++ scummvm/trunk/engines/sci/graphics/controls.cpp	2010-01-31 21:54:43 UTC (rev 47780)
@@ -34,13 +34,13 @@
 #include "sci/graphics/ports.h"
 #include "sci/graphics/paint16.h"
 #include "sci/graphics/font.h"
-#include "sci/graphics/text.h"
+#include "sci/graphics/text16.h"
 #include "sci/graphics/controls.h"
 
 namespace Sci {
 
-Controls::Controls(SegManager *segMan, GfxPorts *ports, GfxPaint16 *paint16, Text *text)
-	: _segMan(segMan), _ports(ports), _paint16(paint16), _text(text) {
+Controls::Controls(SegManager *segMan, GfxPorts *ports, GfxPaint16 *paint16, GfxText16 *text16)
+	: _segMan(segMan), _ports(ports), _paint16(paint16), _text16(text16) {
 	init();
 }
 
@@ -56,7 +56,7 @@
 
 void Controls::drawListControl(Common::Rect rect, reg_t obj, int16 maxChars, int16 count, const char **entries, GuiResourceId fontId, int16 upperPos, int16 cursorPos, bool isAlias) {
 	Common::Rect workerRect = rect;
-	GuiResourceId oldFontId = _text->GetFontId();
+	GuiResourceId oldFontId = _text16->GetFontId();
 	int16 oldPenColor = _ports->_curPort->penClr;
 	uint16 fontSize = 0;
 	int16 i;
@@ -73,9 +73,9 @@
 	//  we draw UP arrow one pixel lower than sierra did, because it looks nicer. Also the DOWN arrow has one pixel
 	//  line inbetween as well
 	workerRect.top++;
-	_text->Box(controlListUpArrow, 0, workerRect, SCI_TEXT_ALIGNMENT_CENTER, 0);
+	_text16->Box(controlListUpArrow, 0, workerRect, SCI_TEXT16_ALIGNMENT_CENTER, 0);
 	workerRect.top = workerRect.bottom - 10;
-	_text->Box(controlListDownArrow, 0, workerRect, SCI_TEXT_ALIGNMENT_CENTER, 0);
+	_text16->Box(controlListDownArrow, 0, workerRect, SCI_TEXT16_ALIGNMENT_CENTER, 0);
 
 	// Draw inner lines
 	workerRect.top = rect.top + 9;
@@ -83,7 +83,7 @@
 	_paint16->frameRect(workerRect);
 	workerRect.grow(-1);
 
-	_text->SetFont(fontId);
+	_text16->SetFont(fontId);
 	fontSize = _ports->_curPort->fontHeight;
 	_ports->penColor(_ports->_curPort->penClr); _ports->backColor(_ports->_curPort->backClr);
 	workerRect.bottom = workerRect.top + 9;
@@ -96,7 +96,7 @@
 		if (listEntry[0]) {
 			_ports->moveTo(workerRect.left, workerRect.top);
 			listEntryLen = strlen(listEntry);
-			_text->Draw(listEntry, 0, MIN(maxChars, listEntryLen), oldFontId, oldPenColor);
+			_text16->Draw(listEntry, 0, MIN(maxChars, listEntryLen), oldFontId, oldPenColor);
 			if ((!isAlias) && (i == cursorPos)) {
 				_paint16->invertRect(workerRect);
 			}
@@ -106,7 +106,7 @@
 			break;
 	}
 
-	_text->SetFont(oldFontId);
+	_text16->SetFont(oldFontId);
 }
 
 void Controls::TexteditCursorDraw(Common::Rect rect, const char *text, uint16 curPos) {
@@ -114,12 +114,12 @@
 	if (!_texteditCursorVisible) {
 		textWidth = 0;
 		for (i = 0; i < curPos; i++) {
-			textWidth += _text->_font->getCharWidth(text[i]);
+			textWidth += _text16->_font->getCharWidth(text[i]);
 		}
 		_texteditCursorRect.left = rect.left + textWidth;
 		_texteditCursorRect.top = rect.top;
-		_texteditCursorRect.bottom = _texteditCursorRect.top + _text->_font->getHeight();
-		_texteditCursorRect.right = _texteditCursorRect.left + (text[curPos] == 0 ? 1 : _text->_font->getCharWidth(text[curPos]));
+		_texteditCursorRect.bottom = _texteditCursorRect.top + _text16->_font->getHeight();
+		_texteditCursorRect.right = _texteditCursorRect.left + (text[curPos] == 0 ? 1 : _text16->_font->getCharWidth(text[curPos]));
 		_paint16->invertRect(_texteditCursorRect);
 		_paint16->bitsShow(_texteditCursorRect);
 		_texteditCursorVisible = true;
@@ -205,17 +205,17 @@
 	}
 
 	if (textChanged) {
-		GuiResourceId oldFontId = _text->GetFontId();
+		GuiResourceId oldFontId = _text16->GetFontId();
 		GuiResourceId fontId = GET_SEL32V(_segMan, controlObject, font);
 		rect = Common::Rect(GET_SEL32V(_segMan, controlObject, nsLeft), GET_SEL32V(_segMan, controlObject, nsTop),
 							  GET_SEL32V(_segMan, controlObject, nsRight), GET_SEL32V(_segMan, controlObject, nsBottom));
 		TexteditCursorErase();
 		_paint16->eraseRect(rect);
-		_text->Box(text.c_str(), 0, rect, SCI_TEXT_ALIGNMENT_LEFT, fontId);
+		_text16->Box(text.c_str(), 0, rect, SCI_TEXT16_ALIGNMENT_LEFT, fontId);
 		_paint16->bitsShow(rect);
-		_text->SetFont(fontId);
+		_text16->SetFont(fontId);
 		TexteditCursorDraw(rect, text.c_str(), cursorPos);
-		_text->SetFont(oldFontId);
+		_text16->SetFont(oldFontId);
 		// Write back string
 		_segMan->strcpy(textReference, text.c_str());
 	} else {

Modified: scummvm/trunk/engines/sci/graphics/controls.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/controls.h	2010-01-31 21:31:11 UTC (rev 47779)
+++ scummvm/trunk/engines/sci/graphics/controls.h	2010-01-31 21:54:43 UTC (rev 47780)
@@ -31,10 +31,10 @@
 class GfxPorts;
 class GfxPaint16;
 class Font;
-class Text;
+class GfxText16;
 class Controls {
 public:
-	Controls(SegManager *segMan, GfxPorts *ports, GfxPaint16 *paint16, Text *text);
+	Controls(SegManager *segMan, GfxPorts *ports, GfxPaint16 *paint16, GfxText16 *text16);
 	~Controls();
 
 	void drawListControl(Common::Rect rect, reg_t obj, int16 maxChars, int16 count, const char **entries, GuiResourceId fontId, int16 upperPos, int16 cursorPos, bool isAlias);
@@ -49,7 +49,7 @@
 	SegManager *_segMan;
 	GfxPorts *_ports;
 	GfxPaint16 *_paint16;
-	Text *_text;
+	GfxText16 *_text16;
 
 	// Textedit-Control related
 	Common::Rect _texteditCursorRect;

Modified: scummvm/trunk/engines/sci/graphics/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/gui.cpp	2010-01-31 21:31:11 UTC (rev 47779)
+++ scummvm/trunk/engines/sci/graphics/gui.cpp	2010-01-31 21:54:43 UTC (rev 47780)
@@ -43,7 +43,7 @@
 #include "sci/graphics/controls.h"
 #include "sci/graphics/menu.h"
 #include "sci/graphics/portrait.h"
-#include "sci/graphics/text.h"
+#include "sci/graphics/text16.h"
 #include "sci/graphics/transitions.h"
 #include "sci/graphics/view.h"
 #include "sci/sound/audio.h"
@@ -58,15 +58,15 @@
 	_transitions = new Transitions(this, _screen, _palette, _s->resMan->isVGA());
 	_animate = new GfxAnimate(_s, _cache, _ports, _paint16, _screen, _palette, _cursor, _transitions);
 	_s->_gfxAnimate = _animate;
-	_text = new Text(_s->resMan, _cache, _ports, _paint16, _screen);
-	_controls = new Controls(_s->_segMan, _ports, _paint16, _text);
-	_menu = new Menu(_s->_event, _s->_segMan, this, _ports, _paint16, _text, _screen, _cursor);
+	_text16 = new GfxText16(_s->resMan, _cache, _ports, _paint16, _screen);
+	_controls = new Controls(_s->_segMan, _ports, _paint16, _text16);
+	_menu = new Menu(_s->_event, _s->_segMan, this, _ports, _paint16, _text16, _screen, _cursor);
 }
 
 SciGui::~SciGui() {
 	delete _menu;
 	delete _controls;
-	delete _text;
+	delete _text16;
 	delete _animate;
 	delete _transitions;
 	delete _paint16;
@@ -83,8 +83,8 @@
 void SciGui::init(bool usesOldGfxFunctions) {
 	_usesOldGfxFunctions = usesOldGfxFunctions;
 
-	_ports->init(this, _paint16, _text, _s->_gameId);
-	_paint16->init(_text);
+	_ports->init(this, _paint16, _text16, _s->_gameId);
+	_paint16->init(_text16);
 	initPriorityBands();
 }
 
@@ -143,7 +143,7 @@
 
 void SciGui::display(const char *text, int argc, reg_t *argv) {
 	int displayArg;
-	TextAlignment alignment = SCI_TEXT_ALIGNMENT_LEFT;
+	TextAlignment alignment = SCI_TEXT16_ALIGNMENT_LEFT;
 	int16 colorPen = -1, colorBack = -1, width = -1, bRedraw = 1;
 	bool doSaveUnder = false;
 	Common::Rect rect;
@@ -182,7 +182,7 @@
 			argc--; argv++;
 			break;
 		case SCI_DISPLAY_SETFONT:
-			_text->SetFont(argv[0].toUint16());
+			_text16->SetFont(argv[0].toUint16());
 			argc--; argv++;
 			break;
 		case SCI_DISPLAY_WIDTH:
@@ -210,7 +210,7 @@
 	}
 
 	// now drawing the text
-	_text->Size(rect, text, -1, width);
+	_text16->Size(rect, text, -1, width);
 	rect.moveTo(_ports->getPort()->curLeft, _ports->getPort()->curTop);
 	if (getSciVersion() >= SCI_VERSION_1_LATE) {
 		int16 leftPos = rect.right <= _screen->getWidth() ? 0 : _screen->getWidth() - rect.right;
@@ -223,7 +223,7 @@
 		_s->r_acc = _paint16->bitsSave(rect, SCI_SCREEN_MASK_VISUAL);
 	if (colorBack != -1)
 		_paint16->fillRect(rect, SCI_SCREEN_MASK_VISUAL, colorBack, 0, 0);
-	_text->Box(text, 0, rect, alignment, -1);
+	_text16->Box(text, 0, rect, alignment, -1);
 	if (_screen->_picNotValid == 0 && bRedraw)
 		_paint16->bitsShow(rect);
 	// restoring port and cursor pos
@@ -237,19 +237,19 @@
 
 void SciGui::textSize(const char *text, int16 font, int16 maxWidth, int16 *textWidth, int16 *textHeight) {
 	Common::Rect rect(0, 0, *textWidth, *textHeight);
-	_text->Size(rect, text, font, maxWidth);
+	_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) {
-	_text->CodeSetFonts(argc, argv);
+	_text16->CodeSetFonts(argc, argv);
 }
 
 // Used SCI1+ for text codes
 void SciGui::textColors(int argc, reg_t *argv) {
-	_text->CodeSetColors(argc, argv);
+	_text16->CodeSetColors(argc, argv);
 }
 
 void SciGui::drawStatus(const char *text, int16 colorPen, int16 colorBack) {
@@ -258,7 +258,7 @@
 	_paint16->fillRect(_ports->_menuBarRect, 1, colorBack);
 	_ports->penColor(colorPen);
 	_ports->moveTo(0, 1);
-	_text->Draw_String(text);
+	_text16->Draw_String(text);
 	_paint16->bitsShow(_ports->_menuBarRect);
 	_ports->setPort(oldPort);
 }
@@ -276,7 +276,7 @@
 
 void SciGui::menuReset() {
 	delete _menu;
-	_menu = new Menu(_s->_event, _s->_segMan, this, _ports, _paint16, _text, _screen, _cursor);
+	_menu = new Menu(_s->_event, _s->_segMan, this, _ports, _paint16, _text16, _screen, _cursor);
 }
 
 void SciGui::menuAdd(Common::String title, Common::String content, reg_t contentVmPtr) {
@@ -333,7 +333,7 @@
 		_paint16->frameRect(rect);
 		rect.grow(-2);
 		_ports->textGreyedOutput(style & 1 ? false : true);
-		_text->Box(text, 0, rect, SCI_TEXT_ALIGNMENT_CENTER, fontId);
+		_text16->Box(text, 0, rect, SCI_TEXT16_ALIGNMENT_CENTER, fontId);
 		_ports->textGreyedOutput(false);
 		rect.grow(1);
 		if (style & 8) // selected
@@ -353,7 +353,7 @@
 		rect.grow(1);
 		_paint16->eraseRect(rect);
 		rect.grow(-1);
-		_text->Box(text, 0, rect, alignment, fontId);
+		_text16->Box(text, 0, rect, alignment, fontId);
 		if (style & 8) { // selected
 			_paint16->frameRect(rect);
 		}
@@ -368,18 +368,18 @@
 
 void SciGui::drawControlTextEdit(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 mode, int16 style, int16 cursorPos, int16 maxChars, bool hilite) {
 	Common::Rect textRect = rect;
-	uint16 oldFontId = _text->GetFontId();
+	uint16 oldFontId = _text16->GetFontId();
 
 	rect.grow(1);
 	_controls->TexteditCursorErase();
 	_paint16->eraseRect(rect);
-	_text->Box(text, 0, textRect, SCI_TEXT_ALIGNMENT_LEFT, fontId);
+	_text16->Box(text, 0, textRect, SCI_TEXT16_ALIGNMENT_LEFT, fontId);
 	_paint16->frameRect(rect);
 	if (style & 8) {
-		_text->SetFont(fontId);
+		_text16->SetFont(fontId);
 		rect.grow(-1);
 		_controls->TexteditCursorDraw(rect, text, cursorPos);
-		_text->SetFont(oldFontId);
+		_text16->SetFont(oldFontId);
 		rect.grow(1);
 	}
 	if (!getControlPicNotValid())

Modified: scummvm/trunk/engines/sci/graphics/gui.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/gui.h	2010-01-31 21:31:11 UTC (rev 47779)
+++ scummvm/trunk/engines/sci/graphics/gui.h	2010-01-31 21:54:43 UTC (rev 47780)
@@ -52,7 +52,7 @@
 class SciGuiAnimate;
 class Controls;
 class Menu;
-class Text;
+class GfxText16;
 class Transitions;
 
 class SciGui {
@@ -160,7 +160,7 @@
 	GfxAnimate *_animate;
 	Controls *_controls;
 	Menu *_menu;
-	Text *_text;
+	GfxText16 *_text16;
 	Transitions *_transitions;
 	int16 _palVaryId;
 	uint32 _palVaryStart;

Modified: scummvm/trunk/engines/sci/graphics/gui32.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/gui32.cpp	2010-01-31 21:31:11 UTC (rev 47779)
+++ scummvm/trunk/engines/sci/graphics/gui32.cpp	2010-01-31 21:54:43 UTC (rev 47780)
@@ -39,7 +39,6 @@
 #include "sci/graphics/compare.h"
 #include "sci/graphics/picture.h"
 #include "sci/graphics/robot.h"
-#include "sci/graphics/text.h"
 #include "sci/graphics/view.h"
 
 namespace Sci {

Modified: scummvm/trunk/engines/sci/graphics/menu.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/menu.cpp	2010-01-31 21:31:11 UTC (rev 47779)
+++ scummvm/trunk/engines/sci/graphics/menu.cpp	2010-01-31 21:54:43 UTC (rev 47780)
@@ -37,14 +37,14 @@
 #include "sci/graphics/animate.h"
 #include "sci/graphics/cursor.h"
 #include "sci/graphics/font.h"
-#include "sci/graphics/text.h"
+#include "sci/graphics/text16.h"
 #include "sci/graphics/screen.h"
 #include "sci/graphics/menu.h"
 
 namespace Sci {
 
-Menu::Menu(SciEvent *event, SegManager *segMan, SciGui *gui, GfxPorts *ports, GfxPaint16 *paint16, Text *text, GfxScreen *screen, Cursor *cursor)
-	: _event(event), _segMan(segMan), _gui(gui), _ports(ports), _paint16(paint16), _text(text), _screen(screen), _cursor(cursor) {
+Menu::Menu(SciEvent *event, SegManager *segMan, SciGui *gui, GfxPorts *ports, GfxPaint16 *paint16, GfxText16 *text16, GfxScreen *screen, Cursor *cursor)
+	: _event(event), _segMan(segMan), _gui(gui), _ports(ports), _paint16(paint16), _text16(text16), _screen(screen), _cursor(cursor) {
 
 	_listCount = 0;
 	// We actually set active item in here and remember last selection of the user
@@ -311,7 +311,7 @@
 	listIterator = _list.begin();
 	while (listIterator != listEnd) {
 		listEntry = *listIterator;
-		_text->Draw_String(listEntry->text.c_str());
+		_text16->Draw_String(listEntry->text.c_str());
 
 		listIterator++;
 	}
@@ -330,7 +330,7 @@
 	menuIterator = _list.begin();
 	while (menuIterator != menuEnd) {
 		menuEntry = *menuIterator;
-		_text->StringWidth(menuEntry->text.c_str(), 0, menuEntry->textWidth, dummyHeight);
+		_text16->StringWidth(menuEntry->text.c_str(), 0, menuEntry->textWidth, dummyHeight);
 
 		menuIterator++;
 	}
@@ -338,8 +338,8 @@
 	itemIterator = _itemList.begin();
 	while (itemIterator != itemEnd) {
 		itemEntry = *itemIterator;
-		_text->StringWidth(itemEntry->text.c_str(), 0, itemEntry->textWidth, dummyHeight);
-		_text->StringWidth(itemEntry->textRightAligned.c_str(), 0, itemEntry->textRightAlignedWidth, dummyHeight);
+		_text16->StringWidth(itemEntry->text.c_str(), 0, itemEntry->textWidth, dummyHeight);
+		_text16->StringWidth(itemEntry->textRightAligned.c_str(), 0, itemEntry->textRightAlignedWidth, dummyHeight);
 
 		itemIterator++;
 	}
@@ -542,9 +542,9 @@
 			if (!listItemEntry->separatorLine) {
 				_ports->textGreyedOutput(listItemEntry->enabled ? false : true);
 				_ports->moveTo(_menuRect.left, topPos);
-				_text->Draw_String(listItemEntry->text.c_str());
+				_text16->Draw_String(listItemEntry->text.c_str());
 				_ports->moveTo(_menuRect.right - listItemEntry->textRightAlignedWidth - 5, topPos);
-				_text->Draw_String(listItemEntry->textRightAligned.c_str());
+				_text16->Draw_String(listItemEntry->textRightAligned.c_str());
 			} else {
 				// We dont 100% follow sierra here, we draw the line from left to right. Looks better
 				// BTW. SCI1.1 seems to put 2 pixels and then skip one, we don't do this at all (lsl6)

Modified: scummvm/trunk/engines/sci/graphics/menu.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/menu.h	2010-01-31 21:31:11 UTC (rev 47779)
+++ scummvm/trunk/engines/sci/graphics/menu.h	2010-01-31 21:54:43 UTC (rev 47780)
@@ -78,7 +78,7 @@
 
 class Menu {
 public:
-	Menu(SciEvent *event, SegManager *segMan, SciGui *gui, GfxPorts *ports, GfxPaint16 *paint16, Text *text, GfxScreen *screen, Cursor *cursor);
+	Menu(SciEvent *event, SegManager *segMan, SciGui *gui, GfxPorts *ports, GfxPaint16 *paint16, GfxText16 *text16, GfxScreen *screen, Cursor *cursor);
 	~Menu();
 
 	void reset();
@@ -107,7 +107,7 @@
 	SciGui *_gui;
 	GfxPorts *_ports;
 	GfxPaint16 *_paint16;
-	Text *_text;
+	GfxText16 *_text16;
 	GfxScreen *_screen;
 	Cursor *_cursor;
 

Modified: scummvm/trunk/engines/sci/graphics/paint16.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/paint16.cpp	2010-01-31 21:31:11 UTC (rev 47779)
+++ scummvm/trunk/engines/sci/graphics/paint16.cpp	2010-01-31 21:54:43 UTC (rev 47780)
@@ -39,7 +39,7 @@
 #include "sci/graphics/view.h"
 #include "sci/graphics/screen.h"
 #include "sci/graphics/palette.h"
-#include "sci/graphics/text.h"
+#include "sci/graphics/text16.h"
 
 namespace Sci {
 
@@ -50,8 +50,8 @@
 GfxPaint16::~GfxPaint16() {
 }
 
-void GfxPaint16::init(Text *text) {
-	_text = text;
+void GfxPaint16::init(GfxText16 *text16) {
+	_text16 = text16;
 
 	_EGAdrawingVisualize = false;
 }

Modified: scummvm/trunk/engines/sci/graphics/paint16.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/paint16.h	2010-01-31 21:31:11 UTC (rev 47779)
+++ scummvm/trunk/engines/sci/graphics/paint16.h	2010-01-31 21:54:43 UTC (rev 47780)
@@ -44,7 +44,7 @@
 	GfxPaint16(ResourceManager *resMan, SegManager *segMan, Kernel *kernel, GfxCache *cache, GfxPorts *ports, GfxScreen *screen, GfxPalette *palette);
 	~GfxPaint16();
 
-	void init(Text *text);
+	void init(GfxText16 *text16);
 
 	void setEGAdrawingVisualize(bool state);
 
@@ -76,7 +76,7 @@
 	GfxPorts *_ports;
 	GfxScreen *_screen;
 	GfxPalette *_palette;
-	Text *_text;
+	GfxText16 *_text16;
 
 	// true means make EGA picture drawing visible
 	bool _EGAdrawingVisualize;

Modified: scummvm/trunk/engines/sci/graphics/ports.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/ports.cpp	2010-01-31 21:31:11 UTC (rev 47779)
+++ scummvm/trunk/engines/sci/graphics/ports.cpp	2010-01-31 21:54:43 UTC (rev 47780)
@@ -30,7 +30,7 @@
 #include "sci/graphics/screen.h"
 #include "sci/graphics/paint16.h"
 #include "sci/graphics/animate.h"
-#include "sci/graphics/text.h"
+#include "sci/graphics/text16.h"
 #include "sci/graphics/ports.h"
 
 namespace Sci {
@@ -54,12 +54,12 @@
 	delete _menuPort;
 }
 
-void GfxPorts::init(SciGui *gui, GfxPaint16 *paint16, Text *text, Common::String gameId) {
+void GfxPorts::init(SciGui *gui, GfxPaint16 *paint16, GfxText16 *text16, Common::String gameId) {
 	int16 offTop = 10;
 
 	_gui = gui;
 	_paint16 = paint16;
-	_text = text;
+	_text16 = text16;
 
 	// _mainPort is not known to windowmanager, that's okay according to sierra sci
 	//  its not even used currently in our engine
@@ -70,7 +70,7 @@
 	// _menuPort has actually hardcoded id 0xFFFF. Its not meant to be known to windowmanager according to sierra sci
 	_menuPort = new Port(0xFFFF);
 	openPort(_menuPort);
-	_text->SetFont(0);
+	_text16->SetFont(0);
 	_menuPort->rect = Common::Rect(0, 0, _screen->getWidth(), _screen->getHeight());
 	_menuBarRect = Common::Rect(0, 0, _screen->getWidth(), 9);
 	_menuRect = Common::Rect(0, 0, _screen->getWidth(), 10);
@@ -312,7 +312,7 @@
 				if (!pWnd->title.empty()) {
 					int16 oldcolor = getPort()->penClr;
 					penColor(255);
-					_text->Box(pWnd->title.c_str(), 1, r, SCI_TEXT_ALIGNMENT_CENTER, 0);
+					_text16->Box(pWnd->title.c_str(), 1, r, SCI_TEXT16_ALIGNMENT_CENTER, 0);
 					penColor(oldcolor);
 				}
 
@@ -399,7 +399,7 @@
 
 	Port *tmp = _curPort;
 	_curPort = port;
-	_text->SetFont(port->fontId);
+	_text16->SetFont(port->fontId);
 	_curPort = tmp;
 
 	port->top = 0;

Modified: scummvm/trunk/engines/sci/graphics/ports.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/ports.h	2010-01-31 21:31:11 UTC (rev 47779)
+++ scummvm/trunk/engines/sci/graphics/ports.h	2010-01-31 21:54:43 UTC (rev 47780)
@@ -33,15 +33,15 @@
 
 class SciGui;
 class GfxPaint16;
-class Screen;
-class Text;
+class GfxScreen;
+class GfxText16;
 
 class GfxPorts {
 public:
 	GfxPorts(SegManager *segMan, GfxScreen *screen);
 	~GfxPorts();
 
-	void init(SciGui *gui, GfxPaint16 *paint16, Text *text, Common::String gameId);
+	void init(SciGui *gui, GfxPaint16 *paint16, GfxText16 *text16, Common::String gameId);
 
 	void kernelSetActive(uint16 portId);
 	Common::Rect kernelGetPicWindow(int16 &picTop, int16 &picLeft);
@@ -98,7 +98,7 @@
 	SciGui *_gui;
 	GfxPaint16 *_paint16;
 	GfxScreen *_screen;
-	Text *_text;
+	GfxText16 *_text16;
 
 	/** The list of open 'windows' (and ports), in visual order. */
 	PortList _windowList;

Deleted: scummvm/trunk/engines/sci/graphics/text.cpp
===================================================================
--- scummvm/trunk/engines/sci/graphics/text.cpp	2010-01-31 21:31:11 UTC (rev 47779)
+++ scummvm/trunk/engines/sci/graphics/text.cpp	2010-01-31 21:54:43 UTC (rev 47780)
@@ -1,394 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "common/util.h"
-#include "common/stack.h"
-#include "graphics/primitives.h"
-
-#include "sci/sci.h"
-#include "sci/engine/state.h"
-#include "sci/graphics/cache.h"
-#include "sci/graphics/ports.h"
-#include "sci/graphics/paint16.h"
-#include "sci/graphics/font.h"
-#include "sci/graphics/text.h"
-
-namespace Sci {
-
-Text::Text(ResourceManager *resMan, GfxCache *cache, GfxPorts *ports, GfxPaint16 *paint16, GfxScreen *screen)
-	: _resMan(resMan), _cache(cache), _ports(ports), _paint16(paint16), _screen(screen) {
-	init();
-}
-
-Text::~Text() {
-}
-
-void Text::init() {
-	_font = NULL;
-	_codeFonts = NULL;
-	_codeFontsCount = 0;
-	_codeColors = NULL;
-	_codeColorsCount = 0;
-}
-
-GuiResourceId Text::GetFontId() {
-	return _ports->_curPort->fontId;
-}
-
-Font *Text::GetFont() {
-	if ((_font == NULL) || (_font->getResourceId() != _ports->_curPort->fontId))
-		_font = _cache->getFont(_ports->_curPort->fontId);
-
-	return _font;
-}
-
-void Text::SetFont(GuiResourceId fontId) {
-	if ((_font == NULL) || (_font->getResourceId() != fontId))
-		_font = _cache->getFont(fontId);
-
-	_ports->_curPort->fontId = _font->getResourceId();
-	_ports->_curPort->fontHeight = _font->getHeight();
-}
-
-void Text::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 Text::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 Text::ClearChar(int16 chr) {
-	if (_ports->_curPort->penMode != 1)
-		return;
-	Common::Rect rect;
-	rect.top = _ports->_curPort->curTop;
-	rect.bottom = rect.top + _ports->_curPort->fontHeight;
-	rect.left = _ports->_curPort->curLeft;
-	rect.right = rect.left + GetFont()->getCharWidth(chr);
-	_paint16->eraseRect(rect);
-}
-
-// This internal function gets called as soon as a '|' is found in a text
-//  It will process the encountered code and set new font/set color
-//  We only support one-digit codes currently, don't know if multi-digit codes are possible
-//  Returns textcode character count
-int16 Text::CodeProcessing(const char *&text, GuiResourceId orgFontId, int16 orgPenColor) {
-	const char *textCode = text;
-	int16 textCodeSize = 0;
-	char curCode;
-	unsigned char curCodeParm;
-
-	// Find the end of the textcode
-	while ((++textCodeSize) && (*text != 0) && (*text++ != 0x7C)) { }
-
-	// possible TextCodes:
-	//  c -> sets textColor to current port pen color
-	//  cX -> sets textColor to _textColors[X-1]
-	curCode = textCode[0];
-	curCodeParm = textCode[1];
-	if (isdigit(curCodeParm)) {
-		curCodeParm -= '0';
-	} else {
-		curCodeParm = 0;
-	}
-	switch (curCode) {
-	case 'c': // set text color
-		if (curCodeParm == 0) {
-			_ports->_curPort->penClr = orgPenColor;
-		} else {
-			if (curCodeParm < _codeColorsCount) {
-				_ports->_curPort->penClr = _codeColors[curCodeParm];
-			}
-		}
-		break;
-	case 'f':
-		if (curCodeParm == 0) {
-			SetFont(orgFontId);
-		} else {
-			if (curCodeParm < _codeFontsCount) {
-				SetFont(_codeFonts[curCodeParm]);
-			}
-		}
-		break;
-	}
-	return textCodeSize;
-}
-
-// return max # of chars to fit maxwidth with full words
-int16 Text::GetLongest(const char *text, int16 maxWidth, GuiResourceId orgFontId) {
-	char curChar;
-	int16 maxChars = 0, curCharCount = 0;
-	uint16 width = 0;
-	GuiResourceId oldFontId = GetFontId();
-	int16 oldPenColor = _ports->_curPort->penClr;
-
-	GetFont();
-	if (!_font)
-		return 0;
-
-	while (width <= maxWidth) {
-		curChar = *text++;
-		switch (curChar) {
-		case 0x7C:
-			if (getSciVersion() >= SCI_VERSION_1_1) {
-				curCharCount++;
-				curCharCount += CodeProcessing(text, orgFontId, oldPenColor);
-				continue;
-			}
-			break;
-
-		case 0xD:
-			curCharCount++;
-			continue;
-
-		case 0xA:
-			curCharCount++;
-		case 0:
-			SetFont(oldFontId);
-			_ports->penColor(oldPenColor);
-			return curCharCount;
-
-		case ' ':
-			maxChars = curCharCount + 1;
-			break;
-		}
-		width += _font->getCharWidth(curChar);
-		curCharCount++;
-	}
-	SetFont(oldFontId);
-	_ports->penColor(oldPenColor);
-	return maxChars;
-}
-
-void Text::Width(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight) {
-	unsigned char curChar;
-	GuiResourceId oldFontId = GetFontId();
-	int16 oldPenColor = _ports->_curPort->penClr;
-
-	textWidth = 0; textHeight = 0;
-
-	GetFont();
-	if (_font) {
-		text += from;
-		while (len--) {
-			curChar = *text++;
-			switch (curChar) {
-			case 0x0A:
-			case 0x0D:
-				textHeight = MAX<int16> (textHeight, _ports->_curPort->fontHeight);
-				break;
-			case 0x7C:
-				if (getSciVersion() >= SCI_VERSION_1_1) {
-					len -= CodeProcessing(text, orgFontId, 0);
-					break;
-				}
-			default:
-				textHeight = MAX<int16> (textHeight, _ports->_curPort->fontHeight);
-				textWidth += _font->getCharWidth(curChar);
-			}
-		}
-	}
-	SetFont(oldFontId);
-	_ports->penColor(oldPenColor);
-	return;
-}
-
-void Text::StringWidth(const char *str, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight) {
-	Width(str, 0, (int16)strlen(str), orgFontId, textWidth, textHeight);
-}
-
-void Text::ShowString(const char *str, GuiResourceId orgFontId, int16 orgPenColor) {
-	Show(str, 0, (int16)strlen(str), orgFontId, orgPenColor);
-}
-void Text::DrawString(const char *str, GuiResourceId orgFontId, int16 orgPenColor) {
-	Draw(str, 0, (int16)strlen(str), orgFontId, orgPenColor);
-}
-
-int16 Text::Size(Common::Rect &rect, const char *str, GuiResourceId fontId, int16 maxWidth) {
-	GuiResourceId oldFontId = GetFontId();
-	int16 oldPenColor = _ports->_curPort->penClr;
-	int16 charCount;
-	int16 maxTextWidth = 0, textWidth;
-	int16 totalHeight = 0, textHeight;
-
-	if (fontId != -1)
-		SetFont(fontId);
-	rect.top = rect.left = 0;
-
-	if (maxWidth < 0) { // force output as single line
-		StringWidth(str, oldFontId, textWidth, textHeight);
-		rect.bottom = textHeight;
-		rect.right = textWidth;
-	} else {
-		// rect.right=found widest line with RTextWidth and GetLongest
-		// rect.bottom=num. lines * GetPointSize
-		rect.right = (maxWidth ? maxWidth : 192);
-		const char*p = str;
-		while (*p) {
-			//if (*p == 0xD || *p == 0xA) {
-			//	p++;
-			//	continue;
-			//}
-			charCount = GetLongest(p, rect.right, oldFontId);
-			if (charCount == 0)
-				break;
-			Width(p, 0, charCount, oldFontId, textWidth, textHeight);
-			maxTextWidth = MAX(textWidth, maxTextWidth);
-			totalHeight += textHeight;
-			p += charCount;
-		}
-		rect.bottom = totalHeight;
-		rect.right = maxWidth ? maxWidth : MIN(rect.right, maxTextWidth);
-	}
-	SetFont(oldFontId);
-	_ports->penColor(oldPenColor);
-	return rect.right;
-}
-
-// returns maximum font height used
-void Text::Draw(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 orgPenColor) {
-	int16 curChar, charWidth;
-	Common::Rect rect;
-
-	GetFont();
-	if (!_font)
-		return;
-
-	rect.top = _ports->_curPort->curTop;
-	rect.bottom = rect.top + _ports->_curPort->fontHeight;
-	text += from;
-	while (len--) {
-		curChar = (*text++);
-		switch (curChar) {
-		case 0x0A:
-		case 0x0D:
-		case 0:
-			break;
-		case 0x7C:
-			if (getSciVersion() >= SCI_VERSION_1_1) {
-				len -= CodeProcessing(text, orgFontId, orgPenColor);
-				break;
-			}
-		default:
-			charWidth = _font->getCharWidth(curChar);
-			// clear char
-			if (_ports->_curPort->penMode == 1) {
-				rect.left = _ports->_curPort->curLeft;
-				rect.right = rect.left + charWidth;
-				_paint16->eraseRect(rect);
-			}
-			// CharStd
-			_font->draw(curChar, _ports->_curPort->top + _ports->_curPort->curTop, _ports->_curPort->left + _ports->_curPort->curLeft, _ports->_curPort->penClr, _ports->_curPort->greyedOutput);
-			_ports->_curPort->curLeft += charWidth;
-		}
-	}
-}
-
-// returns maximum font height used
-void Text::Show(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 orgPenColor) {
-	Common::Rect rect;
-
-	rect.top = _ports->_curPort->curTop;
-	rect.bottom = rect.top + _ports->getPointSize();
-	rect.left = _ports->_curPort->curLeft;
-	Draw(text, from, len, orgFontId, orgPenColor);
-	rect.right = _ports->_curPort->curLeft;
-	_paint16->bitsShow(rect);
-}
-
-// Draws a text in rect.
-void Text::Box(const char *text, int16 bshow, const Common::Rect &rect, TextAlignment alignment, GuiResourceId fontId) {
-	int16 textWidth, textHeight, charCount;
-	int16 offset = 0;
-	int16 hline = 0;
-	GuiResourceId orgFontId = GetFontId();
-	int16 orgPenColor = _ports->_curPort->penClr;
-
-	if (fontId != -1)
-		SetFont(fontId);
-
-	while (*text) {
-//		if (*text == 0xD || *text == 0xA) {
-//			text++;
-//			continue;
-//		}
-		charCount = GetLongest(text, rect.width(), orgFontId);
-		if (charCount == 0)
-			break;
-		Width(text, 0, charCount, orgFontId, textWidth, textHeight);
-		switch (alignment) {
-		case SCI_TEXT_ALIGNMENT_RIGHT:
-			offset = rect.width() - textWidth;
-			break;
-		case SCI_TEXT_ALIGNMENT_CENTER:
-			offset = (rect.width() - textWidth) / 2;
-			break;
-		case SCI_TEXT_ALIGNMENT_LEFT:
-			offset = 0;
-			break;
-
-		default: // left-aligned
-			warning("Invalid alignment %d used in TextBox()", alignment);
-		}
-		_ports->moveTo(rect.left + offset, rect.top + hline);
-
-		if (bshow) {
-			Show(text, 0, charCount, orgFontId, orgPenColor);
-		} else {
-			Draw(text, 0, charCount, orgFontId, orgPenColor);
-		}
-
-		hline += textHeight;
-		text += charCount;
-	}
-	SetFont(orgFontId);
-	_ports->penColor(orgPenColor);
-}
-
-void Text::Draw_String(const char *text) {
-	GuiResourceId orgFontId = GetFontId();
-	int16 orgPenColor = _ports->_curPort->penClr;
-
-	Draw(text, 0, strlen(text), orgFontId, orgPenColor);
-	SetFont(orgFontId);
-	_ports->penColor(orgPenColor);
-}
-
-} // End of namespace Sci

Deleted: scummvm/trunk/engines/sci/graphics/text.h
===================================================================
--- scummvm/trunk/engines/sci/graphics/text.h	2010-01-31 21:31:11 UTC (rev 47779)
+++ scummvm/trunk/engines/sci/graphics/text.h	2010-01-31 21:54:43 UTC (rev 47780)
@@ -1,84 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#ifndef SCI_GRAPHICS_TEXT_H
-#define SCI_GRAPHICS_TEXT_H
-
-namespace Sci {
-
-#define SCI_TEXT_ALIGNMENT_RIGHT -1
-#define SCI_TEXT_ALIGNMENT_CENTER 1
-#define SCI_TEXT_ALIGNMENT_LEFT	0
-
-class GfxPorts;
-class GfxPaint16;
-class Screen;
-class Font;
-class Text {
-public:
-	Text(ResourceManager *_resMan, GfxCache *fonts, GfxPorts *ports, GfxPaint16 *paint16, GfxScreen *screen);
-	~Text();
-
-	GuiResourceId GetFontId();
-	Font *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);
-
-	int16 GetLongest(const char *text, int16 maxWidth, GuiResourceId orgFontId);
-	void Width(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight);
-	void StringWidth(const char *str, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight);
-	void ShowString(const char *str, GuiResourceId orgFontId, int16 orgPenColor);
-	void DrawString(const char *str, GuiResourceId orgFontId, int16 orgPenColor);
-	int16 Size(Common::Rect &rect, const char *str, GuiResourceId fontId, int16 maxWidth);
-	void Draw(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 orgPenColor);
-	void Show(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 orgPenColor);
-	void Box(const char *text, int16 bshow, const Common::Rect &rect, TextAlignment alignment, GuiResourceId fontId);
-	void Draw_String(const char *text);
-
-	Font *_font;
-
-private:
-	void init();
-
-	ResourceManager *_resMan;
-	GfxCache *_cache;
-	GfxPorts *_ports;
-	GfxPaint16 *_paint16;
-	GfxScreen *_screen;
-
-	int _codeFontsCount;
-	GuiResourceId *_codeFonts;
-	int _codeColorsCount;
-	uint16 *_codeColors;
-};
-
-} // End of namespace Sci
-
-#endif

Copied: scummvm/trunk/engines/sci/graphics/text16.cpp (from rev 47779, scummvm/trunk/engines/sci/graphics/text.cpp)
===================================================================
--- scummvm/trunk/engines/sci/graphics/text16.cpp	                        (rev 0)
+++ scummvm/trunk/engines/sci/graphics/text16.cpp	2010-01-31 21:54:43 UTC (rev 47780)
@@ -0,0 +1,394 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/util.h"
+#include "common/stack.h"
+#include "graphics/primitives.h"
+
+#include "sci/sci.h"
+#include "sci/engine/state.h"
+#include "sci/graphics/cache.h"
+#include "sci/graphics/ports.h"
+#include "sci/graphics/paint16.h"
+#include "sci/graphics/font.h"
+#include "sci/graphics/text16.h"
+
+namespace Sci {
+
+GfxText16::GfxText16(ResourceManager *resMan, GfxCache *cache, GfxPorts *ports, GfxPaint16 *paint16, GfxScreen *screen)
+	: _resMan(resMan), _cache(cache), _ports(ports), _paint16(paint16), _screen(screen) {
+	init();
+}
+
+GfxText16::~GfxText16() {
+}
+
+void GfxText16::init() {
+	_font = NULL;
+	_codeFonts = NULL;
+	_codeFontsCount = 0;
+	_codeColors = NULL;
+	_codeColorsCount = 0;
+}
+
+GuiResourceId GfxText16::GetFontId() {
+	return _ports->_curPort->fontId;
+}
+
+Font *GfxText16::GetFont() {
+	if ((_font == NULL) || (_font->getResourceId() != _ports->_curPort->fontId))
+		_font = _cache->getFont(_ports->_curPort->fontId);
+
+	return _font;
+}
+
+void GfxText16::SetFont(GuiResourceId fontId) {
+	if ((_font == NULL) || (_font->getResourceId() != fontId))
+		_font = _cache->getFont(fontId);
+
+	_ports->_curPort->fontId = _font->getResourceId();
+	_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;
+	Common::Rect rect;
+	rect.top = _ports->_curPort->curTop;
+	rect.bottom = rect.top + _ports->_curPort->fontHeight;
+	rect.left = _ports->_curPort->curLeft;
+	rect.right = rect.left + GetFont()->getCharWidth(chr);
+	_paint16->eraseRect(rect);
+}
+
+// This internal function gets called as soon as a '|' is found in a text
+//  It will process the encountered code and set new font/set color
+//  We only support one-digit codes currently, don't know if multi-digit codes are possible
+//  Returns textcode character count
+int16 GfxText16::CodeProcessing(const char *&text, GuiResourceId orgFontId, int16 orgPenColor) {
+	const char *textCode = text;
+	int16 textCodeSize = 0;
+	char curCode;
+	unsigned char curCodeParm;
+
+	// Find the end of the textcode
+	while ((++textCodeSize) && (*text != 0) && (*text++ != 0x7C)) { }
+
+	// possible TextCodes:
+	//  c -> sets textColor to current port pen color
+	//  cX -> sets textColor to _textColors[X-1]
+	curCode = textCode[0];
+	curCodeParm = textCode[1];
+	if (isdigit(curCodeParm)) {
+		curCodeParm -= '0';
+	} else {
+		curCodeParm = 0;
+	}
+	switch (curCode) {
+	case 'c': // set text color
+		if (curCodeParm == 0) {
+			_ports->_curPort->penClr = orgPenColor;
+		} else {
+			if (curCodeParm < _codeColorsCount) {
+				_ports->_curPort->penClr = _codeColors[curCodeParm];
+			}
+		}
+		break;
+	case 'f':
+		if (curCodeParm == 0) {
+			SetFont(orgFontId);
+		} else {
+			if (curCodeParm < _codeFontsCount) {
+				SetFont(_codeFonts[curCodeParm]);
+			}
+		}
+		break;
+	}
+	return textCodeSize;
+}
+
+// return max # of chars to fit maxwidth with full words
+int16 GfxText16::GetLongest(const char *text, int16 maxWidth, GuiResourceId orgFontId) {
+	char curChar;
+	int16 maxChars = 0, curCharCount = 0;
+	uint16 width = 0;
+	GuiResourceId oldFontId = GetFontId();
+	int16 oldPenColor = _ports->_curPort->penClr;
+
+	GetFont();
+	if (!_font)
+		return 0;
+
+	while (width <= maxWidth) {
+		curChar = *text++;
+		switch (curChar) {
+		case 0x7C:
+			if (getSciVersion() >= SCI_VERSION_1_1) {
+				curCharCount++;
+				curCharCount += CodeProcessing(text, orgFontId, oldPenColor);
+				continue;
+			}
+			break;
+
+		case 0xD:
+			curCharCount++;
+			continue;
+
+		case 0xA:
+			curCharCount++;
+		case 0:
+			SetFont(oldFontId);
+			_ports->penColor(oldPenColor);
+			return curCharCount;
+
+		case ' ':
+			maxChars = curCharCount + 1;
+			break;
+		}
+		width += _font->getCharWidth(curChar);
+		curCharCount++;
+	}
+	SetFont(oldFontId);
+	_ports->penColor(oldPenColor);
+	return maxChars;
+}
+
+void GfxText16::Width(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight) {
+	unsigned char curChar;
+	GuiResourceId oldFontId = GetFontId();
+	int16 oldPenColor = _ports->_curPort->penClr;
+
+	textWidth = 0; textHeight = 0;
+
+	GetFont();
+	if (_font) {
+		text += from;
+		while (len--) {
+			curChar = *text++;
+			switch (curChar) {
+			case 0x0A:
+			case 0x0D:
+				textHeight = MAX<int16> (textHeight, _ports->_curPort->fontHeight);
+				break;
+			case 0x7C:
+				if (getSciVersion() >= SCI_VERSION_1_1) {
+					len -= CodeProcessing(text, orgFontId, 0);
+					break;
+				}
+			default:
+				textHeight = MAX<int16> (textHeight, _ports->_curPort->fontHeight);
+				textWidth += _font->getCharWidth(curChar);
+			}
+		}
+	}
+	SetFont(oldFontId);
+	_ports->penColor(oldPenColor);
+	return;
+}
+
+void GfxText16::StringWidth(const char *str, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight) {
+	Width(str, 0, (int16)strlen(str), orgFontId, textWidth, textHeight);
+}
+
+void GfxText16::ShowString(const char *str, GuiResourceId orgFontId, int16 orgPenColor) {
+	Show(str, 0, (int16)strlen(str), orgFontId, orgPenColor);
+}
+void GfxText16::DrawString(const char *str, GuiResourceId orgFontId, int16 orgPenColor) {
+	Draw(str, 0, (int16)strlen(str), orgFontId, orgPenColor);
+}
+
+int16 GfxText16::Size(Common::Rect &rect, const char *str, GuiResourceId fontId, int16 maxWidth) {
+	GuiResourceId oldFontId = GetFontId();
+	int16 oldPenColor = _ports->_curPort->penClr;
+	int16 charCount;
+	int16 maxTextWidth = 0, textWidth;
+	int16 totalHeight = 0, textHeight;
+
+	if (fontId != -1)
+		SetFont(fontId);
+	rect.top = rect.left = 0;
+
+	if (maxWidth < 0) { // force output as single line
+		StringWidth(str, oldFontId, textWidth, textHeight);
+		rect.bottom = textHeight;
+		rect.right = textWidth;
+	} else {
+		// rect.right=found widest line with RTextWidth and GetLongest
+		// rect.bottom=num. lines * GetPointSize
+		rect.right = (maxWidth ? maxWidth : 192);
+		const char*p = str;
+		while (*p) {
+			//if (*p == 0xD || *p == 0xA) {
+			//	p++;
+			//	continue;
+			//}
+			charCount = GetLongest(p, rect.right, oldFontId);
+			if (charCount == 0)
+				break;
+			Width(p, 0, charCount, oldFontId, textWidth, textHeight);
+			maxTextWidth = MAX(textWidth, maxTextWidth);
+			totalHeight += textHeight;
+			p += charCount;
+		}
+		rect.bottom = totalHeight;
+		rect.right = maxWidth ? maxWidth : MIN(rect.right, maxTextWidth);
+	}
+	SetFont(oldFontId);
+	_ports->penColor(oldPenColor);
+	return rect.right;
+}
+
+// returns maximum font height used
+void GfxText16::Draw(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 orgPenColor) {
+	int16 curChar, charWidth;
+	Common::Rect rect;
+
+	GetFont();
+	if (!_font)
+		return;
+
+	rect.top = _ports->_curPort->curTop;
+	rect.bottom = rect.top + _ports->_curPort->fontHeight;
+	text += from;
+	while (len--) {
+		curChar = (*text++);
+		switch (curChar) {
+		case 0x0A:
+		case 0x0D:
+		case 0:
+			break;
+		case 0x7C:
+			if (getSciVersion() >= SCI_VERSION_1_1) {
+				len -= CodeProcessing(text, orgFontId, orgPenColor);
+				break;
+			}
+		default:
+			charWidth = _font->getCharWidth(curChar);
+			// clear char
+			if (_ports->_curPort->penMode == 1) {
+				rect.left = _ports->_curPort->curLeft;
+				rect.right = rect.left + charWidth;
+				_paint16->eraseRect(rect);
+			}
+			// CharStd
+			_font->draw(curChar, _ports->_curPort->top + _ports->_curPort->curTop, _ports->_curPort->left + _ports->_curPort->curLeft, _ports->_curPort->penClr, _ports->_curPort->greyedOutput);
+			_ports->_curPort->curLeft += charWidth;
+		}
+	}
+}
+
+// returns maximum font height used
+void GfxText16::Show(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 orgPenColor) {
+	Common::Rect rect;
+
+	rect.top = _ports->_curPort->curTop;
+	rect.bottom = rect.top + _ports->getPointSize();
+	rect.left = _ports->_curPort->curLeft;
+	Draw(text, from, len, orgFontId, orgPenColor);
+	rect.right = _ports->_curPort->curLeft;
+	_paint16->bitsShow(rect);
+}
+
+// Draws a text in rect.
+void GfxText16::Box(const char *text, int16 bshow, const Common::Rect &rect, TextAlignment alignment, GuiResourceId fontId) {
+	int16 textWidth, textHeight, charCount;
+	int16 offset = 0;
+	int16 hline = 0;
+	GuiResourceId orgFontId = GetFontId();
+	int16 orgPenColor = _ports->_curPort->penClr;
+
+	if (fontId != -1)
+		SetFont(fontId);
+
+	while (*text) {
+//		if (*text == 0xD || *text == 0xA) {
+//			text++;
+//			continue;
+//		}
+		charCount = GetLongest(text, rect.width(), orgFontId);
+		if (charCount == 0)
+			break;
+		Width(text, 0, charCount, orgFontId, textWidth, textHeight);
+		switch (alignment) {
+		case SCI_TEXT16_ALIGNMENT_RIGHT:
+			offset = rect.width() - textWidth;
+			break;
+		case SCI_TEXT16_ALIGNMENT_CENTER:
+			offset = (rect.width() - textWidth) / 2;
+			break;
+		case SCI_TEXT16_ALIGNMENT_LEFT:
+			offset = 0;
+			break;
+
+		default: // left-aligned
+			warning("Invalid alignment %d used in TextBox()", alignment);
+		}
+		_ports->moveTo(rect.left + offset, rect.top + hline);
+
+		if (bshow) {
+			Show(text, 0, charCount, orgFontId, orgPenColor);
+		} else {
+			Draw(text, 0, charCount, orgFontId, orgPenColor);
+		}
+
+		hline += textHeight;
+		text += charCount;
+	}
+	SetFont(orgFontId);
+	_ports->penColor(orgPenColor);
+}
+
+void GfxText16::Draw_String(const char *text) {
+	GuiResourceId orgFontId = GetFontId();
+	int16 orgPenColor = _ports->_curPort->penClr;
+
+	Draw(text, 0, strlen(text), orgFontId, orgPenColor);
+	SetFont(orgFontId);
+	_ports->penColor(orgPenColor);
+}
+
+} // End of namespace Sci

Copied: scummvm/trunk/engines/sci/graphics/text16.h (from rev 47779, scummvm/trunk/engines/sci/graphics/text.h)
===================================================================
--- scummvm/trunk/engines/sci/graphics/text16.h	                        (rev 0)
+++ scummvm/trunk/engines/sci/graphics/text16.h	2010-01-31 21:54:43 UTC (rev 47780)
@@ -0,0 +1,84 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef SCI_GRAPHICS_TEXT16_H
+#define SCI_GRAPHICS_TEXT16_H
+
+namespace Sci {
+
+#define SCI_TEXT16_ALIGNMENT_RIGHT -1
+#define SCI_TEXT16_ALIGNMENT_CENTER 1
+#define SCI_TEXT16_ALIGNMENT_LEFT	0
+
+class GfxPorts;
+class GfxPaint16;
+class GfxScreen;
+class Font;
+class GfxText16 {
+public:
+	GfxText16(ResourceManager *_resMan, GfxCache *fonts, GfxPorts *ports, GfxPaint16 *paint16, GfxScreen *screen);
+	~GfxText16();
+
+	GuiResourceId GetFontId();
+	Font *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);
+
+	int16 GetLongest(const char *text, int16 maxWidth, GuiResourceId orgFontId);
+	void Width(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight);
+	void StringWidth(const char *str, GuiResourceId orgFontId, int16 &textWidth, int16 &textHeight);
+	void ShowString(const char *str, GuiResourceId orgFontId, int16 orgPenColor);
+	void DrawString(const char *str, GuiResourceId orgFontId, int16 orgPenColor);
+	int16 Size(Common::Rect &rect, const char *str, GuiResourceId fontId, int16 maxWidth);
+	void Draw(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 orgPenColor);
+	void Show(const char *text, int16 from, int16 len, GuiResourceId orgFontId, int16 orgPenColor);
+	void Box(const char *text, int16 bshow, const Common::Rect &rect, TextAlignment alignment, GuiResourceId fontId);
+	void Draw_String(const char *text);
+
+	Font *_font;
+
+private:
+	void init();
+
+	ResourceManager *_resMan;
+	GfxCache *_cache;
+	GfxPorts *_ports;
+	GfxPaint16 *_paint16;
+	GfxScreen *_screen;
+
+	int _codeFontsCount;
+	GuiResourceId *_codeFonts;
+	int _codeColorsCount;
+	uint16 *_codeColors;
+};
+
+} // End of namespace Sci
+
+#endif

Modified: scummvm/trunk/engines/sci/module.mk
===================================================================
--- scummvm/trunk/engines/sci/module.mk	2010-01-31 21:31:11 UTC (rev 47779)
+++ scummvm/trunk/engines/sci/module.mk	2010-01-31 21:54:43 UTC (rev 47780)
@@ -47,7 +47,7 @@
 	graphics/portrait.o \
 	graphics/ports.o \
 	graphics/screen.o \
-	graphics/text.o \
+	graphics/text16.o \
 	graphics/transitions.o \
 	graphics/view.o \
 	parser/grammar.o \


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list