ScummVM API documentation
game.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//=============================================================================
23//
24// AGS Runtime header
25//
26//=============================================================================
27
28#ifndef AGS_ENGINE_AC_GAME_H
29#define AGS_ENGINE_AC_GAME_H
30
31#include "ags/engine/ac/dynobj/script_view_frame.h"
32#include "ags/engine/main/game_file.h"
33#include "ags/shared/util/string.h"
34
35namespace AGS3 {
36
37namespace AGS {
38namespace Shared {
39class Bitmap;
40class Stream;
41} // namespace Shared
42} // namespace AGS
43
44using namespace AGS; // FIXME later
45
46#define RAGMODE_PRESERVEGLOBALINT 1
47#define RAGMODE_LOADNOW 0x8000000 // just to make sure it's non-zero
48
49// Game parameter constants for backward-compatibility functions
50#define GP_SPRITEWIDTH 1
51#define GP_SPRITEHEIGHT 2
52#define GP_NUMLOOPS 3
53#define GP_NUMFRAMES 4
54#define GP_ISRUNNEXTLOOP 5
55#define GP_FRAMESPEED 6
56#define GP_FRAMEIMAGE 7
57#define GP_FRAMESOUND 8
58#define GP_NUMGUIS 9
59#define GP_NUMOBJECTS 10
60#define GP_NUMCHARACTERS 11
61#define GP_NUMINVITEMS 12
62#define GP_ISFRAMEFLIPPED 13
63
64enum CutsceneSkipStyle {
65 kSkipSceneUndefined = 0,
66 eSkipSceneEscOnly = 1,
67 eSkipSceneAnyKey = 2,
68 eSkipSceneMouse = 3,
69 eSkipSceneKeyMouse = 4,
70 eSkipSceneEscOrRMB = 5,
71 eSkipSceneScriptOnly = 6
72};
73
74//=============================================================================
75// Audio
76//=============================================================================
77#define VOL_CHANGEEXISTING 1678
78#define VOL_SETFUTUREDEFAULT 1679
79#define VOL_BOTH 1680
80
81void Game_StopAudio(int audioType);
82int Game_IsAudioPlaying(int audioType);
83void Game_SetAudioTypeSpeechVolumeDrop(int audioType, int volumeDrop);
84void Game_SetAudioTypeVolume(int audioType, int volume, int changeType);
85
86int Game_GetMODPattern();
87
88//=============================================================================
89// ---
90//=============================================================================
91int Game_GetDialogCount();
92
93// Sets a default save directory, based on platform driver settings and user config
94void SetDefaultSaveDirectory();
95// Sets a new save directory within the save parent; copies "restart" slot if available
96int Game_SetSaveGameDirectory(const char *newFolder);
97const char *Game_GetSaveSlotDescription(int slnum);
98
99const char *Game_GetGlobalStrings(int index);
100
101// View, loop, frame parameter assertions.
102// WARNING: these functions assume that view is already in an internal 0-based range.
103void AssertView(const char *apiname, int view);
104void AssertViewHasLoops(const char *apiname, int view);
105void AssertLoop(const char *apiname, int view, int loop);
106void AssertFrame(const char *apiname, int view, int loop, int frame);
107
108int Game_GetInventoryItemCount();
109int Game_GetFontCount();
110int Game_GetMouseCursorCount();
111int Game_GetCharacterCount();
112int Game_GetGUICount();
113int Game_GetViewCount();
114int Game_GetUseNativeCoordinates();
115int Game_GetSpriteWidth(int spriteNum);
116int Game_GetSpriteHeight(int spriteNum);
117int Game_GetLoopCountForView(int viewNumber);
118int Game_GetRunNextSettingForLoop(int viewNumber, int loopNumber);
119int Game_GetFrameCountForLoop(int viewNumber, int loopNumber);
120ScriptViewFrame *Game_GetViewFrame(int viewNumber, int loopNumber, int frame);
121int Game_DoOnceOnly(const char *token);
122
123int Game_GetTextReadingSpeed();
124void Game_SetTextReadingSpeed(int newTextSpeed);
125int Game_GetMinimumTextDisplayTimeMs();
126void Game_SetMinimumTextDisplayTimeMs(int newTextMinTime);
127int Game_GetIgnoreUserInputAfterTextTimeoutMs();
128void Game_SetIgnoreUserInputAfterTextTimeoutMs(int newValueMs);
129const char *Game_GetFileName();
130const char *Game_GetName();
131void Game_SetName(const char *newName);
132
133int Game_GetSkippingCutscene();
134int Game_GetInSkippableCutscene();
135
136int Game_GetColorFromRGB(int red, int grn, int blu);
137const char *Game_InputBox(const char *msg);
138const char *Game_GetLocationName(int x, int y);
139
140const char *Game_GetGlobalMessages(int index);
141
142int Game_GetSpeechFont();
143int Game_GetNormalFont();
144
145const char *Game_GetTranslationFilename();
146int Game_ChangeTranslation(const char *newFilename);
147const char *Game_GetSpeechVoxFilename();
148bool Game_ChangeSpeechVox(const char *newFilename);
149
150//=============================================================================
151
152void set_debug_mode(bool on);
153// Sets logical game FPS, telling how often the game should update
154void set_game_speed(int new_fps);
155// Gets strictly logical game FPS, regardless of whether this is real FPS right now or not.
156float get_game_speed();
157void setup_for_dialog();
158void restore_after_dialog();
159Shared::String get_save_game_directory();
160Shared::String get_save_game_suffix();
161void set_save_game_suffix(const Shared::String &suffix);
162// Returns full path to the save for the given slot number
163Shared::String get_save_game_path(int slotNum);
164// Try calling built-in restore game dialog;
165// NOTE: this is a script command; may be aborted according to the game & room settings
166void restore_game_dialog();
167// Unconditionally display a built-in restore game dialog
168bool do_restore_game_dialog();
169// Try calling built-in save game dialog;
170// NOTE: this is a script command; may be aborted according to the game & room settings
171void save_game_dialog();
172// Unconditionally display a built-in save game dialog
173bool do_save_game_dialog();
174void free_do_once_tokens();
175// Free all the memory associated with the game
176void unload_game();
177void save_game(int slotn, const char *descript);
178bool read_savedgame_description(const Shared::String &savedgame, Shared::String &description);
179std::unique_ptr<Shared::Bitmap> read_savedgame_screenshot(const Shared::String &savedgame);
180// Tries to restore saved game and displays an error on failure; if the error occurred
181// too late, when the game data was already overwritten, shuts engine down.
182bool try_restore_save(int slot);
183bool try_restore_save(const Shared::String &path, int slot);
184void serialize_bitmap(const Shared::Bitmap *thispic, Shared::Stream *out);
185// On Windows we could just use IIDFromString but this is platform-independent
186void convert_guid_from_text_to_binary(const char *guidText, unsigned char *buffer);
187Shared::Bitmap *read_serialized_bitmap(Shared::Stream *in);
188void skip_serialized_bitmap(Shared::Stream *in);
189long write_screen_shot_for_vista(Shared::Stream *out, Shared::Bitmap *screenshot);
190
191bool is_in_cutscene();
192CutsceneSkipStyle get_cutscene_skipstyle();
193void start_skipping_cutscene();
194bool check_skip_cutscene_keypress(int kgn);
195bool check_skip_cutscene_mclick(int mbut);
196void initialize_skippable_cutscene();
197void stop_fast_forwarding();
198
199int __GetLocationType(int xxx, int yyy, int allowHotspot0);
200
201// Called whenever game loses input focus
202void display_switch_out();
203// Called whenever game gets input focus
204void display_switch_in();
205// Called when the game looses input focus and must suspend
206void display_switch_out_suspend();
207// Called when the game gets input focus and should resume
208void display_switch_in_resume();
209
210void replace_tokens(const char *srcmes, char *destm, size_t maxlen);
211const char *get_global_message(int msnum);
212void get_message_text(int msnum, char *buffer, char giveErr = 1);
213
214// Notifies the game objects that certain sprite was updated.
215// This make them update their render states, caches, and so on.
216void game_sprite_updated(int sprnum, bool deleted = false);
217// Precaches sprites for a view, within a selected range of loops.
218void precache_view(int view, int first_loop = 0, int last_loop = INT32_MAX, bool with_sounds = false);
219
220extern void set_loop_counter(unsigned int new_counter);
221
222} // namespace AGS3
223
224#endif
Definition: ptr.h:572