00001
00002
00003
00004
00005
00006
00007
00009
00017 #include <iostream>
00018 #include <sstream>
00019
00020 #include "utils.h"
00021
00022 #include "menu.h"
00023 #include "audio.h"
00024 #include "video.h"
00025 #include "mode_manager.h"
00026 #include "system.h"
00027 #include "input.h"
00028 #include "global.h"
00029
00030 using namespace std;
00031
00032 using namespace hoa_utils;
00033 using namespace hoa_audio;
00034 using namespace hoa_video;
00035 using namespace hoa_system;
00036 using namespace hoa_mode_manager;
00037 using namespace hoa_input;
00038 using namespace hoa_global;
00039
00040 using namespace hoa_menu::private_menu;
00041
00042 namespace hoa_menu {
00043
00044 bool MENU_DEBUG = false;
00045
00046 MenuMode* MenuMode::_instance = NULL;
00047
00049
00051
00052 MenuMode::MenuMode(ustring locale_name, string locale_image) {
00053 if (MENU_DEBUG)
00054 cout << "MENU: MenuMode constructor invoked." << endl;
00055
00056 _locale_name = locale_name;
00057
00058
00059 _locale_graphic.SetFilename(locale_image);
00060 _locale_graphic.SetDimensions(500, 125);
00061 _locale_graphic.SetStatic(true);
00062 if (VideoManager->LoadImage(_locale_graphic) == false) {
00063 cerr << "MENU ERROR: failed to load locale graphic in MenuMode constructor: " << locale_image << endl;
00064 exit(1);
00065 }
00066
00067 if (VideoManager->CaptureScreen(_saved_screen) == false) {
00068 if (MENU_DEBUG)
00069 cerr << "MENU WARNING: Couldn't save the screen!" << endl;
00070 }
00071
00072 _current_window = WINDOW_INVENTORY;
00073
00074 GlobalParty & characters = *GlobalManager->GetActiveParty();
00075
00076
00077 switch (characters.GetPartySize()) {
00078 case 4: _character_window3.SetCharacter(dynamic_cast<GlobalCharacter*>(characters.GetActorAtIndex(3)));
00079 case 3: _character_window2.SetCharacter(dynamic_cast<GlobalCharacter*>(characters.GetActorAtIndex(2)));
00080 case 2: _character_window1.SetCharacter(dynamic_cast<GlobalCharacter*>(characters.GetActorAtIndex(1)));
00081 case 1: _character_window0.SetCharacter(dynamic_cast<GlobalCharacter*>(characters.GetActorAtIndex(0)));
00082 break;
00083 default:
00084 cerr << "MENU ERROR: no characters in party!" << endl;
00085 exit(1);
00086 }
00087
00089 uint32 start_x = (1024 - 800) / 2 - 40;
00090 uint32 start_y = (768 - 600) / 2 + 15;
00091 uint32 win_width = 208;
00092
00093
00094 _bottom_window.Create(static_cast<float>(win_width * 4 + 16), 140 + 16, VIDEO_MENU_EDGE_ALL);
00095 _bottom_window.SetPosition(static_cast<float>(start_x), static_cast<float>(start_y + 442));
00096
00097
00098
00099
00100
00101
00102 _character_window0.Create(360, 98, ~VIDEO_MENU_EDGE_BOTTOM, VIDEO_MENU_EDGE_BOTTOM);
00103 _character_window0.SetPosition(static_cast<float>(start_x), static_cast<float>(start_y + 10));
00104
00105 _character_window1.Create(360, 98, ~VIDEO_MENU_EDGE_BOTTOM, VIDEO_MENU_EDGE_BOTTOM | VIDEO_MENU_EDGE_TOP);
00106 _character_window1.SetPosition(static_cast<float>(start_x), static_cast<float>(start_y + 118));
00107
00108 _character_window2.Create(360, 98, ~VIDEO_MENU_EDGE_BOTTOM, VIDEO_MENU_EDGE_BOTTOM | VIDEO_MENU_EDGE_TOP);
00109 _character_window2.SetPosition(static_cast<float>(start_x), static_cast<float>(start_y + 226));
00110
00111 _character_window3.Create(360, 98, ~VIDEO_MENU_EDGE_BOTTOM, VIDEO_MENU_EDGE_TOP | VIDEO_MENU_EDGE_BOTTOM);
00112 _character_window3.SetPosition(static_cast<float>(start_x), static_cast<float>(start_y + 334));
00113
00114 _main_options_window.Create(static_cast<float>(win_width * 4 + 16), 60, ~VIDEO_MENU_EDGE_BOTTOM, VIDEO_MENU_EDGE_BOTTOM);
00115 _main_options_window.SetPosition(static_cast<float>(start_x), static_cast<float>(start_y - 50));
00116
00117
00118 _status_window.Create(static_cast<float>(win_width * 4 + 16), 448, VIDEO_MENU_EDGE_ALL);
00119 _status_window.SetPosition(static_cast<float>(start_x), static_cast<float>(start_y + 10));
00120
00121
00122 _skills_window.Create(static_cast<float>(win_width * 4 + 16), 448, VIDEO_MENU_EDGE_ALL);
00123 _skills_window.SetPosition(static_cast<float>(start_x), static_cast<float>(start_y + 10));
00124
00125
00126 _equip_window.Create(static_cast<float>(win_width * 4 + 16), 448, VIDEO_MENU_EDGE_ALL);
00127 _equip_window.SetPosition(static_cast<float>(start_x), static_cast<float>(start_y + 10));
00128
00129
00130 _inventory_window.Create(static_cast<float>(win_width * 4 + 16), 448, VIDEO_MENU_EDGE_ALL);
00131 _inventory_window.SetPosition(static_cast<float>(start_x), static_cast<float>(start_y + 10));
00132
00133
00134 _formation_window.Create(static_cast<float>(win_width * 4 + 16), 448, VIDEO_MENU_EDGE_ALL);
00135 _formation_window.SetPosition(static_cast<float>(start_x), static_cast<float>(start_y + 10));
00136
00137
00138
00139 _current_menu_showing = SHOW_MAIN;
00140 _current_menu = &_main_options;
00141
00142
00143 _menu_sounds["confirm"] = SoundDescriptor();
00144 _menu_sounds["confirm"].LoadSound("snd/confirm.wav");
00145 _menu_sounds["cancel"] = SoundDescriptor();
00146 _menu_sounds["cancel"].LoadSound("snd/cancel.wav");
00147 _menu_sounds["bump"] = SoundDescriptor();
00148 _menu_sounds["bump"].LoadSound("snd/bump.wav");
00149
00150 if (_instance != NULL) {
00151 if (MENU_DEBUG)
00152 cerr << "MENU WARNING: attempting to create a new instance of MenuMode when one already seems to exist" << endl;
00153 }
00154 _instance = this;
00155 }
00156
00157
00158
00159 MenuMode::~MenuMode() {
00160 if (MENU_DEBUG)
00161 cout << "MENU: MenuMode destructor invoked." << endl;
00162
00163
00164 VideoManager->DeleteImage(_saved_screen);
00165
00166
00167 VideoManager->DeleteImage(_locale_graphic);
00168
00169
00170 _bottom_window.Destroy();
00171 _character_window0.Destroy();
00172 _character_window1.Destroy();
00173 _character_window2.Destroy();
00174 _character_window3.Destroy();
00175 _inventory_window.Destroy();
00176 _status_window.Destroy();
00177 _skills_window.Destroy();
00178 _main_options_window.Destroy();
00179 _equip_window.Destroy();
00180 _formation_window.Destroy();
00181
00182
00183 _menu_sounds["confirm"].FreeSound();
00184 _menu_sounds["bump"].FreeSound();
00185 _menu_sounds["cancel"].FreeSound();
00186
00187 _instance = NULL;
00188 }
00189
00190
00191
00192 void MenuMode::Reset() {
00193
00194 VideoManager->SetCoordSys(0, 1024, 768, 0);
00195
00196 if (!VideoManager->SetFont("default")) {
00197 cerr << "MAP: ERROR > Couldn't set menu font!" << endl;
00198 exit(1);
00199 }
00200
00201
00202 _bottom_window.Show();
00203 _main_options_window.Show();
00204 _character_window0.Show();
00205 _character_window1.Show();
00206 _character_window2.Show();
00207 _character_window3.Show();
00208 _inventory_window.Show();
00209 _status_window.Show();
00210 _skills_window.Show();
00211 _equip_window.Show();
00212 _formation_window.Show();
00213
00214
00215 _SetupMainOptionBox();
00216 _SetupInventoryOptionBox();
00217 _SetupSkillsOptionBox();
00218 _SetupStatusOptionBox();
00219 _SetupOptionsOptionBox();
00220 _SetupSaveOptionBox();
00221 _SetupEquipOptionBox();
00222
00223 }
00224
00225
00226
00227 void MenuMode::_SetupOptionBoxCommonSettings(OptionBox *ob) {
00228
00229 ob->SetFont("default");
00230 ob->SetCellSize(115.0f, 50.0f);
00231 ob->SetPosition(142.0f, 85.0f);
00232 ob->SetAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER);
00233 ob->SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
00234 ob->SetSelectMode(VIDEO_SELECT_SINGLE);
00235 ob->SetHorizontalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
00236 ob->SetCursorOffset(-52.0f, -20.0f);
00237 }
00238
00239
00240
00241 void MenuMode::_SetupMainOptionBox() {
00242
00243 _SetupOptionBoxCommonSettings(&_main_options);
00244 _main_options.SetSize(MAIN_SIZE, 1);
00245
00246
00247 vector<ustring> options;
00248 options.push_back(MakeUnicodeString("Inventory"));
00249 options.push_back(MakeUnicodeString("Skills"));
00250 options.push_back(MakeUnicodeString("Equip"));
00251 options.push_back(MakeUnicodeString("Status"));
00252 options.push_back(MakeUnicodeString("Formation"));
00253 options.push_back(MakeUnicodeString("Exit"));
00254
00255
00256 _main_options.SetOptions(options);
00257 _main_options.SetSelection(MAIN_INVENTORY);
00258
00259
00260 _main_options.EnableOption(4, false);
00261 }
00262
00263
00264
00265 void MenuMode::_SetupInventoryOptionBox() {
00266
00267 _SetupOptionBoxCommonSettings(&_menu_inventory);
00268 _menu_inventory.SetSize(INV_SIZE, 1);
00269
00270
00271 vector<ustring> options;
00272 options.push_back(MakeUnicodeString("Use"));
00273 options.push_back(MakeUnicodeString("Sort"));
00274 options.push_back(MakeUnicodeString("Back"));
00275
00276
00277 _menu_inventory.SetOptions(options);
00278 _menu_inventory.SetSelection(INV_USE);
00279 }
00280
00281
00282
00283 void MenuMode::_SetupSkillsOptionBox() {
00284
00285 _SetupOptionBoxCommonSettings(&_menu_skills);
00286 _menu_skills.SetSize(SKILLS_SIZE, 1);
00287
00288
00289 vector<ustring> options;
00290 options.push_back(MakeUnicodeString("Use"));
00291 options.push_back(MakeUnicodeString("Back"));
00292
00293
00294 _menu_skills.SetOptions(options);
00295 _menu_skills.SetSelection(SKILLS_USE);
00296 }
00297
00298
00299
00300 void MenuMode::_SetupEquipOptionBox() {
00301
00302 _SetupOptionBoxCommonSettings(&_menu_equip);
00303 _menu_equip.SetCellSize(150.0f, 50.0f);
00304 _menu_equip.SetSize(EQUIP_SIZE, 1);
00305
00306
00307 vector<ustring> options;
00308 options.push_back(MakeUnicodeString("Equip"));
00309 options.push_back(MakeUnicodeString("Remove"));
00310 options.push_back(MakeUnicodeString("Back"));
00311
00312
00313 _menu_equip.SetOptions(options);
00314 _menu_equip.SetSelection(EQUIP_EQUIP);
00315
00316
00317
00318 }
00319
00320
00321
00322 void MenuMode::_SetupStatusOptionBox() {
00323
00324 _SetupOptionBoxCommonSettings(&_menu_status);
00325 _menu_status.SetSize(STATUS_SIZE, 1);
00326
00327
00328 vector<ustring> options;
00329 options.push_back(MakeUnicodeString("View"));
00330 options.push_back(MakeUnicodeString("Back"));
00331
00332
00333 _menu_status.SetOptions(options);
00334 _menu_status.SetSelection(STATUS_VIEW);
00335 }
00336
00337
00338
00339 void MenuMode::_SetupOptionsOptionBox() {
00340
00341 _SetupOptionBoxCommonSettings(&_menu_options);
00342 _menu_options.SetSize(OPTIONS_SIZE, 1);
00343
00344
00345 vector<ustring> options;
00346 options.push_back(MakeUnicodeString("Edit"));
00347 options.push_back(MakeUnicodeString("Save"));
00348 options.push_back(MakeUnicodeString("Back"));
00349
00350
00351 _menu_options.SetOptions(options);
00352 _menu_options.SetSelection(OPTIONS_EDIT);
00353 }
00354
00355
00356
00357 void MenuMode::_SetupSaveOptionBox() {
00358
00359 _SetupOptionBoxCommonSettings(&_menu_save);
00360 _menu_save.SetSize(SAVE_SIZE, 1);
00361
00362
00363 vector<ustring> options;
00364 options.push_back(MakeUnicodeString("Save"));
00365 options.push_back(MakeUnicodeString("Back"));
00366
00367
00368 _menu_save.SetOptions(options);
00369 _menu_save.SetSelection(SAVE_SAVE);
00370 }
00371
00373
00375
00376 void MenuMode::Update() {
00377
00378
00379
00380 if (_inventory_window.IsActive()) {
00381
00382 _inventory_window.Update();
00383 return;
00384 }
00385 else if (_status_window.IsActive()) {
00386
00387 _status_window.Update();
00388 return;
00389 }
00390 else if (_skills_window.IsActive()) {
00391
00392 _skills_window.Update();
00393 return;
00394 }
00395 else if (_equip_window.IsActive()) {
00396
00397 _equip_window.Update();
00398 return;
00399 }
00400
00401 if (InputManager->CancelPress()) {
00402
00403 _menu_sounds["cancel"].PlaySound();
00404
00405 if (_current_menu_showing == SHOW_MAIN)
00406 ModeManager->Pop();
00407 else {
00408 _current_menu_showing = SHOW_MAIN;
00409 _current_menu = &_main_options;
00410 }
00411 }
00412 else if (InputManager->ConfirmPress()) {
00413
00414 if (_current_menu->IsEnabled(_current_menu->GetSelection()))
00415 _menu_sounds["confirm"].PlaySound();
00416
00417 _current_menu->HandleConfirmKey();
00418 }
00419 else if (InputManager->LeftPress()) {
00420
00421 _current_menu->HandleLeftKey();
00422 }
00423 else if (InputManager->RightPress()) {
00424
00425 _current_menu->HandleRightKey();
00426 }
00427
00428
00429 int32 event = _current_menu->GetEvent();
00430
00431
00432 if (event == VIDEO_OPTION_CONFIRM) {
00433
00434 switch (_current_menu_showing) {
00435 case SHOW_MAIN:
00436 _HandleMainMenu();
00437 break;
00438
00439 case SHOW_INVENTORY:
00440 _HandleInventoryMenu();
00441 break;
00442
00443 case SHOW_SKILLS:
00444 _HandleSkillsMenu();
00445 break;
00446
00447 case SHOW_STATUS:
00448 _HandleStatusMenu();
00449 break;
00450
00451 case SHOW_EQUIP:
00452 _HandleEquipMenu();
00453 break;
00454
00455
00456
00457
00458
00459 case SHOW_SAVE:
00460 _HandleSaveMenu();
00461 break;
00462
00463 default:
00464 cerr << "MENU: ERROR: Invalid menu showing!" << endl;
00465 break;
00466 }
00467 }
00468 _current_menu->Update();
00469 }
00470
00472
00474
00475 void MenuMode::Draw() {
00476
00477
00478 int32 width = VideoManager->GetWidth();
00479 int32 height = VideoManager->GetHeight();
00480 VideoManager->SetCoordSys (0.0f, static_cast<float>(width), 0.0f, static_cast<float>(height));
00481
00482 VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_BOTTOM, 0);
00483 Color grayed(0.35f, 0.35f, 0.35f, 1.0f);
00484 VideoManager->Move(0, 0);
00485 VideoManager->DrawImage(_saved_screen);
00486
00487
00488 VideoManager->SetCoordSys (0.0f, 1024.0f, 768.0f, 0.0f);
00489
00490
00491 uint32 draw_window;
00492
00493 VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_TOP, VIDEO_BLEND, 0);
00494
00495
00496 VideoManager->Move(0,0);
00497
00498
00499 VideoManager->SetTextColor(Color(1.0f, 1.0f, 1.0f, 1.0f));
00500
00501 _main_options_window.Draw();
00502 _DrawBottomMenu();
00503
00504
00505
00506 if (_current_menu_showing == SHOW_MAIN) {
00507 draw_window = _current_menu->GetSelection() + 1;
00508 }
00509 else {
00510 draw_window = _current_menu_showing;
00511 }
00512
00513
00514 switch (draw_window) {
00515 case SHOW_MAIN:
00516 break;
00517
00518 case SHOW_INVENTORY:
00519 _inventory_window.Draw();
00520 break;
00521
00522 case SHOW_STATUS:
00523 _status_window.Draw();
00524 break;
00525
00526 case SHOW_SKILLS:
00527 _skills_window.Draw();
00528 break;
00529
00530 case SHOW_EQUIP:
00531 _equip_window.Draw();
00532 break;
00533
00534
00535
00536
00537
00538
00539 case SHOW_FORMATION:
00540 case SHOW_EXIT:
00541 _formation_window.Draw();
00542 break;
00543
00544 case SHOW_SAVE:
00545 _HandleSaveMenu();
00546 break;
00547 }
00548
00549
00550
00551
00552
00553 _character_window0.Draw();
00554 _character_window1.Draw();
00555 _character_window2.Draw();
00556 _character_window3.Draw();
00557
00558
00559 _current_menu->Draw();
00560 }
00561
00562
00563
00564 void MenuMode::_DrawBottomMenu() {
00565 _bottom_window.Draw();
00566
00567 VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_BOTTOM, 0);
00568 VideoManager->Move(150, 577);
00569
00570 if (_current_menu_showing == SHOW_INVENTORY )
00571 {
00572
00573 }
00574 else if (_current_menu_showing == SHOW_SKILLS )
00575 {
00576
00577 }
00578 else if (_current_menu_showing == SHOW_EQUIP) {
00579 GlobalActor* actor = GlobalManager->GetActiveParty()->GetActorAtIndex(0);
00580 GlobalCharacter* ch = (GlobalCharacter*)(actor);
00581 string text = "STR: " + NumberToString(ch->GetStrength());
00582 VideoManager->DrawText(MakeUnicodeString(text));
00583
00584 text = "VIG: " + NumberToString(ch->GetVigor());
00585 VideoManager->MoveRelative(0, 20);
00586 VideoManager->DrawText(MakeUnicodeString(text));
00587
00588 text = "FRT: " + NumberToString(ch->GetFortitude());
00589 VideoManager->MoveRelative(0, 20);
00590 VideoManager->DrawText(MakeUnicodeString(text));
00591
00592 text = "PRO: " + NumberToString(ch->GetProtection());
00593 VideoManager->MoveRelative(0, 20);
00594 VideoManager->DrawText(MakeUnicodeString(text));
00595
00596 text = "AGI: " + NumberToString(ch->GetAgility());
00597 VideoManager->MoveRelative(0, 20);
00598 VideoManager->DrawText(MakeUnicodeString(text));
00599
00600 text = "EVD: " + NumberToString(ch->GetEvade()) + "%";
00601 VideoManager->MoveRelative(0, 20);
00602 VideoManager->DrawText(MakeUnicodeString(text));
00603
00604 VideoManager->Move(310, 577);
00605
00606 text = "Current Equipment:";
00607 VideoManager->DrawText(MakeUnicodeString(text));
00608
00609 text = "Weapon";
00610 VideoManager->MoveRelative(0, 20);
00611 VideoManager->DrawText(MakeUnicodeString(text));
00612
00613 text = "Head";
00614 VideoManager->MoveRelative(0, 20);
00615 VideoManager->DrawText(MakeUnicodeString(text));
00616
00617 text = "Torso";
00618 VideoManager->MoveRelative(0, 20);
00619 VideoManager->DrawText(MakeUnicodeString(text));
00620
00621 text = "Arm";
00622 VideoManager->MoveRelative(0, 20);
00623 VideoManager->DrawText(MakeUnicodeString(text));
00624
00625 text = "Legs";
00626 VideoManager->MoveRelative(0, 20);
00627 VideoManager->DrawText(MakeUnicodeString(text));
00628
00629 VideoManager->Move(400, 577);
00630
00631
00632
00633 text = "PHYS ATK: " + NumberToString(ch->GetWeaponEquipped()->GetPhysicalAttack());
00634 VideoManager->MoveRelative(0, 20);
00635 VideoManager->DrawText(MakeUnicodeString(text));
00636
00637 text = "PHYS DEF: " + NumberToString(ch->GetHeadArmorEquipped()->GetPhysicalDefense());
00638 VideoManager->MoveRelative(0, 20);
00639 VideoManager->DrawText(MakeUnicodeString(text));
00640
00641 text = "PHYS DEF: " + NumberToString(ch->GetTorsoArmorEquipped()->GetPhysicalDefense());
00642 VideoManager->MoveRelative(0, 20);
00643 VideoManager->DrawText(MakeUnicodeString(text));
00644
00645 text = "PHYS DEF: " + NumberToString(ch->GetArmArmorEquipped()->GetPhysicalDefense());
00646 VideoManager->MoveRelative(0, 20);
00647 VideoManager->DrawText(MakeUnicodeString(text));
00648
00649 text = "PHYS DEF: " + NumberToString(ch->GetLegArmorEquipped()->GetPhysicalDefense());
00650 VideoManager->MoveRelative(0, 20);
00651 VideoManager->DrawText(MakeUnicodeString(text));
00652
00653 VideoManager->Move(550, 577);
00654
00655
00656
00657 text = "META ATK: " + NumberToString(ch->GetWeaponEquipped()->GetMetaphysicalAttack());
00658 VideoManager->MoveRelative(0, 20);
00659 VideoManager->DrawText(MakeUnicodeString(text));
00660
00661 text = "META DEF: " + NumberToString(ch->GetHeadArmorEquipped()->GetMetaphysicalDefense());
00662 VideoManager->MoveRelative(0, 20);
00663 VideoManager->DrawText(MakeUnicodeString(text));
00664
00665 text = "META DEF: " + NumberToString(ch->GetTorsoArmorEquipped()->GetMetaphysicalDefense());
00666 VideoManager->MoveRelative(0, 20);
00667 VideoManager->DrawText(MakeUnicodeString(text));
00668
00669 text = "META DEF: " + NumberToString(ch->GetArmArmorEquipped()->GetMetaphysicalDefense());
00670 VideoManager->MoveRelative(0, 20);
00671 VideoManager->DrawText(MakeUnicodeString(text));
00672
00673 text = "META DEF: " + NumberToString(ch->GetLegArmorEquipped()->GetMetaphysicalDefense());
00674 VideoManager->MoveRelative(0, 20);
00675 VideoManager->DrawText(MakeUnicodeString(text));
00676 VideoManager->SetDrawFlags(VIDEO_X_CENTER,VIDEO_Y_BOTTOM,0);
00677 }
00678 else {
00679
00680 VideoManager->DrawText(_locale_name);
00681
00682
00683 VideoManager->MoveRelative(-40, 60);
00684 std::ostringstream os_time;
00685 uint8 hours = SystemManager->GetPlayHours();
00686 uint8 minutes = SystemManager->GetPlayMinutes();
00687 uint8 seconds = SystemManager->GetPlaySeconds();
00688 os_time << (hours < 10 ? "0" : "") << static_cast<uint32>(hours) << ":";
00689 os_time << (minutes < 10 ? "0" : "") << static_cast<uint32>(minutes) << ":";
00690 os_time << (seconds < 10 ? "0" : "") << static_cast<uint32>(seconds);
00691
00692 std::string time = std::string("Time: ") + os_time.str();
00693 VideoManager->DrawText(MakeUnicodeString(time));
00694
00695
00696 string money = string("Drunes: " + NumberToString(GlobalManager->GetDrunes()));
00697 VideoManager->MoveRelative(0, 30);
00698 VideoManager->DrawText(MakeUnicodeString(money));
00699
00700 VideoManager->SetDrawFlags(VIDEO_X_RIGHT, VIDEO_Y_BOTTOM, 0);
00701 VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_BOTTOM, 0);
00702 VideoManager->Move(390, 685);
00703 VideoManager->DrawImage(_locale_graphic);
00704 }
00705 }
00706
00707
00708
00709
00710 void MenuMode::_HandleMainMenu() {
00711 switch (_main_options.GetSelection()) {
00712 case MAIN_INVENTORY:
00713 _current_menu_showing = SHOW_INVENTORY;
00714 _current_menu = &_menu_inventory;
00715 break;
00716
00717 case MAIN_SKILLS:
00718 _current_menu_showing = SHOW_SKILLS;
00719 _current_menu = &_menu_skills;
00720 break;
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732 case MAIN_STATUS:
00733 _current_menu_showing = SHOW_STATUS;
00734 _current_menu = &_menu_status;
00735 break;
00736
00737 case MAIN_EQUIP:
00738 _current_menu_showing = SHOW_EQUIP;
00739 _current_menu = &_menu_equip;
00740 break;
00741
00742
00743
00744
00745
00746
00747 case MAIN_EXIT:
00748 ModeManager->Pop();
00749 break;
00750
00751 default:
00752 cerr << "MENU ERROR: Invalid option in MenuMode::_HandleMainMenu()" << endl;
00753 break;
00754 }
00755 }
00756
00757
00758
00759 void MenuMode::_HandleStatusMenu() {
00760 switch (_menu_status.GetSelection()) {
00761 case STATUS_VIEW:
00762 _status_window.Activate(true);
00763 break;
00764
00765 case STATUS_BACK:
00766 _current_menu_showing = SHOW_MAIN;
00767 _current_menu = &_main_options;
00768 break;
00769
00770 default:
00771 cerr << "MENU ERROR: Invalid option in MenuMode::_HandleStatusMenu()" << endl;
00772 break;
00773 }
00774 }
00775
00776
00777
00778 void MenuMode::_HandleInventoryMenu() {
00779 switch (_menu_inventory.GetSelection()) {
00780 case INV_USE:
00781 if (GlobalManager->GetInventory()->size() == 0)
00782 return;
00783 _inventory_window.Activate(true);
00784 _current_menu->SetCursorState(VIDEO_CURSOR_STATE_BLINKING);
00785 break;
00786
00787 case INV_SORT:
00788
00789 cout << "MENU: Inventory sort command!" << endl;
00790 break;
00791
00792 case INV_BACK:
00793 _current_menu_showing = SHOW_MAIN;
00794 _current_menu = &_main_options;
00795 break;
00796
00797 default:
00798 cerr << "MENU ERROR: Invalid option in MenuMode::_HandleInventoryMenu()" << endl;
00799 break;
00800 }
00801 }
00802
00803
00804
00805 void MenuMode::_HandleSkillsMenu() {
00806 switch (_menu_skills.GetSelection()) {
00807 case SKILLS_BACK:
00808 _current_menu_showing = SHOW_MAIN;
00809 _current_menu = &_main_options;
00810 break;
00811
00812 case SKILLS_USE:
00813 _skills_window.Activate(true);
00814 _current_menu->SetCursorState(VIDEO_CURSOR_STATE_BLINKING);
00815 break;
00816
00817 default:
00818 cerr << "MENU ERROR: Invalid option in MenuMode::_HandleSkillsMenu()" << endl;
00819 break;
00820 }
00821 }
00822
00823
00824
00825 void MenuMode::_HandleEquipMenu() {
00826 switch (_menu_equip.GetSelection()) {
00827 case EQUIP_EQUIP:
00828 _equip_window.Activate(true);
00829 _current_menu->SetCursorState(VIDEO_CURSOR_STATE_BLINKING);
00830 break;
00831
00832 case EQUIP_REMOVE:
00833
00834 cout << "MENU: Remove command!" << endl;
00835 break;
00836
00837 case EQUIP_BACK:
00838 _current_menu_showing = SHOW_MAIN;
00839 _current_menu = &_main_options;
00840 break;
00841
00842 default:
00843 cerr << "MENU ERROR: Invalid option in MenuMode::_HandleEquipMenu()" << endl;
00844 break;
00845 }
00846 }
00847
00848
00849
00850 void MenuMode::_HandleOptionsMenu() {
00851 switch (_menu_options.GetSelection()) {
00852 case OPTIONS_EDIT:
00853
00854 cout << "MENU: Options - Edit command!" << endl;
00855 break;
00856
00857 case OPTIONS_SAVE:
00858
00859 cout << "MENU: Options - Save command!" << endl;
00860 break;
00861
00862 case OPTIONS_BACK:
00863 _current_menu_showing = SHOW_MAIN;
00864 _current_menu = &_main_options;
00865 break;
00866
00867 default:
00868 cerr << "MENU ERROR: Invalid option in MenuMode::_HandleOptionsMenu()" << endl;
00869 break;
00870 }
00871 }
00872
00873
00874
00875 void MenuMode::_HandleSaveMenu() {
00876 string file_name;
00877 switch (_menu_save.GetSelection()) {
00878 case SAVE_SAVE:
00879
00880 cout << "MENU: Save - Save command!" << endl;
00881 file_name = "dat/saved_game.lua";
00882 GlobalManager->SaveGame(file_name);
00883 break;
00884
00885 case SAVE_BACK:
00886 _current_menu_showing = SHOW_MAIN;
00887 _current_menu = &_main_options;
00888 break;
00889
00890 default:
00891 cerr << "MENU ERROR: Invalid option in MenuMode::_HandleSaveMenu()" << endl;
00892 }
00893 }
00894
00895 }