[Scummvm-cvs-logs] CVS: scummvm/gui newgui.cpp,1.11,1.12 newgui.h,1.7,1.8

Max Horn fingolfin at users.sourceforge.net
Thu Sep 19 16:07:07 CEST 2002


Update of /cvsroot/scummvm/scummvm/gui
In directory usw-pr-cvs1:/tmp/cvs-serv31739/gui

Modified Files:
	newgui.cpp newgui.h 
Log Message:
NewGui now has its own mouse cursor code -> again one less dependency on Scumm; moved makeCursorColorTransparent to gfx.cpp where it belongs

Index: newgui.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- newgui.cpp	19 Sep 2002 22:37:00 -0000	1.11
+++ newgui.cpp	19 Sep 2002 23:06:54 -0000	1.12
@@ -70,7 +70,7 @@
 // Constructor
 NewGui::NewGui(Scumm *s) : _s(s), _system(s->_system), _screen(0),
 	_use_alpha_blending(true), _need_redraw(false), _prepare_for_gui(true),
-	_currentKeyDown(0)
+	_currentKeyDown(0), _cursorAnimateCounter(0)
 {
 	// Setup some default GUI colors.
 	// TODO - either use nicer values, or maybe make this configurable?
@@ -79,6 +79,9 @@
 	_shadowcolor = RGB_TO_16(64, 64, 64);
 	_textcolor = RGB_TO_16(32, 160, 32);
 	_textcolorhi = RGB_TO_16(0, 255, 0);
+	
+	// Clear the cursor
+	memset(_cursor, 0xFF, sizeof(_cursor));
 }
 
 void NewGui::loop()
@@ -111,7 +114,7 @@
 		_need_redraw = false;
 	}
 	
-	_s->animateCursor();
+	animateCursor();
 
 	if (_eventList.size() > 0)
 	{
@@ -188,19 +191,12 @@
 
 void NewGui::saveState()
 {
+	// Pause sound put
 	_old_soundsPaused = _s->_sound->_soundsPaused;
 	_s->_sound->pauseSounds(true);
 
 	// Backup old cursor
-	memcpy(_old_grabbedCursor, _s->_grabbedCursor, sizeof(_old_grabbedCursor));
-	_old_cursorWidth = _s->_cursorWidth;
-	_old_cursorHeight = _s->_cursorHeight;
-	_old_cursorHotspotX = _s->_cursorHotspotX;
-	_old_cursorHotspotY = _s->_cursorHotspotY;
-	_old_cursor_mode = _system->show_mouse(true);
-
-	_s->_cursorAnimate++;
-	_s->gdi._cursorActive = 1;
+	_oldCursorMode = _system->show_mouse(true);
 	
 	// TODO - add getHeight & getWidth methods to OSystem
 	_system->show_overlay();
@@ -211,18 +207,11 @@
 
 void NewGui::restoreState()
 {
-	_s->_cursorAnimate--;
-
 	// Restore old cursor
-	memcpy(_s->_grabbedCursor, _old_grabbedCursor, sizeof(_old_grabbedCursor));
-	_s->_cursorWidth = _old_cursorWidth;
-	_s->_cursorHeight = _old_cursorHeight;
-	_s->_cursorHotspotX = _old_cursorHotspotX;
-	_s->_cursorHotspotY = _old_cursorHotspotY;
 	_s->updateCursor();
+	_system->show_mouse(_oldCursorMode);
 
-	_system->show_mouse(_old_cursor_mode);
-
+	// Resume sound output
 	_s->_sound->pauseSounds(_old_soundsPaused);
 
 	_system->hide_overlay();
@@ -439,9 +428,9 @@
 	}
 }
 
-/*
- * Draw an 8x8 bitmap at location (x,y)
- */
+//
+// Draw an 8x8 bitmap at location (x,y)
+//
 void NewGui::drawBitmap(uint32 bitmap[8], int x, int y, int16 color)
 {
 	int16 *ptr = getBasePtr(x, y);
@@ -457,4 +446,27 @@
 		}
 		ptr += _screen_pitch;
 	}
+}
+
+//
+// Draw the mouse cursor (animated). This is mostly ripped from the cursor code in gfx.cpp
+// We could plug in a different cursor here if we like to.
+//
+void NewGui::animateCursor()
+{
+	if (0 == (_cursorAnimateCounter & 0x3)) {
+		const byte colors[4] = { 15, 15, 7, 8 };
+		const byte color = colors[(_cursorAnimateCounter >> 2) & 3];
+		int i;
+		
+		for (i = 0; i < 16; i++) {
+			if ((i < 7) || (i > 9)) {
+				_cursor[16 * 8 + i] = color;
+				_cursor[16 * i + 8] = color;
+			}
+		}
+	
+		_system->set_mouse_cursor(_cursor, 16, 16, 8, 8);
+	}
+	_cursorAnimateCounter++;
 }

Index: newgui.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gui/newgui.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- newgui.h	19 Sep 2002 21:45:55 -0000	1.7
+++ newgui.h	19 Sep 2002 23:06:54 -0000	1.8
@@ -94,11 +94,6 @@
 
 	// sound state
 	bool		_old_soundsPaused;
-
-	// mouse cursor state
-	bool		_old_cursor_mode;
-	int			_old_cursorHotspotX, _old_cursorHotspotY, _old_cursorWidth, _old_cursorHeight;
-	byte		_old_grabbedCursor[2048];
 	
 	// position and time of last mouse click (used to detect double clicks)
 	struct {
@@ -109,12 +104,20 @@
 	
 	// List of events to be handled
 	EventList	_eventList;
+	
+
+	// mouse cursor state
+	bool		_oldCursorMode;
+	int			_cursorAnimateCounter;
+	byte		_cursor[2048];
 
 	void saveState();
 	void restoreState();
 	
 	void openDialog(Dialog *dialog);
 	void closeTopDialog();
+	
+	void animateCursor();
 
 public:
 	// Drawing





More information about the Scummvm-git-logs mailing list