ScummVM API documentation
icon_menu.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_ICONMENU_H_INCLUDED
28 #define ICB_ICONMENU_H_INCLUDED
29 
30 // Include headers needed by this class.
31 #include "engines/icb/common/px_string.h"
32 #include "engines/icb/common/px_common.h"
33 #include "engines/icb/common/px_bitmap.h"
34 #include "engines/icb/player.h"
35 #include "engines/icb/icon_list.h"
36 #include "engines/icb/icon_menu_pc.h"
37 
38 namespace ICB {
39 
40 // Use globals as it reduces rdata storage on PSX
41 extern const char *global_nothing_selected;
42 
43 #define ICON_MENU_LOG "icon_menu_log.txt"
44 
45 // This defines the maximum number of icons that can be in the menu.
46 #define ICON_MENU_MAX_ICONS 15 // NB: CHECK PADDING IMPLICATIONS FOR PSX BEFORE CHANGING THIS!
47 
48 // This is the standard number of frames in each icon.
49 #define ICON_FRAME_COUNT 2
50 
51 // Controls how fast the highlight flashes.
52 #define ICON_MENU_HIGHLIGHT_SPEED 5
53 
54 // This controls the flash rate of the added medipacks and ammo clips.
55 #define ICON_MENU_ADDED_FLASHRATE 4
56 
57 // This controls the flashrate of the email-waiting symbol.
58 #define ICON_MENU_EMAIL_FLASHRATE 24
59 
60 // These define the names of the off-screen indicator arrows.
61 #define ICON_MENU_OFF_SCREEN_LEFT "left_arrow"
62 #define ICON_MENU_OFF_SCREEN_RIGHT "right_arrow"
63 
64 // These are names for the ammo and healthcare stuff.
65 #define ARMS_GUN_NAME "gun"
66 #define ARMS_AMMO_NAME "ammo"
67 #define ARMS_HEALTH_NAME "health_pack"
68 #define EMAIL_ARRIVED_NAME "mail"
69 
70 // Used for telling which way we are scrolling / if we are scrolling
71 #define ICON_MENU_SCROLL_NONE 0
72 #define ICON_MENU_SCROLL_LEFT 1
73 #define ICON_MENU_SCROLL_RIGHT 2
74 
75 // struct _icon_menu_duplicates
76 // This structure must be passed into the icon menu upon activation, whereupon the information in it
77 // will be used to add a count to the number of each item currently in the menu.
79  uint8 s_nNumItems;
80  uint8 s_pnItemCounts[ICON_MENU_MAX_ICONS];
81 
82  // Initialisation.
83  _icon_menu_duplicates() { s_nNumItems = 0; }
84 };
85 
86 // This class presents a set of icons to the user and runs the selection interface. It is packaged as a separate
87 // class because it is used by the Remora, the speech system and the inventory.
88 class _icon_menu {
89 public:
90  // Default constructor and destructor.
91  _icon_menu();
92  ~_icon_menu() {}
93 
94  // If the menu is up, call this to process its logic and draw the menu.
95  bool8 CycleIconMenu(const _input &sKeyboardState);
96 
97  // Draw the special armed inventory
98  void DrawArmedMenu(const int32 nBullets, const int32 maxBullets, const int32 nClips, const int32 maxClips);
99 
100  // And this draws it each cycle.
101  void DrawIconMenu();
102 
103  // Call this to close the menu down.
104  void CloseDownIconMenu();
105 
106  // This is the main function for running a menu selection.
107  void Activate(const _icon_list *pIconList, const _icon_menu_duplicates &sDuplicates, bool8 bAllowEscape, uint32 nSelected);
108 
109  // A funstion to recreate/load the icon surfaces after task switching
110  void ReActivate();
111 
112  // This reports whether or not the icon menu is active.
113  bool8 IsActive() const { return ((m_eIconMenuGameState == ACTIVE) ? TRUE8 : FALSE8); }
114 
115  // This says whether or not there is currently a valid selection (i.e. player is 'holding' something.)
116  bool8 IsHolding() const { return (m_bValidSelection); }
117 
118  // This draws the current selection for as long as it is still 'held'.
119  void CycleHoldingLogic();
120 
121  // These handle the logic and drawing for adding medipacks and clips.
122  void SetAddingClipsCount(uint32 nNumClips);
123  void SetAddingMedipacksCount(uint32 nNumMedipacks);
124  bool8 IsAdding() const;
125  void CycleAddingLogic();
126  void DrawAdding();
127 
128  // An icon needs to flash when an email arrives. This mechanism borrows the logic from the medipacks and clips above.
129  void SetEmailArrived();
130  void ClearEmailArrived() { m_bEmailArrived = FALSE8; }
131 
132  // This reports the last menu selection if one is available.
133  const char *GetLastSelection();
134  uint32 GetLastSelectionHash() const;
135 
136  // This clears the selection.
137  void ClearSelection() { m_bValidSelection = FALSE8; }
138 
139  uint32 GetTransparencyKey() const { return (m_nTransparentKey); }
140  void SetTransparencyColourKey();
141 
142  // These are used for PSX smoothing. (Won't do any harm on the PC.)
143  void PreloadIcon(const char *pcIconPath, const char *pcIconName);
144 
145 private:
146  int32 GetScrollingPosition(const int32 nInputX, uint32 &nIconIndex);
147 
148  enum IconMenuGameState { INACTIVE = 0, ACTIVE };
149 
150  IconMenuGameState m_eIconMenuGameState; // Current state of the icon menu object.
151  const _icon_list *m_pIconList; // Pointer to the list of icons to run the selection for.
152  uint32 m_nLastSelection; // Stores the last selection made by the chooser.
153  uint32 m_nSelectedIcon; // Stores the icon currently centred in the screen.
154  uint32 m_nHighlightCounter; // Used to control frequency of highlight flashing.
155  const char *m_pcSelectedIconName; // Name of the currently selected icon.
156  uint32 m_nSelectedIconHash; // Hash of the currently selected icon.
157  uint32 m_nIconClusterHash; // Icon cluster hash value.
158  _icon_menu_duplicates m_sDuplicates; // Count of any duplicate items.
159  uint32 m_nGlobalClusterHash; // Hash value for the global cluster.
160 
161  uint32 m_pnIconSurfaceIDs[ICON_MENU_MAX_ICONS]; // IDs of surfaces where non-highlighted icons are stored.
162  uint32 m_pnHiLiteSurfaceIDs[ICON_MENU_MAX_ICONS]; // IDs of surfaces for storing highlighted versions.
163  uint32 m_nLeftArrowID; // The left-off screen arrow.
164  uint32 m_nRightArrowID; // Highlighted version of it.
165  uint32 m_nLeftArrowHiLiteID; // The right-off screen arrow.
166  uint32 m_nRightArrowHiLiteID; // Highlighted version of it.
167  uint32 m_nAddedClipsSurface; // Surface for the flashing of added clips.
168  uint32 m_nAddedMedipacksSurface; // Surface for the flashing of added medipacks.
169  uint32 m_nEmailArrivedSurface; // Surface for the email-arrived icon.
170  uint32 m_nMenuY; // The y height to draw the menu at
171  uint32 m_nTransparentKey; // Use this colour for transparency in blitting.
172  char m_pcGlobalClusterFile[MAXLEN_CLUSTER_URL]; // The global cluster file.
173  char m_pcIconCluster[MAXLEN_CLUSTER_URL]; // Icon cluster name.
174 
175  bool8 m_bValidSelection; // Gets set true when a selection is made and false when it is read.
176  bool8 m_nKeyLock; // Stops key-repeat.
177  bool8 m_bHighlightVisible; // Whether or not the highlight is visible on the selected icon.
178  bool8 m_bAllowEscape; // Allows backstep to escape from the menu if true.
179 
180  bool8 m_bWiderThanScreen; // Set to true when the icons won't all fit on the screen.
181  uint8 m_nScrollCycles; // Count of how many game cycles we have been scrolling
182  uint8 m_nLastIconIndex; // the last selected icon index used for scrolling
183  uint8 m_nScrollDirection; // which direction we are scrolling
184 
185  uint8 m_nAddedMedipacks; // Gets set to cause flashing of added medipacks.
186  uint8 m_nAddedClips; // Gets set to cause flashing of added clips.
187  uint8 m_nAddedSymbol; // Indicates which 'adding' icon to display.
188  uint8 m_nAddedFlashCount; // Used to control the flashing of added medipacs and clips.
189 
190  bool8 m_bEmailArrived; // Used to flag the arrival of an email.
191  uint8 m_nMaxIconsDisplayed; // Holds current maximum icons that can be displayed.
192  uint8 m_bPad2;
193  uint8 m_bPad3;
194 
195  // Here I block the use of the default '='.
196  _icon_menu(const _icon_menu &) {}
197 
198  void operator=(const _icon_menu &) {}
199 
200  // Private functions used only in this class.
201  void CloseDownIconMenuDisplay();
202 
203  void SetUpOffScreenArrows();
204  void SetupAdding(const char *pcIconName, uint32 &nSurfaceID);
205  void CloseDownAdding();
206 };
207 
208 extern _icon_menu *g_oIconMenu;
209 }
210 
211 #endif // #if !defined( ICONMENU_H_INCLUDED )
Definition: player.h:147
Definition: icon_menu.h:78
Definition: actor.h:32
Definition: icon_menu.h:88
Definition: icon_list.h:65