ScummVM API documentation
pet_control.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef TITANIC_PET_CONTROL_H
23 #define TITANIC_PET_CONTROL_H
24 
25 #include "titanic/core/game_object.h"
26 #include "titanic/core/node_item.h"
27 #include "titanic/core/room_item.h"
28 #include "titanic/messages/messages.h"
29 #include "titanic/messages/mouse_messages.h"
30 #include "titanic/pet_control/pet_conversations.h"
31 #include "titanic/pet_control/pet_frame.h"
32 #include "titanic/pet_control/pet_inventory.h"
33 #include "titanic/pet_control/pet_translation.h"
34 #include "titanic/pet_control/pet_starfield.h"
35 #include "titanic/pet_control/pet_real_life.h"
36 #include "titanic/pet_control/pet_remote.h"
37 #include "titanic/pet_control/pet_rooms.h"
38 #include "titanic/support/strings.h"
39 #include "titanic/room_flags.h"
40 
41 namespace Titanic {
42 
43 enum SummonResult { SUMMON_CANT = 0, SUMMON_PRESENT = 1, SUMMON_CAN = 2 };
44 
45 class CPetControl : public CGameObject {
46  DECLARE_MESSAGE_MAP;
47  struct PetEventInfo {
48  int _id;
49  CPetSection *_target;
50  PetEventInfo() : _id(0), _target(nullptr) {}
51  };
52 private:
53  int _inputLockCount;
54  int _areaLockCount;
55  int _areaChangeType;
56  CPetSection *_sections[7];
57  CPetConversations _conversations;
58  CPetInventory _inventory;
59  CPetStarfield _starfield;
60  CPetRemote _remote;
61  CPetRooms _rooms;
62  CPetRealLife _realLife;
63  CPetTranslation _translation;
64  CPetFrame _frame;
65  CString _activeNPCName;
66  CString _remoteTargetName;
67  CRoomItem *_hiddenRoom;
68  Rect _drawBounds;
69  PetEventInfo _timers[2];
70 private:
74  bool isValid();
75 
79  void loadAreas(SimpleFile *file, int param);
80 
84  void saveAreas(SimpleFile *file, int indent);
85 
89  void loaded();
90 
94  bool containsPt(const Common::Point &pt) const;
95 
99  bool isBotInView(const CString &name) const;
100 
104  CGameObject *findBot(const CString &name, CTreeItem *root);
105 
109  void setTimerPersisent(int id, bool flag);
110 protected:
111  bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
112  bool MouseDragStartMsg(CMouseDragStartMsg *msg);
113  bool MouseDragMoveMsg(CMouseDragMoveMsg *msg);
114  bool MouseDragEndMsg(CMouseDragEndMsg *msg);
115  bool MouseButtonUpMsg(CMouseButtonUpMsg *msg);
116  bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg);
117  bool MouseWheelMsg(CMouseWheelMsg *msg);
118  bool KeyCharMsg(CKeyCharMsg *msg);
119  bool VirtualKeyCharMsg(CVirtualKeyCharMsg *msg);
120  bool TimerMsg(CTimerMsg *msg);
121 public:
122  PetArea _currentArea;
123  CTreeItem *_activeNPC;
124  CGameObject *_remoteTarget;
125 public:
126  CLASSDEF;
127  CPetControl();
128 
132  void save(SimpleFile *file, int indent) override;
133 
137  void load(SimpleFile *file) override;
138 
142  void draw(CScreenManager *screenManager) override;
143 
147  Rect getBounds() const override;
148 
152  void reset();
153 
157  void postLoad();
158 
162  void enterNode(CNodeItem *node);
163 
167  void enterRoom(CRoomItem *room);
168 
172  void resetRemoteTarget();
173 
177  void setRemoteTarget(CGameObject *item);
178 
182  PetArea setArea(PetArea newSection, bool forceChange = false);
183 
187  void hideCursor();
188 
192  void showCursor();
193 
197  void highlightGlyph(int id);
198 
199 
204  CGameObject *getHiddenObject(const CString &name);
205 
210 
214  void drawSquares(CScreenManager *screenManager, int count);
215 
219  bool contains(const Point &pt) const {
220  return _drawBounds.contains(pt);
221  }
222 
226  CGameObject *dragEnd(const Point &pt) const;
227 
231  bool checkDragEnd(CGameObject *item) const;
232 
236  void displayMessage(StringId stringId, int param = 0) const;
237 
241  void displayMessage(const CString &str, int param = 0) const;
242 
246  void addTranslation(StringId id1, StringId id2);
247 
251  void clearTranslation();
252 
256  CGameObject *getFirstObject() const;
257 
262  CGameObject *getNextObject(CGameObject *prior) const;
263 
267  void addToInventory(CGameObject *item);
268 
272  void removeFromInventory(CGameObject *item, CTreeItem *newParent,
273  bool refreshUI = true, bool sendMsg = true);
274 
278  void removeFromInventory(CGameObject *item, bool refreshUI = true, bool sendMsg = true);
279 
283  void invChange(CGameObject *item);
284 
288  void moveToHiddenRoom(CTreeItem *item);
289 
294  void setAreaChangeType(int changeType) { _areaChangeType = changeType; }
295 
296  bool checkNode(const CString &name);
297 
301  void syncSoundSettings();
302 
306  void playSound(int soundNum);
307 
311  int canSummonBot(const CString &name);
312 
316  void summonBot(const CString &name, int val);
317 
321  void onSummonBot(const CString &name, int val);
322 
326  bool dismissBot(const CString &name);
327 
331  bool isDoorOrBellbotPresent() const;
332 
336  void startPetTimer(uint timerIndex, uint firstDuration, uint duration, CPetSection *target);
337 
341  void stopPetTimer(uint timerIndex);
342 
346  bool isInputLocked() const { return _inputLockCount > 0; }
347 
351  void incInputLocks() { ++_inputLockCount; }
352 
356  void decInputLocks() { --_inputLockCount; }
357 
361  bool isAreaUnlocked() const { return _areaLockCount == 0; }
362 
366  void incAreaLocks() { ++_areaLockCount; }
367 
371  void decAreaLocks() {
372  _areaLockCount = MAX(_areaLockCount - 1, 0);
373  }
374 
375  bool isSuccUBusActive() const;
376 
377  /*--- CPetConversations methods ---*/
378 
382  void setActiveNPC(const CString &name);
383 
387  void setActiveNPC(CTrueTalkNPC *npc);
388 
392  void refreshNPC();
393 
397  void resetActiveNPC();
398 
402  void convResetNPC() {
403  _conversations.resetNPC();
404  }
405 
409  void resetDials0();
410 
414  void convResetDials(int flag = 1);
415 
419  void convAddLine(const CString &line) {
420  _conversations.addLine(line);
421  }
422 
423  /*--- CPetRooms methods ---*/
424 
428  void reassignRoom(PassengerClass passClassNum) {
429  _rooms.reassignRoom(passClassNum);
430  }
431 
435  bool changeLocationClass(PassengerClass newClassNum) {
436  return _rooms.changeLocationClass(newClassNum);
437  }
438 
442  bool isInAssignedRoom() const {
443  return _rooms.isAssignedRoom(getRoomFlags());
444  }
445 
446  uint getRoomFlags() const {
447  return _rooms.getRoomFlags();
448  }
449 
453  void setRoomsElevatorNum(int elevNum) {
454  _rooms.setElevatorNum(elevNum);
455  }
456 
460  int getRoomsElevatorNum() const {
461  return _rooms.getElevatorNum();
462  }
463 
467  void setRoomsFloorNum(int floorNum) {
468  _rooms.setFloorNum(floorNum);
469  }
470 
474  int getRoomsFloorNum() const {
475  return _rooms.getFloorNum();
476  }
477 
481  void setRoomsRoomNum(int roomNum) {
482  _rooms.setRoomNum(roomNum);
483  }
484 
488  int getRoomsRoomNum() const {
489  return _rooms.getRoomNum();
490  }
491 
495  void setRoomsWellEntry(int entryNum) {
496  _rooms.setWellEntry(entryNum);
497  }
498 
502  int getRoomsWellEntry() const {
503  return _rooms.getWellEntry();
504  }
505 
509  void setRoomsSublevel(int level) {
510  _rooms.setSublevel(level);
511  }
512 
516  int getRoomsSublevel() const {
517  return _rooms.getSublevel();
518  }
519 
524  _rooms.resetHighlight();
525  }
526 
527  int getAssignedRoomFlags() const {
528  return _rooms.getAssignedRoomFlags();
529  }
530 
531  uint getSpecialRoomFlags(const CString &name) {
532  return CRoomFlags::getSpecialRoomFlags(name);
533  }
534 
538  PassengerClass getMailDestClass(const CRoomFlags &roomFlags) const;
539 
543  bool isSuccUBusDest(uint roomFlags) {
544  return CRoomFlags(roomFlags).isSuccUBusDest();
545  }
546 
550  int getAssignedRoomNum() const {
551  return _rooms.getAssignedRoomNum();
552  }
553 
557  int getAssignedFloorNum() const {
558  return _rooms.getAssignedFloorNum();
559  }
560 
565  return _rooms.getAssignedElevatorNum();
566  }
567 
571  void setRoomsElevatorBroken(bool flag) {
572  _rooms.setElevatorBroken(flag);
573  }
574 
578  bool isFirstClassSuite() const {
579  return CRoomFlags(getRoomFlags()).isFirstClassSuite();
580  }
581 
585  bool isSuccUBusRoom(const CRoomFlags &roomFlags) {
586  return roomFlags.isSuccUBusRoomFlags();
587  }
588 
592  void phonographAction(const CString &action) {
593  // Original had some code that had no effect
594  }
595 
599  void starsSetButtons(int matchIndex, bool isMarkerClose);
600 
604  void starsSetReference();
605 };
606 
607 } // End of namespace Titanic
608 
609 #endif /* TITANIC_PET_CONTROL_H */
Definition: mouse_messages.h:150
void enterRoom(CRoomItem *room)
void onSummonBot(const CString &name, int val)
void convAddLine(const CString &line)
Definition: pet_control.h:419
int getAssignedFloorNum() const
Definition: pet_control.h:557
bool isAssignedRoom(uint roomFlags) const
void incInputLocks()
Definition: pet_control.h:351
PetArea setArea(PetArea newSection, bool forceChange=false)
int getRoomsSublevel() const
Definition: pet_control.h:516
void setRoomsFloorNum(int floorNum)
Definition: pet_control.h:467
bool isFirstClassSuite() const
Definition: room_flags.h:227
void reassignRoom(PassengerClass passClassNum)
Definition: pet_control.h:428
int getAssignedElevatorNum() const
bool isInAssignedRoom() const
Definition: pet_control.h:442
Definition: mouse_messages.h:117
bool contains(int16 x, int16 y) const
Definition: rect.h:210
Definition: pet_section.h:51
int getWellEntry() const
Definition: pet_rooms.h:213
void startPetTimer(uint timerIndex, uint firstDuration, uint duration, CPetSection *target)
Rect getBounds() const override
void save(SimpleFile *file, int indent) override
Definition: true_talk_npc.h:43
Definition: mouse_messages.h:139
void addLine(const CString &line)
void draw(CScreenManager *screenManager) override
Definition: room_flags.h:30
Definition: pet_inventory.h:35
void displayMessage(StringId stringId, int param=0) const
bool contains(const Point &pt) const
Definition: pet_control.h:219
Definition: simple_file.h:49
bool isAreaUnlocked() const
Definition: pet_control.h:361
void setRoomsSublevel(int level)
Definition: pet_control.h:509
Definition: room_item.h:33
void setAreaChangeType(int changeType)
Definition: pet_control.h:294
Definition: node_item.h:29
int getAssignedElevatorNum() const
Definition: pet_control.h:564
bool isSuccUBusRoom(const CRoomFlags &roomFlags)
Definition: pet_control.h:585
Definition: messages.h:188
CRoomItem * getHiddenRoom()
Definition: screen_manager.h:49
void decAreaLocks()
Definition: pet_control.h:371
CGameObject * getNextObject(CGameObject *prior) const
void convResetDials(int flag=1)
void summonBot(const CString &name, int val)
Definition: game_object.h:79
int getRoomsRoomNum() const
Definition: pet_control.h:488
void enterNode(CNodeItem *node)
Definition: pet_starfield.h:33
Definition: messages.h:408
Definition: pet_remote.h:33
uint getAssignedRoomFlags() const
void invChange(CGameObject *item)
Definition: mouse_messages.h:181
Definition: pet_rooms.h:32
void incAreaLocks()
Definition: pet_control.h:366
Definition: tree_item.h:37
void playSound(int soundNum)
int getRoomsFloorNum() const
Definition: pet_control.h:474
void moveToHiddenRoom(CTreeItem *item)
Definition: rect.h:35
Definition: mouse_messages.h:103
void starsSetButtons(int matchIndex, bool isMarkerClose)
bool changeLocationClass(PassengerClass newClassNum)
Definition: pet_control.h:435
Definition: pet_real_life.h:34
bool isSuccUBusRoomFlags() const
Definition: rect.h:45
void removeFromInventory(CGameObject *item, CTreeItem *newParent, bool refreshUI=true, bool sendMsg=true)
Definition: arm.h:30
void resetRoomsHighlight()
Definition: pet_control.h:523
Definition: string.h:40
void addToInventory(CGameObject *item)
PassengerClass getMailDestClass(const CRoomFlags &roomFlags) const
void stopPetTimer(uint timerIndex)
int getAssignedRoomNum() const
Definition: pet_control.h:550
CGameObject * getHiddenObject(const CString &name)
bool isInputLocked() const
Definition: pet_control.h:346
int getRoomsWellEntry() const
Definition: pet_control.h:502
int getRoomsElevatorNum() const
Definition: pet_control.h:460
bool isDoorOrBellbotPresent() const
void drawSquares(CScreenManager *screenManager, int count)
void highlightGlyph(int id)
void setActiveNPC(const CString &name)
Definition: mouse_messages.h:87
void phonographAction(const CString &action)
Definition: pet_control.h:592
void setRoomsElevatorNum(int elevNum)
Definition: pet_control.h:453
static uint getSpecialRoomFlags(const CString &roomName)
void setElevatorBroken(bool flag)
Definition: pet_rooms.h:218
Definition: messages.h:307
uint getRoomFlags() const
Definition: mouse_messages.h:71
void decInputLocks()
Definition: pet_control.h:356
CGameObject * dragEnd(const Point &pt) const
int getAssignedFloorNum() const
bool checkDragEnd(CGameObject *item) const
void load(SimpleFile *file) override
T MAX(T a, T b)
Definition: util.h:62
int getAssignedRoomNum() const
Definition: pet_conversations.h:34
bool isSuccUBusDest() const
Definition: room_flags.h:222
Definition: pet_frame.h:34
void setRemoteTarget(CGameObject *item)
void convResetNPC()
Definition: pet_control.h:402
void resetNPC() override
int canSummonBot(const CString &name)
void setRoomsWellEntry(int entryNum)
Definition: pet_control.h:495
Definition: pet_translation.h:30
void addTranslation(StringId id1, StringId id2)
void setRoomsElevatorBroken(bool flag)
Definition: pet_control.h:571
bool changeLocationClass(PassengerClass newClassNum)
void setRoomsRoomNum(int roomNum)
Definition: pet_control.h:481
bool dismissBot(const CString &name)
void reassignRoom(PassengerClass passClassNum)
bool isFirstClassSuite() const
Definition: pet_control.h:578
Definition: pet_control.h:45
void setWellEntry(int val)
Definition: pet_rooms.h:208
CGameObject * getFirstObject() const
bool isSuccUBusDest(uint roomFlags)
Definition: pet_control.h:543