1 //=============================================================================
2 //
3 // Adventure Game Studio (AGS)
4 //
5 // Copyright (C) 1999-2011 Chris Jones and 2011-20xx others
6 // The full list of copyright holders can be found in the Copyright.txt
7 // file, which is part of this source code distribution.
8 //
9 // The AGS source code is provided under the Artistic License 2.0.
10 // A copy of this license can be found in the file License.txt and at
11 // http://www.opensource.org/licenses/artistic-license-2.0.php
12 //
13 //=============================================================================
14 
15 #ifndef __AC_GAMESTATE_H
16 #define __AC_GAMESTATE_H
17 
18 #include "ac/characterinfo.h"
19 #include "ac/runtime_defines.h"
20 #include "media/audio/queuedaudioitem.h"
21 #include "util/geometry.h"
22 #include "util/string_types.h"
23 
24 // Forward declaration
25 namespace AGS { namespace Common { class Stream; } }
26 using namespace AGS; // FIXME later
27 
28 #define GAME_STATE_RESERVED_INTS 5
29 
30 // Adding to this might need to modify AGSDEFNS.SH and AGSPLUGIN.H
31 struct GameState {
32     int  score;      // player's current score
33     int  usedmode;   // set by ProcessClick to last cursor mode used
34     int  disabled_user_interface;  // >0 while in cutscene/etc
35     int  gscript_timer;    // obsolete
36     int  debug_mode;       // whether we're in debug mode
37     int  globalvars[MAXGLOBALVARS];  // obsolete
38     int  messagetime;      // time left for auto-remove messages
39     int  usedinv;          // inventory item last used
40     int  inv_top,inv_numdisp,obsolete_inv_numorder,inv_numinline;
41     int  text_speed;       // how quickly text is removed
42     int  sierra_inv_color; // background used to paint defualt inv window
43     int  talkanim_speed;   // animation speed of talking anims
44     int  inv_item_wid,inv_item_hit;  // set by SetInvDimensions
45     int  speech_text_shadow;         // colour of outline fonts (default black)
46     int  swap_portrait_side;         // sierra-style speech swap sides
47     int  speech_textwindow_gui;      // textwindow used for sierra-style speech
48     int  follow_change_room_timer;   // delay before moving following characters into new room
49     int  totalscore;           // maximum possible score
50     int  skip_display;         // how the user can skip normal Display windows
51     int  no_multiloop_repeat;  // for backwards compatibility
52     int  roomscript_finished;  // on_call finished in room
53     int  used_inv_on;          // inv item they clicked on
54     int  no_textbg_when_voice; // no textwindow bgrnd when voice speech is used
55     int  max_dialogoption_width; // max width of dialog options text window
56     int  no_hicolor_fadein;      // fade out but instant in for hi-color
57     int  bgspeech_game_speed;    // is background speech relative to game speed
58     int  bgspeech_stay_on_display; // whether to remove bg speech when DisplaySpeech is used
59     int  unfactor_speech_from_textlength; // remove "&10" when calculating time for text to stay
60     int  mp3_loop_before_end;    // (UNUSED!) loop this time before end of track (ms)
61     int  speech_music_drop;      // how much to drop music volume by when speech is played
62     int  in_cutscene;            // we are between a StartCutscene and EndCutscene
63     int  fast_forward;           // player has elected to skip cutscene
64     int  room_width;      // width of current room (320-res co-ordinates)
65     int  room_height;     // height of current room (320-res co-ordinates)
66     // ** up to here is referenced in the plugin interface
67     int  game_speed_modifier;
68     int  score_sound;
69     int  takeover_data;  // value passed to RunAGSGame in previous game
70     int  replay_hotkey;
71     int  dialog_options_x;
72     int  dialog_options_y;
73     int  narrator_speech;
74     int  ambient_sounds_persist;
75     int  lipsync_speed;
76     int  close_mouth_speech_time; // stop speech animation at (messagetime - close_mouth_speech_time)
77                                   // (this is designed to work in text-only mode)
78     int  disable_antialiasing;
79     int  text_speed_modifier;
80     int  text_align;
81     int  speech_bubble_width;
82     int  min_dialogoption_width;
83     int  disable_dialog_parser;
84     int  anim_background_speed;  // the setting for this room
85     int  top_bar_backcolor;
86     int  top_bar_textcolor;
87     int  top_bar_bordercolor;
88     int  top_bar_borderwidth;
89     int  top_bar_ypos;
90     int  screenshot_width;
91     int  screenshot_height;
92     int  top_bar_font;
93     int  speech_text_align;
94     int  auto_use_walkto_points;
95     int  inventory_greys_out;
96     int  skip_speech_specific_key;
97     int  abort_key;
98     int  fade_to_red;
99     int  fade_to_green;
100     int  fade_to_blue;
101     int  show_single_dialog_option;
102     int  keep_screen_during_instant_transition;
103     int  read_dialog_option_colour;
104     int  stop_dialog_at_end;
105     int  speech_portrait_placement; // speech portrait placement mode (automatic/custom)
106     int  speech_portrait_x; // a speech portrait x offset from corresponding screen side
107     int  speech_portrait_y; // a speech portrait y offset
108     int  speech_display_post_time_ms; // keep speech text/portrait on screen after text/voice has finished playing;
109                                       // no speech animation is supposed to be played at this time
110     int  dialog_options_highlight_color; // The colour used for highlighted (hovered over) text in dialog options
111     int  reserved[GAME_STATE_RESERVED_INTS];  // make sure if a future version adds a var, it doesn't mess anything up
112     // ** up to here is referenced in the script "game." object
113     int   recording;   // user is recording their moves
114     int   playback;    // playing back recording
115     short gamestep;    // step number for matching recordings
116     long  randseed;    // random seed
117     int   player_on_region;    // player's current region
118     int   screen_is_faded_out; // the screen is currently black
119     int   check_interaction_only;
120     int   bg_frame,bg_anim_delay;  // for animating backgrounds
121     int   music_vol_was;  // before the volume drop
122     short wait_counter;
123     short mboundx1,mboundx2,mboundy1,mboundy2;
124     int   fade_effect;
125     int   bg_frame_locked;
126     int   globalscriptvars[MAXGSVALUES];
127     int   cur_music_number,music_repeat;
128     int   music_master_volume;
129     int   digital_master_volume;
130     char  walkable_areas_on[MAX_WALK_AREAS+1];
131     short screen_flipped;
132     short offsets_locked;
133     int   entered_at_x,entered_at_y, entered_edge;
134     int   want_speech;
135     int   cant_skip_speech;
136     int   script_timers[MAX_TIMERS];
137     int   sound_volume,speech_volume;
138     int   normal_font, speech_font;
139     char  key_skip_wait;
140     int   swap_portrait_lastchar;
141     int   swap_portrait_lastlastchar;
142     int   separate_music_lib;
143     int   in_conversation;
144     int   screen_tint;
145     int   num_parsed_words;
146     short parsed_words[MAX_PARSED_WORDS];
147     char  bad_parsed_word[100];
148     int   raw_color;
149     int   raw_modified[MAX_BSCENE];
150     short filenumbers[MAXSAVEGAMES];
151     int   room_changes;
152     int   mouse_cursor_hidden;
153     int   silent_midi;
154     int   silent_midi_channel;
155     int   current_music_repeating;  // remember what the loop flag was when this music started
156     unsigned long shakesc_delay;  // unsigned long to match loopcounter
157     int   shakesc_amount, shakesc_length;
158     int   rtint_red, rtint_green, rtint_blue, rtint_level, rtint_light;
159     bool  rtint_enabled;
160     int   end_cutscene_music;
161     int   skip_until_char_stops;
162     int   get_loc_name_last_time;
163     int   get_loc_name_save_cursor;
164     int   restore_cursor_mode_to;
165     int   restore_cursor_image_to;
166     short music_queue_size;
167     short music_queue[MAX_QUEUED_MUSIC];
168     short new_music_queue_size;
169     short crossfading_out_channel;
170     short crossfade_step;
171     short crossfade_out_volume_per_step;
172     short crossfade_initial_volume_out;
173     short crossfading_in_channel;
174     short crossfade_in_volume_per_step;
175     short crossfade_final_volume_in;
176     QueuedAudioItem new_music_queue[MAX_QUEUED_MUSIC];
177     char  takeover_from[50];
178     char  playmp3file_name[PLAYMP3FILE_MAX_FILENAME_LEN];
179     char  globalstrings[MAXGLOBALSTRINGS][MAX_MAXSTRLEN];
180     char  lastParserEntry[MAX_MAXSTRLEN];
181     char  game_name[100];
182     int   ground_level_areas_disabled;
183     int   next_screen_transition;
184     int   gamma_adjustment;
185     short temporarily_turned_off_character;  // Hide Player Charactr ticked
186     short inv_backwards_compatibility;
187     int  *gui_draw_order;
188     char**do_once_tokens;
189     int   num_do_once_tokens;
190     int   text_min_display_time_ms;
191     int   ignore_user_input_after_text_timeout_ms;
192     unsigned long ignore_user_input_until_time;
193     int   default_audio_type_volumes[MAX_AUDIO_TYPES];
194 
195     // Dynamic custom property values for characters and items
196     std::vector<AGS::Common::StringIMap> charProps;
197     AGS::Common::StringIMap invProps[MAX_INV];
198 
199     // These variables are not serialized
200     bool  speech_in_post_state;
201     // Viewport defines the current position of the playable area;
202     // in basic case it will be identical to game size, but it may be smaller
203     // to support room sizes lesser than game size.
204     Rect  viewport;
205     // game size in low-res units (for backwards-compatibility)
206     Size  native_size;
207 
208     void SetViewport(const Size viewport_size);
209 
210     void ReadFromFile_v321(Common::Stream *in);
211     void WriteToFile_v321(Common::Stream *out);
212     void ReadQueuedAudioItems_Aligned(Common::Stream *in);
213     void WriteQueuedAudioItems_Aligned(Common::Stream *out);
214     void ReadCustomProperties(Common::Stream *in);
215     void WriteCustomProperties(Common::Stream *out);
216     void FreeProperties();
217 };
218 
219 extern GameState play;
220 
221 #endif // __AC_GAMESTATE_H
222