[Scummvm-cvs-logs] SF.net SVN: scummvm:[52292] scummvm/trunk/engines/mohawk

mthreepwood at users.sourceforge.net mthreepwood at users.sourceforge.net
Mon Aug 23 06:14:31 CEST 2010


Revision: 52292
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52292&view=rev
Author:   mthreepwood
Date:     2010-08-23 04:14:30 +0000 (Mon, 23 Aug 2010)

Log Message:
-----------
MOHAWK: Add initial work for the dome sliders

While the sliders cannot move yet, the game now knows if the puzzle is complete and whether you're over a slider or not. Drawing the sliders and moving the sliders will come next.

Modified Paths:
--------------
    scummvm/trunk/engines/mohawk/console.cpp
    scummvm/trunk/engines/mohawk/console.h
    scummvm/trunk/engines/mohawk/graphics.h
    scummvm/trunk/engines/mohawk/riven_external.cpp
    scummvm/trunk/engines/mohawk/riven_external.h

Modified: scummvm/trunk/engines/mohawk/console.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/console.cpp	2010-08-22 23:55:29 UTC (rev 52291)
+++ scummvm/trunk/engines/mohawk/console.cpp	2010-08-23 04:14:30 UTC (rev 52292)
@@ -309,6 +309,7 @@
 	DCmd_Register("listZipCards",   WRAP_METHOD(RivenConsole, Cmd_ListZipCards));
 	DCmd_Register("getRMAP",		WRAP_METHOD(RivenConsole, Cmd_GetRMAP));
 	DCmd_Register("combos",         WRAP_METHOD(RivenConsole, Cmd_Combos));
+	DCmd_Register("sliderState",    WRAP_METHOD(RivenConsole, Cmd_SliderState));
 }
 
 RivenConsole::~RivenConsole() {
@@ -641,6 +642,14 @@
 	return true;
 }
 
+bool RivenConsole::Cmd_SliderState(int argc, const char **argv) {
+	if (argc > 1)
+		_vm->_externalScriptHandler->setDomeSliderState((uint32)atoi(argv[1]));
+
+	DebugPrintf("Dome Slider State = %08x\n", _vm->_externalScriptHandler->getDomeSliderState());
+	return true;
+}
+
 LivingBooksConsole::LivingBooksConsole(MohawkEngine_LivingBooks *vm) : GUI::Debugger(), _vm(vm) {
 	DCmd_Register("playSound",			WRAP_METHOD(LivingBooksConsole, Cmd_PlaySound));
 	DCmd_Register("stopSound",			WRAP_METHOD(LivingBooksConsole, Cmd_StopSound));

Modified: scummvm/trunk/engines/mohawk/console.h
===================================================================
--- scummvm/trunk/engines/mohawk/console.h	2010-08-22 23:55:29 UTC (rev 52291)
+++ scummvm/trunk/engines/mohawk/console.h	2010-08-23 04:14:30 UTC (rev 52292)
@@ -89,6 +89,7 @@
 	bool Cmd_ListZipCards(int argc, const char **argv);
 	bool Cmd_GetRMAP(int argc, const char **argv);
 	bool Cmd_Combos(int argc, const char **argv);
+	bool Cmd_SliderState(int argc, const char **argv);
 };
 
 class LivingBooksConsole : public GUI::Debugger {

Modified: scummvm/trunk/engines/mohawk/graphics.h
===================================================================
--- scummvm/trunk/engines/mohawk/graphics.h	2010-08-22 23:55:29 UTC (rev 52291)
+++ scummvm/trunk/engines/mohawk/graphics.h	2010-08-23 04:14:30 UTC (rev 52292)
@@ -41,6 +41,8 @@
 class MystBitmap;
 
 enum {
+	kRivenOpenHandCursor = 2003,
+	kRivenClosedHandCursor = 2004,
 	kRivenMainCursor = 3000,
 	kRivenPelletCursor = 5000,
 	kRivenHideCursor = 9000

Modified: scummvm/trunk/engines/mohawk/riven_external.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/riven_external.cpp	2010-08-22 23:55:29 UTC (rev 52291)
+++ scummvm/trunk/engines/mohawk/riven_external.cpp	2010-08-23 04:14:30 UTC (rev 52292)
@@ -34,8 +34,12 @@
 
 namespace Mohawk {
 
+static const uint32 kDomeSliderDefaultState = 0x01F00000;
+static const uint32 kDomeSliderSlotCount = 25;
+
 RivenExternal::RivenExternal(MohawkEngine_Riven *vm) : _vm(vm) {
 	setupCommands();
+	_sliderState = kDomeSliderDefaultState;
 }
 
 RivenExternal::~RivenExternal() {
@@ -234,6 +238,86 @@
 		*_vm->matchVarToString("domecheck") = 1;
 }
 
+void RivenExternal::resetDomeSliders(uint16 bitmapId, uint16 soundId) {
+	// TODO: Draw the animation of the sliders moving back to the start
+	_sliderState = kDomeSliderDefaultState;
+}
+
+void RivenExternal::checkDomeSliders(uint16 resetSlidersHotspot, uint16 openDomeHotspot) {
+	// Let's see if we're all matched up...
+	if (*_vm->matchVarToString("adomecombo") == _sliderState) {
+		// Set the button hotspot to the open dome hotspot
+		_vm->_hotspots[resetSlidersHotspot].enabled = false;
+		_vm->_hotspots[openDomeHotspot].enabled = true;
+	} else {
+		// Set the button hotspot to the reset sliders hotspot
+		_vm->_hotspots[resetSlidersHotspot].enabled = true;
+		_vm->_hotspots[openDomeHotspot].enabled = false;
+	}
+}
+
+void RivenExternal::checkSliderCursorChange(uint16 startHotspot) {
+	// Set the cursor based on _sliderState and what hotspot we're over
+	for (uint16 i = 0; i < kDomeSliderSlotCount; i++) {
+		if (_vm->_hotspots[i + startHotspot].rect.contains(_vm->_mousePos)) {
+			if (_sliderState & (1 << (24 - i)))
+				_vm->_gfx->changeCursor(kRivenOpenHandCursor);
+			else
+				_vm->_gfx->changeCursor(kRivenMainCursor);
+			break;
+		}
+	}
+}
+
+void RivenExternal::dragDomeSlider(uint16 bitmapId, uint16 soundId, uint16 resetSlidersHotspot, uint16 openDomeHotspot, uint16 startHotspot) {
+	int16 foundSlider = -1;
+
+	for (uint16 i = 0; i < kDomeSliderSlotCount; i++) {
+		if (_vm->_hotspots[i + startHotspot].rect.contains(_vm->_mousePos)) {
+			// If the slider is not at this hotspot, we can't do anything else
+			if (!(_sliderState & (1 << (24 - i))))
+				return;
+
+			foundSlider = i;
+			break;
+		}
+	}
+
+	// We're not over any slider
+	if (foundSlider < 0)
+		return;
+
+	// We've clicked down, so show the closed hand cursor
+	_vm->_gfx->changeCursor(kRivenClosedHandCursor);
+
+	bool done = false;
+	while (!done) {
+		Common::Event event;
+		while (_vm->_system->getEventManager()->pollEvent(event)) {
+			switch (event.type) {
+			case Common::EVENT_MOUSEMOVE:
+				_vm->_system->updateScreen();
+				break;
+			case Common::EVENT_LBUTTONUP:
+				done = true;
+				break;
+			default:
+				break;
+			}
+		}
+		_vm->_system->delayMillis(10);
+	}
+
+	// TODO: Handle any slider movement
+	// TODO: Redraw the sliders
+
+	// Now that we've released, show the open hand cursor again
+	_vm->_gfx->changeCursor(kRivenOpenHandCursor);
+
+	// Check to see if we have the right combination
+	checkDomeSliders(resetSlidersHotspot, openDomeHotspot);
+}
+
 // ------------------------------------------------------------------------------------
 // aspit (Main Menu, Books, Setup) external commands
 // ------------------------------------------------------------------------------------
@@ -698,19 +782,19 @@
 }
 
 void RivenExternal::xbisland190_opencard(uint16 argc, uint16 *argv) {
-	// TODO: Dome related
+	checkDomeSliders(27, 28);
 }
 
 void RivenExternal::xbisland190_resetsliders(uint16 argc, uint16 *argv) {
-	// TODO: Dome related
+	resetDomeSliders(287, 41);
 }
 
 void RivenExternal::xbisland190_slidermd(uint16 argc, uint16 *argv) {
-	// TODO: Dome related
+	dragDomeSlider(287, 41, 27, 28, 2);
 }
 
 void RivenExternal::xbisland190_slidermw(uint16 argc, uint16 *argv) {
-	// TODO: Dome related
+	checkSliderCursorChange(2);
 }
 
 void RivenExternal::xbscpbtn(uint16 argc, uint16 *argv) {
@@ -730,7 +814,7 @@
 	bool done = false;
 
 	// Set the cursor to the closed position
-	_vm->_gfx->changeCursor(2004);
+	_vm->_gfx->changeCursor(kRivenClosedHandCursor);
 	_vm->_system->updateScreen();
 
 	while (!done) {
@@ -819,19 +903,19 @@
 }
 
 void RivenExternal::xgisland25_opencard(uint16 argc, uint16 *argv) {
-	// TODO: Dome related
+	checkDomeSliders(29, 30);
 }
 
 void RivenExternal::xgisland25_resetsliders(uint16 argc, uint16 *argv) {
-	// TODO: Dome related
+	resetDomeSliders(161, 16);
 }
 
 void RivenExternal::xgisland25_slidermd(uint16 argc, uint16 *argv) {
-	// TODO: Dome related
+	dragDomeSlider(161, 16, 29, 30, 2);
 }
 
 void RivenExternal::xgisland25_slidermw(uint16 argc, uint16 *argv) {
-	// TODO: Dome related
+	checkSliderCursorChange(2);
 }
 
 void RivenExternal::xgscpbtn(uint16 argc, uint16 *argv) {
@@ -1105,15 +1189,15 @@
 }
 
 void RivenExternal::xjdome25_resetsliders(uint16 argc, uint16 *argv) {
-	// TODO: Dome related
+	resetDomeSliders(548, 81);
 }
 
 void RivenExternal::xjdome25_slidermd(uint16 argc, uint16 *argv) {
-	// TODO: Dome related
+	dragDomeSlider(548, 81, 27, 28, 2);
 }
 
 void RivenExternal::xjdome25_slidermw(uint16 argc, uint16 *argv) {
-	// TODO: Dome related
+	checkSliderCursorChange(2);
 }
 
 void RivenExternal::xjscpbtn(uint16 argc, uint16 *argv) {
@@ -1128,7 +1212,7 @@
 	Common::Event event;
 	int changeLevel = 0;
 
-	_vm->_gfx->changeCursor(2004);
+	_vm->_gfx->changeCursor(kRivenClosedHandCursor);
 	_vm->_system->updateScreen();
 	for (;;) {
 		while (_vm->_system->getEventManager()->pollEvent(event)) {
@@ -1431,19 +1515,19 @@
 }
 
 void RivenExternal::xpisland25_opencard(uint16 argc, uint16 *argv) {
-	// TODO: Dome related
+	checkDomeSliders(31, 5);
 }
 
 void RivenExternal::xpisland25_resetsliders(uint16 argc, uint16 *argv) {
-	// TODO: Dome related
+	resetDomeSliders(58, 10);
 }
 
 void RivenExternal::xpisland25_slidermd(uint16 argc, uint16 *argv) {
-	// TODO: Dome related
+	dragDomeSlider(58, 10, 31, 5, 6);
 }
 
 void RivenExternal::xpisland25_slidermw(uint16 argc, uint16 *argv) {
-	// TODO: Dome related
+	checkSliderCursorChange(6);
 }
 
 // ------------------------------------------------------------------------------------
@@ -1630,19 +1714,19 @@
 }
 
 void RivenExternal::xtisland5056_opencard(uint16 argc, uint16 *argv) {
-	// TODO: Dome related
+	checkDomeSliders(29, 30);
 }
 
 void RivenExternal::xtisland5056_resetsliders(uint16 argc, uint16 *argv) {
-	// TODO: Dome related
+	resetDomeSliders(798, 37);
 }
 
 void RivenExternal::xtisland5056_slidermd(uint16 argc, uint16 *argv) {
-	// TODO: Dome related
+	dragDomeSlider(798, 37, 29, 30, 3);
 }
 
 void RivenExternal::xtisland5056_slidermw(uint16 argc, uint16 *argv) {
-	// TODO: Dome related
+	checkSliderCursorChange(3);
 }
 
 void RivenExternal::xtatboundary(uint16 argc, uint16 *argv) {

Modified: scummvm/trunk/engines/mohawk/riven_external.h
===================================================================
--- scummvm/trunk/engines/mohawk/riven_external.h	2010-08-22 23:55:29 UTC (rev 52291)
+++ scummvm/trunk/engines/mohawk/riven_external.h	2010-08-23 04:14:30 UTC (rev 52292)
@@ -39,9 +39,12 @@
 
 	void runCommand(uint16 argc, uint16 *argv);
 	uint16 getComboDigit(uint32 correctCombo, uint32 digit);
+	uint32 getDomeSliderState() { return _sliderState; }
+	void setDomeSliderState(uint32 state) { _sliderState = state; }
 
 private:
 	MohawkEngine_Riven *_vm;
+	uint32 _sliderState;
 
 	typedef void (RivenExternal::*ExternalCmd)(uint16 argc, uint16 *argv);
 
@@ -60,6 +63,10 @@
 	void runEndGame(uint16 video);
 	void runDomeCheck();
 	void runDomeButtonMovie();
+	void resetDomeSliders(uint16 bitmapId, uint16 soundId);
+	void checkDomeSliders(uint16 resetSlidersHotspot, uint16 openDomeHotspot);
+	void checkSliderCursorChange(uint16 startHotspot);
+	void dragDomeSlider(uint16 bitmapId, uint16 soundId, uint16 resetSlidersHotspot, uint16 openDomeHotspot, uint16 startHotspot);
 
 	// -----------------------------------------------------
 	// aspit (Main Menu, Books, Setup) external commands


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