ScummVM API documentation
options_manager_pc.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  * Additional copyright for this file:
8  * Copyright (C) 1999-2000 Revolution Software Ltd.
9  * This code is based on source code created by Revolution Software,
10  * used with permission.
11  *
12  * This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  *
25  */
26 
27 #ifndef ICB_OPTIONS_MANAGER_PC_H_INCLUDED
28 #define ICB_OPTIONS_MANAGER_PC_H_INCLUDED
29 
30 #include "engines/icb/p4.h"
31 #include "engines/icb/global_objects.h"
32 #include "engines/icb/global_switches.h"
33 #include "engines/icb/sound/fx_manager.h"
34 #include "engines/icb/sound/speech_manager.h"
35 #include "engines/icb/sound/music_manager.h"
36 #include "engines/icb/sound.h"
37 #include "engines/icb/direct_input.h"
38 
39 namespace ICB {
40 
41 class MovieManager;
42 extern MovieManager *g_personalSequenceManager;
43 
44 #define MAX_BYTESIZE_OF_CREDITS_FILE (8 * 1024)
45 
46 class Crediter {
47 private:
48  uint8 m_theData[MAX_BYTESIZE_OF_CREDITS_FILE];
49  char *m_creditsFile;
50  int32 m_numberOfBytes;
51 
52  int32 m_endOfCredits;
53 
54  int32 m_currentHeight;
55  uint32 m_cursor;
56  int32 m_scrollOffset;
57 
58  uint32 m_logoSurfaceID;
59  int32 m_logoDraw;
60  bool8 m_logoAttached;
61 
62  uint32 m_movieSurfaceID;
63  LRECT m_movieRect;
64  bool8 m_movieBackdrop;
65 
66  bool8 m_loopingMovie;
67  int32 m_frameStart;
68  int32 m_totalMovieFrames;
69 
70 public:
71  Crediter();
72  void Initialise(const char *textFileName, const char *movieFileName, bool8 loopingMovie, bool8 attachLogo, int32 frameStart);
73  int32 DoScreen();
74 };
75 
76 // Global options controller
77 class OptionsManager;
78 extern OptionsManager *g_theOptionsManager;
79 
80 // Type to describe every menu in the entire game
81 enum _MENU_ {
82  INGAME_TOP,
83  INGAME_OPTIONS,
84  INGAME_AUDIO,
85  INGAME_VIDEO,
86  INGAME_SAVE,
87  INGAME_SAVECONFIRM,
88  INGAME_LOAD,
89  INGAME_CONTROLS,
90  INGAME_QUIT,
91 
92  MAIN_TOP,
93  MAIN_LOAD,
94  MAIN_OPTIONS,
95  MAIN_AUDIO,
96  MAIN_VIDEO,
97  MAIN_CONTROLS,
98  MAIN_EXTRAS,
99  MAIN_MOVIES,
100  MAIN_PLAYSELECT,
101  MAIN_PROFILES,
102  MAIN_QUIT,
103 
104  MAIN_A_PROFILE,
105 
106  GAME_OVER,
107  DEAD_LOAD,
108  DEAD_QUIT
109 };
110 
111 #define NUMBER_OF_IN_GAME_TOP_CHOICES 5
112 
113 enum IN_GAME_TOP_CHOICES { CONTINUE = 0, SAVE_GAME = 1, LOAD_GAME = 2, OPTIONS = 3, QUIT = 4 };
114 
115 #define NUMBER_OPTION_CHOICES 4
116 
117 enum OPTION_CHOICES {
118  VIDEO_SETTINGS = 0,
119  AUDIO_SETTINGS = 1,
120  CONTROLS = 2,
121  DO_BACK = 3
122 };
123 
124 #define NUMBER_OF_AUDIO_CHOICES 4
125 
126 enum AUDIO_CHOICES {
127  MUSIC_VOLUME = 0,
128  SPEECH_VOLUME = 1,
129  SFX_VOLUME = 2,
130  DO_ONE = 3
131 };
132 
133 #define NUMBER_OF_VIDEO_CHOICES 4
134 
135 enum VIDEO_CHOICES {
136  SUBTITLES = 0,
137  SHADOWS = 1,
138  FRAMELIMITER = 2,
139  LEAVE = 3
140 };
141 
142 #define NUMBER_OF_CONTROL_CHOICES 2
143 
144 enum CONTROL_CHOICES {
145  METHOD = 0,
146  DONE = 1
147 };
148 
149 #define TOTAL_NUMBER_OF_GAME_SLOTS 100
150 #define NUMBER_OF_VISIBLE_GAME_SLOTS 4
151 #define NUMBER_OF_GAMESLOT_CHOICES 5
152 
153 enum GAMESLOT_CHOICES {
154  SLOT1 = 0,
155  SLOT2 = 1,
156  SLOT3 = 2,
157  SLOT4 = 3,
158  RETURN = 4
159 };
160 
161 #define NUMBER_OF_SAVECONFIRM_CHOICES 2
162 
163 enum SAVECONFIRM_CHOICES { YEY = 0, NAY = 1 };
164 
165 #define NUMBER_OF_QUIT_CHOICES 2
166 
167 enum QUIT_CHOICES { YES = 0, NO = 1 };
168 
169 #define NUMBER_OF_MAIN_TOP_CHOICES 5
170 
171 enum MAIN_TOP_CHOICES {
172  _NEWGAME = 0,
173  _LOAD_GAME = 1,
174  _OPTIONS = 2,
175  _EXTRAS = 3,
176  _EXIT_GAME = 4
177 };
178 #define NUMBER_OF_EXTRA_CHOICES 6
179 
180 enum M_EXTRA_CHOICES {
181  MOVIES = 0,
182  SLIDESHOW = 1,
183  PLAYSELECT = 2,
184  PROFILES = 3,
185  CREDITS = 4,
186  ALLDONE = 5
187 };
188 //-----------------------------------------------------------------------
189 #define NUMBER_OF_PLAYSELECT_CHOICES 10
190 
191 enum M_PLAYSELECT_CHOICES {
192  M01 = 0,
193  M02 = 1,
194  M03 = 2,
195  M04 = 3,
196  M05 = 4,
197  M07 = 5,
198  M08 = 6,
199  M09 = 7,
200  M10 = 8,
201  CANCEL = 9
202 };
203 //-----------------------------------------------------------------------
204 #define TOTAL_NUMBER_OF_MOVIES 47
205 #define M_NUMBER_OF_VISIBLE_MOVIE_SLOTS 12
206 #define M_NUMBER_OF_MOVIE_CHOICES 13
207 
208 enum M_MOVIE_CHOICES {
209  MOVIE01 = 0,
210  MOVIE02 = 1,
211  MOVIE03 = 2,
212  MOVIE04 = 3,
213  MOVIE05 = 4,
214  MOVIE06 = 5,
215  MOVIE07 = 6,
216  MOVIE08 = 7,
217  MOVIE09 = 8,
218  MOVIE10 = 9,
219  MOVIE11 = 10,
220  MOVIE12 = 11,
221  NOTHANKS = 12, // Excluded from name display if greater than this
222  PAGELEFT = 13,
223  PAGERIGHT = 14
224 };
225 #define M_NUMBER_OF_PROFILE_CHOICES 11
226 
227 enum M_PROFILES_CHOICES {
228  CORD = 0,
229  CHI = 1,
230  GREGOR = 2,
231  NAGAROV = 3,
232  LUKYAN = 4,
233  KEIFFER = 5,
234  TOLSTOV = 6,
235  ALEXANDRA = 7,
236  OLIAKOV = 8,
237  SPECTRE = 9,
238  RET = 10
239 };
240 #define NUMBER_OF_GAMEOVER_CHOICES 3
241 
242 enum GAMEOVER_CHOICES { RESTORE = 0, RESTART = 1, GAMEOVER = 2 };
243 
244 #define MAX_LABEL_LENGTH 24
245 
246 typedef struct {
247  char label[MAX_LABEL_LENGTH];
248  uint32 secondsPlayed;
249 
250 } _SLOT;
251 
252 typedef struct {
253  char filename[MAX_LABEL_LENGTH];
254  bool8 visible;
255 
256 } _MOVIESLOT;
257 
258 // These initialised from a saved game and switched when movies are played
259 extern _MOVIESLOT g_movieLibrary[TOTAL_NUMBER_OF_MOVIES];
260 
261 // Anti-aliased support provided for these coloured fonts (DisplayText)
262 #define NORMALFONT 0x0000
263 #define SELECTEDFONT 0x0001
264 #define PALEFONT 0x0002
265 
267  friend class Crediter;
268 
269 private:
270  bool8 m_inGame; // In-game or title screen flag
271  bool8 m_useDirtyRects; // For increased speed over a static background
272  bool8 m_gameover; // Game Over flag
273  bool8 m_haveControl; // OptionsManager active flag
274  bool8 m_thatsEnoughTa; // Quit flag
275 
276  int32 m_autoAnimating; // Animating flags
277  int32 m_autoAnimating2;
278  LRECT m_optionsBox; // Top level screen bounding box
279  int32 m_over_n_Frames; // Animating variable
280  int32 m_grower; // Animating variable
281  uint32 m_lipLength; // Length of top-level box lips
282  LRECT m_box; // Animating variable
283  LRECT m_targetBox; // Child screen title box
284  int32 m_interFrames; // Animating variable
285  int32 m_widthIncrements; // Animating variable
286  int32 m_bottomIncrements; // Animating variable
287  int32 m_topIncrements; // Animating variable
288  bool8 m_warpDirection; // Direction of animation
289 
290  char m_fontName[ENGINE_STRING_LEN]; // Bitmap font handling
291  _pxBitmap *m_font_file;
292  uint32 *m_fontPalette;
293  uint32 m_fontHeight;
294  _pxPCSprite *m_currentSprite;
295  _rgb m_selectedShade;
296  LinkedDataFile *m_global_text;
297 
298  _rgb m_drawColour; // Current primitive drawing colour
299 
300  _MENU_ m_activeMenu; // Active menu identifier
301 
302  _SLOT *m_slots[TOTAL_NUMBER_OF_GAME_SLOTS]; // Save slot pointers
303  uint32 m_slotOffset; // Offset to current slot page
304  uint32 m_movieOffset; // Offset to current movie page
305 
306  // Which option is selected for the main choices
307  MAIN_TOP_CHOICES m_M_TOP_selected;
308  M_EXTRA_CHOICES m_M_EXTRA_selected;
309  M_MOVIE_CHOICES m_M_MOVIE_selected;
310  M_PLAYSELECT_CHOICES m_M_PLAYSELECT_selected;
311  M_PROFILES_CHOICES m_M_PROFILES_selected;
312 
313  // Which option is selected for the in-game choices
314  IN_GAME_TOP_CHOICES m_IG_TOP_selected;
315 
316  // Generic chosers used in both option screens
317  OPTION_CHOICES m_OPTION_selected;
318  VIDEO_CHOICES m_VIDEO_selected;
319  AUDIO_CHOICES m_AUDIO_selected;
320  CONTROL_CHOICES m_CONTROL_selected;
321  GAMESLOT_CHOICES m_GAMESLOT_selected;
322  SAVECONFIRM_CHOICES m_SAVECONFIRM_selected;
323  QUIT_CHOICES m_QUIT_selected;
324  GAMEOVER_CHOICES m_GAMEOVER_selected;
325 
326  // Extra temporary direct draw surfaces to work with
327  uint32 m_myScreenSurfaceID;
328  uint32 m_mySlotSurface1ID;
329  uint32 m_thumbSurfaceIDs[8];
330  uint32 m_grayThumbSurfaceIDs[8];
331  uint32 m_movieSurfaceIDs[24];
332  uint32 m_grayMovieSurfaceIDs[24];
333  uint32 m_profileSurface;
334 
335  LRECT m_fullscreen; // Useful rectangle
336  LRECT m_movieRect; // Paging rectangle
337  uint32 m_colourKey; // Blitting colour key
338 
339  bool8 m_moveLimiter; // Vertical input flag
340  bool8 m_alterLimiter; // Horizontal input flag
341  bool8 m_choiceLimiter; // Select input flag
342  bool8 m_controlPage1; // Control screen page indicator
343  uint32 m_controlAnimCursor; // Animation sequence position
344 
345  int32 m_move_sfx_channel; // Audio channel for move sfx
346  int32 m_choose_sfx_channel; // Audio channel for select sfx
347 
348  bool8 m_canSave; // Is save disabled in game
349 
350  // Edit label buffer position
351  uint32 m_cursorPos;
352  char m_editBuffer[MAX_LABEL_LENGTH];
353  char m_defaultSlotName[MAX_LABEL_LENGTH];
354  bool8 m_editing;
355  bool8 m_defaultWiper;
356  int32 m_emptySlotFlag;
357 
358  uint32 m_timePlayed;
359 
360  // For animating and handling slot pages
361  bool8 m_paging; // Are we currently paging (animating)
362  bool8 m_pageleft; // Left or right paging
363  LRECT m_slotBoundingRect; // Box containing the 10 visible slots
364  int32 m_slotsAnimOffBy; // Animation step incrementer
365  LRECT m_pageOn_from; // Source blit rect for slots entering the screen
366  LRECT m_pageOn_dest; // Target blit rect for slots entering the screen
367  LRECT m_pageOff_from; // Source blit rect for slots leaving the screen
368  LRECT m_pageOff_dest; // Target blit rect for slots leaving the screen
369  bool8 m_letJoystickQuitEdit; // Flag to restrain joystick presses
370 
371  bool8 m_awaitingKeyPress; // For control assignment
372  bool8 m_configLimiter;
373  int32 m_assignFlash;
374 
375  bool8 m_creditControl; // Credits displaying flag
376  Crediter m_crediter; // Crediter class instance
377 
378  bool8 m_slideshowActive; // Slideshow active flag
379  bool8 m_slideLimiter; // Slideshow variables
380  int32 m_currentSlide;
381  int32 m_slideWadger;
382  uint32 m_slideFillColour;
383 
384  uint32 m_margin; // Profile screen variables
385  LRECT m_profileRect;
386  int32 m_profileScrollingOffset;
387  int32 m_profileScrollingLine;
388  bool8 m_lastLineDisplayed;
389  int32 m_profileScrolling;
390 
391 public:
392  OptionsManager(); // Constructor
393  ~OptionsManager(); // Destructor
394 
395  // Initialise menu functions
396  void StartInGameOptions();
397  void StartMainOptions();
398  void StartGameOverOptions();
399 
400  // Cycle
401  void CycleLogic();
402 
403  // Force screen refresh
404  void ForceInGameScreenRefresh();
405 
406  // Enquire as to present status
407  bool8 HasControl() { return m_haveControl; }
408 
409  // Public access routines
410  void DoCredits();
411  void InitialiseScrollingText(const char *textFileName, const char *movieFileName, int32 frameStart);
412  void DoScrollingText();
413  void DisplayText(uint8 *ad, uint32 pitch, const char *str, int32 x, int32 y, uint32 col, bool8 centredHorizontally, bool8 boxed = FALSE8);
414  const char *GetTextFromReference(uint32 hashRef);
415  uint32 CalculateStringWidth(const char *str);
416  void UnlockMovies();
417 
418 private:
419  // Logic
420  void CycleInGameOptionsLogic();
421  void CycleMainOptionsLogic();
422  void CycleGameOverLogic();
423  void InitialiseInGameOptions();
424  void MoveSelected(bool8 _down_);
425  void AlterSelected(bool8 _right_);
426  void DoChoice();
427  void OnEscapeKey();
428 
429  // Input
430  void PollInput();
431 
432  // Graphics handling
433  void MakeAllSurfii();
434  void KillAllSurfii();
435 
436  void SetDrawColour(uint32 def);
437  void DrawRectangle(bool8 selected, uint32 x, uint32 y, uint32 width, uint32 height, uint8 *surface_address, uint32 pitch);
438  void DarkenScreen();
439  void BloodScreen();
440  void SetDesiredOptionsBoxParameters(uint32 width, uint32 height, uint32 nFrames);
441  void SetTargetBox(uint32 x1, uint32 x2, uint32 y1, uint32 y2, uint32 nFrames);
442  bool8 AnimateThoseBrackets(bool8 forwards);
443  bool8 AnimateBracketsToBox(bool8 forwards, uint32 surface_id = working_buffer_id);
444  void AnimateSlotsPaging();
445  void GrabThumbnailImage();
446  void LoadVisibleThumbnails();
447  void LoadPagingThumbnails(uint32 slotOffset);
448  void MakeGrayScaleThumbnail(uint32 src_surface_id, uint32 dst_surface_id, uint32 w = 64, uint32 h = 48);
449  void LoadVisibleMovieShots();
450  void LoadPagingMovieShots(uint32 slotOffset);
451  void DrawWidescreenBorders();
452  void DrawPageIndicator(uint32 x, uint32 y, bool8 up, bool8 selected, uint8 *ad, uint32 pitch);
453  void FadeStrip(uint32 x, uint32 y, uint32 w, bool8 up, uint8 *ad, uint32 pitch);
454 
455  // Screen drawing functions
456  void DrawMainOptionsScreen(uint32 surface_id);
457  void DrawInGameOptionsScreen();
458  void DrawGameOverScreen();
459  void DrawGameSlots(uint32 slotOffset, uint32 surface_id = working_buffer_id);
460  void DrawMovieSlots(uint32 offset, uint32 surface_id = working_buffer_id);
461  void DrawGameOptions();
462  void DrawAudioSettings();
463  void DrawVideoSettings();
464  void DrawControllerConfiguration();
465  void DrawMainLoadScreen(uint32 surface_id = working_buffer_id);
466  void DrawMovieScreen(uint32 surface_id = working_buffer_id);
467  void DrawQuitGameConfirmScreen(uint32 surface_id = working_buffer_id);
468  void DrawExtrasScreen(uint32 surface_id = working_buffer_id);
469  void DrawPlaySelectScreen(uint32 surface_id = working_buffer_id);
470  void DrawSlideShow();
471  void DrawProfileSelectScreen(uint32 surface_id = working_buffer_id);
472  void DrawProfileScreen(uint32 surface_id = working_buffer_id);
473  void DrawOverwriteSaveConfirmScreen(uint32 surface_id = working_buffer_id);
474 
475  // Screen initialising functions
476  void InitialiseControlsScreen();
477  void InitialiseSlideShow();
478  void InitialiseAProfile();
479 
480  // Slot management
481  void InitialiseSlots();
482  void DestroySlots();
483 
484  // Assign control functions
485  void EditSlotLabel();
486  bool8 VerifyLabel();
487  void GetKeyAssignment();
488 
489  // Font handling
490  void LoadBitmapFont();
491  void LoadGlobalTextFile();
492  bool8 SetCharacterSprite(char c);
493  void RenderCharacter(uint8 *ad, uint32 pitch, int32 nX, int32 nY, uint32 col);
494  void GetCentredRectFotText(const char *str, LRECT &r, int32 height);
495 
496  // Option screen sound functions
497  void InitialiseSounds();
498  void PlayMoveFX();
499  void PlayChosenFX();
500 
501  // For the movie library
502  void PlayMovie(uint32 id);
503 
504  // Title screen movie backdrop
505  void LoadTitleScreenMovie();
506  void UnloadTitleScreenMovie();
507 };
508 
509 } // End of namespace ICB
510 
511 #endif
Definition: options_manager_pc.h:252
Definition: px_common.h:109
Definition: options_manager_pc.h:246
Definition: px_bitmap_pc.h:44
Definition: actor.h:32
Definition: px_bitmap_pc.h:51
Definition: px_linkeddatafile.h:53
Definition: options_manager_pc.h:266
Definition: px_types.h:32
Definition: options_manager_pc.h:46