diff options
author | Paul Gilbert | 2016-04-19 21:23:52 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-10 16:11:36 -0400 |
commit | a6e76530b248c6ad61aac0fc4496e126ca6cd77b (patch) | |
tree | 15bfad954c042b2225c41711ae28c49637578075 | |
parent | 5e16f0b6b3da1e06bb3bc25c65f6e10536760291 (diff) | |
download | scummvm-rg350-a6e76530b248c6ad61aac0fc4496e126ca6cd77b.tar.gz scummvm-rg350-a6e76530b248c6ad61aac0fc4496e126ca6cd77b.tar.bz2 scummvm-rg350-a6e76530b248c6ad61aac0fc4496e126ca6cd77b.zip |
TITANIC: Implement RealLife tab setup
-rw-r--r-- | engines/titanic/pet_control/pet_element.cpp | 8 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_element.h | 10 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_glyphs.cpp | 12 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_glyphs.h | 22 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_inventory.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_quit.cpp | 27 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_quit.h | 14 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_real_life.cpp | 23 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_real_life.h | 5 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_sound.h | 4 |
10 files changed, 99 insertions, 28 deletions
diff --git a/engines/titanic/pet_control/pet_element.cpp b/engines/titanic/pet_control/pet_element.cpp index 48c853cfc8..032e7fc7a0 100644 --- a/engines/titanic/pet_control/pet_element.cpp +++ b/engines/titanic/pet_control/pet_element.cpp @@ -33,7 +33,7 @@ void CPetElement::getBounds(Rect *rect) { *rect = Rect(); } -bool CPetElement::proc6(const Common::Point &pt) { +bool CPetElement::proc6(const Point &pt) { bool result = _bounds.contains(pt); if (result) setMode(MODE_SELECTED); @@ -47,18 +47,18 @@ bool CPetElement::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { return result; } -bool CPetElement::contains1(const Common::Point &pt) const { +bool CPetElement::contains1(const Point &pt) const { return _bounds.contains(pt); } -int CPetElement::proc9(const Common::Point &pt) { +int CPetElement::proc9(const Point &pt) { bool result = _bounds.contains(pt); if (result) setMode(MODE_2); return result; } -bool CPetElement::contains2(const Common::Point &pt) const { +bool CPetElement::contains2(const Point &pt) const { return _bounds.contains(pt); } diff --git a/engines/titanic/pet_control/pet_element.h b/engines/titanic/pet_control/pet_element.h index a8f5000155..8aec1fbcf6 100644 --- a/engines/titanic/pet_control/pet_element.h +++ b/engines/titanic/pet_control/pet_element.h @@ -62,27 +62,27 @@ public: /** * Draw the item */ - virtual void draw(CScreenManager *screenManager, const Common::Point &destPos) {} + virtual void draw(CScreenManager *screenManager, const Point &destPos) {} /** * Get the bounds for the element */ virtual void getBounds(Rect *rect); - virtual bool proc6(const Common::Point &pt); + virtual bool proc6(const Point &pt); virtual bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); /** * Returns whether the passed point falls inside the item */ - virtual bool contains1(const Common::Point &pt) const; + virtual bool contains1(const Point &pt) const; - virtual int proc9(const Common::Point &pt); + virtual int proc9(const Point &pt); /** * Returns whether the passed point falls inside the item */ - virtual bool contains2(const Common::Point &pt) const; + virtual bool contains2(const Point &pt) const; /** * Plays back a range of frames in the loaded video file for the element diff --git a/engines/titanic/pet_control/pet_glyphs.cpp b/engines/titanic/pet_control/pet_glyphs.cpp index b121a17288..9e588bfed9 100644 --- a/engines/titanic/pet_control/pet_glyphs.cpp +++ b/engines/titanic/pet_control/pet_glyphs.cpp @@ -30,17 +30,17 @@ void CPetGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { _owner = owner; } -void CPetGlyph::drawAt(CScreenManager *screenManager, int x, int y) { - _element.translate(x, y); +void CPetGlyph::drawAt(CScreenManager *screenManager, const Point &pt) { + _element.translate(pt.x, pt.y); _element.draw(screenManager); - _element.translate(-x, -y); + _element.translate(-pt.x, -pt.y); } void CPetGlyph::proc14() { warning("TODO: CPetGlyph::proc14"); } -bool CPetGlyph::translateContains(const Point &delta, const Point &pt) { +bool CPetGlyph::contains(const Point &delta, const Point &pt) { translate(delta); bool result = _element.contains2(pt); translateBack(delta); @@ -138,7 +138,7 @@ void CPetGlyphs::draw(CScreenManager *screenManager) { if (glyph) { // TODO: Comparison with highlighted index, and a redundant push? - glyph->drawAt(screenManager, pt.x, pt.y); + glyph->drawAt(screenManager, pt); } } } @@ -153,7 +153,7 @@ void CPetGlyphs::draw(CScreenManager *screenManager) { if (_highlightIndex != -1) { CPetGlyph *glyph = getGlyph(_highlightIndex); if (glyph) - glyph->drawHighlight(); + glyph->draw2(screenManager); } } diff --git a/engines/titanic/pet_control/pet_glyphs.h b/engines/titanic/pet_control/pet_glyphs.h index 2360bfa13d..48351c9e44 100644 --- a/engines/titanic/pet_control/pet_glyphs.h +++ b/engines/titanic/pet_control/pet_glyphs.h @@ -33,6 +33,7 @@ namespace Titanic { class CPetGlyphs; class CPetSection; +class CPetText; enum GlyphActionMode { ACTION_REMOVE = 0, ACTION_REMOVED = 1, ACTION_CHANGE = 2 }; @@ -92,15 +93,14 @@ public: virtual void proc11() {} /** - * Draw the glyph at a translated position without permanently - * changing the position + * Draw the glyph at a specified position */ - virtual void drawAt(CScreenManager *screenManager, int x, int y); + virtual void drawAt(CScreenManager *screenManager, const Point &pt); /** - * Handles any secondary drawing of a glyph as highlighted + * Handles any secondary drawing of the glyph */ - virtual void drawHighlight() {} + virtual void draw2(CScreenManager *screenManager) {} virtual void proc14(); @@ -113,7 +113,7 @@ public: virtual int proc17() { return 0; } virtual int proc18() { return 0; } virtual int proc19() { return 0; } - virtual int proc20() { return 0; } + virtual bool MouseButtonDownMsg(CMouseButtonDownMsg *msg) { return false; } virtual int proc21() { return 0; } virtual int proc22() { return 0; } virtual int proc23() { return 0; } @@ -125,12 +125,16 @@ public: virtual int proc29() { return 0; } /** - * Returns true if the glyph's bounds, shifted by a given delta, + * Returns true if the glyph's bounds, shifted to a given position, * will contain the specified point */ - virtual bool translateContains(const Point &delta, const Point &pt); + virtual bool contains(const Point &delta, const Point &pt); + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text) {} - virtual void proc31() {} virtual void proc32() {} virtual int proc33() { return 1; } diff --git a/engines/titanic/pet_control/pet_inventory.cpp b/engines/titanic/pet_control/pet_inventory.cpp index 9a3ee83be2..063f019655 100644 --- a/engines/titanic/pet_control/pet_inventory.cpp +++ b/engines/titanic/pet_control/pet_inventory.cpp @@ -148,7 +148,7 @@ int CPetInventory::getItemIndex(CGameObject *item) const { CGameObject *CPetInventory::getImage(int index) { if (index >= 0 && index < 46) { int offset = index - 20; - int bits; + int bits = 0; switch (offset) { case 0: bits = 4; diff --git a/engines/titanic/pet_control/pet_quit.cpp b/engines/titanic/pet_control/pet_quit.cpp index c489fd9d5b..562a63f80c 100644 --- a/engines/titanic/pet_control/pet_quit.cpp +++ b/engines/titanic/pet_control/pet_quit.cpp @@ -21,8 +21,10 @@ */ #include "titanic/pet_control/pet_quit.h" +#include "titanic/pet_control/pet_control.h" #include "titanic/pet_control/pet_real_life.h" #include "titanic/support/rect.h" +#include "titanic/game_manager.h" namespace Titanic { @@ -57,4 +59,29 @@ bool CPetQuit::reset() { return true; } +void CPetQuit::draw2(CScreenManager *screenManager) { + _text.draw(screenManager); + _btnYes.draw(screenManager); +} + +bool CPetQuit::proc16(const Point &pt) { + return !_btnYes.proc6(pt); +} + +bool CPetQuit::mouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CPetControl *pet = getPetControl(); + if (_btnYes.MouseButtonDownMsg(msg) && pet) { + CGameManager *gameManager = pet->getGameManager(); + if (gameManager) + gameManager->_gameState._quitGame = true; + return true; + } else { + return false; + } +} + +void CPetQuit::getTooltip(CPetText *text) { + text->setText("Quit the game."); +} + } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_quit.h b/engines/titanic/pet_control/pet_quit.h index e1551dcb36..ca207f616a 100644 --- a/engines/titanic/pet_control/pet_quit.h +++ b/engines/titanic/pet_control/pet_quit.h @@ -43,6 +43,20 @@ public: * Reset the glyph */ virtual bool reset(); + + /** + * Handles any secondary drawing of the glyph + */ + virtual void draw2(CScreenManager *screenManager); + + virtual bool proc16(const Point &pt); + + virtual bool mouseButtonDownMsg(CMouseButtonDownMsg *msg); + + /** + * Returns the tooltip text for when the glyph is selected + */ + virtual void getTooltip(CPetText *text); }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_real_life.cpp b/engines/titanic/pet_control/pet_real_life.cpp index 0c7c4bd51f..8d439e9cc1 100644 --- a/engines/titanic/pet_control/pet_real_life.cpp +++ b/engines/titanic/pet_control/pet_real_life.cpp @@ -22,6 +22,10 @@ #include "titanic/pet_control/pet_real_life.h" #include "titanic/pet_control/pet_control.h" +#include "titanic/pet_control/pet_load.h" +#include "titanic/pet_control/pet_save.h" +#include "titanic/pet_control/pet_sound.h" +#include "titanic/pet_control/pet_quit.h" namespace Titanic { @@ -43,15 +47,34 @@ void CPetRealLife::draw(CScreenManager *screenManager) { bool CPetRealLife::setupControl(CPetControl *petControl) { if (petControl) { + _petControl = petControl; + _glyphs.setup(4, this); + _glyphs.set20(6); + addButton(new CPetLoad()); + addButton(new CPetSave()); + addButton(new CPetSound()); + addButton(new CPetQuit()); + + Rect textRect(0, 0, 32, 436); + textRect.moveTo(32, 436); + _text.setBounds(textRect); + _text.setHasBorder(false); + _text.setup(); } return true; } +void CPetRealLife::addButton(CPetGlyph *glyph) { + +} + bool CPetRealLife::isValid(CPetControl *petControl) { setupControl(petControl); return true; } + + } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_real_life.h b/engines/titanic/pet_control/pet_real_life.h index 6281735e33..c4c597c45f 100644 --- a/engines/titanic/pet_control/pet_real_life.h +++ b/engines/titanic/pet_control/pet_real_life.h @@ -41,6 +41,11 @@ private: * Does setup */ bool setupControl(CPetControl *petControl); + + /** + * Adds one of the four button glyphs for display + */ + void addButton(CPetGlyph *glyph); public: virtual ~CPetRealLife() {} diff --git a/engines/titanic/pet_control/pet_sound.h b/engines/titanic/pet_control/pet_sound.h index d0a0fe19ae..fcd8e9a1d9 100644 --- a/engines/titanic/pet_control/pet_sound.h +++ b/engines/titanic/pet_control/pet_sound.h @@ -29,10 +29,8 @@ namespace Titanic { -class CPetQuit : public CPetGlyph { +class CPetSound : public CPetGlyph { private: - CPetControlSub12 _sub12; - CPetGfxElement _element; public: }; |