1 ///////////////////////////////////////////////////////////////////////////////
2 //            Copyright (C) 2004-2010 by The Allacrost Project
3 //                         All Rights Reserved
4 //
5 // This code is licensed under the GNU GPL version 2. It is free software
6 // and you may modify it and/or redistribute it under the terms of this license.
7 // See http://www.gnu.org/copyleft/gpl.html for details.
8 ///////////////////////////////////////////////////////////////////////////////
9 
10 /** ****************************************************************************
11 *** \file    menu.h
12 *** \author  Daniel Steuernol steu@allacrost.org
13 *** \author  Andy Gardner chopperdave@allacrost.org
14 *** \brief   Header file for menu mode interface.
15 ***
16 *** This code handles the game event processing and frame drawing when the user
17 *** is in menu mode. This mode's primary objectives are to allow the user to
18 *** view stastics about their party and manage inventory and equipment.
19 *** ***************************************************************************/
20 
21 #ifndef __MENU_HEADER__
22 #define __MENU_HEADER__
23 
24 #include <string>
25 #include <vector>
26 
27 #include "utils.h"
28 #include "defs.h"
29 
30 #include "video.h"
31 
32 #include "global.h"
33 
34 #include "mode_manager.h"
35 #include "menu_views.h"
36 
37 //! \brief All calls to menu mode are wrapped in this namespace.
38 namespace hoa_menu {
39 
40 //! \brief Determines whether the code in the hoa_menu namespace should print debug statements or not.
41 extern bool MENU_DEBUG;
42 
43 //! \brief An internal namespace to be used only within the menu code. Don't use this namespace anywhere else!
44 namespace private_menu {
45 
46 //! \brief The different item categories
47 enum MAIN_CATEGORY {
48 	MAIN_INVENTORY      = 0,
49 	MAIN_SKILLS         = 1,
50 	MAIN_EQUIP          = 2,
51 	MAIN_STATUS         = 3,
52 //	MAIN_OPTIONS        = 3;
53 	MAIN_SAVE           = 4,
54 	MAIN_FORMATION      = 5,
55 	MAIN_SIZE           = 6
56 };
57 
58 //! \name Inventory Menu Options Constants
59 //@{
60 const uint32 INV_USE    = 0;
61 // const uint32 INV_SORT   = 1;
62 const uint32 INV_BACK   = 1;
63 const uint32 INV_SIZE   = 2;
64 //@}
65 
66 //! \name Skills Menu Options Constants
67 //@{
68 const uint32 SKILLS_USE     = 0;
69 const uint32 SKILLS_BACK    = 1;
70 const uint32 SKILLS_SIZE    = 2;
71 //@}
72 
73 //! \name Equipment Menu Options Constants
74 //@{
75 const uint32 EQUIP_EQUIP   = 0;
76 const uint32 EQUIP_REMOVE  = 1;
77 const uint32 EQUIP_BACK    = 2;
78 const uint32 EQUIP_SIZE    = 3;
79 //@}
80 
81 //! \name Status Menu Options Constants
82 //@{
83 const uint32 STATUS_VIEW    = 0;
84 const uint32 STATUS_BACK    = 1;
85 const uint32 STATUS_SIZE    = 2;
86 //@}
87 
88 //! \name Formation Menu Options Constants
89 //@{
90 const uint32 FORMATION_SWITCH  = 0;
91 const uint32 FORMATION_BACK    = 1;
92 const uint32 FORMATION_SIZE    = 2;
93 //@}
94 
95 //! \name Options Menu Options Constants
96 //@{
97 const uint32 OPTIONS_EDIT    = 0;
98 const uint32 OPTIONS_SAVE    = 1;
99 const uint32 OPTIONS_BACK    = 2;
100 const uint32 OPTIONS_SIZE    = 3;
101 //@}
102 
103 //! \name Save Menu Options Constants
104 //@{
105 const uint32 SAVE_SAVE    = 0;
106 const uint32 SAVE_BACK    = 1;
107 const uint32 SAVE_SIZE    = 2;
108 //@}
109 
110 //! \name MenuMode OptionBox Show Flags
111 //! \brief Constants used to determine which option box is currently showing.
112 //@{
113 const uint32 SHOW_MAIN          = 0;
114 const uint32 SHOW_INVENTORY     = 1;
115 const uint32 SHOW_SKILLS        = 2;
116 const uint32 SHOW_EQUIP         = 3;
117 const uint32 SHOW_STATUS        = 4;
118 //const uint32 SHOW_OPTIONS       = 5;
119 const uint32 SHOW_SAVE          = 5;
120 const uint32 SHOW_FORMATION     = 6;
121 const uint32 SHOW_EXIT          = 7;
122 //@}
123 
124 /** \name MenuMode Active Window Flags
125 *** \brief Constants used to determine which window is currently showing.
126 **/
127 //@{
128 const uint32 WINDOW_INVENTORY      = 1;
129 const uint32 WINDOW_SKILLS         = 2;
130 const uint32 WINDOW_STATUS         = 3;
131 const uint32 WINDOW_EQUIP          = 4;
132 const uint32 WINDOW_FORMATION      = 5;
133 //@}
134 
135 } // namespace private_menu
136 
137 /** ****************************************************************************
138 *** \brief Handles game executing while in the main in-game menu.
139 ***
140 *** This mode of game operation allows the player to examine and manage their
141 *** party, inventory, options, and save their game.
142 ***
143 *** \note MenuMode is always entered from an instance of MapMode. However, there
144 *** may be certain conditions where MenuMode is entered from other game modes.
145 ***
146 *** \note MenuMode does not play its own music, but rather it continues playing
147 *** music from the previous GameMode that created it.
148 *** ***************************************************************************/
149 class MenuMode : public hoa_mode_manager::GameMode {
150 	friend class private_menu::CharacterWindow;
151 	friend class private_menu::InventoryWindow;
152 	friend class private_menu::StatusWindow;
153 	friend class private_menu::SkillsWindow;
154 	friend class private_menu::EquipWindow;
155 	friend class private_menu::FormationWindow;
156 
157 public:
158 	/** \param location_name The name of the current map that will be displayed on the menu screen.
159 	*** \param locale_image The filename for the location image that is displayed in the menus.
160 	**/
161 	MenuMode(hoa_utils::ustring locale_name, std::string locale_image);
162 
163 	~MenuMode();
164 
165 	//! \brief Returns a pointer to the active instance of menu mode
CurrentInstance()166 	static MenuMode* CurrentInstance()
167 		{ return _current_instance; }
168 
169 	//! \brief Resets the menu mode back to its default setup.
170 	void Reset();
171 
172 	//! \brief Updates the menu. Calls Update() on active window if there is one
173 	void Update();
174 
175 	//! \brief Draws the menu. Calls Draw() on active window if there is one.
176 	void Draw();
177 
178 	// TEMP: other menu classes need access to this member
GetCharSelect()179 	hoa_gui::OptionBox& GetCharSelect()
180 		{ return _char_select; }
181 
182 private:
183 	//! \brief A static pointer to the last instantiated MenuMode object
184 	static MenuMode* _current_instance;
185 
186 	//! \brief Text image which displays the name of the location in the game where MenuMode was invoked
187 	hoa_video::TextImage _locale_name;
188 
189 	/** \brief The graphic that represents the current map that the player is exploring
190 	*** This image is set using the string in the MenuMode constructor
191 	**/
192 	hoa_video::StillImage _locale_graphic;
193 
194 	/** \brief Retains a snap-shot of the screen just prior to when menu mode was entered
195 	*** This image is perpetually drawn as the background while in menu mode
196 	**/
197 	hoa_video::StillImage _saved_screen;
198 
199 	/** \name Main Display Windows
200 	*** \brief The various menu windows that are displayed in menu mode
201 	**/
202 	//@{
203 	hoa_gui::MenuWindow _bottom_window;
204 	hoa_gui::MenuWindow _main_options_window;
205 
206 	private_menu::CharacterWindow _character_window0;
207 	private_menu::CharacterWindow _character_window1;
208 	private_menu::CharacterWindow _character_window2;
209 	private_menu::CharacterWindow _character_window3;
210 	private_menu::InventoryWindow _inventory_window;
211 	private_menu::StatusWindow _status_window;
212 	private_menu::SkillsWindow _skills_window;
213 	private_menu::EquipWindow _equip_window;
214 	private_menu::FormationWindow _formation_window;
215 	MessageWindow *_message_window;
216 
217 	/** \brief The currently active window
218 	 **/
219 	hoa_gui::MenuWindow *_active_window;
220 
221 //	private_menu::SaveWindow _save_window;
222 
223 	// FIXME
224 	//std::vector<private_menu::CharacterWindow> _character_windows;
225 	//std::vector<private_menu::FormationWindow> _formation_windows;
226 	//@}
227 
228 	//! \brief A map of the sounds used while in MenuMode
229 	std::map<std::string, hoa_audio::SoundDescriptor> _menu_sounds;
230 
231 	//! The selected character
232 //	static uint32 _char_selected;
233 
234 	//! The selected item/skill/equipment
235 	uint32 _item_selected;
236 
237 	//! The current option box to display
238 	uint32 _current_menu_showing;
239 
240 	//! The current window being drawn
241 	uint32 _current_window;
242 
243 	//! A pointer to the current options menu
244 	hoa_gui::OptionBox *_current_menu;
245 
246 	//! The top level options in boot mode
247 	hoa_gui::OptionBox _main_options;
248 
249 	//! \name Option boxes that are used in the various menu windows
250 	//@{
251 	hoa_gui::OptionBox _menu_inventory;
252 	hoa_gui::OptionBox _menu_skills;
253 	hoa_gui::OptionBox _menu_status;
254 	hoa_gui::OptionBox _menu_options;
255 	hoa_gui::OptionBox _menu_equip;
256 	hoa_gui::OptionBox _menu_formation;
257 	hoa_gui::OptionBox _menu_save;
258 	hoa_gui::OptionBox _char_select;
259 	//@}
260 
261 	//! \brief Functions that initialize the numerous option boxes
262 	//@{
263 	void _SetupOptionBoxCommonSettings(hoa_gui::OptionBox *ob);
264 	void _SetupMainOptionBox();
265 	void _SetupInventoryOptionBox();
266 	void _SetupSkillsOptionBox();
267 	void _SetupStatusOptionBox();
268 	void _SetupOptionsOptionBox();
269 	void _SetupFormationOptionBox();
270 	void _SetupSaveOptionBox();
271 	void _SetupEquipOptionBox();
272 	//@}
273 
274 	/** \name Menu Handle Functions
275 	*** \brief Handler functions to deal with events for all the different menus
276 	**/
277 	//@{
278 	void _HandleMainMenu();
279 	void _HandleInventoryMenu();
280 	void _HandleSkillsMenu();
281 	void _HandleStatusMenu();
282 	void _HandleOptionsMenu();
283 	void _HandleFormationMenu();
284 	void _HandleSaveMenu();
285 	void _HandleEquipMenu();
286 	//@}
287 
288 	/** \name Active Window Functions
289 	*** \brief Handles finding the next active window
290 	**/
291 	//@{
292 	void _GetNextActiveWindow();
293 	//@}
294 
295 	//! \brief Draws the bottom part of the menu mode.
296 	void _DrawBottomMenu();
297 
298 	//! \brief Draws the 'Name' and 'Qty' tags for the item list.
299 	void _DrawItemListHeader();
300 
301 }; // class MenuMode : public hoa_mode_manager::GameMode
302 
303 } // namespace hoa_menu
304 
305 #endif
306