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

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Sun Jul 5 21:58:09 CEST 2009


Revision: 42150
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42150&view=rev
Author:   drmccoy
Date:     2009-07-05 19:58:09 +0000 (Sun, 05 Jul 2009)

Log Message:
-----------
Reordering some methods

Modified Paths:
--------------
    scummvm/trunk/engines/gob/hotspots.cpp
    scummvm/trunk/engines/gob/hotspots.h

Modified: scummvm/trunk/engines/gob/hotspots.cpp
===================================================================
--- scummvm/trunk/engines/gob/hotspots.cpp	2009-07-05 19:57:55 UTC (rev 42149)
+++ scummvm/trunk/engines/gob/hotspots.cpp	2009-07-05 19:58:09 UTC (rev 42150)
@@ -687,53 +687,6 @@
 	return Hotspots::check(handleMouse, delay, id, index);
 }
 
-void Hotspots::printText(uint16 x, uint16 y, const char *str, uint16 fontIndex, uint16 color) const {
-	_vm->_draw->_destSpriteX  = x;
-	_vm->_draw->_destSpriteY  = y;
-	_vm->_draw->_frontColor   = color;
-	_vm->_draw->_fontIndex    = fontIndex;
-	_vm->_draw->_textToPrint  = str;
-	_vm->_draw->_transparency = 1;
-
-	_vm->_draw->spriteOperation(DRAW_PRINTTEXT | 0x10);
-}
-
-void Hotspots::fillRect(uint16 x, uint16 y, uint16 width, uint16 height, uint16 color) const {
-	_vm->_draw->_destSurface  = 21;
-	_vm->_draw->_destSpriteX  = x;
-	_vm->_draw->_destSpriteY  = y;
-	_vm->_draw->_spriteRight  = width;
-	_vm->_draw->_spriteBottom = height;
-	_vm->_draw->_backColor    = color;
-
-	_vm->_draw->spriteOperation(DRAW_FILLRECT | 0x10 );
-}
-
-void Hotspots::getTextCursorPos(const Video::FontDesc &font, const char *str,
-		uint32 pos, uint16 x, uint16 y, uint16 width, uint16 height,
-		uint16 &cursorX, uint16 &cursorY, uint16 &cursorWidth, uint16 &cursorHeight) const {
-
-	if (font.charWidths) {
-		// Cursor to the right of the current character
-
-		cursorX      = x;
-		cursorY      = y;
-		cursorWidth  = 1;
-		cursorHeight = height;
-
-		for (uint32 i = 0; i < pos; i++)
-			cursorX += font.charWidths[str[i] - font.startItem];
-
-	} else {
-		// Cursor underlining the current character
-
-		cursorX      = x + font.itemWidth * pos;
-		cursorY      = y + height - 1;
-		cursorWidth  = font.itemWidth;
-		cursorHeight = 1;
-	}
-}
-
 uint16 Hotspots::readString(uint16 xPos, uint16 yPos, uint16 width, uint16 height,
 		uint16 backColor, uint16 frontColor, char *str, uint16 fontIndex,
 		Type type, int16 &duration, uint16 &id, uint16 index) {
@@ -952,99 +905,6 @@
 	}
 }
 
-void Hotspots::updateAllTexts(const InputDesc *inputs) const {
-	uint16 input = 0;
-
-	for (int i = 0; i < kHotspotCount; i++) {
-		const Hotspot &spot = _hotspots[i];
-
-		if (spot.isEnd())
-			continue;
-
-		if ((spot.getState() & 0xC) != 0x8)
-			continue;
-
-		if (!spot.isInput())
-			continue;
-
-		char tempStr[256];
-		strncpy0(tempStr, GET_VARO_STR(spot.key), 255);
-
-		uint16 x      = spot.left;
-		uint16 y      = spot.top;
-		uint16 width  = spot.right  - spot.left + 1;
-		uint16 height = spot.bottom - spot.top  + 1;
-		fillRect(x, y, width, height, inputs[input].backColor);
-
-		y += (width - _vm->_draw->_fonts[_vm->_draw->_fontIndex]->itemHeight) / 2;
-
-		printText(x, y, tempStr, inputs[input].fontIndex, inputs[input].frontColor);
-
-		input++;
-	}
-}
-
-uint16 Hotspots::findInput(uint16 input) const {
-	uint16 inputIndex = 0;
-	for (int i = 0; i < kHotspotCount; i++) {
-		Hotspot &spot = _hotspots[i];
-
-		if (!spot.isActiveInput())
-			continue;
-
-		if (inputIndex == input)
-			return i;
-
-		inputIndex++;
-	}
-
-	return 0xFFFF;
-}
-
-uint16 Hotspots::findClickedInput(uint16 index) const {
-	for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
-		Hotspot &spot = _hotspots[i];
-
-		if (spot.getWindow() != 0)
-			continue;
-
-		if (spot.getState() & 0x4)
-			continue;
-
-		if (!spot.isIn(_vm->_global->_inter_mouseX, _vm->_global->_inter_mouseY))
-			continue;
-
-		if (spot.getCursor() != 0)
-			continue;
-
-		if (!spot.isInput())
-			continue;
-
-		index = i;
-		break;
-	}
-
-	return index;
-}
-
-uint16 Hotspots::findNthInput(uint16 n) const {
-	uint16 input = 0;
-
-	for (int i = 0; i < kHotspotCount; i++) {
-		Hotspot &spot = _hotspots[i];
-
-		if (!spot.isActiveInput())
-			continue;
-
-		if (i == n)
-			break;
-
-		input++;
-	}
-
-	return input;
-}
-
 uint16 Hotspots::handleInput(int16 time, uint16 inputCount, uint16 &curInput,
 		InputDesc *inputs, uint16 &id, uint16 &index) {
 
@@ -1672,4 +1532,144 @@
 	return cursor;
 }
 
+uint16 Hotspots::findInput(uint16 input) const {
+	uint16 inputIndex = 0;
+	for (int i = 0; i < kHotspotCount; i++) {
+		Hotspot &spot = _hotspots[i];
+
+		if (!spot.isActiveInput())
+			continue;
+
+		if (inputIndex == input)
+			return i;
+
+		inputIndex++;
+	}
+
+	return 0xFFFF;
+}
+
+uint16 Hotspots::findClickedInput(uint16 index) const {
+	for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
+		Hotspot &spot = _hotspots[i];
+
+		if (spot.getWindow() != 0)
+			continue;
+
+		if (spot.getState() & 0x4)
+			continue;
+
+		if (!spot.isIn(_vm->_global->_inter_mouseX, _vm->_global->_inter_mouseY))
+			continue;
+
+		if (spot.getCursor() != 0)
+			continue;
+
+		if (!spot.isInput())
+			continue;
+
+		index = i;
+		break;
+	}
+
+	return index;
+}
+
+uint16 Hotspots::findNthInput(uint16 n) const {
+	uint16 input = 0;
+
+	for (int i = 0; i < kHotspotCount; i++) {
+		Hotspot &spot = _hotspots[i];
+
+		if (!spot.isActiveInput())
+			continue;
+
+		if (i == n)
+			break;
+
+		input++;
+	}
+
+	return input;
+}
+
+void Hotspots::getTextCursorPos(const Video::FontDesc &font, const char *str,
+		uint32 pos, uint16 x, uint16 y, uint16 width, uint16 height,
+		uint16 &cursorX, uint16 &cursorY, uint16 &cursorWidth, uint16 &cursorHeight) const {
+
+	if (font.charWidths) {
+		// Cursor to the right of the current character
+
+		cursorX      = x;
+		cursorY      = y;
+		cursorWidth  = 1;
+		cursorHeight = height;
+
+		for (uint32 i = 0; i < pos; i++)
+			cursorX += font.charWidths[str[i] - font.startItem];
+
+	} else {
+		// Cursor underlining the current character
+
+		cursorX      = x + font.itemWidth * pos;
+		cursorY      = y + height - 1;
+		cursorWidth  = font.itemWidth;
+		cursorHeight = 1;
+	}
+}
+
+void Hotspots::fillRect(uint16 x, uint16 y, uint16 width, uint16 height, uint16 color) const {
+	_vm->_draw->_destSurface  = 21;
+	_vm->_draw->_destSpriteX  = x;
+	_vm->_draw->_destSpriteY  = y;
+	_vm->_draw->_spriteRight  = width;
+	_vm->_draw->_spriteBottom = height;
+	_vm->_draw->_backColor    = color;
+
+	_vm->_draw->spriteOperation(DRAW_FILLRECT | 0x10 );
+}
+
+void Hotspots::printText(uint16 x, uint16 y, const char *str, uint16 fontIndex, uint16 color) const {
+	_vm->_draw->_destSpriteX  = x;
+	_vm->_draw->_destSpriteY  = y;
+	_vm->_draw->_frontColor   = color;
+	_vm->_draw->_fontIndex    = fontIndex;
+	_vm->_draw->_textToPrint  = str;
+	_vm->_draw->_transparency = 1;
+
+	_vm->_draw->spriteOperation(DRAW_PRINTTEXT | 0x10);
+}
+
+void Hotspots::updateAllTexts(const InputDesc *inputs) const {
+	uint16 input = 0;
+
+	for (int i = 0; i < kHotspotCount; i++) {
+		const Hotspot &spot = _hotspots[i];
+
+		if (spot.isEnd())
+			continue;
+
+		if ((spot.getState() & 0xC) != 0x8)
+			continue;
+
+		if (!spot.isInput())
+			continue;
+
+		char tempStr[256];
+		strncpy0(tempStr, GET_VARO_STR(spot.key), 255);
+
+		uint16 x      = spot.left;
+		uint16 y      = spot.top;
+		uint16 width  = spot.right  - spot.left + 1;
+		uint16 height = spot.bottom - spot.top  + 1;
+		fillRect(x, y, width, height, inputs[input].backColor);
+
+		y += (width - _vm->_draw->_fonts[_vm->_draw->_fontIndex]->itemHeight) / 2;
+
+		printText(x, y, tempStr, inputs[input].fontIndex, inputs[input].frontColor);
+
+		input++;
+	}
+}
+
 } // End of namespace Gob

Modified: scummvm/trunk/engines/gob/hotspots.h
===================================================================
--- scummvm/trunk/engines/gob/hotspots.h	2009-07-05 19:57:55 UTC (rev 42149)
+++ scummvm/trunk/engines/gob/hotspots.h	2009-07-05 19:58:09 UTC (rev 42150)
@@ -171,7 +171,7 @@
 	/** Which hotspot is the mouse cursor currently at? */
 	uint16 checkMouse(Type type, uint16 &id, uint16 &index) const;
 
-void checkHotspotChanged();
+	void checkHotspotChanged();
 
 	uint16 readString(uint16 xPos, uint16 yPos, uint16 width, uint16 height,
 			uint16 backColor, uint16 frontColor, char *str, uint16 fontIndex,
@@ -183,17 +183,21 @@
 	void evaluateNew(uint16 i, uint16 *ids, InputDesc *inputs,
 			uint16 &validId, bool &hasInput, uint16 &inputCount);
 
-	void updateAllTexts(const InputDesc *inputs) const;
-
+	// Finding certain inputs
 	uint16 findInput(uint16 input) const;
 	uint16 findClickedInput(uint16 index) const;
 	uint16 findNthInput(uint16 n) const;
 
-	void printText(uint16 x, uint16 y, const char *str, uint16 fontIndex, uint16 color) const;
-	void fillRect(uint16 x, uint16 y, uint16 width, uint16 height, uint16 color) const;
+	/** Calculate the graphical cursor position. */
 	void getTextCursorPos(const Video::FontDesc &font, const char *str,
 			uint32 pos, uint16 x, uint16 y, uint16 width, uint16 height,
 			uint16 &cursorX, uint16 &cursorY, uint16 &cursorWidth, uint16 &cursorHeight) const;
+
+	// Drawing functions
+	void fillRect(uint16 x, uint16 y, uint16 width, uint16 height, uint16 color) const;
+	void printText(uint16 x, uint16 y, const char *str, uint16 fontIndex, uint16 color) const;
+
+	void updateAllTexts(const InputDesc *inputs) const;
 };
 
 } // End of namespace Gob


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