[Scummvm-cvs-logs] SF.net SVN: scummvm:[55167] scummvm/trunk/engines/hugo

strangerke at users.sourceforge.net strangerke at users.sourceforge.net
Sat Jan 8 17:56:52 CET 2011


Revision: 55167
          http://scummvm.svn.sourceforge.net/scummvm/?rev=55167&view=rev
Author:   strangerke
Date:     2011-01-08 16:56:52 +0000 (Sat, 08 Jan 2011)

Log Message:
-----------
HUGO: Merge inventory object and mouse cursor when selected

- Merge inventory object and mouse cursor into a new mouse cursor (looks better)
- Use 16 color mouse pointer
- Clean-up

Modified Paths:
--------------
    scummvm/trunk/engines/hugo/display.cpp
    scummvm/trunk/engines/hugo/display.h
    scummvm/trunk/engines/hugo/hugo.cpp
    scummvm/trunk/engines/hugo/mouse.cpp
    scummvm/trunk/engines/hugo/object.cpp
    scummvm/trunk/engines/hugo/parser.cpp

Modified: scummvm/trunk/engines/hugo/display.cpp
===================================================================
--- scummvm/trunk/engines/hugo/display.cpp	2011-01-08 16:05:27 UTC (rev 55166)
+++ scummvm/trunk/engines/hugo/display.cpp	2011-01-08 16:56:52 UTC (rev 55167)
@@ -33,9 +33,11 @@
 // Display.c - DIB related code for HUGOWIN
 
 #include "common/system.h"
+#include "graphics/cursorman.h"
 
 #include "hugo/hugo.h"
 #include "hugo/display.h"
+#include "hugo/inventory.h"
 #include "hugo/util.h"
 
 namespace Hugo {
@@ -66,6 +68,10 @@
 	g_system->setPalette(_mainPalette, 0, NUM_COLORS);
 }
 
+void Screen::setCursorPal() {
+	CursorMan.replaceCursorPalette(_curPalette, 0, _paletteSize / 4);
+}
+
 /**
 * Create logical palette
 */
@@ -543,5 +549,47 @@
 			free(_arrayFont[i]);
 	}
 }
+
+void Screen::selectInventoryObjId(int16 objId) {
+
+	status_t &gameStatus = _vm->getGameStatus();
+
+	gameStatus.inventoryObjId = objId;              // Select new object
+
+	// Find index of icon
+	int16 iconId;                                   // Find index of dragged icon
+	for (iconId = 0; iconId < _vm->_maxInvent; iconId++) {
+		if (gameStatus.inventoryObjId == _vm->_invent[iconId])
+			break;
+	}
+
+	// Compute source coordinates in dib_u
+	int16 ux = (iconId + NUM_ARROWS) * INV_DX % XPIX;
+	int16 uy = (iconId + NUM_ARROWS) * INV_DX / XPIX * INV_DY;
+
+	// Copy the icon and add to display list
+	moveImage(getGUIBuffer(), ux, uy, INV_DX, INV_DY, XPIX, _iconImage, 0, 0, 32);
+
+	for (int i = 0; i < stdMouseCursorHeight; i++) {
+		for (int j = 0; j < stdMouseCursorWidth; j++) {
+			_iconImage[(i * INV_DX) + j] = (stdMouseCursor[(i * stdMouseCursorWidth) + j] == 1) ? _iconImage[(i * INV_DX) + j] : stdMouseCursor[(i * stdMouseCursorWidth) + j];
+		}
+	}
+
+	CursorMan.replaceCursor(_iconImage, INV_DX, INV_DY, 1, 1, 1);
+}
+
+void Screen::resetInventoryObjId() {
+	_vm->getGameStatus().inventoryObjId = -1;       // Unselect object
+	CursorMan.replaceCursor(stdMouseCursor, stdMouseCursorWidth, stdMouseCursorHeight, 1, 1, 1);
+}
+
+void Screen::showCursor() {
+	CursorMan.showMouse(true);
+}
+
+void Screen::hideCursor() {
+	CursorMan.showMouse(false);
+}
 } // End of namespace Hugo
 

Modified: scummvm/trunk/engines/hugo/display.h
===================================================================
--- scummvm/trunk/engines/hugo/display.h	2011-01-08 16:05:27 UTC (rev 55166)
+++ scummvm/trunk/engines/hugo/display.h	2011-01-08 16:56:52 UTC (rev 55167)
@@ -46,46 +46,37 @@
 
 /**
  * A black and white Windows-style arrow cursor (12x20).
- * 0 = Transparent.
- * 1 = Black (#000000 in 24-bit RGB).
- * 2 = White (#FFFFFF in 24-bit RGB).
+ * 0 = Black (#000000 in 24-bit RGB).
+ * 1 = Transparent.
+ * 15 = White (#FFFFFF in 24-bit RGB).
  * This cursor comes from Mohawk engine.
  */
+
 static const byte stdMouseCursor[] = {
-	1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-	1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-	1, 2, 2,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, 15, 15, 15, 15, 15, 15, 15, 0, 1,
+	0, 15, 15, 15, 15, 15, 15, 0,  0,  0,  0, 0,
+	0, 15, 15, 15, 0,  15, 15, 0,  1,  1,  1, 1,
+	0, 15, 15, 0,  0,  15, 15, 0,  1,  1,  1, 1,
+	0, 15, 0,  1,  0,  0,  15, 15, 0,  1,  1, 1,
+	0, 0,  1,  1,  1,  0,  15, 15, 0,  1,  1, 1,
+	0, 1,  1,  1,  1,  1,  0,  15, 15, 0,  1, 1,
+	1, 1,  1,  1,  1,  1,  0,  15, 15, 0,  1, 1,
+	1, 1,  1,  1,  1,  1,  1,  0,  15, 15, 0, 1,
+	1, 1,  1,  1,  1,  1,  1,  0,  15, 15, 0, 1,
+	1, 1,  1,  1,  1,  1,  1,  1,  0,  0,  1, 1
 };
+static const byte stdMouseCursorHeight = 20;
+static const byte stdMouseCursorWidth = 12;
 
-static const byte stdMousrCursorHeight = 20;
-static const byte stdMousrCursorWidth = 12;
-
-/**
- * RGBA-palette for the black and white arrow cursor.
- * This palette comes from AGI engine.
- */
-static const byte stdMouseCursorPalette[] = {
-	0x00, 0x00, 0x00,	0x00, // Black
-	0xFF, 0xFF, 0xFF,	0x00  // White
-};
-
 class Screen {
 public:
 	Screen(HugoEngine *vm);
@@ -106,17 +97,21 @@
 	void     drawStatusText();
 	void     freeFonts();
 	void     freePalette();
+	void     hideCursor();
 	void     initDisplay();
 	void     initNewScreenDisplay();
 	void     loadPalette(Common::File &in);
 	void     moveImage(image_pt srcImage, uint16 x1, uint16 y1, uint16 dx, uint16 dy, uint16 width1, image_pt dstImage, uint16 x2, uint16 y2, uint16 width2);
 	void     remapPal(uint16 oldIndex, uint16 newIndex);
+	void     resetInventoryObjId();
 	void     restorePal(Common::SeekableReadStream *f);
 	void     savePal(Common::WriteStream *f);
 	void     setBackgroundColor(long color);
+	void     setCursorPal();
+	void     selectInventoryObjId(int16 objId);
 	void     shadowStr(int16 sx, int16 sy, const char *s, byte color);
+	void     showCursor();
 	void     userHelp();
-	void     writeChr(int sx, int sy, byte color, char *local_fontdata);
 	void     writeStr(int16 sx, int16 sy, const char *s, byte color);
 
 	icondib_t &getIconBuffer() {
@@ -150,23 +145,28 @@
 	byte  _fontdata[NUM_FONTS][FONTSIZE];           // Font data
 	byte *_font[NUM_FONTS][FONT_LEN];               // Ptrs to each char
 	byte *_mainPalette;
-	byte *_curPalette;
-	byte  _paletteSize;
-
 	int16 _arrayFontSize[NUM_FONTS];
 
 private:
+	byte     *_curPalette;
+	byte      _iconImage[INV_DX * INV_DY];
+	byte      _paletteSize;
+
+	icondib_t _iconBuffer;                          // Inventory icon DIB
+
+	int16 mergeLists(rect_t *list, rect_t *blist, int16 len, int16 blen, int16 bmax);
+	int16 center(const char *s);
+
+	overlayState_t findOvl(seq_t *seq_p, image_pt dst_p, uint16 y);
+
 	viewdib_t _frontBuffer;
 	viewdib_t _backBuffer;
 	viewdib_t _GUIBuffer;                           // User interface images
 	viewdib_t _backBufferBackup;                    // Backup _backBuffer during inventory
-	icondib_t _iconBuffer;                          // Inventory icon DIB
 
 	void createPal();
-	overlayState_t findOvl(seq_t *seq_p, image_pt dst_p, uint16 y);
 	void merge(rect_t *rectA, rect_t *rectB);
-	int16 mergeLists(rect_t *list, rect_t *blist, int16 len, int16 blen, int16 bmax);
-	int16 center(const char *s);
+	void writeChr(int sx, int sy, byte color, char *local_fontdata);
 };
 
 class Screen_v1d : public Screen {

Modified: scummvm/trunk/engines/hugo/hugo.cpp
===================================================================
--- scummvm/trunk/engines/hugo/hugo.cpp	2011-01-08 16:05:27 UTC (rev 55166)
+++ scummvm/trunk/engines/hugo/hugo.cpp	2011-01-08 16:56:52 UTC (rev 55167)
@@ -28,7 +28,6 @@
 #include "common/events.h"
 #include "common/EventRecorder.h"
 #include "common/debug-channels.h"
-#include "graphics/cursorman.h"
 
 #include "hugo/hugo.h"
 #include "hugo/global.h"
@@ -261,8 +260,8 @@
 		return Common::kUnknownError;
 
 	/* Use Windows-looking mouse cursor */
-	CursorMan.replaceCursorPalette(stdMouseCursorPalette, 1, ARRAYSIZE(stdMouseCursorPalette) / 4);
-	CursorMan.replaceCursor(stdMouseCursor, stdMousrCursorWidth, stdMousrCursorHeight, 1, 1, 0);
+	_screen->setCursorPal();
+	_screen->resetInventoryObjId();
 
 	initStatus();                                   // Initialize game status
 	initConfig(INSTALL);                            // Initialize user's config
@@ -355,7 +354,7 @@
 
 	switch (gameStatus.viewState) {
 	case V_IDLE:                                    // Not processing state machine
-		CursorMan.showMouse(false);
+		_screen->hideCursor();
 		_intro->preNewGame();                       // Any processing before New Game selected
 		break;
 	case V_INTROINIT:                               // Initialization before intro begins
@@ -369,7 +368,7 @@
 		}
 		break;
 	case V_PLAY:                                    // Playing game
-		CursorMan.showMouse(true);
+		_screen->showCursor();
 		_parser->charHandler();                     // Process user cmd input
 		_object->moveObjects();                     // Process object movement
 		_scheduler->runScheduler();                 // Process any actions

Modified: scummvm/trunk/engines/hugo/mouse.cpp
===================================================================
--- scummvm/trunk/engines/hugo/mouse.cpp	2011-01-08 16:05:27 UTC (rev 55166)
+++ scummvm/trunk/engines/hugo/mouse.cpp	2011-01-08 16:56:52 UTC (rev 55167)
@@ -114,9 +114,9 @@
 	// Check if this was over iconbar
 	if (gameStatus.inventoryState == I_ACTIVE && cy < INV_DY + DIBOFF_Y) { // Clicked over iconbar object
 		if (gameStatus.inventoryObjId == -1)
-			gameStatus.inventoryObjId = objId;      // Not using so select new object
+			_vm->_screen->selectInventoryObjId(objId);
 		else if (gameStatus.inventoryObjId == objId)
-			gameStatus.inventoryObjId = -1;         // Same icon - deselect it
+			_vm->_screen->resetInventoryObjId();
 		else
 			_vm->_object->useObject(objId);         // Use status.objid on object
 	} else {                                        // Clicked over viewport object
@@ -195,7 +195,7 @@
 			}
 
 			// Get rid of any attached icon
-			gameStatus.inventoryObjId = -1;
+			_vm->_screen->resetInventoryObjId();
 		}
 		break;
 	default:                                        // Look at an icon or object
@@ -248,32 +248,6 @@
 	if (cx < 0 || cx > XPIX || cy < DIBOFF_Y || cy > VIEW_DY + DIBOFF_Y)
 		return;
 
-	// Display dragged inventory icon if one currently selected
-	if (gameStatus.inventoryObjId != -1) {
-		// Find index of icon
-		int16 iconId;                               // Find index of dragged icon
-		for (iconId = 0; iconId < _vm->_maxInvent; iconId++) {
-			if (gameStatus.inventoryObjId == _vm->_invent[iconId])
-				break;
-		}
-
-		// Compute source coordinates in dib_u
-		int16 ux = (iconId + NUM_ARROWS) * INV_DX % XPIX;
-		int16 uy = (iconId + NUM_ARROWS) * INV_DX / XPIX * INV_DY;
-
-		// Compute destination coordinates in dib_a
-		int iconx = cx + IX_OFF;
-		int icony = cy + IY_OFF;
-		iconx = MAX(iconx, 0);                      // Keep within dib_a bounds
-		iconx = MIN(iconx, XPIX - INV_DX);
-		icony = MAX(icony, 0);
-		icony = MIN(icony, YPIX - INV_DY);
-
-		// Copy the icon and add to display list
-		_vm->_screen->moveImage(_vm->_screen->getGUIBuffer(), ux, uy, INV_DX, INV_DY, XPIX, _vm->_screen->getFrontBuffer(), iconx, icony, XPIX);
-		_vm->_screen->displayList(D_ADD, iconx, icony, INV_DX, INV_DY);
-	}
-
 	int16 objId = -1;                               // Current source object
 	// Process cursor over an object or icon
 	if (gameStatus.inventoryState == I_ACTIVE) {      // Check inventory icon bar first

Modified: scummvm/trunk/engines/hugo/object.cpp
===================================================================
--- scummvm/trunk/engines/hugo/object.cpp	2011-01-08 16:05:27 UTC (rev 55166)
+++ scummvm/trunk/engines/hugo/object.cpp	2011-01-08 16:56:52 UTC (rev 55167)
@@ -131,7 +131,7 @@
 				if (!foundFl) {
 					// Deselect dragged icon if inventory not active
 					if (_vm->getGameStatus().inventoryState != I_ACTIVE)
-						_vm->getGameStatus().inventoryObjId  = -1;
+						_vm->_screen->resetInventoryObjId();
 					Utils::Box(BOX_ANY, "%s", _vm->_textData[use->dataIndex]);
 					return;
 				}
@@ -141,7 +141,9 @@
 
 	if (_vm->getGameStatus().inventoryState == I_ACTIVE) // If inventory active, remove it
 		_vm->getGameStatus().inventoryState = I_UP;
-	_vm->getGameStatus().inventoryObjId  = -1;      // Deselect any dragged icon
+
+	_vm->_screen->resetInventoryObjId();
+
 	_vm->_parser->lineHandler();                    // and process command
 }
 

Modified: scummvm/trunk/engines/hugo/parser.cpp
===================================================================
--- scummvm/trunk/engines/hugo/parser.cpp	2011-01-08 16:05:27 UTC (rev 55166)
+++ scummvm/trunk/engines/hugo/parser.cpp	2011-01-08 16:56:52 UTC (rev 55167)
@@ -139,7 +139,7 @@
 	case Common::KEYCODE_ESCAPE:                    // Escape key, may want to QUIT
 		if (gameStatus.inventoryState == I_ACTIVE)  // Remove inventory, if displayed
 			gameStatus.inventoryState = I_UP;
-		gameStatus.inventoryObjId = -1;             // Deselect any dragged icon
+		_vm->_screen->resetInventoryObjId();
 		break;
 	case Common::KEYCODE_END:
 	case Common::KEYCODE_HOME:


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