diff options
author | Paul Gilbert | 2016-03-19 18:19:45 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-03-19 18:19:45 -0400 |
commit | 4704d72d6af60db97959c3d170a2ea524a0f0f1f (patch) | |
tree | 2b56e66d124be79d02743777f96914edf02bba75 /engines/titanic | |
parent | d86941f8c6b497f2d3d8409c2628af88bc600dae (diff) | |
download | scummvm-rg350-4704d72d6af60db97959c3d170a2ea524a0f0f1f.tar.gz scummvm-rg350-4704d72d6af60db97959c3d170a2ea524a0f0f1f.tar.bz2 scummvm-rg350-4704d72d6af60db97959c3d170a2ea524a0f0f1f.zip |
TITANIC: Implementing view item message handling
Diffstat (limited to 'engines/titanic')
24 files changed, 250 insertions, 62 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index f5e9806365..884873ec0e 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -39,7 +39,7 @@ CGameObject::CGameObject(): CNamedItem() { _field58 = 0; _field5C = 1; _field60 = 0; - _field74 = 1; + _cursorId = 1; _field78 = 0; _field8C = -1; _field90 = 0; @@ -70,7 +70,7 @@ void CGameObject::load(SimpleFile *file) { // Deliberate fall-through case 6: - val = _field74 = file->readNumber(); + val = _cursorId = file->readNumber(); // Deliberate fall-through case 5: @@ -122,4 +122,9 @@ void CGameObject::fn2() { error("TODO"); } +bool CGameObject::checkPoint(const Common::Point &pt, int v0, int v1) { + warning("TODO: CGameObject::checkPoint"); + return false; +} + } // End of namespace Titanic diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h index c284fb4ebe..693f334608 100644 --- a/engines/titanic/core/game_object.h +++ b/engines/titanic/core/game_object.h @@ -43,9 +43,7 @@ protected: int _field54; int _field58; int _field5C; - int _field60; CMovieClipList _clipList1; - int _field74; int _field78; CMovieClipList _clipList2; int _field8C; @@ -59,6 +57,9 @@ protected: CString _string; int _fieldB8; public: + int _field60; + int _cursorId; +public: CLASSDEF CGameObject(); @@ -73,6 +74,8 @@ public: virtual void load(SimpleFile *file); void fn2(); + + bool checkPoint(const Common::Point &pt, int v0, int v1); }; } // End of namespace Titanic diff --git a/engines/titanic/core/link_item.cpp b/engines/titanic/core/link_item.cpp index 175c11f8d0..8d077d0423 100644 --- a/engines/titanic/core/link_item.cpp +++ b/engines/titanic/core/link_item.cpp @@ -27,15 +27,6 @@ namespace Titanic { -void CLinkItemHotspot::clear() { - _field0 = 0; - _field4 = 0; - _field8 = 0; - _fieldC = 0; -} - -/*------------------------------------------------------------------------*/ - CLinkItem::CLinkItem() : CNamedItem() { _roomNumber = -1; _nodeNumber = -1; @@ -60,10 +51,10 @@ void CLinkItem::save(SimpleFile *file, int indent) const { file->writeNumberLine(_viewNumber, indent + 1); file->writeQuotedLine("Hotspot", indent + 1); - file->writeNumberLine(_hotspot._field0, indent + 2); - file->writeNumberLine(_hotspot._field4, indent + 2); - file->writeNumberLine(_hotspot._field8, indent + 2); - file->writeNumberLine(_hotspot._fieldC, indent + 2); + file->writeNumberLine(_hotspot.left, indent + 2); + file->writeNumberLine(_hotspot.top, indent + 2); + file->writeNumberLine(_hotspot.right, indent + 2); + file->writeNumberLine(_hotspot.bottom, indent + 2); CNamedItem::save(file, indent); } @@ -87,10 +78,10 @@ void CLinkItem::load(SimpleFile *file) { _viewNumber = file->readNumber(); file->readBuffer(); - _hotspot._field0 = file->readNumber(); - _hotspot._field4 = file->readNumber(); - _hotspot._field8 = file->readNumber(); - _hotspot._fieldC = file->readNumber(); + _hotspot.left = file->readNumber(); + _hotspot.top = file->readNumber(); + _hotspot.right = file->readNumber(); + _hotspot.bottom = file->readNumber(); break; default: diff --git a/engines/titanic/core/link_item.h b/engines/titanic/core/link_item.h index 06d55f3f44..55219c08cc 100644 --- a/engines/titanic/core/link_item.h +++ b/engines/titanic/core/link_item.h @@ -31,18 +31,6 @@ class CViewItem; class CNodeItem; class CRoomItem; -class CLinkItemHotspot { -public: - int _field0; - int _field4; - int _field8; - int _fieldC; -public: - CLinkItemHotspot() { clear(); } - - void clear(); -}; - class CLinkItem : public CNamedItem { private: /** @@ -56,7 +44,7 @@ protected: int _viewNumber; int _field30; int _field34; - CLinkItemHotspot _hotspot; + Common::Rect _hotspot; public: CLASSDEF CLinkItem(); diff --git a/engines/titanic/core/view_item.cpp b/engines/titanic/core/view_item.cpp index c632458939..485062db27 100644 --- a/engines/titanic/core/view_item.cpp +++ b/engines/titanic/core/view_item.cpp @@ -21,6 +21,7 @@ */ #include "titanic/game_manager.h" +#include "titanic/screen_manager.h" #include "titanic/core/project_item.h" #include "titanic/core/room_item.h" #include "titanic/core/view_item.h" @@ -30,6 +31,7 @@ namespace Titanic { CViewItem::CViewItem() : CNamedItem() { + Common::fill(&_buttonUpTargets[0], &_buttonUpTargets[3], nullptr); _field24 = 0; _field28 = 0.0; _viewNumber = 0; @@ -158,4 +160,69 @@ void CViewItem::enterView(CViewItem *newView) { } } +bool CViewItem::handleEvent(CMouseButtonDownMsg &msg) { + if (msg._buttons & MB_LEFT) { + mouseChange(&msg, true); + // TODO + } + + return true; +} + +bool CViewItem::mouseChange(const CMouseMsg *msg, bool flag) { + const CMouseButtonUpMsg *upMsg = dynamic_cast<const CMouseButtonUpMsg *>(msg); + if (msg->isButtonUpMsg()) { + mouseButtonUp(upMsg); + return true; + } + + Common::Array<CGameObject *> gameObjects; + CTreeItem *treeItem = scan(this); + while (treeItem) { + CGameObject *gameObject = dynamic_cast<CGameObject *>(treeItem); + if (gameObject) { + if (gameObject->checkPoint(msg->_mousePos, 0, 1) && + (!flag || !gameObject->_field60)) { + if (gameObjects.size() < 256) + gameObjects.push_back(gameObject); + } + } + } + + const CMouseMoveMsg *moveMsg = dynamic_cast<const CMouseMoveMsg *>(msg); + if (moveMsg) { + if (gameObjects.size() == 0) + return false; + + for (int idx = (int)gameObjects.size() - 1; idx >= 0; ++idx) { + if (gameObjects[idx]->_cursorId != 12) { + CScreenManager::_screenManagerPtr->_mouseCursor->setCursorId(gameObjects[idx]->_cursorId); + break; + } + } + } + + bool result = false; + for (int idx = (int)gameObjects.size() - 1; idx >= 0; --idx) { + if (msg->execute(gameObjects[idx])) { + if (msg->isButtonDownMsg()) + _buttonUpTargets[msg->_buttons >> 1] = gameObjects[idx]; + return true; + } + + // TODO + } + + return result; +} + +void CViewItem::mouseButtonUp(const CMouseButtonUpMsg *msg) { + CTreeItem *&target = _buttonUpTargets[msg->_buttons >> 1]; + + if (target) { + msg->execute(target); + target = nullptr; + } +} + } // End of namespace Titanic diff --git a/engines/titanic/core/view_item.h b/engines/titanic/core/view_item.h index ad09ed69e6..9994ec6625 100644 --- a/engines/titanic/core/view_item.h +++ b/engines/titanic/core/view_item.h @@ -25,18 +25,33 @@ #include "titanic/core/named_item.h" #include "titanic/core/resource_key.h" +#include "titanic/messages/mouse_messages.h" namespace Titanic { -class CViewItem : public CNamedItem { +class CViewItem : public CNamedItem { //, CMouseButtonDownMsgTarget { +private: + CTreeItem *_buttonUpTargets[4]; private: void setData(double v); + + /** + * Called to handle mouse messagaes on the view + */ + bool mouseChange(const CMouseMsg *msg, bool flag); + + /** + * Handles mouse button up messages + */ + void mouseButtonUp(const CMouseButtonUpMsg *msg); protected: int _field24; double _field28; CResourceKey _resourceKey; int _field50; int _field54; +protected: + virtual bool handleEvent(CMouseButtonDownMsg &msg); public: int _viewNumber; public: diff --git a/engines/titanic/files_manager.cpp b/engines/titanic/files_manager.cpp index d668563258..47da8e53ba 100644 --- a/engines/titanic/files_manager.cpp +++ b/engines/titanic/files_manager.cpp @@ -55,6 +55,9 @@ bool CFilesManager::scanForFile(const CString &name) { fname += ".st"; } + if (_gameManager) + _gameManager->viewChange(); + // The original had a bunch of code here handling determining // which asset path, if any, the filename was present for, // and storing the "active asset path" it was found on. @@ -66,4 +69,8 @@ void CFilesManager::fn1() { warning("TODO: CFilesManager::fn1"); } +void CFilesManager::debug(CScreenManager *screenManager) { + warning("TODO: CFilesManager::debug"); +} + } // End of namespace Titanic diff --git a/engines/titanic/files_manager.h b/engines/titanic/files_manager.h index ae5703373d..a767056bdf 100644 --- a/engines/titanic/files_manager.h +++ b/engines/titanic/files_manager.h @@ -24,6 +24,7 @@ #define TITANIC_FILES_MANAGER_H #include "titanic/core/list.h" +#include "titanic/screen_manager.h" namespace Titanic { @@ -65,6 +66,8 @@ public: bool scanForFile(const CString &name); void fn1(); + + void debug(CScreenManager *screenManager); }; } // End of namespace Titanic diff --git a/engines/titanic/game/gondolier/gondolier_mixer.cpp b/engines/titanic/game/gondolier/gondolier_mixer.cpp index b647a31ac2..3d0a0e1f19 100644 --- a/engines/titanic/game/gondolier/gondolier_mixer.cpp +++ b/engines/titanic/game/gondolier/gondolier_mixer.cpp @@ -21,6 +21,7 @@ */ #include "titanic/game/gondolier/gondolier_mixer.h" +#include "titanic/core/room_item.h" namespace Titanic { @@ -57,7 +58,7 @@ void CGondolierMixer::load(SimpleFile *file) { } bool CGondolierMixer::handleEvent(CEnterRoomMsg &msg) { - CTreeItem *parentRoom = getParent(); + CRoomItem *parentRoom = dynamic_cast<CRoomItem *>(getParent()); if (parentRoom == msg._newRoom) msg.execute(parentRoom); diff --git a/engines/titanic/game_manager.cpp b/engines/titanic/game_manager.cpp index 296299a526..1177ca8abd 100644 --- a/engines/titanic/game_manager.cpp +++ b/engines/titanic/game_manager.cpp @@ -139,6 +139,10 @@ void CGameManager::fn2() { warning("TODO"); } +void CGameManager::fn10(void *param1, CRoomItem *oldRoom, CRoomItem *newRoom) { + warning("TODO: CGameManager::fn10"); +} + void CGameManager::update() { warning("TODO: CGameManager::update"); } diff --git a/engines/titanic/game_manager.h b/engines/titanic/game_manager.h index 6404845fa2..3e33e7a928 100644 --- a/engines/titanic/game_manager.h +++ b/engines/titanic/game_manager.h @@ -78,7 +78,6 @@ public: class CGameManager { private: - CGameView *_gameView; CSound _sound; CTrueTalkManager _trueTalkManager; CGameManagerList _list; @@ -92,6 +91,7 @@ private: uint _tickCount2; public: CProjectItem *_project; + CGameView *_gameView; CGameState _gameState; Common::Rect _bounds; CInputHandler _inputHandler; @@ -151,6 +151,8 @@ public: void fn2(); + void fn10(void *param1, CRoomItem *oldRoom, CRoomItem *newRoom); + /** * Updates the state of the manager */ diff --git a/engines/titanic/game_state.cpp b/engines/titanic/game_state.cpp index d0baf21599..ad91a5a948 100644 --- a/engines/titanic/game_state.cpp +++ b/engines/titanic/game_state.cpp @@ -89,4 +89,15 @@ void CGameState::enterNode() { _nodeEnterTicks = g_vm->_events->getTicksCount(); } +void CGameState::enterView() { + CViewItem *oldView = _gameLocation.getView(); + CViewItem *newView = _list._view; + oldView->preEnterView(newView); + + _gameManager->_gameView->setView(newView); + CRoomItem *oldRoom = oldView->findNode()->findRoom(); + CRoomItem *newRoom = newView->findNode()->findRoom(); + _gameManager->fn10(_list._field14, oldRoom, newRoom); +} + } // End of namespace Titanic z diff --git a/engines/titanic/game_state.h b/engines/titanic/game_state.h index 10b87b5f9a..19a59f8424 100644 --- a/engines/titanic/game_state.h +++ b/engines/titanic/game_state.h @@ -35,10 +35,10 @@ enum GameStateMode { GSMODE_0 = 0, GSMODE_1 = 1, GSMODE_2 = 2, GSMODE_3 = 3, GSM class CGameStateList : public List<ListItem> { public: - int _field10; - int _field14; + CViewItem *_view; + void *_field14; public: - CGameStateList() : List<ListItem>(), _field10(0), _field14(0) {} + CGameStateList() : List<ListItem>(), _view(nullptr), _field14(nullptr) {} }; class CGameState { @@ -85,6 +85,11 @@ public: * Called by the PET when a new node is entered */ void enterNode(); + + /** + * Enters a new view + */ + void enterView(); }; } // End of namespace Titanic diff --git a/engines/titanic/main_game_window.cpp b/engines/titanic/main_game_window.cpp index 0c80149173..2c148c8c2e 100644 --- a/engines/titanic/main_game_window.cpp +++ b/engines/titanic/main_game_window.cpp @@ -128,7 +128,7 @@ void CMainGameWindow::fn2() { warning("TODO: Stuff"); case GSMODE_5: - warning("TODO: FilesManager::fn1"); + g_vm->_filesManager.fn1(); break; default: diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h index 0776ab9493..54581a7b07 100644 --- a/engines/titanic/messages/messages.h +++ b/engines/titanic/messages/messages.h @@ -24,10 +24,7 @@ #define TITANIC_MESSAGES_H #include "titanic/core/saveable_object.h" -#include "titanic/core/game_object.h" -#include "titanic/core/node_item.h" -#include "titanic/core/room_item.h" -#include "titanic/core/view_item.h" +#include "titanic/core/tree_item.h" namespace Titanic { @@ -40,6 +37,11 @@ enum MessageFlag { #define MSGTARGET(NAME) class NAME; class NAME##Target { public: \ virtual bool handleEvent(NAME &msg) = 0; } +class CGameObject; +class CRoomItem; +class CNodeItem; +class CViewItem; + class CMessage : public CSaveableObject { public: CLASSDEF diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk index da194bf00e..af5c89c072 100644 --- a/engines/titanic/module.mk +++ b/engines/titanic/module.mk @@ -16,6 +16,7 @@ MODULE_OBJS := \ input_handler.o \ input_translator.o \ main_game_window.o \ + mouse_cursor.o \ screen_manager.o \ simple_file.o \ string.o \ diff --git a/engines/titanic/mouse_cursor.cpp b/engines/titanic/mouse_cursor.cpp new file mode 100644 index 0000000000..ee252ccf63 --- /dev/null +++ b/engines/titanic/mouse_cursor.cpp @@ -0,0 +1,40 @@ +/* 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/textconsole.h" +#include "titanic/mouse_cursor.h" + +namespace Titanic { + +void CMouseCursor::show() { + warning("CMouseCursor::show"); +} + +void CMouseCursor::hide() { + warning("CMouseCursor::hide"); +} + +void CMouseCursor::setCursorId(int id) { + warning("CMouseCursor::setCursorId"); +} + +} // End of namespace Titanic diff --git a/engines/titanic/mouse_cursor.h b/engines/titanic/mouse_cursor.h new file mode 100644 index 0000000000..ecbee8569c --- /dev/null +++ b/engines/titanic/mouse_cursor.h @@ -0,0 +1,40 @@ +/* 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 TITANIC_MOUSE_CURSOR_H +#define TITANIC_MOUSE_CURSOR_H + +#include "common/scummsys.h" + +namespace Titanic { + +class CMouseCursor { +public: + void show(); + void hide(); + void setCursorId(int id); +}; + + +} // End of namespace Titanic + +#endif /* TITANIC_MOUSE_CURSOR_H */ diff --git a/engines/titanic/pet_control/pet_val.cpp b/engines/titanic/pet_control/pet_val.cpp index 31494e1033..96b82f1632 100644 --- a/engines/titanic/pet_control/pet_val.cpp +++ b/engines/titanic/pet_control/pet_val.cpp @@ -41,7 +41,7 @@ void CPetVal::proc4() { error("TODO"); } -void CPetVal::proc5(CLinkItemHotspot *linkItem) { +void CPetVal::proc5(Common::Rect *rect) { error("TODO"); } diff --git a/engines/titanic/pet_control/pet_val.h b/engines/titanic/pet_control/pet_val.h index 2bf082fbc8..bd1fb9e55c 100644 --- a/engines/titanic/pet_control/pet_val.h +++ b/engines/titanic/pet_control/pet_val.h @@ -40,7 +40,7 @@ public: virtual void proc3(); virtual void proc4(); - virtual void proc5(CLinkItemHotspot *linkItem); + virtual void proc5(Common::Rect *linkItem); virtual int proc16(); }; diff --git a/engines/titanic/pet_control/pet_val_base.cpp b/engines/titanic/pet_control/pet_val_base.cpp index 2eb93394a9..c798c37971 100644 --- a/engines/titanic/pet_control/pet_val_base.cpp +++ b/engines/titanic/pet_control/pet_val_base.cpp @@ -28,9 +28,9 @@ namespace Titanic { CPetValBase::CPetValBase() : _field4(0), _field8(0), _fieldC(0), _field10(0), _field14(0) {} -void CPetValBase::proc5(CLinkItemHotspot *linkItem) { - if (linkItem) - linkItem->clear(); +void CPetValBase::proc5(Common::Rect *rect) { + if (rect) + *rect = Common::Rect(); } int CPetValBase::proc6() { diff --git a/engines/titanic/pet_control/pet_val_base.h b/engines/titanic/pet_control/pet_val_base.h index e6e78ae4b0..c4ff66568d 100644 --- a/engines/titanic/pet_control/pet_val_base.h +++ b/engines/titanic/pet_control/pet_val_base.h @@ -44,7 +44,7 @@ public: virtual void proc3() {} virtual void proc4() {} - virtual void proc5(CLinkItemHotspot *linkItem); + virtual void proc5(Common::Rect *rect); virtual int proc6(); virtual int proc7(); diff --git a/engines/titanic/screen_manager.cpp b/engines/titanic/screen_manager.cpp index 9c88dc6de9..0c3ab6f556 100644 --- a/engines/titanic/screen_manager.cpp +++ b/engines/titanic/screen_manager.cpp @@ -110,7 +110,16 @@ void OSScreenManager::setMode(int width, int height, int bpp, uint numBackSurfac void OSScreenManager::proc5() {} void OSScreenManager::proc6() {} void OSScreenManager::proc7() {} -void OSScreenManager::proc8() {} + +CVideoSurface *OSScreenManager::getSurface(int surfaceNum) const { + if (surfaceNum == -1) + return _frontRenderSurface; + else if (surfaceNum >= 0 && surfaceNum < (int)_backSurfaces.size()) + return _backSurfaces[surfaceNum]; + else + return nullptr; +} + void OSScreenManager::proc9() {} void OSScreenManager::proc10() {} void OSScreenManager::proc11() {} diff --git a/engines/titanic/screen_manager.h b/engines/titanic/screen_manager.h index caaefc87a6..1be2de9a8c 100644 --- a/engines/titanic/screen_manager.h +++ b/engines/titanic/screen_manager.h @@ -28,6 +28,7 @@ #include "titanic/direct_draw.h" #include "titanic/font.h" #include "titanic/input_handler.h" +#include "titanic/mouse_cursor.h" #include "titanic/video_surface.h" #include "titanic/core/resource_key.h" @@ -48,11 +49,6 @@ public: CScreenManagerRec(); }; -struct MouseCursor { - void show() {} - void hide() {} -}; - class CScreenManager { protected: TitanicEngine *_vm; @@ -68,7 +64,7 @@ public: Common::Array<CVideoSurface *> _backSurfaces; CVideoSurface *_frontRenderSurface; CScreenManagerRec _entries[2]; - MouseCursor *_mouseCursor; + CMouseCursor *_mouseCursor; void *_textCursor; CInputHandler *_inputHandler; int _fontNumber; @@ -79,15 +75,13 @@ public: void fn1() {} void fn2() {} - - virtual void setWindowHandle(int v); virtual bool resetWindowHandle(int v); virtual void setMode(int width, int height, int bpp, uint numBackSurfaces, bool flag2) = 0; virtual void proc5() = 0; virtual void proc6() = 0; virtual void proc7() = 0; - virtual void proc8() = 0; + virtual CVideoSurface *getSurface(int surfaceNum) const = 0; virtual void proc9() = 0; virtual void proc10() = 0; virtual void proc11() = 0; @@ -153,7 +147,7 @@ public: virtual void proc5(); virtual void proc6(); virtual void proc7(); - virtual void proc8(); + virtual CVideoSurface *getSurface(int surfaceNum) const; virtual void proc9(); virtual void proc10(); virtual void proc11(); |