[Scummvm-cvs-logs] SF.net SVN: scummvm: [23449] scummvm/trunk

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Thu Jul 20 22:37:45 CEST 2006


Revision: 23449
          http://svn.sourceforge.net/scummvm/?rev=23449&view=rev
Author:   fingolfin
Date:     2006-07-09 02:40:44 -0700 (Sun, 09 Jul 2006)

Log Message:
-----------
Added OSystem::setFocusRectangle (first part of Nintendo DS patch)

Modified Paths:
--------------
    scummvm/trunk/common/system.h
    scummvm/trunk/engines/queen/display.cpp
    scummvm/trunk/engines/queen/display.h
    scummvm/trunk/engines/queen/talk.cpp
    scummvm/trunk/engines/scumm/actor.cpp
    scummvm/trunk/engines/sky/logic.cpp
    scummvm/trunk/engines/sky/screen.cpp
    scummvm/trunk/engines/sky/screen.h

Modified: scummvm/trunk/common/system.h
===================================================================
--- scummvm/trunk/common/system.h	2006-07-09 08:45:20 UTC (rev 23448)
+++ scummvm/trunk/common/system.h	2006-07-09 09:40:44 UTC (rev 23449)
@@ -439,6 +439,28 @@
 	 *       and instead implement the functionality in the frontend.
 	 */
 	virtual void setShakePos(int shakeOffset) = 0;
+		
+	/**
+	 * Sets the area of the screen that has the focus.  For example, when a character
+	 * is speaking, they will have the focus.  Allows for pan-and-scan style views
+	 * where the backend could follow the speaking character or area of interest on 
+	 * the screen.
+	 *
+	 * The backend is responsible for clipping the rectangle and deciding how best to
+	 * zoom the screen to show any shape and size rectangle the engine provides.
+	 *
+	 * @param rect A rectangle on the screen to be focused on
+	 * @see clearFocusRectangle
+	 */	
+	virtual void setFocusRectangle(const Common::Rect& rect) {}
+	
+	/**
+	 * Clears the focus set by a call to setFocusRectangle().  This allows the engine
+	 * to clear the focus during times when no particular area of the screen has the
+	 * focus.
+	 * @see setFocusRectangle
+	 */
+	virtual void clearFocusRectangle() {}
 
 	//@}
 

Modified: scummvm/trunk/engines/queen/display.cpp
===================================================================
--- scummvm/trunk/engines/queen/display.cpp	2006-07-09 08:45:20 UTC (rev 23448)
+++ scummvm/trunk/engines/queen/display.cpp	2006-07-09 09:40:44 UTC (rev 23449)
@@ -851,6 +851,10 @@
 	}
 }
 
+void Display::setFocusRect(const Common::Rect& rect) {
+	_system->setFocusRectangle(rect);
+}
+
 int Display::textCenterX(const char *text) const {
 	return (GAME_SCREEN_WIDTH - textWidth(text)) / 2;
 }

Modified: scummvm/trunk/engines/queen/display.h
===================================================================
--- scummvm/trunk/engines/queen/display.h	2006-07-09 08:45:20 UTC (rev 23448)
+++ scummvm/trunk/engines/queen/display.h	2006-07-09 09:40:44 UTC (rev 23449)
@@ -28,6 +28,9 @@
 #include "queen/defs.h"
 
 class OSystem;
+namespace Common {
+	struct Rect;
+}
 
 namespace Queen {
 
@@ -148,6 +151,9 @@
 
 	//! change the text color for the specified texts list entry
 	void textColor(uint16 y, uint8 color) { _texts[y].color = color; }
+	
+	//! Set the focus rectangle to the speaking character
+	void setFocusRect(const Common::Rect& rect);
 
 	int textCenterX(const char *text) const;
 	uint16 textWidth(const char *text) const;

Modified: scummvm/trunk/engines/queen/talk.cpp
===================================================================
--- scummvm/trunk/engines/queen/talk.cpp	2006-07-09 08:45:20 UTC (rev 23448)
+++ scummvm/trunk/engines/queen/talk.cpp	2006-07-09 09:40:44 UTC (rev 23449)
@@ -21,6 +21,7 @@
  */
 
 #include "common/stdafx.h"
+#include "common/rect.h"
 #include "queen/talk.h"
 
 #include "queen/bankman.h"
@@ -865,6 +866,16 @@
 		textY = bob->y;
 	}
 
+	// Set the focus rectangle
+	// FIXME: This may not be correct!
+	BobFrame *pbf = _vm->bankMan()->fetchFrame(bob->frameNum);
+
+	int height = (pbf->height * bob->scale) / 100;
+	
+	Common::Rect focus(textX - 96, textY - height - 64, textX + 96, textY + height + 64);
+	_vm->display()->setFocusRect(focus);
+	
+
 	//int SF = _vm->grid()->findScale(textX, textY);
 
 	const SpeechParameters *parameters = NULL;

Modified: scummvm/trunk/engines/scumm/actor.cpp
===================================================================
--- scummvm/trunk/engines/scumm/actor.cpp	2006-07-09 08:45:20 UTC (rev 23448)
+++ scummvm/trunk/engines/scumm/actor.cpp	2006-07-09 09:40:44 UTC (rev 23449)
@@ -22,6 +22,7 @@
  */
 
 #include "common/stdafx.h"
+#include "common/system.h"	// for setFocusRectangle/clearFocusRectangle
 #include "scumm/scumm.h"
 #include "scumm/actor.h"
 #include "scumm/akos.h"
@@ -844,6 +845,20 @@
 }
 
 void ScummEngine::setTalkingActor(int value) {
+
+	if (value == 255) {
+		_system->clearFocusRectangle();
+	} else {
+		// Work out the screen co-ordinates of the actor
+		int x = _actors[value]._pos.x - (camera._cur.x - (_screenWidth >> 1));
+		int y = _actors[value]._top - (camera._cur.y - (_screenHeight >> 1));
+		
+		// Set the focus area to the calculated position
+		// TODO: Make the size adjust depending on what it's focusing on.
+		Common::Rect rect(x - 96, y - 64, x + 96, y + 64);
+		_system->setFocusRectangle(rect);
+	}
+
 	if (_game.id == GID_MANIAC && _game.version <= 1 && !(_game.platform == Common::kPlatformNES))
 		_V1TalkingActor = value;
 	else

Modified: scummvm/trunk/engines/sky/logic.cpp
===================================================================
--- scummvm/trunk/engines/sky/logic.cpp	2006-07-09 08:45:20 UTC (rev 23448)
+++ scummvm/trunk/engines/sky/logic.cpp	2006-07-09 09:40:44 UTC (rev 23449)
@@ -22,6 +22,7 @@
 
 #include "common/stdafx.h"
 #include "common/endian.h"
+#include "common/rect.h"
 
 #include "sky/autoroute.h"
 #include "sky/compact.h"
@@ -2512,6 +2513,17 @@
 	if (SkyEngine::isCDVersion())
 		speechFileFound = _skySound->startSpeech((uint16)textNum);
 
+	
+	// Calculate the point where the character is
+	int x = (((uint32) (target->xcood)) * GAME_SCREEN_WIDTH) >> 9;
+	int y = ((((uint32) (target->ycood)) * GAME_SCREEN_HEIGHT) >> 9);
+
+	// Set the focus region to that area
+	// TODO: Make the box size change based on the object that has the focus
+	Common::Rect rect(x - 96, y - 64, x + 96, y + 64);
+	_skyScreen->setFocusRectangle(rect);
+
+
 	if ((SkyEngine::_systemVars.systemFlags & SF_ALLOW_TEXT) || !speechFileFound) {
 		// form the text sprite, if player wants subtitles or
 		// if we couldn't find the speech file

Modified: scummvm/trunk/engines/sky/screen.cpp
===================================================================
--- scummvm/trunk/engines/sky/screen.cpp	2006-07-09 08:45:20 UTC (rev 23448)
+++ scummvm/trunk/engines/sky/screen.cpp	2006-07-09 09:40:44 UTC (rev 23449)
@@ -105,6 +105,10 @@
 	_system->updateScreen();
 }
 
+void Screen::setFocusRectangle(const Common::Rect& rect) {
+	_system->setFocusRectangle(rect);
+}
+
 //set a new palette, pal is a pointer to dos vga rgb components 0..63
 void Screen::setPalette(uint8 *pal) {
 

Modified: scummvm/trunk/engines/sky/screen.h
===================================================================
--- scummvm/trunk/engines/sky/screen.h	2006-07-09 08:45:20 UTC (rev 23448)
+++ scummvm/trunk/engines/sky/screen.h	2006-07-09 09:40:44 UTC (rev 23449)
@@ -28,6 +28,9 @@
 #include "sky/skydefs.h"
 
 class OSystem;
+namespace Common {
+	struct Rect;
+}
 
 namespace Sky {
 
@@ -80,6 +83,7 @@
 	void fnFadeDown(uint32 scroll);
 	void fnDrawScreen(uint32 palette, uint32 scroll);
 	void clearScreen(void);
+	void setFocusRectangle(const Common::Rect& rect);
 
 	void recreate(void);
 	void flip(bool doUpdate = true);






More information about the Scummvm-git-logs mailing list