aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/titanic/core/link_item.cpp20
-rw-r--r--engines/titanic/core/link_item.h9
-rw-r--r--engines/titanic/core/movie_clip.cpp16
-rw-r--r--engines/titanic/core/movie_clip.h4
-rw-r--r--engines/titanic/core/room_item.h5
-rw-r--r--engines/titanic/core/view_item.cpp25
-rw-r--r--engines/titanic/core/view_item.h4
-rw-r--r--engines/titanic/debugger.cpp8
-rw-r--r--engines/titanic/events.cpp21
-rw-r--r--engines/titanic/events.h7
-rw-r--r--engines/titanic/game_manager.cpp4
-rw-r--r--engines/titanic/game_manager.h9
-rw-r--r--engines/titanic/game_state.cpp36
-rw-r--r--engines/titanic/game_state.h15
-rw-r--r--engines/titanic/pet_control/pet_control.cpp4
-rw-r--r--engines/titanic/sound/sound.cpp4
-rw-r--r--engines/titanic/sound/sound.h6
17 files changed, 165 insertions, 32 deletions
diff --git a/engines/titanic/core/link_item.cpp b/engines/titanic/core/link_item.cpp
index 8d077d0423..02b4215cfa 100644
--- a/engines/titanic/core/link_item.cpp
+++ b/engines/titanic/core/link_item.cpp
@@ -51,10 +51,10 @@ void CLinkItem::save(SimpleFile *file, int indent) const {
file->writeNumberLine(_viewNumber, indent + 1);
file->writeQuotedLine("Hotspot", indent + 1);
- file->writeNumberLine(_hotspot.left, indent + 2);
- file->writeNumberLine(_hotspot.top, indent + 2);
- file->writeNumberLine(_hotspot.right, indent + 2);
- file->writeNumberLine(_hotspot.bottom, indent + 2);
+ file->writeNumberLine(_bounds.left, indent + 2);
+ file->writeNumberLine(_bounds.top, indent + 2);
+ file->writeNumberLine(_bounds.right, indent + 2);
+ file->writeNumberLine(_bounds.bottom, indent + 2);
CNamedItem::save(file, indent);
}
@@ -78,10 +78,10 @@ void CLinkItem::load(SimpleFile *file) {
_viewNumber = file->readNumber();
file->readBuffer();
- _hotspot.left = file->readNumber();
- _hotspot.top = file->readNumber();
- _hotspot.right = file->readNumber();
- _hotspot.bottom = file->readNumber();
+ _bounds.left = file->readNumber();
+ _bounds.top = file->readNumber();
+ _bounds.right = file->readNumber();
+ _bounds.bottom = file->readNumber();
break;
default:
@@ -130,4 +130,8 @@ CRoomItem *CLinkItem::getDestRoom() const {
return getDestNode()->findRoom();
}
+CMovieClip *CLinkItem::getClip() const {
+ return findRoom()->findClip(getName());
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/core/link_item.h b/engines/titanic/core/link_item.h
index 55219c08cc..733a4c9bdd 100644
--- a/engines/titanic/core/link_item.h
+++ b/engines/titanic/core/link_item.h
@@ -24,6 +24,7 @@
#define TITANIC_LINK_ITEM_H
#include "titanic/core/named_item.h"
+#include "titanic/core/movie_clip.h"
namespace Titanic {
@@ -44,7 +45,8 @@ protected:
int _viewNumber;
int _field30;
int _field34;
- Common::Rect _hotspot;
+public:
+ Common::Rect _bounds;
public:
CLASSDEF
CLinkItem();
@@ -79,6 +81,11 @@ public:
* Get the destination view for the link item
*/
virtual CRoomItem *getDestRoom() const;
+
+ /**
+ * Get the movie clip, if any, that's used when the link is used
+ */
+ CMovieClip *getClip() const;
};
} // End of namespace Titanic
diff --git a/engines/titanic/core/movie_clip.cpp b/engines/titanic/core/movie_clip.cpp
index fec09f6542..9a787e2aa9 100644
--- a/engines/titanic/core/movie_clip.cpp
+++ b/engines/titanic/core/movie_clip.cpp
@@ -30,7 +30,7 @@ CMovieClip::CMovieClip() {
void CMovieClip::save(SimpleFile *file, int indent) const {
file->writeNumberLine(2, indent);
file->writeQuotedLine("Clip", indent);
- file->writeQuotedLine(_string1, indent);
+ file->writeQuotedLine(_name, indent);
file->writeNumberLine(_field18, indent);
file->writeNumberLine(_field1C, indent);
@@ -42,7 +42,7 @@ void CMovieClip::load(SimpleFile *file) {
switch (val) {
case 1:
- _string1 = file->readString();
+ _name = file->readString();
_field18 = file->readNumber();
_field1C = file->readNumber();
_field20 = file->readNumber();
@@ -54,7 +54,7 @@ void CMovieClip::load(SimpleFile *file) {
case 2:
file->readString();
- _string1 = file->readString();
+ _name = file->readString();
_field18 = file->readNumber();
_field1C = file->readNumber();
break;
@@ -66,4 +66,14 @@ void CMovieClip::load(SimpleFile *file) {
ListItem::load(file);
}
+CMovieClip *CMovieClipList::findByName(const Common::String &name) const {
+ for (const_iterator i = begin(); i != end(); ++i) {
+ CMovieClip *clip = *i;
+ if (clip->_name == name)
+ return clip;
+ }
+
+ return nullptr;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/core/movie_clip.h b/engines/titanic/core/movie_clip.h
index cd6125d438..0abda9453f 100644
--- a/engines/titanic/core/movie_clip.h
+++ b/engines/titanic/core/movie_clip.h
@@ -32,7 +32,6 @@ namespace Titanic {
*/
class CMovieClip : public ListItem {
private:
- CString _string1;
int _field18;
int _field1C;
int _field20;
@@ -43,6 +42,8 @@ private:
CString _string2;
CString _string3;
public:
+ CString _name;
+public:
CLASSDEF
CMovieClip();
@@ -62,6 +63,7 @@ public:
*/
class CMovieClipList: public List<CMovieClip> {
public:
+ CMovieClip *findByName(const Common::String &name) const;
};
} // End of namespace Titanic
diff --git a/engines/titanic/core/room_item.h b/engines/titanic/core/room_item.h
index 2235f6a5d2..a42ffab32e 100644
--- a/engines/titanic/core/room_item.h
+++ b/engines/titanic/core/room_item.h
@@ -54,6 +54,11 @@ public:
* Load the data for the class from file
*/
virtual void load(SimpleFile *file);
+
+ /**
+ * Return a movie clip for the room by name
+ */
+ CMovieClip *findClip(const CString &name) { return _clipList.findByName(name); }
};
} // End of namespace Titanic
diff --git a/engines/titanic/core/view_item.cpp b/engines/titanic/core/view_item.cpp
index cc8ba49ba9..a80f25bcc1 100644
--- a/engines/titanic/core/view_item.cpp
+++ b/engines/titanic/core/view_item.cpp
@@ -162,17 +162,34 @@ void CViewItem::enterView(CViewItem *newView) {
bool CViewItem::handleEvent(CMouseButtonDownMsg &msg) {
if (msg._buttons & MB_LEFT) {
- mouseChange(&msg, true);
+ if (!handleMouseMsg(&msg, true)) {
+ CGameManager *gm = getGameManager();
+ if (gm->test54()) {
+ findNode()->findRoom();
+
+ CLinkItem *linkItem = dynamic_cast<CLinkItem *>(
+ findChildInstanceOf(CLinkItem::_type));
+ while (linkItem) {
+ if (linkItem->_bounds.contains(msg._mousePos)) {
+ gm->_gameState.triggerLink(linkItem);
+ return true;
+ }
+
+ linkItem = dynamic_cast<CLinkItem *>(
+ findNextInstanceOf(CLinkItem::_type, linkItem));
+ }
+ }
+ }
// TODO
}
return true;
}
-bool CViewItem::mouseChange(const CMouseMsg *msg, bool flag) {
+bool CViewItem::handleMouseMsg(const CMouseMsg *msg, bool flag) {
const CMouseButtonUpMsg *upMsg = dynamic_cast<const CMouseButtonUpMsg *>(msg);
if (msg->isButtonUpMsg()) {
- mouseButtonUp(upMsg);
+ handleButtonUpMsg(upMsg);
return true;
}
@@ -217,7 +234,7 @@ bool CViewItem::mouseChange(const CMouseMsg *msg, bool flag) {
return result;
}
-void CViewItem::mouseButtonUp(const CMouseButtonUpMsg *msg) {
+void CViewItem::handleButtonUpMsg(const CMouseButtonUpMsg *msg) {
CTreeItem *&target = _buttonUpTargets[msg->_buttons >> 1];
if (target) {
diff --git a/engines/titanic/core/view_item.h b/engines/titanic/core/view_item.h
index 9994ec6625..b1de0bb305 100644
--- a/engines/titanic/core/view_item.h
+++ b/engines/titanic/core/view_item.h
@@ -38,12 +38,12 @@ private:
/**
* Called to handle mouse messagaes on the view
*/
- bool mouseChange(const CMouseMsg *msg, bool flag);
+ bool handleMouseMsg(const CMouseMsg *msg, bool flag);
/**
* Handles mouse button up messages
*/
- void mouseButtonUp(const CMouseButtonUpMsg *msg);
+ void handleButtonUpMsg(const CMouseButtonUpMsg *msg);
protected:
int _field24;
double _field28;
diff --git a/engines/titanic/debugger.cpp b/engines/titanic/debugger.cpp
index 7af86fc71d..87ce07d189 100644
--- a/engines/titanic/debugger.cpp
+++ b/engines/titanic/debugger.cpp
@@ -160,10 +160,12 @@ bool Debugger::cmdRoom(int argc, const char **argv) {
else {
CViewItem *viewItem = findView(nodeItem, argv[3]);
- if (!viewItem)
+ if (!viewItem) {
debugPrintf("Could not find view - %s\n", argv[3]);
- else {
- debugPrintf("Found view. TODO: Jump to it\n");
+ } else {
+ // Change to the specified view
+ g_vm->_window->_gameManager->_gameState.changeView(viewItem, nullptr);
+ return false;
}
}
}
diff --git a/engines/titanic/events.cpp b/engines/titanic/events.cpp
index 09ec3e5872..346b43c02b 100644
--- a/engines/titanic/events.cpp
+++ b/engines/titanic/events.cpp
@@ -66,6 +66,9 @@ void Events::pollEvents() {
case Common::EVENT_KEYDOWN:
keyDown(event.kbd);
break;
+ case Common::EVENT_KEYUP:
+ keyUp(event.kbd);
+ break;
default:
break;
}
@@ -177,6 +180,8 @@ void Events::charPress(char c) {
}
void Events::keyDown(Common::KeyState keyState) {
+ handleKbdSpecial(keyState);
+
if (keyState.keycode == Common::KEYCODE_d && (keyState.flags & Common::KBD_CTRL)) {
// Attach to the debugger
_vm->_debugger->attach();
@@ -184,4 +189,20 @@ void Events::keyDown(Common::KeyState keyState) {
}
}
+void Events::keyUp(Common::KeyState keyState) {
+ handleKbdSpecial(keyState);
+}
+
+void Events::handleKbdSpecial(Common::KeyState keyState) {
+ if (keyState.flags & Common::KBD_CTRL)
+ _specialButtons |= MK_CONTROL;
+ else
+ _specialButtons &= ~MK_CONTROL;
+
+ if (keyState.flags & Common::KBD_SHIFT)
+ _specialButtons |= MK_SHIFT;
+ else
+ _specialButtons &= ~MK_SHIFT;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/events.h b/engines/titanic/events.h
index dc1781fae1..fe2c75166d 100644
--- a/engines/titanic/events.h
+++ b/engines/titanic/events.h
@@ -67,6 +67,8 @@ private:
void rightButtonDoubleClick();
void charPress(char c);
void keyDown(Common::KeyState keyState);
+ void keyUp(Common::KeyState keyState);
+ void handleKbdSpecial(Common::KeyState keyState);
public:
Events(TitanicEngine *vm);
~Events() {}
@@ -91,6 +93,11 @@ public:
* Get the elapsed playtime
*/
uint32 getTicksCount() const;
+
+ /**
+ * Return whether a given special key is currently pressed
+ */
+ bool isSpecialPressed(SpecialButtons btn) const { return _specialButtons; }
};
} // End of namespace Titanic
diff --git a/engines/titanic/game_manager.cpp b/engines/titanic/game_manager.cpp
index 1177ca8abd..4a45fa52f9 100644
--- a/engines/titanic/game_manager.cpp
+++ b/engines/titanic/game_manager.cpp
@@ -139,8 +139,8 @@ void CGameManager::fn2() {
warning("TODO");
}
-void CGameManager::fn10(void *param1, CRoomItem *oldRoom, CRoomItem *newRoom) {
- warning("TODO: CGameManager::fn10");
+void CGameManager::playClip(CMovieClip *clip, CRoomItem *oldRoom, CRoomItem *newRoom) {
+ warning("TODO: CGameManager::playClip");
}
void CGameManager::update() {
diff --git a/engines/titanic/game_manager.h b/engines/titanic/game_manager.h
index 3e33e7a928..38edc6e1a4 100644
--- a/engines/titanic/game_manager.h
+++ b/engines/titanic/game_manager.h
@@ -78,7 +78,6 @@ public:
class CGameManager {
private:
- CSound _sound;
CTrueTalkManager _trueTalkManager;
CGameManagerList _list;
int _field30;
@@ -98,6 +97,7 @@ public:
CInputTranslator _inputTranslator;
CTreeItem *_dragItem;
CMusicRoom _musicRoom;
+ CSound _sound;
public:
CGameManager(CProjectItem *project, CGameView *gameView);
~CGameManager();
@@ -151,7 +151,10 @@ public:
void fn2();
- void fn10(void *param1, CRoomItem *oldRoom, CRoomItem *newRoom);
+ /**
+ * Plays a movie clip
+ */
+ void playClip(CMovieClip *clip, CRoomItem *oldRoom, CRoomItem *newRoom);
/**
* Updates the state of the manager
@@ -162,6 +165,8 @@ public:
* Called when the view changes
*/
void viewChange();
+
+ bool test54() const { return !_field54; }
};
} // End of namespace Titanic
diff --git a/engines/titanic/game_state.cpp b/engines/titanic/game_state.cpp
index ad91a5a948..f10f945f93 100644
--- a/engines/titanic/game_state.cpp
+++ b/engines/titanic/game_state.cpp
@@ -97,7 +97,39 @@ void CGameState::enterView() {
_gameManager->_gameView->setView(newView);
CRoomItem *oldRoom = oldView->findNode()->findRoom();
CRoomItem *newRoom = newView->findNode()->findRoom();
- _gameManager->fn10(_list._field14, oldRoom, newRoom);
+ _gameManager->playClip(_list._movieClip, oldRoom, newRoom);
}
-} // End of namespace Titanic z
+void CGameState::triggerLink(CLinkItem *link) {
+ changeView(link->getDestView(), link->getClip());
+}
+
+void CGameState::changeView(CViewItem *newView, CMovieClip *clip) {
+ // Signal the old view that it's being left
+ CViewItem *oldView = _gameLocation.getView();
+ oldView->leaveView(newView);
+
+ // If Shift key is pressed, skip showing the transition clip
+ if (g_vm->_events->isSpecialPressed(MK_SHIFT))
+ clip = nullptr;
+
+ if (_mode == GSMODE_2) {
+ _list._view = newView;
+ _list._movieClip = clip;
+ } else {
+ oldView->preEnterView(newView);
+ _gameManager->_gameView->setView(newView);
+ CRoomItem *oldRoom = newView->findNode()->findRoom();
+ CRoomItem *newRoom = newView->findNode()->findRoom();
+
+ // If a transition clip is defined, play it
+ if (clip)
+ _gameManager->playClip(clip, oldRoom, newRoom);
+
+ // Final view change handling
+ _gameManager->_sound.viewChanged(newView, newRoom != oldRoom);
+ oldView->enterView(newView);
+ }
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/game_state.h b/engines/titanic/game_state.h
index 19a59f8424..b9d25e9662 100644
--- a/engines/titanic/game_state.h
+++ b/engines/titanic/game_state.h
@@ -24,6 +24,7 @@
#define TITANIC_GAME_STATE_H
#include "titanic/core/list.h"
+#include "titanic/core/link_item.h"
#include "titanic/simple_file.h"
#include "titanic/game_location.h"
@@ -36,9 +37,9 @@ enum GameStateMode { GSMODE_0 = 0, GSMODE_1 = 1, GSMODE_2 = 2, GSMODE_3 = 3, GSM
class CGameStateList : public List<ListItem> {
public:
CViewItem *_view;
- void *_field14;
+ CMovieClip *_movieClip;
public:
- CGameStateList() : List<ListItem>(), _view(nullptr), _field14(nullptr) {}
+ CGameStateList() : List<ListItem>(), _view(nullptr), _movieClip(nullptr) {}
};
class CGameState {
@@ -90,6 +91,16 @@ public:
* Enters a new view
*/
void enterView();
+
+ /**
+ * Triggers a link item in a view
+ */
+ void triggerLink(CLinkItem *link);
+
+ /**
+ * Changes the current view
+ */
+ void changeView(CViewItem *newView, CMovieClip *clip);
};
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp
index a61773d319..f5498887e3 100644
--- a/engines/titanic/pet_control/pet_control.cpp
+++ b/engines/titanic/pet_control/pet_control.cpp
@@ -38,9 +38,9 @@ void CPetControl::save(SimpleFile *file, int indent) const {
void CPetControl::load(SimpleFile *file) {
int val = file->readNumber();
- bool valid = isValid();
+ isValid();
- if (!valid) {
+ if (!val) {
_fieldBC = file->readNumber();
_string1 = file->readString();
_string2 = file->readString();
diff --git a/engines/titanic/sound/sound.cpp b/engines/titanic/sound/sound.cpp
index 062e43debc..54c14508cf 100644
--- a/engines/titanic/sound/sound.cpp
+++ b/engines/titanic/sound/sound.cpp
@@ -43,4 +43,8 @@ void CSound::preLoad() {
_gameManager->_musicRoom.preLoad();
}
+void CSound::viewChanged(CViewItem *newView, bool isNewRoom) {
+ warning("CSound::viewChanged");
+}
+
} // End of namespace Titanic z
diff --git a/engines/titanic/sound/sound.h b/engines/titanic/sound/sound.h
index fce29eb625..0bfd3f29b1 100644
--- a/engines/titanic/sound/sound.h
+++ b/engines/titanic/sound/sound.h
@@ -25,6 +25,7 @@
#include "titanic/simple_file.h"
#include "titanic/sound/sound_manager.h"
+#include "titanic/core/view_item.h"
namespace Titanic {
@@ -66,6 +67,11 @@ public:
* Called when a game has finished being saved
*/
void postSave() { _soundManager.postSave(); }
+
+ /**
+ * Called when the view has been changed
+ */
+ void viewChanged(CViewItem *newView, bool isNewRoom);
};
} // End of namespace Titanic