aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/pet_control
diff options
context:
space:
mode:
authorPaul Gilbert2016-06-24 22:39:01 -0400
committerPaul Gilbert2016-07-15 19:24:46 -0400
commit6f5f59af17290930ea75261c604471057e3b45e3 (patch)
treef7aa9d83f0b606e2d714a55ad77bb3b5bf488ebd /engines/titanic/pet_control
parentc2f6110d0218802b811c1172f114b5d8ed8bf37c (diff)
downloadscummvm-rg350-6f5f59af17290930ea75261c604471057e3b45e3.tar.gz
scummvm-rg350-6f5f59af17290930ea75261c604471057e3b45e3.tar.bz2
scummvm-rg350-6f5f59af17290930ea75261c604471057e3b45e3.zip
TITANIC: Added various PET methods
Diffstat (limited to 'engines/titanic/pet_control')
-rw-r--r--engines/titanic/pet_control/pet_conversations.cpp2
-rw-r--r--engines/titanic/pet_control/pet_conversations.h5
-rw-r--r--engines/titanic/pet_control/pet_glyphs.cpp58
-rw-r--r--engines/titanic/pet_control/pet_glyphs.h84
-rw-r--r--engines/titanic/pet_control/pet_inventory.cpp4
-rw-r--r--engines/titanic/pet_control/pet_inventory_glyphs.cpp10
-rw-r--r--engines/titanic/pet_control/pet_inventory_glyphs.h9
-rw-r--r--engines/titanic/pet_control/pet_rooms.cpp4
-rw-r--r--engines/titanic/pet_control/pet_rooms_glyphs.cpp6
-rw-r--r--engines/titanic/pet_control/pet_rooms_glyphs.h7
-rw-r--r--engines/titanic/pet_control/pet_section.h9
11 files changed, 146 insertions, 52 deletions
diff --git a/engines/titanic/pet_control/pet_conversations.cpp b/engines/titanic/pet_control/pet_conversations.cpp
index 9f41a356ed..4ec6e8996d 100644
--- a/engines/titanic/pet_control/pet_conversations.cpp
+++ b/engines/titanic/pet_control/pet_conversations.cpp
@@ -309,7 +309,7 @@ void CPetConversations::displayNPCName(CGameObject *npc) {
}
}
-void CPetConversations::proc34(const CString &name) {
+void CPetConversations::setNPC(const CString &name) {
_field418 = 0;
resetDials(name);
startNPCTimer();
diff --git a/engines/titanic/pet_control/pet_conversations.h b/engines/titanic/pet_control/pet_conversations.h
index 9b75a3300c..9af1f14ee7 100644
--- a/engines/titanic/pet_control/pet_conversations.h
+++ b/engines/titanic/pet_control/pet_conversations.h
@@ -228,7 +228,10 @@ public:
*/
virtual void displayNPCName(CGameObject *npc);
- virtual void proc34(const CString &name);
+ /**
+ * Sets the NPC to use
+ */
+ virtual void setNPC(const CString &name);
virtual void proc35();
diff --git a/engines/titanic/pet_control/pet_glyphs.cpp b/engines/titanic/pet_control/pet_glyphs.cpp
index 1aea34f708..2e9b590db1 100644
--- a/engines/titanic/pet_control/pet_glyphs.cpp
+++ b/engines/titanic/pet_control/pet_glyphs.cpp
@@ -71,6 +71,10 @@ void CPetGlyph::setName(const CString &name, CPetControl *petControl) {
_element.reset(name, petControl, MODE_UNSELECTED);
}
+bool CPetGlyph::isHighlighted() const {
+ return _owner->isGlyphHighlighted(this);
+}
+
/*------------------------------------------------------------------------*/
CPetGlyphs::CPetGlyphs() : _firstVisibleIndex(0), _numVisibleGlyphs(TOTAL_GLYPHS),
@@ -177,7 +181,7 @@ void CPetGlyphs::draw(CScreenManager *screenManager) {
}
}
-Point CPetGlyphs::getPosition(int index) {
+Point CPetGlyphs::getPosition(int index) const {
Point tempPoint(37 + index * 70, 375);
return tempPoint;
}
@@ -230,7 +234,7 @@ void CPetGlyphs::highlight(const CPetGlyph *glyph) {
highlight(indexOf(glyph));
}
-int CPetGlyphs::getHighlightedIndex(int index) {
+int CPetGlyphs::getHighlightedIndex(int index) const {
int idx = index - _firstVisibleIndex;
return (idx >= 0 && idx < _numVisibleGlyphs) ? idx : -1;
}
@@ -416,15 +420,27 @@ bool CPetGlyphs::KeyCharMsg(int key) {
bool CPetGlyphs::VirtualKeyCharMsg(int key) {
bool handled = false;
- warning("TODO: CPetGlyphs::virtualKeyCharMsg");
- if (!handled && _highlightIndex >= 0) {
+ switch (key) {
+ case Common::KEYCODE_LEFT:
+ decSelection();
+ return true;
+
+ case Common::KEYCODE_RIGHT:
+ incSelection();
+ return true;
+
+ default:
+ break;
+ }
+
+ if (_highlightIndex >= 0) {
CPetGlyph *glyph = getGlyph(_highlightIndex);
if (glyph && glyph->VirtualKeyCharMsg(key))
- handled = true;
+ return true;
}
- return handled;
+ return false;
}
bool CPetGlyphs::enterHighlighted() {
@@ -492,4 +508,34 @@ void CPetGlyphs::decSelection() {
}
}
+CGameObject *CPetGlyphs::getObjectAt(const Point &pt) {
+ for (int idx = 0; idx < _numVisibleGlyphs; ++idx) {
+ Rect glyphRect = getRect(idx);
+ if (glyphRect.contains(pt)) {
+ CPetGlyph *glyph = getGlyph(getItemIndex(idx));
+ if (glyph)
+ return glyph->getObjectAt();
+ }
+ }
+
+ return nullptr;
+}
+
+bool CPetGlyphs::isGlyphHighlighted(const CPetGlyph *glyph) const {
+ if (_highlightIndex == -1)
+ return false;
+
+ return indexOf(glyph) == _highlightIndex;
+}
+
+Point CPetGlyphs::getHighlightedGlyphPos() const {
+ if (_highlightIndex != -1) {
+ int idx = getHighlightedIndex(_highlightIndex);
+ if (idx >= 0)
+ return getPosition(idx);
+ }
+
+ return Point(0, 0);
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_glyphs.h b/engines/titanic/pet_control/pet_glyphs.h
index f1587e3e5a..9dfe5ad3fa 100644
--- a/engines/titanic/pet_control/pet_glyphs.h
+++ b/engines/titanic/pet_control/pet_glyphs.h
@@ -64,31 +64,6 @@ 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); }
-
- /**
- * Get the parent RealLife area
- */
- CPetGlyphs *getOwner() { return _owner; }
-
- /**
- * Get the PET control
- */
- CPetControl *getPetControl() const;
-
- /**
- * Sets new name and default bounds for glyph
- */
- void setName(const CString &name, CPetControl *petControl);
-
- /**
* Setup the glyph
*/
virtual bool setup(CPetControl *petControl, CPetGlyphs *owner);
@@ -199,7 +174,10 @@ public:
*/
virtual void getTooltip(CPetText *text) {}
- virtual void save2(SimpleFile *file, int indent) {}
+ /**
+ * Saves the data for the glyph
+ */
+ virtual void saveGlyph(SimpleFile *file, int indent) {}
virtual bool proc33(CPetGlyph *glyph) { return true; }
virtual int proc34() { return 1; }
@@ -214,12 +192,45 @@ public:
*/
virtual void leaveHighlighted() {}
- virtual int proc37() { return 0; }
+ /**
+ * Returns the object associated with the glyph
+ */
+ virtual CGameObject *getObjectAt() { return nullptr; }
/**
* Does a processing action on the glyph
*/
virtual bool doAction(CGlyphAction *action) { return true; }
+
+ /**
+ * 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); }
+
+ /**
+ * Get the parent RealLife area
+ */
+ CPetGlyphs *getOwner() { return _owner; }
+
+ /**
+ * Get the PET control
+ */
+ CPetControl *getPetControl() const;
+
+ /**
+ * Sets new name and default bounds for glyph
+ */
+ void setName(const CString &name, CPetControl *petControl);
+
+ /**
+ * Returns true if the specified glyph is the currently highlighted one
+ */
+ bool isHighlighted() const;
};
class CPetGlyphs : public List<CPetGlyph> {
@@ -227,7 +238,7 @@ private:
/**
* Get a position for the glyph
*/
- Point getPosition(int index);
+ Point getPosition(int index) const;
/**
* Get a rect for the glyph
@@ -237,7 +248,7 @@ private:
/**
* Returns the on-screen index for the highlight to be shown at
*/
- int getHighlightedIndex(int index);
+ int getHighlightedIndex(int index) const;
/**
* Returns the index of a glyph given the visible on-screen glyph number
@@ -434,6 +445,21 @@ public:
* Decrement the currently selected index
*/
void decSelection();
+
+ /**
+ * Returns the object associated the glyph under the specified position
+ */
+ CGameObject *getObjectAt(const Point &pt);
+
+ /**
+ * Returns true if the specified glyph is the currently highlighted one
+ */
+ bool isGlyphHighlighted(const CPetGlyph *glyph) const;
+
+ /**
+ * Get the top-left position of the currently highlighted glyph
+ */
+ Point getHighlightedGlyphPos() const;
};
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_inventory.cpp b/engines/titanic/pet_control/pet_inventory.cpp
index 37a73420bd..bf6b913d0d 100644
--- a/engines/titanic/pet_control/pet_inventory.cpp
+++ b/engines/titanic/pet_control/pet_inventory.cpp
@@ -124,14 +124,14 @@ bool CPetInventory::setPetControl(CPetControl *petControl) {
void CPetInventory::change(CCarry *item) {
if (item) {
CInventoryGlyphAction action(item, ACTION_CHANGE);
- _items.change(&action);
+ _items.doAction(&action);
}
}
void CPetInventory::itemRemoved(CGameObject *item) {
if (item) {
CInventoryGlyphAction action(item, ACTION_REMOVED);
- _items.change(&action);
+ _items.doAction(&action);
}
}
diff --git a/engines/titanic/pet_control/pet_inventory_glyphs.cpp b/engines/titanic/pet_control/pet_inventory_glyphs.cpp
index b793c1af13..441726ee75 100644
--- a/engines/titanic/pet_control/pet_inventory_glyphs.cpp
+++ b/engines/titanic/pet_control/pet_inventory_glyphs.cpp
@@ -146,7 +146,15 @@ bool CPetInventoryGlyph::doAction(CGlyphAction *action) {
if (_item == invAction->_item && _owner) {
int v = populateItem(_item, 0);
_background = owner->getBackground(v);
+
+ if (isHighlighted()) {
+ warning("TODO");
+ }
}
+ break;
+
+ default:
+ break;
}
return true;
@@ -154,7 +162,7 @@ bool CPetInventoryGlyph::doAction(CGlyphAction *action) {
/*------------------------------------------------------------------------*/
-bool CPetInventoryGlyphs::change(CInventoryGlyphAction *action) {
+bool CPetInventoryGlyphs::doAction(CInventoryGlyphAction *action) {
for (iterator i = begin(); i != end(); ++i) {
(*i)->doAction(action);
}
diff --git a/engines/titanic/pet_control/pet_inventory_glyphs.h b/engines/titanic/pet_control/pet_inventory_glyphs.h
index 91b1e5ee50..17222a9076 100644
--- a/engines/titanic/pet_control/pet_inventory_glyphs.h
+++ b/engines/titanic/pet_control/pet_inventory_glyphs.h
@@ -54,6 +54,11 @@ public:
void setItem(CGameObject *item, int val);
/**
+ * Returns the object associated with the glyph
+ */
+ virtual CGameObject *getObjectAt() { return _item; }
+
+ /**
* Does a processing action on the glyph
*/
virtual bool doAction(CGlyphAction *action);
@@ -73,9 +78,9 @@ private:
CGameObject *getBackground(int index);
public:
/**
- *
+ * Do an action on the glyphs
*/
- bool change(CInventoryGlyphAction *item);
+ bool doAction(CInventoryGlyphAction *item);
};
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_rooms.cpp b/engines/titanic/pet_control/pet_rooms.cpp
index 028f1def3d..bbb8dafef7 100644
--- a/engines/titanic/pet_control/pet_rooms.cpp
+++ b/engines/titanic/pet_control/pet_rooms.cpp
@@ -149,8 +149,8 @@ void CPetRooms::postLoad() {
}
void CPetRooms::save(SimpleFile *file, int indent) const {
- _glyphs.save2(file, indent);
- _glyphItem.save2(file, indent);
+ _glyphs.saveGlyphs(file, indent);
+ _glyphItem.saveGlyph(file, indent);
file->writeNumberLine(_floorNum, indent);
file->writeNumberLine(_elevatorNum, indent);
file->writeNumberLine(_roomNum, indent);
diff --git a/engines/titanic/pet_control/pet_rooms_glyphs.cpp b/engines/titanic/pet_control/pet_rooms_glyphs.cpp
index b0a486d574..864ae2ee39 100644
--- a/engines/titanic/pet_control/pet_rooms_glyphs.cpp
+++ b/engines/titanic/pet_control/pet_rooms_glyphs.cpp
@@ -166,7 +166,7 @@ void CPetRoomsGlyph::getTooltip(CPetText *text) {
text->setText(roomStr);
}
-void CPetRoomsGlyph::save2(SimpleFile *file, int indent) const {
+void CPetRoomsGlyph::saveGlyph(SimpleFile *file, int indent) const {
file->writeNumberLine(_roomFlags, indent);
file->writeNumberLine(_mode, indent);
}
@@ -227,11 +227,11 @@ void CPetRoomsGlyph::drawObjects(uint flags, const Point &pt, CScreenManager *sc
/*------------------------------------------------------------------------*/
-void CPetRoomsGlyphs::save2(SimpleFile *file, int indent) const {
+void CPetRoomsGlyphs::saveGlyphs(SimpleFile *file, int indent) const {
file->writeNumberLine(size(), indent);
for (const_iterator i = begin(); i != end(); ++i)
- (*i)->save2(file, indent);
+ (*i)->saveGlyph(file, indent);
}
CPetRoomsGlyph *CPetRoomsGlyphs::findAssignedRoom() const {
diff --git a/engines/titanic/pet_control/pet_rooms_glyphs.h b/engines/titanic/pet_control/pet_rooms_glyphs.h
index 3706fcc01e..f0c2ce0133 100644
--- a/engines/titanic/pet_control/pet_rooms_glyphs.h
+++ b/engines/titanic/pet_control/pet_rooms_glyphs.h
@@ -90,7 +90,10 @@ public:
*/
virtual void getTooltip(CPetText *text);
- virtual void save2(SimpleFile *file, int indent) const;
+ /**
+ * Saves the data for the glyph
+ */
+ virtual void saveGlyph(SimpleFile *file, int indent) const;
virtual bool proc33(CPetGlyph *glyph);
@@ -140,7 +143,7 @@ public:
/**
* Save the list
*/
- void save2(SimpleFile *file, int indent) const;
+ void saveGlyphs(SimpleFile *file, int indent) const;
/**
* Returns the glyph for hte player's assigned room
diff --git a/engines/titanic/pet_control/pet_section.h b/engines/titanic/pet_control/pet_section.h
index 15c4033e8b..d888e051c8 100644
--- a/engines/titanic/pet_control/pet_section.h
+++ b/engines/titanic/pet_control/pet_section.h
@@ -167,9 +167,12 @@ public:
virtual void displayNPCName(CGameObject *npc) {}
virtual void proc33() {}
-
- virtual void proc34(const CString &name) {}
-
+
+ /**
+ * Sets the NPC to use
+ */
+ virtual void setNPC(const CString &name) {}
+
virtual void proc35() {}
/**