[Scummvm-cvs-logs] SF.net SVN: scummvm:[45451] scummvm/trunk/engines/draci

spalek at users.sourceforge.net spalek at users.sourceforge.net
Wed Oct 28 00:51:32 CET 2009


Revision: 45451
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45451&view=rev
Author:   spalek
Date:     2009-10-27 23:51:32 +0000 (Tue, 27 Oct 2009)

Log Message:
-----------
Don't change mouse cursors so ridiculously often.

Modified Paths:
--------------
    scummvm/trunk/engines/draci/game.cpp
    scummvm/trunk/engines/draci/mouse.cpp
    scummvm/trunk/engines/draci/mouse.h

Modified: scummvm/trunk/engines/draci/game.cpp
===================================================================
--- scummvm/trunk/engines/draci/game.cpp	2009-10-27 21:34:43 UTC (rev 45450)
+++ scummvm/trunk/engines/draci/game.cpp	2009-10-27 23:51:32 UTC (rev 45451)
@@ -463,16 +463,11 @@
 	if (_loopStatus == kStatusDialogue)
 		return;
 
+	bool mouseChanged = false;
+
 	// If we are in inventory mode, we do a different kind of updating that handles
 	// inventory items and return early
 	if (_loopStatus == kStatusInventory && _loopSubstatus == kSubstatusOrdinary) {
-
-		if (_currentItem == kNoItem) {
-			_vm->_mouse->setCursorType(kNormalCursor);
-		} else {
-			_vm->_mouse->loadItemCursor(_currentItem);
-		}
-
 		if (_itemUnderCursor != kNoItem) {
 			const GameItem *item = &_items[_itemUnderCursor];
 
@@ -482,8 +477,16 @@
 				} else {
 					_vm->_mouse->loadItemCursor(_currentItem, true);
 				}
+				mouseChanged = true;
 			}
 		}
+		if (!mouseChanged) {
+			if (_currentItem == kNoItem) {
+				_vm->_mouse->setCursorType(kNormalCursor);
+			} else {
+				_vm->_mouse->loadItemCursor(_currentItem);
+			}
+		}
 
 		return;
 	}
@@ -498,14 +501,6 @@
 		_oldObjUnderCursor = _objUnderCursor;
 	}
 
-	// Load the appropriate cursor (item image if an item is held or ordinary cursor
-	// if not)
-	if (_currentItem == kNoItem) {
-		_vm->_mouse->setCursorType(kNormalCursor);
-	} else {
-		_vm->_mouse->loadItemCursor(_currentItem);
-	}
-
 	// TODO: Handle main menu
 
 	// If there is no game object under the cursor, try using the room itself
@@ -516,6 +511,7 @@
 			} else {
 				_vm->_mouse->loadItemCursor(_currentItem, true);
 			}
+			mouseChanged = true;
 		}
 	// If there *is* a game object under the cursor, update the cursor image
 	} else {
@@ -531,13 +527,24 @@
 				} else {
 					_vm->_mouse->loadItemCursor(_currentItem, true);
 				}
+				mouseChanged = true;
 			}
 		// If the walking direction *is* set, the game object is a gate, so update
 		// the cursor image to the appropriate arrow.
 		} else {
 			_vm->_mouse->setCursorType((CursorType)obj->_walkDir);
+			mouseChanged = true;
 		}
 	}
+	// Load the appropriate cursor (item image if an item is held or ordinary cursor
+	// if not)
+	if (!mouseChanged) {
+		if (_currentItem == kNoItem) {
+			_vm->_mouse->setCursorType(kNormalCursor);
+		} else {
+			_vm->_mouse->loadItemCursor(_currentItem);
+		}
+	}
 }
 
 void Game::updateTitle() {

Modified: scummvm/trunk/engines/draci/mouse.cpp
===================================================================
--- scummvm/trunk/engines/draci/mouse.cpp	2009-10-27 21:34:43 UTC (rev 45450)
+++ scummvm/trunk/engines/draci/mouse.cpp	2009-10-27 23:51:32 UTC (rev 45451)
@@ -34,7 +34,7 @@
 	_y = 0;
 	_lButton = false;
 	_rButton = false;
-	_cursorType = kNormalCursor;
+	_cursorType = kUninitializedCursor;
 	_vm = vm;
 }
 
@@ -90,10 +90,13 @@
 }
 
 void Mouse::setCursorType(CursorType cur) {
+	if (cur == getCursorType()) {
+		return;
+	}
 	_cursorType = cur;
 
 	const BAFile *f;
-	f = _vm->_iconsArchive->getFile(_cursorType);
+	f = _vm->_iconsArchive->getFile(cur);
 
 	Sprite sp(f->_data, f->_length, 0, 0, true);
 	CursorMan.replaceCursorPalette(_vm->_screen->getPalette(), 0, kNumColours);
@@ -102,8 +105,15 @@
 }
 
 void Mouse::loadItemCursor(int itemID, bool highlighted) {
+	int archiveIndex = 2 * itemID + highlighted;
+	CursorType newCursor = static_cast<CursorType> (kItemCursor + archiveIndex);
+	if (newCursor == getCursorType()) {
+		return;
+	}
+	_cursorType = newCursor;
+
 	const BAFile *f;
-	f = _vm->_itemImagesArchive->getFile(2 * itemID + highlighted);
+	f = _vm->_itemImagesArchive->getFile(archiveIndex);
 
 	Sprite sp(f->_data, f->_length, 0, 0, true);
 	CursorMan.replaceCursorPalette(_vm->_screen->getPalette(), 0, kNumColours);

Modified: scummvm/trunk/engines/draci/mouse.h
===================================================================
--- scummvm/trunk/engines/draci/mouse.h	2009-10-27 21:34:43 UTC (rev 45450)
+++ scummvm/trunk/engines/draci/mouse.h	2009-10-27 23:51:32 UTC (rev 45451)
@@ -39,7 +39,9 @@
 	kArrowCursor4,
 	kDialogueCursor,
 	kHighlightedCursor,
-	kMainMenuCursor
+	kMainMenuCursor,
+	kUninitializedCursor = 100,
+	kItemCursor			// + the index in the BArchive
 };
 
 class DraciEngine;


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