ScummVM API documentation
pregob.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  * This file is dual-licensed.
22  * In addition to the GPLv3 license mentioned above, this code is also
23  * licensed under LGPL 2.1. See LICENSES/COPYING.LGPL file for the
24  * full text of the license.
25  *
26  */
27 
28 #ifndef GOB_PREGOB_PREGOB_H
29 #define GOB_PREGOB_PREGOB_H
30 
31 #include "common/str.h"
32 #include "common/array.h"
33 
34 #include "gob/util.h"
35 #include "gob/aniobject.h"
36 
37 #include "gob/pregob/txtfile.h"
38 
39 namespace Gob {
40 
41 class GobEngine;
42 class ANIFile;
43 class Surface;
44 class SoundDesc;
45 
46 class GCTFile;
47 
48 class PreGob {
49 public:
50  PreGob(GobEngine *vm);
51  virtual ~PreGob();
52 
53  virtual void run() = 0;
54 
55  struct AnimProperties {
56  uint16 animation;
57  uint16 frame;
58 
59  ANIObject::Mode mode;
60 
61  bool visible;
62  bool paused;
63 
64  bool hasPosition;
65  int16 x;
66  int16 y;
67  };
68 
69 protected:
71 
72  static const char kLanguageSuffixShort[5];
73  static const char *kLanguageSuffixLong [5];
74 
75 
76  GobEngine *_vm;
77 
78 
79  // -- Graphics --
80 
82  void initScreen();
83 
84  void fadeOut();
85  void fadeIn();
86 
87  void clearScreen();
88 
94  void setPalette(const byte *palette, uint16 size);
95 
97  void addCursor();
99  void removeCursor();
100 
102  void setCursor(Surface &sprite, int16 hotspotX, int16 hotspotY);
104  void setCursor(Surface &sprite, int16 left, int16 top, int16 right, int16 bottom,
105  int16 hotspotX, int16 hotspotY);
106 
108  void showCursor();
110  void hideCursor();
111 
113  bool isCursorVisible() const;
114 
116  void clearAnim(ANIObject &anim);
118  void drawAnim(ANIObject &anim);
120  void redrawAnim(ANIObject &anim);
121 
123  void clearAnim(const ANIList &anims);
125  void drawAnim(const ANIList &anims);
127  void redrawAnim(const ANIList &anims);
128 
129  void loadAnims(ANIList &anims, ANIFile &ani, uint count, const AnimProperties *props) const;
130  void freeAnims(ANIList &anims) const;
131 
132  void setAnim(ANIObject &anim, const AnimProperties &props) const;
133 
135  void endFrame(bool doInput);
136 
137 
138  // -- Sound --
139 
141  void loadSounds(const char * const *sounds, uint soundCount);
143  void freeSounds();
144 
146  void playSound(uint sound, int16 frequency = 0, int16 repCount = 0);
148  void stopSound();
149 
151  void playSoundFile(const Common::String &file, int16 frequency = 0, int16 repCount = 0, bool interruptible = true);
152 
154  void beep(int16 frequency, int32 length);
155 
156 
157  // -- Input --
158 
160  int16 checkInput(int16 &mouseX, int16 &mouseY, MouseButtons &mouseButtons);
162  int16 waitInput (int16 &mouseX, int16 &mouseY, MouseButtons &mouseButtons);
164  int16 waitInput();
166  bool hasInput();
167 
168 
169  // -- TXT helpers --
170 
172  Common::String getLocFile(const Common::String &file) const;
174  TXTFile *loadTXT(const Common::String &txtFile, TXTFile::Format format) const;
175 
177  virtual void fixTXTStrings(TXTFile &txt) const;
178 
179 
180  // -- GCT helpers --
181 
182  GCTFile *loadGCT(const Common::String &gctFile) const;
183 
184 
185 private:
187  bool _fadedOut;
188 
190  Common::Array<SoundDesc> _sounds;
191 
192 
194  bool loadSound(SoundDesc &sound, const Common::String &file) const;
195 };
196 
197 } // End of namespace Gob
198 
199 #endif // GOB_PREGOB_PREGOB_H
void showCursor()
void clearAnim(ANIObject &anim)
Definition: pregob.h:48
void freeSounds()
Definition: gob.h:156
Definition: str.h:59
Definition: aniobject.h:42
bool hasInput()
void beep(int16 frequency, int32 length)
Definition: array.h:52
void setCursor(Surface &sprite, int16 hotspotX, int16 hotspotY)
void playSound(uint sound, int16 frequency=0, int16 repCount=0)
Definition: gctfile.h:47
void setPalette(const byte *palette, uint16 size)
Change the palette.
void loadSounds(const char *const *sounds, uint soundCount)
int16 checkInput(int16 &mouseX, int16 &mouseY, MouseButtons &mouseButtons)
bool isCursorVisible() const
Definition: anifile.h:40
void drawAnim(ANIObject &anim)
void addCursor()
TXTFile * loadTXT(const Common::String &txtFile, TXTFile::Format format) const
Common::String getLocFile(const Common::String &file) const
Definition: txtfile.h:46
void playSoundFile(const Common::String &file, int16 frequency=0, int16 repCount=0, bool interruptible=true)
void fadeIn()
Fade to the current palette.
Definition: surface.h:100
Definition: sounddesc.h:43
void redrawAnim(ANIObject &anim)
Definition: anifile.h:53
int16 waitInput()
void endFrame(bool doInput)
void stopSound()
void removeCursor()
Mode
Definition: aniobject.h:44
virtual void fixTXTStrings(TXTFile &txt) const
void fadeOut()
Fade to black.
Definition: pregob.h:55
void hideCursor()
void initScreen()