ScummVM API documentation
game_object.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_GAME_OBJECT_H
23 #define TITANIC_GAME_OBJECT_H
24 
25 #include "audio/mixer.h"
26 #include "common/stream.h"
27 #include "titanic/core/named_item.h"
28 #include "titanic/sound/proximity.h"
29 #include "titanic/sound/sound_manager.h"
30 #include "titanic/support/mouse_cursor.h"
31 #include "titanic/support/credit_text.h"
32 #include "titanic/support/movie_range_info.h"
33 #include "titanic/support/rect.h"
34 #include "titanic/support/strings.h"
35 #include "titanic/support/movie_clip.h"
36 #include "titanic/pet_control/pet_section.h"
37 #include "titanic/gfx/text_control.h"
38 #include "titanic/game_state.h"
39 
40 namespace Titanic {
41 
42 enum Find { FIND_GLOBAL = 1, FIND_ROOM = 2, FIND_PET = 4, FIND_MAILMAN = 8 };
43 enum Found { FOUND_NONE = 0, FOUND_GLOBAL = 1, FOUND_ROOM = 2, FOUND_PET = 3, FOUND_MAILMAN = 4 };
44 enum RoomFlagsComparison { RFC_LOCATION = 1, RFC_CLASS_ELEVATOR = 2, RFC_TITANIA = 3 };
45 
46 enum StarControlAction {
47  STAR_SHOW = 0,
48  STAR_HIDE,
49  STAR_VIEW_EARTH,
50  STAR_VIEW_FROM_EARTH,
51  STAR_VIEW_BOUNDARIES,
52  STAR_VIEW_CONSTELLATIONS,
53  STAR_VIEW_RANDOM_STAR,
54  STAR_FULL_SPEED,
55  STAR_TOGGLE_STEREO_PAIR,
56  STAR_TOGGLE_HOME_PHOTO,
57  STAR_TOGGLE_SOLAR_RENDERING,
58  STAR_TOGGLE_POS_FRAME,
59  STAR_STEREO_PAIR_ON,
60  STAR_STEREO_PAIR_OFF,
61  STAR_SET_REFERENCE,
62  STAR_FADE_IN,
63  STAR_FADE_OUT,
64  LOCK_STAR,
65  UNLOCK_STAR,
66  STAR_CLEAR_MODIFIED
67 };
68 
69 class CDontSaveFileItem;
70 class CMailMan;
71 class CMusicRoom;
72 class CRoomItem;
73 class CStarControl;
74 class CMouseDragStartMsg;
75 class CTrueTalkNPC;
76 class CVideoSurface;
77 class OSMovie;
78 
79 class CGameObject : public CNamedItem {
80  friend class OSMovie;
81  DECLARE_MESSAGE_MAP;
82 private:
83  static int _soundHandles[4];
84 private:
88  void loadResource(const CString &name);
89 
93  void processMoveRangeInfo();
94 
99  bool clipRect(const Rect &rect1, Rect &rect2) const;
100 protected:
101  static CCreditText *_credits;
102 protected:
103  double _unused1;
104  double _unused2;
105  double _unused3;
106  bool _nonvisual;
107  byte _toggleR, _toggleG, _toggleB;
108  CMovieClipList _movieClips;
109  int _initialFrame;
110  CMovieRangeInfoList _movieRangeInfoList;
111  int _frameNumber;
112  CTextControl *_text;
113  uint _textBorder;
114  uint _textBorderRight;
115  Common::Point _savedPos;
116  CVideoSurface *_surface;
117  CString _resource;
118  int _unused4;
119 protected:
123  void savePosition();
124 
128  void resetPosition();
129 
134 
138  void gotoView(const CString &viewName, const CString &clipName);
139 
144  CViewItem * parseView(const CString &viewString);
145 
149  void loadMovie(const CString &name, bool pendingFlag = true);
150 
154  void loadImage(const CString &name, bool pendingFlag = true);
155 
159  void incTransitions();
160 
164  void decTransitions();
165 
169  void lockMouse();
170 
174  void unlockMouse();
175 
179  void hideMouse();
180 
184  void showMouse();
185 
189  void disableMouse();
190 
194  void enableMouse();
195 
199  void mouseDisableControl();
200 
204  void mouseEnableControl();
205 
209  void mouseSetPosition(const Point &pt, double rate);
210 
214  void lockInputHandler();
215 
219  void unlockInputHandler();
220 
224  void loadSound(const CString &name);
225 
233  int playSound(const CString &name, uint volume = 100, int balance = 0, bool repeated = false);
234 
240  int playSound(const CString &name, CProximity &prox);
241 
250  int queueSound(const CString &name, uint priorHandle, uint volume = 100, int balance = 0,
251  bool repeated = false, Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType);
252 
258  void stopSound(int handle, uint seconds = 0);
259 
263  bool isSoundActive(int handle) const;
264 
271  void setSoundVolume(int handle, uint percent, uint seconds);
272 
282  void playAmbientSound(const CString &resName, VolumeMode mode, bool initialMute, bool repeated,
283  int handleIndex, Audio::Mixer::SoundType soundType = Audio::Mixer::kMusicSoundType);
284 
290  void stopAmbientSound(bool transition, int handleIndex);
291 
298  void setAmbientSoundVolume(VolumeMode mode, uint seconds, int handleIndex);
299 
303  void stopSoundChannel(bool channel3);
304 
308  int addTimer(int endVal, uint firstDuration, uint repeatDuration);
309 
313  int addTimer(uint firstDuration, uint repeatDuration = 0);
314 
318  void stopTimer(int id);
319 
323  int startAnimTimer(const CString &action, uint firstDuration, uint repeatDuration = 0);
324 
328  void stopAnimTimer(int id);
329 
333  void sleep(uint milli);
334 
338  Point getMousePos() const;
339 
340  /*
341  * Compares the current view's name in a Room.Node.View tuplet
342  * string form to the passed string
343  */
344  bool compareViewNameTo(const CString &name) const;
345 
349  bool compareRoomNameTo(const CString &name);
350 
355 
360 
364  CGameObject *findMailByFlags(RoomFlagsComparison compareType, uint roomFlags);
365 
370 
374  CGameObject *findRoomObject(const CString &name) const;
375 
379  CGameObject *findInRoom(const CString &name);
380 
384  void moveToView();
385 
389  void moveToView(const CString &name);
390 
394  bool changeView(const CString &viewName, const CString &clipName);
395 
399  bool changeView(const CString &viewName);
400 
404  void playClip(const CString &name, uint flags = 0);
405 
409  void playClip(uint startFrame, uint endFrame);
410 
415  bool playCutscene(uint startFrame, uint endFrame);
416 
420  void playRandomClip(const char *const *names, uint flags = 0);
421 
425  CString getViewFullName() const;
426 
431  bool clipExistsByStart(const CString &name, int startFrame = 0) const;
432 
437  bool clipExistsByEnd(const CString &name, int endFrame = 0) const;
438 
442  void petClear() const;
443 
447  CMailMan *getMailMan() const;
448 
453 
457  CTreeItem *getDontSaveChild(ClassDef *classDef) const;
458 
462  CRoomItem *getHiddenRoom() const;
463 
467  CRoomItem *locateRoom(const CString &name) const;
468 
472  CTreeItem *findUnder(CTreeItem *parent, const CString &name) const;
473 
477  CRoomItem *findRoomByName(const CString &name);
478 
482  CMusicRoom *getMusicRoom() const;
483 
487  void setPassengerClass(PassengerClass newClass);
488 
493  void setToggleColor(byte r, byte g, byte b);
494 
498  int getClipDuration(const CString &name, int frameRate = 14) const;
499 
503  uint32 getTicksCount();
504 
509 
513  bool mailExists(uint roomFlags) const;
514 
518  CGameObject *findMail(uint roomFlags) const;
519 
523  void resetMail();
524 
528  void petLockInput();
529 
533  void petUnlockInput();
534 
538  void quitGame();
539 
543  void setMovieFrameRate(double rate);
544 
548  int getRandomNumber(int max, int *oldVal = nullptr);
549 
556 public:
557  Rect _bounds;
558  bool _isPendingMail;
559  uint _destRoomFlags;
560  uint _roomFlags;
561  bool _handleMouseFlag;
562  CursorId _cursorId;
563  bool _visible;
564 public:
568  static void init();
569 
573  static void deinit();
574 public:
575  CLASSDEF;
576  CGameObject();
577  ~CGameObject() override;
578 
582  void save(SimpleFile *file, int indent) override;
583 
587  void load(SimpleFile *file) override;
588 
592  const CMovieClipList *getMovieClips() const override { return &_movieClips; }
593 
597  void draw(CScreenManager *screenManager) override;
598 
602  Rect getBounds() const override;
603 
607  void freeSurface() override;
608 
612  void draw(CScreenManager *screenManager, const Rect &destRect, const Rect &srcRect);
613 
617  void draw(CScreenManager *screenManager, const Point &destPos);
618 
622  void draw(CScreenManager *screenManager, const Point &destPos, const Rect &srcRect);
623 
627  virtual bool isPet() const;
628 
633  bool checkPoint(const Point &pt, bool ignoreSurface = false, bool visibleOnly = false);
634 
642  bool findPoint(Quadrant quadrant, Point &pt);
643 
647  void setPosition(const Point &newPos);
648 
652  Point getControid() const;
653 
657  void playMovie(uint flags);
658 
662  void playMovie(int startFrame, int endFrame, uint flags);
663 
667  void playMovie(int startFrame, int endFrame, int initialFrame, uint flags);
668 
672  bool hasActiveMovie() const;
673 
677  void stopMovie();
678 
682  void movieSetPlaying(bool flag);
683 
687  int getMovieFrame() const;
688 
692  int getFrameNumber() const { return _frameNumber; }
693 
697  void loadFrame(int frameNumber);
698 
702  void loadSurface();
703 
707  void makeDirty();
708 
712  void makeDirty(const Rect &r);
713 
717  void setVisible(bool val);
718 
722  PassengerClass getPassengerClass() const;
723 
727  PassengerClass getPriorClass() const;
728 
732  void setMailDest(uint roomFlags);
733 
738  bool surfaceHasFrame() const;
739 
743  Found find(const CString &name, CGameObject **item, int findAreas);
744 
748  CGameObject *getHiddenObject(const CString &name) const;
749 
753  void dragMove(const Point &pt);
754 
759 
763  static bool compareRoomFlags(RoomFlagsComparison compareType, uint flags1, uint flags2);
764 
765  /*--- Text display methods ---*/
766 
770  void createCredits();
771 
775  void setText(const CString &str, int border = 0, int borderRight = 0);
776 
780  void setTextHasBorders(bool hasBorders);
781 
785  void setTextBounds();
786 
790  void setTextColor(byte r, byte g, byte b);
791 
795  void setTextFontNumber(int fontNumber);
796 
800  int getTextWidth() const;
801 
805  void scrollTextUp();
806 
810  void scrollTextDown();
811 
815  CTextCursor *getTextCursor() const;
816 
820  Movement getMovement() const;
821 
822  /*--- CGameManager Methods ---*/
823 
827  CRoomItem *getRoom() const;
828 
832  CNodeItem *getNode() const;
833 
837  CViewItem *getView() const;
838 
842  CString getRoomName() const;
843 
847  CString getRoomNodeName() const;
848 
852  void addMail(uint destRoomFlags);
853 
857  void sendMail(uint currRoomFlags, uint newRoomFlags);
858 
864 
865  /*--- CPetControl Methods ---*/
866 
870  CPetControl *getPetControl() const;
871 
875  void petAddToCarryParcel(CGameObject *obj);
876 
880  void petAddToInventory();
881 
882  CTreeItem *petContainerRemove(CGameObject *obj);
883 
884  bool petCheckNode(const CString &name);
885 
889  bool petDismissBot(const CString &name);
890 
894  bool petDoorOrBellbotPresent() const;
895 
899  void petDisplayMessage(int unused, StringId stringId);
900 
904  void petDisplayMessage(int unused, const CString &str);
905 
909  void petDisplayMessage(StringId stringId, int param = 0);
910 
914  void petDisplayMessage(const CString &str, int param = 0);
915 
919  int petGetRoomsWellEntry() const;
920 
924  void petHide();
925 
929  void petHideCursor();
930 
934  void petHighlightGlyph(int id);
935 
939  void petInvChange();
940 
944  void petMoveToHiddenRoom();
945 
949  void petReassignRoom(PassengerClass passClassNum);
950 
954  void petSetArea(PetArea newArea) const;
955 
959  void petSetRemoteTarget();
960 
964  void petSetRoomsWellEntry(int entryNum);
965 
969  void petSetRoomsElevatorBroken(bool flag);
970 
974  void petShow();
975 
979  void petIncAreaLocks();
980 
984  void petDecAreaLocks();
985 
989  void petShowCursor();
990 
994  void petOnSummonBot(const CString &name, int val);
995 
996  /*--- CStarControl Methods ---*/
997 
1001  CStarControl *getStarControl() const;
1002 
1006  void starFn(StarControlAction action);
1007 
1011  bool starIsSolved() const;
1012 
1013  /*--- CTrueTalkManager Methods ---*/
1014 
1018  void startTalking(CTrueTalkNPC *npc, uint id, CViewItem *view = nullptr);
1019 
1023  void startTalking(const CString &name, uint id, CViewItem *view = nullptr);
1024 
1028  void setTalking(CTrueTalkNPC *npc, bool viewFlag, CViewItem *view = nullptr);
1029 
1030 
1034  void talkSetDialRegion(const CString &name, int dialNum, int regionNum);
1035 
1039  int talkGetDialRegion(const CString &name, int dialNum);
1040 
1041  /*--- CVideoSurface Methods ---*/
1042 
1046  void movieEvent(int frameNumber);
1047 
1052  void movieEvent();
1053 
1054  /*--- CGameState Methods ---*/
1055 
1059  void stateSetSoundMakerAllowed(bool flag);
1060 
1064  void stateChangeSeason();
1065 
1069  Season stateGetSeason() const;
1070 
1074  void stateSetParrotMet();
1075 
1079  bool stateGetParrotMet() const;
1080 
1084  void incParrotResponse();
1085 
1089  int getParrotResponse() const;
1090 
1094  uint getNodeChangedCtr() const;
1095 
1099  uint getNodeEnterTicks() const;
1100 };
1101 
1102 } // End of namespace Titanic
1103 
1104 #endif /* TITANIC_GAME_OBJECT_H */
Definition: mouse_messages.h:150
CViewItem * getView() const
CRoomItem * findRoomByName(const CString &name)
Definition: mixer.h:65
const CMovieClipList * getMovieClips() const override
Definition: game_object.h:592
void petReassignRoom(PassengerClass passClassNum)
void petHighlightGlyph(int id)
bool isBotDisallowedLocation()
Definition: text_control.h:35
int petGetRoomsWellEntry() const
CMailMan * getMailMan() const
Definition: dont_save_file_item.h:29
CGameObject * getDraggingObject() const
CGameObject * getMailManNextObject(CGameObject *prior) const
bool hasActiveMovie() const
bool surfaceHasFrame() const
void startTalking(CTrueTalkNPC *npc, uint id, CViewItem *view=nullptr)
CNodeItem * getNode() const
void petSetArea(PetArea newArea) const
void setMailDest(uint roomFlags)
CTextCursor * getTextCursor() const
void petDisplayMessage(int unused, StringId stringId)
CString getFullViewName()
bool changeView(const CString &viewName, const CString &clipName)
void setTextColor(byte r, byte g, byte b)
CGameObject * getHiddenObject(const CString &name) const
void setTalking(CTrueTalkNPC *npc, bool viewFlag, CViewItem *view=nullptr)
Definition: true_talk_npc.h:43
int getMovieFrame() const
void petClear() const
CMusicRoom * getMusicRoom() const
void playMovie(uint flags)
void setAmbientSoundVolume(VolumeMode mode, uint seconds, int handleIndex)
Point getMousePos() const
void stopAmbientSound(bool transition, int handleIndex)
Definition: credit_text.h:48
void load(SimpleFile *file) override
Definition: proximity.h:36
Definition: mail_man.h:29
int getRandomNumber(int max, int *oldVal=nullptr)
CGameObject * getNextMail(CGameObject *prior)
void mouseSetPosition(const Point &pt, double rate)
void talkSetDialRegion(const CString &name, int dialNum, int regionNum)
Movement getMovement() const
Found find(const CString &name, CGameObject **item, int findAreas)
Definition: stream.h:745
CGameObject * findRoomObject(const CString &name) const
Definition: simple_file.h:49
void gotoView(const CString &viewName, const CString &clipName)
Definition: saveable_object.h:35
void addMail(uint destRoomFlags)
Definition: movie_range_info.h:76
void setSoundVolume(int handle, uint percent, uint seconds)
Definition: room_item.h:33
Definition: named_item.h:33
Definition: node_item.h:29
int playSound(const CString &name, uint volume=100, int balance=0, bool repeated=false)
void sleep(uint milli)
void movieSetPlaying(bool flag)
CRoomItem * getRoom() const
CGameObject * getMailManFirstObject() const
Definition: screen_manager.h:49
CString getViewFullName() const
PassengerClass getPriorClass() const
int startAnimTimer(const CString &action, uint firstDuration, uint repeatDuration=0)
CDontSaveFileItem * getDontSave() const
void stateSetSoundMakerAllowed(bool flag)
void playClip(const CString &name, uint flags=0)
bool checkPoint(const Point &pt, bool ignoreSurface=false, bool visibleOnly=false)
void petSetRoomsWellEntry(int entryNum)
Definition: game_object.h:79
void freeSurface() override
SoundType
Definition: mixer.h:62
void playAmbientSound(const CString &resName, VolumeMode mode, bool initialMute, bool repeated, int handleIndex, Audio::Mixer::SoundType soundType=Audio::Mixer::kMusicSoundType)
bool starIsSolved() const
Point getControid() const
CRoomItem * locateRoom(const CString &name) const
void draw(CScreenManager *screenManager) override
void setMovieFrameRate(double rate)
void starFn(StarControlAction action)
int getFrameNumber() const
Definition: game_object.h:692
void petSetRoomsElevatorBroken(bool flag)
bool isSoundActive(int handle) const
void stopAnimTimer(int id)
Definition: tree_item.h:37
bool clipExistsByStart(const CString &name, int startFrame=0) const
void stopTimer(int id)
void setPassengerClass(PassengerClass newClass)
void save(SimpleFile *file, int indent) override
bool mailExists(uint roomFlags) const
Definition: rect.h:35
void loadMovie(const CString &name, bool pendingFlag=true)
void petAddToCarryParcel(CGameObject *obj)
void sendMail(uint currRoomFlags, uint newRoomFlags)
void playRandomClip(const char *const *names, uint flags=0)
int queueSound(const CString &name, uint priorHandle, uint volume=100, int balance=0, bool repeated=false, Audio::Mixer::SoundType soundType=Audio::Mixer::kPlainSoundType)
void loadFrame(int frameNumber)
CPetControl * getPetControl() const
void setPosition(const Point &newPos)
uint getNodeChangedCtr() const
Definition: rect.h:45
Definition: arm.h:30
void setTextFontNumber(int fontNumber)
Definition: string.h:40
Definition: text_cursor.h:33
bool petDismissBot(const CString &name)
CTreeItem * getDontSaveChild(ClassDef *classDef) const
static bool compareRoomFlags(RoomFlagsComparison compareType, uint flags1, uint flags2)
void setTextHasBorders(bool hasBorders)
CViewItem * parseView(const CString &viewString)
void loadImage(const CString &name, bool pendingFlag=true)
bool playCutscene(uint startFrame, uint endFrame)
bool compareRoomNameTo(const CString &name)
Definition: movie_clip.h:69
void petOnSummonBot(const CString &name, int val)
void setText(const CString &str, int border=0, int borderRight=0)
int addTimer(int endVal, uint firstDuration, uint repeatDuration)
void stopSoundChannel(bool channel3)
CGameObject * findMail(uint roomFlags) const
CTreeItem * findUnder(CTreeItem *parent, const CString &name) const
PassengerClass getPassengerClass() const
uint getNodeEnterTicks() const
bool findPoint(Quadrant quadrant, Point &pt)
void stopSound(int handle, uint seconds=0)
CStarControl * getStarControl() const
Rect getBounds() const override
Definition: video_surface.h:43
CGameObject * findMailByFlags(RoomFlagsComparison compareType, uint roomFlags)
void setToggleColor(byte r, byte g, byte b)
static void init()
static void deinit()
bool petDoorOrBellbotPresent() const
int talkGetDialRegion(const CString &name, int dialNum)
bool stateGetParrotMet() const
void setVisible(bool val)
Definition: movie.h:165
int getClipDuration(const CString &name, int frameRate=14) const
CGameObject * findInRoom(const CString &name)
int getParrotResponse() const
void dragMove(const Point &pt)
Season stateGetSeason() const
Common::SeekableReadStream * getResource(const CString &name)
Definition: music_room.h:33
void loadSound(const CString &name)
Definition: mixer.h:63
Definition: pet_control.h:45
int getTextWidth() const
CString getRoomName() const
Definition: star_control.h:33
virtual bool isPet() const
CRoomItem * getHiddenRoom() const
Definition: view_item.h:32
CString getRoomNodeName() const
bool clipExistsByEnd(const CString &name, int endFrame=0) const
bool checkStartDragging(CMouseDragStartMsg *msg)