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

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Wed Oct 7 23:29:47 CEST 2009


Revision: 44760
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44760&view=rev
Author:   thebluegr
Date:     2009-10-07 21:29:47 +0000 (Wed, 07 Oct 2009)

Log Message:
-----------
- Cleaned up the cursor code
- Renamed gui -> _gui in EngineState, for consistency
- Added a reference to SciGuiCursor in EngineState, to be used by current code
- Renamed setCursorHide -> hideCursor, setCursorShow -> showCursor
- Moved the cursor zone limiting code inside SciGuiCursor. This code is currently not functioning, as we need to call refreshPosition() before each updateScreen() call to limit the cursor position.

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    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/engine/kmenu.cpp
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/engine/state.cpp
    scummvm/trunk/engines/sci/engine/state.h
    scummvm/trunk/engines/sci/gfx/gfx_driver.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/gui/gui_cursor.cpp
    scummvm/trunk/engines/sci/gui/gui_cursor.h
    scummvm/trunk/engines/sci/gui32/gui32.cpp
    scummvm/trunk/engines/sci/gui32/gui32.h
    scummvm/trunk/engines/sci/sci.cpp

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2009-10-07 21:25:31 UTC (rev 44759)
+++ scummvm/trunk/engines/sci/console.cpp	2009-10-07 21:29:47 UTC (rev 44760)
@@ -1498,7 +1498,7 @@
 	case 1:
 	case 2:
 	case 3:
-		return _vm->_gamestate->gui->debugShowMap(map);
+		return _vm->_gamestate->_gui->debugShowMap(map);
 		break;
 
 	default:

Modified: scummvm/trunk/engines/sci/engine/game.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/game.cpp	2009-10-07 21:25:31 UTC (rev 44759)
+++ scummvm/trunk/engines/sci/engine/game.cpp	2009-10-07 21:29:47 UTC (rev 44760)
@@ -279,9 +279,6 @@
 	s->titlebar_port->_bgcolor.priority = 11; // Standard priority for the titlebar port
 #endif
 
-	Common::Point mousePos(160, 150);
-	s->gui->moveCursor(mousePos);
-
 	return 0;
 }
 

Modified: scummvm/trunk/engines/sci/engine/kevent.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kevent.cpp	2009-10-07 21:25:31 UTC (rev 44759)
+++ scummvm/trunk/engines/sci/engine/kevent.cpp	2009-10-07 21:29:47 UTC (rev 44760)
@@ -31,6 +31,7 @@
 #include "sci/console.h"
 #include "sci/debug.h"	// for g_debug_simulated_key
 #include "sci/gui/gui.h"
+#include "sci/gui/gui_cursor.h"
 
 namespace Sci {
 
@@ -43,6 +44,7 @@
 	int oldx, oldy;
 	int modifier_mask = getSciVersion() <= SCI_VERSION_01 ? SCI_EVM_ALL : SCI_EVM_NO_FOOLOCK;
 	SegManager *segMan = s->_segMan;
+	Common::Point mousePos = s->_cursor->getPosition();
 
 	// If there's a simkey pending, and the game wants a keyboard event, use the
 	// simkey instead of a normal event
@@ -50,22 +52,22 @@
 		PUT_SEL32V(obj, type, SCI_EVT_KEYBOARD); // Keyboard event
 		PUT_SEL32V(obj, message, g_debug_simulated_key);
 		PUT_SEL32V(obj, modifiers, SCI_EVM_NUMLOCK); // Numlock on
-		PUT_SEL32V(obj, x, s->gfx_state->pointer_pos.x);
-		PUT_SEL32V(obj, y, s->gfx_state->pointer_pos.y);
+		PUT_SEL32V(obj, x, mousePos.x);
+		PUT_SEL32V(obj, y, mousePos.y);
 		g_debug_simulated_key = 0;
 		return make_reg(0, 1);
 	}
 
-	oldx = s->gfx_state->pointer_pos.x;
-	oldy = s->gfx_state->pointer_pos.y;
+	oldx = mousePos.x;
+	oldy = mousePos.y;
 	e = gfxop_get_event(s->gfx_state, mask);
 
 	s->parser_event = NULL_REG; // Invalidate parser event
 
-	PUT_SEL32V(obj, x, s->gfx_state->pointer_pos.x);
-	PUT_SEL32V(obj, y, s->gfx_state->pointer_pos.y);
+	PUT_SEL32V(obj, x, mousePos.x);
+	PUT_SEL32V(obj, y, mousePos.y);
 
-	//s->gui->moveCursor(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:
@@ -94,11 +96,12 @@
 	case SCI_EVT_MOUSE_RELEASE:
 	case SCI_EVT_MOUSE_PRESS: {
 		int extra_bits = 0;
+		Common::Point mousePos = s->_cursor->getPosition();
 
 		// track left buttton clicks, if requested
 		if (e.type == SCI_EVT_MOUSE_PRESS && e.data == 1 && g_debug_track_mouse_clicks) {
 			((SciEngine *)g_engine)->getSciDebugger()->DebugPrintf("Mouse clicked at %d, %d\n", 
-						s->gfx_state->pointer_pos.x, s->gfx_state->pointer_pos.y);
+						mousePos.x, mousePos.y);
 		}
 
 		if (mask & e.type) {
@@ -210,7 +213,7 @@
 		int16 x = GET_SEL32V(obj, x);
 		int16 y = GET_SEL32V(obj, y);
 
-		s->gui->globalToLocal(&x, &y);
+		s->_gui->globalToLocal(&x, &y);
 
 		PUT_SEL32V(obj, x, x);
 		PUT_SEL32V(obj, y, y);
@@ -228,7 +231,7 @@
 		int16 x = GET_SEL32V(obj, x);
 		int16 y = GET_SEL32V(obj, y);
 
-		s->gui->localToGlobal(&x, &y);
+		s->_gui->localToGlobal(&x, &y);
 
 		PUT_SEL32V(obj, x, x);
 		PUT_SEL32V(obj, y, y);

Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-10-07 21:25:31 UTC (rev 44759)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-10-07 21:29:47 UTC (rev 44760)
@@ -39,6 +39,7 @@
 #include "sci/gfx/gfx_state_internal.h"	// required for GfxContainer, GfxPort, GfxVisual
 #include "sci/gfx/seq_decoder.h"
 #include "sci/gui/gui.h"
+#include "sci/gui/gui_cursor.h"
 
 namespace Sci {
 
@@ -275,14 +276,14 @@
 	if (argc >= 4) {
 		pos.y = argv[3].toSint16();
 		pos.x = argv[2].toSint16();
-		s->gui->setCursorPos(pos);
+		s->_gui->setCursorPos(pos);
 	}
 
 	if ((argc >= 2) && (argv[1].toSint16() == 0)) {
 		cursorId = -1;
 	}
 
-	s->gui->setCursorShape(cursorId);
+	s->_gui->setCursorShape(cursorId);
 	return s->r_acc;
 }
 
@@ -293,14 +294,14 @@
 	switch (argc) {
 	case 1:
 		if (argv[0].isNull())
-			s->gui->setCursorHide();
+			s->_gui->hideCursor();
 		else
-			s->gui->setCursorShow();
+			s->_gui->showCursor();
 		break;
 	case 2:
 		pos.y = argv[1].toSint16();
 		pos.x = argv[0].toSint16();
-		s->gui->setCursorPos(pos);
+		s->_gui->setCursorPos(pos);
 		break;
 	case 4: {
 		int16 top = argv[0].toSint16();
@@ -310,7 +311,7 @@
 
 		if ((right >= left) && (bottom >= top)) {
 			Common::Rect rect = Common::Rect(left, top, right, bottom);
-			gfxop_set_pointer_zone(s->gfx_state, rect);
+			s->_cursor->setMoveZone(rect);
 		} else {
 			warning("kSetCursor: Ignoring invalid mouse zone (%i, %i)-(%i, %i)", left, top, right, bottom);
 		}
@@ -349,7 +350,7 @@
 	if (argc == 2) {
 		pos.y = argv[1].toSint16();
 		pos.x = argv[0].toSint16();
-		s->gui->moveCursor(pos);
+		s->_gui->moveCursor(pos);
 	}
 	return s->r_acc;
 }
@@ -448,27 +449,27 @@
 		color = argv[5].toSint16();
 
 		// FIXME: rect must be changed to 2 Common::Point
-		s->gui->graphDrawLine(Common::Point(x, y), Common::Point(x1, y1), color, priority, control);
+		s->_gui->graphDrawLine(Common::Point(x, y), Common::Point(x1, y1), color, priority, control);
 		break;
 
 	case K_GRAPH_SAVE_BOX:
 		rect = Common::Rect(x, y, x1, y1);
 		flags = (argc > 5) ? argv[5].toUint16() : 0;
-		return s->gui->graphSaveBox(rect, flags);
+		return s->_gui->graphSaveBox(rect, flags);
 		break;
 
 	case K_GRAPH_RESTORE_BOX:
-		s->gui->graphRestoreBox(argv[1]);
+		s->_gui->graphRestoreBox(argv[1]);
 		break;
 
 	case K_GRAPH_FILL_BOX_BACKGROUND:
 		rect = Common::Rect(x, y, x1, y1);
-		s->gui->graphFillBoxBackground(rect);
+		s->_gui->graphFillBoxBackground(rect);
 		break;
 
 	case K_GRAPH_FILL_BOX_FOREGROUND:
 		rect = Common::Rect(x, y, x1, y1);
-		s->gui->graphFillBoxForeground(rect);
+		s->_gui->graphFillBoxForeground(rect);
 		break;
 
 	case K_GRAPH_FILL_BOX_ANY:
@@ -478,7 +479,7 @@
 		colorMask = argv[5].toUint16();
 
 		rect = Common::Rect(x, y, x1, y1);
-		s->gui->graphFillBox(rect, colorMask, color, priority, control);
+		s->_gui->graphFillBox(rect, colorMask, color, priority, control);
 		break;
 
 	case K_GRAPH_UPDATE_BOX: {
@@ -551,7 +552,7 @@
 	}
 
 	textWidth = dest[3].toUint16(); textHeight = dest[2].toUint16();
-	s->gui->textSize(s->strSplit(text.c_str(), sep).c_str(), font_nr, maxwidth, &textWidth, &textHeight);
+	s->_gui->textSize(s->strSplit(text.c_str(), sep).c_str(), font_nr, maxwidth, &textWidth, &textHeight);
 	debugC(2, kDebugLevelStrings, "GetTextSize '%s' -> %dx%d\n", text.c_str(), textWidth, textHeight);
 
 	dest[2] = make_reg(0, textHeight);
@@ -578,7 +579,7 @@
 
 	// FIXME: we should not be asking from the GUI to wait. The kernel sounds
 	// like a better place
-	s->gui->wait(sleep_time);
+	s->_gui->wait(sleep_time);
 
 	return s->r_acc;
 }
@@ -897,7 +898,7 @@
 		rect.right = rect.left + 1;
 		rect.bottom = rect.top + 1;
 	}
-	return make_reg(0, s->gui->onControl(screenMask, rect));
+	return make_reg(0, s->_gui->onControl(screenMask, rect));
 }
 
 void _k_view_list_free_backgrounds(EngineState *s, ViewObject *list, int list_nr);
@@ -928,7 +929,7 @@
 	if (argc >= 4)
 		EGApaletteNo = argv[3].toUint16();
 
-	s->gui->drawPicture(pictureId, animationNr, mirroredFlag, addToFlag, EGApaletteNo);
+	s->_gui->drawPicture(pictureId, animationNr, mirroredFlag, addToFlag, EGApaletteNo);
 
 	return s->r_acc;
 }
@@ -1096,7 +1097,7 @@
 }
 
 reg_t kSetNowSeen(EngineState *s, int argc, reg_t *argv) {
-	s->gui->setNowSeen(argv[0]);
+	s->_gui->setNowSeen(argv[0]);
 	return s->r_acc;
 }
 
@@ -1107,7 +1108,7 @@
 		if (argc==3) {
 			int resourceNo = argv[1].toUint16();
 			int flags = argv[2].toUint16();
-			s->gui->paletteSet(resourceNo, flags);
+			s->_gui->paletteSet(resourceNo, flags);
 		}
 		break;
 	case 2:
@@ -1123,7 +1124,7 @@
 			int intensity = argv[3].toUint16();
 			bool setPalette = (argc < 5) ? true : (argv[5].isNull()) ? true : false;
 
-			s->gui->paletteSetIntensity(fromColor, toColor, intensity, setPalette);
+			s->_gui->paletteSetIntensity(fromColor, toColor, intensity, setPalette);
 		}
 		break;
 	}
@@ -1132,14 +1133,14 @@
 		int g = argv[2].toUint16();
 		int b = argv[3].toUint16();
 
-		return make_reg(0, s->gui->paletteFind(r, g, b));
+		return make_reg(0, s->_gui->paletteFind(r, g, b));
 	}
 	case 6:
 		if (argc==4) {
 			int fromColor = argv[1].toUint16();
 			int toColor = argv[2].toUint16();
 			int speed = argv[3].toSint16();
-			s->gui->paletteAnimate(fromColor, toColor, speed);
+			s->_gui->paletteAnimate(fromColor, toColor, speed);
 		}
 		break;
 	case 7:
@@ -1444,13 +1445,13 @@
 	switch (type) {
 	case K_CONTROL_BUTTON:
 		debugC(2, kDebugLevelGraphics, "drawing button %04x:%04x to %d,%d\n", PRINT_REG(obj), x, y);
-		s->gui->drawControlButton(rect, obj, s->strSplit(text.c_str(), NULL).c_str(), font_nr, state, hilite);
+		s->_gui->drawControlButton(rect, obj, s->strSplit(text.c_str(), NULL).c_str(), font_nr, state, hilite);
 		return;
 
 	case K_CONTROL_TEXT:
 		mode = (gfx_alignment_t) GET_SEL32V(obj, mode);
 		debugC(2, kDebugLevelGraphics, "drawing text %04x:%04x ('%s') to %d,%d, mode=%d\n", PRINT_REG(obj), text.c_str(), x, y, mode);
-		s->gui->drawControlText(rect, obj, s->strSplit(text.c_str(), NULL).c_str(), font_nr, mode, state, hilite);
+		s->_gui->drawControlText(rect, obj, s->strSplit(text.c_str(), NULL).c_str(), font_nr, mode, state, hilite);
 		return;
 
 	case K_CONTROL_EDIT:
@@ -1468,7 +1469,7 @@
 
 	case K_CONTROL_ICON:
 		debugC(2, kDebugLevelGraphics, "drawing icon control %04x:%04x to %d,%d\n", PRINT_REG(obj), x, y - 1);
-		s->gui->drawControlIcon(rect, obj, view, loop, cel, state, hilite);
+		s->_gui->drawControlIcon(rect, obj, view, loop, cel, state, hilite);
 		return;
 
 	case K_CONTROL_CONTROL:
@@ -1572,7 +1573,7 @@
 	case 0:
 		break;
 	case 1:
-		s->gui->addToPicList(argv[0], argc, argv);
+		s->_gui->addToPicList(argv[0], argc, argv);
 		break;
 	case 7:
 		viewId = argv[0].toUint16();
@@ -1582,7 +1583,7 @@
 		topPos = argv[4].toSint16();
 		priority = argv[5].toSint16();
 		control = argv[6].toSint16();
-		s->gui->addToPicView(viewId, loopNo, celNo, leftPos, topPos, priority, control);
+		s->_gui->addToPicView(viewId, loopNo, celNo, leftPos, topPos, priority, control);
 		break;
 	default:
 		error("kAddToPic with unsupported parameter count %d", argc);
@@ -1591,7 +1592,7 @@
 }
 
 reg_t kGetPort(EngineState *s, int argc, reg_t *argv) {
-	return s->gui->getPort();
+	return s->_gui->getPort();
 }
 
 reg_t kSetPort(EngineState *s, int argc, reg_t *argv) {
@@ -1602,7 +1603,7 @@
 	switch (argc) {
 		case 1:
 		portPtr = argv[0].toSint16();
-		s->gui->setPort(portPtr);
+		s->_gui->setPort(portPtr);
 		break;
 
 		case 6:
@@ -1612,7 +1613,7 @@
 		picRect.right = argv[3].toSint16();
 		picTop = argv[4].toSint16();
 		picLeft = argv[5].toSint16();
-		s->gui->setPortPic(picRect, picTop, picLeft);
+		s->_gui->setPortPic(picRect, picTop, picLeft);
 		break;
 
 		default:
@@ -1631,7 +1632,7 @@
 	int priority = (argc > 5) ? argv[5].toUint16()  : -1;
 	int paletteNo = (argc > 6) ? argv[6].toSint16() : 0;
 
-	s->gui->drawCel(viewId, loopNo, celNo, x, y, priority, paletteNo);
+	s->_gui->drawCel(viewId, loopNo, celNo, x, y, priority, paletteNo);
 
 	return s->r_acc;
 }
@@ -1640,7 +1641,7 @@
 	int goner_nr = argv[0].toSint16();
 	int arg2 = (argc != 2 || argv[2].toUint16() == 0 ? 0 : 1);
 
-	s->gui->disposeWindow(goner_nr, arg2);
+	s->_gui->disposeWindow(goner_nr, arg2);
 	return s->r_acc;
 }
 
@@ -1664,14 +1665,14 @@
 		title = s->strSplit(title.c_str(), NULL);
 	}
 
-	return s->gui->newWindow(rect1, rect2, style, priority, colorPen, colorBack, title.c_str());
+	return s->_gui->newWindow(rect1, rect2, style, priority, colorPen, colorBack, title.c_str());
 }
 
 reg_t kAnimate(EngineState *s, int argc, reg_t *argv) {
 	reg_t castListReference = (argc > 0) ? argv[0] : NULL_REG;
 	bool cycle = (argc > 1) ? ((argv[1].toUint16()) ? true : false) : false;
 
-	s->gui->animate(castListReference, cycle, argc, argv);
+	s->_gui->animate(castListReference, cycle, argc, argv);
 	return s->r_acc;
 }
 
@@ -1729,7 +1730,7 @@
 		text = kernel_lookup_text(s, textp, index);
 	}
 
-	s->gui->display(s->strSplit(text.c_str()).c_str(), argc, argv);
+	s->_gui->display(s->strSplit(text.c_str()).c_str(), argc, argv);
 	return s->r_acc;
 }
 
@@ -1889,12 +1890,12 @@
 // New calls for SCI11. Using those is only needed when using text-codes so that one is able to change
 //  font and/or color multiple times during kDisplay and kDrawControl
 reg_t kTextFonts(EngineState *s, int argc, reg_t *argv) {
-	s->gui->textFonts(argc, argv);
+	s->_gui->textFonts(argc, argv);
 	return s->r_acc;
 }
 
 reg_t kTextColors(EngineState *s, int argc, reg_t *argv) {
-	s->gui->textColors(argc, argv);
+	s->_gui->textColors(argc, argv);
 	return s->r_acc;
 }
 

Modified: scummvm/trunk/engines/sci/engine/kmenu.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kmenu.cpp	2009-10-07 21:25:31 UTC (rev 44759)
+++ scummvm/trunk/engines/sci/engine/kmenu.cpp	2009-10-07 21:29:47 UTC (rev 44760)
@@ -31,6 +31,7 @@
 #include "sci/gfx/menubar.h"
 #include "sci/gfx/gfx_state_internal.h"	// required for GfxPort, GfxVisual
 #include "sci/gui/gui.h"
+#include "sci/gui/gui_cursor.h"
 
 namespace Sci {
 
@@ -75,7 +76,7 @@
 		// Sometimes this is called without giving text, if thats the case dont process it
 		text = s->_segMan->getString(textReference);
 
-		s->gui->drawStatus(s->strSplit(text.c_str(), NULL).c_str(), colorPen, colorBack);
+		s->_gui->drawStatus(s->strSplit(text.c_str(), NULL).c_str(), colorPen, colorBack);
 	}
 	return s->r_acc;
 }
@@ -174,7 +175,9 @@
 		}
 	}
 
-	if ((type == SCI_EVT_MOUSE_PRESS) && (s->gfx_state->pointer_pos.y < 10)) {
+	Common::Point cursorPos = s->_cursor->getPosition();
+
+	if ((type == SCI_EVT_MOUSE_PRESS) && (cursorPos.y < 10)) {
 		menu_mode = 1;
 		mouse_down = 1;
 	}
@@ -188,7 +191,7 @@
 
 		/* Default to menu 0, unless the mouse was used to generate this effect */
 		if (mouse_down)
-			s->_menubar->mapPointer(s->gfx_state->pointer_pos, menu_nr, item_nr, port);
+			s->_menubar->mapPointer(cursorPos, menu_nr, item_nr, port);
 		else
 			menu_nr = 0;
 
@@ -261,9 +264,12 @@
 				break;
 
 			case SCI_EVT_MOUSE_RELEASE:
-				menu_mode = (s->gfx_state->pointer_pos.y < 10);
-				claimed = !menu_mode && !s->_menubar->mapPointer(s->gfx_state->pointer_pos, menu_nr, item_nr, port);
+				{
+				Common::Point curMousePos = s->_cursor->getPosition();
+				menu_mode = (curMousePos.y < 10);
+				claimed = !menu_mode && !s->_menubar->mapPointer(curMousePos, menu_nr, item_nr, port);
 				mouse_down = 0;
+				}
 				break;
 
 			case SCI_EVT_MOUSE_PRESS:
@@ -276,7 +282,7 @@
 			}
 
 			if (mouse_down)
-				s->_menubar->mapPointer(s->gfx_state->pointer_pos, menu_nr, item_nr, port);
+				s->_menubar->mapPointer(s->_cursor->getPosition(), menu_nr, item_nr, port);
 
 			if ((item_nr > -1 && old_item == -1) || (menu_nr != old_menu)) { /* Update menu */
 

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2009-10-07 21:25:31 UTC (rev 44759)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2009-10-07 21:29:47 UTC (rev 44760)
@@ -737,7 +737,7 @@
 	}
 
 	// FIXME: Do in-place loading at some point, instead of creating a new EngineState instance from scratch.
-	retval = new EngineState(s->resMan, s->_kernel, s->_voc, s->_flags);
+	retval = new EngineState(s->resMan, s->_kernel, s->_voc, s->_gui, s->_cursor, s->_flags);
 
 	// Copy some old data
 	retval->gfx_state = s->gfx_state;
@@ -797,8 +797,6 @@
 	// Message state:
 	retval->_msgState = s->_msgState;
 
-	retval->gui = s->gui;
-
 	return retval;
 }
 

Modified: scummvm/trunk/engines/sci/engine/state.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/state.cpp	2009-10-07 21:25:31 UTC (rev 44759)
+++ scummvm/trunk/engines/sci/engine/state.cpp	2009-10-07 21:29:47 UTC (rev 44760)
@@ -29,8 +29,8 @@
 
 namespace Sci {
 
-EngineState::EngineState(ResourceManager *res, Kernel *kernel, Vocabulary *voc, uint32 flags)
-: resMan(res), _kernel(kernel), _voc(voc), _flags(flags), _dirseeker(this) {
+EngineState::EngineState(ResourceManager *res, Kernel *kernel, Vocabulary *voc, SciGui *gui, SciGuiCursor *cursor, uint32 flags)
+: resMan(res), _kernel(kernel), _voc(voc), _gui(gui), _cursor(cursor), _flags(flags), _dirseeker(this) {
 
 	gfx_state = 0;
 	old_screen = 0;

Modified: scummvm/trunk/engines/sci/engine/state.h
===================================================================
--- scummvm/trunk/engines/sci/engine/state.h	2009-10-07 21:25:31 UTC (rev 44759)
+++ scummvm/trunk/engines/sci/engine/state.h	2009-10-07 21:29:47 UTC (rev 44760)
@@ -49,6 +49,7 @@
 
 class Menubar;
 class SciGui;
+class SciGuiCursor;
 
 struct GfxState;
 struct GfxPort;
@@ -159,7 +160,7 @@
 
 struct EngineState : public Common::Serializable {
 public:
-	EngineState(ResourceManager *res, Kernel *kernel, Vocabulary *voc, uint32 flags);
+	EngineState(ResourceManager *res, Kernel *kernel, Vocabulary *voc, SciGui *gui, SciGuiCursor *cursor, uint32 flags);
 	virtual ~EngineState();
 
 	virtual void saveLoadWithSerializer(Common::Serializer &ser);
@@ -176,7 +177,8 @@
 
 	/* Non-VM information */
 
-	SciGui *gui; /* Currently active Gui */
+	SciGui *_gui; /* Currently active Gui */
+	SciGuiCursor *_cursor;	/* Cursor functions */
 
 	GfxState *gfx_state; /**< Graphics state and driver */
 	gfx_pixmap_t *old_screen; /**< Old screen content: Stored during kDrawPic() for kAnimate() */

Modified: scummvm/trunk/engines/sci/gfx/gfx_driver.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_driver.cpp	2009-10-07 21:25:31 UTC (rev 44759)
+++ scummvm/trunk/engines/sci/gfx/gfx_driver.cpp	2009-10-07 21:29:47 UTC (rev 44760)
@@ -168,6 +168,7 @@
 		}
 		break;
 	case GFX_BUFFER_FRONT: {
+		// TODO: we need to call SciGuiCursor::refreshPosition() before each screen update to limit the mouse cursor position
 		g_system->copyRectToScreen(_screen->_displayScreen + (src.x + src.y * _mode->xsize), _mode->xsize, dest.x, dest.y, src.width, src.height);
 		g_system->updateScreen();
 		break;

Modified: scummvm/trunk/engines/sci/gfx/operations.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.cpp	2009-10-07 21:25:31 UTC (rev 44759)
+++ scummvm/trunk/engines/sci/gfx/operations.cpp	2009-10-07 21:29:47 UTC (rev 44760)
@@ -249,35 +249,6 @@
 	driver->drawPixmap(pxm, priority, src, clipped_dest, static_buf ? GFX_BUFFER_STATIC : GFX_BUFFER_BACK);
 }
 
-static void _gfxop_full_pointer_refresh(GfxState *state) {
-	bool clipped = false;
-	Common::Point mousePoint = g_system->getEventManager()->getMousePos();
-
-	state->pointer_pos.x = mousePoint.x / state->driver->getMode()->scaleFactor;
-	state->pointer_pos.y = mousePoint.y / state->driver->getMode()->scaleFactor;
-
-	if (state->pointer_pos.x < state->pointerZone.left) {
-		state->pointer_pos.x = state->pointerZone.left;
-		clipped = true;
-	} else if (state->pointer_pos.x >= state->pointerZone.right) {
-		state->pointer_pos.x = state->pointerZone.right - 1;
-		clipped = true;
-	}
-
-	if (state->pointer_pos.y < state->pointerZone.top) {
-		state->pointer_pos.y = state->pointerZone.top;
-		clipped = true;
-	} else if (state->pointer_pos.y >= state->pointerZone.bottom) {
-		state->pointer_pos.y = state->pointerZone.bottom - 1;
-		clipped = true;
-	}
-
-	// FIXME: Do this only when mouse is grabbed?
-	if (clipped)
-		g_system->warpMouse(state->pointer_pos.x * state->driver->getMode()->scaleFactor,
-							state->pointer_pos.y * state->driver->getMode()->scaleFactor);
-}
-
 static void _gfxop_buffer_propagate_box(GfxState *state, rect_t box, gfx_buffer_t buffer);
 
 gfx_pixmap_t *_gfxr_get_cel(GfxState *state, int nr, int *loop, int *cel, int palette) {
@@ -404,7 +375,6 @@
 	state->gfxResMan = new GfxResManager(state->options, state->driver, resMan, screen, palette);
 
 	gfxop_set_clip_zone(state, gfx_rect(0, 0, 320, 200));
-	state->pointerZone = Common::Rect(0, 0, 320, 200);
 
 	init_aux_pixmap(&(state->control_map));
 	init_aux_pixmap(&(state->priority_map));
@@ -720,8 +690,6 @@
 	gfx_line_style_t line_style) {
 	int skipone = (start.x ^ end.y) & 1; // Used for simulated line stippling
 
-	_gfxop_full_pointer_refresh(state);
-
 	// First, make sure that the line is normalized
 	if (start.y > end.y) {
 		Common::Point swap = start;
@@ -778,8 +746,6 @@
 	Common::Point upper_left_u, upper_right_u, lower_left_u, lower_right_u;
 	Common::Point upper_left, upper_right, lower_left, lower_right;
 
-	_gfxop_full_pointer_refresh(state);
-
 	xfact = state->driver->getMode()->scaleFactor;
 	yfact = state->driver->getMode()->scaleFactor;
 
@@ -820,11 +786,8 @@
 	gfx_rectangle_fill_t driver_shade_type;
 	rect_t new_box;
 
-	_gfxop_full_pointer_refresh(state);
-
 	shade_type = GFX_BOX_SHADE_FLAT;
 
-
 	_gfxop_add_dirty(state, box);
 
 	if (color1.mask & GFX_MASK_CONTROL) {
@@ -904,7 +867,6 @@
 extern int sci0_palette;
 
 void gfxop_clear_box(GfxState *state, rect_t box) {
-	_gfxop_full_pointer_refresh(state);
 	_gfxop_add_dirty(state, box);
 	DDIRTY(stderr, "[]  clearing box %d %d %d %d\n", GFX_PRINT_RECT(box));
 
@@ -991,6 +953,7 @@
 	while (true) {
 		// let backend process events and update the screen
 		gfxop_get_event(state, SCI_EVT_PEEK);
+		// TODO: we need to call SciGuiCursor::refreshPosition() before each screen update to limit the mouse cursor position
 		g_system->updateScreen();
 		time = g_system->getMillis();
 		if (time + 10 < wakeup_time) {
@@ -1040,10 +1003,6 @@
 	}
 }
 
-void gfxop_set_pointer_zone(GfxState *state, Common::Rect rect) {
-	state->pointerZone = rect;
-}
-
 #define SCANCODE_ROWS_NR 3
 
 struct scancode_row {
@@ -1359,7 +1318,7 @@
 	//sci_event_t error_event = { SCI_EVT_ERROR, 0, 0, 0 };
 	sci_event_t event = { 0, 0, 0, 0 };
 
-	_gfxop_full_pointer_refresh(state);
+	// TODO: we need to call SciGuiCursor::refreshPosition() before each screen update to limit the mouse cursor position
 
 	// Update the screen here, since it's called very often
 	g_system->updateScreen();
@@ -1391,8 +1350,6 @@
 		// there is no need to change it.
 	}
 
-	_gfxop_full_pointer_refresh(state);
-
 	if (event.type == SCI_EVT_KEYBOARD) {
 		// Do we still have to translate the key?
 
@@ -1719,7 +1676,6 @@
 void gfxop_draw_text(GfxState *state, TextHandle *handle, rect_t zone) {
 	int line_height;
 	rect_t pos;
-	_gfxop_full_pointer_refresh(state);
 
 	if (!handle)
 		error("Attempt to draw text with NULL handle");
@@ -1795,7 +1751,6 @@
 gfx_pixmap_t *gfxop_grab_pixmap(GfxState *state, rect_t area) {
 	gfx_pixmap_t *pixmap = NULL;
 	rect_t resultzone; // Ignored for this application
-	_gfxop_full_pointer_refresh(state);
 
 	_gfxop_scale_rect(&area, state->driver->getMode());
 	_gfxop_grab_pixmap(state, &pixmap, area.x, area.y, area.width, area.height, 0, &resultzone);
@@ -1809,7 +1764,6 @@
 	if (!pxm)
 		error("Attempt to draw NULL pixmap");
 
-	_gfxop_full_pointer_refresh(state);
 	_gfxop_add_dirty(state, target);
 
 	_gfxop_scale_rect(&zone, state->driver->getMode());

Modified: scummvm/trunk/engines/sci/gfx/operations.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.h	2009-10-07 21:25:31 UTC (rev 44759)
+++ scummvm/trunk/engines/sci/gfx/operations.h	2009-10-07 21:29:47 UTC (rev 44760)
@@ -93,9 +93,6 @@
 struct GfxState {
 	gfx_options_t *options;
 
-	Common::Point pointer_pos; /**< Mouse pointer coordinates */
-	Common::Rect pointerZone; /**< Rectangle in which the pointer can move */
-
 	rect_t clip_zone_unscaled; /**< The current UNSCALED clipping zone */
 	rect_t clip_zone; /**< The current SCALED clipping zone; a cached scaled version of clip_zone_unscaled */
 
@@ -388,14 +385,6 @@
 void gfxop_set_pointer_view(GfxState *state, int nr, int loop, int cel, Common::Point *hotspot);
 
 /**
- * Limits the mouse movement to a given rectangle.
- *
- * @param[in] state	The affected state
- * @param[in] rect	The rectangle
- */
-void gfxop_set_pointer_zone(GfxState *state, Common::Rect rect);
-
-/**
  * Retrieves the next input event from the driver.
  *
  * @param[in] state	The affected state

Modified: scummvm/trunk/engines/sci/gui/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-07 21:25:31 UTC (rev 44759)
+++ scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-07 21:29:47 UTC (rev 44760)
@@ -460,11 +460,11 @@
 	_gfx->SetNowSeen(objectReference);
 }
 
-void SciGui::setCursorHide() {
+void SciGui::hideCursor() {
 	_cursor->hide();
 }
 
-void SciGui::setCursorShow() {
+void SciGui::showCursor() {
 	_cursor->show();
 }
 

Modified: scummvm/trunk/engines/sci/gui/gui.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.h	2009-10-07 21:25:31 UTC (rev 44759)
+++ scummvm/trunk/engines/sci/gui/gui.h	2009-10-07 21:29:47 UTC (rev 44760)
@@ -84,8 +84,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 setCursorHide();
-	virtual void setCursorShow();
+	virtual void hideCursor();
+	virtual void showCursor();
 	virtual void setCursorShape(GuiResourceId cursorId);
 	virtual void setCursorPos(Common::Point pos);
 	virtual void moveCursor(Common::Point pos);

Modified: scummvm/trunk/engines/sci/gui/gui_cursor.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_cursor.cpp	2009-10-07 21:25:31 UTC (rev 44759)
+++ scummvm/trunk/engines/sci/gui/gui_cursor.cpp	2009-10-07 21:29:47 UTC (rev 44760)
@@ -25,6 +25,7 @@
 
 #include "graphics/cursorman.h"
 #include "common/util.h"
+#include "common/events.h"
 
 #include "sci/sci.h"
 #include "sci/engine/state.h"
@@ -35,18 +36,16 @@
 
 namespace Sci {
 
-SciGuiCursor::SciGuiCursor(EngineState *state, SciGuiPalette *palette)
-	: _s(state), _palette(palette) {
-	init();
+SciGuiCursor::SciGuiCursor(ResourceManager *resMan, SciGuiPalette *palette)
+	: _resMan(resMan), _palette(palette) {
+	_rawBitmap = NULL;
+
+	setPosition(Common::Point(160, 150));		// TODO: how is that different in 640x400 games?
 }
 
 SciGuiCursor::~SciGuiCursor() {
 }
 
-void SciGuiCursor::init() {
-	_rawBitmap = NULL;
-}
-
 void SciGuiCursor::show() {
 	CursorMan.showMouse(true);
 }
@@ -72,7 +71,7 @@
 	}
 	
 	// Load cursor resource...
-	resource = _s->resMan->findResource(ResourceId(kResourceTypeCursor, resourceId), false);
+	resource = _resMan->findResource(ResourceId(kResourceTypeCursor, resourceId), false);
 	if (!resource)
 		error("cursor resource %d not found", resourceId);
 	if (resource->size != SCI_CURSOR_SCI0_RESOURCESIZE)
@@ -117,4 +116,33 @@
 	g_system->warpMouse(pos.x, pos.y);
 }
 
+Common::Point SciGuiCursor::getPosition() {
+	return g_system->getEventManager()->getMousePos();
+}
+
+void SciGuiCursor::refreshPosition() {
+	bool clipped = false;
+	Common::Point mousePoint = getPosition();
+
+	if (mousePoint.x < _moveZone.left) {
+		mousePoint.x = _moveZone.left;
+		clipped = true;
+	} else if (mousePoint.x >= _moveZone.right) {
+		mousePoint.x = _moveZone.right - 1;
+		clipped = true;
+	}
+
+	if (mousePoint.y < _moveZone.top) {
+		mousePoint.y = _moveZone.top;
+		clipped = true;
+	} else if (mousePoint.y >= _moveZone.bottom) {
+		mousePoint.y = _moveZone.bottom - 1;
+		clipped = true;
+	}
+
+	// FIXME: Do this only when mouse is grabbed?
+	if (clipped)
+		g_system->warpMouse(mousePoint.x, mousePoint.y);
+}
+
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/gui/gui_cursor.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_cursor.h	2009-10-07 21:25:31 UTC (rev 44759)
+++ scummvm/trunk/engines/sci/gui/gui_cursor.h	2009-10-07 21:29:47 UTC (rev 44760)
@@ -39,22 +39,30 @@
 class SciGuiPalette;
 class SciGuiCursor {
 public:
-	SciGuiCursor(EngineState *state, SciGuiPalette *palette);
+	SciGuiCursor(ResourceManager *resMan, SciGuiPalette *palette);
 	~SciGuiCursor();
 
 	void show();
 	void hide();
 	void setShape(GuiResourceId resourceId);
 	void setPosition(Common::Point pos);
+	Common::Point getPosition();
+	void refreshPosition();
 
+	/**
+	 * Limits the mouse movement to a given rectangle.
+	 *
+	 * @param[in] rect	The rectangle
+	 */
+	void setMoveZone(Common::Rect zone) { _moveZone = zone; }
+
 private:
-	void init();
-
-	EngineState *_s;
+	ResourceManager *_resMan;
 	SciGuiScreen *_screen;
 	SciGuiPalette *_palette;
 
 	byte *_rawBitmap;
+	Common::Rect _moveZone; // Rectangle in which the pointer can move
 };
 
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/gui32/gui32.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui32/gui32.cpp	2009-10-07 21:25:31 UTC (rev 44759)
+++ scummvm/trunk/engines/sci/gui32/gui32.cpp	2009-10-07 21:29:47 UTC (rev 44760)
@@ -2002,11 +2002,11 @@
 	_k_set_now_seen(objectReference);
 }
 
-void SciGui32::setCursorHide() {
+void SciGui32::hideCursor() {
 	CursorMan.showMouse(false);
 }
 
-void SciGui32::setCursorShow() {
+void SciGui32::showCursor() {
 	CursorMan.showMouse(true);
 }
 

Modified: scummvm/trunk/engines/sci/gui32/gui32.h
===================================================================
--- scummvm/trunk/engines/sci/gui32/gui32.h	2009-10-07 21:25:31 UTC (rev 44759)
+++ scummvm/trunk/engines/sci/gui32/gui32.h	2009-10-07 21:29:47 UTC (rev 44760)
@@ -77,8 +77,8 @@
 	void addToPicView(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 leftPos, int16 topPos, int16 priority, int16 control);
 	void setNowSeen(reg_t objectReference);
 
-	void setCursorHide();
-	void setCursorShow();
+	void hideCursor();
+	void showCursor();
 	void setCursorShape(GuiResourceId cursorId);
 	void setCursorPos(Common::Point pos);
 	void moveCursor(Common::Point pos);

Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp	2009-10-07 21:25:31 UTC (rev 44759)
+++ scummvm/trunk/engines/sci/sci.cpp	2009-10-07 21:29:47 UTC (rev 44760)
@@ -137,7 +137,8 @@
 	_kernel = new Kernel(_resMan);
 	_vocabulary = new Vocabulary(_resMan);
 
-	_gamestate = new EngineState(_resMan, _kernel, _vocabulary, flags);
+	// we'll set the gui and cursor below
+	_gamestate = new EngineState(_resMan, _kernel, _vocabulary, NULL, NULL, flags);
 
 	if (script_init_engine(_gamestate))
 		return Common::kUnknownError;
@@ -159,11 +160,14 @@
 
 	SciGuiScreen *screen = new SciGuiScreen();
 	SciGuiPalette *palette = new SciGuiPalette(_gamestate, screen);
-	SciGuiCursor *cursor = new SciGuiCursor(_gamestate, palette);
+	SciGuiCursor *cursor = new SciGuiCursor(_resMan, palette);
 
+	_gamestate->_cursor = cursor;
+	_gamestate->_cursor->setMoveZone(Common::Rect(0, 0, 320, 200));
+
 	// Gui change
-	//_gamestate->gui = new SciGui(_gamestate, screen, palette, cursor);    // new
-	_gamestate->gui = new SciGui32(_gamestate, screen, palette, cursor);  // old
+	//_gamestate->_gui = new SciGui(_gamestate, screen, palette, cursor);    // new
+	_gamestate->_gui = new SciGui32(_gamestate, screen, palette, cursor);  // old
 
 	// Assign default values to the config manager, in case settings are missing
 	ConfMan.registerDefault("dither_mode", "0");
@@ -196,7 +200,7 @@
 		return Common::kUnknownError;
 	}
 
-	_gamestate->gui->init(_kernel->usesOldGfxFunctions());
+	_gamestate->_gui->init(_kernel->usesOldGfxFunctions());
 
 	printf("Emulating SCI version %s\n", getSciVersionDesc(getSciVersion()).c_str());
 


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