ScummVM API documentation
cstime.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 MOHAWK_CSTIME_H
23 #define MOHAWK_CSTIME_H
24 
25 #include "mohawk/mohawk.h"
26 #include "mohawk/console.h"
27 #include "mohawk/cstime_graphics.h"
28 
29 #include "common/random.h"
30 #include "common/list.h"
31 
32 namespace Mohawk {
33 
34 class CSTimeCase;
35 class CSTimeInterface;
36 class CSTimeView;
37 class VideoManager;
38 
39 enum {
40  kCSTimeEventNothing = 0xffff,
41  kCSTimeEventCondition = 1,
42  kCSTimeEventCharPlayNIS = 2,
43  kCSTimeEventStartConversation = 3,
44  kCSTimeEventNewScene = 4,
45  kCSTimeEventCharStartFlapping = 5,
46  kCSTimeEventSetCaseVariable = 6,
47  kCSTimeEventSetupAmbientAnims = 7,
48  kCSTimeEventUnused8 = 8,
49  kCSTimeEventDropItemInInventory = 9,
50  kCSTimeEventRemoveItemFromInventory = 10,
51  kCSTimeEventAddNotePiece = 11,
52  kCSTimeEventDisableHotspot = 12,
53  kCSTimeEventDisableFeature = 13,
54  kCSTimeEventAddFeature = 14,
55  kCSTimeEventStartMusic = 15,
56  kCSTimeEventStopMusic = 16,
57  kCSTimeEventEnableHotspot = 17,
58  kCSTimeEventSetAsked = 18,
59  kCSTimeEventStartHelp = 19,
60  kCSTimeEventPlaySound = 20,
61  kCSTimeEventUnused21 = 21,
62  kCSTimeEventShowBigNote = 22,
63  kCSTimeEventActivateCuffs = 23,
64  kCSTimeEventHelperSetupRestPos = 24,
65  kCSTimeEventUnknown25 = 25,
66  kCSTimeEventUnknown26 = 26,
67  kCSTimeEventRemoveChar = 27,
68  kCSTimeEventUnknown28 = 28,
69  kCSTimeEventUnknown29 = 29,
70  kCSTimeEventUnknown30 = 30,
71  kCSTimeEventUnknown31 = 31,
72  kCSTimeEventCharSomeNIS32 = 32,
73  kCSTimeEventCharResetNIS = 33,
74  kCSTimeEventUnknown34 = 34,
75  kCSTimeEventCharPauseAmbients = 35,
76  kCSTimeEventCharUnauseAmbients = 36,
77  kCSTimeEventCharDisableAmbients = 37,
78  kCSTimeEventStopAmbientAnims = 38,
79  kCSTimeEventUnknown39 = 39,
80  kCSTimeEventWait = 40,
81  kCSTimeEventSpeech = 41,
82  kCSTimeEventCharSetState = 42,
83  kCSTimeEventUnknown43 = 43,
84  kCSTimeEventCharSetupRestPos = 44,
85  kCSTimeEventCharStopAmbients = 45,
86  kCSTimeEventCharRestartAmbients = 46,
87  kCSTimeEventStopEnvironmentSound = 47,
88  kCSTimeEventWaitForClick = 48,
89  kCSTimeEventSetMusic = 49,
90  kCSTimeEventStartEnvironmentSound = 50,
91  kCSTimeEventPreloadSound = 51,
92  kCSTimeEventPlayPreloadedSound = 52,
93  kCSTimeEventSetInsertBefore = 53,
94  kCSTimeEventSetEnvironmentSound = 54,
95  kCSTimeEventCharSomeNIS55 = 55,
96  kCSTimeEventUnknown56 = 56,
97  kCSTimeEventUpdateBubble = 57,
98  kCSTimeEventCharSurfAndFlap = 58,
99  kCSTimeEventInitScene = 59,
100  kCSTimeEventFadeDown = 60,
101  kCSTimeEventEndOfCase = 61,
102  kCSTimeEventCharPlaySimultaneousAnim = 62,
103  kCSTimeEventUnused63 = 63,
104  kCSTimeEventUnknown64 = 64,
105  kCSTimeEventPrepareSave = 65,
106  kCSTimeEventSave = 66,
107  kCSTimeEventQuit = 67,
108  kCSTimeEventPlayMovie = 68,
109  kCSTimeEventUnknown69 = 69, // queues Unknown48
110  kCSTimeEventUnknown70 = 70 // conv/QaR cleanup
111 };
112 
113 struct CSTimeEvent {
114  CSTimeEvent() : type(0), param1(0), param2(0) { }
115  CSTimeEvent(uint16 t, uint16 p1, uint16 p2) : type(t), param1(p1), param2(p2) { }
116 
117  uint16 type;
118  uint16 param1;
119  uint16 param2;
120 };
121 
122 enum CSTimeState {
123  kCSTStateStartup,
124  kCSTStateNewCase,
125  kCSTStateNewScene,
126  kCSTStateNormal
127 };
128 
130 protected:
131  Common::Error run() override;
132 
133 public:
134  MohawkEngine_CSTime(OSystem *syst, const MohawkGameDescription *gamedesc);
135  ~MohawkEngine_CSTime() override;
136 
137  Common::RandomSource *_rnd;
138 
139  VideoManager *_video;
140  Sound *_sound;
141  CSTimeGraphics *_gfx;
142  bool _needsUpdate;
143 
144  CSTimeView *getView() { return _view; }
145  CSTimeCase *getCase() { return _case; }
146  CSTimeInterface *getInterface() { return _interface; }
147 
148  void loadResourceFile(const Common::Path &name);
149 
150  void addEvent(const CSTimeEvent &event);
151  void addEventList(const Common::Array<CSTimeEvent> &list);
152  void insertEventAtFront(const CSTimeEvent &event);
153  uint16 getCurrentEventType();
154  void eventIdle();
155  void resetTimeout();
156  void mouseClicked();
157  bool NISIsRunning();
158 
159  uint16 _haveInvItem[19];
160  uint16 _caseVariable[20];
161 
162 private:
163  CSTimeCase *_case;
164  CSTimeInterface *_interface;
165  CSTimeView *_view;
166 
167  CSTimeState _state;
168 
169  void initCase();
170  void nextScene();
171  void update();
172 
173  uint16 _nextSceneId;
174 
175  bool _processingEvent;
176  bool _processingNIS55;
177  bool _NISRunning;
178  uint32 _lastTimeout;
179  void reset();
180 
182  void triggerEvent(CSTimeEvent &event);
183 
184  void pauseEngineIntern(bool) override;
185 };
186 
187 } // End of namespace Mohawk
188 
189 #endif
Definition: cstime_view.h:61
Definition: error.h:84
Definition: array.h:52
Definition: random.h:44
Definition: list.h:44
Definition: path.h:52
Definition: video.h:244
Definition: cstime_graphics.h:31
Definition: sound.h:102
Definition: cstime.h:113
Definition: cstime_ui.h:173
Definition: mohawk.h:54
Definition: cstime_game.h:246
Definition: cstime.h:129
Definition: system.h:167
Definition: bitmap.h:32
Definition: detection.h:65