[Scummvm-cvs-logs] SF.net SVN: scummvm:[44664] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Mon Oct 5 18:43:24 CEST 2009


Revision: 44664
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44664&view=rev
Author:   thebluegr
Date:     2009-10-05 16:43:24 +0000 (Mon, 05 Oct 2009)

Log Message:
-----------
Moved the cursor movement code in the GUI

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/game.cpp
    scummvm/trunk/engines/sci/engine/kevent.cpp
    scummvm/trunk/engines/sci/engine/kgraphics.cpp
    scummvm/trunk/engines/sci/gfx/operations.cpp
    scummvm/trunk/engines/sci/gfx/operations.h
    scummvm/trunk/engines/sci/gui/gui.cpp
    scummvm/trunk/engines/sci/gui/gui.h
    scummvm/trunk/engines/sci/gui32/gui32.cpp
    scummvm/trunk/engines/sci/gui32/gui32.h

Modified: scummvm/trunk/engines/sci/engine/game.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/game.cpp	2009-10-05 13:33:26 UTC (rev 44663)
+++ scummvm/trunk/engines/sci/engine/game.cpp	2009-10-05 16:43:24 UTC (rev 44664)
@@ -31,6 +31,7 @@
 #include "sci/engine/state.h"
 #include "sci/engine/kernel.h"
 #include "sci/engine/kernel_types.h"
+#include "sci/gui/gui.h"
 #include "sci/gfx/gfx_widgets.h"
 #include "sci/gfx/gfx_state_internal.h"	// required for GfxPort, GfxVisual
 #include "sci/gfx/menubar.h"
@@ -210,7 +211,7 @@
 	gfxop_fill_box(s->gfx_state, gfx_rect(0, 0, 320, 200), s->ega_colors[0]); // Fill screen black
 	gfxop_update(s->gfx_state);
 
-	gfxop_set_pointer_position(s->gfx_state, Common::Point(160, 150));
+	s->gui->moveCursor(160, 150);
 
 	s->pic_is_new = 0;
 	s->pic_visible_map = GFX_MASK_NONE; // Other values only make sense for debugging

Modified: scummvm/trunk/engines/sci/engine/kevent.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kevent.cpp	2009-10-05 13:33:26 UTC (rev 44663)
+++ scummvm/trunk/engines/sci/engine/kevent.cpp	2009-10-05 16:43:24 UTC (rev 44664)
@@ -65,7 +65,7 @@
 	PUT_SEL32V(obj, x, s->gfx_state->pointer_pos.x);
 	PUT_SEL32V(obj, y, s->gfx_state->pointer_pos.y);
 
-	//gfxop_set_pointer_position(s->gfx_state, Common::Point(s->gfx_state->pointer_pos.x, s->gfx_state->pointer_pos.y));
+	//s->gui->moveCursor(s->gfx_state->pointer_pos.x, s->gfx_state->pointer_pos.y);
 
 	switch (e.type) {
 	case SCI_EVT_QUIT:

Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-10-05 13:33:26 UTC (rev 44663)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-10-05 16:43:24 UTC (rev 44664)
@@ -276,10 +276,8 @@
 	gfxop_set_pointer_cursor(s->gfx_state, cursor);
 
 	// Set pointer position, if requested
-	if (argc >= 4) {
-		Common::Point newPos = Common::Point(argv[2].toSint16() + s->port->_bounds.x, argv[3].toSint16() + s->port->_bounds.y);
-		gfxop_set_pointer_position(s->gfx_state, newPos);
-	}
+	if (argc >= 4)
+		s->gui->moveCursor(argv[2].toSint16() + s->port->_bounds.x, argv[3].toSint16() + s->port->_bounds.y);
 
 	return s->r_acc;
 }
@@ -292,8 +290,7 @@
 		CursorMan.showMouse(argv[0].toSint16() != 0);
 		break;
 	case 2:
-		gfxop_set_pointer_position(s->gfx_state,
-				   Common::Point(argv[0].toUint16() + s->port->_bounds.x, argv[1].toUint16() + s->port->_bounds.y));
+		s->gui->moveCursor(argv[0].toUint16() + s->port->_bounds.x, argv[1].toUint16() + s->port->_bounds.y);
 		break;
 	case 4: {
 		int16 top = argv[0].toSint16();

Modified: scummvm/trunk/engines/sci/gfx/operations.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.cpp	2009-10-05 13:33:26 UTC (rev 44663)
+++ scummvm/trunk/engines/sci/gfx/operations.cpp	2009-10-05 16:43:24 UTC (rev 44664)
@@ -1040,21 +1040,6 @@
 	}
 }
 
-void gfxop_set_pointer_position(GfxState *state, Common::Point pos) {
-	state->pointer_pos = pos;
-
-	if (pos.x > 320 || pos.y > 200) {
-		debug("[GFX] Attempt to place pointer at invalid coordinates (%d, %d)\n", pos.x, pos.y);
-		return; // Not fatal
-	}
-
-	g_system->warpMouse(pos.x * state->driver->getMode()->scaleFactor, pos.y * state->driver->getMode()->scaleFactor);
-
-	// Trigger event reading to make sure the mouse coordinates will
-	// actually have changed the next time we read them.
-	gfxop_get_event(state, SCI_EVT_PEEK);
-}
-
 void gfxop_set_pointer_zone(GfxState *state, Common::Rect rect) {
 	state->pointerZone = rect;
 }

Modified: scummvm/trunk/engines/sci/gfx/operations.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.h	2009-10-05 13:33:26 UTC (rev 44663)
+++ scummvm/trunk/engines/sci/gfx/operations.h	2009-10-05 16:43:24 UTC (rev 44664)
@@ -389,16 +389,6 @@
 void gfxop_set_pointer_view(GfxState *state, int nr, int loop, int cel, Common::Point *hotspot);
 
 /**
- * Teleports the mouse pointer to a specific position.
- *
- * Depending on the graphics driver, this operation may be without any effect
- *
- * @param[in] state	The state the pointer is in
- * @param[in] pos	The position to teleport it to
- */
-void gfxop_set_pointer_position(GfxState *state, Common::Point pos);
-
-/**
  * Limits the mouse movement to a given rectangle.
  *
  * @param[in] state	The affected state

Modified: scummvm/trunk/engines/sci/gui/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-05 13:33:26 UTC (rev 44663)
+++ scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-05 16:43:24 UTC (rev 44664)
@@ -403,7 +403,7 @@
 	_gfx->SetNowSeen(objectReference);
 }
 
-void SciGui::moveCursor(int16 x, int16 y) {
+void SciGui::moveCursor(int16 x, int16 y, int16 scaleFactor) {
 	Common::Point newPos;
 	
 	x += _windowMgr->_picWind->rect.left;
@@ -411,7 +411,16 @@
 	newPos.x = CLIP<int16>(x, _windowMgr->_picWind->rect.left, _windowMgr->_picWind->rect.right - 1);
 	newPos.y = CLIP<int16>(y, _windowMgr->_picWind->rect.top, _windowMgr->_picWind->rect.bottom - 1);
 
-	gfxop_set_pointer_position(_s->gfx_state, newPos);
+	if (x > _screen->_width || y > _screen->_height) {
+		debug("[GFX] Attempt to place pointer at invalid coordinates (%d, %d)\n", x, y);
+		return; // Not fatal
+	}
+
+	g_system->warpMouse(x * scaleFactor, y * scaleFactor);
+
+	// Trigger event reading to make sure the mouse coordinates will
+	// actually have changed the next time we read them.
+	gfxop_get_event(_s->gfx_state, SCI_EVT_PEEK);
 }
 
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/gui/gui.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.h	2009-10-05 13:33:26 UTC (rev 44663)
+++ scummvm/trunk/engines/sci/gui/gui.h	2009-10-05 16:43:24 UTC (rev 44664)
@@ -85,7 +85,8 @@
 	virtual void addToPicView(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 leftPos, int16 topPos, int16 priority, int16 control);
 	virtual void setNowSeen(reg_t objectReference);
 
-	virtual void moveCursor(int16 x, int16 y);
+	virtual void moveCursor(int16 x, int16 y, int16 scaleFactor = 1);
+	void moveCursor(Common::Point p, int16 scaleFactor = 1) { moveCursor(p.x, p.y, scaleFactor); }
 
 private:
 	OSystem *_system;

Modified: scummvm/trunk/engines/sci/gui32/gui32.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui32/gui32.cpp	2009-10-05 13:33:26 UTC (rev 44663)
+++ scummvm/trunk/engines/sci/gui32/gui32.cpp	2009-10-05 16:43:24 UTC (rev 44664)
@@ -1994,7 +1994,7 @@
 }
 
 
-void SciGui32::moveCursor(int16 x, int16 y) {
+void SciGui32::moveCursor(int16 x, int16 y, int16 scaleFactor) {
 	Common::Point newPos;
 
 	// newPos = s->gfx_state->pointer_pos;
@@ -2007,9 +2007,21 @@
 	if (newPos.y > s->port->zone.y + s->port->zone.height)
 		newPos.y = s->port->zone.y + s->port->zone.height;
 
-	if (newPos.x < 0) newPos.x = 0;
-	if (newPos.y < 0) newPos.y = 0;
-	gfxop_set_pointer_position(s->gfx_state, newPos);
+	if (newPos.x < 0)
+		newPos.x = 0;
+	if (newPos.y < 0)
+		newPos.y = 0;
+
+	if (x > 320 || y > 200) {
+		debug("[GFX] Attempt to place pointer at invalid coordinates (%d, %d)\n", x, y);
+		return; // Not fatal
+	}
+
+	g_system->warpMouse(x * scaleFactor, y * scaleFactor);
+
+	// Trigger event reading to make sure the mouse coordinates will
+	// actually have changed the next time we read them.
+	gfxop_get_event(s->gfx_state, SCI_EVT_PEEK);
 }
 
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/gui32/gui32.h
===================================================================
--- scummvm/trunk/engines/sci/gui32/gui32.h	2009-10-05 13:33:26 UTC (rev 44663)
+++ scummvm/trunk/engines/sci/gui32/gui32.h	2009-10-05 16:43:24 UTC (rev 44664)
@@ -80,7 +80,7 @@
 	void addToPicView(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 leftPos, int16 topPos, int16 priority, int16 control);
 	void setNowSeen(reg_t objectReference);
 
-	void moveCursor(int16 x, int16 y);
+	void moveCursor(int16 x, int16 y, int16 scaleFactor = 1);
 
 private:
 	OSystem *_system;


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