From d3193687a73b92213095db6b8bbf6b6b4614af12 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 22 Oct 2011 20:44:26 +1100 Subject: TSAGE: Beginnings of support for Return to Ringworld --- engines/tsage/blue_force/blueforce_logic.cpp | 40 +- engines/tsage/blue_force/blueforce_logic.h | 2 + engines/tsage/blue_force/blueforce_scenes0.cpp | 42 +- engines/tsage/blue_force/blueforce_scenes1.cpp | 12 +- engines/tsage/blue_force/blueforce_scenes2.cpp | 2 +- engines/tsage/blue_force/blueforce_scenes3.cpp | 70 +-- engines/tsage/blue_force/blueforce_scenes4.cpp | 34 +- engines/tsage/blue_force/blueforce_scenes5.cpp | 48 +- engines/tsage/blue_force/blueforce_scenes6.cpp | 4 +- engines/tsage/blue_force/blueforce_scenes8.cpp | 40 +- engines/tsage/blue_force/blueforce_scenes9.cpp | 62 +- engines/tsage/blue_force/blueforce_ui.cpp | 522 ---------------- engines/tsage/blue_force/blueforce_ui.h | 156 ----- engines/tsage/core.cpp | 70 ++- engines/tsage/core.h | 2 + engines/tsage/detection_tables.h | 16 + engines/tsage/events.cpp | 4 +- engines/tsage/events.h | 10 + engines/tsage/globals.cpp | 23 +- engines/tsage/globals.h | 31 +- engines/tsage/module.mk | 6 +- engines/tsage/resources.cpp | 2 + engines/tsage/resources.h | 5 +- engines/tsage/ringworld2/ringworld2_logic.cpp | 757 ++++++++++++++++++++++++ engines/tsage/ringworld2/ringworld2_logic.h | 249 ++++++++ engines/tsage/ringworld2/ringworld2_scenes0.cpp | 331 +++++++++++ engines/tsage/ringworld2/ringworld2_scenes0.h | 84 +++ engines/tsage/scenes.cpp | 36 +- engines/tsage/scenes.h | 3 +- engines/tsage/tsage.cpp | 5 +- engines/tsage/tsage.h | 3 +- engines/tsage/user_interface.cpp | 510 ++++++++++++++++ engines/tsage/user_interface.h | 148 +++++ 33 files changed, 2446 insertions(+), 883 deletions(-) delete mode 100644 engines/tsage/blue_force/blueforce_ui.cpp delete mode 100644 engines/tsage/blue_force/blueforce_ui.h create mode 100644 engines/tsage/ringworld2/ringworld2_logic.cpp create mode 100644 engines/tsage/ringworld2/ringworld2_logic.h create mode 100644 engines/tsage/ringworld2/ringworld2_scenes0.cpp create mode 100644 engines/tsage/ringworld2/ringworld2_scenes0.h create mode 100644 engines/tsage/user_interface.cpp create mode 100644 engines/tsage/user_interface.h (limited to 'engines/tsage') diff --git a/engines/tsage/blue_force/blueforce_logic.cpp b/engines/tsage/blue_force/blueforce_logic.cpp index 958690a564..70b0a5802f 100644 --- a/engines/tsage/blue_force/blueforce_logic.cpp +++ b/engines/tsage/blue_force/blueforce_logic.cpp @@ -714,8 +714,8 @@ void SceneExt::postInit(SceneObjectList *OwnerList) { } void SceneExt::remove() { - BF_GLOBALS._uiElements.hide(); - BF_GLOBALS._uiElements.resetClear(); + T2_GLOBALS._uiElements.hide(); + T2_GLOBALS._uiElements.resetClear(); // Below code originally in Blue Force Scene::remove(). Placed here to avoid contaminating // core class with Blue Force specific code @@ -739,8 +739,8 @@ void SceneExt::dispatch() { if (_field37A) { if ((--_field37A == 0) && BF_GLOBALS._dayNumber) { - if (BF_GLOBALS._uiElements._active && BF_GLOBALS._player._enabled) { - BF_GLOBALS._uiElements.show(); + if (T2_GLOBALS._uiElements._active && BF_GLOBALS._player._enabled) { + T2_GLOBALS._uiElements.show(); } _field37A = 0; @@ -829,8 +829,8 @@ void SceneExt::startStrip() { scene->_savedCanWalk = BF_GLOBALS._player._canWalk; BF_GLOBALS._player.disableControl(); - if (!BF_GLOBALS._v50696 && BF_GLOBALS._uiElements._active) - BF_GLOBALS._uiElements.hide(); + if (!BF_GLOBALS._v50696 && T2_GLOBALS._uiElements._active) + T2_GLOBALS._uiElements.hide(); } } @@ -843,8 +843,8 @@ void SceneExt::endStrip() { BF_GLOBALS._player._uiEnabled = scene->_savedUiEnabled; BF_GLOBALS._player._canWalk = scene->_savedCanWalk; - if (!BF_GLOBALS._v50696 && BF_GLOBALS._uiElements._active) - BF_GLOBALS._uiElements.show(); + if (!BF_GLOBALS._v50696 && T2_GLOBALS._uiElements._active) + T2_GLOBALS._uiElements.show(); } } @@ -941,8 +941,8 @@ void SceneHandlerExt::process(Event &event) { if (scene && scene->_focusObject) scene->_focusObject->process(event); - if (BF_GLOBALS._uiElements._active) { - BF_GLOBALS._uiElements.process(event); + if (T2_GLOBALS._uiElements._active) { + T2_GLOBALS._uiElements.process(event); if (event.handled) return; } @@ -1199,6 +1199,9 @@ void BlueForceInvObjectList::reset() { setObjectScene(INV_DOG_WHISTLE, 880); setObjectScene(INV_YELLOW_CORD, 910); setObjectScene(INV_BLACK_CORD, 910); + + // Set up the select item handler method + T2_GLOBALS._onSelectItem = SelectItem; } void BlueForceInvObjectList::setObjectScene(int objectNum, int sceneNumber) { @@ -1213,7 +1216,7 @@ void BlueForceInvObjectList::setObjectScene(int objectNum, int sceneNumber) { BF_GLOBALS._events.setCursor(CURSOR_USE); // Update the user interface if necessary - BF_GLOBALS._uiElements.updateInventory(); + T2_GLOBALS._uiElements.updateInventory(); } void BlueForceInvObjectList::alterInventory(int mode) { @@ -1305,6 +1308,21 @@ void BlueForceInvObjectList::alterInventory(int mode) { } } +/** + * When an inventory item is selected, check if it's the gun belt, since that has a specific dialog + */ +bool BlueForceInvObjectList::SelectItem(int objectNumber) { + if (objectNumber == INV_AMMO_BELT) { + AmmoBeltDialog *dlg = new AmmoBeltDialog(); + dlg->execute(); + delete dlg; + + return true; + } + + return false; +} + /*--------------------------------------------------------------------------*/ NamedHotspot::NamedHotspot() : SceneHotspot() { diff --git a/engines/tsage/blue_force/blueforce_logic.h b/engines/tsage/blue_force/blueforce_logic.h index 021483c645..1b161bce06 100644 --- a/engines/tsage/blue_force/blueforce_logic.h +++ b/engines/tsage/blue_force/blueforce_logic.h @@ -252,6 +252,8 @@ public: }; class BlueForceInvObjectList : public InvObjectList { +private: + static bool SelectItem(int objectNumber); public: InvObject _none; InvObject _colt45; diff --git a/engines/tsage/blue_force/blueforce_scenes0.cpp b/engines/tsage/blue_force/blueforce_scenes0.cpp index bf4f74d519..bb283d051e 100644 --- a/engines/tsage/blue_force/blueforce_scenes0.cpp +++ b/engines/tsage/blue_force/blueforce_scenes0.cpp @@ -332,7 +332,7 @@ void Scene50::postInit(SceneObjectList *OwnerList) { SceneExt::postInit(); BF_GLOBALS._interfaceY = 200; - BF_GLOBALS._uiElements._active = false; + T2_GLOBALS._uiElements._active = false; BF_GLOBALS._player.postInit(); BF_GLOBALS._player.setVisage(830); BF_GLOBALS._player.setStrip(3); @@ -424,7 +424,7 @@ void Scene50::remove() { BF_GLOBALS._scrollFollower = &BF_GLOBALS._player; SceneExt::remove(); - BF_GLOBALS._uiElements._active = true; + T2_GLOBALS._uiElements._active = true; } void Scene50::signal() { @@ -683,7 +683,7 @@ bool Scene60::MirandaCard::startAction(CursorType action, Event &event) { SceneItem::display2(60, 6); BF_INVENTORY.setObjectScene(INV_MIRANDA_CARD, 1); if (!BF_GLOBALS.getFlag(fGotPointsForTktBook)) { - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); BF_GLOBALS.setFlag(fGotPointsForTktBook); } @@ -714,7 +714,7 @@ bool Scene60::TicketBook::startAction(CursorType action, Event &event) { SceneItem::display2(60, 3); BF_INVENTORY.setObjectScene(INV_TICKET_BOOK, 1); if (!BF_GLOBALS.getFlag(fShotNicoIn910)) { - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); BF_GLOBALS.setFlag(fShotNicoIn910); } } @@ -779,10 +779,10 @@ void Scene60::Action1::signal() { switch (_state) { case 1: if (BF_GLOBALS.removeFlag(fCan1004Marina)) { - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); _state = 606; } else if (BF_GLOBALS.removeFlag(fCan1004Drunk)) { - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); _state = 606; } else { _state = 611; @@ -793,13 +793,13 @@ void Scene60::Action1::signal() { break; case 3: if (BF_GLOBALS.removeFlag(f1015Marina)) { - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); _state = 613; } else if (BF_GLOBALS.removeFlag(f1015Frankie)) { - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); _state = 614; } else if (BF_GLOBALS.removeFlag(f1015Drunk)) { - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); _state = 615; } else { _state = 616; @@ -807,15 +807,15 @@ void Scene60::Action1::signal() { break; case 4: if (BF_GLOBALS.removeFlag(f1027Marina)) { - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); _actionIndex = 5; _state = 617; } else if (BF_GLOBALS.removeFlag(f1027Frankie)) { - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); _actionIndex = 5; _state = 618; } else if (BF_GLOBALS.removeFlag(f1015Drunk)) { - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); _actionIndex = 5; _state = 619; } else { @@ -825,15 +825,15 @@ void Scene60::Action1::signal() { case 5: if (BF_GLOBALS.removeFlag(f1035Marina)) { BF_GLOBALS.setFlag(fCalledBackup); - BF_GLOBALS._uiElements.addScore(50); + T2_GLOBALS._uiElements.addScore(50); _state = 621; } else if (BF_GLOBALS.removeFlag(f1035Frankie)) { BF_GLOBALS.setFlag(fCalledBackup); - BF_GLOBALS._uiElements.addScore(50); + T2_GLOBALS._uiElements.addScore(50); _actionIndex = 5; _state = 622; } else if (BF_GLOBALS.removeFlag(f1035Drunk)) { - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); _state = 623; } else { _state = 624; @@ -841,14 +841,14 @@ void Scene60::Action1::signal() { break; case 6: if (BF_GLOBALS.removeFlag(f1097Marina)) { - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); _state = 625; } else if (BF_GLOBALS.removeFlag(f1097Frankie)) { - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); _actionIndex = 5; _state = 626; } else if (BF_GLOBALS.removeFlag(f1097Drunk)) { - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); _state = 627; } else { _state = 628; @@ -856,13 +856,13 @@ void Scene60::Action1::signal() { break; case 7: if (BF_GLOBALS.removeFlag(f1098Marina)) { - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); _state = 629; } else if (BF_GLOBALS.removeFlag(f1098Frankie)) { - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); _state = 630; } else if (BF_GLOBALS.removeFlag(f1098Drunk)) { - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); _state = 631; } else { _state = 632; diff --git a/engines/tsage/blue_force/blueforce_scenes1.cpp b/engines/tsage/blue_force/blueforce_scenes1.cpp index 6c5951a427..b1123cba6b 100644 --- a/engines/tsage/blue_force/blueforce_scenes1.cpp +++ b/engines/tsage/blue_force/blueforce_scenes1.cpp @@ -1130,7 +1130,7 @@ bool Scene115::Object2::startAction(CursorType action, Event &event) { scene->_sceneMode = 1151; scene->setAction(&scene->_action9); } else { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(fTalkedToTony); if (BF_GLOBALS._v4CEAA == 0) { scene->_sceneMode = 1150; @@ -1354,7 +1354,7 @@ void Scene115::Action2::signal() { if (BF_GLOBALS.getFlag(fTalkedToTony)) { switch (BF_GLOBALS._v4CEAA) { case 1: - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); scene->_stripManager.start(1181, this); break; case 2: @@ -1371,7 +1371,7 @@ void Scene115::Action2::signal() { if (BF_GLOBALS.getFlag(fTalkedToTony)) { switch (BF_GLOBALS._v4CEAA) { case 1: - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); scene->_stripManager.start(1153, this); break; case 2: @@ -1531,7 +1531,7 @@ void Scene115::Action8::signal() { setAction(&scene->_sequenceManager1, this, 2115, &scene->_object1, &BF_GLOBALS._player, NULL); break; case 1: - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); setAction(&scene->_sequenceManager1, this, 4115, &scene->_object1, &BF_GLOBALS._player, NULL); break; case 2: @@ -1546,7 +1546,7 @@ void Scene115::Action8::signal() { break; case 5: BF_INVENTORY.setObjectScene(INV_NAPKIN, 1); - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); scene->_object1.setVisage(131); scene->_object1.setStrip(1); scene->_object1.setFrame(1); @@ -3298,7 +3298,7 @@ void Scene190::postInit(SceneObjectList *OwnerList) { default: BF_GLOBALS.setFlag(onBike); BF_GLOBALS._player.disableControl(); - BF_GLOBALS._uiElements._active = true; + T2_GLOBALS._uiElements._active = true; _sceneMode = BF_GLOBALS.getFlag(onDuty) ? 192 : 190; setAction(&_sequenceManager, this, _sceneMode, &BF_GLOBALS._player, NULL); break; diff --git a/engines/tsage/blue_force/blueforce_scenes2.cpp b/engines/tsage/blue_force/blueforce_scenes2.cpp index bf9661cebd..8dbbe7ca24 100644 --- a/engines/tsage/blue_force/blueforce_scenes2.cpp +++ b/engines/tsage/blue_force/blueforce_scenes2.cpp @@ -1104,7 +1104,7 @@ void Scene270::signal() { SceneItem::display2(270, 37); BF_GLOBALS._player.enableControl(); } else { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(shownLyleCrate1Day1); _sceneMode = 12; ADD_PLAYER_MOVER(192, 135); diff --git a/engines/tsage/blue_force/blueforce_scenes3.cpp b/engines/tsage/blue_force/blueforce_scenes3.cpp index 90f2ccdb52..d04f1256cb 100644 --- a/engines/tsage/blue_force/blueforce_scenes3.cpp +++ b/engines/tsage/blue_force/blueforce_scenes3.cpp @@ -862,7 +862,7 @@ bool Scene315::BulletinMemo::startAction(CursorType action, Event &event) { return true; case CURSOR_USE: if (!BF_GLOBALS.getFlag(fGotPointsForCleaningGun)) { - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); BF_GLOBALS.setFlag(fGotPointsForCleaningGun); } BF_GLOBALS._player.addMover(NULL); @@ -906,7 +906,7 @@ bool Scene315::ATFMemo::startAction(CursorType action, Event &event) { return true; case CURSOR_USE: if (!BF_GLOBALS.getFlag(fGotPointsForMemo)) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(fGotPointsForMemo); } @@ -937,7 +937,7 @@ void Scene315::Action1::signal() { break; case 3: if (scene->_sceneMode == 3169) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_INVENTORY.setObjectScene(INV_MUG_SHOT, 1); } @@ -1088,7 +1088,7 @@ void Scene315::postInit(SceneObjectList *OwnerList) { setAction(&_sequenceManager, this, _sceneMode, &BF_GLOBALS._player, NULL); break; case 325: - BF_GLOBALS._uiElements._active = false; + T2_GLOBALS._uiElements._active = false; _object6.postInit(); _object7.postInit(); _object8.setFrame(8); @@ -1192,7 +1192,7 @@ void Scene315::signal() { } break; case 12: - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_INVENTORY.setObjectScene((int)_currentCursor, 315); if (!_field1B64 || (_field1B66 != _field1B64)) @@ -1221,11 +1221,11 @@ void Scene315::signal() { BF_GLOBALS._player.enableControl(); _field1B68 = false; BF_GLOBALS._walkRegions.proc1(4); - BF_GLOBALS._uiElements._active = true; - BF_GLOBALS._uiElements.show(); + T2_GLOBALS._uiElements._active = true; + T2_GLOBALS._uiElements.show(); break; case 3153: - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_INVENTORY.setObjectScene((int)_currentCursor, 315); if (_stripNumber != 0) @@ -1242,11 +1242,11 @@ void Scene315::signal() { BF_GLOBALS._player.enableControl(); _field1B68 = false; BF_GLOBALS._walkRegions.proc1(4); - BF_GLOBALS._uiElements._active = true; - BF_GLOBALS._uiElements.show(); + T2_GLOBALS._uiElements._active = true; + T2_GLOBALS._uiElements.show(); break; case 3156: - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); BF_INVENTORY.setObjectScene(INV_DA_NOTE, 1); _object2.remove(); BF_GLOBALS._player.enableControl(); @@ -1257,12 +1257,12 @@ void Scene315::signal() { break; case 3158: BF_GLOBALS._player.enableControl(); - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); BF_INVENTORY.setObjectScene(INV_FOREST_RAP, 1); break; case 3159: if (!BF_GLOBALS.getFlag(fBookedGreenEvidence)) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(fBookedGreenEvidence); } BF_GLOBALS.setFlag(gunClean); @@ -2562,7 +2562,7 @@ bool Scene350::Hook::startAction(CursorType action, Event &event) { BF_INVENTORY.setObjectScene(INV_HOOK, 1); if (!BF_GLOBALS.getFlag(hookPoints)) { BF_GLOBALS.setFlag(hookPoints); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); } remove(); return true; @@ -2684,8 +2684,8 @@ void Scene350::postInit(SceneObjectList *OwnerList) { switch (BF_GLOBALS._sceneManager._previousScene) { case 370: BF_GLOBALS._player.enableControl(); - BF_GLOBALS._uiElements._active = true; - BF_GLOBALS._uiElements.show(); + T2_GLOBALS._uiElements._active = true; + T2_GLOBALS._uiElements.show(); // Deliberate fall-through case 355: if (BF_GLOBALS.getFlag(onDuty) && BF_GLOBALS.getFlag(gunDrawn)) @@ -2988,7 +2988,7 @@ bool Scene355::Object5::startAction(CursorType action, Event &event) { return true; case CURSOR_USE: BF_INVENTORY.setObjectScene(INV_FLARE, 1); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); scene->_object9.remove(); remove(); @@ -3073,7 +3073,7 @@ bool Scene355::Green::startAction(CursorType action, Event &event) { scene->_sceneMode = 9979; scene->setAction(&scene->_sequenceManager, scene, 4551, &BF_GLOBALS._player, this, NULL); BF_INVENTORY.setObjectScene(INV_HANDCUFFS, 355); - BF_GLOBALS._uiElements.addScore(50); + T2_GLOBALS._uiElements.addScore(50); _flag = 1; BF_GLOBALS._bookmark = bInvestigateBoat; } @@ -3748,14 +3748,14 @@ void Scene355::signal() { case 3562: if (!BF_GLOBALS.getFlag(unlockBoat)) { BF_GLOBALS.setFlag(unlockBoat); - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); } SceneItem::display2(355, !_doorway._v3 ? 24 : 25); BF_GLOBALS._player.enableControl(); break; case 4550: - BF_GLOBALS._uiElements.addScore(50); + T2_GLOBALS._uiElements.addScore(50); _object10.remove(); BF_GLOBALS._sound1.play(90); BF_GLOBALS._player._regionBitList |= 0x10; @@ -3871,7 +3871,7 @@ void Scene355::signal() { _sceneMode = 0; _stripManager.start(3569, this); BF_INVENTORY.setObjectScene(INV_GRENADES, 1); - BF_GLOBALS._uiElements.addScore(50); + T2_GLOBALS._uiElements.addScore(50); BF_GLOBALS._player._regionBitList |= 0x10; break; case 9986: @@ -3898,7 +3898,7 @@ void Scene355::signal() { } break; case 9988: - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); if ((BF_INVENTORY.getObjectScene(INV_RAGS) == 0) && (BF_INVENTORY.getObjectScene(INV_JAR) == 0) && (BF_INVENTORY.getObjectScene(INV_FLARE) == 0)) { _green.postInit(); @@ -3962,7 +3962,7 @@ void Scene355::signal() { case 9993: BF_INVENTORY.setObjectScene(INV_SCREWDRIVER, 1); SceneItem::display2(355, 29); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); _sceneMode = 0; signal(); break; @@ -4304,7 +4304,7 @@ void Scene360::Action1::signal() { if (BF_INVENTORY.getObjectScene(INV_WAREHOUSE_KEYS) == 360) { SceneItem::display2(360, 20); BF_INVENTORY.setObjectScene(INV_WAREHOUSE_KEYS, 1); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); } else { SceneItem::display2(360, 5); } @@ -4671,7 +4671,7 @@ bool Scene370::Green::startAction(CursorType action, Event &event) { if (_v2 != 3) SceneItem::display2(370, 2); else { - BF_GLOBALS._uiElements.addScore(50); + T2_GLOBALS._uiElements.addScore(50); BF_GLOBALS._player.disableControl(); scene->_sceneMode = 3704; scene->setAction(&scene->_sequenceManager, scene, 3704, &BF_GLOBALS._player, this, &scene->_harrison, NULL); @@ -4954,7 +4954,7 @@ void Scene370::signal() { _sound1.play(6); BF_GLOBALS._sound1.changeSound(35); BF_INVENTORY.setObjectScene(INV_GREENS_GUN, 370); - BF_GLOBALS._uiElements.addScore(50); + T2_GLOBALS._uiElements.addScore(50); BF_GLOBALS._sceneItems.push_front(&_greensGun); BF_GLOBALS._player.enableControl(); @@ -4980,13 +4980,13 @@ void Scene370::signal() { case 3711: BF_GLOBALS._walkRegions.proc1(3); BF_INVENTORY.setObjectScene(INV_GREENS_GUN, 1); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); _greensGun.remove(); BF_GLOBALS._player.enableControl(); break; case 3712: - BF_GLOBALS._uiElements._active = false; - BF_GLOBALS._uiElements.hide(); + T2_GLOBALS._uiElements._active = false; + T2_GLOBALS._uiElements.hide(); if (BF_GLOBALS._sceneObjects->contains(&_greensGun)) _greensGun.remove(); @@ -4998,7 +4998,7 @@ void Scene370::signal() { BF_GLOBALS._player._canWalk = false; break; case 3715: - BF_GLOBALS._uiElements.addScore(50); + T2_GLOBALS._uiElements.addScore(50); BF_INVENTORY.setObjectScene(INV_GREEN_ID, 1); BF_INVENTORY.setObjectScene(INV_GREENS_KNIFE, 1); BF_GLOBALS._walkRegions.proc1(3); @@ -5316,7 +5316,7 @@ bool Scene385::Jim::startAction(CursorType action, Event &event) { return true; case INV_PRINT_OUT: if (!BF_GLOBALS.getFlag(fGotPointsForMCard)) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.getFlag(fGotPointsForMCard); scene->setAction(&scene->_action2); @@ -5612,7 +5612,7 @@ bool Scene390::Green::startAction(CursorType action, Event &event) { if (BF_GLOBALS.getFlag(readGreenRights)) { SceneItem::display2(390, 15); } else { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(readGreenRights); BF_GLOBALS._player.disableControl(); scene->_sceneMode = 3904; @@ -5738,7 +5738,7 @@ bool Scene390::GangMember1::startAction(CursorType action, Event &event) { SceneItem::display2(390, 15); } else { BF_GLOBALS.setFlag(readFrankRights); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS._player.disableControl(); scene->_sceneMode = 3904; @@ -5762,7 +5762,7 @@ bool Scene390::GangMember2::startAction(CursorType action, Event &event) { if (BF_GLOBALS.getFlag(readFrankRights)) { SceneItem::display2(390, 15); } else { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(readFrankRights); BF_GLOBALS._player.disableControl(); @@ -5913,7 +5913,7 @@ void Scene390::signal() { BF_GLOBALS._player.enableControl(); break; case 3905: - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); _object2.remove(); BF_INVENTORY.setObjectScene(INV_HANDCUFFS, 1); BF_GLOBALS._player.enableControl(); diff --git a/engines/tsage/blue_force/blueforce_scenes4.cpp b/engines/tsage/blue_force/blueforce_scenes4.cpp index 338b180c2c..6ed4e8af02 100644 --- a/engines/tsage/blue_force/blueforce_scenes4.cpp +++ b/engines/tsage/blue_force/blueforce_scenes4.cpp @@ -226,7 +226,7 @@ void Scene410::Action7::signal() { &scene->_harrison, NULL); break; case 5: - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); setAction(&scene->_sequenceManager1, this, 4118, &BF_GLOBALS._player, NULL); BF_GLOBALS._player.disableControl(); break; @@ -274,7 +274,7 @@ bool Scene410::TruckFront::startAction(CursorType action, Event &event) { else if (BF_GLOBALS.getFlag(fSearchedTruck)) SceneItem::display2(410, 13); else if (BF_GLOBALS.getFlag(fGangInCar)) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); scene->_sceneMode = 4118; scene->signal(); } else { @@ -307,7 +307,7 @@ bool Scene410::Driver::startAction(CursorType action, Event &event) { } else if (!scene->_field1FC0) { scene->_sceneMode = 4124; scene->_field1FC0 = 1; - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); scene->signal(); } else { break; @@ -325,7 +325,7 @@ bool Scene410::Driver::startAction(CursorType action, Event &event) { scene->_sceneMode = 4123; scene->_stripManager.start(4125, scene); scene->_field1FBC = 1; - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); } else { if (BF_GLOBALS.getFlag(fTalkedDriverNoBkup)) { scene->setAction(&scene->_action4); @@ -345,7 +345,7 @@ bool Scene410::Driver::startAction(CursorType action, Event &event) { break; } else { scene->_field1FC2 = 1; - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS._player.disableControl(); scene->_sceneMode = 4127; scene->setAction(&scene->_sequenceManager1, scene, 4127, &BF_GLOBALS._player, &scene->_driver, NULL); @@ -359,7 +359,7 @@ bool Scene410::Driver::startAction(CursorType action, Event &event) { SceneItem::display2(390, 15); } else { BF_GLOBALS.setFlag(readFrankRights); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS._player.disableControl(); scene->_sceneMode = 0; @@ -390,7 +390,7 @@ bool Scene410::Passenger::startAction(CursorType action, Event &event) { } else if (!scene->_field1FBE) { scene->_sceneMode = 4121; scene->_field1FBE = 1; - BF_GLOBALS._uiElements.addScore(50); + T2_GLOBALS._uiElements.addScore(50); scene->signal(); } else { break; @@ -423,7 +423,7 @@ bool Scene410::Passenger::startAction(CursorType action, Event &event) { SceneItem::display2(390, 15); } else { BF_GLOBALS.setFlag(readFrankRights); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS._player.disableControl(); scene->_sceneMode = 0; @@ -729,7 +729,7 @@ void Scene410::signal() { _stripManager.start(4111, this); _field1FBA = 1; BF_GLOBALS.setFlag(fCuffedFrankie); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); break; case 10: BF_GLOBALS._player.updateAngle(_harrison._position); @@ -932,7 +932,7 @@ bool Scene415::GunAndWig::startAction(CursorType action, Event &event) { BF_INVENTORY.setObjectScene(INV_AUTO_RIFLE, 1); BF_INVENTORY.setObjectScene(INV_WIG, 1); BF_GLOBALS.setFlag(fGotAutoWeapon); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); remove(); return true; @@ -943,7 +943,7 @@ bool Scene415::GunAndWig::startAction(CursorType action, Event &event) { BF_GLOBALS._player.disableControl(); scene->_sceneMode = 0; scene->_stripManager.start(4126, scene); - BF_GLOBALS._uiElements.addScore(50); + T2_GLOBALS._uiElements.addScore(50); scene->_fieldE14 = true; return true; default: @@ -988,7 +988,7 @@ bool Scene415::TheBullets::startAction(CursorType action, Event &event) { NamedObject::startAction(action, event); BF_INVENTORY.setObjectScene(INV_22_BULLET, 1); BF_GLOBALS.setFlag(fGotBulletsFromDash); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); remove(); scene->_dashDrawer.remove(); @@ -1001,7 +1001,7 @@ bool Scene415::TheBullets::startAction(CursorType action, Event &event) { BF_GLOBALS._player.disableControl(); scene->_sceneMode = 0; scene->_stripManager.start(4122, scene); - BF_GLOBALS._uiElements.addScore(50); + T2_GLOBALS._uiElements.addScore(50); scene->_fieldE16 = true; } break; @@ -1350,7 +1350,7 @@ bool Scene450::Weasel::startAction(CursorType action, Event &event) { case INV_FOREST_RAP: BF_INVENTORY.setObjectScene(INV_FOREST_RAP, 450); BF_GLOBALS._player.disableControl(); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); scene->_sceneMode = 4505; scene->setAction(&scene->_sequenceManager, scene, 4505, &BF_GLOBALS._player, this, @@ -1450,7 +1450,7 @@ bool Scene450::Manager::startAction(CursorType action, Event &event) { SceneItem::display2(450, 16); BF_GLOBALS._player.enableControl(); } else { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); scene->_sceneMode = 4510; BF_INVENTORY.setObjectScene(INV_NAPKIN, 450); scene->setAction(&scene->_sequenceManager, scene, 4510, &BF_GLOBALS._player, this, NULL); @@ -1465,12 +1465,12 @@ bool Scene450::Manager::startAction(CursorType action, Event &event) { BF_GLOBALS._player.disableControl(); if (!BF_GLOBALS.getFlag(showEugeneID)) - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(showEugeneID); if ((BF_GLOBALS.getFlag(showRapEugene) || BF_GLOBALS.getFlag(showEugeneNapkin)) && !BF_GLOBALS.getFlag(fMgrCallsWeasel)) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); scene->_sceneMode = 4511; scene->setAction(&scene->_sequenceManager, scene, 4511, &BF_GLOBALS._player, this, NULL); } else { diff --git a/engines/tsage/blue_force/blueforce_scenes5.cpp b/engines/tsage/blue_force/blueforce_scenes5.cpp index d89dd24ecb..7d11e782a5 100644 --- a/engines/tsage/blue_force/blueforce_scenes5.cpp +++ b/engines/tsage/blue_force/blueforce_scenes5.cpp @@ -465,7 +465,7 @@ bool Scene551::Drunk::startAction(CursorType action, Event &event) { BF_GLOBALS.set2Flags(f1098Drunk); BF_GLOBALS.setFlag(didDrunk); _flag = 1; - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS._player.disableControl(); scene->_sceneMode = 5506; @@ -560,7 +560,7 @@ bool Scene551::TrunkKits::startAction(CursorType action, Event &event) { break; case 2: if (!BF_GLOBALS.getFlag(fShowedBluePrint)) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(fShowedBluePrint); } @@ -1175,7 +1175,7 @@ void Scene560::SafeInset::signal() { BF_GLOBALS._sceneObjects->draw(); if (!BF_GLOBALS.getFlag(fGotPointsForBank)) { - BF_GLOBALS._uiElements.addScore(50); + T2_GLOBALS._uiElements.addScore(50); BF_GLOBALS.setFlag(fGotPointsForBank); } @@ -1305,7 +1305,7 @@ bool Scene560::SafeInset::Item::startAction(CursorType action, Event &event) { bool Scene560::Nickel::startAction(CursorType action, Event &event) { if (action == CURSOR_USE) { BF_INVENTORY.setObjectScene(INV_NICKEL, 1); - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); remove(); return true; } else { @@ -1335,7 +1335,7 @@ bool Scene560::BoxInset::Item1::startAction(CursorType action, Event &event) { if (action == CURSOR_USE) { if (!BF_GLOBALS.getFlag(fGotPointsForBox)) { - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); BF_GLOBALS.setFlag(fGotPointsForBox); } @@ -1513,7 +1513,7 @@ void Scene560::signal() { } } else if ((_sceneMode != 3) && (_sceneMode != 4)) { if (!BF_GLOBALS.getFlag(fGotPointsForPunch)) { - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); BF_GLOBALS.setFlag(fGotPointsForPunch); } @@ -1664,12 +1664,12 @@ void Scene570::PasswordEntry::checkPassword() { if (!_entryBuffer.compareTo("JACKIE") || !_entryBuffer.compareTo("SCUMMVM")) { // Password was correct - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS._player.disableControl(); scene->_sound1.play(73); - BF_GLOBALS._uiElements.hide(); - BF_GLOBALS._uiElements._active = false; + T2_GLOBALS._uiElements.hide(); + T2_GLOBALS._uiElements._active = false; scene->_sceneMode = 5701; scene->setAction(&scene->_sequenceManager, scene, 5701, &scene->_object3, NULL); } else { @@ -1846,20 +1846,20 @@ bool Scene570::Icon::startAction(CursorType action, Event &event) { scene->_iconManager.hideList(); switch (_folderId) { case 8: - BF_GLOBALS._uiElements.hide(); - BF_GLOBALS._uiElements._active = false; + T2_GLOBALS._uiElements.hide(); + T2_GLOBALS._uiElements._active = false; scene->_sceneMode = 5705; scene->setAction(&scene->_sequenceManager, scene, 5705, &scene->_object3, NULL); break; case 10: - BF_GLOBALS._uiElements.hide(); - BF_GLOBALS._uiElements._active = false; + T2_GLOBALS._uiElements.hide(); + T2_GLOBALS._uiElements._active = false; scene->_sceneMode = 5706; scene->setAction(&scene->_sequenceManager, scene, 5706, &scene->_object3, NULL); break; case 12: - BF_GLOBALS._uiElements.hide(); - BF_GLOBALS._uiElements._active = false; + T2_GLOBALS._uiElements.hide(); + T2_GLOBALS._uiElements._active = false; scene->_sceneMode = 5707; scene->setAction(&scene->_sequenceManager, scene, 5707, &scene->_object3, NULL); break; @@ -1869,8 +1869,8 @@ bool Scene570::Icon::startAction(CursorType action, Event &event) { break; case 7: scene->_iconManager.hideList(); - BF_GLOBALS._uiElements.hide(); - BF_GLOBALS._uiElements._active = false; + T2_GLOBALS._uiElements.hide(); + T2_GLOBALS._uiElements._active = false; scene->_sceneMode = 5704; scene->setAction(&scene->_sequenceManager, scene, 5704, &scene->_object3, NULL); break; @@ -1889,7 +1889,7 @@ bool Scene570::Icon::startAction(CursorType action, Event &event) { scene->_sound1.play(74); if (BF_INVENTORY.getObjectScene(INV_PRINT_OUT) == 570) { SceneItem::display2(570, 6); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_INVENTORY.setObjectScene(INV_PRINT_OUT, 1); } else { SceneItem::display2(570, 7); @@ -1938,7 +1938,7 @@ bool Scene570::PowerSwitch::startAction(CursorType action, Event &event) { scene->_object3.remove(); } else { if (!BF_GLOBALS.getFlag(fGotPointsForCoin)) { - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); BF_GLOBALS.setFlag(fGotPointsForCoin); } @@ -2106,16 +2106,16 @@ void Scene570::signal() { _icon3.setDetails(7, 6, 0, 2, SCENE570_COBB); _iconManager.refreshList(); - BF_GLOBALS._uiElements._active = true; - BF_GLOBALS._uiElements.show(); + T2_GLOBALS._uiElements._active = true; + T2_GLOBALS._uiElements.show(); BF_GLOBALS._player.enableControl(); break; case 5704: case 5705: case 5706: case 5707: - BF_GLOBALS._uiElements._active = true; - BF_GLOBALS._uiElements.show(); + T2_GLOBALS._uiElements._active = true; + T2_GLOBALS._uiElements.show(); _object3.setPosition(Common::Point(220, 75)); _object3.setVisage(572); _object3.setStrip(4); @@ -2333,7 +2333,7 @@ bool Scene590::Skip::startAction(CursorType action, Event &event) { return true; case INV_BASEBALL_CARD: scene->_field17DE = 1; - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); BF_INVENTORY.setObjectScene(INV_BASEBALL_CARD, 2); BF_GLOBALS._player.disableControl(); diff --git a/engines/tsage/blue_force/blueforce_scenes6.cpp b/engines/tsage/blue_force/blueforce_scenes6.cpp index e8c9af5492..56fdec47cd 100644 --- a/engines/tsage/blue_force/blueforce_scenes6.cpp +++ b/engines/tsage/blue_force/blueforce_scenes6.cpp @@ -281,7 +281,7 @@ void Scene666::postInit(SceneObjectList *OwnerList) { } BF_GLOBALS._scenePalette.loadPalette(BF_GLOBALS._sceneManager._previousScene); - BF_GLOBALS._uiElements._active = false; + T2_GLOBALS._uiElements._active = false; _item1.setDetails(Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), 666, -1, -1, -1, 1, NULL); BF_GLOBALS._player.postInit(); @@ -350,7 +350,7 @@ void Scene666::remove() { BF_GLOBALS._sound1.fadeOut2(NULL); BF_GLOBALS._scrollFollower = &BF_GLOBALS._player; SceneExt::remove(); - BF_GLOBALS._uiElements._active = true; + T2_GLOBALS._uiElements._active = true; } void Scene666::signal() { diff --git a/engines/tsage/blue_force/blueforce_scenes8.cpp b/engines/tsage/blue_force/blueforce_scenes8.cpp index 12474b29d1..fd5eb068e0 100644 --- a/engines/tsage/blue_force/blueforce_scenes8.cpp +++ b/engines/tsage/blue_force/blueforce_scenes8.cpp @@ -103,7 +103,7 @@ bool Scene800::Car1::startAction(CursorType action, Event &event) { else { BF_GLOBALS.setFlag(ticketVW); BF_GLOBALS._player.disableControl(); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); scene->_sceneMode = 8005; scene->setAction(&scene->_action1); } @@ -398,7 +398,7 @@ void Scene810::Action2::signal() { switch (_actionIndex++) { case 0: if (!BF_GLOBALS.getFlag(shownLyleCrate1Day1)) - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); if (scene->_lyle._position.x == 115) { ADD_PLAYER_MOVER(174, 142); @@ -652,7 +652,7 @@ bool Scene810::FaxMachineInset::startAction(CursorType action, Event &event) { case CURSOR_USE: if (scene->_rect3.contains(event.mousePos)) { if (BF_INVENTORY.getObjectScene(INV_PRINT_OUT) == 811) { - BF_GLOBALS._uiElements.addScore(50); + T2_GLOBALS._uiElements.addScore(50); scene->_sound1.play(77); BF_GLOBALS._player.disableControl(); @@ -1164,7 +1164,7 @@ void Scene810::signal() { BF_GLOBALS._player.enableControl(); break; case 8106: - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_INVENTORY.setObjectScene(INV_MICROFILM, 820); BF_GLOBALS._sceneManager.changeScene(820); break; @@ -1194,7 +1194,7 @@ void Scene810::signal() { BF_GLOBALS._sceneManager.changeScene(935); break; case 8114: - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); BF_INVENTORY.setObjectScene(INV_MICROFILM, 1); BF_GLOBALS._player.enableControl(); break; @@ -1853,13 +1853,13 @@ void Scene830::signal() { BF_GLOBALS._player.animate(ANIM_MODE_1, NULL); BF_GLOBALS._player._strip = 7; - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_INVENTORY.setObjectScene(INV_CARTER_NOTE, 1); break; case 8307: BF_GLOBALS._player.enableControl(); _object5.remove(); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_INVENTORY.setObjectScene(INV_FISHING_NET, 1); break; case 8309: @@ -2013,7 +2013,7 @@ bool Scene840::BoatKeysInset::startAction(CursorType action, Event &event) { if ((BF_GLOBALS._dayNumber != 4) || (BF_GLOBALS._bookmark != bEndDayThree)) SceneItem::display2(840, 47); else { - BF_GLOBALS._uiElements.addScore(50); + T2_GLOBALS._uiElements.addScore(50); if (BF_INVENTORY.getObjectScene(INV_RENTAL_KEYS) == 1) { // Replace rental keys @@ -2058,7 +2058,7 @@ bool Scene840::BoatKeysInset::RentalKeys::startAction(CursorType action, Event & } else { SceneItem::display2(840, 55); BF_INVENTORY.setObjectScene(INV_RENTAL_KEYS, 1); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); scene->_boatKeysInset._v1B4 = 1; remove(); @@ -2077,7 +2077,7 @@ bool Scene840::BoatKeysInset::WaveKeys::startAction(CursorType action, Event &ev if (scene->_field1AC2) { SceneItem::display2(840, 56); BF_INVENTORY.setObjectScene(INV_WAVE_KEYS, 1); - BF_GLOBALS._uiElements.addScore(50); + T2_GLOBALS._uiElements.addScore(50); scene->_boatKeysInset._v1B6 = 1; remove(); } else { @@ -2150,7 +2150,7 @@ bool Scene840::Carter::startAction(CursorType action, Event &event) { if (BF_INVENTORY.getObjectScene(INV_WAVE_KEYS) == 1) { if (!BF_GLOBALS.getFlag(fGotPointsForCombo)) { - BF_GLOBALS._uiElements.addScore(50); + T2_GLOBALS._uiElements.addScore(50); BF_GLOBALS.setFlag(fGotPointsForCombo); } } @@ -2409,13 +2409,13 @@ void Scene840::signal() { break; case 8402: BF_GLOBALS._player.enableControl(); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_INVENTORY.setObjectScene(INV_CARTER_NOTE, 3); BF_INVENTORY.setObjectScene(INV_BASEBALL_CARD, 1); BF_INVENTORY.setObjectScene(INV_RENTAL_COUPON, 1); break; case 8403: - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); _sceneMode = 3; _field1AC0 = 1; _stripManager.start(8441, this); @@ -2477,13 +2477,13 @@ void Scene840::signal() { } break; case 8413: - BF_GLOBALS._uiElements.addScore(50); + T2_GLOBALS._uiElements.addScore(50); _sceneMode = 8409; setAction(&_sequenceManager1, this, 8409, &BF_GLOBALS._player, &_carter, &_doors, NULL); break; case 8417: _field1ABA = 1; - BF_GLOBALS._uiElements.addScore(50); + T2_GLOBALS._uiElements.addScore(50); BF_INVENTORY.setObjectScene(INV_WAVE_KEYS, 0); BF_INVENTORY.setObjectScene(INV_RENTAL_KEYS, 0); BF_GLOBALS._player.enableControl(); @@ -2926,7 +2926,7 @@ bool Scene870::CrateInset::Jar::startAction(CursorType action, Event &event) { if (action == CURSOR_USE) { BF_INVENTORY.setObjectScene(INV_JAR, 1); remove(); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); return true; } else { return NamedObject::startAction(action, event); @@ -2937,7 +2937,7 @@ bool Scene870::CrateInset::Rags::startAction(CursorType action, Event &event) { if (action == CURSOR_USE) { BF_INVENTORY.setObjectScene(INV_RAGS, 1); remove(); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); return true; } else { return NamedObject::startAction(action, event); @@ -3443,14 +3443,14 @@ void Scene880::signal() { BF_GLOBALS._sceneManager.changeScene(666); break; case 3: - BF_GLOBALS._uiElements.addScore(50); + T2_GLOBALS._uiElements.addScore(50); BF_GLOBALS.clearFlag(gunDrawn); BF_INVENTORY.setObjectScene(INV_GRENADES, 880); _sceneMode = 0; signal(); break; case 4: - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.clearFlag(gunDrawn); _sceneMode = 0; signal(); @@ -3489,7 +3489,7 @@ void Scene880::signal() { case 8815: if (BF_INVENTORY.getObjectScene(INV_DOG_WHISTLE) == 880) { BF_INVENTORY.setObjectScene(INV_DOG_WHISTLE, 1); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); SceneItem::display2(880, 13); } else { diff --git a/engines/tsage/blue_force/blueforce_scenes9.cpp b/engines/tsage/blue_force/blueforce_scenes9.cpp index ad0ac2f24f..74fd1214a1 100644 --- a/engines/tsage/blue_force/blueforce_scenes9.cpp +++ b/engines/tsage/blue_force/blueforce_scenes9.cpp @@ -90,14 +90,14 @@ bool Scene900::Gate::startAction(CursorType action, Event &event) { if (BF_GLOBALS._v4CEC0 == 0) { if (!BF_GLOBALS.getFlag(fGotPointsForUnlockGate)) { BF_GLOBALS.setFlag(fGotPointsForUnlockGate); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); } BF_GLOBALS._v4CEC0 = 1; } else { if (!BF_GLOBALS.getFlag(fGotPointsForLockGate)) { if (BF_GLOBALS._bookmark == bEndDayThree) { BF_GLOBALS.setFlag(fGotPointsForLockGate); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); } } BF_GLOBALS._v4CEC0 = 0; @@ -324,7 +324,7 @@ void Scene900::Action2::signal() { BF_GLOBALS._player._strip = 7; if (!BF_GLOBALS.getFlag(fGotPointsForTrapDog)) { BF_GLOBALS.setFlag(fGotPointsForTrapDog); - BF_GLOBALS._uiElements.addScore(50); + T2_GLOBALS._uiElements.addScore(50); } SceneItem::display2(900, 10); scene->_dog._flag = 1; @@ -377,7 +377,7 @@ void Scene900::Action3::signal() { SceneItem::display2(900, 24); if (!BF_GLOBALS.getFlag(fGotPointsForLockWarehouse)) { BF_GLOBALS.setFlag(fGotPointsForLockWarehouse); - BF_GLOBALS._uiElements.addScore(10); + T2_GLOBALS._uiElements.addScore(10); } BF_GLOBALS._player.enableControl(); remove(); @@ -427,7 +427,7 @@ void Scene900::postInit(SceneObjectList *OwnerList) { BF_GLOBALS._sound1.changeSound(91); _field1974 = 0; _field1976 = 0; - BF_GLOBALS._uiElements._active = true; + T2_GLOBALS._uiElements._active = true; BF_GLOBALS.clearFlag(fCanDrawGun); if (BF_GLOBALS._dayNumber == 0) { BF_GLOBALS._dayNumber = 4; @@ -634,7 +634,7 @@ void Scene900::signal() { _dog.signal(); if ((!BF_GLOBALS.getFlag(fGotPointsForFreeDog)) && (BF_GLOBALS._bookmark == bEndDayThree)) { BF_GLOBALS.setFlag(fGotPointsForFreeDog); - BF_GLOBALS._uiElements.addScore(50); + T2_GLOBALS._uiElements.addScore(50); } BF_INVENTORY.setObjectScene(INV_FISHING_NET, 1); SceneItem::display2(900, 11); @@ -647,14 +647,14 @@ void Scene900::signal() { _door._flag = 1; if ((!BF_GLOBALS.getFlag(fGotPointsForLockWarehouse)) && (BF_GLOBALS._bookmark == bEndDayThree)) { BF_GLOBALS.setFlag(fGotPointsForLockWarehouse); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); } } else { SceneItem::display2(900, 13); _door._flag = 0; if (!BF_GLOBALS.getFlag(fGotPointsForUnlockWarehouse)) { BF_GLOBALS.setFlag(fGotPointsForUnlockWarehouse); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); } } BF_GLOBALS._player.enableControl(); @@ -1292,7 +1292,7 @@ bool Scene910::Object13::startAction(CursorType action, Event &event) { if (BF_GLOBALS._v4CEE2 < 1) { if (_frame == 2) { if (!BF_GLOBALS.getFlag(81)) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(81); } scene->_sceneMode = 0; @@ -1333,7 +1333,7 @@ bool Scene910::Object13::startAction(CursorType action, Event &event) { } else { if (BF_GLOBALS._v4CEC8 == 1) { if (!BF_GLOBALS.getFlag(78)) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(78); } BF_GLOBALS._player.disableControl(); @@ -1659,12 +1659,12 @@ bool Scene910::BlackPlug::startAction(CursorType action, Event &event) { if (BF_GLOBALS._v4CECA == 0) { if (_field90 == 1) { if (!BF_GLOBALS.getFlag(fGotPointsForBlackCord)) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(fGotPointsForBlackCord); } } else { if (!BF_GLOBALS.getFlag(fGotPointsForGeneratorPlug)) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(fGotPointsForGeneratorPlug); } } @@ -1674,12 +1674,12 @@ bool Scene910::BlackPlug::startAction(CursorType action, Event &event) { } else if (BF_GLOBALS._v4CECA == 1) { if (_field90 == 1) { if (!BF_GLOBALS.getFlag(fGotPointsForBlackCord)) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(fGotPointsForBlackCord); } } else { if (!BF_GLOBALS.getFlag(fGotPointsForGeneratorPlug)) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(fGotPointsForGeneratorPlug); } } @@ -1771,7 +1771,7 @@ bool Scene910::PowerButton::startAction(CursorType action, Event &event) { scene->_sound1.play(100); scene->_sound1.holdAt(1); if (!BF_GLOBALS.getFlag(77)) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(77); } setFrame(5); @@ -1786,7 +1786,7 @@ bool Scene910::PowerButton::startAction(CursorType action, Event &event) { scene->_sound1.release(); if (BF_GLOBALS._bookmark == 21) { if (!BF_GLOBALS.getFlag(82)) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(82); } } @@ -2409,7 +2409,7 @@ void Scene910::signal() { break; case 9110: if (!BF_GLOBALS.getFlag(fGotPointsForCrate)) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(fGotPointsForCrate); } BF_INVENTORY.setObjectScene(INV_BLACK_CORD, 1); @@ -2418,7 +2418,7 @@ void Scene910::signal() { break; case 9111: if ((BF_GLOBALS._bookmark == bEndDayThree) && (!BF_GLOBALS.getFlag(fGotPointsForGeneratorOff))) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(fGotPointsForGeneratorOff); } BF_INVENTORY.setObjectScene(INV_BLACK_CORD, 910); @@ -2482,7 +2482,7 @@ void Scene910::signal() { break; case 9119: if (!BF_GLOBALS.getFlag(fGotPointsForCordOnForklift)) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(fGotPointsForCordOnForklift); } BF_INVENTORY.setObjectScene(INV_YELLOW_CORD, 0); @@ -2640,7 +2640,7 @@ void Scene910::signal() { break; case 9136: if (!BF_GLOBALS.getFlag(fGotPointsForCuffingNico)) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(fGotPointsForCuffingNico); } _lyle.setAction(&_sequenceManager2, NULL, 9131, &_lyle, NULL); @@ -2666,7 +2666,7 @@ void Scene910::signal() { case 9141: BF_INVENTORY.setObjectScene(INV_22_SNUB, 1); if (!BF_GLOBALS.getFlag(fGotPointsForCuffingDA)) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(fGotPointsForCuffingDA); } BF_GLOBALS._player.enableControl(); @@ -2674,7 +2674,7 @@ void Scene910::signal() { case 9142: BF_GLOBALS._player.enableControl(); if (!BF_GLOBALS.getFlag(fGotPointsForSearchingNico)) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(fGotPointsForSearchingNico); } break; @@ -2868,7 +2868,7 @@ void Scene910::subE82BD() { return; if (! BF_GLOBALS.getFlag(fGotPointsForLightsOn)) { - BF_GLOBALS._uiElements.addScore(50); + T2_GLOBALS._uiElements.addScore(50); BF_GLOBALS.setFlag(fGotPointsForLightsOn); } BF_GLOBALS._v4CEE0 = 1; @@ -2886,7 +2886,7 @@ void Scene910::subE83E1() { if (BF_GLOBALS._v4CEE0 != 0) { _fakeWall.show(); if ((BF_GLOBALS._bookmark == 21) && (!BF_GLOBALS.getFlag(80))) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(80); } BF_GLOBALS._v4CEE0 = 0; @@ -2929,7 +2929,7 @@ bool Scene920::Item1::startAction(CursorType action, Event &event) { scene->_crateWindow.postInit(); scene->_sceneMode = 9204; if (!BF_GLOBALS.getFlag(fGotPointsForBoots)) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(fGotPointsForBoots); } scene->setAction(&scene->_sequenceManager1, scene, 9204, &BF_GLOBALS._player, &scene->_crateWindow, NULL); @@ -3054,7 +3054,7 @@ void Scene920::signal() { } case 9207: BF_GLOBALS._player.enableControl(); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_INVENTORY.setObjectScene(15, 1); BF_GLOBALS._bookmark = bEndDayThree; break; @@ -3123,7 +3123,7 @@ bool Scene930::Object2::startAction(CursorType action, Event &event) { return NamedObject::startAction(action, event); NamedObject::startAction(action, event); - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_INVENTORY.setObjectScene(54, 1); BF_GLOBALS.setFlag(93); remove(); @@ -3203,7 +3203,7 @@ bool Scene930::Object5::startAction(CursorType action, Event &event) { _lookLineNum = 76; _useLineNum = 78; } else { - BF_GLOBALS._uiElements.addScore(50); + T2_GLOBALS._uiElements.addScore(50); BF_INVENTORY.setObjectScene(55, 1); setFrame2(getFrameCount()); _lookLineNum = 92; @@ -3270,7 +3270,7 @@ void Scene930::Action1::signal() { case 5: scene->showBootWindow(); if (!BF_GLOBALS.getFlag(72)) { - BF_GLOBALS._uiElements.addScore(30); + T2_GLOBALS._uiElements.addScore(30); BF_GLOBALS.setFlag(72); } SceneItem::display(0, 312); @@ -3803,7 +3803,7 @@ void Scene940::postInit(SceneObjectList *OwnerList) { BF_GLOBALS._sound1.play(115); BF_GLOBALS._dayNumber = 6; BF_GLOBALS._interfaceY = 200; - BF_GLOBALS._uiElements._active = false; + T2_GLOBALS._uiElements._active = false; _gameTextSpeaker2._speakerName = "SENTTEXT"; _gameTextSpeaker2._color1 = 104; @@ -3885,7 +3885,7 @@ void Scene940::remove() { // clearScren(); BF_GLOBALS._scrollFollower = &BF_GLOBALS._player; SceneExt::remove(); - BF_GLOBALS._uiElements._active = true; + T2_GLOBALS._uiElements._active = true; } } // End of namespace BlueForce diff --git a/engines/tsage/blue_force/blueforce_ui.cpp b/engines/tsage/blue_force/blueforce_ui.cpp deleted file mode 100644 index 9df5c93014..0000000000 --- a/engines/tsage/blue_force/blueforce_ui.cpp +++ /dev/null @@ -1,522 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "tsage/blue_force/blueforce_ui.h" -#include "tsage/blue_force/blueforce_dialogs.h" -#include "tsage/blue_force/blueforce_logic.h" -#include "tsage/tsage.h" -#include "tsage/core.h" - -namespace TsAGE { - -namespace BlueForce { - -void StripProxy::process(Event &event) { - if (_action) - _action->process(event); -} - -/*--------------------------------------------------------------------------*/ - -void UIElement::synchronize(Serializer &s) { - BackgroundSceneObject::synchronize(s); - s.syncAsSint16LE(_field88); - s.syncAsSint16LE(_enabled); - s.syncAsSint16LE(_frameNum); -} - -void UIElement::setup(int visage, int stripNum, int frameNum, int posX, int posY, int priority) { - _field88 = 0; - _frameNum = frameNum; - _enabled = true; - - SceneObject::setup(visage, stripNum, frameNum, posX, posY, priority); -} - -void UIElement::setEnabled(bool flag) { - if (_enabled != flag) { - _enabled = flag; - setFrame(_enabled ? _frameNum : _frameNum + 2); - } -} - -/*--------------------------------------------------------------------------*/ - -void UIQuestion::process(Event &event) { - if (event.eventType == EVENT_BUTTON_DOWN) { - CursorType currentCursor = GLOBALS._events.getCursor(); - GLOBALS._events.hideCursor(); - showDescription(currentCursor); - - event.handled = true; - } -} - -void UIQuestion::showDescription(CursorType cursor) { - if (cursor == INV_FOREST_RAP) { - // Forest rap item has a graphical display - showItem(5, 1, 1); - } else { - // Display object description - SceneItem::display2(9001, (int)cursor); - } -} - -void UIQuestion::setEnabled(bool flag) { - if (_enabled != flag) { - UIElement::setEnabled(flag); - BF_GLOBALS._uiElements.draw(); - } -} - -void UIQuestion::showItem(int resNum, int rlbNum, int frameNum) { - GfxDialog::setPalette(); - - // Get the item to display - GfxSurface objImage = surfaceFromRes(resNum, rlbNum, frameNum); - Rect imgRect; - imgRect.resize(objImage, 0, 0, 100); - imgRect.center(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2); - - // Save the area behind where the image will be displayed - GfxSurface *savedArea = Surface_getArea(BF_GLOBALS.gfxManager().getSurface(), imgRect); - - // Draw the image - BF_GLOBALS.gfxManager().copyFrom(objImage, imgRect); - - // Wait for a press - BF_GLOBALS._events.waitForPress(); - - // Restore the old area - BF_GLOBALS.gfxManager().copyFrom(*savedArea, imgRect); - delete savedArea; -} - -/*--------------------------------------------------------------------------*/ - -void UIScore::postInit(SceneObjectList *OwnerList) { - int xp = 266; - _digit3.setup(1, 6, 1, xp, 180, 255); - _digit3.reposition(); - xp += 7; - _digit2.setup(1, 6, 1, xp, 180, 255); - _digit2.reposition(); - xp += 7; - _digit1.setup(1, 6, 1, xp, 180, 255); - _digit1.reposition(); - xp += 7; - _digit0.setup(1, 6, 1, xp, 180, 255); - _digit0.reposition(); -} - -void UIScore::draw() { - _digit3.draw(); - _digit2.draw(); - _digit1.draw(); - _digit0.draw(); -} - -void UIScore::updateScore() { - int score = BF_GLOBALS._uiElements._scoreValue; - - _digit3.setFrame(score / 1000 + 1); score %= 1000; - _digit2.setFrame(score / 100 + 1); score %= 100; - _digit1.setFrame(score / 10 + 1); score %= 10; - _digit0.setFrame(score + 1); -} - -/*--------------------------------------------------------------------------*/ - -UIInventorySlot::UIInventorySlot(): UIElement() { - _objIndex = 0; - _object = NULL; -} - -void UIInventorySlot::synchronize(Serializer &s) { - UIElement::synchronize(s); - s.syncAsSint16LE(_objIndex); - SYNC_POINTER(_object); -} - -void UIInventorySlot::process(Event &event) { - if (event.eventType == EVENT_BUTTON_DOWN) { - event.handled = true; - - if (_objIndex == INV_AMMO_BELT) { - // Handle showing ammo belt - showAmmoBelt(); - - } else if (_objIndex != INV_NONE) { - _object->setCursor(); - } - } -} - -void UIInventorySlot::showAmmoBelt() { - AmmoBeltDialog *dlg = new AmmoBeltDialog(); - dlg->execute(); - delete dlg; -} - -/*--------------------------------------------------------------------------*/ - -UIInventoryScroll::UIInventoryScroll() { - _isLeft = false; -} - -void UIInventoryScroll::synchronize(Serializer &s) { - UIElement::synchronize(s); - s.syncAsSint16LE(_isLeft); -} - -void UIInventoryScroll::process(Event &event) { - switch (event.eventType) { - case EVENT_BUTTON_DOWN: - // Draw the button as selected - toggle(true); - - event.handled = true; - break; - case EVENT_BUTTON_UP: - // Restore unselected version - toggle(false); - - // Scroll the inventory as necessary - BF_GLOBALS._uiElements.scrollInventory(_isLeft); - event.handled = true; - break; - default: - break; - } -} - -void UIInventoryScroll::toggle(bool pressed) { - if (_enabled) { - setFrame(pressed ? (_frameNum + 1) : _frameNum); - BF_GLOBALS._uiElements.draw(); - } -} - -/*--------------------------------------------------------------------------*/ - -UICollection::UICollection(): EventHandler() { - _clearScreen = false; - _visible = false; - _cursorChanged = false; -} - -void UICollection::setup(const Common::Point &pt) { - _position = pt; - _bounds.left = _bounds.right = pt.x; - _bounds.top = _bounds.bottom = pt.y; -} - -void UICollection::hide() { - erase(); - _visible = false; -} - -void UICollection::show() { - _visible = true; - draw(); -} - -void UICollection::erase() { - if (_clearScreen) { - Rect tempRect(0, BF_INTERFACE_Y, SCREEN_WIDTH, SCREEN_HEIGHT); - BF_GLOBALS._screenSurface.fillRect(tempRect, 0); - BF_GLOBALS._sceneManager._scene->_backSurface.fillRect(tempRect, 0); - _clearScreen = false; - } -} - -void UICollection::resetClear() { - _clearScreen = false; -} - -void UICollection::draw() { - if (_visible) { - // Temporarily reset the sceneBounds when drawing UI elements to force them on-screen - Rect savedBounds = g_globals->_sceneManager._scene->_sceneBounds; - g_globals->_sceneManager._scene->_sceneBounds = Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); - - // Draw the elements onto the background - for (uint idx = 0; idx < _objList.size(); ++idx) - _objList[idx]->draw(); - - // Draw the resulting UI onto the screen - BF_GLOBALS._screenSurface.copyFrom(BF_GLOBALS._sceneManager._scene->_backSurface, - Rect(0, BF_INTERFACE_Y, SCREEN_WIDTH, SCREEN_HEIGHT), - Rect(0, BF_INTERFACE_Y, SCREEN_WIDTH, SCREEN_HEIGHT)); - - _clearScreen = 1; - g_globals->_sceneManager._scene->_sceneBounds = savedBounds; - } -} - -/*--------------------------------------------------------------------------*/ - -UIElements::UIElements(): UICollection() { - _cursorVisage.setVisage(1, 5); - g_saver->addLoadNotifier(&UIElements::loadNotifierProc); -} - -void UIElements::synchronize(Serializer &s) { - UICollection::synchronize(s); - - s.syncAsSint16LE(_slotStart); - s.syncAsSint16LE(_scoreValue); - s.syncAsByte(_active); - - int count = _itemList.size(); - s.syncAsSint16LE(count); - if (s.isLoading()) { - // Load in item list - _itemList.clear(); - - for (int idx = 0; idx < count; ++idx) { - int itemId; - s.syncAsSint16LE(itemId); - _itemList.push_back(itemId); - } - } else { - // Save item list - for (int idx = 0; idx < count; ++idx) { - int itemId = _itemList[idx]; - s.syncAsSint16LE(itemId); - } - } -} - -void UIElements::process(Event &event) { - if (_clearScreen && BF_GLOBALS._player._enabled && (BF_GLOBALS._sceneManager._sceneNumber != 50)) { - if (_bounds.contains(event.mousePos)) { - // Cursor inside UI area - if (!_cursorChanged) { - if (BF_GLOBALS._events.isInventoryIcon()) { - // Inventory icon being displayed, so leave alone - } else { - // Change to the inventory use cursor - GfxSurface surface = _cursorVisage.getFrame(6); - BF_GLOBALS._events.setCursor(surface); - } - _cursorChanged = true; - } - - // Pass event to any element that the cursor falls on - for (int idx = (int)_objList.size() - 1; idx >= 0; --idx) { - if (_objList[idx]->_bounds.contains(event.mousePos) && _objList[idx]->_enabled) { - _objList[idx]->process(event); - if (event.handled) - break; - } - } - - if (event.eventType == EVENT_BUTTON_DOWN) - event.handled = true; - - } else if (_cursorChanged) { - // Cursor outside UI area, so reset as necessary - BF_GLOBALS._events.setCursor(BF_GLOBALS._events.getCursor()); - _cursorChanged = false; - - SceneExt *scene = (SceneExt *)BF_GLOBALS._sceneManager._scene; - if (scene->_focusObject) { - GfxSurface surface = _cursorVisage.getFrame(7); - BF_GLOBALS._events.setCursor(surface); - } - } - } -} - -void UIElements::setup(const Common::Point &pt) { - _slotStart = 0; - _itemList.clear(); - _scoreValue = 0; - _active = true; - UICollection::setup(pt); - hide(); - - _object1.setup(1, 3, 1, 0, 0, 255); - add(&_object1); - - // Set up the inventory slots - int xp = 0; - for (int idx = 0; idx < 4; ++idx) { - UIElement *item = NULL; - switch (idx) { - case 0: - item = &_slot1; - break; - case 1: - item = &_slot2; - break; - case 2: - item = &_slot3; - break; - case 3: - item = &_slot4; - break; - } - - xp = idx * 63 + 2; - item->setup(9, 1, idx, xp, 4, 255); - add(item); - } - - // Setup bottom-right hand buttons - xp += 62; - _question.setup(1, 4, 7, xp, 16, 255); - _question.setEnabled(false); - add(&_question); - - xp += 21; - _scrollLeft.setup(1, 4, 1, xp, 16, 255); - add(&_scrollLeft); - _scrollLeft._isLeft = true; - - xp += 22; - _scrollRight.setup(1, 4, 4, xp, 16, 255); - add(&_scrollRight); - _scrollRight._isLeft = false; - - // Set up the score - _score.postInit(); - add(&_score); - - // Set interface area - _bounds = Rect(0, BF_INTERFACE_Y - 1, SCREEN_WIDTH, SCREEN_HEIGHT); - - updateInventory(); -} - -void UIElements::add(UIElement *obj) { - // Add object - assert(_objList.size() < 12); - _objList.push_back(obj); - - obj->setPosition(Common::Point(_bounds.left + obj->_position.x, _bounds.top + obj->_position.y)); - obj->reposition(); - - GfxSurface s = obj->getFrame(); - s.draw(obj->_position); -} - -/** - * Handles updating the visual inventory in the user interface - */ -void UIElements::updateInventory() { - _score.updateScore(); - updateInvList(); - - // Enable scroll buttons if the player has more than four items - if (_itemList.size() > 4) { - _scrollLeft.setEnabled(true); - _scrollRight.setEnabled(true); - } else { - _scrollLeft.setEnabled(false); - _scrollRight.setEnabled(false); - } - - // Handle cropping the slots start within inventory - int lastPage = (_itemList.size() - 1) / 4 + 1; - if (_slotStart < 0) - _slotStart = lastPage - 1; - else if (_slotStart > (lastPage - 1)) - _slotStart = 0; - - // Handle refreshing slot graphics - UIInventorySlot *slotList[4] = { &_slot1, &_slot2, &_slot3, &_slot4 }; - - // Loop through the inventory objects - SynchronizedList::iterator i; - int objIndex = 0; - for (i = BF_INVENTORY._itemList.begin(); i != BF_INVENTORY._itemList.end(); ++i, ++objIndex) { - InvObject *obj = *i; - - // Check whether the object is in any of the four inventory slots - for (int slotIndex = 0; slotIndex < 4; ++slotIndex) { - int idx = _slotStart * 4 + slotIndex; - int objectIdx = (idx < (int)_itemList.size()) ? _itemList[idx] : 0; - - if (objectIdx == objIndex) { - UIInventorySlot *slot = slotList[slotIndex]; - - slot->_objIndex = objIndex; - slot->_object = obj; - slot->setVisage(obj->_visage); - slot->setStrip(obj->_strip); - slot->setFrame(obj->_frame); - } - } - } - - // Refresh the display if necessary - if (_active) - draw(); -} - -/** - * Update the list of the indexes of items in the player's inventory - */ -void UIElements::updateInvList() { - // Update the index list of items in the player's inventory - _itemList.clear(); - - SynchronizedList::iterator i; - int itemIndex = 0; - for (i = BF_GLOBALS._inventory->_itemList.begin(); i != BF_GLOBALS._inventory->_itemList.end(); ++i, ++itemIndex) { - InvObject *invObject = *i; - if (invObject->inInventory()) - _itemList.push_back(itemIndex); - } -} - -/** - * Set the game score - */ -void UIElements::addScore(int amount) { - _scoreValue += amount; - BF_GLOBALS._sound2.play(0); - updateInventory(); -} - -/* - * Scroll the inventory slots - */ -void UIElements::scrollInventory(bool isLeft) { - if (isLeft) - --_slotStart; - else - ++_slotStart; - - updateInventory(); -} - -void UIElements::loadNotifierProc(bool postFlag) { - if (postFlag && BF_GLOBALS._uiElements._active) - BF_GLOBALS._uiElements.show(); -} - -} // End of namespace BlueForce - -} // End of namespace TsAGE diff --git a/engines/tsage/blue_force/blueforce_ui.h b/engines/tsage/blue_force/blueforce_ui.h deleted file mode 100644 index 601b97a9fe..0000000000 --- a/engines/tsage/blue_force/blueforce_ui.h +++ /dev/null @@ -1,156 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef TSAGE_BLUEFORCE_UI_H -#define TSAGE_BLUEFORCE_UI_H - -#include "common/scummsys.h" -#include "tsage/core.h" -#include "tsage/graphics.h" -#include "tsage/sound.h" - -namespace TsAGE { - -namespace BlueForce { - -using namespace TsAGE; - -class StripProxy: public EventHandler { -public: - virtual void process(Event &event); -}; - -class UIElement: public BackgroundSceneObject { -public: - int _field88; - bool _enabled; - int _frameNum; - - virtual Common::String getClassName() { return "UIElement"; } - virtual void synchronize(Serializer &s); - - void setup(int visage, int stripNum, int frameNum, int posX, int posY, int priority); - void setEnabled(bool flag); -}; - -// This class implements the Question mark button -class UIQuestion: public UIElement { -private: - void showDescription(CursorType item); - void showItem(int resNum, int rlbNum, int frameNum); -public: - virtual void process(Event &event); - void setEnabled(bool flag); -}; - -// This class implements the score counter -class UIScore: public UIElement { -private: - void showDescription(int lineNum); -public: - UIElement _digit3, _digit2, _digit1, _digit0; - - virtual void postInit(SceneObjectList *OwnerList = NULL); - virtual void draw(); - - void updateScore(); -}; - -class UIInventorySlot: public UIElement { -private: - void showAmmoBelt(); -public: - int _objIndex; - InvObject *_object; - - UIInventorySlot(); - virtual Common::String getClassName() { return "UIInventorySlot"; } - virtual void synchronize(Serializer &s); - virtual void process(Event &event); -}; - -class UIInventoryScroll: public UIElement { -private: - void toggle(bool pressed); -public: - bool _isLeft; - - UIInventoryScroll(); - virtual Common::String getClassName() { return "UIInventoryScroll"; } - virtual void synchronize(Serializer &s); - virtual void process(Event &event); -}; - -class UICollection: public EventHandler { -protected: - void erase(); -public: - Common::Point _position; - Rect _bounds; - bool _visible; - bool _clearScreen; - bool _cursorChanged; - Common::Array _objList; - - UICollection(); - void setup(const Common::Point &pt); - void hide(); - void show(); - void resetClear(); - void draw(); -}; - -class UIElements: public UICollection { -private: - void add(UIElement *obj); - void updateInvList(); -public: - UIElement _object1; - UIQuestion _question; - UIScore _score; - UIInventorySlot _slot1, _slot2, _slot3, _slot4; - UIInventoryScroll _scrollLeft, _scrollRight; - ASound _sound; - int _slotStart, _scoreValue; - bool _active; - Common::Array _itemList; - Visage _cursorVisage; - - UIElements(); - virtual Common::String getClassName() { return "UIElements"; } - virtual void synchronize(Serializer &s); - virtual void postInit(SceneObjectList *OwnerList = NULL) { error("Wrong init() called"); } - virtual void process(Event &event); - - void setup(const Common::Point &pt); - void updateInventory(); - void addScore(int amount); - void scrollInventory(bool isLeft); - - static void loadNotifierProc(bool postFlag); -}; - -} // End of namespace BlueForce - -} // End of namespace TsAGE - -#endif diff --git a/engines/tsage/core.cpp b/engines/tsage/core.cpp index 61a413f307..b40c5af91b 100644 --- a/engines/tsage/core.cpp +++ b/engines/tsage/core.cpp @@ -66,6 +66,16 @@ InvObject::InvObject(int visage, int strip, int frame) { _iconResNum = 10; } +InvObject::InvObject(int strip, int frame) { + assert(g_vm->getGameID() == GType_Ringworld2); + _strip = strip; + _frame = frame; + + _visage = 0; + _sceneNumber = 0; + _iconResNum = 10; +} + void InvObject::setCursor() { if (g_vm->getGameID() == GType_BlueForce) { // Blue Force cursor handling @@ -1523,8 +1533,8 @@ void SceneItem::display(int resNum, int lineNum, ...) { Common::String msg = (!resNum || (resNum == -1)) ? Common::String() : g_resourceManager->getMessage(resNum, lineNum); - if ((g_vm->getGameID() == GType_BlueForce) && BF_GLOBALS._uiElements._active) - BF_GLOBALS._uiElements.hide(); + if ((g_vm->getGameID() == GType_BlueForce) && T2_GLOBALS._uiElements._active) + T2_GLOBALS._uiElements.hide(); if (g_globals->_sceneObjects->contains(&g_globals->_sceneText)) { g_globals->_sceneText.remove(); @@ -1655,9 +1665,9 @@ void SceneItem::display(int resNum, int lineNum, ...) { g_globals->_sceneText.remove(); } - if ((g_vm->getGameID() == GType_BlueForce) && BF_GLOBALS._uiElements._active) { + if ((g_vm->getGameID() == GType_BlueForce) && T2_GLOBALS._uiElements._active) { // Show user interface - BF_GLOBALS._uiElements.show(); + T2_GLOBALS._uiElements.show(); // Re-show the cursor BF_GLOBALS._events.setCursor(BF_GLOBALS._events.getCursor()); @@ -1689,13 +1699,15 @@ void SceneItem::display(const Common::String &msg) { /*--------------------------------------------------------------------------*/ bool SceneHotspot::startAction(CursorType action, Event &event) { - if (g_vm->getGameID() != GType_BlueForce) - return SceneItem::startAction(action, event); - else { + switch (action) { + case GType_BlueForce: { BlueForce::SceneExt *scene = (BlueForce::SceneExt *)BF_GLOBALS._sceneManager._scene; assert(scene); return scene->display(action); } + default: + return SceneItem::startAction(action, event); + } } void SceneHotspot::doAction(int action) { @@ -2423,6 +2435,13 @@ void SceneObject::setup(int visage, int stripFrameNum, int frameNum, int posX, i fixPriority(priority); } +void SceneObject::setup(int visage, int stripFrameNum, int frameNum) { + postInit(); + setVisage(visage); + setStrip(stripFrameNum); + setFrame(frameNum); +} + /*--------------------------------------------------------------------------*/ void BackgroundSceneObject::postInit(SceneObjectList *OwnerList) { @@ -2765,7 +2784,7 @@ void SceneText::updateScreen() { // FIXME: Hack for Blue Force to handle not refreshing the screen if the user interface // has been re-activated after showing some scene text if ((g_vm->getGameID() != GType_BlueForce) || (_bounds.top < BF_INTERFACE_Y) || - !BF_GLOBALS._uiElements._visible) + !T2_GLOBALS._uiElements._visible) SceneObject::updateScreen(); } @@ -2898,16 +2917,38 @@ void Player::disableControl() { g_globals->_events.setCursor(CURSOR_NONE); _enabled = false; - if ((g_vm->getGameID() == GType_BlueForce) && BF_GLOBALS._uiElements._active) - BF_GLOBALS._uiElements.hide(); + if ((g_vm->getGameID() == GType_BlueForce) && T2_GLOBALS._uiElements._active) + T2_GLOBALS._uiElements.hide(); } void Player::enableControl() { + CursorType cursor; + _canWalk = true; _uiEnabled = true; _enabled = true; - if (g_vm->getGameID() == GType_Ringworld) { + switch (g_vm->getGameID()) { + case GType_BlueForce: + cursor = g_globals->_events.getCursor(); + g_globals->_events.setCursor(cursor); + + if (T2_GLOBALS._uiElements._active) + T2_GLOBALS._uiElements.show(); + break; + + case GType_Ringworld2: + cursor = g_globals->_events.getCursor(); + g_globals->_events.setCursor(cursor); + + /* + if (R2_GLOBALS._uiElements._active) + R2_GLOBALS._uiElements.show(); + */ + break; + + default: + // Ringworld g_globals->_events.setCursor(CURSOR_WALK); switch (g_globals->_events.getCursor()) { @@ -2921,12 +2962,7 @@ void Player::enableControl() { g_globals->_events.setCursor(CURSOR_WALK); break; } - } else { - CursorType cursor = g_globals->_events.getCursor(); - g_globals->_events.setCursor(cursor); - - if (BF_GLOBALS._uiElements._active) - BF_GLOBALS._uiElements.show(); + break; } } diff --git a/engines/tsage/core.h b/engines/tsage/core.h index 95eeba7526..0137134583 100644 --- a/engines/tsage/core.h +++ b/engines/tsage/core.h @@ -62,6 +62,7 @@ public: public: InvObject(int sceneNumber, int rlbNum, int cursorNum, CursorType cursorId, const Common::String description); InvObject(int visage, int strip, int frame); + InvObject(int visage, int strip); bool inInventory() const { return _sceneNumber == 1; } void setCursor(); @@ -578,6 +579,7 @@ public: virtual void changeAngle(int angle); void setup(int visage, int stripFrameNum, int frameNum, int posX, int posY, int priority); + void setup(int visage, int stripFrameNum, int frameNum); }; class BackgroundSceneObject: public SceneObject { diff --git a/engines/tsage/detection_tables.h b/engines/tsage/detection_tables.h index 07ca4ac7c9..fdd7adc85d 100644 --- a/engines/tsage/detection_tables.h +++ b/engines/tsage/detection_tables.h @@ -140,6 +140,22 @@ static const tSageGameDescription gameDescriptions[] = { GType_BlueForce, GF_CD | GF_ALT_REGIONS }, + + // Return to Ringworld + { + { + "ringworld2", + "CD", + AD_ENTRY1s("r2rw.rlb", "df6c25622387007788ca36d99362c1f0", 47586928), + Common::EN_ANY, + Common::kPlatformPC, + ADGF_CD | ADGF_UNSTABLE, + Common::GUIO_NOSPEECH | Common::GUIO_NOSFX + }, + GType_Ringworld2, + GF_CD | GF_ALT_REGIONS + }, + { AD_TABLE_END_MARKER, 0, 0 } }; diff --git a/engines/tsage/events.cpp b/engines/tsage/events.cpp index 940709c8c7..97b2c8ce3b 100644 --- a/engines/tsage/events.cpp +++ b/engines/tsage/events.cpp @@ -156,7 +156,7 @@ void EventsClass::setCursor(CursorType cursorType) { // No cursor g_globals->setFlag(122); - if ((g_vm->getFeatures() & GF_DEMO) || (g_vm->getGameID() == GType_BlueForce)) { + if ((g_vm->getFeatures() & GF_DEMO) || (g_vm->getGameID() != GType_Ringworld)) { CursorMan.showMouse(false); return; } @@ -246,7 +246,7 @@ void EventsClass::setCursor(CursorType cursorType) { // For Blue Force, enable the question button when an inventory icon is selected if (g_vm->getGameID() == GType_BlueForce) - BF_GLOBALS._uiElements._question.setEnabled(questionEnabled); + T2_GLOBALS._uiElements._question.setEnabled(questionEnabled); } void EventsClass::pushCursor(CursorType cursorType) { diff --git a/engines/tsage/events.h b/engines/tsage/events.h index 7e1b745521..874020f140 100644 --- a/engines/tsage/events.h +++ b/engines/tsage/events.h @@ -82,6 +82,16 @@ enum CursorType { INV_JACKET = 63, INV_GREENS_KNIFE = 64, INV_DOG_WHISTLE = 65, INV_AMMO_BELT = 66, INV_CARAVAN_KEY = 67, BF_LAST_INVENT = 68, + // Ringworld 2 objects + R2_1 = 1, R2_2 = 2, R2_3 = 3, R2_STEPPING_DISKS = 4, R2_5 = 5, R2_6 = 6, R2_7 = 7, + R2_8 = 8, R2_9 = 9, R2_10 = 10, R2_11 = 11, R2_12 = 12, R2_13 = 13, R2_14 = 14, + R2_15 = 15, R2_16 = 16, R2_17 = 17, R2_18 = 18, R2_19 = 19, R2_20 = 20, R2_21 = 21, + R2_22 = 22, R2_23 = 23, R2_24 = 24, R2_25 = 25, R2_26 = 26, R2_27 = 27, R2_28 = 28, + R2_29 = 29, R2_30 = 30, R2_31 = 31, R2_32 = 32, R2_33 = 33, R2_34 = 34, R2_35 = 35, + R2_36 = 36, R2_37 = 37, R2_38 = 38, R2_39 = 39, R2_40 = 40, R2_41 = 41, R2_42 = 42, + R2_43 = 43, R2_44 = 44, R2_45 = 45, R2_46 = 46, R2_47 = 47, R2_48 = 48, R2_49 = 49, + R2_50 = 50, R2_51 = 51, R2_52 = 52, + // Cursors CURSOR_WALK = 0x100, CURSOR_LOOK = 0x200, CURSOR_700 = 700, CURSOR_USE = 0x400, CURSOR_TALK = 0x800, CURSOR_1000 = 0x1000, CURSOR_PRINTER = 0x4000, CURSOR_EXIT = 0x7004, CURSOR_9999 = 9999, diff --git a/engines/tsage/globals.cpp b/engines/tsage/globals.cpp index f22405d0d4..21bf542713 100644 --- a/engines/tsage/globals.cpp +++ b/engines/tsage/globals.cpp @@ -25,6 +25,7 @@ #include "tsage/blue_force/blueforce_logic.h" #include "tsage/ringworld/ringworld_demo.h" #include "tsage/ringworld/ringworld_logic.h" +#include "tsage/ringworld2/ringworld2_logic.h" namespace TsAGE { @@ -75,6 +76,14 @@ Globals::Globals() : _dialogCenter(160, 140), _gfxManagerInstance(_screenSurface _fontColors.background = 88; _fontColors.foreground = 92; _dialogCenter.y = 140; + } else if (g_vm->getGameID() == GType_Ringworld2) { + // Return to Ringworld + _gfxFontNumber = 2; + _gfxColors.background = 89; + _gfxColors.foreground = 83; + _fontColors.background = 88; + _fontColors.foreground = 92; + _dialogCenter.y = 140; } else if ((g_vm->getGameID() == GType_Ringworld) && (g_vm->getFeatures() & GF_CD)) { _gfxFontNumber = 50; _gfxColors.background = 53; @@ -124,6 +133,12 @@ Globals::Globals() : _dialogCenter(160, 140), _gfxManagerInstance(_screenSurface _inventory = new BlueForce::BlueForceInvObjectList(); _sceneHandler = new BlueForce::SceneHandlerExt(); break; + + case GType_Ringworld2: + _inventory = new Ringworld2::Ringworld2InvObjectList(); + _game = new Ringworld2::Ringworld2Game(); + _sceneHandler = new SceneHandler(); + break; } } @@ -183,7 +198,7 @@ void Globals::dispatchSounds() { namespace BlueForce { -BlueForceGlobals::BlueForceGlobals(): Globals() { +BlueForceGlobals::BlueForceGlobals(): TsAGE2Globals() { } void BlueForceGlobals::synchronize(Serializer &s) { @@ -242,9 +257,9 @@ void BlueForceGlobals::reset() { // Reset the inventory ((BlueForceInvObjectList *)_inventory)->reset(); - BF_GLOBALS._uiElements.updateInventory(); - BF_GLOBALS._uiElements._scoreValue = 0; - BF_GLOBALS._uiElements._active = false; + T2_GLOBALS._uiElements.updateInventory(); + T2_GLOBALS._uiElements._scoreValue = 0; + T2_GLOBALS._uiElements._active = false; _mapLocationId = 1; _driveFromScene = 300; diff --git a/engines/tsage/globals.h b/engines/tsage/globals.h index 6740aa8a1f..d6724aafa2 100644 --- a/engines/tsage/globals.h +++ b/engines/tsage/globals.h @@ -30,7 +30,7 @@ #include "tsage/events.h" #include "tsage/sound.h" #include "tsage/saveload.h" -#include "tsage/blue_force/blueforce_ui.h" +#include "tsage/user_interface.h" namespace TsAGE { @@ -97,10 +97,25 @@ public: void dispatchSounds(); }; +typedef bool (*SelectItemProc)(int objectNumber); + +/** + * The following class represents common globals that were introduced after the release of Ringworld. + */ +class TsAGE2Globals: public Globals { +public: + UIElements _uiElements; + SelectItemProc _onSelectItem; + + TsAGE2Globals() { _onSelectItem = NULL; } +}; + extern Globals *g_globals; -#define GLOBALS (*g_globals) +#define GLOBALS (*::TsAGE::g_globals) +#define T2_GLOBALS (*((::TsAGE::TsAGE2Globals *)g_globals)) #define BF_GLOBALS (*((::TsAGE::BlueForce::BlueForceGlobals *)g_globals)) +#define R2_GLOBALS (*((::TsAGE::Ringworld2::Ringworld2Globals *)g_globals)) // Note: Currently this can't be part of the g_globals structure, since it needs to be constructed // prior to many of the fields in Globals execute their constructors @@ -162,10 +177,9 @@ enum Flag { hookPoints }; -class BlueForceGlobals: public Globals { +class BlueForceGlobals: public TsAGE2Globals { public: ASoundExt _sound1, _sound2, _sound3; - UIElements _uiElements; StripProxy _stripProxy; int _dayNumber; int _v4CEA4; @@ -220,6 +234,15 @@ public: } // End of namespace BlueForce +namespace Ringworld2 { + +class Ringworld2Globals: public TsAGE2Globals { +public: + ASoundExt _sound1, _sound2, _sound3, _sound4; +}; + +} // End of namespace Ringworld2 + } // End of namespace TsAGE #endif diff --git a/engines/tsage/module.mk b/engines/tsage/module.mk index 50b269941e..7b32636da1 100644 --- a/engines/tsage/module.mk +++ b/engines/tsage/module.mk @@ -14,7 +14,6 @@ MODULE_OBJS := \ blue_force/blueforce_scenes8.o \ blue_force/blueforce_scenes9.o \ blue_force/blueforce_speakers.o \ - blue_force/blueforce_ui.o \ converse.o \ core.o \ debugger.o \ @@ -36,11 +35,14 @@ MODULE_OBJS := \ ringworld/ringworld_scenes8.o \ ringworld/ringworld_scenes10.o \ ringworld/ringworld_speakers.o \ + ringworld2/ringworld2_logic.o \ + ringworld2/ringworld2_scenes0.o \ saveload.o \ scenes.o \ sound.o \ staticres.o \ - tsage.o + tsage.o \ + user_interface.o # This module can be built as a plugin ifeq ($(ENABLE_TSAGE), DYNAMIC_PLUGIN) diff --git a/engines/tsage/resources.cpp b/engines/tsage/resources.cpp index e83801d748..652ab32350 100644 --- a/engines/tsage/resources.cpp +++ b/engines/tsage/resources.cpp @@ -354,6 +354,8 @@ void TLib::loadIndex() { se.resNum = resNum; se.resType = (ResourceType)(configId & 0x1f); se.fileOffset = (((configId >> 5) & 0x7ff) << 16) | fileOffset; + if (g_vm->getGameID() == GType_Ringworld2) + se.fileOffset <<= 4; _sections.push_back(se); } diff --git a/engines/tsage/resources.h b/engines/tsage/resources.h index 176d60fcc4..8f90b21908 100644 --- a/engines/tsage/resources.h +++ b/engines/tsage/resources.h @@ -42,7 +42,10 @@ const int MEMORY_POOL_SIZE = 1000; enum ResourceType { RES_LIBRARY, RES_STRIP, RES_IMAGE, RES_PALETTE, RES_VISAGE, RES_SOUND, RES_MESSAGE, RES_FONT, RES_POINTER, RES_BANK, RES_SND_DRIVER, RES_PRIORITY, RES_CONTROL, RES_WALKRGNS, - RES_BITMAP, RES_SAVE, RES_SEQUENCE }; + RES_BITMAP, RES_SAVE, RES_SEQUENCE, + // Return to Ringworld specific resource types + RT17, RT18, RT19, RT20, RT21, RT22, RT23, RT24, RT25, RT26, RT27, RT28, RT29, RT30, RT31 +}; class MemoryHeader { public: diff --git a/engines/tsage/ringworld2/ringworld2_logic.cpp b/engines/tsage/ringworld2/ringworld2_logic.cpp new file mode 100644 index 0000000000..e2583a5f1f --- /dev/null +++ b/engines/tsage/ringworld2/ringworld2_logic.cpp @@ -0,0 +1,757 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/config-manager.h" +#include "tsage/scenes.h" +#include "tsage/tsage.h" +#include "tsage/staticres.h" +#include "tsage/ringworld2/ringworld2_logic.h" +#include "tsage/ringworld2/ringworld2_scenes0.h" + +namespace TsAGE { + +namespace Ringworld2 { + +Scene *Ringworld2Game::createScene(int sceneNumber) { + switch (sceneNumber) { + /* Scene group #0 */ + // Quinn's room + case 100: return new Scene100(); + + default: + error("Unknown scene number - %d", sceneNumber); + break; + } +} + +/** + * Returns true if it is currently okay to restore a game + */ +bool Ringworld2Game::canLoadGameStateCurrently() { + return true; +} + +/** + * Returns true if it is currently okay to save the game + */ +bool Ringworld2Game::canSaveGameStateCurrently() { + return true; +} + +/*--------------------------------------------------------------------------*/ + +SceneExt::SceneExt(): Scene() { + _stripManager._onBegin = SceneExt::startStrip; + _stripManager._onEnd = SceneExt::endStrip; + + _field372 = _field37A = 0; + _savedPlayerEnabled = false; + _savedUiEnabled = false; + _savedCanWalk = false; + _focusObject = NULL; +} + +void SceneExt::postInit(SceneObjectList *OwnerList) { + Scene::postInit(OwnerList); +} + +void SceneExt::remove() { +/* + R2_GLOBALS._uiElements.hide(); + R2_GLOBALS._uiElements.resetClear(); + + if (_action) { + if (_action->_endHandler) + _action->_endHandler = NULL; + _action->remove(); + } + + _focusObject = NULL; +*/ +} + +void SceneExt::process(Event &event) { + if (!event.handled) + Scene::process(event); +} + +void SceneExt::dispatch() { +/* + _timerList.dispatch(); + + if (_field37A) { + if ((--_field37A == 0) && R2_GLOBALS._dayNumber) { + if (R2_GLOBALS._uiElements._active && R2_GLOBALS._player._enabled) { + R2_GLOBALS._uiElements.show(); + } + + _field37A = 0; + } + } +*/ + Scene::dispatch(); +} + +void SceneExt::loadScene(int sceneNum) { + Scene::loadScene(sceneNum); + + _v51C34.top = 0; + _v51C34.bottom = 300; +} + +bool SceneExt::display(CursorType action) { + switch (action) { + case CURSOR_LOOK: + SceneItem::display2(9000, R2_GLOBALS._randomSource.getRandomNumber(2)); + break; + case CURSOR_USE: + SceneItem::display2(9000, R2_GLOBALS._randomSource.getRandomNumber(2) + 6); + break; + case CURSOR_TALK: + SceneItem::display2(9000, R2_GLOBALS._randomSource.getRandomNumber(2) + 3); + break; + default: + return false; + } + + return true; +} + +void SceneExt::fadeOut() { + uint32 black = 0; + R2_GLOBALS._scenePalette.fade((const byte *)&black, false, 100); +} + +void SceneExt::startStrip() { + SceneExt *scene = (SceneExt *)R2_GLOBALS._sceneManager._scene; + scene->_field372 = 1; + scene->_savedPlayerEnabled = R2_GLOBALS._player._enabled; + + if (scene->_savedPlayerEnabled) { + scene->_savedUiEnabled = R2_GLOBALS._player._uiEnabled; + scene->_savedCanWalk = R2_GLOBALS._player._canWalk; + R2_GLOBALS._player.disableControl(); +/* + if (!R2_GLOBALS._v50696 && R2_GLOBALS._uiElements._active) + R2_GLOBALS._uiElements.hide(); +*/ + } +} + +void SceneExt::endStrip() { + SceneExt *scene = (SceneExt *)R2_GLOBALS._sceneManager._scene; + scene->_field372 = 0; + + if (scene->_savedPlayerEnabled) { + R2_GLOBALS._player.enableControl(); + R2_GLOBALS._player._uiEnabled = scene->_savedUiEnabled; + R2_GLOBALS._player._canWalk = scene->_savedCanWalk; +/* + if (!R2_GLOBALS._v50696 && R2_GLOBALS._uiElements._active) + R2_GLOBALS._uiElements.show(); +*/ + } +} + +void SceneExt::clearScreen() { + R2_GLOBALS._screenSurface.fillRect(R2_GLOBALS._screenSurface.getBounds(), 0); +} + +void SceneExt::refreshBackground(int xAmount, int yAmount) { + switch (_activeScreenNumber) { + case 700: + case 1020: + case 1100: + case 1700: + case 2600: + case 2950: + case 3100: + case 3101: + case 3275: + case 3600: + // Use traditional style sectioned screen loading + Scene::refreshBackground(xAmount, yAmount); + return; + default: + // Break out to new style screen loading + break; + } + + /* New style background loading */ + + // Get the screen data + byte *dataP = g_resourceManager->getResource(RT18, _activeScreenNumber, 0); + int screenSize = g_vm->_memoryManager.getSize(dataP); + + // Lock the background for update + Graphics::Surface s = _backSurface.lockSurface(); + assert(screenSize == (s.w * s.h)); + + // Copy the data + byte *destP = (byte *)s.getBasePtr(0, 0); + Common::copy(dataP, dataP + (s.w * s.h), destP); + _backSurface.unlockSurface(); + + // Free the resource data + DEALLOCATE(dataP); +} + +/*--------------------------------------------------------------------------*/ + +DisplayHotspot::DisplayHotspot(int regionId, ...) { + _sceneRegionId = regionId; + + // Load up the actions + va_list va; + va_start(va, regionId); + + int param = va_arg(va, int); + while (param != LIST_END) { + _actions.push_back(param); + param = va_arg(va, int); + } + + va_end(va); +} + +bool DisplayHotspot::performAction(int action) { + for (uint i = 0; i < _actions.size(); i += 3) { + if (_actions[i] == action) { + display(_actions[i + 1], _actions[i + 2], SET_WIDTH, 200, SET_EXT_BGCOLOR, 7, LIST_END); + return true; + } + } + + return false; +} + +/*--------------------------------------------------------------------------*/ + +DisplayObject::DisplayObject(int firstAction, ...) { + // Load up the actions + va_list va; + va_start(va, firstAction); + + int param = firstAction; + while (param != LIST_END) { + _actions.push_back(param); + param = va_arg(va, int); + } + + va_end(va); +} + +bool DisplayObject::performAction(int action) { + for (uint i = 0; i < _actions.size(); i += 3) { + if (_actions[i] == action) { + display(_actions[i + 1], _actions[i + 2], SET_WIDTH, 200, SET_EXT_BGCOLOR, 7, LIST_END); + return true; + } + } + + return false; +} + +/*--------------------------------------------------------------------------*/ + +Ringworld2InvObjectList::Ringworld2InvObjectList(): + _inv1(1, 2), + _inv2(1, 3), + _inv3(1, 4), + _steppingDisks(1, 5), + _inv5(1, 6), + _inv6(1, 7), + _inv7(1, 8), + _inv8(1, 9), + _inv9(1, 10), + _inv10(1, 11), + _inv11(1, 12), + _inv12(1, 13), + _inv13(1, 14), + _inv14(1, 15), + _inv15(1, 16), + _inv16(1, 17), + _inv17(2, 2), + _inv18(2, 3), + _inv19(2, 4), + _inv20(2, 5), + _inv21(2, 5), + _inv22(2, 6), + _inv23(2, 7), + _inv24(2, 8), + _inv25(2, 9), + _inv26(2, 10), + _inv27(2, 11), + _inv28(2, 12), + _inv29(2, 13), + _inv30(2, 14), + _inv31(2, 15), + _inv32(2, 16), + _inv33(3, 2), + _inv34(3, 3), + _inv35(3, 4), + _inv36(3, 5), + _inv37(3, 6), + _inv38(3, 7), + _inv39(1, 10), + _inv40(3, 8), + _inv41(3, 9), + _inv42(3, 10), + _inv43(3, 11), + _inv44(3, 12), + _inv45(3, 13), + _inv46(3, 17), + _inv47(3, 14), + _inv48(3, 14), + _inv49(3, 15), + _inv50(3, 15), + _inv51(3, 17), + _inv52(4, 2) { + + // Add the items to the list + _itemList.push_back(&_inv1); + _itemList.push_back(&_inv2); + _itemList.push_back(&_inv3); + _itemList.push_back(&_steppingDisks); + _itemList.push_back(&_inv5); + _itemList.push_back(&_inv6); + _itemList.push_back(&_inv7); + _itemList.push_back(&_inv8); + _itemList.push_back(&_inv9); + _itemList.push_back(&_inv10); + _itemList.push_back(&_inv11); + _itemList.push_back(&_inv12); + _itemList.push_back(&_inv13); + _itemList.push_back(&_inv14); + _itemList.push_back(&_inv15); + _itemList.push_back(&_inv16); + _itemList.push_back(&_inv17); + _itemList.push_back(&_inv18); + _itemList.push_back(&_inv19); + _itemList.push_back(&_inv20); + _itemList.push_back(&_inv21); + _itemList.push_back(&_inv22); + _itemList.push_back(&_inv23); + _itemList.push_back(&_inv24); + _itemList.push_back(&_inv25); + _itemList.push_back(&_inv26); + _itemList.push_back(&_inv27); + _itemList.push_back(&_inv28); + _itemList.push_back(&_inv29); + _itemList.push_back(&_inv30); + _itemList.push_back(&_inv31); + _itemList.push_back(&_inv32); + _itemList.push_back(&_inv33); + _itemList.push_back(&_inv34); + _itemList.push_back(&_inv35); + _itemList.push_back(&_inv36); + _itemList.push_back(&_inv37); + _itemList.push_back(&_inv38); + _itemList.push_back(&_inv39); + _itemList.push_back(&_inv40); + _itemList.push_back(&_inv41); + _itemList.push_back(&_inv42); + _itemList.push_back(&_inv43); + _itemList.push_back(&_inv44); + _itemList.push_back(&_inv45); + _itemList.push_back(&_inv46); + _itemList.push_back(&_inv47); + _itemList.push_back(&_inv48); + _itemList.push_back(&_inv49); + _itemList.push_back(&_inv50); + _itemList.push_back(&_inv51); + _itemList.push_back(&_inv52); + + _selectedItem = NULL; +} + +void Ringworld2InvObjectList::reset() { + // Reset all object scene numbers + SynchronizedList::iterator i; + for (i = _itemList.begin(); i != _itemList.end(); ++i) { + (*i)->_sceneNumber = 0; + } + + // Set up default inventory + setObjectScene(R2_1, 800); + setObjectScene(R2_2, 400); + setObjectScene(R2_3, 100); + setObjectScene(R2_STEPPING_DISKS, 100); + setObjectScene(R2_5, 400); + setObjectScene(R2_6, 400); + setObjectScene(R2_7, 500); + setObjectScene(R2_8, 700); + setObjectScene(R2_9, 800); + setObjectScene(R2_10, 100); + setObjectScene(R2_11, 400); + setObjectScene(R2_12, 500); + setObjectScene(R2_13, 1550); + setObjectScene(R2_14, 850); + setObjectScene(R2_15, 850); + setObjectScene(R2_16, 0); + setObjectScene(R2_17, 1550); + setObjectScene(R2_18, 1550); + setObjectScene(R2_19, 1550); + setObjectScene(R2_20, 500); + setObjectScene(R2_21, 500); + setObjectScene(R2_22, 1550); + setObjectScene(R2_23, 1580); + setObjectScene(R2_24, 9999); + setObjectScene(R2_25, 1550); + setObjectScene(R2_26, 1550); + setObjectScene(R2_27, 1580); + setObjectScene(R2_28, 1550); + setObjectScene(R2_29, 2525); + setObjectScene(R2_30, 2440); + setObjectScene(R2_31, 2455); + setObjectScene(R2_32, 2535); + setObjectScene(R2_33, 2530); + setObjectScene(R2_34, 1950); + setObjectScene(R2_35, 1950); + setObjectScene(R2_36, 9999); + setObjectScene(R2_37, 2430); + setObjectScene(R2_38, 9999); + setObjectScene(R2_39, 2); + setObjectScene(R2_40, 9999); + setObjectScene(R2_41, 3150); + setObjectScene(R2_42, 0); + setObjectScene(R2_43, 3260); + setObjectScene(R2_44, 2); + setObjectScene(R2_45, 1550); + setObjectScene(R2_46, 0); + setObjectScene(R2_47, 3150); + setObjectScene(R2_48, 2435); + setObjectScene(R2_49, 2440); + setObjectScene(R2_50, 2435); + setObjectScene(R2_51, 1580); + setObjectScene(R2_52, 3260); +} + +void Ringworld2InvObjectList::setObjectScene(int objectNum, int sceneNumber) { + // Find the appropriate object + int num = objectNum; + SynchronizedList::iterator i = _itemList.begin(); + while (num-- > 0) ++i; + (*i)->_sceneNumber = sceneNumber; + + // If the item is the currently active one, default back to the use cursor + if (R2_GLOBALS._events.getCursor() == objectNum) + R2_GLOBALS._events.setCursor(CURSOR_USE); + + // Update the user interface if necessary + T2_GLOBALS._uiElements.updateInventory(); +} + +/*--------------------------------------------------------------------------*/ + +void Ringworld2Game::start() { + int slot = -1; + + if (ConfMan.hasKey("save_slot")) { + slot = ConfMan.getInt("save_slot"); + Common::String file = g_vm->generateSaveName(slot); + Common::InSaveFile *in = g_vm->_system->getSavefileManager()->openForLoading(file); + if (in) + delete in; + else + slot = -1; + } + + if (slot >= 0) + g_globals->_sceneHandler->_loadGameSlot = slot; + else { + // Switch to the first game scene + g_globals->_events.setCursor(CURSOR_WALK); + g_globals->_sceneManager.setNewScene(100); + } + + g_globals->_events.showCursor(); +} + +void Ringworld2Game::restart() { + g_globals->_scenePalette.clearListeners(); + g_globals->_soundHandler.stop(); + + // Change to the first game scene + g_globals->_sceneManager.changeScene(100); +} + +void Ringworld2Game::endGame(int resNum, int lineNum) { + g_globals->_events.setCursor(CURSOR_WALK); + Common::String msg = g_resourceManager->getMessage(resNum, lineNum); + bool savesExist = g_saver->savegamesExist(); + + if (!savesExist) { + // No savegames exist, so prompt the user to restart or quit + if (MessageDialog::show(msg, QUIT_BTN_STRING, RESTART_BTN_STRING) == 0) + g_vm->quitGame(); + else + restart(); + } else { + // Savegames exist, so prompt for Restore/Restart + bool breakFlag; + do { + if (g_vm->shouldQuit()) { + breakFlag = true; + } else if (MessageDialog::show(msg, RESTART_BTN_STRING, RESTORE_BTN_STRING) == 0) { + restart(); + breakFlag = true; + } else { + handleSaveLoad(false, g_globals->_sceneHandler->_loadGameSlot, g_globals->_sceneHandler->_saveName); + breakFlag = g_globals->_sceneHandler->_loadGameSlot >= 0; + } + } while (!breakFlag); + } + + g_globals->_events.setCursorFromFlag(); +} + +void Ringworld2Game::processEvent(Event &event) { + if (event.eventType == EVENT_KEYPRESS) { + switch (event.kbd.keycode) { + case Common::KEYCODE_F1: + // F1 - Help +// MessageDialog::show(HELP_MSG, OK_BTN_STRING); + break; + + case Common::KEYCODE_F2: + // F2 - Sound Options + SoundDialog::execute(); + break; + + case Common::KEYCODE_F3: + // F3 - Quit + quitGame(); + event.handled = false; + break; + + case Common::KEYCODE_F4: + // F4 - Restart + restartGame(); + g_globals->_events.setCursorFromFlag(); + break; + + case Common::KEYCODE_F7: + // F7 - Restore + restoreGame(); + g_globals->_events.setCursorFromFlag(); + break; + + case Common::KEYCODE_F10: + // F10 - Pause + GfxDialog::setPalette(); + MessageDialog::show(GAME_PAUSED_MSG, OK_BTN_STRING); + g_globals->_events.setCursorFromFlag(); + break; + + default: + break; + } + } +} + +void Ringworld2Game::rightClick() { +/* + RightClickDialog *dlg = new RightClickDialog(); + dlg->execute(); + delete dlg; +*/ +} + +/*--------------------------------------------------------------------------*/ + +NamedHotspot::NamedHotspot() : SceneHotspot() { + _resNum = 0; + _lookLineNum = _useLineNum = _talkLineNum = -1; +} + +bool NamedHotspot::startAction(CursorType action, Event &event) { + switch (action) { + case CURSOR_WALK: + // Nothing + return false; + case CURSOR_LOOK: + if (_lookLineNum == -1) + return SceneHotspot::startAction(action, event); + + SceneItem::display2(_resNum, _lookLineNum); + return true; + case CURSOR_USE: + if (_useLineNum == -1) + return SceneHotspot::startAction(action, event); + + SceneItem::display2(_resNum, _useLineNum); + return true; + case CURSOR_TALK: + if (_talkLineNum == -1) + return SceneHotspot::startAction(action, event); + + SceneItem::display2(_resNum, _talkLineNum); + return true; + default: + return SceneHotspot::startAction(action, event); + } +} + +void NamedHotspot::setDetails(int ys, int xs, int ye, int xe, const int resnum, const int lookLineNum, const int useLineNum) { + setBounds(ys, xe, ye, xs); + _resNum = resnum; + _lookLineNum = lookLineNum; + _useLineNum = useLineNum; + _talkLineNum = -1; + g_globals->_sceneItems.addItems(this, NULL); +} + +void NamedHotspot::setDetails(const Rect &bounds, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode, SceneItem *item) { + setBounds(bounds); + _resNum = resNum; + _lookLineNum = lookLineNum; + _talkLineNum = talkLineNum; + _useLineNum = useLineNum; + + switch (mode) { + case 2: + g_globals->_sceneItems.push_front(this); + break; + case 4: + g_globals->_sceneItems.addBefore(item, this); + break; + case 5: + g_globals->_sceneItems.addAfter(item, this); + break; + default: + g_globals->_sceneItems.push_back(this); + break; + } +} + +void NamedHotspot::setDetails(int sceneRegionId, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode) { + _sceneRegionId = sceneRegionId; + _resNum = resNum; + _lookLineNum = lookLineNum; + _talkLineNum = talkLineNum; + _useLineNum = useLineNum; + + // Handle adding hotspot to scene items list as necessary + switch (mode) { + case 2: + GLOBALS._sceneItems.push_front(this); + break; + case 3: + break; + default: + GLOBALS._sceneItems.push_back(this); + break; + } +} + +void NamedHotspot::synchronize(Serializer &s) { + SceneHotspot::synchronize(s); + s.syncAsSint16LE(_resNum); + s.syncAsSint16LE(_lookLineNum); + s.syncAsSint16LE(_useLineNum); + + if (g_vm->getGameID() == GType_BlueForce) + s.syncAsSint16LE(_talkLineNum); +} + +void SceneActor::postInit(SceneObjectList *OwnerList) { + _lookLineNum = _talkLineNum = _useLineNum = -1; + SceneObject::postInit(); +} + +void SceneActor::synchronize(Serializer &s) { + SceneObject::synchronize(s); + s.syncAsSint16LE(_resNum); + s.syncAsSint16LE(_lookLineNum); + s.syncAsSint16LE(_talkLineNum); + s.syncAsSint16LE(_useLineNum); + + s.syncAsSint16LE(_effect); + s.syncAsSint16LE(_shade); +} + +bool SceneActor::startAction(CursorType action, Event &event) { + bool handled = true; + + switch (action) { + case CURSOR_LOOK: + if (_lookLineNum == -1) + handled = false; + else + SceneItem::display2(_resNum, _lookLineNum); + break; + case CURSOR_USE: + if (_useLineNum == -1) + handled = false; + else + SceneItem::display2(_resNum, _useLineNum); + break; + case CURSOR_TALK: + if (_talkLineNum == -1) + handled = false; + else + SceneItem::display2(_resNum, _talkLineNum); + break; + default: + handled = false; + break; + } + + if (!handled) + handled = ((SceneExt *)R2_GLOBALS._sceneManager._scene)->display(action); + return handled; +} + +void SceneActor::setDetails(int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode, SceneItem *item) { + _resNum = resNum; + _lookLineNum = lookLineNum; + _talkLineNum = talkLineNum; + _useLineNum = useLineNum; + + switch (mode) { + case 2: + g_globals->_sceneItems.push_front(this); + break; + case 4: + g_globals->_sceneItems.addBefore(item, this); + break; + case 5: + g_globals->_sceneItems.addAfter(item, this); + break; + default: + g_globals->_sceneItems.push_back(this); + break; + } +} + +void SceneActor::setDetails(int resNum, int lookLineNum, int talkLineNum, int useLineNum) { + _resNum = resNum; + _lookLineNum = lookLineNum; + _talkLineNum = talkLineNum; + _useLineNum = useLineNum; +} + + +} // End of namespace Ringworld2 + +} // End of namespace TsAGE diff --git a/engines/tsage/ringworld2/ringworld2_logic.h b/engines/tsage/ringworld2/ringworld2_logic.h new file mode 100644 index 0000000000..3922cdb799 --- /dev/null +++ b/engines/tsage/ringworld2/ringworld2_logic.h @@ -0,0 +1,249 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TSAGE_RINGWORLD2_LOGIC_H +#define TSAGE_RINGWORLD2_LOGIC_H + +#include "common/scummsys.h" +#include "tsage/events.h" +#include "tsage/core.h" +#include "tsage/scenes.h" +#include "tsage/globals.h" + +namespace TsAGE { + +namespace Ringworld2 { + +using namespace TsAGE; + +#define R2_INVENTORY (*((::TsAGE::Ringworld2::Ringworld2InvObjectList *)g_globals->_inventory)) + +class SceneFactory { +public: + static Scene *createScene(int sceneNumber); +}; + +class SceneExt: public Scene { +private: + static void startStrip(); + static void endStrip(); +public: + int _field372; + bool _savedPlayerEnabled; + bool _savedUiEnabled; + bool _savedCanWalk; + int _field37A; + + SceneObject *_focusObject; + Visage _cursorVisage; + + Rect _v51C34; +public: + SceneExt(); + + virtual Common::String getClassName() { return "SceneExt"; } + virtual void postInit(SceneObjectList *OwnerList = NULL); + virtual void remove(); + virtual void process(Event &event); + virtual void dispatch(); + virtual void loadScene(int sceneNum); + virtual void refreshBackground(int xAmount, int yAmount); + + bool display(CursorType action); + void fadeOut(); + void clearScreen(); +}; + +class DisplayHotspot : public SceneObject { +private: + Common::Array _actions; + bool performAction(int action); +public: + DisplayHotspot(int regionId, ...); + + virtual void doAction(int action) { + if (!performAction(action)) + SceneHotspot::doAction(action); + } +}; + +class DisplayObject : public SceneObject { +private: + Common::Array _actions; + bool performAction(int action); +public: + DisplayObject(int firstAction, ...); + + virtual void doAction(int action) { + if (!performAction(action)) + SceneHotspot::doAction(action); + } +}; + +class SceneObjectExt : public SceneObject { +public: + int _state; + + virtual void synchronize(Serializer &s) { + SceneObject::synchronize(s); + s.syncAsSint16LE(_state); + } + virtual Common::String getClassName() { return "SceneObjectExt"; } +}; + +/*--------------------------------------------------------------------------*/ + +class Ringworld2InvObjectList : public InvObjectList { +public: + InvObject _inv1; + InvObject _inv2; + InvObject _inv3; + InvObject _steppingDisks; + InvObject _inv5; + InvObject _inv6; + InvObject _inv7; + InvObject _inv8; + InvObject _inv9; + InvObject _inv10; + InvObject _inv11; + InvObject _inv12; + InvObject _inv13; + InvObject _inv14; + InvObject _inv15; + InvObject _inv16; + InvObject _inv17; + InvObject _inv18; + InvObject _inv19; + InvObject _inv20; + InvObject _inv21; + InvObject _inv22; + InvObject _inv23; + InvObject _inv24; + InvObject _inv25; + InvObject _inv26; + InvObject _inv27; + InvObject _inv28; + InvObject _inv29; + InvObject _inv30; + InvObject _inv31; + InvObject _inv32; + InvObject _inv33; + InvObject _inv34; + InvObject _inv35; + InvObject _inv36; + InvObject _inv37; + InvObject _inv38; + InvObject _inv39; + InvObject _inv40; + InvObject _inv41; + InvObject _inv42; + InvObject _inv43; + InvObject _inv44; + InvObject _inv45; + InvObject _inv46; + InvObject _inv47; + InvObject _inv48; + InvObject _inv49; + InvObject _inv50; + InvObject _inv51; + InvObject _inv52; + + Ringworld2InvObjectList(); + void reset(); + void setObjectScene(int objectNum, int sceneNumber); + + virtual Common::String getClassName() { return "Ringworld2InvObjectList"; } +}; + +#define RING2_INVENTORY (*((::TsAGE::Ringworld2::Ringworld2InvObjectList *)g_globals->_inventory)) + +class Ringworld2Game: public Game { +public: + virtual void start(); + virtual void restart(); + virtual void endGame(int resNum, int lineNum); + + virtual Scene *createScene(int sceneNumber); + virtual void processEvent(Event &event); + virtual void rightClick(); + virtual bool canSaveGameStateCurrently(); + virtual bool canLoadGameStateCurrently(); +}; + +class NamedHotspot : public SceneHotspot { +public: + int _resNum, _lookLineNum, _useLineNum, _talkLineNum; + NamedHotspot(); + + virtual bool startAction(CursorType action, Event &event); + virtual Common::String getClassName() { return "NamedHotspot"; } + virtual void synchronize(Serializer &s); + virtual void setDetails(int ys, int xs, int ye, int xe, const int resnum, const int lookLineNum, const int useLineNum); + virtual void setDetails(const Rect &bounds, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode, SceneItem *item); + virtual void setDetails(int sceneRegionId, int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode = 0); +}; + +class NamedHotspotExt : public NamedHotspot { +public: + int _flag; + NamedHotspotExt() { _flag = 0; } + + virtual Common::String getClassName() { return "NamedHotspot"; } + virtual void synchronize(Serializer &s) { + NamedHotspot::synchronize(s); + s.syncAsSint16LE(_flag); + } +}; + +class SceneActor: public SceneObject { +public: + int _resNum; + int _lookLineNum, _talkLineNum, _useLineNum; + int _effect, _shade; + + virtual Common::String getClassName() { return "SceneActor"; } + virtual void synchronize(Serializer &s); + virtual void postInit(SceneObjectList *OwnerList = NULL); + virtual bool startAction(CursorType action, Event &event); + + void setDetails(int resNum, int lookLineNum, int talkLineNum, int useLineNum, int mode, SceneItem *item); + void setDetails(int resNum, int lookLineNum, int talkLineNum, int useLineNum); +}; + +class SceneActorExt: public SceneActor { +public: + int _state; + + SceneActorExt() { _state = 0; } + virtual Common::String getClassName() { return "SceneActorExt"; } + virtual void synchronize(Serializer &s) { + SceneActor::synchronize(s); + s.syncAsSint16LE(_state); + } +}; + + +} // End of namespace Ringworld2 + +} // End of namespace TsAGE + +#endif diff --git a/engines/tsage/ringworld2/ringworld2_scenes0.cpp b/engines/tsage/ringworld2/ringworld2_scenes0.cpp new file mode 100644 index 0000000000..526bf6e3c9 --- /dev/null +++ b/engines/tsage/ringworld2/ringworld2_scenes0.cpp @@ -0,0 +1,331 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "tsage/scenes.h" +#include "tsage/tsage.h" +#include "tsage/staticres.h" +#include "tsage/ringworld2/ringworld2_scenes0.h" + +namespace TsAGE { + +namespace Ringworld2 { + +/*-------------------------------------------------------------------------- + * Scene 100 - Quinn's Room + * + *--------------------------------------------------------------------------*/ + +bool Scene100::Object7::startAction(CursorType action, Event &event) { + Scene100 *scene = (Scene100 *)R2_GLOBALS._sceneManager._scene; + + switch (action) { + case CURSOR_USE: + if (_state) { + SceneItem::display2(100, 6); + } else { + R2_GLOBALS._player.disableControl(); + scene->_sceneMode = 101; + scene->setAction(&scene->_sequenceManager1, scene, 101, &R2_GLOBALS._player, this, NULL); + } + return true; + case CURSOR_TALK: + if (_state) { + SceneItem::display2(100, 26); + _state = 0; + scene->_object10.setFrame(1); + } else { + SceneItem::display2(100, 27); + _state = 1; + scene->_object10.setFrame(2); + } + return true; + default: + return SceneActor::startAction(action, event); + } +} + +bool Scene100::Object8::startAction(CursorType action, Event &event) { + Scene100 *scene = (Scene100 *)R2_GLOBALS._sceneManager._scene; + + switch (action) { + case CURSOR_USE: + R2_GLOBALS._player.disableControl(); + if (_strip == 2) { + scene->_sceneMode = 108; + scene->_object3.postInit(); + scene->_object9.postInit(); + + if (R2_INVENTORY.getObjectScene(R2_3) == 1) { + scene->_object9.setup(100, 7, 2); + } else { + scene->_object9.setup(100, 7, 1); + scene->_object9.setDetails(100, 21, 22, 23, 2, NULL); + } + + scene->setAction(&scene->_sequenceManager2, scene, 108, this, &scene->_object3, + &scene->_object9, &R2_GLOBALS._player, NULL); + } else { + scene->_sceneMode = 109; + scene->setAction(&scene->_sequenceManager2, scene, 109, this, &scene->_object3, + &scene->_object9, &R2_GLOBALS._player, NULL); + } + return true; + case CURSOR_TALK: + R2_GLOBALS._player.disableControl(); + + if (_strip == 2) { + SceneItem::display2(100, 18); + scene->_sceneMode = 102; + scene->_object3.postInit(); + scene->_object9.postInit(); + + if (R2_INVENTORY.getObjectScene(R2_3) == 1) { + scene->_object9.setup(100, 7, 2); + } else { + scene->_object9.setup(100, 7, 1); + scene->_object9.setDetails(100, 21, 22, 23, 2, NULL); + } + + scene->setAction(&scene->_sequenceManager2, scene, 102, this, &scene->_object3, + &scene->_object9, NULL); + } else { + SceneItem::display2(100, 19); + scene->_sceneMode = 103; + scene->setAction(&scene->_sequenceManager2, scene, 103, this, &scene->_object3, + &scene->_object9, NULL); + } + return true; + default: + return SceneActor::startAction(action, event); + } +} + +bool Scene100::Object9::startAction(CursorType action, Event &event) { + Scene100 *scene = (Scene100 *)R2_GLOBALS._sceneManager._scene; + + switch (action) { + case CURSOR_USE: + R2_GLOBALS._player.disableControl(); + scene->_sceneMode = 107; + scene->setAction(&scene->_sequenceManager1, scene, 107, &R2_GLOBALS._player, &scene->_object9, NULL); + return true; + default: + return SceneActor::startAction(action, event); + } +} + +bool Scene100::Object10::startAction(CursorType action, Event &event) { + Scene100 *scene = (Scene100 *)R2_GLOBALS._sceneManager._scene; + + switch (action) { + case CURSOR_LOOK: + SceneItem::display2(100, _state ? 24 : 25); + return true; + case CURSOR_TALK: + SceneItem::display2(100, _state ? 26 : 27); + return true; + case CURSOR_USE: + R2_GLOBALS._player.disableControl(); + scene->_sceneMode = 110; + scene->setAction(&scene->_sequenceManager1, scene, 110, &R2_GLOBALS._player, NULL); + return true; + default: + return SceneActor::startAction(action, event); + } +} + +bool Scene100::SteppingDisks::startAction(CursorType action, Event &event) { + Scene100 *scene = (Scene100 *)R2_GLOBALS._sceneManager._scene; + + switch (action) { + case CURSOR_USE: + R2_GLOBALS._player.disableControl(); + scene->_sceneMode = 111; + scene->setAction(&scene->_sequenceManager1, scene, 111, &R2_GLOBALS._player, this, NULL); + return true; + default: + return SceneActor::startAction(action, event); + } +} + +/*--------------------------------------------------------------------------*/ + +void Scene100::postInit(SceneObjectList *OwnerList) { + SceneExt::postInit(); + loadScene(100); + R2_GLOBALS._scenePalette.loadPalette(0); + + if (R2_GLOBALS._sceneManager._previousScene != 125) + R2_GLOBALS._sound1.play(10); + + _object7.postInit(); + _object7._state = 0; + _object7.setVisage(100); + _object7.setPosition(Common::Point(160, 84)); + _object7.setDetails(100, 3, 4, 5, 1, NULL); + + _object10.postInit(); + _object10.setup(100, 2, 1); + _object10.setDetails(100, -1, -1, -1, 1, NULL); + + _object8.postInit(); + _object8.setup(100, 2, 3); + _object8.setPosition(Common::Point(175, 157)); + _object8.setDetails(100, 17, 18, 20, 1, NULL); + + _object1.postInit(); + _object1.setup(100, 3, 1); + _object1.setPosition(Common::Point(89, 79)); + _object1.fixPriority(250); + _object1.animate(ANIM_MODE_2, NULL); + _object1._numFrames = 3; + + _object2.postInit(); + _object2.setup(100, 3, 1); + _object2.setPosition(Common::Point(89, 147)); + _object2.fixPriority(250); + _object2.animate(ANIM_MODE_7, 0, NULL); + _object2._numFrames = 3; + + _object6.postInit(); + _object6.setVisage(101); + _object6.setPosition(Common::Point(231, 126)); + _object6.fixPriority(10); + _object6.setDetails(100, 37, -1, 39, 1, NULL); + + if (R2_INVENTORY.getObjectScene(R2_STEPPING_DISKS) == 100) { + _steppingDisks.postInit(); + _steppingDisks.setup(100, 8, 1); + _steppingDisks.setPosition(Common::Point(274, 130)); + _steppingDisks.setDetails(100, 40, -1, 42, 1, NULL); + } + + _item5.setDetails(11, 100, 14, 15, 16); + _item4.setDetails(12, 100, 11, -1, 13); + _item3.setDetails(13, 100, 8, 9, 10); + _item2.setDetails(14, 100, 34, -1, 36); + + R2_GLOBALS._player.postInit(); + R2_GLOBALS._player.setVisage(10); + R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); + R2_GLOBALS._player.disableControl(); + + _item1.setDetails(Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), 100, 0, 1, -1, 1, NULL); + + switch (R2_GLOBALS._sceneManager._previousScene) { + case 50: + case 180: + _object5.postInit(); + _object4.postInit(); + _sceneMode = 104; + setAction(&_sequenceManager1, this, 104, &R2_GLOBALS._player, &_object6, &_object4, &_object5, NULL); + break; + case 125: + _sceneMode = 100; + setAction(&_sequenceManager1, this, 106, &R2_GLOBALS._player, NULL); + break; + case 200: + _sceneMode = 100; + setAction(&_sequenceManager1, this, 100, &R2_GLOBALS._player, &_object7, NULL); + break; + default: + R2_GLOBALS._player.setStrip(3); + R2_GLOBALS._player.setPosition(Common::Point(180, 100)); + R2_GLOBALS._player.enableControl(); + break; + } +} + +void Scene100::remove() { + R2_GLOBALS._sound1.play(10); + SceneExt::remove(); +} + +void Scene100::signal() { + switch (_sceneMode) { + case 101: + R2_GLOBALS._sceneManager.changeScene(200); + break; + case 103: + case 109: + _object8.setStrip(2); + _object8.setFrame(3); + + _object3.remove(); + _object9.remove(); + R2_GLOBALS._player.enableControl(); + break; + case 104: + _sceneMode = 0; + _object5.remove(); + _object4.remove(); + + R2_GLOBALS._player.animate(ANIM_MODE_1, NULL); + R2_GLOBALS._player._numFrames = 10; + R2_GLOBALS._player.fixPriority(-1); + R2_GLOBALS._player.enableControl(); + break; + case 105: + R2_GLOBALS._sceneManager.changeScene(125); + break; + case 107: + R2_GLOBALS._sceneItems.remove(&_object9); + + _object9.setFrame(2); + R2_INVENTORY.setObjectScene(3, 1); + R2_GLOBALS._player.enableControl(); + break; + case 110: + if (_object7._state) { + _object7._state = 0; + _object10.setFrame(1); + } else { + _object7._state = 1; + _object10.setFrame(2); + } + R2_GLOBALS._player.enableControl(); + break; + default: + R2_GLOBALS._player.enableControl(); + break; + } +} + +void Scene100::dispatch() { +/* + int regionIndex = R2_GLOBALS._player.getRegionIndex(); + if (regionIndex == 13) + R2_GLOBALS._player._shade = 4; + + if ((R2_GLOBALS._player._visage == 13) || (R2_GLOBALS._player._visage == 101)) + (R2_GLOBALS._player._shade = 0; +*/ + SceneExt::dispatch(); + + if ((_sceneMode == 101) && (_object7._frame == 2) && (_object8._strip == 5)) { + _object8.setAction(&_sequenceManager2, NULL, 103, &_object8, &_object3, &_object9, NULL); + } +} + +} // End of namespace Ringworld2 + +} // End of namespace TsAGE diff --git a/engines/tsage/ringworld2/ringworld2_scenes0.h b/engines/tsage/ringworld2/ringworld2_scenes0.h new file mode 100644 index 0000000000..c51b044137 --- /dev/null +++ b/engines/tsage/ringworld2/ringworld2_scenes0.h @@ -0,0 +1,84 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TSAGE_RINGWORLD2_SCENES0_H +#define TSAGE_RINGWORLD2_SCENES0_H + +#include "common/scummsys.h" +#include "tsage/converse.h" +#include "tsage/events.h" +#include "tsage/core.h" +#include "tsage/scenes.h" +#include "tsage/globals.h" +#include "tsage/sound.h" +#include "tsage/ringworld2/ringworld2_logic.h" + +namespace TsAGE { + +namespace Ringworld2 { + +using namespace TsAGE; + +class Scene100: public SceneExt { + /* Objects */ + class Object7: public SceneActorExt { + public: + bool startAction(CursorType action, Event &event); + }; + class Object8: public SceneActor { + public: + bool startAction(CursorType action, Event &event); + }; + class Object9: public SceneActor { + public: + bool startAction(CursorType action, Event &event); + }; + class Object10: public SceneActorExt { + public: + bool startAction(CursorType action, Event &event); + }; + class SteppingDisks: public SceneActor { + public: + bool startAction(CursorType action, Event &event); + }; +public: + NamedHotspot _item1, _item2, _item3, _item4, _item5; + SceneActor _object1, _object2, _object3, _object4, _object5; + SceneActor _object6; + Object7 _object7; + Object8 _object8; + Object9 _object9; + Object10 _object10; + SteppingDisks _steppingDisks; + SequenceManager _sequenceManager1, _sequenceManager2; + + virtual void postInit(SceneObjectList *OwnerList = NULL); + virtual void remove(); + virtual void signal(); + virtual void dispatch(); +}; + +} // End of namespace Ringworld2 + +} // End of namespace TsAGE + +#endif diff --git a/engines/tsage/scenes.cpp b/engines/tsage/scenes.cpp index baa114218e..686b8725f5 100644 --- a/engines/tsage/scenes.cpp +++ b/engines/tsage/scenes.cpp @@ -316,11 +316,39 @@ void Scene::loadScene(int sceneNum) { void Scene::loadSceneData(int sceneNum) { _activeScreenNumber = sceneNum; - // Get the basic scene size - byte *data = g_resourceManager->getResource(RES_BITMAP, sceneNum, 9999); - _backgroundBounds = Rect(0, 0, READ_LE_UINT16(data), READ_LE_UINT16(data + 2)); + if (g_vm->getGameID() == GType_Ringworld2) { + // Most scenes in Ringworld 2 don't have a scene size resource, but rather just have + // a standard 320x200 size. Only read the scene size data for the specific few scenes + switch (sceneNum) { + case 700: + case 1020: + case 1100: + case 1700: + case 2600: + case 2950: + case 3100: + case 3101: + case 3275: + case 3600: { + // Get the basic scene size from the resource + byte *data = g_resourceManager->getResource(RES_BITMAP, sceneNum, 9999); + _backgroundBounds = Rect(0, 0, READ_LE_UINT16(data), READ_LE_UINT16(data + 2)); + DEALLOCATE(data); + break; + } + default: + // For all other scenes, use a standard screen size + _backgroundBounds = Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + break; + } + } else { + // Get the basic scene size + byte *data = g_resourceManager->getResource(RES_BITMAP, sceneNum, 9999); + _backgroundBounds = Rect(0, 0, READ_LE_UINT16(data), READ_LE_UINT16(data + 2)); + DEALLOCATE(data); + } + g_globals->_sceneManager._scene->_sceneBounds.contain(_backgroundBounds); - DEALLOCATE(data); // Set up a surface for storing the scene background SceneManager::setBackSurface(); diff --git a/engines/tsage/scenes.h b/engines/tsage/scenes.h index 202648a1a8..2daa71ba98 100644 --- a/engines/tsage/scenes.h +++ b/engines/tsage/scenes.h @@ -63,10 +63,11 @@ public: virtual void process(Event &event); virtual void dispatch(); virtual void loadScene(int sceneNum); + virtual void refreshBackground(int xAmount, int yAmount); void setZoomPercents(int yStart, int minPercent, int yEnd, int maxPercent); void loadBackground(int xAmount, int yAmount); - void refreshBackground(int xAmount, int yAmount); + void loadSceneData(int sceneNum); }; diff --git a/engines/tsage/tsage.cpp b/engines/tsage/tsage.cpp index 5b0e0b66ee..dbbdac3b1f 100644 --- a/engines/tsage/tsage.cpp +++ b/engines/tsage/tsage.cpp @@ -84,10 +84,13 @@ void TSageEngine::initialize() { g_globals = new BlueForce::BlueForceGlobals(); // Setup the user interface - BF_GLOBALS._uiElements.setup(Common::Point(0, BF_INTERFACE_Y - 2)); + T2_GLOBALS._uiElements.setup(Common::Point(0, BF_INTERFACE_Y - 2)); // Reset all global variables BF_GLOBALS.reset(); + } else if (g_vm->getGameID() == GType_Ringworld2) { + g_resourceManager->addLib("R2RW.RLB"); + g_globals = new Ringworld2::Ringworld2Globals(); } g_globals->gfxManager().setDefaults(); diff --git a/engines/tsage/tsage.h b/engines/tsage/tsage.h index a4e9240aee..511f87fb2f 100644 --- a/engines/tsage/tsage.h +++ b/engines/tsage/tsage.h @@ -40,7 +40,8 @@ namespace TsAGE { enum { GType_Ringworld = 0, - GType_BlueForce = 1 + GType_BlueForce = 1, + GType_Ringworld2 = 2 }; enum { diff --git a/engines/tsage/user_interface.cpp b/engines/tsage/user_interface.cpp new file mode 100644 index 0000000000..a1b998748f --- /dev/null +++ b/engines/tsage/user_interface.cpp @@ -0,0 +1,510 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "tsage/user_interface.h" +#include "tsage/core.h" +#include "tsage/tsage.h" +#include "tsage/blue_force/blueforce_dialogs.h" +#include "tsage/blue_force/blueforce_logic.h" + +namespace TsAGE { + +void StripProxy::process(Event &event) { + if (_action) + _action->process(event); +} + +/*--------------------------------------------------------------------------*/ + +void UIElement::synchronize(Serializer &s) { + BackgroundSceneObject::synchronize(s); + s.syncAsSint16LE(_field88); + s.syncAsSint16LE(_enabled); + s.syncAsSint16LE(_frameNum); +} + +void UIElement::setup(int visage, int stripNum, int frameNum, int posX, int posY, int priority) { + _field88 = 0; + _frameNum = frameNum; + _enabled = true; + + SceneObject::setup(visage, stripNum, frameNum, posX, posY, priority); +} + +void UIElement::setEnabled(bool flag) { + if (_enabled != flag) { + _enabled = flag; + setFrame(_enabled ? _frameNum : _frameNum + 2); + } +} + +/*--------------------------------------------------------------------------*/ + +void UIQuestion::process(Event &event) { + if (event.eventType == EVENT_BUTTON_DOWN) { + CursorType currentCursor = GLOBALS._events.getCursor(); + GLOBALS._events.hideCursor(); + showDescription(currentCursor); + + event.handled = true; + } +} + +void UIQuestion::showDescription(CursorType cursor) { + if (cursor == INV_FOREST_RAP) { + // Forest rap item has a graphical display + showItem(5, 1, 1); + } else { + // Display object description + SceneItem::display2(9001, (int)cursor); + } +} + +void UIQuestion::setEnabled(bool flag) { + if (_enabled != flag) { + UIElement::setEnabled(flag); + T2_GLOBALS._uiElements.draw(); + } +} + +void UIQuestion::showItem(int resNum, int rlbNum, int frameNum) { + GfxDialog::setPalette(); + + // Get the item to display + GfxSurface objImage = surfaceFromRes(resNum, rlbNum, frameNum); + Rect imgRect; + imgRect.resize(objImage, 0, 0, 100); + imgRect.center(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2); + + // Save the area behind where the image will be displayed + GfxSurface *savedArea = Surface_getArea(BF_GLOBALS.gfxManager().getSurface(), imgRect); + + // Draw the image + BF_GLOBALS.gfxManager().copyFrom(objImage, imgRect); + + // Wait for a press + BF_GLOBALS._events.waitForPress(); + + // Restore the old area + BF_GLOBALS.gfxManager().copyFrom(*savedArea, imgRect); + delete savedArea; +} + +/*--------------------------------------------------------------------------*/ + +void UIScore::postInit(SceneObjectList *OwnerList) { + int xp = 266; + _digit3.setup(1, 6, 1, xp, 180, 255); + _digit3.reposition(); + xp += 7; + _digit2.setup(1, 6, 1, xp, 180, 255); + _digit2.reposition(); + xp += 7; + _digit1.setup(1, 6, 1, xp, 180, 255); + _digit1.reposition(); + xp += 7; + _digit0.setup(1, 6, 1, xp, 180, 255); + _digit0.reposition(); +} + +void UIScore::draw() { + _digit3.draw(); + _digit2.draw(); + _digit1.draw(); + _digit0.draw(); +} + +void UIScore::updateScore() { + int score = T2_GLOBALS._uiElements._scoreValue; + + _digit3.setFrame(score / 1000 + 1); score %= 1000; + _digit2.setFrame(score / 100 + 1); score %= 100; + _digit1.setFrame(score / 10 + 1); score %= 10; + _digit0.setFrame(score + 1); +} + +/*--------------------------------------------------------------------------*/ + +UIInventorySlot::UIInventorySlot(): UIElement() { + _objIndex = 0; + _object = NULL; +} + +void UIInventorySlot::synchronize(Serializer &s) { + UIElement::synchronize(s); + s.syncAsSint16LE(_objIndex); + SYNC_POINTER(_object); +} + +void UIInventorySlot::process(Event &event) { + if (event.eventType == EVENT_BUTTON_DOWN) { + event.handled = true; + + // Check if game has a select item handler, and if so, give it a chance to check + // whether something special happens when the item is selected + if (!T2_GLOBALS._onSelectItem || !T2_GLOBALS._onSelectItem((CursorType)_objIndex)) + _object->setCursor(); + } +} + +/*--------------------------------------------------------------------------*/ + +UIInventoryScroll::UIInventoryScroll() { + _isLeft = false; +} + +void UIInventoryScroll::synchronize(Serializer &s) { + UIElement::synchronize(s); + s.syncAsSint16LE(_isLeft); +} + +void UIInventoryScroll::process(Event &event) { + switch (event.eventType) { + case EVENT_BUTTON_DOWN: + // Draw the button as selected + toggle(true); + + event.handled = true; + break; + case EVENT_BUTTON_UP: + // Restore unselected version + toggle(false); + + // Scroll the inventory as necessary + T2_GLOBALS._uiElements.scrollInventory(_isLeft); + event.handled = true; + break; + default: + break; + } +} + +void UIInventoryScroll::toggle(bool pressed) { + if (_enabled) { + setFrame(pressed ? (_frameNum + 1) : _frameNum); + T2_GLOBALS._uiElements.draw(); + } +} + +/*--------------------------------------------------------------------------*/ + +UICollection::UICollection(): EventHandler() { + _clearScreen = false; + _visible = false; + _cursorChanged = false; +} + +void UICollection::setup(const Common::Point &pt) { + _position = pt; + _bounds.left = _bounds.right = pt.x; + _bounds.top = _bounds.bottom = pt.y; +} + +void UICollection::hide() { + erase(); + _visible = false; +} + +void UICollection::show() { + _visible = true; + draw(); +} + +void UICollection::erase() { + if (_clearScreen) { + Rect tempRect(0, BF_INTERFACE_Y, SCREEN_WIDTH, SCREEN_HEIGHT); + BF_GLOBALS._screenSurface.fillRect(tempRect, 0); + BF_GLOBALS._sceneManager._scene->_backSurface.fillRect(tempRect, 0); + _clearScreen = false; + } +} + +void UICollection::resetClear() { + _clearScreen = false; +} + +void UICollection::draw() { + if (_visible) { + // Temporarily reset the sceneBounds when drawing UI elements to force them on-screen + Rect savedBounds = g_globals->_sceneManager._scene->_sceneBounds; + g_globals->_sceneManager._scene->_sceneBounds = Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + + // Draw the elements onto the background + for (uint idx = 0; idx < _objList.size(); ++idx) + _objList[idx]->draw(); + + // Draw the resulting UI onto the screen + BF_GLOBALS._screenSurface.copyFrom(BF_GLOBALS._sceneManager._scene->_backSurface, + Rect(0, BF_INTERFACE_Y, SCREEN_WIDTH, SCREEN_HEIGHT), + Rect(0, BF_INTERFACE_Y, SCREEN_WIDTH, SCREEN_HEIGHT)); + + _clearScreen = 1; + g_globals->_sceneManager._scene->_sceneBounds = savedBounds; + } +} + +/*--------------------------------------------------------------------------*/ + +UIElements::UIElements(): UICollection() { + _cursorVisage.setVisage(1, 5); + g_saver->addLoadNotifier(&UIElements::loadNotifierProc); +} + +void UIElements::synchronize(Serializer &s) { + UICollection::synchronize(s); + + s.syncAsSint16LE(_slotStart); + s.syncAsSint16LE(_scoreValue); + s.syncAsByte(_active); + + int count = _itemList.size(); + s.syncAsSint16LE(count); + if (s.isLoading()) { + // Load in item list + _itemList.clear(); + + for (int idx = 0; idx < count; ++idx) { + int itemId; + s.syncAsSint16LE(itemId); + _itemList.push_back(itemId); + } + } else { + // Save item list + for (int idx = 0; idx < count; ++idx) { + int itemId = _itemList[idx]; + s.syncAsSint16LE(itemId); + } + } +} + +void UIElements::process(Event &event) { + if (_clearScreen && BF_GLOBALS._player._enabled && (BF_GLOBALS._sceneManager._sceneNumber != 50)) { + if (_bounds.contains(event.mousePos)) { + // Cursor inside UI area + if (!_cursorChanged) { + if (BF_GLOBALS._events.isInventoryIcon()) { + // Inventory icon being displayed, so leave alone + } else { + // Change to the inventory use cursor + GfxSurface surface = _cursorVisage.getFrame(6); + BF_GLOBALS._events.setCursor(surface); + } + _cursorChanged = true; + } + + // Pass event to any element that the cursor falls on + for (int idx = (int)_objList.size() - 1; idx >= 0; --idx) { + if (_objList[idx]->_bounds.contains(event.mousePos) && _objList[idx]->_enabled) { + _objList[idx]->process(event); + if (event.handled) + break; + } + } + + if (event.eventType == EVENT_BUTTON_DOWN) + event.handled = true; + + } else if (_cursorChanged) { + // Cursor outside UI area, so reset as necessary + BF_GLOBALS._events.setCursor(BF_GLOBALS._events.getCursor()); + _cursorChanged = false; +/* + SceneExt *scene = (SceneExt *)BF_GLOBALS._sceneManager._scene; + if (scene->_focusObject) { + GfxSurface surface = _cursorVisage.getFrame(7); + BF_GLOBALS._events.setCursor(surface); + } +*/ + } + } +} + +void UIElements::setup(const Common::Point &pt) { + _slotStart = 0; + _itemList.clear(); + _scoreValue = 0; + _active = true; + UICollection::setup(pt); + hide(); + + _object1.setup(1, 3, 1, 0, 0, 255); + add(&_object1); + + // Set up the inventory slots + int xp = 0; + for (int idx = 0; idx < 4; ++idx) { + UIElement *item = NULL; + switch (idx) { + case 0: + item = &_slot1; + break; + case 1: + item = &_slot2; + break; + case 2: + item = &_slot3; + break; + case 3: + item = &_slot4; + break; + } + + xp = idx * 63 + 2; + item->setup(9, 1, idx, xp, 4, 255); + add(item); + } + + // Setup bottom-right hand buttons + xp += 62; + _question.setup(1, 4, 7, xp, 16, 255); + _question.setEnabled(false); + add(&_question); + + xp += 21; + _scrollLeft.setup(1, 4, 1, xp, 16, 255); + add(&_scrollLeft); + _scrollLeft._isLeft = true; + + xp += 22; + _scrollRight.setup(1, 4, 4, xp, 16, 255); + add(&_scrollRight); + _scrollRight._isLeft = false; + + // Set up the score + _score.postInit(); + add(&_score); + + // Set interface area + _bounds = Rect(0, BF_INTERFACE_Y - 1, SCREEN_WIDTH, SCREEN_HEIGHT); + + updateInventory(); +} + +void UIElements::add(UIElement *obj) { + // Add object + assert(_objList.size() < 12); + _objList.push_back(obj); + + obj->setPosition(Common::Point(_bounds.left + obj->_position.x, _bounds.top + obj->_position.y)); + obj->reposition(); + + GfxSurface s = obj->getFrame(); + s.draw(obj->_position); +} + +/** + * Handles updating the visual inventory in the user interface + */ +void UIElements::updateInventory() { + _score.updateScore(); + updateInvList(); + + // Enable scroll buttons if the player has more than four items + if (_itemList.size() > 4) { + _scrollLeft.setEnabled(true); + _scrollRight.setEnabled(true); + } else { + _scrollLeft.setEnabled(false); + _scrollRight.setEnabled(false); + } + + // Handle cropping the slots start within inventory + int lastPage = (_itemList.size() - 1) / 4 + 1; + if (_slotStart < 0) + _slotStart = lastPage - 1; + else if (_slotStart > (lastPage - 1)) + _slotStart = 0; + + // Handle refreshing slot graphics + UIInventorySlot *slotList[4] = { &_slot1, &_slot2, &_slot3, &_slot4 }; + + // Loop through the inventory objects + SynchronizedList::iterator i; + int objIndex = 0; + for (i = BF_INVENTORY._itemList.begin(); i != BF_INVENTORY._itemList.end(); ++i, ++objIndex) { + InvObject *obj = *i; + + // Check whether the object is in any of the four inventory slots + for (int slotIndex = 0; slotIndex < 4; ++slotIndex) { + int idx = _slotStart * 4 + slotIndex; + int objectIdx = (idx < (int)_itemList.size()) ? _itemList[idx] : 0; + + if (objectIdx == objIndex) { + UIInventorySlot *slot = slotList[slotIndex]; + + slot->_objIndex = objIndex; + slot->_object = obj; + slot->setVisage(obj->_visage); + slot->setStrip(obj->_strip); + slot->setFrame(obj->_frame); + } + } + } + + // Refresh the display if necessary + if (_active) + draw(); +} + +/** + * Update the list of the indexes of items in the player's inventory + */ +void UIElements::updateInvList() { + // Update the index list of items in the player's inventory + _itemList.clear(); + + SynchronizedList::iterator i; + int itemIndex = 0; + for (i = BF_GLOBALS._inventory->_itemList.begin(); i != BF_GLOBALS._inventory->_itemList.end(); ++i, ++itemIndex) { + InvObject *invObject = *i; + if (invObject->inInventory()) + _itemList.push_back(itemIndex); + } +} + +/** + * Set the game score + */ +void UIElements::addScore(int amount) { + _scoreValue += amount; + BF_GLOBALS._sound2.play(0); + updateInventory(); +} + +/* + * Scroll the inventory slots + */ +void UIElements::scrollInventory(bool isLeft) { + if (isLeft) + --_slotStart; + else + ++_slotStart; + + updateInventory(); +} + +void UIElements::loadNotifierProc(bool postFlag) { + if (postFlag && T2_GLOBALS._uiElements._active) + T2_GLOBALS._uiElements.show(); +} + +} // End of namespace TsAGE diff --git a/engines/tsage/user_interface.h b/engines/tsage/user_interface.h new file mode 100644 index 0000000000..eb38bcb740 --- /dev/null +++ b/engines/tsage/user_interface.h @@ -0,0 +1,148 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef TSAGE_USER_INTERFACE_H +#define TSAGE_USER_INTERFACE_H + +#include "common/scummsys.h" +#include "tsage/core.h" +#include "tsage/graphics.h" +#include "tsage/sound.h" + +namespace TsAGE { + +class StripProxy: public EventHandler { +public: + virtual void process(Event &event); +}; + +class UIElement: public BackgroundSceneObject { +public: + int _field88; + bool _enabled; + int _frameNum; + + virtual Common::String getClassName() { return "UIElement"; } + virtual void synchronize(Serializer &s); + + void setup(int visage, int stripNum, int frameNum, int posX, int posY, int priority); + void setEnabled(bool flag); +}; + +// This class implements the Question mark button +class UIQuestion: public UIElement { +private: + void showDescription(CursorType item); + void showItem(int resNum, int rlbNum, int frameNum); +public: + virtual void process(Event &event); + void setEnabled(bool flag); +}; + +// This class implements the score counter +class UIScore: public UIElement { +private: + void showDescription(int lineNum); +public: + UIElement _digit3, _digit2, _digit1, _digit0; + + virtual void postInit(SceneObjectList *OwnerList = NULL); + virtual void draw(); + + void updateScore(); +}; + +class UIInventorySlot: public UIElement { +public: + int _objIndex; + InvObject *_object; + + UIInventorySlot(); + virtual Common::String getClassName() { return "UIInventorySlot"; } + virtual void synchronize(Serializer &s); + virtual void process(Event &event); +}; + +class UIInventoryScroll: public UIElement { +private: + void toggle(bool pressed); +public: + bool _isLeft; + + UIInventoryScroll(); + virtual Common::String getClassName() { return "UIInventoryScroll"; } + virtual void synchronize(Serializer &s); + virtual void process(Event &event); +}; + +class UICollection: public EventHandler { +protected: + void erase(); +public: + Common::Point _position; + Rect _bounds; + bool _visible; + bool _clearScreen; + bool _cursorChanged; + Common::Array _objList; + + UICollection(); + void setup(const Common::Point &pt); + void hide(); + void show(); + void resetClear(); + void draw(); +}; + +class UIElements: public UICollection { +private: + void add(UIElement *obj); + void updateInvList(); +public: + UIElement _object1; + UIQuestion _question; + UIScore _score; + UIInventorySlot _slot1, _slot2, _slot3, _slot4; + UIInventoryScroll _scrollLeft, _scrollRight; + ASound _sound; + int _slotStart, _scoreValue; + bool _active; + Common::Array _itemList; + Visage _cursorVisage; + + UIElements(); + virtual Common::String getClassName() { return "UIElements"; } + virtual void synchronize(Serializer &s); + virtual void postInit(SceneObjectList *OwnerList = NULL) { error("Wrong init() called"); } + virtual void process(Event &event); + + void setup(const Common::Point &pt); + void updateInventory(); + void addScore(int amount); + void scrollInventory(bool isLeft); + + static void loadNotifierProc(bool postFlag); +}; + +} // End of namespace TsAGE + +#endif -- cgit v1.2.3