diff options
author | Paul Gilbert | 2016-05-01 09:24:42 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-10 16:37:58 -0400 |
commit | 6b97394ebd577326c8818cfa02b08c119beab8c0 (patch) | |
tree | cb7f4856c924806974e6986043ad46d63a0d79ac /engines/titanic/pet_control | |
parent | ad02fa76e0bbb81f28610a100aa988f082067c71 (diff) | |
download | scummvm-rg350-6b97394ebd577326c8818cfa02b08c119beab8c0.tar.gz scummvm-rg350-6b97394ebd577326c8818cfa02b08c119beab8c0.tar.bz2 scummvm-rg350-6b97394ebd577326c8818cfa02b08c119beab8c0.zip |
TITANIC: Fully implement PET Rooms loading/saving
Diffstat (limited to 'engines/titanic/pet_control')
-rw-r--r-- | engines/titanic/pet_control/pet_glyphs.cpp | 14 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_glyphs.h | 12 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_rooms.cpp | 20 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_rooms.h | 5 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_rooms_glyphs.cpp | 12 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_rooms_glyphs.h | 10 |
6 files changed, 58 insertions, 15 deletions
diff --git a/engines/titanic/pet_control/pet_glyphs.cpp b/engines/titanic/pet_control/pet_glyphs.cpp index 96e61c9d48..d1cb384729 100644 --- a/engines/titanic/pet_control/pet_glyphs.cpp +++ b/engines/titanic/pet_control/pet_glyphs.cpp @@ -222,6 +222,10 @@ void CPetGlyphs::highlight(int index) { warning("TODO: CPetGlyphs::highlight"); } +void CPetGlyphs::highlight(const CPetGlyph *glyph) { + highlight(indexOf(glyph)); +} + int CPetGlyphs::getHighlightedIndex(int index) { int idx = index - _firstVisibleIndex; return (idx >= 0 && idx < _numVisibleGlyphs) ? idx : -1; @@ -445,4 +449,14 @@ bool CPetGlyphs::highlighted14() { return false; } +int CPetGlyphs::indexOf(const CPetGlyph *glyph) const { + int index = 0; + for (const_iterator i = begin(); i != end(); ++i, ++index) { + if (*i == glyph) + return index; + } + + return -1; +} + } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_glyphs.h b/engines/titanic/pet_control/pet_glyphs.h index 0163f39a7e..2aa80db41b 100644 --- a/engines/titanic/pet_control/pet_glyphs.h +++ b/engines/titanic/pet_control/pet_glyphs.h @@ -321,11 +321,16 @@ public: void draw(CScreenManager *screenManager); /** - * Highlight a specific glyph + * Highlight a specific glyph by indexe */ void highlight(int index); /** + * Highlight a specific glyph + */ + void highlight(const CPetGlyph *glyph); + + /** * Get the owning section for the glyphs */ CPetSection *getOwner() const { return _owner; } @@ -398,6 +403,11 @@ public: void resetHighlight() { changeHighlight(-1); } bool highlighted14(); + + /** + * Returns the index of the specified glyph in the lsit + */ + int indexOf(const CPetGlyph *glyph) const; }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_rooms.cpp b/engines/titanic/pet_control/pet_rooms.cpp index 0a403e66d6..7c2b9fb569 100644 --- a/engines/titanic/pet_control/pet_rooms.cpp +++ b/engines/titanic/pet_control/pet_rooms.cpp @@ -113,9 +113,8 @@ void CPetRooms::load(SimpleFile *file, int param) { int count = file->readNumber(); for (int idx = 0; idx < count; ++idx) { - int v1 = file->readNumber(); - int v2 = file->readNumber(); - warning("TODO: CPetRoomsSection::load - %d,%d", v1, v2); + CPetRoomsGlyph *glyph = addGlyph(file->readNumber(), false); + glyph->set3C(file->readNumber()); } _glyphItem.set34(file->readNumber()); @@ -134,7 +133,7 @@ void CPetRooms::postLoad() { } void CPetRooms::save(SimpleFile *file, int indent) const { - _glyphs.save(file, indent); + _glyphs.save2(file, indent); _glyphItem.save2(file, indent); file->writeNumberLine(_field1C0, indent); file->writeNumberLine(_field1C4, indent); @@ -208,4 +207,17 @@ void CPetRooms::areaChanged(PetArea area) { _petControl->makeDirty(); } +CPetRoomsGlyph *CPetRooms::addGlyph(int val, bool highlight) { + CPetRoomsGlyph *glyph = new CPetRoomsGlyph(val); + if (!glyph->setup(_petControl, &_glyphs)) { + delete glyph; + return nullptr; + } else { + _glyphs.push_back(glyph); + if (highlight) + _glyphs.highlight(glyph); + } +} + + } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_rooms.h b/engines/titanic/pet_control/pet_rooms.h index 4c153d7fad..a0fd3e92cb 100644 --- a/engines/titanic/pet_control/pet_rooms.h +++ b/engines/titanic/pet_control/pet_rooms.h @@ -68,6 +68,11 @@ private: int fn1(); void areaChanged(PetArea area); + + /** + * Adds a glyph to the list + */ + CPetRoomsGlyph *addGlyph(int val, bool highlight); public: CPetRooms(); diff --git a/engines/titanic/pet_control/pet_rooms_glyphs.cpp b/engines/titanic/pet_control/pet_rooms_glyphs.cpp index 6b762d890b..57c6e8568c 100644 --- a/engines/titanic/pet_control/pet_rooms_glyphs.cpp +++ b/engines/titanic/pet_control/pet_rooms_glyphs.cpp @@ -32,12 +32,10 @@ CPetRoomsGlyph::CPetRoomsGlyph() : CPetGlyph(), _field50(nullptr), _field54(nullptr), _field58(nullptr), _field5C(nullptr) { } -void CPetRoomsGlyph::set34(int val) { - _field34 = val; -} - -void CPetRoomsGlyph::set38(int val) { - _field38 = val; +CPetRoomsGlyph::CPetRoomsGlyph(int val) : CPetGlyph(), + _field34(val), _field38(0), _field3C(0), + _field40(nullptr), _field44(nullptr), _field48(nullptr), _field4C(nullptr), + _field50(nullptr), _field54(nullptr), _field58(nullptr), _field5C(nullptr) { } bool CPetRoomsGlyph::setup(CPetControl *petControl, CPetGlyphs *owner) { @@ -87,7 +85,7 @@ void CPetRoomsGlyph::proc39() { /*------------------------------------------------------------------------*/ -void CPetRoomsGlyphs::save(SimpleFile *file, int indent) const { +void CPetRoomsGlyphs::save2(SimpleFile *file, int indent) const { file->writeNumberLine(size(), indent); for (const_iterator i = begin(); i != end(); ++i) diff --git a/engines/titanic/pet_control/pet_rooms_glyphs.h b/engines/titanic/pet_control/pet_rooms_glyphs.h index 2e8ede2287..3f37bdb55d 100644 --- a/engines/titanic/pet_control/pet_rooms_glyphs.h +++ b/engines/titanic/pet_control/pet_rooms_glyphs.h @@ -42,10 +42,13 @@ protected: CGameObject *_field5C; public: CPetRoomsGlyph(); + CPetRoomsGlyph(int val); - void set34(int val); + void set34(int val) { _field34 = val; } - void set38(int val); + void set38(int val) { _field38 = val; } + + void set3C(int val) { _field3C = val; } /** * Setup the glyph @@ -77,11 +80,12 @@ public: }; class CPetRoomsGlyphs : public CPetGlyphs { +private: public: /** * Save the list */ - void save(SimpleFile *file, int indent) const; + void save2(SimpleFile *file, int indent) const; }; } // End of namespace Titanic |