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_views.h
12 *** \author Daniel Steuernol steu@allacrost.org
13 *** \author Andy Gardner chopperdave@allacrost.org
14 *** \brief Header file for various menu views.
15 ***
16 *** This code handles the different menu windows that the user will see while the
17 *** is in menu mode. These windows are used for displaying inventory lists,
18 *** character statistics, and various other pieces of information.
19 *** ***************************************************************************/
20
21 #ifndef __MENU_VIEWS__
22 #define __MENU_VIEWS__
23
24 #include <string>
25 #include <vector>
26
27 #include "utils.h"
28 #include "defs.h"
29
30 #include "video.h"
31 #include "gui.h"
32
33 #include "global.h"
34
35
36
37 namespace hoa_menu {
38
39 namespace private_menu {
40
41 //! \brief The different item categories
42 enum ITEM_CATEGORY {
43 ITEM_ALL = 0,
44 ITEM_ITEM = 1,
45 ITEM_WEAPONS = 2,
46 ITEM_HEAD_ARMOR = 3,
47 ITEM_TORSO_ARMOR = 4,
48 ITEM_ARM_ARMOR = 5,
49 ITEM_LEG_ARMOR = 6,
50 ITEM_KEY = 7,
51 ITEM_CATEGORY_SIZE = 8
52 };
53
54 //! \brief The different skill types
55 enum SKILL_CATEGORY {
56 SKILL_ALL = 0,
57 SKILL_FIELD = 1,
58 SKILL_BATTLE = 2,
59 SKILL_CATEGORY_SIZE = 3
60 };
61
62 //! \brief The different equipment categories
63 enum EQUIP_CATEGORY {
64 EQUIP_WEAPON = 0,
65 EQUIP_HEADGEAR = 1,
66 EQUIP_BODYARMOR = 2,
67 EQUIP_OFFHAND = 3,
68 EQUIP_LEGGINGS = 4,
69 EQUIP_CATEGORY_SIZE = 5
70 };
71
72 //! \brief The different option boxes that can be active for items
73 enum ITEM_ACTIVE_OPTION {
74 ITEM_ACTIVE_NONE = 0,
75 ITEM_ACTIVE_CATEGORY = 1,
76 ITEM_ACTIVE_LIST = 2,
77 ITEM_ACTIVE_CHAR = 3,
78 ITEM_ACTIVE_SIZE = 4
79 };
80
81 //! \brief The different option boxes that can be active for skills
82 enum SKILL_ACTIVE_OPTION {
83 SKILL_ACTIVE_NONE = 0,
84 SKILL_ACTIVE_CHAR = 1,
85 SKILL_ACTIVE_CATEGORY = 2,
86 SKILL_ACTIVE_LIST = 3,
87 SKILL_ACTIVE_CHAR_APPLY = 4,
88 SKILL_ACTIVE_SIZE = 5
89 };
90
91 //! \brief The different option boxes that can be active for equipment
92 enum EQUIP_ACTIVE_OPTION {
93 EQUIP_ACTIVE_NONE = 0,
94 EQUIP_ACTIVE_CHAR = 1,
95 EQUIP_ACTIVE_SELECT = 2,
96 EQUIP_ACTIVE_LIST = 3,
97 EQUIP_ACTIVE_SIZE = 4
98 };
99
100 //! \brief The different option boxes that can be active for equipment
101 enum FORM_ACTIVE_OPTION {
102 FORM_ACTIVE_NONE = 0,
103 FORM_ACTIVE_CHAR = 1,
104 FORM_ACTIVE_SECOND = 2,
105 FORM_ACTIVE_SIZE = 3
106 };
107
108 //! \brief Possible values from the confirm window
109 enum CONFIRM_RESULT
110 {
111 CONFIRM_RESULT_YES = 0,
112 CONFIRM_RESULT_NO = 1,
113 CONFIRM_RESULT_NOTHING = 2,
114 CONFIRM_RESULT_CANCEL = 3,
115 };
116
117 /** ****************************************************************************
118 *** \brief Represents an individual character window
119 ***
120 *** There should be one of these windows for each character in the game.
121 *** It will contain all the information of the character and handle its draw
122 *** placement.
123 *** ***************************************************************************/
124 class CharacterWindow : public hoa_gui::MenuWindow {
125 private:
126 //! The name of the character that this window corresponds) to
127 uint32 _char_id;
128
129 //! The image of the character
130 hoa_video::StillImage _portrait;
131
132 public:
133 CharacterWindow();
134
135 ~CharacterWindow();
136
137 /** \brief Set the character for this window
138 *** \param character the character to associate with this window
139 **/
140 void SetCharacter(hoa_global::GlobalCharacter *character);
141
142 /** \brief render this window to the screen
143 *** \return success/failure
144 **/
145 void Draw();
146 }; // class CharacterWindow : public hoa_video::MenuWindow
147
148
149
150 /** ****************************************************************************
151 *** \brief Represents the inventory window to browse the party's inventory
152 ***
153 *** This handles item use. You can also view all items by category.
154 *** ***************************************************************************/
155 class InventoryWindow : public hoa_gui::MenuWindow {
156 friend class hoa_menu::MenuMode;
157
158 public:
159 InventoryWindow();
160
161 ~InventoryWindow();
162
163 /** \brief Toggles the inventory window being in the active context for the player
164 *** \param new_status Activates the inventory window when true, de-activates it when false
165 **/
166 void Activate(bool new_status);
167
168 /** \brief Indicates whether the inventory window is in the active context
169 *** \return True if the inventory window is in the active context
170 **/
IsActive()171 bool IsActive()
172 { return _active_box; }
173
174 //! If the inventory window is ready to cancel out, or cancel out a sub-window
175 //bool CanCancel();
176
177 /*!
178 * \brief Updates the inventory window. Handles key presses, switches window context, etc.
179 */
180 void Update();
181
182 /*!
183 * \brief Draw the inventory window
184 * \return success/failure
185 */
186 void Draw();
187
188 private:
189 //! Used for char portraits in bottom menu
190 std::vector<hoa_video::StillImage> _portraits;
191
192 //! Used for the current dungeon
193 hoa_video::StillImage _location_graphic;
194
195 //! Flag to specify the active option box
196 uint32 _active_box;
197
198 //! OptionBox to display all of the items
199 hoa_gui::OptionBox _inventory_items;
200
201 //! OptionBox to choose character
202 hoa_gui::OptionBox _char_select;
203
204 //! OptionBox to choose item category
205 hoa_gui::OptionBox _item_categories;
206
207 //! TextBox that holds the selected object's description
208 hoa_gui::TextBox _description;
209
210 //! Vector of GlobalObjects that corresponds to _inventory_items
211 std::vector< hoa_global::GlobalObject* > _item_objects;
212
213 /*!
214 * \brief Updates the item text in the inventory items
215 */
216 void _UpdateItemText();
217
218 /*!
219 * \brief Initializes inventory items option box
220 */
221 void _InitInventoryItems();
222
223 /*!
224 * \brief Initializes char select option box
225 */
226 void _InitCharSelect();
227
228 /*!
229 * \brief Initializes item category select option box
230 */
231 void _InitCategory();
232
233 template <class T> std::vector<hoa_global::GlobalObject*> _GetItemVector(std::vector<T*>* inv);
234 }; // class InventoryWindow : public hoa_video::MenuWindow
235
236
237
238 /** ****************************************************************************
239 *** \brief Represents the Status window, displaying all the information about the character.
240 ***
241 *** This window display all the attributes of the character.
242 *** You can scroll through them all as well, to view all the different characters.
243 *** ***************************************************************************/
244 class StatusWindow : public hoa_gui::MenuWindow {
245 private:
246 //! char portraits
247 std::vector<hoa_video::StillImage> _full_portraits;
248
249 //! if the window is active or not
250 bool _char_select_active;
251
252 //! character selection option box
253 hoa_gui::OptionBox _char_select;
254
255 /*!
256 * \brief initialize character selection option box
257 */
258 void _InitCharSelect();
259
260 public:
261
262 StatusWindow();
263 ~StatusWindow();
264
265 /*!
266 * \brief render this window to the screen
267 * \return success/failure
268 */
269 void Draw();
270
271 /*!
272 * \brief update function handles input to the window
273 */
274 void Update();
275
276 /*!
277 * \brief Check if status window is active
278 * \return true if the window is active, false if it's not
279 */
IsActive()280 inline bool IsActive() { return _char_select_active; }
281
282 /*!
283 * \brief Active this window
284 * \param new_value true to activate window, false to deactivate window
285 */
286 void Activate(bool new_value);
287
288 }; // class StatusWindow : public hoa_video::MenuWindow
289
290
291
292 /** ****************************************************************************
293 *** \brief Represents the Skills window, displaying all the skills for the character.
294 ***
295 *** This window display all the skills for a particular character.
296 *** You can scroll through them all, filter by category, choose one, and apply it
297 *** to a character.
298 *** ***************************************************************************/
299 class SkillsWindow : public hoa_gui::MenuWindow {
300 friend class hoa_menu::MenuMode;
301
302 public:
303 SkillsWindow();
304
~SkillsWindow()305 ~SkillsWindow()
306 {}
307
308 /*!
309 * \brief Updates key presses and window states
310 */
311 void Update();
312
313 /*!
314 * \brief Draws the windows and option boxes
315 * \return success/failure
316 */
317 void Draw();
318
319 /*!
320 * \brief Activates the window
321 * \param new_value true to activate window, false to deactivate window
322 */
323 void Activate(bool new_status);
324
325 /*!
326 * \brief Checks to see if the skills window is active
327 * \return true if the window is active, false if it's not
328 */
IsActive()329 bool IsActive()
330 { return _active_box; }
331
332 private:
333 //! Flag to specify the active option box
334 uint32 _active_box;
335
336 //! The character select option box
337 hoa_gui::OptionBox _char_select;
338
339 //! The skills categories option box
340 hoa_gui::OptionBox _skills_categories;
341
342 //! The skills list option box
343 hoa_gui::OptionBox _skills_list;
344
345 //! The skill SP cost option box
346 hoa_gui::OptionBox _skill_cost_list;
347
348 //! TextBox that holds the selected skill's description
349 hoa_gui::TextBox _description;
350
351 //! Track which character's skillset was chosen
352 int32 _char_skillset;
353
354 /*!
355 * \brief Initializes the skills category chooser
356 */
357 void _InitSkillsCategories();
358
359 /*!
360 * \brief Initializes the skills chooser
361 */
362 void _InitSkillsList();
363
364 /*!
365 * \brief Initializes the character selector
366 */
367 void _InitCharSelect();
368
369 //! \brief Returns the currently selected skill
370 hoa_global::GlobalSkill *_GetCurrentSkill();
371
372 /*!
373 * \brief Sets up the skills that comprise the different categories
374 */
375 void _UpdateSkillList();
376
377 hoa_utils::ustring _BuildSkillListText(const hoa_global::GlobalSkill * skill);
378
379 //! \brief parses the 3 skill lists of the global character and sorts them according to use (menu/battle)
380 void _BuildMenuBattleSkillLists(std::vector<hoa_global::GlobalSkill *> *skill_list,
381 std::vector<hoa_global::GlobalSkill *> *field, std::vector<hoa_global::GlobalSkill *> *battle,
382 std::vector<hoa_global::GlobalSkill *> *all);
383
384 }; //class SkillsWindow : public hoa_video::MenuWindow
385
386
387 /** ****************************************************************************
388 *** \brief Represents the Equipment window, allowing the player to change equipment.
389 ***
390 *** This window changes a character's equipment.
391 *** You can choose a piece of equipment and replace with an item from the given list.
392 *** ***************************************************************************/
393 class EquipWindow : public hoa_gui::MenuWindow {
394 friend class hoa_menu::MenuMode;
395
396 public:
397 EquipWindow();
398 ~EquipWindow();
399
400 /*!
401 * \brief Draws window
402 * \return success/failure
403 */
404 void Draw();
405
406 /*!
407 * \brief Performs updates
408 */
409 void Update();
410
411 /*!
412 * \brief Checks to see if the equipment window is active
413 * \return true if the window is active, false if it's not
414 */
IsActive()415 bool IsActive()
416 { return _active_box; }
417
418 /*!
419 * \brief Activates the window
420 * \param new_value true to activate window, false to deactivate window
421 */
422 void Activate(bool new_status);
423
424 private:
425
426 //! Character selector
427 hoa_gui::OptionBox _char_select;
428
429 //! Equipment selector
430 hoa_gui::OptionBox _equip_select;
431
432 //! Replacement selector
433 hoa_gui::OptionBox _equip_list;
434
435 //! Flag to specify the active option box
436 uint32 _active_box;
437
438 //! equipment images
439 std::vector<hoa_video::StillImage> _equip_images;
440
441 /*!
442 * \brief Set up char selector
443 */
444 void _InitCharSelect();
445
446 /*!
447 * \brief Set up equipment selector
448 */
449 void _InitEquipmentSelect();
450
451 /*!
452 * \brief Set up replacement selector
453 */
454 void _InitEquipmentList();
455
456 /*!
457 * \brief Updates the equipment list
458 */
459 void _UpdateEquipList();
460
461 }; // class EquipWindow : public hoa_video::MenuWindow
462
463
464
465 /** ****************************************************************************
466 *** \brief Represents the Formation window, allowing the party to change order.
467 ***
468 *** This window changes party order.
469 *** ***************************************************************************/
470 class FormationWindow : public hoa_gui::MenuWindow {
471 friend class hoa_menu::MenuMode;
472
473 public:
474 FormationWindow();
475 ~FormationWindow();
476 void Update();
477 void Draw();
478
479 /*!
480 * \brief Activates the window
481 * \param new_value true to activate window, false to deactivate window
482 */
483 void Activate(bool new_status);
484
485 /*!
486 * \brief Checks to see if the skills window is active
487 * \return true if the window is active, false if it's not
488 */
IsActive()489 bool IsActive()
490 { return _active_box; }
491
492 private:
493 //! Flag to specify the active option box
494 uint32 _active_box;
495
496 //! The character select option box
497 hoa_gui::OptionBox _char_select;
498
499 //! The character select option box once first character has been selected
500 hoa_gui::OptionBox _second_char_select;
501
502 /*!
503 * \brief initialize character selection option box
504 */
505 void _InitCharSelect();
506
507 }; // class FormationWindow : public hoa_video::MenuWindow
508
509 /*!
510 * \brief Converts a vector of GlobalItem*, etc. to a vector of GlobalObjects*
511 * \return the same vector, with elements of type GlobalObject*
512 */
_GetItemVector(std::vector<T * > * inv)513 template <class T> std::vector<hoa_global::GlobalObject*> InventoryWindow::_GetItemVector(std::vector<T*>* inv) {
514 std::vector<hoa_global::GlobalObject*> obj_vector;
515
516 for (typename std::vector<T*>::iterator i = inv->begin(); i != inv->end(); i++) {
517 obj_vector.push_back( *i );
518 }
519
520 return obj_vector;
521 }
522
523 } // namespace private_menu
524
525 /** **************************************************************************
526 *** \brief A window to display a message to the player
527 *** Displays a message to the user in the center of the screen
528 *** This class is not private because it's a handy message box and
529 *** it could be used else where.
530 *** **************************************************************************/
531 class MessageWindow : public hoa_gui::MenuWindow
532 {
533 public:
534 MessageWindow(const hoa_utils::ustring &message, float w, float h);
535 ~MessageWindow();
536
537 //! \brief Set the text to display in the window
SetText(const hoa_utils::ustring & message)538 void SetText(const hoa_utils::ustring &message)
539 { _message = message; _textbox.SetDisplayText(message); }
540
541 //! \brief Standard Window Functions
542 //@{
543 void Draw();
544 //@}
545
546 private:
547 //! \brief the message to display
548 hoa_utils::ustring _message;
549
550 //! \brief used to display the message
551 hoa_gui::TextBox _textbox;
552 }; // class MessageWindow
553
554 } // namespace hoa_menu
555
556 #endif
557