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
41namespace Titanic {
42
43enum SummonResult { SUMMON_CANT = 0, SUMMON_PRESENT = 1, SUMMON_CAN = 2 };
44
45class CPetControl : public CGameObject {
46 DECLARE_MESSAGE_MAP;
47 struct PetEventInfo {
48 int _id;
49 CPetSection *_target;
50 PetEventInfo() : _id(0), _target(nullptr) {}
51 };
52private:
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];
70private:
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);
110protected:
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 ActionMsg(CActionMsg *msg);
120 bool TimerMsg(CTimerMsg *msg);
121public:
122 PetArea _currentArea;
123 CTreeItem *_activeNPC;
124 CGameObject *_remoteTarget;
125public:
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
173
178
182 PetArea setArea(PetArea newSection, bool forceChange = false);
183
188
193
197 void highlightGlyph(int id);
198
199
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
252
257
263
268
273 bool refreshUI = true, bool sendMsg = true);
274
278 void removeFromInventory(CGameObject *item, bool refreshUI = true, bool sendMsg = true);
279
284
289
294 void setAreaChangeType(int changeType) { _areaChangeType = changeType; }
295
296 bool checkNode(const CString &name);
297
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
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
372 _areaLockCount = MAX(_areaLockCount - 1, 0);
373 }
374
375 bool isSuccUBusActive() const;
376
377 /*--- CPetConversations methods ---*/
378
382 void setActiveNPC(const CString &name);
383
388
393
398
403 _conversations.resetNPC();
404 }
405
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
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) {
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
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
605};
606
607} // End of namespace Titanic
608
609#endif /* TITANIC_PET_CONTROL_H */
Definition: messages.h:410
Definition: game_object.h:79
Definition: messages.h:309
Definition: mouse_messages.h:71
Definition: mouse_messages.h:87
Definition: mouse_messages.h:117
Definition: mouse_messages.h:181
Definition: mouse_messages.h:139
Definition: mouse_messages.h:150
Definition: mouse_messages.h:103
Definition: node_item.h:29
Definition: pet_control.h:45
void incInputLocks()
Definition: pet_control.h:351
int getAssignedElevatorNum() const
Definition: pet_control.h:564
int getRoomsSublevel() const
Definition: pet_control.h:516
void drawSquares(CScreenManager *screenManager, int count)
void setActiveNPC(CTrueTalkNPC *npc)
int canSummonBot(const CString &name)
void convResetNPC()
Definition: pet_control.h:402
CGameObject * getNextObject(CGameObject *prior) const
void reassignRoom(PassengerClass passClassNum)
Definition: pet_control.h:428
void setRoomsElevatorNum(int elevNum)
Definition: pet_control.h:453
void summonBot(const CString &name, int val)
bool contains(const Point &pt) const
Definition: pet_control.h:219
PetArea setArea(PetArea newSection, bool forceChange=false)
void setRemoteTarget(CGameObject *item)
int getRoomsWellEntry() const
Definition: pet_control.h:502
void removeFromInventory(CGameObject *item, CTreeItem *newParent, bool refreshUI=true, bool sendMsg=true)
void load(SimpleFile *file) override
void setRoomsWellEntry(int entryNum)
Definition: pet_control.h:495
void invChange(CGameObject *item)
bool isDoorOrBellbotPresent() const
bool isSuccUBusDest(uint roomFlags)
Definition: pet_control.h:543
void highlightGlyph(int id)
void resetRoomsHighlight()
Definition: pet_control.h:523
void draw(CScreenManager *screenManager) override
int getRoomsRoomNum() const
Definition: pet_control.h:488
void addTranslation(StringId id1, StringId id2)
void displayMessage(StringId stringId, int param=0) const
void playSound(int soundNum)
void addToInventory(CGameObject *item)
bool isInputLocked() const
Definition: pet_control.h:346
void incAreaLocks()
Definition: pet_control.h:366
void setAreaChangeType(int changeType)
Definition: pet_control.h:294
int getAssignedRoomNum() const
Definition: pet_control.h:550
CGameObject * dragEnd(const Point &pt) const
void convResetDials(int flag=1)
bool dismissBot(const CString &name)
void starsSetButtons(int matchIndex, bool isMarkerClose)
PassengerClass getMailDestClass(const CRoomFlags &roomFlags) const
int getRoomsElevatorNum() const
Definition: pet_control.h:460
CRoomItem * getHiddenRoom()
void setActiveNPC(const CString &name)
void decAreaLocks()
Definition: pet_control.h:371
void moveToHiddenRoom(CTreeItem *item)
int getRoomsFloorNum() const
Definition: pet_control.h:474
void phonographAction(const CString &action)
Definition: pet_control.h:592
bool isAreaUnlocked() const
Definition: pet_control.h:361
void setRoomsElevatorBroken(bool flag)
Definition: pet_control.h:571
Rect getBounds() const override
int getAssignedFloorNum() const
Definition: pet_control.h:557
void decInputLocks()
Definition: pet_control.h:356
void startPetTimer(uint timerIndex, uint firstDuration, uint duration, CPetSection *target)
void removeFromInventory(CGameObject *item, bool refreshUI=true, bool sendMsg=true)
void onSummonBot(const CString &name, int val)
CGameObject * getHiddenObject(const CString &name)
bool changeLocationClass(PassengerClass newClassNum)
Definition: pet_control.h:435
void enterNode(CNodeItem *node)
void save(SimpleFile *file, int indent) override
bool isSuccUBusRoom(const CRoomFlags &roomFlags)
Definition: pet_control.h:585
bool isFirstClassSuite() const
Definition: pet_control.h:578
void setRoomsFloorNum(int floorNum)
Definition: pet_control.h:467
CGameObject * getFirstObject() const
bool isInAssignedRoom() const
Definition: pet_control.h:442
void enterRoom(CRoomItem *room)
void stopPetTimer(uint timerIndex)
void displayMessage(const CString &str, int param=0) const
void setRoomsRoomNum(int roomNum)
Definition: pet_control.h:481
void convAddLine(const CString &line)
Definition: pet_control.h:419
bool checkDragEnd(CGameObject *item) const
void setRoomsSublevel(int level)
Definition: pet_control.h:509
Definition: pet_conversations.h:34
void addLine(const CString &line)
void resetNPC() override
Definition: pet_frame.h:34
Definition: pet_inventory.h:35
Definition: pet_real_life.h:34
Definition: pet_remote.h:33
Definition: pet_rooms.h:32
uint getRoomFlags() const
int getAssignedElevatorNum() const
uint getAssignedRoomFlags() const
int getAssignedRoomNum() const
void reassignRoom(PassengerClass passClassNum)
bool changeLocationClass(PassengerClass newClassNum)
void setElevatorBroken(bool flag)
Definition: pet_rooms.h:218
int getWellEntry() const
Definition: pet_rooms.h:213
void setWellEntry(int val)
Definition: pet_rooms.h:208
int getAssignedFloorNum() const
bool isAssignedRoom(uint roomFlags) const
Definition: pet_section.h:51
Definition: pet_starfield.h:33
Definition: pet_translation.h:30
Definition: room_flags.h:30
bool isSuccUBusDest() const
Definition: room_flags.h:222
bool isFirstClassSuite() const
Definition: room_flags.h:227
static uint getSpecialRoomFlags(const CString &roomName)
bool isSuccUBusRoomFlags() const
Definition: room_item.h:33
Definition: screen_manager.h:49
Definition: string.h:40
Definition: messages.h:190
Definition: tree_item.h:37
Definition: true_talk_npc.h:43
Definition: rect.h:35
Definition: simple_file.h:49
T MAX(T a, T b)
Definition: util.h:66
Definition: rect.h:144
bool contains(T x, T y) const
Definition: rect.h:246