TITANIC: Restructuring PET list classes, beginning of inventory

This commit is contained in:
Paul Gilbert
2016-07-10 16:11:16 -04:00
parent fb5565679b
commit daaa458d64
21 changed files with 180 additions and 136 deletions
+5 -5
View File
@@ -119,7 +119,7 @@ bool CArm::UseWithOtherMsg(CUseWithOtherMsg *msg) {
if (hookedMsg._result) {
_string7 = "GondolierLeftLever";
} else {
dropOnPet();
addToInventory();
}
} else if (msg->_other->getName() == "GondolierRightLever") {
CIsHookedOnMsg hookedMsg(_hookedRect, 0, getName());
@@ -129,7 +129,7 @@ bool CArm::UseWithOtherMsg(CUseWithOtherMsg *msg) {
if (hookedMsg._result) {
_string7 = "GondolierRightLever";
} else {
dropOnPet();
addToInventory();
}
}
@@ -166,13 +166,13 @@ bool CArm::MaitreDHappyMsg(CMaitreDHappyMsg *msg) {
CGameObject *child = static_cast<CGameObject *>(getFirstChild());
if (child) {
child->setVisible(true);
dropOnPet();
addToInventory();
}
_visibleFrame = _field170;
loadFrame(_visibleFrame);
_string6 = "None";
addToInventory();
invFn3();
}
}
@@ -189,7 +189,7 @@ bool CArm::PETGainedObjectMsg(CPETGainedObjectMsg *msg) {
_visibleFrame = _field170;
loadFrame(_visibleFrame);
child->setVisible(true);
child->dropOnPet();
child->addToInventory();
}
_string6 = "None";
+1 -1
View File
@@ -56,7 +56,7 @@ bool CBridgePiece::UseWithOtherMsg(CUseWithOtherMsg *msg) {
if (!shipSetting) {
return CCarry::UseWithOtherMsg(msg);
} else if (shipSetting->_string4 == "NULL") {
dropOnPet();
addToInventory();
return true;
} else {
setVisible(false);
+10 -8
View File
@@ -123,7 +123,7 @@ bool CCarry::MouseDragMoveMsg(CMouseDragMoveMsg *msg) {
bool CCarry::MouseDragEndMsg(CMouseDragEndMsg *msg) {
if (msg->_dropTarget) {
if (msg->_dropTarget->isPet()) {
dropOnPet();
addToInventory();
return true;
}
@@ -147,7 +147,7 @@ bool CCarry::MouseDragEndMsg(CMouseDragEndMsg *msg) {
CString viewName = getViewFullName();
if (viewName.empty() || msg->_mousePos.y >= 360) {
sleep(250);
dropOnPet();
addToInventory();
} else {
setPosition(_origPos);
loadFrame(_itemFrame);
@@ -165,7 +165,7 @@ bool CCarry::UseWithCharMsg(CUseWithCharMsg *msg) {
} else {
CShowTextMsg textMsg(_string4);
textMsg.execute("PET");
dropOnPet();
addToInventory();
}
return true;
@@ -182,7 +182,7 @@ bool CCarry::UseWithOtherMsg(CUseWithOtherMsg *msg) {
_fullViewName = getViewFullName();
if (_fullViewName.empty() || _bounds.top >= 360) {
sleep(250);
dropOnPet();
addToInventory();
} else {
setPosition(_origPos);
}
@@ -238,14 +238,16 @@ bool CCarry::PassOnDragStartMsg(CPassOnDragStartMsg *msg) {
return true;
}
void CCarry::dropOnPet() {
warning("TODO: dropOnPet");
}
void CCarry::addToInventory() {
CPetControl *pet = getPetControl();
if (pet)
pet->addToInventory(this);
}
void CCarry::invFn3() {
CPetControl *pet = getPetControl();
if (pet)
pet->invFn3(this);
}
} // End of namespace Titanic
+4 -4
View File
@@ -63,9 +63,9 @@ protected:
int _visibleFrame;
protected:
/**
* Add the item to the PET inventory
*
*/
void addToInventory();
void invFn3();
public:
CLASSDEF
CCarry();
@@ -81,9 +81,9 @@ public:
virtual void load(SimpleFile *file);
/**
* Called to drop an item into the PET
* Add the item to the inventory
*/
void dropOnPet();
void addToInventory();
};
} // End of namespace Titanic
+2 -2
View File
@@ -105,7 +105,7 @@ bool CCarryParrot::MouseDragEndMsg(CMouseDragEndMsg *msg) {
stopMovie();
if (msg->_mousePos.y >= 360) {
dropOnPet();
addToInventory();
return true;
}
@@ -215,7 +215,7 @@ bool CCarryParrot::ActMsg(CActMsg *msg) {
CCarry *feathers = static_cast<CCarry *>(getRoot()->findByName("Feathers"));
if (feathers) {
feathers->setVisible(true);
feathers->dropOnPet();
feathers->addToInventory();
}
_field140 = true;
+5 -5
View File
@@ -72,13 +72,13 @@ bool CChicken::UseWithOtherMsg(CUseWithOtherMsg *msg) {
if (_field12C || _string6 == "None") {
CActMsg actMsg("Clean");
actMsg.execute(this);
dropOnPet();
addToInventory();
} else {
CShowTextMsg textMsg("The chicken is already clean.");
textMsg.execute("PET");
}
dropOnPet();
addToInventory();
} else {
CSauceDispensor *dispensor = static_cast<CSauceDispensor *>(msg->_other);
if (!dispensor || _string6 == "None") {
@@ -101,7 +101,7 @@ bool CChicken::UseWithCharMsg(CUseWithCharMsg *msg) {
acceptMsg._item = this;
acceptMsg.execute(succubus);
} else {
dropOnPet();
addToInventory();
}
return true;
@@ -110,7 +110,7 @@ bool CChicken::UseWithCharMsg(CUseWithCharMsg *msg) {
bool CChicken::ActMsg(CActMsg *msg) {
if (msg->_action == "GoToPET") {
setVisible(true);
dropOnPet();
addToInventory();
} else if (msg->_action == "Tomato") {
_string6 = "Tomato";
loadFrame(4);
@@ -171,7 +171,7 @@ bool CChicken::TimerMsg(CTimerMsg *msg) {
}
if (flag) {
addToInventory();
invFn3();
stopTimer(_timerId);
}
+1 -1
View File
@@ -53,7 +53,7 @@ bool CNapkin::UseWithOtherMsg(CUseWithOtherMsg *msg) {
}
}
dropOnPet();
addToInventory();
return CCarry::UseWithOtherMsg(msg);
}
+4 -6
View File
@@ -204,11 +204,6 @@ protected:
*/
static CGameObject *findUnder(CTreeItem *parent, const CString &name);
/**
* Moves the item from it's original position to be under the hidden room
*/
void moveToHiddenRoom();
/**
* Moves the item from it's original position to be under the current view
*/
@@ -313,7 +308,10 @@ public:
*/
void setVisible(bool val);
/**
* Moves the item from it's original position to be under the hidden room
*/
void moveToHiddenRoom();
};
} // End of namespace Titanic
+2 -2
View File
@@ -356,25 +356,25 @@ MODULE_OBJS := \
npcs/titania.o \
npcs/true_talk_npc.o \
pet_control/pet_control.o \
pet_control/pet_control_list_item.o \
pet_control/pet_control_list_item2.o \
pet_control/pet_conversations.o \
pet_control/pet_element.o \
pet_control/pet_frame.o \
pet_control/pet_gfx_element.o \
pet_control/pet_inventory.o \
pet_control/pet_inventory_glyphs.o \
pet_control/pet_rooms.o \
pet_control/pet_remote.o \
pet_control/pet_saves.o \
pet_control/pet_section.o \
pet_control/pet_control_sub5.o \
pet_control/pet_control_sub7.o \
pet_control/pet_control_sub10.o \
pet_control/pet_control_sub11.o \
pet_control/pet_control_sub12.o \
pet_control/pet_drag_chev.o \
pet_control/pet_graphic2.o \
pet_control/pet_graphic.o \
pet_control/pet_glyphs.o \
pet_control/pet_leaf.o \
pet_control/pet_mode_off.o \
pet_control/pet_mode_on.o \
+28 -1
View File
@@ -353,7 +353,30 @@ CGameObject *CPetControl::getNextObject(CGameObject *prior) const {
}
void CPetControl::addToInventory(CCarry *item) {
_inventory.addItem(item);
item->detach();
if (item->getName() == "CarryParcel") {
CCarry *child = static_cast<CCarry *>(getLastChild());
if (child)
child->detach();
item->moveToHiddenRoom();
if (!child)
return;
item = child;
}
item->addUnder(this);
_inventory.itemsChanged();
setArea(PET_INVENTORY);
if (_currentArea != PET_INVENTORY)
_inventory.couldntShowInventory(item);
makeDirty();
CPETGainedObjectMsg msg;
msg.execute(item);
}
void CPetControl::removeFromInventory(CCarry *item, CTreeItem *newParent,
@@ -376,6 +399,10 @@ void CPetControl::removeFromInventory(CCarry *item, bool refreshUI, bool sendMsg
removeFromInventory(item, view, refreshUI, sendMsg);
}
void CPetControl::invFn3(CCarry *item) {
_inventory.fn3(item);
}
void CPetControl::moveToHiddenRoom(CTreeItem *item) {
CRoomItem *room = getHiddenRoom();
if (room) {
@@ -224,6 +224,8 @@ public:
*/
void removeFromInventory(CCarry *item, bool refreshUI = true, bool sendMsg = true);
void invFn3(CCarry *item);
/**
* Moves a tree item from it's original position to be under the hidden room
*/
@@ -1,27 +0,0 @@
/* 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_control_list_item.h"
namespace Titanic {
} // End of namespace Titanic
@@ -1,42 +0,0 @@
/* 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_CONTROL_LIST_ITEM_H
#define TITANIC_PET_CONTROL_LIST_ITEM_H
#include "titanic/core/list.h"
#include "titanic/pet_control/pet_gfx_element.h"
namespace Titanic {
class CPetControlListItem : public ListItem {
protected:
CPetGfxElement _val;
int _field30;
public:
CPetControlListItem() : _field30(0) {}
};
} // End of namespace Titanic
#endif /* TITANIC_PET_CONTROL_LIST_ITEM_H */
@@ -23,11 +23,11 @@
#ifndef TITANIC_PET_CONTROL_LIST_ITEM2_H
#define TITANIC_PET_CONTROL_LIST_ITEM2_H
#include "titanic/pet_control/pet_control_list_item.h"
#include "titanic/pet_control/pet_glyphs.h"
namespace Titanic {
class CPetControlListItem2 : public CPetControlListItem {
class CPetControlListItem2 : public CPetGlyph {
protected:
int _field34;
int _field38;
@@ -23,11 +23,11 @@
#ifndef TITANIC_PET_CONTROL_SUB11_H
#define TITANIC_PET_CONTROL_SUB11_H
#include "titanic/pet_control/pet_control_sub10.h"
#include "titanic/pet_control/pet_glyphs.h"
namespace Titanic {
class CPetControlSub11 : public CPetControlSub10 {
class CPetControlSub11 : public CPetGlyphs<CPetGlyph> {
public:
};
+24 -4
View File
@@ -38,7 +38,7 @@ bool CPetInventory::setup(CPetControl *petControl) {
}
bool CPetInventory::setup() {
_sub10.setup();
_items.setup();
_sub12.setup();
// TODO
@@ -47,7 +47,7 @@ bool CPetInventory::setup() {
void CPetInventory::draw(CScreenManager *screenManager) {
_petControl->drawIndent(screenManager, 7);
_sub10.draw(screenManager);
_items.draw(screenManager);
_sub12.draw(screenManager);
}
@@ -79,8 +79,8 @@ bool CPetInventory::setPetControl(CPetControl *petControl) {
return false;
_petControl = petControl;
_sub10.proc8();
_sub10.set20(28);
_items.proc8();
_items.set20(28);
Rect tempRect(0, 0, 52, 52);
for (uint idx = 0; idx < TOTAL_ITEMS; ++idx) {
@@ -103,6 +103,10 @@ bool CPetInventory::setPetControl(CPetControl *petControl) {
}
void CPetInventory::addItem(CCarry *item) {
if (item) {
CPetCarry glyphItem(item, 2);
}
warning("TODO: CPetInventory::addItem");
}
@@ -110,4 +114,20 @@ void CPetInventory::itemRemoved(CCarry *item) {
warning("TODO: CPetInventory::itemRemoved");
}
void CPetInventory::fn3(CCarry *item) {
warning("TODO: CPetInventory::fn3");
}
void CPetInventory::itemsChanged() {
_items.clear();
//CGameObject *item = static_cast<CGameObject *>(_petControl->getFirstObject());
}
void CPetInventory::couldntShowInventory(CCarry *item) {
}
} // End of namespace Titanic
+14 -2
View File
@@ -25,7 +25,7 @@
#include "titanic/support/simple_file.h"
#include "titanic/pet_control/pet_section.h"
#include "titanic/pet_control/pet_control_sub10.h"
#include "titanic/pet_control/pet_inventory_glyphs.h"
#include "titanic/pet_control/pet_control_sub12.h"
namespace Titanic {
@@ -36,7 +36,7 @@ namespace Titanic {
class CPetInventory : public CPetSection {
private:
CPetControlSub12 _sub12;
CPetControlSub10 _sub10;
CPetInventoryGlyphs _items;
CGameObject *_itemBackgrounds[46];
CGameObject *_itemGlyphs[46];
int _field28C;
@@ -100,6 +100,18 @@ public:
* Called when an item has been removed from the PET
*/
void itemRemoved(CCarry *item);
void fn3(CCarry *item);
/**
* Called when the items under the PET have changed
*/
void itemsChanged();
/**
* Called when the inventory can't be shown after adding an item
*/
void couldntShowInventory(CCarry *item);
};
} // End of namespace Titanic
@@ -21,32 +21,48 @@
*/
#include "common/textconsole.h"
#include "titanic/pet_control/pet_control_sub10.h"
#include "titanic/pet_control/pet_inventory_glyphs.h"
namespace Titanic {
CPetControlSub10::CPetControlSub10() : _field10(0), _field14(7),
CPetInventoryGlyphs::CPetInventoryGlyphs() : _field10(0), _field14(7),
_field18(-1), _field1C(-1), _field20(0), _field24(0) {
}
void CPetControlSub10::proc8() {
void CPetInventoryGlyphs::proc8() {
error("TODO");
}
void CPetControlSub10::setup() {
warning("TODO: CPetControlSub10::setup");
void CPetInventoryGlyphs::setup() {
warning("TODO: CPetInventoryGlyphs::setup");
}
void CPetControlSub10::proc10() {
void CPetInventoryGlyphs::proc10() {
error("TODO");
}
void CPetControlSub10::proc11() {
void CPetInventoryGlyphs::proc11() {
error("TODO");
}
void CPetControlSub10::draw(CScreenManager *screenManager) {
warning("TODO: CPetControlSub10::draw");
void CPetInventoryGlyphs::draw(CScreenManager *screenManager) {
warning("TODO: CPetInventoryGlyphs::draw");
}
void CPetInventoryGlyphs::addItem(CPetCarry *item) {
warning("TODO");
}
void CPetInventoryGlyphs::clear() {
fn1(-1);
destroyContents();
_field10 = 0;
}
void CPetInventoryGlyphs::fn1(int val) {
warning("TODO: CPetInventoryGlyphs::fn1");
}
} // End of namespace Titanic
@@ -20,17 +20,37 @@
*
*/
#ifndef TITANIC_PET_CONTROL_SUB10_H
#define TITANIC_PET_CONTROL_SUB10_H
#ifndef TITANIC_PET_INVENTORY_GLYPHS_H
#define TITANIC_PET_INVENTORY_GLYPHS_H
#include "titanic/core/list.h"
#include "titanic/pet_control/pet_control_sub10.h"
#include "titanic/pet_control/pet_control_list_item.h"
#include "titanic/pet_control/pet_glyphs.h"
#include "titanic/support/screen_manager.h"
namespace Titanic {
class CPetControlSub10 : public List<CPetControlListItem> {
class CPetInventoryGlyph : public CPetGlyph {
public:
CCarry *_item;
int _field34;
int _field38;
int _field3C;
int _field40;
public:
CPetInventoryGlyph(CCarry *item, int val) : _item(item),
_field34(val), _field38(0), _field3C(0), _field40(0) {}
};
class CPetCarry {
public:
int _val;
CCarry *_item;
public:
CPetCarry(CCarry *item, int val) : _item(item), _val(val) {}
};
class CPetInventoryGlyphs : public CPetGlyphs<CPetInventoryGlyph> {
private:
void fn1(int val);
protected:
int _field10;
int _field14;
@@ -42,7 +62,7 @@ protected:
CPetGfxElement _scrollLeft;
CPetGfxElement _scrollRight;
public:
CPetControlSub10();
CPetInventoryGlyphs();
virtual void proc8();
@@ -60,8 +80,18 @@ public:
* 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
#endif /* TITANIC_PET_CONTROL_SUB10_H */
#endif /* TITANIC_PET_INVENTORY_GLYPHS_H */
+5 -2
View File
@@ -24,15 +24,18 @@
#define TITANIC_PET_REMOTE_H
#include "titanic/pet_control/pet_section.h"
#include "titanic/pet_control/pet_control_sub10.h"
#include "titanic/pet_control/pet_glyphs.h"
#include "titanic/pet_control/pet_control_sub12.h"
#include "titanic/pet_control/pet_gfx_element.h"
namespace Titanic {
class CPetRemoteGlyphs : public CPetGlyphs<CPetGlyph> {
};
class CPetRemote : public CPetSection {
private:
CPetControlSub10 _sub10;
CPetRemoteGlyphs _items;
CPetGfxElement _val1;
CPetGfxElement _val2;
CPetGfxElement _val3;
+6 -3
View File
@@ -24,15 +24,18 @@
#define TITANIC_PET_SAVES_H
#include "titanic/pet_control/pet_section.h"
#include "titanic/pet_control/pet_control_sub10.h"
#include "titanic/pet_control/pet_glyphs.h"
#include "titanic/pet_control/pet_control_sub12.h"
namespace Titanic {
class CPetSaveGlyphs : public CPetGlyphs<CPetGlyph> {
};
class CPetSaves : public CPetSection {
private:
CPetControlSub10 _sub10;
CPetControlSub10 _sub12;
CPetSaveGlyphs _sub10;
CPetSaveGlyphs _sub12;
public:
/**
* Returns true if the object is in a valid state