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.cpp
12 *** \author Daniel Steuernol steu@allacrost.org
13 *** \author Andy Gardner chopperdave@allacrost.org
14 *** \brief Source file for menu mode interface.
15 *** ***************************************************************************/
16
17 #include <iostream>
18 #include <sstream>
19
20 #include "system.h"
21 #include "input.h"
22 #include "audio.h"
23 #include "pause.h"
24
25 #include "save_mode.h" // TODO: remove this
26
27 #include "mode_manager.h"
28 #include "menu.h"
29
30
31 using namespace std;
32
33 using namespace hoa_utils;
34 using namespace hoa_audio;
35 using namespace hoa_video;
36 using namespace hoa_gui;
37 using namespace hoa_system;
38 using namespace hoa_mode_manager;
39 using namespace hoa_input;
40 using namespace hoa_global;
41 using namespace hoa_pause;
42
43 using namespace hoa_menu::private_menu;
44
45 namespace hoa_menu {
46
47 bool MENU_DEBUG = false;
48
49 MenuMode* MenuMode::_current_instance = NULL;
50
51 ////////////////////////////////////////////////////////////////////////////////
52 // MenuMode class -- Initialization and Destruction Code
53 ////////////////////////////////////////////////////////////////////////////////
54
MenuMode(ustring locale_name,string locale_image)55 MenuMode::MenuMode(ustring locale_name, string locale_image) :
56 _message_window(NULL)
57 {
58 if (MENU_DEBUG)
59 cout << "MENU: MenuMode constructor invoked." << endl;
60
61 _locale_name.SetStyle(TextStyle("title22"));
62 _locale_name.SetText(locale_name);
63
64 // Initialize the location graphic
65 _locale_graphic.SetStatic(true);
66 if (_locale_graphic.Load(locale_image, 500, 125) == false) {
67 cerr << "MENU ERROR: failed to load locale graphic in MenuMode constructor: " << locale_image << endl;
68 exit(1);
69 }
70
71 try {
72 _saved_screen = VideoManager->CaptureScreen();
73 }
74 catch(Exception e) {
75 cerr << e.ToString() << endl;
76 }
77
78 _current_window = WINDOW_INVENTORY;
79
80 GlobalParty & characters = *GlobalManager->GetActiveParty();
81
82 // Setup character windows based on active party size
83 switch (characters.GetPartySize()) {
84 case 4: _character_window3.SetCharacter(dynamic_cast<GlobalCharacter*>(characters.GetActorAtIndex(3)));
85 case 3: _character_window2.SetCharacter(dynamic_cast<GlobalCharacter*>(characters.GetActorAtIndex(2)));
86 case 2: _character_window1.SetCharacter(dynamic_cast<GlobalCharacter*>(characters.GetActorAtIndex(1)));
87 case 1: _character_window0.SetCharacter(dynamic_cast<GlobalCharacter*>(characters.GetActorAtIndex(0)));
88 break;
89 default:
90 cerr << "MENU ERROR: no characters in party!" << endl;
91 exit(1);
92 }
93
94 //////////// Setup the menu windows
95 uint32 start_x = (1024 - 800) / 2 - 40;
96 uint32 start_y = (768 - 600) / 2 + 15;
97 uint32 win_width = 208;
98
99 //The bottom window for the menu
100 _bottom_window.Create(static_cast<float>(win_width * 4 + 16), 140 + 16, VIDEO_MENU_EDGE_ALL);
101 _bottom_window.SetPosition(static_cast<float>(start_x), static_cast<float>(start_y + 442));
102
103 // Width of each character window is 360 px.
104 // Each char window will have an additional 16 px for the left border
105 // The 4th (last) char window will have another 16 px for the right border
106 // Height of the char window is 98 px.
107 // The bottom window in the main view is 192 px high, and the full width which will be 216 * 4 + 16
108 _character_window0.Create(360, 98, ~VIDEO_MENU_EDGE_BOTTOM, VIDEO_MENU_EDGE_BOTTOM);
109 _character_window0.SetPosition(static_cast<float>(start_x), static_cast<float>(start_y + 10));
110
111 _character_window1.Create(360, 98, ~VIDEO_MENU_EDGE_BOTTOM, VIDEO_MENU_EDGE_BOTTOM | VIDEO_MENU_EDGE_TOP);
112 _character_window1.SetPosition(static_cast<float>(start_x), static_cast<float>(start_y + 118));
113
114 _character_window2.Create(360, 98, ~VIDEO_MENU_EDGE_BOTTOM, VIDEO_MENU_EDGE_BOTTOM | VIDEO_MENU_EDGE_TOP);
115 _character_window2.SetPosition(static_cast<float>(start_x), static_cast<float>(start_y + 226));
116
117 _character_window3.Create(360, 98, ~VIDEO_MENU_EDGE_BOTTOM, VIDEO_MENU_EDGE_TOP | VIDEO_MENU_EDGE_BOTTOM);
118 _character_window3.SetPosition(static_cast<float>(start_x), static_cast<float>(start_y + 334));
119
120 _main_options_window.Create(static_cast<float>(win_width * 4 + 16), 60, ~VIDEO_MENU_EDGE_BOTTOM, VIDEO_MENU_EDGE_BOTTOM);
121 _main_options_window.SetPosition(static_cast<float>(start_x), static_cast<float>(start_y - 50));
122
123 // Set up the status window
124 _status_window.Create(static_cast<float>(win_width * 4 + 16), 448, VIDEO_MENU_EDGE_ALL);
125 _status_window.SetPosition(static_cast<float>(start_x), static_cast<float>(start_y + 10));
126
127 //Set up the skills window
128 _skills_window.Create(static_cast<float>(win_width * 4 + 16), 448, VIDEO_MENU_EDGE_ALL);
129 _skills_window.SetPosition(static_cast<float>(start_x), static_cast<float>(start_y + 10));
130
131 //Set up the equipment window
132 _equip_window.Create(static_cast<float>(win_width * 4 + 16), 448, VIDEO_MENU_EDGE_ALL);
133 _equip_window.SetPosition(static_cast<float>(start_x), static_cast<float>(start_y + 10));
134
135 // Set up the inventory window
136 _inventory_window.Create(static_cast<float>(win_width * 4 + 16), 448, VIDEO_MENU_EDGE_ALL);
137 _inventory_window.SetPosition(static_cast<float>(start_x), static_cast<float>(start_y + 10));
138
139 // // TODO: Set up the formation window
140 _formation_window.Create(static_cast<float>(win_width * 4 + 16), 448, VIDEO_MENU_EDGE_ALL);
141 _formation_window.SetPosition(static_cast<float>(start_x), static_cast<float>(start_y + 10));
142
143
144 // Set the menu to show the main options
145 _current_menu_showing = SHOW_MAIN;
146 _current_menu = &_main_options;
147
148 // Load menu sounds
149 _menu_sounds["confirm"] = SoundDescriptor();
150 _menu_sounds["confirm"].LoadAudio("snd/confirm.wav");
151 _menu_sounds["cancel"] = SoundDescriptor();
152 _menu_sounds["cancel"].LoadAudio("snd/cancel.wav");
153 _menu_sounds["bump"] = SoundDescriptor();
154 _menu_sounds["bump"].LoadAudio("snd/bump.wav");
155
156 if (_current_instance != NULL) {
157 if (MENU_DEBUG)
158 cerr << "MENU WARNING: attempting to create a new instance of MenuMode when one already seems to exist" << endl;
159 }
160 _current_instance = this;
161 } // MenuMode::MenuMode()
162
163
164
~MenuMode()165 MenuMode::~MenuMode() {
166 if (MENU_DEBUG)
167 cout << "MENU: MenuMode destructor invoked." << endl;
168
169 // Destroy all menu windows
170 _bottom_window.Destroy();
171 _character_window0.Destroy();
172 _character_window1.Destroy();
173 _character_window2.Destroy();
174 _character_window3.Destroy();
175 _inventory_window.Destroy();
176 _status_window.Destroy();
177 _skills_window.Destroy();
178 _main_options_window.Destroy();
179 _equip_window.Destroy();
180 _formation_window.Destroy();
181
182 // Free sounds
183 _menu_sounds["confirm"].FreeAudio();
184 _menu_sounds["bump"].FreeAudio();
185 _menu_sounds["cancel"].FreeAudio();
186
187 _current_instance = NULL;
188
189 if (_message_window != NULL)
190 delete _message_window;
191 } // MenuMode::~MenuMode()
192
193
194 // Resets configuration/data for the class as appropriate
Reset()195 void MenuMode::Reset() {
196 // Top left corner coordinates in menu mode are always (0,0)
197 VideoManager->SetCoordSys(0.0f, 1023.0f, 767.0f, 0.0f);
198
199 // Show all windows (make them visible)
200 _bottom_window.Show();
201 _main_options_window.Show();
202 _character_window0.Show();
203 _character_window1.Show();
204 _character_window2.Show();
205 _character_window3.Show();
206 _inventory_window.Show();
207 _status_window.Show();
208 _skills_window.Show();
209 _equip_window.Show();
210 _formation_window.Show();
211
212 _inventory_window.Activate(false);
213 _active_window = &_inventory_window;
214
215 // Setup OptionBoxes
216 _SetupMainOptionBox();
217 _SetupInventoryOptionBox();
218 _SetupSkillsOptionBox();
219 _SetupStatusOptionBox();
220 _SetupOptionsOptionBox();
221 _SetupSaveOptionBox();
222 _SetupEquipOptionBox();
223 _SetupFormationOptionBox();
224 } // void MenuMode::Reset()
225
226 ////////////////////////////////////////////////////////////////////////////////
227 // MenuMode class -- Update Code
228 ////////////////////////////////////////////////////////////////////////////////
229
Update()230 void MenuMode::Update() {
231 if (InputManager->QuitPress() == true) {
232 ModeManager->Push(new PauseMode(true));
233 return;
234 }
235 else if (InputManager->PausePress() == true) {
236 ModeManager->Push(new PauseMode(false));
237 return;
238 }
239
240 // check the message window
241 if (_message_window != NULL)
242 {
243 _message_window->Update();
244 if (InputManager->ConfirmPress() || InputManager->CancelPress())
245 {
246 delete _message_window;
247 _message_window = NULL;
248 }
249 return;
250 }
251
252 if (_active_window->IsActive())
253 {
254 _active_window->Update();
255 return;
256 }
257
258 if (InputManager->CancelPress()) {
259 // Play sound.
260 _menu_sounds["cancel"].Play();
261 // If in main menu, return to previous Mode, else return to main menu.
262 if (_current_menu_showing == SHOW_MAIN) {
263 ModeManager->Pop();
264 }
265 else {
266 _current_menu_showing = SHOW_MAIN;
267 _current_menu = &_main_options;
268 _current_menu->Update();
269 }
270 }
271 else if (InputManager->ConfirmPress()) {
272 // Play Sound
273 if (_current_menu->IsEnabled(_current_menu->GetSelection()))
274 _menu_sounds["confirm"].Play();
275
276 _current_menu->InputConfirm();
277 }
278 else if (InputManager->LeftPress()) {
279 // Play Sound
280 _current_menu->InputLeft();
281 }
282 else if (InputManager->RightPress()) {
283 // Play Sound
284 _current_menu->InputRight();
285 }
286 else if (InputManager->SwapPress()) {
287 // Play Sound
288 _char_select.SetSelection((_char_select.GetSelection() + 1) %
289 GlobalManager->GetActiveParty()->GetPartySize());
290 }
291
292 // Get the latest event from the current menu
293 int32 event = _current_menu->GetEvent();
294
295 // If confirm was pressed
296 if (event == VIDEO_OPTION_CONFIRM) {
297 // Handle options for the current menu
298 switch (_current_menu_showing) {
299 case SHOW_MAIN:
300 _HandleMainMenu();
301 break;
302
303 case SHOW_INVENTORY:
304 _HandleInventoryMenu();
305 break;
306
307 case SHOW_SKILLS:
308 _HandleSkillsMenu();
309 break;
310
311 case SHOW_STATUS:
312 _HandleStatusMenu();
313 break;
314
315 case SHOW_EQUIP:
316 _HandleEquipMenu();
317 break;
318
319 case SHOW_FORMATION:
320 _HandleFormationMenu();
321 break;
322
323 /*case SHOW_OPTIONS:
324 _HandleOptionsMenu();
325 break;*/
326
327 case SHOW_SAVE:
328 _HandleSaveMenu();
329 break;
330
331 default:
332 cerr << "MENU: ERROR: Invalid menu showing!" << endl;
333 break;
334 } // switch (_current_menu_showing)
335 _GetNextActiveWindow();
336 } // if VIDEO_OPTION_CONFIRM
337
338 _current_menu->Update();
339
340 } // void MenuMode::Update()
341
342 ////////////////////////////////////////////////////////////////////////////////
343 // MenuMode class -- Draw Code
344 ////////////////////////////////////////////////////////////////////////////////
Draw()345 void MenuMode::Draw() {
346 // Draw the saved screen background
347 // For that, set the system coordinates to the size of the window (same with the save-screen)
348 int32 width = VideoManager->GetScreenWidth();
349 int32 height = VideoManager->GetScreenHeight();
350 VideoManager->SetCoordSys(0.0f, static_cast<float>(width), 0.0f, static_cast<float>(height));
351
352 VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_BOTTOM, 0);
353 Color grayed(0.35f, 0.35f, 0.35f, 1.0f);
354 VideoManager->Move(0.0f, 0.0f);
355 _saved_screen.Draw();
356
357 // Restore the Coordinate system (that one is menu mode coodinate system)
358 VideoManager->SetCoordSys(0.0f, 1024.0f, 768.0f, 0.0f);
359
360
361 uint32 draw_window;
362
363 VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_TOP, VIDEO_BLEND, 0);
364
365 // Move to the top left corner
366 VideoManager->Move(0.0f, 0.0f);
367
368 _main_options_window.Draw();
369 _DrawBottomMenu();
370
371 // Detects which option is highlighted in main menu choices and sets that to the current window
372 // to draw
373 if (_current_menu_showing == SHOW_MAIN) {
374 draw_window = _current_menu->GetSelection() + 1;
375 }
376 else {
377 draw_window = _current_menu_showing;
378 }
379
380 // Draw the chosen window
381 switch (draw_window) {
382 case SHOW_MAIN:
383 break;
384
385 case SHOW_INVENTORY:
386 _inventory_window.Draw();
387 break;
388
389 case SHOW_STATUS:
390 _status_window.Draw();
391 break;
392
393 case SHOW_SKILLS:
394 _skills_window.Draw();
395 break;
396
397 case SHOW_EQUIP:
398 _equip_window.Draw();
399 break;
400
401 /*case SHOW_OPTIONS:
402 _HandleOptionsMenu();
403 break;*/
404
405 case SHOW_SAVE:
406 case SHOW_EXIT:
407 case SHOW_FORMATION:
408 _formation_window.Draw();
409 break;
410 } // switch draw_window
411
412 // Draw character windows
413 _character_window0.Draw();
414 _character_window1.Draw();
415 _character_window2.Draw();
416 _character_window3.Draw();
417
418 // Draw currently active options box
419 _current_menu->Draw();
420
421 // Draw message window if it's active
422 if (_message_window != NULL)
423 _message_window->Draw();
424 } // void MenuMode::Draw()
425
426
427 //FIX ME: Adjust for new layout
_HandleMainMenu()428 void MenuMode::_HandleMainMenu() {
429 switch (_main_options.GetSelection()) {
430 case MAIN_INVENTORY:
431 _current_menu_showing = SHOW_INVENTORY;
432 _current_menu = &_menu_inventory;
433 break;
434
435 case MAIN_SKILLS:
436 _current_menu_showing = SHOW_SKILLS;
437 _current_menu = &_menu_skills;
438 break;
439
440 /*case MAIN_OPTIONS:
441 _current_menu_showing = SHOW_OPTIONS;
442 _current_menu = &_menu_options;
443 break;*/
444
445 case MAIN_FORMATION:
446 _current_menu_showing = SHOW_FORMATION;
447 _current_menu = &_menu_formation;
448 break;
449
450 case MAIN_STATUS:
451 _current_menu_showing = SHOW_STATUS;
452 _current_menu = &_menu_status;
453 break;
454
455 case MAIN_EQUIP:
456 _current_menu_showing = SHOW_EQUIP;
457 _current_menu = &_menu_equip;
458 break;
459
460 case MAIN_SAVE:
461 // _current_menu_showing = SHOW_SAVE;
462 // _current_menu = &_menu_save;
463 { hoa_save::SaveMode *SVM = new hoa_save::SaveMode(true);
464 ModeManager->Push(SVM);
465 break;
466 } // end scope
467
468 default:
469 cerr << "MENU ERROR: Invalid option in MenuMode::_HandleMainMenu()" << endl;
470 break;
471 }
472 } // void MenuMode::_HandleMainMenu()
473
_HandleInventoryMenu()474 void MenuMode::_HandleInventoryMenu() {
475 switch (_menu_inventory.GetSelection()) {
476 case INV_USE:
477 if (GlobalManager->GetInventory()->size() == 0)
478 return;
479 _inventory_window.Activate(true);
480 break;
481
482 /* case INV_SORT:
483 // TODO: Handle the sort inventory comand
484 cout << "MENU: Inventory sort command!" << endl;
485 break;*/
486
487 case INV_BACK:
488 _current_menu_showing = SHOW_MAIN;
489 _current_menu = &_main_options;
490 break;
491
492 default:
493 cerr << "MENU ERROR: Invalid option in MenuMode::_HandleInventoryMenu()" << endl;
494 break;
495 }
496 }
497
_SetupOptionBoxCommonSettings(OptionBox * ob)498 void MenuMode::_SetupOptionBoxCommonSettings(OptionBox *ob) {
499 // Set all the default options
500 ob->SetTextStyle(TextStyle("title22"));
501 ob->SetPosition(142.0f, 85.0f);
502 ob->SetDimensions(115.0f, 50.0f, 1, 1, 1, 1);
503 ob->SetAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER);
504 ob->SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
505 ob->SetSelectMode(VIDEO_SELECT_SINGLE);
506 ob->SetHorizontalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
507 ob->SetCursorOffset(-52.0f, -20.0f);
508 }
509
510
511
_SetupMainOptionBox()512 void MenuMode::_SetupMainOptionBox() {
513 // Setup the main options box
514 _SetupOptionBoxCommonSettings(&_main_options);
515 _main_options.SetDimensions(745.0f, 50.0f, MAIN_SIZE, 1, 6, 1);
516
517 // Generate the strings
518 vector<ustring> options;
519 options.push_back(UTranslate("Inventory"));
520 options.push_back(UTranslate("Skills"));
521 options.push_back(UTranslate("Equip"));
522 options.push_back(UTranslate("Status"));
523 options.push_back(UTranslate("Save"));
524 options.push_back(UTranslate("Formation"));
525
526 // Add strings and set default selection.
527 _main_options.SetOptions(options);
528 _main_options.SetSelection(MAIN_INVENTORY);
529 }
530
531
532
_SetupInventoryOptionBox()533 void MenuMode::_SetupInventoryOptionBox() {
534 // Setup the option box
535 _SetupOptionBoxCommonSettings(&_menu_inventory);
536 _menu_inventory.SetDimensions(115.0f, 50.0f, INV_SIZE, 1, INV_SIZE, 1);
537
538 // Generate the strings
539 vector<ustring> options;
540 options.push_back(UTranslate("Use"));
541 // options.push_back(UTranslate("Sort"));
542 options.push_back(UTranslate("Back"));
543
544 // Add strings and set default selection.
545 _menu_inventory.SetOptions(options);
546 _menu_inventory.SetSelection(INV_USE);
547 }
548
549
550
_SetupSkillsOptionBox()551 void MenuMode::_SetupSkillsOptionBox() {
552 // Setup the option box
553 _SetupOptionBoxCommonSettings(&_menu_skills);
554 _menu_skills.SetDimensions(115.0f, 50.0f, SKILLS_SIZE, 1, SKILLS_SIZE, 1);
555
556 // Generate the strings
557 vector<ustring> options;
558 options.push_back(UTranslate("Use"));
559 options.push_back(UTranslate("Back"));
560
561 // Add strings and set default selection.
562 _menu_skills.SetOptions(options);
563 _menu_skills.SetSelection(SKILLS_USE);
564 }
565
_SetupStatusOptionBox()566 void MenuMode::_SetupStatusOptionBox() {
567 // Setup the status option box
568 _SetupOptionBoxCommonSettings(&_menu_status);
569 _menu_status.SetDimensions(115.0f, 50.0f, STATUS_SIZE, 1, STATUS_SIZE, 1);
570
571 // Generate the strings
572 vector<ustring> options;
573 options.push_back(UTranslate("View"));
574 options.push_back(UTranslate("Back"));
575
576 // Add strings and set default selection.
577 _menu_status.SetOptions(options);
578 _menu_status.SetSelection(STATUS_VIEW);
579 }
580
581
582
_SetupOptionsOptionBox()583 void MenuMode::_SetupOptionsOptionBox() {
584 // Setup the options option box
585 _SetupOptionBoxCommonSettings(&_menu_options);
586 _menu_options.SetDimensions(115.0f, 50.0f, OPTIONS_SIZE, 1, OPTIONS_SIZE, 1);
587
588 // Generate the strings
589 vector<ustring> options;
590 options.push_back(UTranslate("Edit"));
591 options.push_back(UTranslate("Save"));
592 options.push_back(UTranslate("Back"));
593
594 // Add strings and set default selection.
595 _menu_options.SetOptions(options);
596 _menu_options.SetSelection(OPTIONS_EDIT);
597 }
598
_SetupSaveOptionBox()599 void MenuMode::_SetupSaveOptionBox() {
600 // setup the save options box
601 _SetupOptionBoxCommonSettings(&_menu_save);
602 // _menu_save.SetSize(SAVE_SIZE, 1);
603
604 // Generate the strings
605 vector<ustring> options;
606 options.push_back(UTranslate("Save"));
607 options.push_back(UTranslate("Back"));
608
609 // Add strings and set default selection.
610 _menu_save.SetOptions(options);
611 _menu_save.SetSelection(SAVE_SAVE);
612 }
613
_SetupFormationOptionBox()614 void MenuMode::_SetupFormationOptionBox() {
615 // setup the save options box
616 _SetupOptionBoxCommonSettings(&_menu_formation);
617 _menu_formation.SetDimensions(115.0f, 50.0f, FORMATION_SIZE, 1, FORMATION_SIZE, 1);
618
619 // Generate the strings
620 vector<ustring> options;
621 options.push_back(UTranslate("Switch"));
622 options.push_back(UTranslate("Back"));
623
624 // Add strings and set default selection.
625 _menu_formation.SetOptions(options);
626 _menu_formation.SetSelection(FORMATION_SWITCH);
627 }
628
_SetupEquipOptionBox()629 void MenuMode::_SetupEquipOptionBox() {
630 // Setup the status option box
631 _SetupOptionBoxCommonSettings(&_menu_equip);
632 _menu_equip.SetDimensions(195.0f, 50.0f, EQUIP_SIZE, 1, EQUIP_SIZE, 1);
633
634 // Generate the strings
635 vector<ustring> options;
636 options.push_back(UTranslate("Equip"));
637 options.push_back(UTranslate("Remove"));
638 options.push_back(UTranslate("Back"));
639
640 // Add strings and set default selection.
641 _menu_equip.SetOptions(options);
642 _menu_equip.SetSelection(EQUIP_EQUIP);
643
644 }
645
646
_HandleSkillsMenu()647 void MenuMode::_HandleSkillsMenu() {
648 switch (_menu_skills.GetSelection()) {
649 case SKILLS_BACK:
650 _current_menu_showing = SHOW_MAIN;
651 _current_menu = &_main_options;
652 break;
653
654 case SKILLS_USE:
655 _skills_window.Activate(true);
656 break;
657
658 default:
659 cerr << "MENU ERROR: Invalid option in MenuMode::_HandleSkillsMenu()" << endl;
660 break;
661 }
662 }
663
664
_HandleStatusMenu()665 void MenuMode::_HandleStatusMenu() {
666 switch (_menu_status.GetSelection()) {
667 case STATUS_VIEW:
668 _status_window.Activate(true);
669 break;
670
671 case STATUS_BACK:
672 _current_menu_showing = SHOW_MAIN;
673 _current_menu = &_main_options;
674 break;
675
676 default:
677 cerr << "MENU ERROR: Invalid option in MenuMode::_HandleStatusMenu()" << endl;
678 break;
679 }
680 }
681
_HandleOptionsMenu()682 void MenuMode::_HandleOptionsMenu() {
683 switch (_menu_options.GetSelection()) {
684 case OPTIONS_EDIT:
685 // TODO: Handle the Options - Edit command
686 cout << "MENU: Options - Edit command!" << endl;
687 break;
688
689 case OPTIONS_SAVE:
690 // TODO: Handle the Options - Save command
691 cout << "MENU: Options - Save command!" << endl;
692 break;
693
694 case OPTIONS_BACK:
695 _current_menu_showing = SHOW_MAIN;
696 _current_menu = &_main_options;
697 break;
698
699 default:
700 cerr << "MENU ERROR: Invalid option in MenuMode::_HandleOptionsMenu()" << endl;
701 break;
702 }
703 }
704
705
706
_HandleFormationMenu()707 void MenuMode::_HandleFormationMenu() {
708 switch (_menu_formation.GetSelection()) {
709 case FORMATION_SWITCH:
710 _formation_window._char_select.SetSelection(0);
711 _formation_window.Activate(true);
712 break;
713
714 case FORMATION_BACK:
715 _current_menu_showing = SHOW_MAIN;
716 _current_menu = &_main_options;
717 break;
718
719 default:
720 cerr << "MENU ERROR: Invalid option in MenuMode::_HandleFormationMenu()" << endl;
721 break;
722 }
723 }
724
725
726
_HandleSaveMenu()727 void MenuMode::_HandleSaveMenu() {
728 string file_name;
729 switch (_menu_save.GetSelection()) {
730 case SAVE_SAVE: {
731 hoa_save::SaveMode *SVM = new hoa_save::SaveMode(true);
732 ModeManager->Push(SVM);
733 break;
734 }
735
736 case SAVE_BACK: {
737 _current_menu_showing = SHOW_MAIN;
738 _current_menu = &_main_options;
739 break;
740 }
741
742 default: {
743 cerr << "MENU ERROR: Invalid option in MenuMode::_HandleSaveMenu()" << endl;
744 }
745 }
746 }
747
_HandleEquipMenu()748 void MenuMode::_HandleEquipMenu() {
749 switch (_menu_equip.GetSelection()) {
750 case EQUIP_EQUIP:
751 _equip_window.Activate(true);
752 break;
753
754 case EQUIP_REMOVE:
755 // TODO: Handle the remove command
756 cout << "MENU: Equip - Remove command!" << endl;
757 break;
758
759 case EQUIP_BACK:
760 _current_menu_showing = SHOW_MAIN;
761 _current_menu = &_main_options;
762 break;
763
764 default:
765 cerr << "MENU ERROR: Invalid option in MenuMode::_HandleEquipMenu()" << endl;
766 break;
767 }
768 }
769
770
771
_GetNextActiveWindow()772 void MenuMode::_GetNextActiveWindow()
773 {
774 switch (_current_menu_showing)
775 {
776 case SHOW_MAIN:
777 case SHOW_INVENTORY:
778 _active_window = &_inventory_window;
779 break;
780 case SHOW_EQUIP:
781 _active_window = &_equip_window;
782 break;
783 case SHOW_SKILLS:
784 _active_window = &_skills_window;
785 break;
786 case SHOW_FORMATION:
787 _active_window = &_formation_window;
788 break;
789 case SHOW_STATUS:
790 _active_window = &_status_window;
791 break;
792 }
793 }
794
795
796 //FIX ME: Make dynamic, move category id and select state enums to this class
_DrawBottomMenu()797 void MenuMode::_DrawBottomMenu() {
798 _bottom_window.Draw();
799
800 VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_BOTTOM, 0);
801 VideoManager->Move(150, 580);
802
803 if (_current_menu_showing == SHOW_INVENTORY ) {
804 if (_inventory_window._active_box == ITEM_ACTIVE_LIST) {
805 GlobalObject* obj = _inventory_window._item_objects[ _inventory_window._inventory_items.GetSelection() ];
806
807 VideoManager->SetDrawFlags(VIDEO_X_LEFT,VIDEO_Y_CENTER,0);
808
809 VideoManager->Move(100, 600);
810 obj->GetIconImage().Draw();
811 VideoManager->MoveRelative(65, 0);
812 VideoManager->Text()->Draw(obj->GetName());
813 VideoManager->SetDrawFlags(VIDEO_X_LEFT,VIDEO_Y_BOTTOM,0);
814 _inventory_window._description.Draw();
815 } // if ITEM_ACTIVE_LIST
816 } // if SHOW_INVENTORY
817 else if (_current_menu_showing == SHOW_SKILLS ) {
818 _skills_window._description.Draw();
819 } // if SHOW_SKILLS
820 else if (_current_menu_showing == SHOW_EQUIP) {
821 GlobalCharacter* ch = dynamic_cast<GlobalCharacter*>(GlobalManager->GetActiveParty()->GetActorAtIndex(_equip_window._char_select.GetSelection()));
822 VideoManager->Text()->Draw(UTranslate("STR: ") + MakeUnicodeString(NumberToString(ch->GetStrength())));
823
824 VideoManager->MoveRelative(0, 20);
825 VideoManager->Text()->Draw(UTranslate("VIG: ") + MakeUnicodeString(NumberToString(ch->GetVigor())));
826
827 VideoManager->MoveRelative(0, 20);
828 VideoManager->Text()->Draw(UTranslate("FRT: ") + MakeUnicodeString(NumberToString(ch->GetFortitude())));
829
830 VideoManager->MoveRelative(0, 20);
831 VideoManager->Text()->Draw(UTranslate("PRO: ") + MakeUnicodeString(NumberToString(ch->GetProtection())));
832
833 VideoManager->MoveRelative(0, 20);
834 VideoManager->Text()->Draw(UTranslate("AGI: ") + MakeUnicodeString(NumberToString(ch->GetAgility())));
835
836 VideoManager->MoveRelative(0, 20);
837 VideoManager->Text()->Draw(UTranslate("EVD: ") + MakeUnicodeString(NumberToString(ch->GetEvade()) + "%"));
838
839 VideoManager->Move(310, 577);
840
841 VideoManager->Text()->Draw(UTranslate("Current Equipment:"));
842
843 VideoManager->MoveRelative(0, 20);
844 VideoManager->Text()->Draw(UTranslate("Weapon"));
845
846 VideoManager->MoveRelative(0, 20);
847 VideoManager->Text()->Draw(UTranslate("Head"));
848
849 VideoManager->MoveRelative(0, 20);
850 VideoManager->Text()->Draw(UTranslate("Torso"));
851
852 VideoManager->MoveRelative(0, 20);
853 VideoManager->Text()->Draw(UTranslate("Arm"));
854
855 VideoManager->MoveRelative(0, 20);
856 VideoManager->Text()->Draw(UTranslate("Legs"));
857
858 VideoManager->Move(400, 577);
859
860 VideoManager->MoveRelative(0, 20);
861 VideoManager->Text()->Draw(UTranslate("PHYS ATK: ") + MakeUnicodeString(NumberToString(ch->GetWeaponEquipped()->GetPhysicalAttack())));
862
863 VideoManager->MoveRelative(0, 20);
864 VideoManager->Text()->Draw(UTranslate("PHYS DEF: ") + MakeUnicodeString(NumberToString(ch->GetHeadArmorEquipped()->GetPhysicalDefense())));
865
866 VideoManager->MoveRelative(0, 20);
867 VideoManager->Text()->Draw(UTranslate("PHYS DEF: ") + MakeUnicodeString(NumberToString(ch->GetTorsoArmorEquipped()->GetPhysicalDefense())));
868
869 VideoManager->MoveRelative(0, 20);
870 VideoManager->Text()->Draw(UTranslate("PHYS DEF: ") + MakeUnicodeString(NumberToString(ch->GetArmArmorEquipped()->GetPhysicalDefense())));
871
872 VideoManager->MoveRelative(0, 20);
873 VideoManager->Text()->Draw(UTranslate("PHYS DEF: ") + MakeUnicodeString(NumberToString(ch->GetLegArmorEquipped()->GetPhysicalDefense())));
874
875 VideoManager->Move(550, 577);
876
877 VideoManager->MoveRelative(0, 20);
878 VideoManager->Text()->Draw(UTranslate("META ATK: ") + MakeUnicodeString(NumberToString(ch->GetWeaponEquipped()->GetMetaphysicalAttack())));
879
880 VideoManager->MoveRelative(0, 20);
881 VideoManager->Text()->Draw(UTranslate("META DEF: ") + MakeUnicodeString(NumberToString(ch->GetHeadArmorEquipped()->GetMetaphysicalDefense())));
882
883 VideoManager->MoveRelative(0, 20);
884 VideoManager->Text()->Draw(UTranslate("META DEF: ") + MakeUnicodeString(NumberToString(ch->GetTorsoArmorEquipped()->GetMetaphysicalDefense())));
885
886 VideoManager->MoveRelative(0, 20);
887 VideoManager->Text()->Draw(UTranslate("META DEF: ") + MakeUnicodeString(NumberToString(ch->GetArmArmorEquipped()->GetMetaphysicalDefense())));
888
889 VideoManager->MoveRelative(0, 20);
890 VideoManager->Text()->Draw(UTranslate("META DEF: ") + MakeUnicodeString(NumberToString(ch->GetLegArmorEquipped()->GetMetaphysicalDefense())));
891 VideoManager->SetDrawFlags(VIDEO_X_CENTER,VIDEO_Y_BOTTOM,0);
892
893
894 if (_equip_window._active_box == EQUIP_ACTIVE_LIST) {
895 VideoManager->Move(755, 577);
896
897 switch (_equip_window._equip_select.GetSelection()) {
898 case EQUIP_WEAPON:
899 {
900 GlobalWeapon* weapon = GlobalManager->GetInventoryWeapons()->at(_equip_window._equip_list.GetSelection());
901
902 VideoManager->Text()->Draw(weapon->GetName());
903 VideoManager->MoveRelative(0, 20);
904
905 VideoManager->Text()->Draw(UTranslate("PHYS ATK:"));
906 VideoManager->MoveRelative(0, 20);
907 VideoManager->Text()->Draw(MakeUnicodeString(NumberToString(weapon->GetPhysicalAttack())));
908 VideoManager->MoveRelative(0, 20);
909
910 VideoManager->Text()->Draw(UTranslate("META ATK:"));
911 VideoManager->MoveRelative(0, 20);
912 VideoManager->Text()->Draw(MakeUnicodeString(NumberToString(weapon->GetMetaphysicalAttack())));
913 VideoManager->MoveRelative(0, 20);
914
915 break;
916 } // case EQUIP_WEAPON
917 case EQUIP_HEADGEAR:
918 {
919 GlobalArmor* armor = GlobalManager->GetInventoryHeadArmor()->at(_equip_window._equip_list.GetSelection());
920
921 VideoManager->Text()->Draw(armor->GetName());
922 VideoManager->MoveRelative(0, 20);
923
924 VideoManager->Text()->Draw(UTranslate("PHYS DEF:"));
925 VideoManager->MoveRelative(0, 20);
926 VideoManager->Text()->Draw(MakeUnicodeString(NumberToString(armor->GetPhysicalDefense())));
927 VideoManager->MoveRelative(0, 20);
928
929 VideoManager->Text()->Draw(UTranslate("META DEF:"));
930 VideoManager->MoveRelative(0, 20);
931 VideoManager->Text()->Draw(MakeUnicodeString(NumberToString(armor->GetMetaphysicalDefense())));
932 VideoManager->MoveRelative(0, 20);
933
934 break;
935 } // case EQUIP_HEADGEAR
936 case EQUIP_BODYARMOR:
937 {
938 GlobalArmor* armor = GlobalManager->GetInventoryTorsoArmor()->at(_equip_window._equip_list.GetSelection());
939
940 VideoManager->Text()->Draw(armor->GetName());
941 VideoManager->MoveRelative(0, 20);
942
943 VideoManager->Text()->Draw(UTranslate("PHYS DEF:"));
944 VideoManager->MoveRelative(0, 20);
945 VideoManager->Text()->Draw(MakeUnicodeString(NumberToString(armor->GetPhysicalDefense())));
946 VideoManager->MoveRelative(0, 20);
947
948 VideoManager->Text()->Draw(UTranslate("META DEF:"));
949 VideoManager->MoveRelative(0, 20);
950 VideoManager->Text()->Draw(MakeUnicodeString(NumberToString(armor->GetMetaphysicalDefense())));
951 VideoManager->MoveRelative(0, 20);
952
953 break;
954 } // case EQUIP_BODYARMOR
955 case EQUIP_OFFHAND:
956 {
957 GlobalArmor* armor = GlobalManager->GetInventoryArmArmor()->at(_equip_window._equip_list.GetSelection());
958
959 VideoManager->Text()->Draw(armor->GetName());
960 VideoManager->MoveRelative(0, 20);
961
962 VideoManager->Text()->Draw(UTranslate("PHYS DEF:"));
963 VideoManager->MoveRelative(0, 20);
964 VideoManager->Text()->Draw(MakeUnicodeString(NumberToString(armor->GetPhysicalDefense())));
965 VideoManager->MoveRelative(0, 20);
966
967 VideoManager->Text()->Draw(UTranslate("META DEF:"));
968 VideoManager->MoveRelative(0, 20);
969 VideoManager->Text()->Draw(MakeUnicodeString(NumberToString(armor->GetMetaphysicalDefense())));
970 VideoManager->MoveRelative(0, 20);
971
972 break;
973 } // case EQUIP_OFFHAND
974 case EQUIP_LEGGINGS:
975 {
976 GlobalArmor* armor = GlobalManager->GetInventoryLegArmor()->at(_equip_window._equip_list.GetSelection());
977
978 VideoManager->Text()->Draw(armor->GetName());
979 VideoManager->MoveRelative(0, 20);
980
981 VideoManager->Text()->Draw(UTranslate("PHYS DEF:"));
982 VideoManager->MoveRelative(0, 20);
983 VideoManager->Text()->Draw(MakeUnicodeString(NumberToString(armor->GetPhysicalDefense())));
984 VideoManager->MoveRelative(0, 20);
985
986 VideoManager->Text()->Draw(UTranslate("META DEF:"));
987 VideoManager->MoveRelative(0, 20);
988 VideoManager->Text()->Draw(MakeUnicodeString(NumberToString(armor->GetMetaphysicalDefense())));
989 VideoManager->MoveRelative(0, 20);
990
991 break;
992 } // case EQUIP_LEGGINGS
993
994 default:
995 break;
996 } // switch
997 } // if EQUIP_ACTIVE_LIST
998 } // if SHOW_EQUIP
999 else {
1000 // Display Location
1001 _locale_name.Draw();
1002
1003 // Draw Played Time
1004 VideoManager->MoveRelative(-40, 60);
1005 std::ostringstream os_time;
1006 uint8 hours = SystemManager->GetPlayHours();
1007 uint8 minutes = SystemManager->GetPlayMinutes();
1008 uint8 seconds = SystemManager->GetPlaySeconds();
1009 os_time << (hours < 10 ? "0" : "") << static_cast<uint32>(hours) << ":";
1010 os_time << (minutes < 10 ? "0" : "") << static_cast<uint32>(minutes) << ":";
1011 os_time << (seconds < 10 ? "0" : "") << static_cast<uint32>(seconds);
1012
1013 std::string time = std::string("Time: ") + os_time.str();
1014 VideoManager->Text()->Draw(MakeUnicodeString(time));
1015
1016 // Display the current funds that the party has
1017 VideoManager->MoveRelative(0, 30);
1018 VideoManager->Text()->Draw(UTranslate("Drunes: ") + MakeUnicodeString(NumberToString(GlobalManager->GetDrunes())));
1019
1020 VideoManager->SetDrawFlags(VIDEO_X_RIGHT, VIDEO_Y_BOTTOM, 0);
1021 VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_BOTTOM, 0);
1022 VideoManager->Move(390, 685);
1023 _locale_graphic.Draw();
1024 }
1025 } // void MenuMode::_DrawBottomMenu()
1026
1027
_DrawItemListHeader()1028 void MenuMode::_DrawItemListHeader()
1029 { }
1030
1031 } // namespace hoa_menu
1032