[Scummvm-git-logs] scummvm master -> c4cabdef0f61a6a170551733d32e909f7e6061c1

stevenhoefel stevenhoefel at hotmail.com
Wed Jan 11 23:45:35 CET 2017


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
c4cabdef0f DIRECTOR: Hooks for both cast member and cast frame events.


Commit: c4cabdef0f61a6a170551733d32e909f7e6061c1
    https://github.com/scummvm/scummvm/commit/c4cabdef0f61a6a170551733d32e909f7e6061c1
Author: stevenhoefel (stevenhoefel at hotmail.com)
Date: 2017-01-12T09:45:23+11:00

Commit Message:
DIRECTOR: Hooks for both cast member and cast frame events.

Changed paths:
    engines/director/frame.cpp
    engines/director/frame.h
    engines/director/score.cpp


diff --git a/engines/director/frame.cpp b/engines/director/frame.cpp
index 6978c57..1d689ab 100644
--- a/engines/director/frame.cpp
+++ b/engines/director/frame.cpp
@@ -604,8 +604,9 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) {
 				int height = _sprites[i]->_height;
 				int width = _sprites[i]->_width;
 
-				Common::Rect drawRect = Common::Rect(x, y, x + width, y + height);
-				_drawRects[i] = drawRect;
+				Common::Rect drawRect(x, y, x + width, y + height);
+
+				addDrawRect(i, drawRect);
 
 				switch (_sprites[i]->_ink) {
 				case kInkTypeCopy:
@@ -637,6 +638,13 @@ void Frame::renderSprites(Graphics::ManagedSurface &surface, bool renderTrail) {
 	}
 }
 
+void Frame::addDrawRect(uint16 spriteId, Common::Rect &rect) {
+	FrameEntity *fi = new FrameEntity();
+	fi->spriteId = spriteId;
+	fi->rect = rect;
+	_drawRects.push_back(fi);
+}
+
 void Frame::renderShape(Graphics::ManagedSurface &surface, uint16 spriteID) {
 	Common::Rect r = Common::Rect(_sprites[spriteID]->_startPoint.x,
 		_sprites[spriteID]->_startPoint.y,
@@ -674,7 +682,7 @@ void Frame::renderShape(Graphics::ManagedSurface &surface, uint16 spriteID) {
 		break;
 	}
 
-	_drawRects[spriteID] = r;
+	addDrawRect(spriteID, r);
 }
 
 void Frame::renderButton(Graphics::ManagedSurface &surface, uint16 spriteId, uint16 textId) {
@@ -698,13 +706,13 @@ void Frame::renderButton(Graphics::ManagedSurface &surface, uint16 spriteId, uin
 		// Magic numbers: checkbox square need to move left about 5px from text and 12px side size (D4)
 		_rect = Common::Rect(x - 17, y, x + 12, y + 12);
 		surface.frameRect(_rect, 0);
-		_drawRects[spriteId] = _rect;
+		addDrawRect(spriteId, _rect);
 		break;
 	case kTypeButton: {
 			_rect = Common::Rect(x, y, x + width - 1, y + height + 5);
 			Graphics::MacPlotData pd(&surface, &_vm->getMacWindowManager()->getPatterns(), Graphics::MacGUIConstants::kPatternSolid, 1);
 			Graphics::drawRoundRect(_rect, 4, 0, false, Graphics::macDrawPixel, &pd);
-			_drawRects[spriteId] = _rect;
+			addDrawRect(spriteId, _rect);
 		}
 		break;
 	case kTypeRadio:
@@ -1042,11 +1050,10 @@ void Frame::drawMatteSprite(Graphics::ManagedSurface &target, const Graphics::Su
 }
 
 uint16 Frame::getSpriteIDFromPos(Common::Point pos) {
-	// Find first from top to bottom
-	//TODO: THIS NEEDS TO BE REVERSED!
-	for (Common::HashMap<uint16, Common::Rect>::const_iterator dr = _drawRects.begin(); dr != _drawRects.end(); dr++)
-		if (dr->_value.contains(pos))
-			return dr->_key;
+	// Find first from front to back
+	for (int dr = _drawRects.size() - 1; dr >= 0; dr--)
+		if (_drawRects[dr]->rect.contains(pos))
+			return _drawRects[dr]->spriteId;
 
 	return 0;
 }
diff --git a/engines/director/frame.h b/engines/director/frame.h
index 29ae9dd..b71afb7 100644
--- a/engines/director/frame.h
+++ b/engines/director/frame.h
@@ -104,6 +104,11 @@ struct PaletteInfo {
 	uint16 cycleCount;
 };
 
+struct FrameEntity {
+	uint16 spriteId;
+	Common::Rect rect;
+};
+
 
 class Frame {
 public:
@@ -131,6 +136,7 @@ private:
 	void drawMatteSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect);
 	void drawGhostSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect);
 	void drawReverseSprite(Graphics::ManagedSurface &target, const Graphics::Surface &sprite, Common::Rect &drawRect);
+	void addDrawRect(uint16 entityId, Common::Rect &rect);
 
 public:
 	byte _channelData[kChannelDataSize];
@@ -150,7 +156,7 @@ public:
 	uint8 _skipFrameFlag;
 	uint8 _blend;
 	Common::Array<Sprite *> _sprites;
-	Common::HashMap<uint16, Common::Rect> _drawRects;
+	Common::Array<FrameEntity *> _drawRects;
 	DirectorEngine *_vm;
 };
 
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index fb384c2..267536b 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -935,8 +935,6 @@ void Score::update() {
 	if (_vm->getVersion() >= 6)
 		_lingo->processEvent(kEventPrepareFrame, _currentFrame);
 
-	_currentFrame++;
-
 	Common::SortedArray<Label *>::iterator i;
 	if (_labels != NULL) {
 		for (i = _labels->begin(); i != _labels->end(); ++i) {
@@ -946,6 +944,8 @@ void Score::update() {
 		}
 	}
 
+	_currentFrame++;
+
 	_frames[_currentFrame]->prepareFrame(this);
 	// Stage is drawn between the prepareFrame and enterFrame events (Lingo in a Nutshell)
 
@@ -998,14 +998,19 @@ void Score::processEvents() {
 			if (event.type == Common::EVENT_LBUTTONDOWN) {
 				Common::Point pos = g_system->getEventManager()->getMousePos();
 
-				// TODO there is dont send frame id
-				_lingo->processEvent(kEventMouseDown, _frames[_currentFrame]->getSpriteIDFromPos(pos));
+				//TODO: check that this is the order of script execution!
+				uint16 spriteId = _frames[_currentFrame]->getSpriteIDFromPos(pos);
+				_lingo->processEvent(kEventMouseDown, _frames[_currentFrame]->_sprites[spriteId]->_castId);
+				_lingo->processEvent(kEventMouseDown, _frames[_currentFrame]->_sprites[spriteId]->_scriptId);
 			}
 
 			if (event.type == Common::EVENT_LBUTTONUP) {
 				Common::Point pos = g_system->getEventManager()->getMousePos();
 
-				_lingo->processEvent(kEventMouseUp, _frames[_currentFrame]->getSpriteIDFromPos(pos));
+				//TODO: check that this is the order of script execution!
+				uint16 spriteId = _frames[_currentFrame]->getSpriteIDFromPos(pos);
+				_lingo->processEvent(kEventMouseUp, _frames[_currentFrame]->_sprites[spriteId]->_castId);
+				_lingo->processEvent(kEventMouseUp, _frames[_currentFrame]->_sprites[spriteId]->_scriptId);
 			}
 
 			if (event.type == Common::EVENT_KEYDOWN) {





More information about the Scummvm-git-logs mailing list