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

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Sun Oct 4 07:22:49 CEST 2009


Revision: 44585
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44585&view=rev
Author:   m_kiewitz
Date:     2009-10-04 05:22:49 +0000 (Sun, 04 Oct 2009)

Log Message:
-----------
SCI/newgui: unfinished TextColors/TextFonts support/setting default palette mapping for kq5

Modified Paths:
--------------
    scummvm/trunk/engines/sci/gui/gui.cpp
    scummvm/trunk/engines/sci/gui/gui_gfx.cpp
    scummvm/trunk/engines/sci/gui/gui_gfx.h

Modified: scummvm/trunk/engines/sci/gui/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-04 05:20:56 UTC (rev 44584)
+++ scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-04 05:22:49 UTC (rev 44585)
@@ -218,10 +218,12 @@
 
 // Used SCI1+ for text codes
 void SciGUI::textFonts(int argc, reg_t *argv) {
+	_gfx->SetTextFonts(argc, argv);
 }
 
 // Used SCI1+ for text codes
 void SciGUI::textColors(int argc, reg_t *argv) {
+	_gfx->SetTextColors(argc, argv);
 }
 
 void SciGUI::drawPicture(sciResourceId pictureId, uint16 style, uint16 flags, int16 EGApaletteNo) {

Modified: scummvm/trunk/engines/sci/gui/gui_gfx.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_gfx.cpp	2009-10-04 05:20:56 UTC (rev 44584)
+++ scummvm/trunk/engines/sci/gui/gui_gfx.cpp	2009-10-04 05:22:49 UTC (rev 44585)
@@ -54,6 +54,8 @@
 	uint16 a = 0;
 
 	_font = NULL;
+	_textFonts = NULL; _textFontsCount = 0;
+	_textColors = NULL; _textColorsCount = 0;
 
 	_mainPort = mallocPort();
 	SetPort(_mainPort);
@@ -158,11 +160,16 @@
 	int colorNo = 0;
 
 	memset(paletteOut, 0, sizeof(sciPalette));
+	// Setup default mapping
+	for (colorNo = 0; colorNo < 256; colorNo++) {
+		paletteOut->mapping[colorNo] = colorNo;
+	}
 	if (data[0] == 0 && data[1] == 1) {
 		// SCI0/SCI1 palette
 		palFormat = SCI_PAL_FORMAT_VARIABLE; // CONSTANT;
 		palOffset = 260;
 		palColorStart = 0; palColorCount = 256;
+		//memcpy(&paletteOut->mapping, data, 256);
 	} else {
 		// SCI1.1 palette
 		palFormat = data[32];
@@ -496,18 +503,7 @@
 	SciGUIfont *font = GetFont();
 	return font ? font->getCharWidth(ch) : 0;
 }
-//-----------------------------
-int16 SciGUIgfx::TextWidth(const char *text, int16 from, int16 len) {
-	SciGUIfont *font = GetFont();
-	if (font) {
-		int16 width = 0;
-		for (int i = from; i < len; i++)
-			width += _font->getCharWidth(text[i]);
-		return width;
-	}
-	return 0;
-}
-//-----------------------------
+
 void SciGUIgfx::ClearChar(int16 chr) {
 	if (_curPort->penMode != 1)
 		return;
@@ -536,7 +532,45 @@
 #endif
 }
 
+void SciGUIgfx::SetTextFonts(int argc, reg_t *argv) {
+	int i;
+
+	if (_textFonts) {
+		delete _textFonts;
+	}
+	_textFontsCount = argc;
+	_textFonts = new sciResourceId[argc];
+	for (i = 0; i < argc; i++) {
+		_textFonts[i] = (sciResourceId)argv[i].toUint16();
+	}
+}
+
+void SciGUIgfx::SetTextColors(int argc, reg_t *argv) {
+	int i;
+
+	if (_textColors) {
+		delete _textColors;
+	}
+	_textColorsCount = argc;
+	_textColors = new uint16[argc];
+	for (i = 0; i < argc; i++) {
+		_textColors[i] = argv[i].toUint16();
+	}
+}
+
 // TODO: implement codes
+int16 SciGUIgfx::TextWidth(const char *text, int16 from, int16 len) {
+	SciGUIfont *font = GetFont();
+	if (font) {
+		int16 width = 0;
+		for (int i = from; i < len; i++)
+			width += _font->getCharWidth(text[i]);
+		return width;
+	}
+	return 0;
+}
+
+// TODO: implement codes
 int16 SciGUIgfx::TextSize(Common::Rect &rect, const char *str, int16 fontId, int16 maxwidth) {
 	char buff[1000] = { 0 };
 	int16 oldfont = GetFontId();
@@ -612,16 +646,23 @@
 	rect.bottom = rect.top + _curPort->fontH;
 	while (len--) {
 		chr = (*text++) & 0xFF;
-		width = font->getCharWidth(chr);
-		// clear char
-		if (_curPort->penMode == 1) {
-			rect.left = _curPort->curLeft;
-			rect.right = rect.left + width;
-			EraseRect(rect);
+		switch (chr) {
+		case 0x7C:
+			while ((len--) && (*text++ != 0x7C)) { }
+			break;
+			
+		default:
+			width = font->getCharWidth(chr);
+			// clear char
+			if (_curPort->penMode == 1) {
+				rect.left = _curPort->curLeft;
+				rect.right = rect.left + width;
+				EraseRect(rect);
+			}
+			// CharStd
+			font->draw(chr, _curPort->top + _curPort->curTop, _curPort->left + _curPort->curLeft, _curPort->penClr, _curPort->textFace);
+			_curPort->curLeft += width;
 		}
-		// CharStd
-		font->draw(chr, _curPort->top + _curPort->curTop, _curPort->left + _curPort->curLeft, _curPort->penClr, _curPort->textFace);
-		_curPort->curLeft += width;
 	}
 }
 

Modified: scummvm/trunk/engines/sci/gui/gui_gfx.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_gfx.h	2009-10-04 05:20:56 UTC (rev 44584)
+++ scummvm/trunk/engines/sci/gui/gui_gfx.h	2009-10-04 05:22:49 UTC (rev 44585)
@@ -79,13 +79,16 @@
 
 	byte CharHeight(int16 ch);
 	byte CharWidth(int16 ch);
+	void ClearChar(int16 chr);
+	void DrawChar(int16 chr);
+	void StdChar(int16 chr);
+
+	void SetTextFonts(int argc, reg_t *argv);
+	void SetTextColors(int argc, reg_t *argv);
 	int16 TextWidth(const char*text, int16 from, int16 len);
 	int16 StringWidth(const char*str) {
 		return TextWidth(str, 0, (int16)strlen(str));
 	}
-	void ClearChar(int16 chr);
-	void DrawChar(int16 chr);
-	void StdChar(int16 chr);
 	int16 TextSize(Common::Rect &rect, const char *str, int16 fontId, int16 maxwidth);
 	int16 GetLongest(const char *str, int16 maxwidth);
 	void DrawText(const char *str, int16 from, int16 len);
@@ -133,14 +136,17 @@
 	Common::Rect _bounds;
 	sciPort *_mainPort;
 	sciPort *_curPort;
-//	byte *_visualScreen;
-//	byte *_pcSeg;
 	uint16 _clrPowers[256];
 
 	byte bMapColors;
 	sciPalette *pPicPal;
 	Common::Array<sciPalSched> _palSchedules;
 
+	int _textFontsCount;
+	sciResourceId *_textFonts;
+	int _textColorsCount;
+	uint16 *_textColors;
+
 	SciGUIfont *_font;
 };
 


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