diff options
author | Paul Gilbert | 2016-04-16 22:58:37 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-10 16:11:17 -0400 |
commit | 066dd4f5cd1b0f5408cd0da5ef9050a738edc4b0 (patch) | |
tree | 0dbcec8b2a4be49c874eb87badcb5535f55053d4 /engines/titanic | |
parent | daaa458d64df42f113b7badd65cdfaf0da0504ff (diff) | |
download | scummvm-rg350-066dd4f5cd1b0f5408cd0da5ef9050a738edc4b0.tar.gz scummvm-rg350-066dd4f5cd1b0f5408cd0da5ef9050a738edc4b0.tar.bz2 scummvm-rg350-066dd4f5cd1b0f5408cd0da5ef9050a738edc4b0.zip |
TITANIC: Implementing PET inventory population
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/core/game_object.cpp | 5 | ||||
-rw-r--r-- | engines/titanic/core/game_object.h | 13 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_control_sub11.h | 2 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_element.cpp | 4 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_element.h | 5 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_glyphs.cpp | 82 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_glyphs.h | 152 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_inventory.cpp | 11 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_inventory_glyphs.cpp | 116 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_inventory_glyphs.h | 59 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_remote.h | 2 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_saves.h | 2 | ||||
-rw-r--r-- | engines/titanic/support/movie.cpp | 6 | ||||
-rw-r--r-- | engines/titanic/support/movie.h | 14 | ||||
-rw-r--r-- | engines/titanic/titanic.cpp | 6 | ||||
-rw-r--r-- | engines/titanic/titanic.h | 2 |
16 files changed, 398 insertions, 83 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index 7549797ca9..d2af519fcd 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -442,9 +442,9 @@ bool CGameObject::hasActiveMovie() const { return false; } -int CGameObject::getMovie19() const { +int CGameObject::getMovieFrame() const { if (_surface && _surface->_movie) - return _surface->_movie->proc19(); + return _surface->_movie->getFrame(); return _initialFrame; } @@ -718,6 +718,7 @@ bool CGameObject::changeView(const CString &viewName, const CString &clipName) { } gameManager->_gameState.changeView(newView, clip); + return true; } } // End of namespace Titanic diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h index 430f70521e..b987606a4c 100644 --- a/engines/titanic/core/game_object.h +++ b/engines/titanic/core/game_object.h @@ -274,7 +274,11 @@ public: */ bool hasActiveMovie() const; - int getMovie19() const; + /** + * Get the current movie frame + */ + int getMovieFrame() const; + int getSurface45() const; void sound8(bool flag) const; @@ -311,7 +315,12 @@ public: /** * Moves the item from it's original position to be under the hidden room */ - void moveToHiddenRoom(); + void moveToHiddenRoom(); + + /** + * Returns the object's frame number + */ + int getFrameNumber() const { return _frameNumber; } }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_control_sub11.h b/engines/titanic/pet_control/pet_control_sub11.h index e3f8c3d493..eeeb8bf2c8 100644 --- a/engines/titanic/pet_control/pet_control_sub11.h +++ b/engines/titanic/pet_control/pet_control_sub11.h @@ -27,7 +27,7 @@ namespace Titanic { -class CPetControlSub11 : public CPetGlyphs<CPetGlyph> { +class CPetControlSub11 : public CPetGlyphs { public: }; diff --git a/engines/titanic/pet_control/pet_element.cpp b/engines/titanic/pet_control/pet_element.cpp index 625415fb62..48c853cfc8 100644 --- a/engines/titanic/pet_control/pet_element.cpp +++ b/engines/titanic/pet_control/pet_element.cpp @@ -87,9 +87,9 @@ void CPetElement::loadFrame(int frameNumber) { gameObject->loadFrame(frameNumber); } -int CPetElement::proc15() { +int CPetElement::getFrame() { CGameObject *gameObject = getObject(); - return gameObject ? gameObject->getMovie19() : 0; + return gameObject ? gameObject->getMovieFrame() : 0; } void CPetElement::setMode(PetElementMode newMode) { diff --git a/engines/titanic/pet_control/pet_element.h b/engines/titanic/pet_control/pet_element.h index de9f552ec8..d4ca580349 100644 --- a/engines/titanic/pet_control/pet_element.h +++ b/engines/titanic/pet_control/pet_element.h @@ -104,7 +104,10 @@ public: */ virtual void loadFrame(int frameNumber); - virtual int proc15(); + /** + * Get the current frame + */ + virtual int getFrame(); /** * Get the game object associated with this item diff --git a/engines/titanic/pet_control/pet_glyphs.cpp b/engines/titanic/pet_control/pet_glyphs.cpp new file mode 100644 index 0000000000..057025c03d --- /dev/null +++ b/engines/titanic/pet_control/pet_glyphs.cpp @@ -0,0 +1,82 @@ +/* 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 "titanic/pet_control/pet_glyphs.h" + +namespace Titanic { + +void CPetGlyph::setOwner(CPetControl *petControl, CPetGlyphs *owner) { + _element.setBounds(Rect(0, 0, 52, 50)); + _owner = owner; +} + +void CPetGlyph::translateDraw(CScreenManager *screenManager, int deltaX, int deltaY) { + _element.translate(deltaX, deltaY); + _element.draw(screenManager); + _element.translate(-deltaX, -deltaY); +} + +void CPetGlyph::proc14() { + warning("TODO: CPetGlyph::proc14"); +} + +bool CPetGlyph::translateContains(const Point &delta, const Point &pt) { + translate(delta); + bool result = _element.contains2(pt); + translateBack(delta); + + return result; +} + +/*------------------------------------------------------------------------*/ + +void CPetGlyphs::clear() { + fn1(-1); + destroyContents(); + _field10 = 0; +} + +void CPetGlyphs::proc8() { + error("TODO"); +} + +void CPetGlyphs::setup() { + warning("TODO: CPetGlyphs::setup"); +} + +void CPetGlyphs::proc10() { + error("TODO"); +} + +void CPetGlyphs::proc11() { + error("TODO"); +} + +void CPetGlyphs::draw(CScreenManager *screenManager) { + warning("TODO: CPetGlyphs::draw"); +} + +void CPetGlyphs::fn1(int val) { + warning("TODO: CPetGlyphs::fn1"); +} + +} // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_glyphs.h b/engines/titanic/pet_control/pet_glyphs.h new file mode 100644 index 0000000000..796b165e92 --- /dev/null +++ b/engines/titanic/pet_control/pet_glyphs.h @@ -0,0 +1,152 @@ +/* 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_PET_GLYPHS_H +#define TITANIC_PET_GLYPHS_H + +#include "titanic/core/list.h" +#include "titanic/pet_control/pet_gfx_element.h" +#include "titanic/support/rect.h" + +namespace Titanic { + +class CPetGlyphs; + +class CPetGlyph : public ListItem { +public: + CPetGfxElement _element; + CPetGlyphs *_owner; +public: + CPetGlyph() : ListItem(), _owner(nullptr) {} + + /** + * Translate the glyph's position + */ + void translate(const Point &pt) { _element.translate(pt.x, pt.y); } + + /** + * Translate the glyph's position back + */ + void translateBack(const Point &pt) { _element.translate(-pt.x, -pt.y); } + + /** + * Set the glyph + */ + virtual void setOwner(CPetControl *petControl, CPetGlyphs *owner); + + virtual int proc9() { return 0; } + + virtual void proc10() {} + virtual void proc11() {} + + /** + * Draw the glyph at a translated position without permanently + * changing the position + */ + virtual void translateDraw(CScreenManager *screenManager, int deltaX, int deltaY); + + virtual void proc13() {} + + virtual void proc14(); + + /** + * Get the bounds for the glyph + */ + virtual Rect getBounds() { return Rect(); } + + virtual int proc16() { return 0; } + virtual int proc17() { return 0; } + virtual int proc18() { return 0; } + virtual int proc19() { return 0; } + virtual int proc20() { return 0; } + virtual int proc21() { return 0; } + virtual int proc22() { return 0; } + virtual int proc23() { return 0; } + virtual int proc24() { return 0; } + virtual void proc25() {} + virtual void proc26() {} + virtual void proc27() {} + virtual void proc28() {} + virtual int proc29() { return 0; } + + /** + * Returns true if the glyph's bounds, shifted by a given delta, + * will contain the specified point + */ + virtual bool translateContains(const Point &delta, const Point &pt); + + virtual void proc31() {} + virtual void proc32() {} + + virtual int proc33() { return 1; } + virtual int proc34() { return 1; } + virtual int proc35() { return 0; } + virtual void proc36() {} + virtual int proc37() { return 0; } + virtual int proc38() { return 1; } +}; + +class CPetGlyphs : public List<CPetGlyph> { +protected: + int _field10; + int _field14; + int _field18; + int _field1C; + int _field20; + int _field24; + CPetGfxElement _selection; + CPetGfxElement _scrollLeft; + CPetGfxElement _scrollRight; +protected: + void fn1(int val); +public: + CPetGlyphs::CPetGlyphs() : _field10(0), _field14(7), + _field18(-1), _field1C(-1), _field20(0), _field24(0) { + } + + /** + * Clears the glyph list + */ + void clear(); + + + virtual void proc8(); + + /** + * Set up the control + */ + virtual void setup(); + + virtual void proc10(); + virtual void proc11(); + + void set20(int val) { _field20 = val; } + + /** + * Draw the control + */ + void draw(CScreenManager *screenManager); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_PET_GLYPHS_H */ diff --git a/engines/titanic/pet_control/pet_inventory.cpp b/engines/titanic/pet_control/pet_inventory.cpp index 89eb692a7e..f143e24ecb 100644 --- a/engines/titanic/pet_control/pet_inventory.cpp +++ b/engines/titanic/pet_control/pet_inventory.cpp @@ -22,6 +22,7 @@ #include "titanic/pet_control/pet_inventory.h" #include "titanic/pet_control/pet_control.h" +#include "titanic/carry/carry.h" #include "titanic/titanic.h" namespace Titanic { @@ -121,9 +122,15 @@ void CPetInventory::fn3(CCarry *item) { void CPetInventory::itemsChanged() { _items.clear(); - //CGameObject *item = static_cast<CGameObject *>(_petControl->getFirstObject()); - + CGameObject *item = _petControl->getFirstObject(); + while (item) { + CPetInventoryGlyph *glyph = new CPetInventoryGlyph(); + glyph->setOwner(_petControl, &_items); + glyph->setItem(item, _field290); + _items.push_back(glyph); + item = _petControl->getNextObject(item); + } } void CPetInventory::couldntShowInventory(CCarry *item) { diff --git a/engines/titanic/pet_control/pet_inventory_glyphs.cpp b/engines/titanic/pet_control/pet_inventory_glyphs.cpp index 6fc58ff2ad..2614306891 100644 --- a/engines/titanic/pet_control/pet_inventory_glyphs.cpp +++ b/engines/titanic/pet_control/pet_inventory_glyphs.cpp @@ -22,47 +22,117 @@ #include "common/textconsole.h" #include "titanic/pet_control/pet_inventory_glyphs.h" +#include "titanic/titanic.h" namespace Titanic { -CPetInventoryGlyphs::CPetInventoryGlyphs() : _field10(0), _field14(7), - _field18(-1), _field1C(-1), _field20(0), _field24(0) { -} +const uint ITEM_MODES[40] = { + 0, 2, 11, 10, 12, 13, 9, 40, 7, 6, + 4, 5, 8, 15, 19, 24, 25, 26, 30, 20, + 21, 22, 23, 36, 39, 39, 31, 31, 32, 32, + 33, 34, 35, 38, 41, 42, 43, 44, 45, 37 +}; -void CPetInventoryGlyphs::proc8() { - error("TODO"); -} +void CPetInventoryGlyph::setItem(CGameObject *item, int val) { + _item = item; -void CPetInventoryGlyphs::setup() { - warning("TODO: CPetInventoryGlyphs::setup"); + if (_owner && item) { + int v1 = populateItem(item, val); + _field3C = static_cast<CPetInventoryGlyphs *>(_owner)->fn1(v1); + warning("TODO: CPetInventoryGlyph::setItem"); + } } -void CPetInventoryGlyphs::proc10() { - error("TODO"); -} +int CPetInventoryGlyph::populateItem(CGameObject *item, int val) { + // Scan the master item names list + CString itemName = item->getName(); + int itemIndex = -1; + for (int idx = 0; idx < 40 && itemIndex == -1; ++idx) { + if (itemName == g_vm->_itemIds[idx]) + itemIndex = idx; + } + if (itemIndex == -1) + return -1; -void CPetInventoryGlyphs::proc11() { - error("TODO"); -} + switch (ITEM_MODES[itemIndex]) { + case 0: + switch (subMode(item, val)) { + case 0: + case 1: + return 0; + case 2: + case 3: + return 1; + default: + return 0; + } + + case 2: + switch (subMode(item, val)) { + case 0: + return 2; + default: + return 3; + } + break; + + case 15: + switch (subMode(item, val)) { + case 0: + case 1: + return 14; + case 2: + return 16; + case 3: + return 15; + case 4: + return 17; + case 5: + return 18; + default: + return 15; + } + break; -void CPetInventoryGlyphs::draw(CScreenManager *screenManager) { - warning("TODO: CPetInventoryGlyphs::draw"); + case 26: + switch (subMode(item, val)) { + case 0: + return 26; + case 1: + return 29; + case 2: + return 28; + case 3: + return 27; + default: + return 26; + } + break; + + default: + return ITEM_MODES[itemIndex]; + } } -void CPetInventoryGlyphs::addItem(CPetCarry *item) { +int CPetInventoryGlyph::subMode(CGameObject *item, int val) { + int frameNum = item->getFrameNumber(); + int movieFrame = item->getMovieFrame(); + if (val && frameNum != -1 && frameNum != movieFrame) + item->loadFrame(frameNum); - warning("TODO"); + return frameNum; } -void CPetInventoryGlyphs::clear() { - fn1(-1); - destroyContents(); - _field10 = 0; +/*------------------------------------------------------------------------*/ + +void CPetInventoryGlyphs::addItem(CPetCarry *item) { + } -void CPetInventoryGlyphs::fn1(int val) { +int CPetInventoryGlyphs::fn1(int val) { warning("TODO: CPetInventoryGlyphs::fn1"); + return 0; } } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_inventory_glyphs.h b/engines/titanic/pet_control/pet_inventory_glyphs.h index f8d4d7f2fa..8c483ea60c 100644 --- a/engines/titanic/pet_control/pet_inventory_glyphs.h +++ b/engines/titanic/pet_control/pet_inventory_glyphs.h @@ -23,21 +23,35 @@ #ifndef TITANIC_PET_INVENTORY_GLYPHS_H #define TITANIC_PET_INVENTORY_GLYPHS_H +#include "titanic/carry/carry.h" #include "titanic/pet_control/pet_glyphs.h" #include "titanic/support/screen_manager.h" namespace Titanic { class CPetInventoryGlyph : public CPetGlyph { +private: + /** + * Populate the details for an item + */ + int populateItem(CGameObject *item, int val); + + int subMode(CGameObject *item, int val); public: - CCarry *_item; + CGameObject *_item; int _field34; - int _field38; int _field3C; int _field40; public: + CPetInventoryGlyph() : _item(nullptr), _field34(0), + _field3C(0), _field40(0) {} CPetInventoryGlyph(CCarry *item, int val) : _item(item), - _field34(val), _field38(0), _field3C(0), _field40(0) {} + _field34(val), _field3C(0), _field40(0) {} + + /** + * Set the inventory item + */ + void setItem(CGameObject *item, int val); }; class CPetCarry { @@ -48,48 +62,15 @@ public: CPetCarry(CCarry *item, int val) : _item(item), _val(val) {} }; -class CPetInventoryGlyphs : public CPetGlyphs<CPetInventoryGlyph> { +class CPetInventoryGlyphs : public CPetGlyphs { + friend class CPetInventoryGlyph; private: - void fn1(int val); -protected: - int _field10; - int _field14; - int _field18; - int _field1C; - int _field20; - int _field24; - CPetGfxElement _selection; - CPetGfxElement _scrollLeft; - CPetGfxElement _scrollRight; + int fn1(int val); public: - CPetInventoryGlyphs(); - - virtual void proc8(); - - /** - * Set up the control - */ - virtual void setup(); - - virtual void proc10(); - virtual void proc11(); - - void set20(int val) { _field20 = val; } - - /** - * Draw the control - */ - void draw(CScreenManager *screenManager); - /** * Add a new item to the list */ void addItem(CPetCarry *item); - - /** - * Clears the glyph list - */ - void clear(); }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_remote.h b/engines/titanic/pet_control/pet_remote.h index 953f012e67..85cff3fe4f 100644 --- a/engines/titanic/pet_control/pet_remote.h +++ b/engines/titanic/pet_control/pet_remote.h @@ -30,7 +30,7 @@ namespace Titanic { -class CPetRemoteGlyphs : public CPetGlyphs<CPetGlyph> { +class CPetRemoteGlyphs : public CPetGlyphs { }; class CPetRemote : public CPetSection { diff --git a/engines/titanic/pet_control/pet_saves.h b/engines/titanic/pet_control/pet_saves.h index d100e8f702..8366ab6dda 100644 --- a/engines/titanic/pet_control/pet_saves.h +++ b/engines/titanic/pet_control/pet_saves.h @@ -29,7 +29,7 @@ namespace Titanic { -class CPetSaveGlyphs : public CPetGlyphs<CPetGlyph> { +class CPetSaveGlyphs : public CPetGlyphs { }; class CPetSaves : public CPetSection { diff --git a/engines/titanic/support/movie.cpp b/engines/titanic/support/movie.cpp index 6f66bec7a7..3ae2636404 100644 --- a/engines/titanic/support/movie.cpp +++ b/engines/titanic/support/movie.cpp @@ -121,9 +121,9 @@ void OSMovie::proc18() { warning("TODO: OSMovie::proc18"); } -int OSMovie::proc19() { - warning("TODO: OSMovie::proc19"); - return 0; +int OSMovie::getFrame() { + assert(_video); + return _video->getCurFrame(); } void OSMovie::proc20() { diff --git a/engines/titanic/support/movie.h b/engines/titanic/support/movie.h index a871af6fc7..644f582d64 100644 --- a/engines/titanic/support/movie.h +++ b/engines/titanic/support/movie.h @@ -73,7 +73,12 @@ public: virtual void proc16() = 0; virtual void proc17() = 0; virtual void proc18() = 0; - virtual int proc19() = 0; + + /** + * Get the current movie frame + */ + virtual int getFrame() = 0; + virtual void proc20() = 0; virtual void *proc21() = 0; @@ -131,7 +136,12 @@ public: virtual void proc16(); virtual void proc17(); virtual void proc18(); - virtual int proc19(); + + /** + * Get the current movie frame + */ + virtual int getFrame(); + virtual void proc20(); virtual void *proc21(); diff --git a/engines/titanic/titanic.cpp b/engines/titanic/titanic.cpp index 8e079d5a60..3660ce18ea 100644 --- a/engines/titanic/titanic.cpp +++ b/engines/titanic/titanic.cpp @@ -157,8 +157,8 @@ void TitanicEngine::setItemNames() { for (uint idx = 0; idx < TOTAL_ITEMS; ++idx) _itemDescriptions[idx] = DESCRIPTIONS[idx]; - // Short descriptions.. maybe? - static const char *const SHORT_DESC[40] = { + // Item identifiers + static const char *const ITEM_IDS[40] = { "MaitreD Left Arm", "MaitreD Right Arm", "OlfactoryCentre", "AuditoryCentre", "SpeechCentre", "VisionCentre", "CentralCore", "Perch", "SeasonBridge", "FanBridge", "BeamBridge", "ChickenBridge", "CarryParrot", "Chicken", @@ -169,7 +169,7 @@ void TitanicEngine::setItemNames() { "Phonograph Cylinder 3", "Photograph", "Music System Key" }; for (uint idx = 0; idx < 40; ++idx) - _itemShortDesc[idx] = SHORT_DESC[idx]; + _itemIds[idx] = ITEM_IDS[idx]; } diff --git a/engines/titanic/titanic.h b/engines/titanic/titanic.h index f83e728ca3..f639a9c672 100644 --- a/engines/titanic/titanic.h +++ b/engines/titanic/titanic.h @@ -114,7 +114,7 @@ public: CString _itemNames[TOTAL_ITEMS]; CString _itemDescriptions[TOTAL_ITEMS]; CString _itemObjects[TOTAL_ITEMS]; - CString _itemShortDesc[40]; + CString _itemIds[40]; public: TitanicEngine(OSystem *syst, const TitanicGameDescription *gameDesc); virtual ~TitanicEngine(); |