[Scummvm-cvs-logs] SF.net SVN: scummvm: [20767] scummvm/trunk/engines/lure

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Sat Feb 18 20:23:00 CET 2006


Revision: 20767
Author:   dreammaster
Date:     2006-02-18 20:22:00 -0800 (Sat, 18 Feb 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm?rev=20767&view=rev

Log Message:
-----------
Converted mouse and events classes to use new getReference style

Modified Paths:
--------------
    scummvm/trunk/engines/lure/events.cpp
    scummvm/trunk/engines/lure/events.h
Modified: scummvm/trunk/engines/lure/events.cpp
===================================================================
--- scummvm/trunk/engines/lure/events.cpp	2006-02-19 04:20:18 UTC (rev 20766)
+++ scummvm/trunk/engines/lure/events.cpp	2006-02-19 04:22:00 UTC (rev 20767)
@@ -21,6 +21,8 @@
  */
 
 #include "lure/events.h"
+#include "lure/system.h"
+#include "lure/res.h"
 
 namespace Lure {
 
@@ -30,7 +32,7 @@
 	return *int_mouse; 
 }
 
-Mouse::Mouse(OSystem &system): _system(system), _cursors(Disk::getReference().getEntry(CURSOR_RESOURCE_ID)) {
+Mouse::Mouse() {
 	int_mouse = this;
 
 	_lButton = false; 
@@ -40,7 +42,6 @@
 }
 
 Mouse::~Mouse() {
-	delete _cursors;
 }
 
 void Mouse::handleEvent(OSystem::Event event) {
@@ -67,11 +68,11 @@
 
 
 void Mouse::cursorOn() {
-	_system.showMouse(true);
+	System::getReference().showMouse(true);
 }
 
 void Mouse::cursorOff() {
-	_system.showMouse(false);
+	System::getReference().showMouse(false);
 }
 
 void Mouse::setCursorNum(uint8 cursorNum) {
@@ -85,13 +86,16 @@
 }
 
 void Mouse::setCursorNum(uint8 cursorNum, int hotspotX, int hotspotY) {
+	Resources &res = Resources::getReference();
+	OSystem &system = System::getReference();
+
 	_cursorNum = cursorNum;
-	byte *cursorAddr = _cursors->data() + (cursorNum * CURSOR_SIZE);
-	_system.setMouseCursor(cursorAddr, CURSOR_WIDTH, CURSOR_HEIGHT, hotspotX, hotspotY, 0);
+	byte *cursorAddr = res.getCursor(cursorNum);
+	system.setMouseCursor(cursorAddr, CURSOR_WIDTH, CURSOR_HEIGHT, hotspotX, hotspotY, 0);
 }
 
 void Mouse::setPosition(int newX, int newY) {
-	_system.warpMouse(newX, newY);
+	System::getReference().warpMouse(newX, newY);
 }
 
 void Mouse::waitForRelease() {
@@ -99,7 +103,6 @@
 
 	do {
 		e.pollEvent();
-		_system.delayMillis(10);
 	} while (!e.quitFlag && (lButton() || rButton()));
 }
 
@@ -107,8 +110,9 @@
 
 static Events *int_events = NULL;
 
-Events::Events(OSystem &system, Mouse &mouse): _system(system), _mouse(mouse), quitFlag(false) {
+Events::Events() {
 	int_events = this;
+	quitFlag = false;
 }
 
 Events &Events::getReference() {
@@ -117,7 +121,7 @@
 
 
 bool Events::pollEvent() {
-	if (!_system.pollEvent(_event)) return false;
+	if (!System::getReference().pollEvent(_event)) return false;
 
 	// Handle keypress
 	switch (_event.type) {
@@ -132,7 +136,7 @@
 	case OSystem::EVENT_MOUSEMOVE:
 	case OSystem::EVENT_WHEELUP:
 	case OSystem::EVENT_WHEELDOWN:
-		_mouse.handleEvent(_event);
+		Mouse::getReference().handleEvent(_event);
 		break;
 
 	default:
@@ -151,10 +155,9 @@
 			else if ((_event.type == OSystem::EVENT_LBUTTONDOWN) ||
 				(_event.type == OSystem::EVENT_RBUTTONDOWN)) {
 				keyButton = true;
-				_mouse.waitForRelease();				
+				Mouse::getReference().waitForRelease();				
 			}
 		}
-		_system.delayMillis(10);
 	}
 }
 

Modified: scummvm/trunk/engines/lure/events.h
===================================================================
--- scummvm/trunk/engines/lure/events.h	2006-02-19 04:20:18 UTC (rev 20766)
+++ scummvm/trunk/engines/lure/events.h	2006-02-19 04:22:00 UTC (rev 20767)
@@ -32,13 +32,11 @@
 
 class Mouse {
 private:
-	OSystem &_system;
-	MemoryBlock *_cursors;
 	uint8 _cursorNum;
 	int16 _x, _y;
 	bool _lButton, _rButton;
 public:
-	Mouse(OSystem &system);
+	Mouse();
 	~Mouse();
 	static Mouse &getReference(); 
 	void handleEvent(OSystem::Event event);
@@ -58,13 +56,11 @@
 
 class Events {
 private:
-	OSystem &_system;
-	Mouse &_mouse;
 	OSystem::Event _event;
 public:
 	bool quitFlag;
 
-	Events(OSystem &system, Mouse &mouse);
+	Events();
 	static Events &getReference();
 
 	bool pollEvent();







More information about the Scummvm-git-logs mailing list