diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/pet_control/pet_control_sub10.cpp | 4 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_control_sub10.h | 15 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_control_sub12.cpp | 41 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_control_sub12.h | 22 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_inventory.cpp | 46 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_inventory.h | 22 | ||||
-rw-r--r-- | engines/titanic/titanic.cpp | 8 | ||||
-rw-r--r-- | engines/titanic/titanic.h | 7 |
8 files changed, 138 insertions, 27 deletions
diff --git a/engines/titanic/pet_control/pet_control_sub10.cpp b/engines/titanic/pet_control/pet_control_sub10.cpp index 226ac4ec8b..59b9648fc1 100644 --- a/engines/titanic/pet_control/pet_control_sub10.cpp +++ b/engines/titanic/pet_control/pet_control_sub10.cpp @@ -33,8 +33,8 @@ void CPetControlSub10::proc8() { error("TODO"); } -void CPetControlSub10::proc9() { - error("TODO"); +void CPetControlSub10::setup() { + warning("TODO: CPetControlSub10::setup"); } void CPetControlSub10::proc10() { diff --git a/engines/titanic/pet_control/pet_control_sub10.h b/engines/titanic/pet_control/pet_control_sub10.h index e31937865b..625100a25f 100644 --- a/engines/titanic/pet_control/pet_control_sub10.h +++ b/engines/titanic/pet_control/pet_control_sub10.h @@ -37,16 +37,23 @@ protected: int _field1C; int _field20; int _field24; - CPetGfxElement _val1; - CPetGfxElement _val2; - CPetGfxElement _val3; + CPetGfxElement _selection; + CPetGfxElement _scrollLeft; + CPetGfxElement _scrollRight; public: CPetControlSub10(); virtual void proc8(); - virtual void proc9(); + + /** + * Set up the control + */ + virtual void setup(); + virtual void proc10(); virtual void proc11(); + + void set20(int val) { _field20 = val; } }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_control_sub12.cpp b/engines/titanic/pet_control/pet_control_sub12.cpp index 5daf826ae6..2bba6747b9 100644 --- a/engines/titanic/pet_control/pet_control_sub12.cpp +++ b/engines/titanic/pet_control/pet_control_sub12.cpp @@ -25,8 +25,7 @@ namespace Titanic { CPetControlSub12::CPetControlSub12(int count) : - _field18(0), _field1C(0), _field20(0), _field24(0), - _field28(0), _field30(-1), _field34(0), _field38(-1), + _field18(0), _field30(-1), _field34(0), _field38(-1), _field3C(0), _field40(0), _field44(0), _field48(0xff), _field4C(0xff), _field50(0xff), _field54(0), _field58(0), _field5C(200), _field60(0), _field64(0), _field68(0), @@ -46,15 +45,44 @@ void CPetControlSub12::freeArrays() { _array.clear(); } +void CPetControlSub12::setup() { + for (int idx = 0; idx < (int)_array.size(); ++idx) { + _array[idx]._string1.clear(); + setArrayStr2(idx, _field54, _field58, _field5C); + _array[idx]._string3.clear(); + } + + _field34 = 0; + _field18 = 0; +} + +void CPetControlSub12::setArrayStr2(uint idx, int val1, int val2, int val3) { + char buffer[6]; + if (!val1) + val1 = 1; + if (!val2) + val2 = 1; + if (!val3) + val3 = 1; + + buffer[0] = 27; + buffer[1] = val1; + buffer[2] = val2; + buffer[3] = val3; + buffer[4] = 27; + buffer[5] = '\0'; + _array[idx]._string2 = buffer; +} + void CPetControlSub12::load(SimpleFile *file, int param) { if (!param) { int var1 = file->readNumber(); int var2 = file->readNumber(); uint count = file->readNumber(); - _field1C = file->readNumber(); - _field20 = file->readNumber(); - _field24 = file->readNumber(); - _field28 = file->readNumber(); + _bounds.left = file->readNumber(); + _bounds.top = file->readNumber(); + _bounds.right = file->readNumber(); + _bounds.bottom = file->readNumber(); _field3C = file->readNumber(); _field40 = file->readNumber(); _field44 = file->readNumber(); @@ -77,5 +105,4 @@ void CPetControlSub12::load(SimpleFile *file, int param) { } } - } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_control_sub12.h b/engines/titanic/pet_control/pet_control_sub12.h index 5c0f0b397c..b5ff1b0663 100644 --- a/engines/titanic/pet_control/pet_control_sub12.h +++ b/engines/titanic/pet_control/pet_control_sub12.h @@ -37,10 +37,7 @@ private: Common::Array<ArrayEntry> _array; CString _string1; int _field18; - int _field1C; - int _field20; - int _field24; - int _field28; + Rect _bounds; int _field30; int _field34; int _field38; @@ -65,10 +62,27 @@ private: void setupArrays(int count); void freeArrays(); + + void setArrayStr2(uint idx, int val1, int val2, int val3); public: CPetControlSub12(int count = 10); + /** + * Set up the control + */ + void setup(); + + /** + * Load the data for the control + */ void load(SimpleFile *file, int param); + + /** + * Set the bounds for the control + */ + void setBounds(const Rect &bounds) { _bounds = bounds; } + + void set70(int val) { _field70 = val; } }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_inventory.cpp b/engines/titanic/pet_control/pet_inventory.cpp index c0a93fa23b..0417092ea4 100644 --- a/engines/titanic/pet_control/pet_inventory.cpp +++ b/engines/titanic/pet_control/pet_inventory.cpp @@ -21,16 +21,58 @@ */ #include "titanic/pet_control/pet_inventory.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/titanic.h" namespace Titanic { CPetInventory::CPetInventory() : CPetSection(), _field28C(0), _field290(0), _field294(0), _field298(0) { - for (int idx = 0; idx < 46; ++idx) { - _valArray1[idx] = _valArray2[idx] = 0; + for (int idx = 0; idx < TOTAL_ITEMS; ++idx) { + _itemBackgrounds[idx] = _itemGlyphs[idx] = nullptr; } } +bool CPetInventory::setup(CPetControl *petControl) { + return setPetControl(petControl) && setup(); +} + +bool CPetInventory::setup() { + _sub10.setup(); + _sub12.setup(); + + // TODO + return true; +} + +bool CPetInventory::setPetControl(CPetControl *petControl) { + if (!petControl) + return false; + + _petControl = petControl; + _sub10.proc8(); + _sub10.set20(28); + + Rect tempRect(0, 0, 52, 52); + for (uint idx = 0; idx < TOTAL_ITEMS; ++idx) { + if (!g_vm->_itemNames[idx].empty()) { + CString name = "3Pet" + g_vm->_itemNames[idx]; + _itemBackgrounds[idx] = petControl->getHiddenObject(name); + } + + if (!g_vm->_itemObjects[idx].empty()) { + _itemGlyphs[idx] = petControl->getHiddenObject(g_vm->_itemObjects[idx]); + } + } + + tempRect = Rect(0, 0, 580, 15); + tempRect.translate(32, 445); + _sub12.setBounds(tempRect); + _sub12.set70(0); + + return true; +} + void CPetInventory::save(SimpleFile *file, int indent) const { file->writeNumberLine(_field298, indent); } diff --git a/engines/titanic/pet_control/pet_inventory.h b/engines/titanic/pet_control/pet_inventory.h index ef295f1507..6f3fd62c78 100644 --- a/engines/titanic/pet_control/pet_inventory.h +++ b/engines/titanic/pet_control/pet_inventory.h @@ -30,20 +30,38 @@ namespace Titanic { +/** + * Handles displaying the player's inventory in the PET + */ class CPetInventory : public CPetSection { private: CPetControlSub12 _sub12; CPetControlSub10 _sub10; - int _valArray1[46]; - int _valArray2[46]; + CGameObject *_itemBackgrounds[46]; + CGameObject *_itemGlyphs[46]; int _field28C; int _field290; int _field294; int _field298; +private: + /** + * Handles initial setup + */ + bool setPetControl(CPetControl *petControl); public: CPetInventory(); /** + * Sets up the section + */ + virtual bool setup(CPetControl *petControl); + + /** + * Sets up the section + */ + virtual bool setup(); + + /** * Save the data for the class to file */ virtual void save(SimpleFile *file, int indent) const; diff --git a/engines/titanic/titanic.cpp b/engines/titanic/titanic.cpp index 9e24bbd4e9..03d50f6153 100644 --- a/engines/titanic/titanic.cpp +++ b/engines/titanic/titanic.cpp @@ -120,7 +120,7 @@ Common::Error TitanicEngine::run() { } void TitanicEngine::setItemNames() { - static const char *const NAMES[46] = { + static const char *const NAMES[TOTAL_ITEMS] = { "LeftArmWith", "LeftArmWithout", "RightArmWith", "RightArmWithout", "BridgeRed", "BridgeYellow", "BridgeBlue", "BridgeGreen", "Parrot", "CentralCore", "BrainGreen", "BrainYellow", "BrainRed", "BrainBlue", "ChickenGreasy", "ChickenPlain", "ChickenPurple", @@ -130,11 +130,11 @@ void TitanicEngine::setItemNames() { "Nose", "Perch", "PhonoCylinder", "PhonoCylinder1", "PhonoCylinder2", "PhonoCylinder3", "Photo" }; - for (uint idx = 0; idx < 46; ++idx) + for (uint idx = 0; idx < TOTAL_ITEMS; ++idx) _itemNames[idx] = NAMES[idx]; // Item descriptions - static const char *const DESCRIPTIONS[46] = { + static const char *const DESCRIPTIONS[TOTAL_ITEMS] = { "The Maitre d'Bot's left arm holding a key", "The Maitre d'Bot's left arm", "The Maitre d'Bot's right arm holding Titania's auditory center", "The Maitre d'Bot's right arm", "Red Fuse", "Yellow Fuse", "Blue Fuse", @@ -153,7 +153,7 @@ void TitanicEngine::setItemNames() { "A phonograph cylinder", "A phonograph cylinder", "A phonograph cylinder", "A photograph" }; - for (uint idx = 0; idx < 46; ++idx) + for (uint idx = 0; idx < TOTAL_ITEMS; ++idx) _itemDescriptions[idx] = DESCRIPTIONS[idx]; // Short descriptions.. maybe? diff --git a/engines/titanic/titanic.h b/engines/titanic/titanic.h index fff8865f15..6b85211194 100644 --- a/engines/titanic/titanic.h +++ b/engines/titanic/titanic.h @@ -64,6 +64,8 @@ enum TitanicDebugChannels { #define ERROR_INTERMEDIATE 2 #define ERROR_DETAILED 3 +#define TOTAL_ITEMS 46 + struct TitanicGameDescription; class TitanicEngine; @@ -109,8 +111,9 @@ public: CMainGameWindow *_window; Common::RandomSource _randomSource; CGlobalMovies _movieList; - CString _itemNames[46]; - CString _itemDescriptions[46]; + CString _itemNames[TOTAL_ITEMS]; + CString _itemDescriptions[TOTAL_ITEMS]; + CString _itemObjects[TOTAL_ITEMS]; CString _itemShortDesc[40]; public: TitanicEngine(OSystem *syst, const TitanicGameDescription *gameDesc); |