[Scummvm-cvs-logs] SF.net SVN: scummvm:[35596] scummvm/trunk/engines/gob

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Mon Dec 29 01:03:09 CET 2008


Revision: 35596
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35596&view=rev
Author:   drmccoy
Date:     2008-12-29 00:03:09 +0000 (Mon, 29 Dec 2008)

Log Message:
-----------
Implemented the non-monospaced font in the save name input field

Modified Paths:
--------------
    scummvm/trunk/engines/gob/game.h
    scummvm/trunk/engines/gob/game_v1.cpp
    scummvm/trunk/engines/gob/game_v2.cpp
    scummvm/trunk/engines/gob/game_v6.cpp

Modified: scummvm/trunk/engines/gob/game.h
===================================================================
--- scummvm/trunk/engines/gob/game.h	2008-12-28 22:09:31 UTC (rev 35595)
+++ scummvm/trunk/engines/gob/game.h	2008-12-29 00:03:09 UTC (rev 35596)
@@ -127,10 +127,12 @@
 			uint16 funcEnter, uint16 funcLeave, uint16 funcSub = 0) = 0;
 	virtual void collisionsBlock(void) = 0;
 	virtual int16 multiEdit(int16 time, int16 index, int16 *pCurPos,
-			InputDesc *inpDesc, int16 *collResId, int16 *collIndex) = 0;
+			InputDesc *inpDesc, int16 *collResId,
+			int16 *collIndex, bool mono = true) = 0;
 	virtual int16 inputArea(int16 xPos, int16 yPos, int16 width, int16 height,
 			int16 backColor, int16 frontColor, char *str, int16 fontIndex,
-			char inpType, int16 *pTotTime, int16 *collResId, int16 *collIndex) = 0;
+			char inpType, int16 *pTotTime, int16 *collResId,
+			int16 *collIndex, bool mono = true) = 0;
 	virtual int16 checkCollisions(byte handleMouse, int16 deltaTime,
 			int16 *pResId, int16 *pResIndex) = 0;
 
@@ -245,10 +247,12 @@
 			uint16 funcEnter, uint16 funcLeave, uint16 funcSub = 0);
 	virtual void collisionsBlock(void);
 	virtual int16 multiEdit(int16 time, int16 index, int16 *pCurPos,
-			InputDesc *inpDesc, int16 *collResId, int16 *collIndex);
+			InputDesc *inpDesc, int16 *collResId,
+			int16 *collIndex, bool mono = true);
 	virtual int16 inputArea(int16 xPos, int16 yPos, int16 width, int16 height,
 			int16 backColor, int16 frontColor, char *str, int16 fontIndex,
-			char inpType, int16 *pTotTime, int16 *collResId, int16 *collIndex);
+			char inpType, int16 *pTotTime, int16 *collResId,
+			int16 *collIndex, bool mono = true);
 	virtual int16 checkCollisions(byte handleMouse, int16 deltaTime,
 			int16 *pResId, int16 *pResIndex);
 
@@ -274,10 +278,12 @@
 			uint16 funcEnter, uint16 funcLeave, uint16 funcSub = 0);
 	virtual void collisionsBlock(void);
 	virtual int16 multiEdit(int16 time, int16 index, int16 *pCurPos,
-			InputDesc *inpDesc, int16 *collResId, int16 *collIndex);
+			InputDesc *inpDesc, int16 *collResId,
+			int16 *collIndex, bool mono = true);
 	virtual int16 inputArea(int16 xPos, int16 yPos, int16 width, int16 height,
 			int16 backColor, int16 frontColor, char *str, int16 fontIndex,
-			char inpType, int16 *pTotTime, int16 *collResId, int16 *collIndex);
+			char inpType, int16 *pTotTime, int16 *collResId,
+			int16 *collIndex, bool mono = true);
 	virtual int16 checkCollisions(byte handleMouse, int16 deltaTime,
 			int16 *pResId, int16 *pResIndex);
 

Modified: scummvm/trunk/engines/gob/game_v1.cpp
===================================================================
--- scummvm/trunk/engines/gob/game_v1.cpp	2008-12-28 22:09:31 UTC (rev 35595)
+++ scummvm/trunk/engines/gob/game_v1.cpp	2008-12-29 00:03:09 UTC (rev 35596)
@@ -1088,7 +1088,7 @@
 }
 
 int16 Game_v1::multiEdit(int16 time, int16 index, int16 *pCurPos,
-		InputDesc * inpDesc, int16 *collResId, int16 *collIndex) {
+		InputDesc * inpDesc, int16 *collResId, int16 *collIndex, bool mono) {
 	Collision *collArea;
 	int16 descInd;
 	int16 key;
@@ -1250,7 +1250,7 @@
 
 int16 Game_v1::inputArea(int16 xPos, int16 yPos, int16 width, int16 height,
 		int16 backColor, int16 frontColor, char *str, int16 fontIndex,
-		char inpType, int16 *pTotTime, int16 *collResId, int16 *collIndex) {
+		char inpType, int16 *pTotTime, int16 *collResId, int16 *collIndex, bool mono) {
 	int16 handleMouse;
 	uint32 editSize;
 	Video::FontDesc *pFont;

Modified: scummvm/trunk/engines/gob/game_v2.cpp
===================================================================
--- scummvm/trunk/engines/gob/game_v2.cpp	2008-12-28 22:09:31 UTC (rev 35595)
+++ scummvm/trunk/engines/gob/game_v2.cpp	2008-12-29 00:03:09 UTC (rev 35596)
@@ -1141,7 +1141,7 @@
 }
 
 int16 Game_v2::multiEdit(int16 time, int16 index, int16 *pCurPos,
-		InputDesc * inpDesc, int16 *collResId, int16 *collIndex) {
+		InputDesc * inpDesc, int16 *collResId, int16 *collIndex, bool mono) {
 	Collision *collArea;
 	int16 descInd;
 	int16 key;
@@ -1181,18 +1181,23 @@
 		_vm->_draw->_transparency = 1;
 		_vm->_draw->_fontIndex = inpDesc[descInd].fontIndex;
 
-		fontExtraBak = _vm->_draw->_fonts[_vm->_draw->_fontIndex]->extraData;
-		needAdjust = _vm->_draw->_needAdjust;
-		_vm->_draw->_needAdjust = 2;
-		_vm->_draw->_fonts[_vm->_draw->_fontIndex]->extraData = 0;
+		if (mono) {
+			fontExtraBak = _vm->_draw->_fonts[_vm->_draw->_fontIndex]->extraData;
+			needAdjust = _vm->_draw->_needAdjust;
+			_vm->_draw->_needAdjust = 2;
+			_vm->_draw->_fonts[_vm->_draw->_fontIndex]->extraData = 0;
+		}
+
 		_vm->_draw->spriteOperation(DRAW_FILLRECT | 0x10);
 
 		_vm->_draw->_destSpriteY += ((collArea->bottom - collArea->top + 1) -
 				_vm->_draw->_fonts[_vm->_draw->_fontIndex]->itemHeight) / 2;
 		_vm->_draw->spriteOperation(DRAW_PRINTTEXT | 0x10);
 
-		_vm->_draw->_needAdjust = needAdjust;
-		_vm->_draw->_fonts[_vm->_draw->_fontIndex]->extraData = fontExtraBak;
+		if (mono) {
+			_vm->_draw->_needAdjust = needAdjust;
+			_vm->_draw->_fonts[_vm->_draw->_fontIndex]->extraData = fontExtraBak;
+		}
 
 		descInd++;
 	}
@@ -1235,7 +1240,7 @@
 		    collArea->bottom - collArea->top + 1,
 		    inpDesc[*pCurPos].backColor, inpDesc[*pCurPos].frontColor,
 		    GET_VARO_STR(collArea->key), inpDesc[*pCurPos].fontIndex,
-				collArea->flags, &time, collResId, collIndex);
+				collArea->flags, &time, collResId, collIndex, mono);
 
 		if (_vm->_inter->_terminate)
 			return 0;
@@ -1340,7 +1345,7 @@
 
 int16 Game_v2::inputArea(int16 xPos, int16 yPos, int16 width, int16 height,
 		int16 backColor, int16 frontColor, char *str, int16 fontIndex,
-		char inpType, int16 *pTotTime, int16 *collResId, int16 *collIndex) {
+		char inpType, int16 *pTotTime, int16 *collResId, int16 *collIndex, bool mono) {
 	byte handleMouse;
 	uint32 editSize;
 	Video::FontDesc *pFont;
@@ -1363,22 +1368,24 @@
 
 	pos = strlen(str);
 	pFont = _vm->_draw->_fonts[fontIndex];
-	editSize = width / pFont->itemWidth;
+	editSize = (!mono && pFont->extraData) ? 0 : (width / pFont->itemWidth);
 
 	while (1) {
 		strncpy0(_tempStr, str, 254);
 		strcat(_tempStr, " ");
-		if (strlen(_tempStr) > editSize)
+		if ((editSize != 0) && strlen(_tempStr) > editSize)
 			strncpy0(_tempStr, str, 255);
 
-		fontExtraBak = _vm->_draw->_fonts[fontIndex]->extraData;
-		needAdjust = _vm->_draw->_needAdjust;
-		_vm->_draw->_needAdjust = 2;
-		_vm->_draw->_fonts[fontIndex]->extraData = 0;
+		if (mono) {
+			fontExtraBak = _vm->_draw->_fonts[fontIndex]->extraData;
+			needAdjust = _vm->_draw->_needAdjust;
+			_vm->_draw->_needAdjust = 2;
+			_vm->_draw->_fonts[fontIndex]->extraData = 0;
+		}
 
 		_vm->_draw->_destSpriteX = xPos;
 		_vm->_draw->_destSpriteY = yPos;
-		_vm->_draw->_spriteRight = editSize * pFont->itemWidth;
+		_vm->_draw->_spriteRight = mono ? (editSize * pFont->itemWidth) : width;
 		_vm->_draw->_spriteBottom = height;
 
 		_vm->_draw->_destSurface = 21;
@@ -1392,10 +1399,12 @@
 		_vm->_draw->_destSpriteY = yPos + (height - pFont->itemHeight) / 2;
 		_vm->_draw->spriteOperation(DRAW_PRINTTEXT | 0x10);
 
-		_vm->_draw->_needAdjust = needAdjust;
-		_vm->_draw->_fonts[fontIndex]->extraData = fontExtraBak;
+		if (mono) {
+			_vm->_draw->_needAdjust = needAdjust;
+			_vm->_draw->_fonts[fontIndex]->extraData = fontExtraBak;
+		}
 
-		if (pos == editSize)
+		if ((editSize != 0) && (pos == editSize))
 			pos--;
 
 		curSym = _tempStr[pos];
@@ -1406,24 +1415,40 @@
 			WRITE_VAR(56, pos);
 
 		while (1) {
-			fontExtraBak = _vm->_draw->_fonts[fontIndex]->extraData;
-			needAdjust = _vm->_draw->_needAdjust;
-			_vm->_draw->_needAdjust = 2;
-			_vm->_draw->_fonts[fontIndex]->extraData = 0;
+			if (mono) {
+				fontExtraBak = _vm->_draw->_fonts[fontIndex]->extraData;
+				needAdjust = _vm->_draw->_needAdjust;
+				_vm->_draw->_needAdjust = 2;
+				_vm->_draw->_fonts[fontIndex]->extraData = 0;
+			}
 
 			_tempStr[0] = curSym;
 			_tempStr[1] = 0;
 
-			_vm->_draw->_destSpriteX = xPos + pFont->itemWidth * pos;
-			_vm->_draw->_destSpriteY = yPos + height - 1;
-			_vm->_draw->_spriteRight = pFont->itemWidth;
-			_vm->_draw->_spriteBottom = 1;
+			if (pFont->extraData) {
+				_vm->_draw->_destSpriteY = yPos;
+				_vm->_draw->_spriteBottom = height;
+				_vm->_draw->_spriteRight = 1;
+
+				_vm->_draw->_destSpriteX = xPos;
+				for (uint32 j = 0; j < pos; j++)
+					_vm->_draw->_destSpriteX += pFont->extraData[str[j] - pFont->startItem];
+
+			} else {
+				_vm->_draw->_destSpriteX = xPos + pFont->itemWidth * pos;
+				_vm->_draw->_destSpriteY = yPos + height - 1;
+				_vm->_draw->_spriteRight = pFont->itemWidth;
+				_vm->_draw->_spriteBottom = 1;
+			}
+
 			_vm->_draw->_destSurface = 21;
 			_vm->_draw->_backColor = frontColor;
 			_vm->_draw->spriteOperation(DRAW_FILLRECT | 0x10);
 
-			_vm->_draw->_needAdjust = needAdjust;
-			_vm->_draw->_fonts[fontIndex]->extraData = fontExtraBak;
+			if (mono) {
+				_vm->_draw->_needAdjust = needAdjust;
+				_vm->_draw->_fonts[fontIndex]->extraData = fontExtraBak;
+			}
 
 			if (flag != 0) {
 				key = checkCollisions(handleMouse, -1, collResId, collIndex);
@@ -1433,17 +1458,32 @@
 			} else
 				key = checkCollisions(handleMouse, -300, collResId, collIndex);
 
-			fontExtraBak = _vm->_draw->_fonts[fontIndex]->extraData;
-			needAdjust = _vm->_draw->_needAdjust;
-			_vm->_draw->_needAdjust = 2;
-			_vm->_draw->_fonts[fontIndex]->extraData = 0;
+			if (mono) {
+				fontExtraBak = _vm->_draw->_fonts[fontIndex]->extraData;
+				needAdjust = _vm->_draw->_needAdjust;
+				_vm->_draw->_needAdjust = 2;
+				_vm->_draw->_fonts[fontIndex]->extraData = 0;
+			}
 
 			_tempStr[0] = curSym;
 			_tempStr[1] = 0;
-			_vm->_draw->_destSpriteX = xPos + pFont->itemWidth * pos;
-			_vm->_draw->_destSpriteY = yPos + height - 1;
-			_vm->_draw->_spriteRight = pFont->itemWidth;
-			_vm->_draw->_spriteBottom = 1;
+
+			if (pFont->extraData) {
+				_vm->_draw->_destSpriteY = yPos;
+				_vm->_draw->_spriteBottom = height;
+				_vm->_draw->_spriteRight = 1;
+
+				_vm->_draw->_destSpriteX = xPos;
+				for (uint32 j = 0; j < pos; j++)
+					_vm->_draw->_destSpriteX += pFont->extraData[str[j] - pFont->startItem];
+
+			} else {
+				_vm->_draw->_destSpriteX = xPos + pFont->itemWidth * pos;
+				_vm->_draw->_destSpriteY = yPos + height - 1;
+				_vm->_draw->_spriteRight = pFont->itemWidth;
+				_vm->_draw->_spriteBottom = 1;
+			}
+
 			_vm->_draw->_destSurface = 21;
 			_vm->_draw->_backColor = backColor;
 			_vm->_draw->_frontColor = frontColor;
@@ -1455,8 +1495,10 @@
 			_vm->_draw->_destSpriteY = yPos + (height - pFont->itemHeight) / 2;
 			_vm->_draw->spriteOperation(DRAW_PRINTTEXT | 0x10);
 
-			_vm->_draw->_needAdjust = needAdjust;
-			_vm->_draw->_fonts[fontIndex]->extraData = fontExtraBak;
+			if (mono) {
+				_vm->_draw->_needAdjust = needAdjust;
+				_vm->_draw->_fonts[fontIndex]->extraData = fontExtraBak;
+			}
 
 			if ((key != 0) || (*collResId != 0))
 				break;
@@ -1483,7 +1525,7 @@
 
 		switch (key) {
 		case 0x4D00: // Right Arrow
-			if ((pos < strlen(str)) && (pos < (editSize - 1))) {
+			if ((pos > strlen(str)) || (pos > (editSize - 1)) || (editSize == 0)) {
 				pos++;
 				continue;
 			}
@@ -1501,6 +1543,9 @@
 				_vm->_util->cutFromStr(str, pos - 1, 1);
 				pos--;
 				continue;
+			} else {
+				if (pos < strlen(str))
+					_vm->_util->cutFromStr(str, pos, 1);
 			}
 
 		case 0x5300: // Del
@@ -1568,9 +1613,24 @@
 			}
 
 			if ((key >= ' ') && (key <= 0xFF)) {
-				if (editSize == strlen(str))
-					_vm->_util->cutFromStr(str, strlen(str) - 1, 1);
+				if (editSize == 0) {
+					int length = _vm->_draw->stringLength(str, fontIndex) +
+						pFont->extraData[' ' - pFont->startItem] +
+						pFont->extraData[key - pFont->startItem];
 
+					if (length > width)
+						continue;
+
+					if (((int32) strlen(str)) >= (_vm->_global->_inter_animDataSize * 4 - 1))
+						continue;
+
+				} else {
+					if (strlen(str) > editSize)
+						continue;
+					else if (editSize == strlen(str))
+						_vm->_util->cutFromStr(str, strlen(str) - 1, 1);
+				}
+
 				pos++;
 				_tempStr[0] = key;
 				_tempStr[1] = 0;

Modified: scummvm/trunk/engines/gob/game_v6.cpp
===================================================================
--- scummvm/trunk/engines/gob/game_v6.cpp	2008-12-28 22:09:31 UTC (rev 35595)
+++ scummvm/trunk/engines/gob/game_v6.cpp	2008-12-29 00:03:09 UTC (rev 35596)
@@ -667,7 +667,7 @@
 	do {
 		if (var_1C != 0) {
 			key = multiEdit(deltaTime, index, &curEditIndex, descArray,
-					&activeCollResId, &activeCollIndex);
+					&activeCollResId, &activeCollIndex, false);
 
 			WRITE_VAR(55, curEditIndex);
 			if (key == 0x1C0D) {


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