aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2011-03-12 17:22:32 +1100
committerPaul Gilbert2011-03-12 17:22:32 +1100
commit97a674ca09008fc0226b5822173d3a765a460ebf (patch)
tree81b67d90969120532f419650abf6a302ed52be65
parent7e0d120ce18c7e2fb3d1a8b4f43679e97a8a89d9 (diff)
downloadscummvm-rg350-97a674ca09008fc0226b5822173d3a765a460ebf.tar.gz
scummvm-rg350-97a674ca09008fc0226b5822173d3a765a460ebf.tar.bz2
scummvm-rg350-97a674ca09008fc0226b5822173d3a765a460ebf.zip
Implemented Scene #2310 - Spacecraft - Copy Protection screen
-rw-r--r--engines/tsage/ringworld_scenes3.cpp180
-rw-r--r--engines/tsage/ringworld_scenes3.h33
2 files changed, 213 insertions, 0 deletions
diff --git a/engines/tsage/ringworld_scenes3.cpp b/engines/tsage/ringworld_scenes3.cpp
index b00159517c..3be2ded4db 100644
--- a/engines/tsage/ringworld_scenes3.cpp
+++ b/engines/tsage/ringworld_scenes3.cpp
@@ -23,6 +23,7 @@
*
*/
+#include "common/config-manager.h"
#include "tsage/ringworld_scenes3.h"
#include "tsage/scenes.h"
#include "tsage/tsage.h"
@@ -4810,4 +4811,183 @@ void Scene2300::postInit(SceneObjectList *OwnerList) {
_globals->_sceneItems.addItems(&_hotspot12, &_hotspot11, &_hotspot13, &_hotspot14, &_hotspot15, NULL);
}
+/*--------------------------------------------------------------------------
+ * Scene 2310 - Starcraft - Copy Protection Screen
+ *
+ *--------------------------------------------------------------------------*/
+
+Scene2310::Scene2310() {
+ _pageList[0].set(0, 0, 0, 0, 0, 0);
+ _pageList[1].set(1, 0, 3, 2, 1, 4);
+ _pageList[2].set(2, 1, 4, 3, 2, 0);
+ _pageList[3].set(3, 2, 0, 4, 3, 1);
+ _pageList[4].set(4, 3, 1, 0, 2, 4);
+ _pageList[5].set(5, 4, 2, 1, 3, 0);
+ _pageList[6].set(6, 0, 4, 2, 3, 1);
+ _pageList[7].set(7, 1, 0, 2, 4, 3);
+ _pageList[8].set(8, 2, 1, 3, 0, 4);
+ _pageList[9].set(9, 3, 2, 4, 1, 0);
+ _pageList[10].set(10, 4, 1, 2, 0, 3);
+ _pageList[11].set(11, 0, 2, 3, 4, 1);
+ _pageList[12].set(12, 1, 2, 0, 4, 3);
+ _pageList[13].set(13, 2, 4, 0, 3, 1);
+ _pageList[14].set(14, 3, 4, 1, 0, 2);
+ _pageList[15].set(15, 4, 3, 1, 2, 0);
+ _pageList[16].set(16, 0, 1, 4, 2, 3);
+ _pageList[17].set(17, 1, 3, 4, 0, 2);
+ _pageList[18].set(18, 2, 3, 0, 1, 4);
+ _pageList[19].set(19, 3, 0, 1, 4, 2);
+ _pageList[20].set(20, 4, 0, 3, 1, 2);
+}
+
+void Scene2310::postInit(SceneObjectList *OwnerList) {
+ Scene::postInit();
+ loadScene(2301);
+ Common::Point pointList[5] = { Common::Point(142, 82), Common::Point(158, 82), Common::Point(174, 82),
+ Common::Point(190, 82), Common::Point(205, 82) };
+
+ for (int idx = 0; idx < 5; ++idx) {
+ _wireList[idx].postInit();
+ _wireList[idx].setVisage(2300);
+ _wireList[idx]._strip = idx + 1;
+ _wireList[idx]._frame = 1;
+ _wireList[idx].setPosition(pointList[idx]);
+ }
+
+ _rectList[0].set(135, 70, 151, 140);
+ _rectList[1].set(151, 70, 167, 140);
+ _rectList[2].set(167, 70, 183, 140);
+ _rectList[3].set(183, 70, 199, 140);
+ _rectList[4].set(199, 70, 215, 140);
+
+ _globals->_player.disableControl();
+ _globals->_events.setCursor(CURSOR_WALK);
+
+ _wireIndex = 5;
+ _pageIndex = _globals->_randomSource.getRandomNumber(19) + 1;
+ signal();
+}
+
+void Scene2310::signal() {
+ switch (_sceneMode++) {
+ case 0: {
+ Common::String fmtString = _vm->_dataManager->getMessage(2300, 22);
+ Common::String msg = Common::String::format(fmtString.c_str(), _pageList[_pageIndex]._pageNumber);
+
+ _sceneText._width = 280;
+ _sceneText._textMode = ALIGN_CENTRE;
+ _sceneText._colour1 = 35;
+ _sceneText._fontNumber = 2;
+ _sceneText.setup(msg);
+ _sceneText.setPriority2(255);
+ _sceneText.setPosition(Common::Point(30, 20));
+ break;
+ }
+ case 1: {
+ Common::String msg = _vm->_dataManager->getMessage(2300, 23);
+ _sceneText.setup(msg);
+ _sceneText.setPriority2(255);
+ _sceneText.setPosition(Common::Point(30, 170));
+
+ _globals->_sceneObjects->draw();
+ _globals->_events.waitForPress();
+
+ _sceneText.flag100();
+ _globals->_sceneObjects->draw();
+
+ _globals->_sceneManager.changeScene(2200);
+ break;
+ }
+ }
+}
+
+void Scene2310::synchronise(Serialiser &s) {
+ Scene::synchronise(s);
+
+ s.syncAsSint16LE(_wireIndex);
+ s.syncAsSint16LE(_pageIndex);
+}
+
+void Scene2310::process(Event &event) {
+ int frameNum = 0;
+
+ if (!event.handled && (event.eventType == EVENT_BUTTON_DOWN)) {
+ int idx = 0;
+ while (idx < 5) {
+ if (_rectList[idx].contains(event.mousePos))
+ break;
+ ++idx;
+ }
+
+ if (idx < 5) {
+ // In handled rectangle area
+ if (_wireIndex == 5) {
+ // No wire is currently active, so start moving designated wire
+ _wireIndex = idx;
+ frameNum = idx + 2;
+
+ if (event.mousePos.y > 105)
+ idx = findObject(idx);
+
+ if (idx != 5) {
+ _wireList[idx].flag100();
+ _globals->_sceneObjects->draw();
+ _wireList[idx].setFrame(frameNum);
+
+ _wireList[idx].unflag100();
+ _globals->_sceneObjects->draw();
+ }
+ } else {
+ // End the moving of the currently active wire
+ _wireList[_wireIndex].setFrame(idx + 2);
+ _wireIndex = 5;
+
+ // Check if solution has been reached
+ int idx2 = 0;
+ do {
+ int objIndex = findObject(idx2);
+ if (_pageList[_pageIndex]._connectionList[idx2] != objIndex)
+ // Mismatch
+ break;
+ } while (++idx2 < 5);
+
+ if (idx2 == 5)
+ // All the entries are correct
+ signal();
+ }
+
+ event.handled = true;
+ } else if (_wireIndex != 5) {
+ // Reset the active wire back to unplugged
+ _wireList[_wireIndex].setFrame(1);
+ _wireIndex = 5;
+ }
+ }
+}
+
+void Scene2310::dispatch() {
+ if ((_vm->getFeatures() & GF_CD) && !ConfMan.getBool("copy_protection")) {
+ // CD version of Ringworld has the copy protection disabled
+ signal();
+ } else if (_wireIndex != 5) {
+ for (int idx = 0; idx < 5; ++idx) {
+ if (_rectList[idx].contains(_globals->_events._mousePos)) {
+ _wireList[_wireIndex].setFrame(idx + 2);
+ return;
+ }
+ }
+
+ _wireList[_wireIndex].setFrame(1);
+ }
+}
+
+int Scene2310::findObject(int objIndex) {
+ for (int idx = 0; idx < 5; ++idx) {
+ if (_wireList[idx]._frame == (objIndex + 2))
+ return idx;
+ }
+
+ return 5;
+}
+
} // End of namespace tSage
diff --git a/engines/tsage/ringworld_scenes3.h b/engines/tsage/ringworld_scenes3.h
index da6c69681c..cd2ce44d0f 100644
--- a/engines/tsage/ringworld_scenes3.h
+++ b/engines/tsage/ringworld_scenes3.h
@@ -742,6 +742,39 @@ public:
virtual void postInit(SceneObjectList *OwnerList = NULL);
};
+class Scene2310: public Scene {
+private:
+ int findObject(int objIndex);
+
+ /* Custom classes */
+ class ProtectionEntry {
+ public:
+ int _pageNumber;
+ int _connectionList[5];
+
+ void set(int pageNumber, int v1, int v2, int v3, int v4, int v5) {
+ _pageNumber = pageNumber;
+ _connectionList[0] = v1; _connectionList[1] = v2; _connectionList[2] = v3;
+ _connectionList[3] = v4; _connectionList[4] = v5;
+ }
+ };
+
+public:
+ SequenceManager _sequenceManager;
+ int _wireIndex, _pageIndex;
+ SceneObject _wireList[5];
+ Rect _rectList[5];
+ SceneText _sceneText;
+ ProtectionEntry _pageList[21];
+
+ Scene2310();
+ virtual void postInit(SceneObjectList *OwnerList = NULL);
+ virtual void synchronise(Serialiser &s);
+ virtual void signal();
+ virtual void process(Event &event);
+ virtual void dispatch();
+};
+
} // End of namespace tSage
#endif