aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/pet_control
diff options
context:
space:
mode:
authorPaul Gilbert2016-06-23 20:17:26 -0400
committerPaul Gilbert2016-07-15 19:24:18 -0400
commitf7d6db05e849855cbd17a60c3bbc3b1e96d1453a (patch)
treea0399d8b1a146a174e2af38e7b4e52473bb2964a /engines/titanic/pet_control
parent54eac84dc5051c9833ea96f0be6c7b44ba262817 (diff)
downloadscummvm-rg350-f7d6db05e849855cbd17a60c3bbc3b1e96d1453a.tar.gz
scummvm-rg350-f7d6db05e849855cbd17a60c3bbc3b1e96d1453a.tar.bz2
scummvm-rg350-f7d6db05e849855cbd17a60c3bbc3b1e96d1453a.zip
TITANIC: Adding Pet Room glyph methods
Diffstat (limited to 'engines/titanic/pet_control')
-rw-r--r--engines/titanic/pet_control/pet_glyphs.h2
-rw-r--r--engines/titanic/pet_control/pet_rooms_glyphs.cpp51
-rw-r--r--engines/titanic/pet_control/pet_rooms_glyphs.h10
3 files changed, 59 insertions, 4 deletions
diff --git a/engines/titanic/pet_control/pet_glyphs.h b/engines/titanic/pet_control/pet_glyphs.h
index 5dc5013a9b..f0b9ef128b 100644
--- a/engines/titanic/pet_control/pet_glyphs.h
+++ b/engines/titanic/pet_control/pet_glyphs.h
@@ -178,7 +178,7 @@ public:
/**
*
*/
- virtual void proc28(const Point &pt) {}
+ virtual void proc28(const Point &topLeft, const Point &pt) {}
virtual int proc29(const Point &pt) { return 0; }
diff --git a/engines/titanic/pet_control/pet_rooms_glyphs.cpp b/engines/titanic/pet_control/pet_rooms_glyphs.cpp
index 9ecaefbf68..de06e02bc4 100644
--- a/engines/titanic/pet_control/pet_rooms_glyphs.cpp
+++ b/engines/titanic/pet_control/pet_rooms_glyphs.cpp
@@ -21,9 +21,11 @@
*/
#include "titanic/pet_control/pet_rooms_glyphs.h"
+#include "titanic/pet_control/pet_control.h"
#include "titanic/pet_control/pet_section.h"
#include "titanic/support/screen_manager.h"
#include "titanic/room_flags.h"
+#include "titanic/titanic.h"
namespace Titanic {
@@ -63,11 +65,36 @@ void CPetRoomsGlyph::drawAt(CScreenManager *screenManager, const Point &pt) {
warning("TODO: CPetRoomsGlyph::drawAt");
}
-void CPetRoomsGlyph::proc28(const Point &pt) {
+void CPetRoomsGlyph::proc28(const Point &topLeft, const Point &pt) {
+ if (isModeValid()) {
+ bool isShiftPressed = g_vm->_events->getSpecialButtons() & MK_SHIFT;
+ if (isShiftPressed) {
+ int selection = getSelection(topLeft, pt);
+ if (selection >= 0)
+ _roomFlags |= 1 << selection;
+ }
+
+ updateTooltip();
+ }
}
int CPetRoomsGlyph::proc29(const Point &pt) {
+ bool isShiftPressed = g_vm->_events->getSpecialButtons() & MK_SHIFT;
+ CPetControl *petControl = getPetControl();
+
+ if (!isShiftPressed && petControl) {
+ CGameObject *chevron = petControl->getHiddenObject("3PetChevron");
+
+ if (chevron) {
+ chevron->_id = _roomFlags;
+ chevron->_isMail = _field38;
+// petControl->removeFromInventory(chevon);
+// chevron->loadSurface();
+ // TODO
+ }
+ }
+
return 0;
}
@@ -92,6 +119,28 @@ void CPetRoomsGlyph::changeLocation(int newClassNum) {
_roomFlags = roomFlags.get();
}
+int CPetRoomsGlyph::getSelection(const Point &topLeft, const Point &pt) {
+ Rect rects[4] = {
+ Rect(topLeft.x, topLeft.y, topLeft.x + 13, topLeft.y + 10),
+ Rect(topLeft.x + 13, topLeft.y, topLeft.x + 26, topLeft.y + 10),
+ Rect(topLeft.x + 26, topLeft.y, topLeft.x + 39, topLeft.y + 10),
+ Rect(topLeft.x + 39, topLeft.y, topLeft.x + 52, topLeft.y + 10)
+ };
+
+ for (int idx = 0, btnIndex = 19; idx < 5; ++idx, btnIndex -= 4) {
+ // Iterate through each of the four rects, seeing if there's a match.
+ // If not, move it down to the next row for the next loop iteration
+ for (int i = 0; i < 4; ++i) {
+ if (rects[i].contains(pt))
+ return btnIndex - i;
+
+ rects[i].translate(0, 10);
+ }
+ }
+
+ return -1;
+}
+
/*------------------------------------------------------------------------*/
void CPetRoomsGlyphs::save2(SimpleFile *file, int indent) const {
diff --git a/engines/titanic/pet_control/pet_rooms_glyphs.h b/engines/titanic/pet_control/pet_rooms_glyphs.h
index bed167f934..cb937ec5c0 100644
--- a/engines/titanic/pet_control/pet_rooms_glyphs.h
+++ b/engines/titanic/pet_control/pet_rooms_glyphs.h
@@ -31,7 +31,7 @@ namespace Titanic {
enum RoomGlyphMode { RGM_0 = 0, RGM_1 = 1, RGM_2 = 2 };
class CPetRoomsGlyph : public CPetGlyph {
-protected:
+private:
uint _roomFlags;
int _field38;
RoomGlyphMode _mode;
@@ -43,6 +43,12 @@ protected:
CGameObject *_field54;
CGameObject *_field58;
CGameObject *_field5C;
+private:
+ /**
+ * Find the selected button under the given point, based on the buttons
+ * starting at a designated top/left position
+ */
+ int getSelection(const Point &topLeft, const Point &pt);
public:
CPetRoomsGlyph();
CPetRoomsGlyph(uint flags);
@@ -65,7 +71,7 @@ public:
/**
*
*/
- virtual void proc28(const Point &pt);
+ virtual void proc28(const Point &topLeft, const Point &pt);
virtual int proc29(const Point &pt);