ScummVM API documentation
game_struct_defines.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 AGS_SHARED_AC_GAME_STRUCT_DEFINES_H
23#define AGS_SHARED_AC_GAME_STRUCT_DEFINES_H
24
25#include "ags/shared/util/geometry.h"
26#include "ags/shared/core/types.h"
27
28namespace AGS3 {
29
30#define PAL_GAMEWIDE 0
31#define PAL_LOCKED 1
32#define PAL_BACKGROUND 2
33#define MAXGLOBALMES 500
34#define GLOBALMESLENGTH 500
35#define MAXLANGUAGE 5
36#define LEGACY_MAX_FONTS 30
37
38// General game options
39#define OPT_DEBUGMODE 0
40#define OPT_SCORESOUND 1
41#define OPT_WALKONLOOK 2
42#define OPT_DIALOGIFACE 3
43#define OPT_ANTIGLIDE 4
44#define OPT_TWCUSTOM 5
45#define OPT_DIALOGGAP 6
46#define OPT_NOSKIPTEXT 7
47#define OPT_DISABLEOFF 8
48#define OPT_ALWAYSSPCH 9
49#define OPT_SPEECHTYPE 10
50#define OPT_PIXPERFECT 11
51#define OPT_NOWALKMODE 12
52#define OPT_LETTERBOX 13
53#define OPT_FIXEDINVCURSOR 14
54#define OPT_NOLOSEINV 15
55#define OPT_HIRES_FONTS 16
56#define OPT_SPLITRESOURCES 17
57#define OPT_ROTATECHARS 18
58#define OPT_FADETYPE 19
59#define OPT_HANDLEINVCLICKS 20
60#define OPT_MOUSEWHEEL 21
61#define OPT_DIALOGNUMBERED 22
62#define OPT_DIALOGUPWARDS 23
63#define OPT_CROSSFADEMUSIC 24
64#define OPT_ANTIALIASFONTS 25
65#define OPT_THOUGHTGUI 26
66#define OPT_TURNTOFACELOC 27
67#define OPT_RIGHTLEFTWRITE 28 // right-to-left text writing
68#define OPT_DUPLICATEINV 29 // if they have 2 of the item, draw it twice
69#define OPT_SAVESCREENSHOT 30
70#define OPT_PORTRAITSIDE 31
71#define OPT_STRICTSCRIPTING 32 // don't allow MoveCharacter-style commands
72#define OPT_LEFTTORIGHTEVAL 33 // left-to-right operator evaluation
73#define OPT_COMPRESSSPRITES 34 // sprite compression type (None, RLE, LZW, Deflate)
74#define OPT_STRICTSTRINGS 35 // don't allow old-style strings, for reference only
75#define OPT_NEWGUIALPHA 36 // alpha blending method when drawing GUI and controls
76#define OPT_RUNGAMEDLGOPTS 37
77#define OPT_NATIVECOORDINATES 38 // defines coordinate relation between game logic and game screen
78#define OPT_GLOBALTALKANIMSPD 39
79#define OPT_HIGHESTOPTION_321 39
80#define OPT_SPRITEALPHA 40 // alpha blending method when drawing images on DrawingSurface
81#define OPT_SAFEFILEPATHS 41 // restricted file path in script (not writing to the game dir, etc)
82#define OPT_DIALOGOPTIONSAPI 42 // version of dialog options API (-1 for pre-3.4.0 API)
83#define OPT_BASESCRIPTAPI 43 // version of the Script API (ScriptAPIVersion) used to compile game script
84#define OPT_SCRIPTCOMPATLEV 44 // level of API compatibility (ScriptAPIVersion) used to compile game script
85#define OPT_RENDERATSCREENRES 45 // scale sprites at the (final) screen resolution
86#define OPT_RELATIVEASSETRES 46 // relative asset resolution mode (where sprites are resized to match game type)
87#define OPT_WALKSPEEDABSOLUTE 47 // if movement speeds are independent of walkable mask resolution
88#define OPT_CLIPGUICONTROLS 48 // clip drawn gui control contents to the control's rectangle
89#define OPT_GAMETEXTENCODING 49 // how the text in the game data should be interpreted
90#define OPT_KEYHANDLEAPI 50 // key handling mode (old/new)
91#define OPT_CUSTOMENGINETAG 51 // custom engine tag (for overriding behavior)
92#define OPT_SCALECHAROFFSETS 52 // apply character scaling to the sprite offsets (z, locked offs)
93#define OPT_HIGHESTOPTION OPT_SCALECHAROFFSETS
94#define OPT_NOMODMUSIC 98 // [DEPRECATED]
95#define OPT_LIPSYNCTEXT 99
96
97#define CUSTOMENG_NONE 0
98#define CUSTOMENG_DRACONIAN 1 // Draconian Edition
99#define CUSTOMENG_CLIFFTOP 2 // Clifftop Games
100
101// Sierra-style portrait position style
102#define PORTRAIT_LEFT 0
103#define PORTRAIT_RIGHT 1
104#define PORTRAIT_ALTERNATE 2
105#define PORTRAIT_XPOSITION 3
106
107// Room transition style
108#define FADE_NORMAL 0
109#define FADE_INSTANT 1
110#define FADE_DISSOLVE 2
111#define FADE_BOXOUT 3
112#define FADE_CROSSFADE 4
113#define FADE_LAST 4 // this should equal the last one
114
115// Legacy font flags
116//#define FFLG_LEGACY_NOSCALE 0x01 // TODO: is this from legacy format, ever used?
117#define FFLG_LEGACY_SIZEMASK 0x3f
118#define MAX_LEGACY_FONT_SIZE 63
119// Contemporary font flags
120#define FFLG_SIZEMULTIPLIER 0x01 // size data means multiplier
121#define FFLG_DEFLINESPACING 0x02 // linespacing derived from the font height
122// Font load flags, primarily for backward compatibility:
123// REPORTNOMINALHEIGHT: get_font_height should return nominal font's height,
124// eq to "font size" parameter, otherwise returns real pixel height.
125#define FFLG_REPORTNOMINALHEIGHT 0x04
126// ASCENDFIXUP: do the TTF ascender fixup, where font's ascender is resized
127// to the nominal font's height.
128#define FFLG_ASCENDERFIXUP 0x08
129// Collection of flags defining fully backward compatible TTF fixup
130#define FFLG_TTF_BACKCOMPATMASK (FFLG_REPORTNOMINALHEIGHT | FFLG_ASCENDERFIXUP)
131// Collection of flags defining font's load mode
132#define FFLG_LOADMODEMASK (FFLG_REPORTNOMINALHEIGHT | FFLG_ASCENDERFIXUP)
133// Font outline types
134#define FONT_OUTLINE_NONE -1
135#define FONT_OUTLINE_AUTO -10
136
137#define DIALOG_OPTIONS_HIGHLIGHT_COLOR_DEFAULT 14 // Yellow
138
139// MAXVIEWNAMELENGTH comes from unknown old engine version
140#define LEGACY_MAXVIEWNAMELENGTH 15
141#define MAXLIPSYNCFRAMES 20
142#define MAX_GUID_LENGTH 40
143#define MAX_SG_EXT_LENGTH 20
144#define LEGACY_MAX_SG_FOLDER_LEN 50
145
146enum GameResolutionType {
147 kGameResolution_Undefined = -1,
148 // definition of 320x200 in very old versions of the engine (somewhere pre-2.56)
149 kGameResolution_Default = 0,
150 kGameResolution_320x200 = 1,
151 kGameResolution_320x240 = 2,
152 kGameResolution_640x400 = 3,
153 kGameResolution_640x480 = 4,
154 kGameResolution_800x600 = 5,
155 kGameResolution_1024x768 = 6,
156 kGameResolution_1280x720 = 7,
157 kGameResolution_Custom = 8,
158 kNumGameResolutions,
159
160 kGameResolution_LastLoRes = kGameResolution_320x240,
161 kGameResolution_FirstHiRes = kGameResolution_640x400
162};
163
164inline bool IsLegacyHiRes(GameResolutionType resolution) {
165 return resolution > kGameResolution_LastLoRes;
166}
167
168Size ResolutionTypeToSize(GameResolutionType resolution, bool letterbox = false);
169
170// Automatic numbering of dialog options (OPT_DIALOGNUMBERED)
171enum DialogOptionNumbering {
172 kDlgOptNoNumbering = -1,
173 kDlgOptKeysOnly = 0, // implicit key shortcuts
174 kDlgOptNumbering = 1 // draw option indices and use key shortcuts
175};
176
177// Version of the script api (OPT_BASESCRIPTAPI and OPT_SCRIPTCOMPATLEV).
178// If the existing script function meaning had changed, that may be
179// possible to find out which implementation to use by checking one of those
180// two options.
181// NOTE: please remember that those values are valid only for games made with
182// 3.4.0 final and above.
183enum ScriptAPIVersion {
184 kScriptAPI_Undefined = INT32_MIN,
185 kScriptAPI_v321 = 0,
186 kScriptAPI_v330 = 1,
187 kScriptAPI_v334 = 2,
188 kScriptAPI_v335 = 3,
189 kScriptAPI_v340 = 4,
190 kScriptAPI_v341 = 5,
191 kScriptAPI_v350 = 6,
192 kScriptAPI_v3507 = 7,
193 kScriptAPI_v351 = 8,
194 kScriptAPI_v360 = 3060000,
195 kScriptAPI_v36026 = 3060026,
196 kScriptAPI_v361 = 3060100,
197 kScriptAPI_Current = kScriptAPI_v361
198};
199
200extern const char *GetScriptAPIName(ScriptAPIVersion v);
201
202// Determines whether the graphics renderer should scale sprites at the final
203// screen resolution, as opposed to native resolution
204enum RenderAtScreenRes {
205 kRenderAtScreenRes_UserDefined = 0,
206 kRenderAtScreenRes_Enabled = 1,
207 kRenderAtScreenRes_Disabled = 2,
208};
209
210// Method to use when blending two sprites with alpha channel
211enum GameSpriteAlphaRenderingStyle {
212 kSpriteAlphaRender_Legacy = 0,
213 kSpriteAlphaRender_Proper
214};
215
216// Method to use when blending two GUI elements with alpha channel
217enum GameGuiAlphaRenderingStyle {
218 kGuiAlphaRender_Legacy = 0,
219 kGuiAlphaRender_AdditiveAlpha,
220 kGuiAlphaRender_Proper
221};
222
223// Sprite flags
224// SERIALIZATION NOTE: serialized as 8-bit in game data and legacy saves
225// serialized as 32-bit in new saves (for dynamic sprites only).
226#define SPF_HIRES 0x01 // sized for high native resolution (legacy option)
227#define SPF_HICOLOR 0x02 // is 16-bit (UNUSED)
228#define SPF_DYNAMICALLOC 0x04 // created by runtime script
229#define SPF_TRUECOLOR 0x08 // is 32-bit (UNUSED)
230#define SPF_ALPHACHANNEL 0x10 // has alpha-channel
231#define SPF_VAR_RESOLUTION 0x20 // variable resolution (refer to SPF_HIRES)
232#define SPF_HADALPHACHANNEL 0x80 // the saved sprite on disk has one
233#define SPF_OBJECTOWNED 0x0100 // owned by a game object (not created in user script)
234
235// General information about sprite (properties, size)
237 int Width = 0;
238 int Height = 0;
239 uint32_t Flags = 0u; // SPF_* flags
240
241 SpriteInfo() = default;
242 SpriteInfo(int w, int h, uint32_t flags) : Width(w), Height(h), Flags(flags) {}
243
244 inline Size GetResolution() const { return Size(Width, Height); }
245 // Gets if sprite is created at runtime (by engine, or a script command)
246 inline bool IsDynamicSprite() const { return (Flags & SPF_DYNAMICALLOC) != 0; }
247
248 //
249 // Legacy game support
250 //
251 // Gets if sprite should adjust its base size depending on game's resolution
252 inline bool IsRelativeRes() const {
253 return (Flags & SPF_VAR_RESOLUTION) != 0;
254 }
255 // Gets if sprite belongs to high resolution; hi-res sprites should be
256 // downscaled in low-res games, and low-res sprites should be upscaled
257 // in hi-res games
258 inline bool IsLegacyHiRes() const {
259 return (Flags & SPF_HIRES) != 0;
260 }
261};
262
263// Various font parameters, defining and extending font rendering behavior.
264// While FontRenderer object's main goal is to render single line of text at
265// the strictly determined position on canvas, FontInfo may additionally
266// provide instructions on adjusting drawing position, as well as arranging
267// multiple lines, and similar cases.
268struct FontInfo {
269 enum AutoOutlineStyle : int {
270 kSquared = 0,
271 kRounded = 1,
272 };
273
274 // General font's loading and rendering flags
275 uint32_t Flags;
276 // Nominal font import size (in pixels)
277 int Size;
278 // Factor to multiply base font size by
279 int SizeMultiplier;
280 // Outlining font index, or auto-outline flag
281 int Outline;
282 // Custom vertical render offset, used mainly for fixing broken fonts
283 int YOffset;
284 // Custom line spacing between two lines of text (0 = use font height)
285 int LineSpacing;
286 // When automatic outlining, thickness of the outline (0 = no auto outline)
287 int AutoOutlineThickness;
288 // When automatic outlining, style of the outline
289 AutoOutlineStyle AutoOutlineStyle;
290
291 FontInfo();
292};
293
294} // namespace AGS3
295
296#endif
Definition: game_struct_defines.h:268
Definition: geometry.h:148
Definition: game_struct_defines.h:236