diff options
author | Matthew Hoops | 2011-12-12 15:25:28 -0500 |
---|---|---|
committer | Matthew Hoops | 2011-12-12 15:25:28 -0500 |
commit | 00279659b22cbd5db739d5351e83a9fc2a2ae408 (patch) | |
tree | 497f06f46820043cbdf1725652b8f0073223e24a /engines/tsage/blue_force/blueforce_logic.cpp | |
parent | d932df79bed5aac97e17c0920a5e75cb5ce733ee (diff) | |
parent | d1628feb761acc9f4607f64de3eb620fea53bcc9 (diff) | |
download | scummvm-rg350-00279659b22cbd5db739d5351e83a9fc2a2ae408.tar.gz scummvm-rg350-00279659b22cbd5db739d5351e83a9fc2a2ae408.tar.bz2 scummvm-rg350-00279659b22cbd5db739d5351e83a9fc2a2ae408.zip |
Merge remote branch 'upstream/master' into pegasus
Conflicts:
video/qt_decoder.cpp
Diffstat (limited to 'engines/tsage/blue_force/blueforce_logic.cpp')
-rw-r--r-- | engines/tsage/blue_force/blueforce_logic.cpp | 390 |
1 files changed, 359 insertions, 31 deletions
diff --git a/engines/tsage/blue_force/blueforce_logic.cpp b/engines/tsage/blue_force/blueforce_logic.cpp index 247fc4b9f2..22299c1bf1 100644 --- a/engines/tsage/blue_force/blueforce_logic.cpp +++ b/engines/tsage/blue_force/blueforce_logic.cpp @@ -43,9 +43,7 @@ namespace BlueForce { void BlueForceGame::start() { // Start the game - g_globals->_sceneManager.changeScene(300); - - g_globals->_events.setCursor(CURSOR_WALK); + g_globals->_sceneManager.changeScene(20); } Scene *BlueForceGame::createScene(int sceneNumber) { @@ -65,17 +63,32 @@ Scene *BlueForceGame::createScene(int sceneNumber) { // Tsnunami Title Screen #2 return new Scene100(); case 109: - // Introduction Bar Room + // Introduction - Bar Room return new Scene109(); case 110: + // Introduction - Outside the bar + return new Scene110(); case 114: + // Outside Tony's Bar + return new Scene114(); case 115: + // Inside Tony's Bar + return new Scene115(); case 125: + // Intro - Chase in the city + return new Scene125(); case 140: + // Intro - Burglar near the House + return new Scene140(); case 150: + // Intro - Burglar inside the house + return new Scene150(); case 160: + // Intro - Burial + return new Scene160(); case 180: - error("Scene group 1 not implemented"); + // Front of Home + return new Scene180(); case 190: // Front of Police Station return new Scene190(); @@ -92,7 +105,7 @@ Scene *BlueForceGame::createScene(int sceneNumber) { // Credits - Gun Training return new Scene225(); case 265: - // Graduation Article + // Intro - Graduation Article return new Scene265(); case 270: // Living Room & Kitchen @@ -101,7 +114,8 @@ Scene *BlueForceGame::createScene(int sceneNumber) { // Living Room & Kitchen #2 return new Scene271(); case 280: - error("Scene group 2 not implemented"); + // Bedroom Flashback cut-scene + return new Scene280(); case 300: // Outside Police Station return new Scene300(); @@ -184,13 +198,17 @@ Scene *BlueForceGame::createScene(int sceneNumber) { // Decking return new Scene690(); case 710: + // Beach return new Scene710(); case 800: // Jamison & Ryan return new Scene800(); case 810: + // Lyle's Office + return new Scene810(); case 820: - error("Scene group 8 not implemented"); + // Microfiche Reader + return new Scene820(); case 830: // Outside Boat Rentals return new Scene830(); @@ -198,17 +216,25 @@ Scene *BlueForceGame::createScene(int sceneNumber) { // Boat Rentals return new Scene840(); case 850: + // Boat Leaving/Entering Marina + return new Scene850(); case 860: + // Boat Entering Cove + return new Scene860(); case 870: + // Cove Beach + return new Scene870(); case 880: - error("Scene group 8 not implemented"); + // Beach Path + return new Scene880(); case 900: - // Outside Warehouse + // Outside the Warehouse return new Scene900(); case 910: - error("Scene group 9 not implemented"); + // Inside the Warehouse + return new Scene910(); case 920: - // Inside Warehouse: Secret room + // Inside the Warehouse: Secret room return new Scene920(); case 930: // Inside the caravan @@ -217,6 +243,7 @@ Scene *BlueForceGame::createScene(int sceneNumber) { // Hidden in the wardrobe return new Scene935(); case 940: + // Jail ending animation return new Scene940(); default: error("Unknown scene number - %d", sceneNumber); @@ -224,6 +251,20 @@ Scene *BlueForceGame::createScene(int sceneNumber) { } } +/** + * Returns true if it is currently okay to restore a game + */ +bool BlueForceGame::canLoadGameStateCurrently() { + return true; +} + +/** + * Returns true if it is currently okay to save the game + */ +bool BlueForceGame::canSaveGameStateCurrently() { + return true; +} + void BlueForceGame::rightClick() { RightClickDialog *dlg = new RightClickDialog(); dlg->execute(); @@ -274,6 +315,24 @@ void BlueForceGame::processEvent(Event &event) { } } +void BlueForceGame::restart() { + g_globals->_scenePalette.clearListeners(); + g_globals->_soundHandler.stop(); + + // Reset the globals + g_globals->reset(); + + // Clear save/load slots + g_globals->_sceneHandler->_saveGameSlot = -1; + g_globals->_sceneHandler->_loadGameSlot = -1; + + g_globals->_stripNum = 0; + g_globals->_events.setCursor(CURSOR_WALK); + + // Change to the first game scene + g_globals->_sceneManager.changeScene(190); +} + /*--------------------------------------------------------------------------*/ AObjectArray::AObjectArray(): EventHandler() { @@ -563,15 +622,15 @@ void FollowerObject::dispatch() { } else if ((_object->_visage != 308) || (_object->_strip != 1)) { show(); setStrip(_object->_strip); - setPosition(_object->_position, _object->_yDiff); + setPosition(Common::Point(_object->_position.x + 1, _object->_position.y), _yDiff); } } void FollowerObject::reposition() { assert(_object); setStrip(_object->_strip); - setPosition(_object->_position, _object->_yDiff); - reposition(); + setPosition(_object->_position, _yDiff); + NamedObject::reposition(); } void FollowerObject::setup(SceneObject *object, int visage, int frameNum, int yDiff) { @@ -665,13 +724,28 @@ void SceneExt::postInit(SceneObjectList *OwnerList) { Scene::postInit(OwnerList); if (BF_GLOBALS._dayNumber) { // Blank out the bottom portion of the screen - BF_GLOBALS._interfaceY = BF_INTERFACE_Y; + BF_GLOBALS._interfaceY = UI_INTERFACE_Y; - Rect r(0, BF_INTERFACE_Y, SCREEN_WIDTH, SCREEN_HEIGHT); + Rect r(0, UI_INTERFACE_Y, SCREEN_WIDTH, SCREEN_HEIGHT); BF_GLOBALS.gfxManager().getSurface().fillRect(r, 0); } } +void SceneExt::remove() { + 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 + if (_action) { + if (_action->_endHandler) + _action->_endHandler = NULL; + _action->remove(); + } + + _focusObject = NULL; +} + void SceneExt::process(Event &event) { _objArray2.process(event); if (!event.handled) @@ -683,8 +757,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; @@ -699,6 +773,7 @@ void SceneExt::loadScene(int sceneNum) { _v51C34.top = 0; _v51C34.bottom = 300; + BF_GLOBALS._sceneHandler->_delayTicks = 1; } void SceneExt::checkGun() { @@ -773,8 +848,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(); } } @@ -787,8 +862,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(); } } @@ -841,12 +916,12 @@ void PalettedScene::add2Faders(const byte *arrBufferRGB, int step, int paletteNu BF_GLOBALS._scenePalette.addFader(_palette._palette, 256, step, action); } -void PalettedScene::sub15E4F(const byte *arrBufferRGB, int arg8, int paletteNum, Action *action, int fromColor1, int fromColor2, int toColor1, int toColor2, bool flag) { +void PalettedScene::transition(const byte *arrBufferRGB, int percent, int paletteNum, Action *action, int fromColor1, int fromColor2, int toColor1, int toColor2, bool flag) { byte tmpPalette[768]; _palette.loadPalette(paletteNum); _palette.loadPalette(2); - if (!flag) { + if (flag) { for (int i = fromColor1; i <= fromColor2; i++) { tmpPalette[(3 * i)] = BF_GLOBALS._scenePalette._palette[(3 * i)]; tmpPalette[(3 * i) + 1] = BF_GLOBALS._scenePalette._palette[(3 * i) + 1]; @@ -861,9 +936,9 @@ void PalettedScene::sub15E4F(const byte *arrBufferRGB, int arg8, int paletteNum, } for (int i = toColor1; i <= toColor2; i++) { - tmpPalette[i] = _palette._palette[i] - ((_palette._palette[i] - arrBufferRGB[0]) * (100 - arg8)) / 100; - tmpPalette[i + 1] = _palette._palette[i + 1] - ((_palette._palette[i + 1] - arrBufferRGB[1]) * (100 - arg8)) / 100; - tmpPalette[i + 2] = _palette._palette[i + 2] - ((_palette._palette[i + 2] - arrBufferRGB[2]) * (100 - arg8)) / 100; + tmpPalette[i * 3] = _palette._palette[i * 3] - ((_palette._palette[i * 3] - arrBufferRGB[i * 3]) * (100 - percent)) / 100; + tmpPalette[i * 3 + 1] = _palette._palette[i * 3 + 1] - ((_palette._palette[i * 3 + 1] - arrBufferRGB[i * 3 + 1]) * (100 - percent)) / 100; + tmpPalette[i * 3 + 2] = _palette._palette[i * 3 + 2] - ((_palette._palette[i * 3 + 2] - arrBufferRGB[i * 3 + 2]) * (100 - percent)) / 100; } BF_GLOBALS._scenePalette.addFader((const byte *)tmpPalette, 256, 100, action); @@ -885,8 +960,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; } @@ -899,6 +974,23 @@ void SceneHandlerExt::process(Event &event) { return; } + // If the user clicks the button whilst the introduction is active, prompt for playing the game + if ((BF_GLOBALS._dayNumber == 0) && (event.eventType == EVENT_BUTTON_DOWN)) { + // Prompt user for whether to start play or watch introduction + BF_GLOBALS._player.enableControl(); + BF_GLOBALS._events.setCursor(CURSOR_WALK); + + if (MessageDialog::show2(WATCH_INTRO_MSG, START_PLAY_BTN_STRING, INTRODUCTION_BTN_STRING) == 0) { + // Start the game + BF_GLOBALS._dayNumber = 1; + BF_GLOBALS._sceneManager.changeScene(190); + } else { + BF_GLOBALS._player.disableControl(); + } + + event.handled = true; + } + SceneHandler::process(event); } @@ -1126,6 +1218,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) { @@ -1140,7 +1235,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) { @@ -1232,8 +1327,241 @@ 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() { + _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 SceneMessage::remove() { + SceneExt *scene = (SceneExt *)BF_GLOBALS._sceneManager._scene; + if (scene->_focusObject == this) + scene->_focusObject = NULL; + + Action::remove(); +} + +void SceneMessage::signal() { + SceneExt *scene = (SceneExt *)BF_GLOBALS._sceneManager._scene; + + switch (_actionIndex++) { + case 0: + scene->_focusObject = this; + BF_GLOBALS._events.setCursor(CURSOR_WALK); + draw(); + setDelay(180); + break; + case 1: + clear(); + remove(); + break; + default: + break; + } +} + +void SceneMessage::process(Event &event) { + if ((event.eventType == EVENT_BUTTON_DOWN) || + ((event.eventType == EVENT_KEYPRESS) && (event.kbd.keycode == Common::KEYCODE_RETURN))) { + signal(); + } +} + + +void SceneMessage::draw() { + GfxSurface &surface = BF_GLOBALS._screenSurface; + + // Clear the game area + surface.fillRect(Rect(0, 0, SCREEN_WIDTH, UI_INTERFACE_Y), 0); + + // Disable scene fade in + BF_GLOBALS._paneRefreshFlag[0] = 0; + + // Set up the font + GfxFont &font = BF_GLOBALS._gfxManagerInstance._font; + BF_GLOBALS._scenePalette.setEntry(font._colors.foreground, 255, 255, 255); + BF_GLOBALS._scenePalette.setPalette(font._colors.foreground, 1); + + // Write out the message + Rect textRect(0, UI_INTERFACE_Y / 2 - (font.getHeight() / 2), SCREEN_WIDTH, + UI_INTERFACE_Y / 2 + (font.getHeight() / 2)); + BF_GLOBALS._gfxManagerInstance._font.writeLines(_message.c_str(), textRect, ALIGN_CENTER); + + // TODO: Ideally, saving and loading should be disabled here until the message display is complete +} + +void SceneMessage::clear() { + // Fade out the text display + static const uint32 black = 0; + BF_GLOBALS._scenePalette.fade((const byte *)&black, false, 100); + + // Refresh the background + BF_GLOBALS._paneRefreshFlag[0] = 0; + + // Set up to fade in the game scene + g_globals->_sceneManager._fadeMode = FADEMODE_GRADUAL; + g_globals->_sceneManager._hasPalette = true; +} + +IntroSceneText::IntroSceneText(): SceneText() { + _action = NULL; + _frameNumber = 0; + _diff = 0; +} + +void IntroSceneText::setup(const Common::String &msg, Action *action) { + _frameNumber = BF_GLOBALS._events.getFrameNumber(); + _diff = 180; + _action = action; + _fontNumber = 4; + _width = 300; + _textMode = ALIGN_CENTER; + _color1 = BF_GLOBALS._scenePalette._colors.background; + _color2 = _color3 = 0; + + SceneText::setup(msg); + + // Center the text on-screen + reposition(); + _bounds.center(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2); + + // Set the new position + _position.x = _bounds.left; + _position.y = _bounds.top; +} + +void IntroSceneText::synchronize(Serializer &s) { + SceneText::synchronize(s); + SYNC_POINTER(_action); + s.syncAsUint32LE(_frameNumber); + s.syncAsSint16LE(_diff); +} + +void IntroSceneText::dispatch() { + if (_diff) { + uint32 frameNumber = BF_GLOBALS._events.getFrameNumber(); + if (_frameNumber < frameNumber) { + _diff -= frameNumber - _frameNumber; + _frameNumber = frameNumber; + + if (_diff <= 0) { + // Time has expired, so remove the text and signal the designated action + remove(); + if (_action) + _action->signal(); + } + } + } +} + } // End of namespace BlueForce } // End of namespace TsAGE |