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 
28 namespace 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 // [DEPRECATED]
74 #define OPT_STRICTSTRINGS 35 // don't allow old-style strings, for reference only
75 #define OPT_NEWGUIALPHA 36
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
81 #define OPT_SAFEFILEPATHS 41
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_HIGHESTOPTION OPT_CUSTOMENGINETAG
93 #define OPT_NOMODMUSIC 98 // [DEPRECATED]
94 #define OPT_LIPSYNCTEXT 99
95 
96 #define CUSTOMENG_NONE 0
97 #define CUSTOMENG_DRACONIAN 1 // Draconian Edition
98 #define CUSTOMENG_CLIFFTOP 2 // Clifftop Games
99 
100 // Sierra-style portrait position style
101 #define PORTRAIT_LEFT 0
102 #define PORTRAIT_RIGHT 1
103 #define PORTRAIT_ALTERNATE 2
104 #define PORTRAIT_XPOSITION 3
105 
106 // Room transition style
107 #define FADE_NORMAL 0
108 #define FADE_INSTANT 1
109 #define FADE_DISSOLVE 2
110 #define FADE_BOXOUT 3
111 #define FADE_CROSSFADE 4
112 #define FADE_LAST 4 // this should equal the last one
113 
114 // Legacy font flags
115 //#define FFLG_LEGACY_NOSCALE 0x01 // TODO: is this from legacy format, ever used?
116 #define FFLG_LEGACY_SIZEMASK 0x3f
117 #define MAX_LEGACY_FONT_SIZE 63
118 // Contemporary font flags
119 #define FFLG_SIZEMULTIPLIER 0x01 // size data means multiplier
120 #define FFLG_DEFLINESPACING 0x02 // linespacing derived from the font height
121 // Font load flags, primarily for backward compatibility:
122 // REPORTNOMINALHEIGHT: get_font_height should return nominal font's height,
123 // eq to "font size" parameter, otherwise returns real pixel height.
124 #define FFLG_REPORTNOMINALHEIGHT 0x04
125 // ASCENDFIXUP: do the TTF ascender fixup, where font's ascender is resized
126 // to the nominal font's height.
127 #define FFLG_ASCENDERFIXUP 0x08
128 // Collection of flags defining fully backward compatible TTF fixup
129 #define FFLG_TTF_BACKCOMPATMASK (FFLG_REPORTNOMINALHEIGHT | FFLG_ASCENDERFIXUP)
130 // Collection of flags defining font's load mode
131 #define FFLG_LOADMODEMASK (FFLG_REPORTNOMINALHEIGHT | FFLG_ASCENDERFIXUP)
132 // Font outline types
133 #define FONT_OUTLINE_NONE -1
134 #define FONT_OUTLINE_AUTO -10
135 
136 #define DIALOG_OPTIONS_HIGHLIGHT_COLOR_DEFAULT 14 // Yellow
137 
138 #define MAXVIEWNAMELENGTH 15
139 #define MAXLIPSYNCFRAMES 20
140 #define MAX_GUID_LENGTH 40
141 #define MAX_SG_EXT_LENGTH 20
142 #define MAX_SG_FOLDER_LEN 50
143 
144 enum GameResolutionType {
145  kGameResolution_Undefined = -1,
146  // definition of 320x200 in very old versions of the engine (somewhere pre-2.56)
147  kGameResolution_Default = 0,
148  kGameResolution_320x200 = 1,
149  kGameResolution_320x240 = 2,
150  kGameResolution_640x400 = 3,
151  kGameResolution_640x480 = 4,
152  kGameResolution_800x600 = 5,
153  kGameResolution_1024x768 = 6,
154  kGameResolution_1280x720 = 7,
155  kGameResolution_Custom = 8,
156  kNumGameResolutions,
157 
158  kGameResolution_LastLoRes = kGameResolution_320x240,
159  kGameResolution_FirstHiRes = kGameResolution_640x400
160 };
161 
162 inline bool IsLegacyHiRes(GameResolutionType resolution) {
163  return resolution > kGameResolution_LastLoRes;
164 }
165 
166 Size ResolutionTypeToSize(GameResolutionType resolution, bool letterbox = false);
167 
168 // Automatic numbering of dialog options (OPT_DIALOGNUMBERED)
169 enum DialogOptionNumbering {
170  kDlgOptNoNumbering = -1,
171  kDlgOptKeysOnly = 0, // implicit key shortcuts
172  kDlgOptNumbering = 1 // draw option indices and use key shortcuts
173 };
174 
175 // Version of the script api (OPT_BASESCRIPTAPI and OPT_SCRIPTCOMPATLEV).
176 // If the existing script function meaning had changed, that may be
177 // possible to find out which implementation to use by checking one of those
178 // two options.
179 // NOTE: please remember that those values are valid only for games made with
180 // 3.4.0 final and above.
181 enum ScriptAPIVersion {
182  kScriptAPI_Undefined = INT32_MIN,
183  kScriptAPI_v321 = 0,
184  kScriptAPI_v330 = 1,
185  kScriptAPI_v334 = 2,
186  kScriptAPI_v335 = 3,
187  kScriptAPI_v340 = 4,
188  kScriptAPI_v341 = 5,
189  kScriptAPI_v350 = 6,
190  kScriptAPI_v3507 = 7,
191  kScriptAPI_v351 = 8,
192  kScriptAPI_v360 = 3060000,
193  kScriptAPI_v36026 = 3060026,
194  kScriptAPI_Current = kScriptAPI_v36026
195 };
196 
197 extern const char *GetScriptAPIName(ScriptAPIVersion v);
198 
199 // Determines whether the graphics renderer should scale sprites at the final
200 // screen resolution, as opposed to native resolution
201 enum RenderAtScreenRes {
202  kRenderAtScreenRes_UserDefined = 0,
203  kRenderAtScreenRes_Enabled = 1,
204  kRenderAtScreenRes_Disabled = 2,
205 };
206 
207 // Method to use when blending two sprites with alpha channel
208 enum GameSpriteAlphaRenderingStyle {
209  kSpriteAlphaRender_Legacy = 0,
210  kSpriteAlphaRender_Proper
211 };
212 
213 // Method to use when blending two GUI elements with alpha channel
214 enum GameGuiAlphaRenderingStyle {
215  kGuiAlphaRender_Legacy = 0,
216  kGuiAlphaRender_AdditiveAlpha,
217  kGuiAlphaRender_Proper
218 };
219 
220 
221 // Sprite flags (serialized as 8-bit)
222 #define SPF_HIRES 0x01 // sized for high native resolution (legacy option)
223 #define SPF_HICOLOR 0x02 // is 16-bit
224 #define SPF_DYNAMICALLOC 0x04 // created by runtime script
225 #define SPF_TRUECOLOR 0x08 // is 32-bit
226 #define SPF_ALPHACHANNEL 0x10 // has alpha-channel
227 #define SPF_VAR_RESOLUTION 0x20 // variable resolution (refer to SPF_HIRES)
228 #define SPF_HADALPHACHANNEL 0x80 // the saved sprite on disk has one
229 
230 // General information about sprite (properties, size)
231 struct SpriteInfo {
232  uint32_t Flags;
233  int Width;
234  int Height;
235 
236  SpriteInfo();
237 
238  //
239  // Legacy game support
240  //
241  // Gets if sprite should adjust its base size depending on game's resolution
242  inline bool IsRelativeRes() const {
243  return (Flags & SPF_VAR_RESOLUTION) != 0;
244  }
245  // Gets if sprite belongs to high resolution; hi-res sprites should be
246  // downscaled in low-res games, and low-res sprites should be upscaled
247  // in hi-res games
248  inline bool IsLegacyHiRes() const {
249  return (Flags & SPF_HIRES) != 0;
250  }
251 };
252 
253 // Various font parameters, defining and extending font rendering behavior.
254 // While FontRenderer object's main goal is to render single line of text at
255 // the strictly determined position on canvas, FontInfo may additionally
256 // provide instructions on adjusting drawing position, as well as arranging
257 // multiple lines, and similar cases.
258 struct FontInfo {
259  enum AutoOutlineStyle : int {
260  kSquared = 0,
261  kRounded = 1,
262  };
263 
264  // General font's loading and rendering flags
265  uint32_t Flags;
266  // Nominal font import size (in pixels)
267  int Size;
268  // Factor to multiply base font size by
269  int SizeMultiplier;
270  // Outlining font index, or auto-outline flag
271  int8 Outline;
272  // Custom vertical render offset, used mainly for fixing broken fonts
273  int YOffset;
274  // Custom line spacing between two lines of text (0 = use font height)
275  int LineSpacing;
276  // When automatic outlining, thickness of the outline (0 = no auto outline)
277  int AutoOutlineThickness;
278  // When automatic outlining, style of the outline
279  AutoOutlineStyle AutoOutlineStyle;
280 
281  FontInfo();
282 };
283 
284 } // namespace AGS3
285 
286 #endif
Definition: geometry.h:144
Definition: game_struct_defines.h:258
Definition: game_struct_defines.h:231
Definition: ags.h:40