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
40namespace Titanic {
41
42enum Find { FIND_GLOBAL = 1, FIND_ROOM = 2, FIND_PET = 4, FIND_MAILMAN = 8 };
43enum Found { FOUND_NONE = 0, FOUND_GLOBAL = 1, FOUND_ROOM = 2, FOUND_PET = 3, FOUND_MAILMAN = 4 };
44enum RoomFlagsComparison { RFC_LOCATION = 1, RFC_CLASS_ELEVATOR = 2, RFC_TITANIA = 3 };
45
46enum 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
69class CDontSaveFileItem;
70class CMailMan;
71class CMusicRoom;
72class CRoomItem;
73class CStarControl;
74class CMouseDragStartMsg;
75class CTrueTalkNPC;
76class CVideoSurface;
77class OSMovie;
78
79class CGameObject : public CNamedItem {
80 friend class OSMovie;
81 DECLARE_MESSAGE_MAP;
82private:
83 static int _soundHandles[4];
84private:
88 void loadResource(const CString &name);
89
93 void processMoveRangeInfo();
94
99 bool clipRect(const Rect &rect1, Rect &rect2) const;
100protected:
101 static CCreditText *_credits;
102protected:
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;
119protected:
124
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
160
165
169 void lockMouse();
170
175
179 void hideMouse();
180
184 void showMouse();
185
190
195
200
205
209 void mouseSetPosition(const Point &pt, double rate);
210
215
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
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
380
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
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
448
453
458
463
467 CRoomItem *locateRoom(const CString &name) const;
468
472 CTreeItem *findUnder(CTreeItem *parent, const CString &name) const;
473
478
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
504
509
513 bool mailExists(uint roomFlags) const;
514
518 CGameObject *findMail(uint roomFlags) const;
519
523 void resetMail();
524
529
534
538 void quitGame();
539
543 void setMovieFrameRate(double rate);
544
548 int getRandomNumber(int max, int *oldVal = nullptr);
549
556public:
557 Rect _bounds;
558 bool _isPendingMail;
559 uint _destRoomFlags;
560 uint _roomFlags;
561 bool _handleMouseFlag;
562 CursorId _cursorId;
563 bool _visible;
564public:
568 static void init();
569
573 static void deinit();
574public:
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
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
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
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
771
775 void setText(const CString &str, int border = 0, int borderRight = 0);
776
780 void setTextHasBorders(bool hasBorders);
781
786
790 void setTextColor(byte r, byte g, byte b);
791
795 void setTextFontNumber(int fontNumber);
796
800 int getTextWidth() const;
801
806
811
816
820 Movement getMovement() const;
821
822 /*--- CGameManager Methods ---*/
823
828
833
838
843
848
852 void addMail(uint destRoomFlags);
853
857 void sendMail(uint currRoomFlags, uint newRoomFlags);
858
864
865 /*--- CPetControl Methods ---*/
866
871
876
881
882 CTreeItem *petContainerRemove(CGameObject *obj);
883
884 bool petCheckNode(const CString &name);
885
889 bool petDismissBot(const CString &name);
890
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
920
924 void petHide();
925
930
934 void petHighlightGlyph(int id);
935
940
945
949 void petReassignRoom(PassengerClass passClassNum);
950
954 void petSetArea(PetArea newArea) const;
955
960
964 void petSetRoomsWellEntry(int entryNum);
965
970
974 void petShow();
975
980
985
990
994 void petOnSummonBot(const CString &name, int val);
995
996 /*--- CStarControl Methods ---*/
997
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
1053
1054 /*--- CGameState Methods ---*/
1055
1060
1065
1069 Season stateGetSeason() const;
1070
1075
1079 bool stateGetParrotMet() const;
1080
1085
1090
1094 uint getNodeChangedCtr() const;
1095
1099 uint getNodeEnterTicks() const;
1100};
1101
1102} // End of namespace Titanic
1103
1104#endif /* TITANIC_GAME_OBJECT_H */
SoundType
Definition: mixer.h:73
@ kMusicSoundType
Definition: mixer.h:76
@ kPlainSoundType
Definition: mixer.h:74
Definition: stream.h:745
Definition: credit_text.h:48
Definition: dont_save_file_item.h:29
Definition: game_object.h:79
void setPassengerClass(PassengerClass newClass)
bool mailExists(uint roomFlags) const
void makeDirty(const Rect &r)
CRoomItem * locateRoom(const CString &name) const
Common::SeekableReadStream * getResource(const CString &name)
int getTextWidth() const
void setTextFontNumber(int fontNumber)
bool checkStartDragging(CMouseDragStartMsg *msg)
Point getMousePos() const
void petAddToCarryParcel(CGameObject *obj)
int addTimer(int endVal, uint firstDuration, uint repeatDuration)
CGameObject * findMailByFlags(RoomFlagsComparison compareType, uint roomFlags)
CViewItem * parseView(const CString &viewString)
CGameObject * findRoomObject(const CString &name) const
virtual bool isPet() const
void setTextHasBorders(bool hasBorders)
void talkSetDialRegion(const CString &name, int dialNum, int regionNum)
Found find(const CString &name, CGameObject **item, int findAreas)
void setMailDest(uint roomFlags)
bool playCutscene(uint startFrame, uint endFrame)
void petDisplayMessage(const CString &str, int param=0)
void playMovie(int startFrame, int endFrame, uint flags)
void sendMail(uint currRoomFlags, uint newRoomFlags)
void petDisplayMessage(int unused, StringId stringId)
void setTalking(CTrueTalkNPC *npc, bool viewFlag, CViewItem *view=nullptr)
CMailMan * getMailMan() const
int playSound(const CString &name, uint volume=100, int balance=0, bool repeated=false)
uint getNodeEnterTicks() const
CTextCursor * getTextCursor() const
int talkGetDialRegion(const CString &name, int dialNum)
void playMovie(int startFrame, int endFrame, int initialFrame, uint flags)
bool starIsSolved() const
void petSetRoomsWellEntry(int entryNum)
CStarControl * getStarControl() const
CPetControl * getPetControl() const
void loadSound(const CString &name)
int playSound(const CString &name, CProximity &prox)
CGameObject * getDraggingObject() const
void moveToView(const CString &name)
void setPosition(const Point &newPos)
bool clipExistsByStart(const CString &name, int startFrame=0) const
bool stateGetParrotMet() const
void loadImage(const CString &name, bool pendingFlag=true)
void setAmbientSoundVolume(VolumeMode mode, uint seconds, int handleIndex)
CString getRoomName() const
bool clipExistsByEnd(const CString &name, int endFrame=0) const
void dragMove(const Point &pt)
void petSetArea(PetArea newArea) const
void playAmbientSound(const CString &resName, VolumeMode mode, bool initialMute, bool repeated, int handleIndex, Audio::Mixer::SoundType soundType=Audio::Mixer::kMusicSoundType)
void loadFrame(int frameNumber)
int petGetRoomsWellEntry() const
CString getRoomNodeName() const
int getFrameNumber() const
Definition: game_object.h:692
bool isBotDisallowedLocation()
void petOnSummonBot(const CString &name, int val)
void petHighlightGlyph(int id)
int getClipDuration(const CString &name, int frameRate=14) const
void petDisplayMessage(int unused, const CString &str)
void petClear() const
void startTalking(CTrueTalkNPC *npc, uint id, CViewItem *view=nullptr)
CTreeItem * getDontSaveChild(ClassDef *classDef) const
PassengerClass getPassengerClass() const
CRoomItem * getHiddenRoom() const
void draw(CScreenManager *screenManager) override
void load(SimpleFile *file) override
static bool compareRoomFlags(RoomFlagsComparison compareType, uint flags1, uint flags2)
CGameObject * findMail(uint roomFlags) const
CGameObject * findInRoom(const CString &name)
bool checkPoint(const Point &pt, bool ignoreSurface=false, bool visibleOnly=false)
int getMovieFrame() const
bool compareRoomNameTo(const CString &name)
void setMovieFrameRate(double rate)
int getRandomNumber(int max, int *oldVal=nullptr)
CGameObject * getNextMail(CGameObject *prior)
static void init()
void save(SimpleFile *file, int indent) override
CGameObject * getMailManNextObject(CGameObject *prior) const
static void deinit()
CString getViewFullName() const
void stopTimer(int id)
void setText(const CString &str, int border=0, int borderRight=0)
bool petDoorOrBellbotPresent() const
CGameObject * getHiddenObject(const CString &name) const
void gotoView(const CString &viewName, const CString &clipName)
int addTimer(uint firstDuration, uint repeatDuration=0)
void setToggleColor(byte r, byte g, byte b)
uint getNodeChangedCtr() const
bool petDismissBot(const CString &name)
int queueSound(const CString &name, uint priorHandle, uint volume=100, int balance=0, bool repeated=false, Audio::Mixer::SoundType soundType=Audio::Mixer::kPlainSoundType)
CRoomItem * findRoomByName(const CString &name)
CTreeItem * findUnder(CTreeItem *parent, const CString &name) const
void stopAmbientSound(bool transition, int handleIndex)
int getParrotResponse() const
int startAnimTimer(const CString &action, uint firstDuration, uint repeatDuration=0)
void sleep(uint milli)
Rect getBounds() const override
void petDisplayMessage(StringId stringId, int param=0)
void addMail(uint destRoomFlags)
void startTalking(const CString &name, uint id, CViewItem *view=nullptr)
Point getControid() const
Season stateGetSeason() const
bool changeView(const CString &viewName, const CString &clipName)
void loadMovie(const CString &name, bool pendingFlag=true)
void playClip(uint startFrame, uint endFrame)
bool hasActiveMovie() const
void stopSoundChannel(bool channel3)
void movieSetPlaying(bool flag)
void freeSurface() override
bool isSoundActive(int handle) const
void setVisible(bool val)
void stopAnimTimer(int id)
bool findPoint(Quadrant quadrant, Point &pt)
void mouseSetPosition(const Point &pt, double rate)
void stopSound(int handle, uint seconds=0)
CRoomItem * getRoom() const
const CMovieClipList * getMovieClips() const override
Definition: game_object.h:592
PassengerClass getPriorClass() const
CString getFullViewName()
void petSetRoomsElevatorBroken(bool flag)
void playRandomClip(const char *const *names, uint flags=0)
void playMovie(uint flags)
CViewItem * getView() const
bool surfaceHasFrame() const
void petReassignRoom(PassengerClass passClassNum)
void draw(CScreenManager *screenManager, const Point &destPos, const Rect &srcRect)
void movieEvent(int frameNumber)
CGameObject * getMailManFirstObject() const
bool changeView(const CString &viewName)
CMusicRoom * getMusicRoom() const
void draw(CScreenManager *screenManager, const Rect &destRect, const Rect &srcRect)
void setTextColor(byte r, byte g, byte b)
void setSoundVolume(int handle, uint percent, uint seconds)
Movement getMovement() const
void draw(CScreenManager *screenManager, const Point &destPos)
void starFn(StarControlAction action)
void stateSetSoundMakerAllowed(bool flag)
CDontSaveFileItem * getDontSave() const
void playClip(const CString &name, uint flags=0)
CNodeItem * getNode() const
Definition: mail_man.h:29
Definition: mouse_messages.h:150
Definition: movie_clip.h:69
Definition: movie_range_info.h:76
Definition: music_room.h:33
Definition: named_item.h:33
Definition: node_item.h:29
Definition: pet_control.h:45
Definition: proximity.h:36
Definition: room_item.h:33
Definition: screen_manager.h:49
Definition: star_control.h:33
Definition: string.h:40
Definition: text_control.h:35
Definition: text_cursor.h:33
Definition: tree_item.h:37
Definition: true_talk_npc.h:43
Definition: video_surface.h:43
Definition: view_item.h:32
Definition: saveable_object.h:35
Definition: movie.h:165
Definition: rect.h:35
Definition: simple_file.h:49
Definition: rect.h:144