00001
00002
00003
00004
00005
00006
00007
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <iostream>
00018 #include <sstream>
00019
00020 #include "utils.h"
00021
00022 #include "audio.h"
00023 #include "video.h"
00024 #include "global.h"
00025 #include "input.h"
00026 #include "system.h"
00027
00028 #include "menu.h"
00029 #include "menu_views.h"
00030
00031 using namespace std;
00032 using namespace hoa_menu::private_menu;
00033 using namespace hoa_utils;
00034 using namespace hoa_audio;
00035 using namespace hoa_video;
00036 using namespace hoa_global;
00037 using namespace hoa_input;
00038 using namespace hoa_system;
00039
00040 namespace hoa_menu {
00041
00042 namespace private_menu {
00043
00044
00046
00048
00049 CharacterWindow::CharacterWindow()
00050 {
00051 _char_id = GLOBAL_CHARACTER_INVALID;
00052 }
00053
00054
00055
00056 CharacterWindow::~CharacterWindow()
00057 {
00058
00059 VideoManager->DeleteImage(_portrait);
00060 }
00061
00062
00063
00064 void CharacterWindow::SetCharacter(GlobalCharacter *character)
00065 {
00066 _char_id = character->GetID();
00067
00068 _portrait.SetFilename("img/portraits/map/" + character->GetFilename() + ".png");
00069 _portrait.SetStatic(true);
00070 _portrait.SetDimensions(100, 100);
00071 VideoManager->LoadImage(_portrait);
00072 }
00073
00074
00075
00076
00077 void CharacterWindow::Draw()
00078 {
00079
00080 MenuWindow::Draw();
00081
00082
00083 if (_char_id == hoa_global::GLOBAL_CHARACTER_INVALID)
00084
00085 return;
00086
00087 VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_TOP, 0);
00088
00089
00090 float x, y, w, h;
00091 GetPosition(x,y);
00092 GetDimensions(w,h);
00093
00094 GlobalCharacter *character = GlobalManager->GetCharacter(_char_id);
00095
00096
00097 VideoManager->Move(x + 12, y + 8);
00098 VideoManager->DrawImage(_portrait);
00099
00100
00101 VideoManager->MoveRelative(150, 0);
00102 if (!VideoManager->DrawText(character->GetName()))
00103 cerr << "CHARACTERWINDOW: ERROR > Couldn't draw Character Name!" << endl;
00104
00105
00106 VideoManager->MoveRelative(0,20);
00107 std::ostringstream os_level;
00108 os_level << character->GetExperienceLevel();
00109 std::string xp_level = std::string("Lv: ") + os_level.str();
00110 if (!VideoManager->DrawText(MakeUnicodeString(xp_level)))
00111 cerr << "CHARACTERWINDOW: ERROR: > Couldn't draw xp level" << endl;
00112
00113
00114 VideoManager->MoveRelative(0,20);
00115 ostringstream os_health;
00116 os_health << character->GetHitPoints() << " / " << character->GetMaxHitPoints();
00117 std::string health = std::string("HP: ") + os_health.str();
00118 if (!VideoManager->DrawText(MakeUnicodeString(health)))
00119 cerr << "CHARACTERWINDOW: ERROR > Couldn't draw health!" << endl;
00120
00121
00122 VideoManager->MoveRelative(0,20);
00123 ostringstream os_skill;
00124 os_skill << character->GetSkillPoints() << " / " << character->GetMaxSkillPoints();
00125 std::string skill = std::string("SP: ") + os_skill.str();
00126 if (!VideoManager->DrawText(MakeUnicodeString(skill)))
00127 cerr << "CHARACTERWINDOW: ERROR > Couldn't draw skill!" << endl;
00128
00129
00130 VideoManager->MoveRelative(0, 20);
00131 ostringstream os_xp;
00132 os_xp << character->GetExperienceForNextLevel();
00133 std::string xp = std::string("XP To Next: ") + os_xp.str();
00134 if (!VideoManager->DrawText(MakeUnicodeString(xp)))
00135 cerr << "CHARACTERWINDOW: ERROR > Couldn't draw xp!" << endl;
00136
00137 return;
00138 }
00139
00140
00142
00144
00145
00146 InventoryWindow::InventoryWindow() : _active_box(ITEM_ACTIVE_NONE)
00147 {
00148 _InitCategory();
00149 _InitInventoryItems();
00150 _InitCharSelect();
00151
00152
00153 _description.SetOwner(this);
00154 _description.SetPosition(30.0f, 525.0f);
00155 _description.SetDimensions(800.0f, 80.0f);
00156 _description.SetDisplaySpeed(30);
00157 _description.SetFont("default");
00158 _description.SetDisplayMode(VIDEO_TEXT_INSTANT);
00159 _description.SetTextAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP);
00160
00161 }
00162
00163 InventoryWindow::~InventoryWindow()
00164 {
00165 }
00166
00167
00168 void InventoryWindow::_InitInventoryItems() {
00169
00170 _inventory_items.SetCellSize(400.0f, 60.0f);
00171
00172 _inventory_items.SetPosition(500.0f, 170.0f);
00173 _inventory_items.SetFont("default");
00174 _inventory_items.SetCursorOffset(-52.0f, -20.0f);
00175 _inventory_items.SetHorizontalWrapMode(VIDEO_WRAP_MODE_SHIFTED);
00176 _inventory_items.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
00177 _inventory_items.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER);
00178 _inventory_items.TEMP_OverideScissorring(true);
00179
00180
00181 _UpdateItemText();
00182 _inventory_items.SetSelection(0);
00183 VideoManager->MoveRelative(-65, 20);
00184
00185 _inventory_items.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00186 }
00187
00188
00189 void InventoryWindow::_InitCharSelect() {
00190
00191 vector<ustring> options;
00192 uint32 size = GlobalManager->GetActiveParty()->GetPartySize();
00193
00194 _char_select.SetCursorOffset(-50.0f, -6.0f);
00195 _char_select.SetFont("default");
00196 _char_select.SetHorizontalWrapMode(VIDEO_WRAP_MODE_SHIFTED);
00197 _char_select.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
00198 _char_select.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER);
00199 _char_select.SetSize(1, ((size >= 4) ? 4 : size));
00200 _char_select.SetSize(1, 4);
00201 _char_select.SetCellSize(360, 108);
00202 _char_select.SetPosition(72.0f, 109.0f);
00203
00204
00205
00206 for (uint32 i = 0; i < size; i++) {
00207 options.push_back(MakeUnicodeString(" "));
00208 }
00209
00210 _char_select.SetOptions(options);
00211 _char_select.SetSelection(0);
00212 _char_select.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00213 }
00214
00215
00216 void InventoryWindow::_InitCategory() {
00217 _item_categories.SetCellSize(85.0f,30.0f);
00218 _item_categories.SetPosition(458.0f, 120.0f);
00219 _item_categories.SetFont("default");
00220 _item_categories.SetSize(ITEM_CATEGORY_SIZE,1);
00221
00222 _item_categories.SetCursorOffset(-52.0f, -20.0f);
00223 _item_categories.SetHorizontalWrapMode(VIDEO_WRAP_MODE_SHIFTED);
00224 _item_categories.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
00225 _item_categories.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
00226
00227 vector<ustring> options;
00228 options.push_back(MakeUnicodeString("All"));
00229 options.push_back(MakeUnicodeString("Field"));
00230 options.push_back(MakeUnicodeString("Battle"));
00231 options.push_back(MakeUnicodeString("Gear"));
00232 options.push_back(MakeUnicodeString("Key"));
00233
00234 _item_categories.SetOptions(options);
00235 _item_categories.SetSelection(ITEM_ALL);
00236 _item_categories.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00237
00238
00239
00240 }
00241
00242
00243 void InventoryWindow::Activate(bool new_status)
00244 {
00245
00246 if (_inventory_items.GetNumberOptions() > 0 && new_status) {
00247 _active_box = ITEM_ACTIVE_CATEGORY;
00248
00249 _item_categories.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
00250 }
00251 else {
00252
00253 _active_box = ITEM_ACTIVE_NONE;
00254 _item_categories.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00255 }
00256 }
00257
00258
00259 void InventoryWindow::Update() {
00260
00261
00262 if ( GlobalManager->GetInventory()->size() == 0 )
00263 {
00264
00265 Activate(false);
00266 return;
00267 }
00268
00269
00270 OptionBox *active_option = NULL;
00271
00272 _inventory_items.Update( SystemManager->GetUpdateTime() );
00273
00274 switch (_active_box) {
00275 case ITEM_ACTIVE_CATEGORY:
00276 active_option = &_item_categories;
00277 break;
00278 case ITEM_ACTIVE_CHAR:
00279 active_option = &_char_select;
00280 break;
00281 case ITEM_ACTIVE_LIST:
00282 active_option = &_inventory_items;
00283 break;
00284 }
00285
00286
00287 if (InputManager->ConfirmPress())
00288 {
00289 active_option->HandleConfirmKey();
00290 }
00291 else if (InputManager->CancelPress())
00292 {
00293 active_option->HandleCancelKey();
00294 }
00295 else if (InputManager->LeftPress())
00296 {
00297 active_option->HandleLeftKey();
00298 }
00299 else if (InputManager->RightPress())
00300 {
00301 active_option->HandleRightKey();
00302 }
00303 else if (InputManager->UpPress())
00304 {
00305 active_option->HandleUpKey();
00306 }
00307 else if (InputManager->DownPress())
00308 {
00309 active_option->HandleDownKey();
00310 }
00311
00312 uint32 event = active_option->GetEvent();
00313 active_option->Update();
00314
00315 switch (_active_box) {
00316 case ITEM_ACTIVE_NONE: break;
00317
00318 case ITEM_ACTIVE_CATEGORY:
00319 {
00320
00321 if (event == VIDEO_OPTION_CONFIRM) {
00322 if (_inventory_items.GetNumberOptions() > 0) {
00323 _inventory_items.SetSelection(0);
00324 _item_categories.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00325 _inventory_items.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
00326 _description.SetDisplayText( _item_objects[ 0 ]->GetDescription() );
00327 _active_box = ITEM_ACTIVE_LIST;
00328 MenuMode::_instance->_menu_sounds["confirm"].PlaySound();
00329 }
00330 }
00331
00332 else if (event == VIDEO_OPTION_CANCEL) {
00333 MenuMode::_instance->_menu_sounds["cancel"].PlaySound();
00334 _item_categories.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00335 Activate(false);
00336 }
00337 }
00338 break;
00339
00340 case ITEM_ACTIVE_LIST:
00341 {
00342
00343 if (event == VIDEO_OPTION_CONFIRM) {
00344 _active_box = ITEM_ACTIVE_CHAR;
00345 _inventory_items.SetCursorState(VIDEO_CURSOR_STATE_BLINKING);
00346 _char_select.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
00347 MenuMode::_instance->_menu_sounds["confirm"].PlaySound();
00348 }
00349
00350 else if (event == VIDEO_OPTION_CANCEL) {
00351 _active_box = ITEM_ACTIVE_CATEGORY;
00352 MenuMode::_instance->_menu_sounds["cancel"].PlaySound();
00353 _inventory_items.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00354 _item_categories.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
00355 }
00356 else if ( event == VIDEO_OPTION_BOUNDS_UP || VIDEO_OPTION_BOUNDS_DOWN )
00357 {
00358 _description.SetDisplayText( _item_objects[ _inventory_items.GetSelection() ]->GetDescription() );
00359 }
00360 }
00361 break;
00362
00363 case ITEM_ACTIVE_CHAR:
00364 {
00365
00366 if (event == VIDEO_OPTION_CONFIRM) {
00367 GlobalObject* obj = _item_objects[ _inventory_items.GetSelection() ];
00368 GlobalCharacter *ch = dynamic_cast<GlobalCharacter*>(GlobalManager->GetActiveParty()->GetActorAtIndex(_char_select.GetSelection()));
00369 if (obj->GetObjectType() == GLOBAL_OBJECT_ITEM) {
00370 GlobalItem *item = (GlobalItem*)obj;
00371 item->MenuUse(ch);
00372 item->DecrementCount(1);
00373 if (item->GetCount() <= 0) {
00374 GlobalManager->RemoveFromInventory(item->GetID());
00375 }
00376 }
00377
00378 }
00379
00380 else if (event == VIDEO_OPTION_CANCEL) {
00381 _active_box = ITEM_ACTIVE_LIST;
00382 _inventory_items.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
00383 _char_select.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00384 MenuMode::_instance->_menu_sounds["cancel"].PlaySound();
00385 }
00386 }
00387 break;
00388 }
00389
00390
00391 _UpdateItemText();
00392 }
00393
00394
00395 void InventoryWindow::_UpdateItemText()
00396 {
00397
00398 std::map<uint32, GlobalObject*>* inv = GlobalManager->GetInventory();
00399 std::vector<GlobalItem*>* invItems = GlobalManager->GetInventoryItems();
00400 std::vector<GlobalWeapon*>* invWeapons = GlobalManager->GetInventoryWeapons();
00401 std::vector<GlobalArmor*>* invArmor;
00402 std::vector<GlobalKeyItem*>* invKeyItems = GlobalManager->GetInventoryKeyItems();
00403
00404
00405
00406 std::vector<ustring> inv_names;
00407
00408 std::map<uint32, GlobalObject*>::iterator i;
00409 std::vector<GlobalItem*>::iterator i_item;
00410 std::vector<GlobalWeapon*>::iterator i_weapon;
00411 std::vector<GlobalArmor*>::iterator i_armor;
00412 std::vector<GlobalKeyItem*>::iterator i_key;
00413
00414
00415 GlobalObject* obj;
00416 GlobalItem* item;
00417 GlobalWeapon* weapon;
00418 GlobalArmor* armor;
00419 GlobalKeyItem* key_item;
00420
00421 _item_objects.clear();
00422
00423
00424 string text;
00425
00426
00427 switch (_item_categories.GetSelection()) {
00428
00429
00430 case ITEM_ALL:
00431 for (i = inv->begin(); i != inv->end(); i++) {
00432 obj = i->second;
00433 text = "<" + obj->GetIconImage().GetFilename() + "><32> " + MakeStandardString(obj->GetName()) + "<R><350>" + NumberToString(obj->GetCount()) + " ";
00434 inv_names.push_back(MakeUnicodeString(text));
00435 _item_objects.push_back( obj );
00436 }
00437 break;
00438
00439
00440
00441 case ITEM_FIELD:
00442 for (i_item = invItems->begin(); i_item != invItems->end(); i_item++) {
00443 item = *i_item;
00444 if( item->GetUsage() == GLOBAL_USE_MENU || item->GetUsage() == GLOBAL_USE_ALL ) {
00445 text = "<" + item->GetIconImage().GetFilename() + "><32> " + MakeStandardString(item->GetName()) + "<R><350>" + NumberToString(item->GetCount()) + " ";
00446 inv_names.push_back(MakeUnicodeString(text));
00447 _item_objects.push_back( item );
00448 }
00449 }
00450 break;
00451
00452
00453 case ITEM_BATTLE:
00454 for (i_item = invItems->begin(); i_item != invItems->end(); i_item++) {
00455 item = *i_item;
00456 if( item->GetUsage() == GLOBAL_USE_BATTLE ) {
00457 text = "<" + item->GetIconImage().GetFilename() + "><32> " + MakeStandardString(item->GetName()) + "<R><350>" + NumberToString(item->GetCount()) + " ";
00458 inv_names.push_back(MakeUnicodeString(text));
00459 _item_objects.push_back( item );
00460 }
00461 }
00462 break;
00463
00464
00465 case ITEM_EQUIPMENT:
00466 for (i_weapon = invWeapons->begin(); i_weapon != invWeapons->end(); i_weapon++) {
00467 weapon = *i_weapon;
00468 text = "<" + weapon->GetIconImage().GetFilename() + "><32> " + MakeStandardString(weapon->GetName()) + "<R><350>" + NumberToString(weapon->GetCount()) + " ";
00469 inv_names.push_back(MakeUnicodeString(text));
00470 _item_objects.push_back( weapon );
00471 }
00472
00473 invArmor = GlobalManager->GetInventoryHeadArmor();
00474 for (i_armor = invArmor->begin(); i_armor != invArmor->end(); i_armor++) {
00475 armor = *i_armor;
00476 text = "<" + armor->GetIconImage().GetFilename() + "><32> " + MakeStandardString(armor->GetName()) + "<R><350>" + NumberToString(armor->GetCount()) + " ";
00477 inv_names.push_back(MakeUnicodeString(text));
00478 _item_objects.push_back( armor );
00479 }
00480
00481 invArmor = GlobalManager->GetInventoryTorsoArmor();
00482 for (i_armor = invArmor->begin(); i_armor != invArmor->end(); i_armor++) {
00483 armor = *i_armor;
00484 text = "<" + armor->GetIconImage().GetFilename() + "><32> " + MakeStandardString(armor->GetName()) + "<R><350>" + NumberToString(armor->GetCount()) + " ";
00485 inv_names.push_back(MakeUnicodeString(text));
00486 _item_objects.push_back( armor );
00487 }
00488
00489 invArmor = GlobalManager->GetInventoryArmArmor();
00490 for (i_armor = invArmor->begin(); i_armor != invArmor->end(); i_armor++) {
00491 armor = *i_armor;
00492 text = "<" + armor->GetIconImage().GetFilename() + "><32> " + MakeStandardString(armor->GetName()) + "<R><350>" + NumberToString(armor->GetCount()) + " ";
00493 inv_names.push_back(MakeUnicodeString(text));
00494 _item_objects.push_back( armor );
00495 }
00496
00497 invArmor = GlobalManager->GetInventoryLegArmor();
00498 for (i_armor = invArmor->begin(); i_armor != invArmor->end(); i_armor++) {
00499 armor = *i_armor;
00500 text = "<" + armor->GetIconImage().GetFilename() + "><32> " + MakeStandardString(armor->GetName()) + "<R><350>" + NumberToString(armor->GetCount()) + " ";
00501 inv_names.push_back(MakeUnicodeString(text));
00502 _item_objects.push_back( armor );
00503 }
00504
00505 break;
00506
00507 case ITEM_KEY:
00508 for (i_key = invKeyItems->begin(); i_key != invKeyItems->end(); i_key++) {
00509 key_item = *i_key;
00510 text = "<" + key_item->GetIconImage().GetFilename() + "><32> " + MakeStandardString(key_item->GetName()) + "<R><350>" + NumberToString(key_item->GetCount()) + " ";
00511 inv_names.push_back(MakeUnicodeString(text));
00512 _item_objects.push_back( key_item );
00513 }
00514 break;
00515 }
00516
00517 _inventory_items.SetSize(1,6);
00518 _inventory_items.SetOptions(inv_names);
00519 }
00520
00521
00522
00523 void InventoryWindow::Draw()
00524 {
00525 MenuWindow::Draw();
00526
00527
00528 if (_active_box == ITEM_ACTIVE_LIST) {
00529 GlobalObject* obj = _item_objects[ _inventory_items.GetSelection() ];
00530
00531 VideoManager->SetDrawFlags(VIDEO_X_LEFT,VIDEO_Y_CENTER,0);
00532
00533 VideoManager->Move(100, 600);
00534 VideoManager->DrawImage(obj->GetIconImage() );
00535 VideoManager->MoveRelative(65, 0);
00536 VideoManager->DrawText(obj->GetName());
00537 VideoManager->SetDrawFlags(VIDEO_X_LEFT,VIDEO_Y_BOTTOM,0);
00538 _description.Draw();
00539 }
00540
00541
00542 _UpdateItemText();
00543
00544
00545 _char_select.Draw();
00546
00547
00548 _item_categories.Draw();
00549
00550
00551 _inventory_items.Draw();
00552
00553 return;
00554 }
00555
00556
00558
00560
00561 StatusWindow::StatusWindow() : _char_select_active(false) {
00562
00563 uint32 partysize = GlobalManager->GetActiveParty()->GetPartySize();
00564 StillImage portrait;
00565
00566 GlobalCharacter* ch;
00567
00568
00569 for (uint32 i = 0; i < partysize; i++) {
00570 ch = dynamic_cast<GlobalCharacter*>(GlobalManager->GetActiveParty()->GetActorAtIndex(i));
00571 portrait.SetFilename("img/portraits/menu/" + ch->GetFilename() + "_large.png");
00572 portrait.SetStatic(true);
00573 portrait.SetDimensions(150, 350);
00574 VideoManager->LoadImage(portrait);
00575 _full_portraits.push_back(portrait);
00576 }
00577
00578
00579 _InitCharSelect();
00580
00581 _current_char = dynamic_cast<GlobalCharacter*>(GlobalManager->GetActiveParty()->GetActorAtIndex(_char_select.GetSelection()));
00582 }
00583
00584
00585
00586 StatusWindow::~StatusWindow() {
00587 uint32 partysize = GlobalManager->GetActiveParty()->GetPartySize();
00588
00589 for (uint32 i = 0; i < partysize; i++) {
00590 VideoManager->DeleteImage(_full_portraits[i]);
00591 }
00592 }
00593
00594
00595 void StatusWindow::Activate(bool new_value) {
00596 _char_select_active = new_value;
00597
00598 if (_char_select_active)
00599 _char_select.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
00600 else
00601 _char_select.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00602 }
00603
00604 void StatusWindow::_InitCharSelect() {
00605
00606 vector<ustring> options;
00607 uint32 size = GlobalManager->GetActiveParty()->GetPartySize();
00608
00609 _char_select.SetCursorOffset(-50.0f, -6.0f);
00610 _char_select.SetFont("default");
00611 _char_select.SetHorizontalWrapMode(VIDEO_WRAP_MODE_SHIFTED);
00612 _char_select.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
00613 _char_select.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER);
00614 _char_select.SetSize(1, ((size >= 4) ? 4 : size));
00615 _char_select.SetCellSize(360, 108);
00616 _char_select.SetPosition(72.0f, 109.0f);
00617
00618
00619 for (uint32 i = 0; i < size; i++) {
00620 options.push_back(MakeUnicodeString(" "));
00621 }
00622
00623 _char_select.SetOptions(options);
00624 _char_select.SetSelection(0);
00625 _char_select.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00626 }
00627
00628
00629 void StatusWindow::Update() {
00630 _current_char = dynamic_cast<GlobalCharacter*>(GlobalManager->GetActiveParty()->GetActorAtIndex(_char_select.GetSelection()));
00631
00632
00633 if (InputManager->UpPress())
00634 {
00635 _char_select.HandleUpKey();
00636 }
00637 else if (InputManager->DownPress())
00638 {
00639 _char_select.HandleDownKey();
00640 }
00641 else if (InputManager->CancelPress())
00642 {
00643 _char_select.HandleCancelKey();
00644 }
00645
00646 if (_char_select.GetEvent() == VIDEO_OPTION_CANCEL) {
00647 Activate(false);
00648 MenuMode::_instance->_menu_sounds["cancel"].PlaySound();
00649 }
00650 _char_select.Update();
00651 _current_char = dynamic_cast<GlobalCharacter*>(GlobalManager->GetActiveParty()->GetActorAtIndex(_char_select.GetSelection()));
00652
00653 }
00654
00655
00656
00657 void StatusWindow::Draw() {
00658 MenuWindow::Draw();
00659
00660
00661 VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_TOP, VIDEO_BLEND, 0);
00662
00663
00664 VideoManager->Move(565, 130);
00665
00666
00667 VideoManager->SetDrawFlags(VIDEO_X_CENTER, 0);
00668 VideoManager->DrawText(_current_char->GetName());
00669
00670 VideoManager->MoveRelative(0, 25);
00671 ostringstream lvl;
00672 lvl << "Experience Level: " << _current_char->GetExperienceLevel();
00673 VideoManager->DrawText(MakeUnicodeString(lvl.str()));
00674
00675 VideoManager->SetDrawFlags(VIDEO_X_LEFT, 0);
00676
00677
00678 VideoManager->MoveRelative(-55, 60);
00679
00680 ostringstream ohp;
00681 ohp << "HP: " << _current_char->GetHitPoints() << " (" << _current_char->GetMaxHitPoints() << ")";
00682 VideoManager->DrawText(MakeUnicodeString(ohp.str()));
00683
00684 VideoManager->MoveRelative(0, 25);
00685 ostringstream osp;
00686 osp << "SP: " << _current_char->GetSkillPoints() << " (" << _current_char->GetMaxSkillPoints() << ")";
00687 VideoManager->DrawText(MakeUnicodeString(osp.str()));
00688
00689 VideoManager->MoveRelative(0, 25);
00690 ostringstream next;
00691 next << "XP to Next: " << _current_char->GetExperienceForNextLevel();
00692 VideoManager->DrawText(MakeUnicodeString(next.str()));
00693
00694 VideoManager->MoveRelative(0, 25);
00695 ostringstream ostr;
00696 ostr << "Strength: " << _current_char->GetStrength();
00697 VideoManager->DrawText(MakeUnicodeString(ostr.str()));
00698
00699 VideoManager->MoveRelative(0, 25);
00700 ostringstream ovig;
00701 ovig << "Vigor: " << _current_char->GetVigor();
00702 VideoManager->DrawText(MakeUnicodeString(ovig.str()));
00703
00704 VideoManager->MoveRelative(0, 25);
00705 ostringstream ofort;
00706 ofort << "XP to Next: " << _current_char->GetFortitude();
00707 VideoManager->DrawText(MakeUnicodeString(ofort.str()));
00708
00709 VideoManager->MoveRelative(0, 25);
00710 ostringstream ores;
00711 ores << "Protection: " << _current_char->GetProtection();
00712 VideoManager->DrawText(MakeUnicodeString(ores.str()));
00713
00714 VideoManager->MoveRelative(0, 25);
00715 ostringstream agl;
00716 agl << "Agility: " << _current_char->GetAgility();
00717 VideoManager->DrawText(MakeUnicodeString(agl.str()));
00718
00719 VideoManager->MoveRelative(0, 25);
00720 ostringstream oeva;
00721 oeva << "Evade: " << _current_char->GetEvade() << "%";
00722 VideoManager->DrawText(MakeUnicodeString(oeva.str()));
00723
00724
00725 VideoManager->Move(735, 145);
00726
00727 VideoManager->DrawImage(_full_portraits[_char_select.GetSelection()]);
00728
00729 _char_select.Draw();
00730 }
00731
00733
00735
00736 SkillsWindow::SkillsWindow() : _active_box(SKILL_ACTIVE_NONE) {
00737
00738 _InitCharSelect();
00739 _InitSkillsList();
00740 _InitSkillsCategories();
00741
00742 _description.SetOwner(this);
00743 _description.SetPosition(30.0f, 525.0f);
00744 _description.SetDimensions(800.0f, 80.0f);
00745 _description.SetDisplaySpeed(30);
00746 _description.SetFont("default");
00747 _description.SetDisplayMode(VIDEO_TEXT_INSTANT);
00748 _description.SetTextAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP);
00749
00750 }
00751
00752
00753
00754 void SkillsWindow::Activate(bool new_status) {
00755
00756 if (new_status) {
00757 _char_select.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
00758 _active_box = SKILL_ACTIVE_CHAR;
00759 }
00760 else {
00761 _char_select.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00762 _active_box = SKILL_ACTIVE_NONE;
00763 }
00764 }
00765
00766
00767
00768 void SkillsWindow::_InitSkillsList() {
00769
00770 _skills_list.SetCellSize(180.0f, 30.0f);
00771 _skills_list.SetPosition(500.0f, 170.0f);
00772 _skills_list.SetFont("default");
00773 _skills_list.SetCursorOffset(-52.0f, -20.0f);
00774 _skills_list.SetHorizontalWrapMode(VIDEO_WRAP_MODE_SHIFTED);
00775 _skills_list.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
00776 _skills_list.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER);
00777
00778 _UpdateSkillList();
00779 _skills_list.SetSelection(0);
00780 _skills_list.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00781 }
00782
00783
00784
00785 void SkillsWindow::_InitCharSelect() {
00786
00787 vector<ustring> options;
00788 uint32 size = GlobalManager->GetActiveParty()->GetPartySize();
00789
00790 _char_select.SetCursorOffset(-50.0f, -6.0f);
00791 _char_select.SetFont("default");
00792 _char_select.SetHorizontalWrapMode(VIDEO_WRAP_MODE_SHIFTED);
00793 _char_select.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
00794 _char_select.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER);
00795 _char_select.SetSize(1, ((size >= 4) ? 4 : size));
00796 _char_select.SetCellSize(360, 108);
00797 _char_select.SetPosition(72.0f, 109.0f);
00798
00799
00800 for (uint32 i = 0; i < size; i++) {
00801 options.push_back(MakeUnicodeString(" "));
00802 }
00803
00804
00805 _char_select.SetOptions(options);
00806 _char_select.SetSelection(0);
00807 _char_select.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00808 }
00809
00810
00811
00812 void SkillsWindow::_InitSkillsCategories() {
00813 _skills_categories.SetCellSize(105.0f,30.0f);
00814 _skills_categories.SetPosition(510.0f, 120.0f);
00815 _skills_categories.SetFont("default");
00816 _skills_categories.SetSize(SKILL_CATEGORY_SIZE,1);
00817 _skills_categories.SetCursorOffset(-52.0f, -20.0f);
00818 _skills_categories.SetHorizontalWrapMode(VIDEO_WRAP_MODE_SHIFTED);
00819 _skills_categories.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
00820 _skills_categories.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
00821
00822
00823 vector<ustring> options;
00824 options.push_back(MakeUnicodeString("All"));
00825 options.push_back(MakeUnicodeString("Field"));
00826 options.push_back(MakeUnicodeString("Battle"));
00827
00828
00829 _skills_categories.SetOptions(options);
00830 _skills_categories.SetSelection(SKILL_ALL);
00831 _skills_categories.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00832 }
00833
00834
00835
00836 void SkillsWindow::Update() {
00837 OptionBox *active_option = NULL;
00838
00839
00840 switch (_active_box) {
00841 case SKILL_ACTIVE_CATEGORY:
00842 active_option = &_skills_categories;
00843 break;
00844 case SKILL_ACTIVE_CHAR_APPLY:
00845 case SKILL_ACTIVE_CHAR:
00846 active_option = &_char_select;
00847 break;
00848 case SKILL_ACTIVE_LIST:
00849 active_option = &_skills_list;
00850 break;
00851 }
00852
00853
00854 if (InputManager->ConfirmPress())
00855 {
00856 active_option->HandleConfirmKey();
00857 }
00858 else if (InputManager->CancelPress())
00859 {
00860 active_option->HandleCancelKey();
00861 }
00862 else if (InputManager->LeftPress())
00863 {
00864 active_option->HandleLeftKey();
00865 }
00866 else if (InputManager->RightPress())
00867 {
00868 active_option->HandleRightKey();
00869 }
00870 else if (InputManager->UpPress())
00871 {
00872 active_option->HandleUpKey();
00873 }
00874 else if (InputManager->DownPress())
00875 {
00876 active_option->HandleDownKey();
00877 }
00878
00879 uint32 event = active_option->GetEvent();
00880 active_option->Update();
00881 switch (_active_box) {
00882 case SKILL_ACTIVE_CHAR_APPLY:
00883
00884 if (event == VIDEO_OPTION_CONFIRM) {
00885
00886 MenuMode::_instance->_menu_sounds["confirm"].PlaySound();
00887 }
00888 else if (event == VIDEO_OPTION_CANCEL) {
00889 _active_box = SKILL_ACTIVE_LIST;
00890 _skills_list.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
00891 _char_select.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00892 MenuMode::_instance->_menu_sounds["cancel"].PlaySound();
00893 }
00894 break;
00895
00896 case SKILL_ACTIVE_CHAR:
00897
00898 if (event == VIDEO_OPTION_CONFIRM) {
00899 _active_box = SKILL_ACTIVE_CATEGORY;
00900 _char_select.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00901 _skills_categories.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
00902 _char_skillset = _char_select.GetSelection();
00903 MenuMode::_instance->_menu_sounds["confirm"].PlaySound();
00904 }
00905 else if (event == VIDEO_OPTION_CANCEL) {
00906 Activate(false);
00907 _char_select.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00908 MenuMode::_instance->_menu_sounds["cancel"].PlaySound();
00909 }
00910 break;
00911
00912 case SKILL_ACTIVE_LIST:
00913
00914 if (event == VIDEO_OPTION_CONFIRM) {
00915
00916
00917
00918
00919 MenuMode::_instance->_menu_sounds["cancel"].PlaySound();
00920 }
00921 else if (event == VIDEO_OPTION_CANCEL) {
00922 _active_box = SKILL_ACTIVE_CATEGORY;
00923 MenuMode::_instance->_menu_sounds["cancel"].PlaySound();
00924 _skills_list.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00925 _skills_categories.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
00926 }
00927 break;
00928
00929 case SKILL_ACTIVE_CATEGORY:
00930
00931 if (event == VIDEO_OPTION_CONFIRM) {
00932 _skills_list.SetSelection(0);
00933 if (_skills_list.GetNumberOptions() > 0) {
00934 _active_box = SKILL_ACTIVE_LIST;
00935 _skills_categories.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00936 _skills_list.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
00937 MenuMode::_instance->_menu_sounds["confirm"].PlaySound();
00938 }
00939 else {
00940 MenuMode::_instance->_menu_sounds["cancel"].PlaySound();
00941 }
00942 }
00943 else if (event == VIDEO_OPTION_CANCEL) {
00944 _active_box = SKILL_ACTIVE_CHAR;
00945 MenuMode::_instance->_menu_sounds["cancel"].PlaySound();
00946 _skills_categories.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00947 _char_select.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
00948 _char_select.SetSelection(_char_skillset);
00949 }
00950 break;
00951 }
00952
00953 _UpdateSkillList();
00954
00955 if (_skills_list.GetNumberOptions() > 0 &&
00956 _skills_list.GetSelection() >= 0 &&
00957 _skills_list.GetNumberOptions() > _skills_list.GetSelection()) {
00958 GlobalCharacter* ch = dynamic_cast<GlobalCharacter*>(GlobalManager->GetActiveParty()->GetActorAtIndex(_char_select.GetSelection()));
00959 std::vector<hoa_global::GlobalSkill*>* skills = ch->GetAttackSkills();
00960 GlobalSkill* skill = skills->at(_skills_list.GetSelection());
00961 _description.SetDisplayText( skill->GetDescription() );
00962 }
00963 }
00964
00965
00966
00967 void SkillsWindow::_UpdateSkillList() {
00968 GlobalCharacter* ch = dynamic_cast<GlobalCharacter*>(GlobalManager->GetActiveParty()->GetActorAtIndex(_char_select.GetSelection()));
00969 std::vector<ustring> options;
00970
00971
00972 std::vector<hoa_global::GlobalSkill*>* skills = ch->GetAttackSkills();
00973 uint32 skillsize = skills->size();
00974
00975 string tempstr = "";
00976
00977 switch (_skills_categories.GetSelection()) {
00978 case SKILL_ALL:
00979 case SKILL_BATTLE:
00980 _skills_list.SetSize(1,skillsize);
00981
00982 for (uint32 i = 0; i < skillsize; i++) {
00983 tempstr = MakeStandardString(skills->at(i)->GetName()) + " " + NumberToString(skills->at(i)->GetSPRequired()) + " SP";
00984 options.push_back(MakeUnicodeString(tempstr));
00985 }
00986 break;
00987
00988 case SKILL_FIELD:
00989 default:
00990 _skills_list.SetSize(1,0);
00991 }
00992
00993 _skills_list.SetOptions(options);
00994 }
00995
00996
00997
00998 void SkillsWindow::Draw() {
00999 MenuWindow::Draw();
01000
01001
01002 if (_active_box == SKILL_ACTIVE_LIST) {
01003 GlobalCharacter* ch = dynamic_cast<GlobalCharacter*>(GlobalManager->GetActiveParty()->GetActorAtIndex(_char_select.GetSelection()));
01004 std::vector<ustring> options;
01005 std::vector<hoa_global::GlobalSkill*>* skills = ch->GetAttackSkills();
01006 GlobalSkill* skill = skills->at(_skills_list.GetSelection());
01007
01008 VideoManager->SetDrawFlags(VIDEO_X_LEFT,VIDEO_Y_CENTER,0);
01009
01010 VideoManager->Move(100, 600);
01011 VideoManager->MoveRelative(65, 0);
01012 VideoManager->DrawText(skill->GetName());
01013 VideoManager->SetDrawFlags(VIDEO_X_LEFT,VIDEO_Y_BOTTOM,0);
01014 _description.Draw();
01015 }
01016
01017
01018 _char_select.Draw();
01019 _skills_categories.Draw();
01020 _skills_list.Draw();
01021 }
01022
01024
01026
01027 EquipWindow::EquipWindow() : _active_box(EQUIP_ACTIVE_NONE) {
01028
01029 _InitCharSelect();
01030 _InitEquipmentSelect();
01031 _InitEquipmentList();
01032
01033 StillImage i;
01034 GlobalActor* actor = GlobalManager->GetActiveParty()->GetActorAtIndex(_char_select.GetSelection());
01035 GlobalCharacter* ch = (GlobalCharacter*)(actor);
01036
01037 i.SetFilename(ch->GetWeaponEquipped()->GetIconImage().GetFilename());
01038 _equip_images.push_back(i);
01039
01040 i.SetFilename(ch->GetHeadArmorEquipped()->GetIconImage().GetFilename());
01041 _equip_images.push_back(i);
01042
01043 i.SetFilename(ch->GetTorsoArmorEquipped()->GetIconImage().GetFilename());
01044 _equip_images.push_back(i);
01045
01046 i.SetFilename(ch->GetArmArmorEquipped()->GetIconImage().GetFilename());
01047 _equip_images.push_back(i);
01048
01049 i.SetFilename(ch->GetLegArmorEquipped()->GetIconImage().GetFilename());
01050 _equip_images.push_back(i);
01051
01052 for (uint32 i = 0; i < EQUIP_CATEGORY_SIZE; i++) {
01053 _equip_images[i].SetDimensions(60, 60);
01054 VideoManager->LoadImage(_equip_images[i]);
01055 }
01056
01057 }
01058
01059
01060
01061 EquipWindow::~EquipWindow() {
01062 for (uint32 i = 0; i < EQUIP_CATEGORY_SIZE; i++) {
01063 VideoManager->DeleteImage(_equip_images[i]);
01064 }
01065 }
01066
01067
01068
01069 void EquipWindow::Activate(bool new_status) {
01070
01071
01072 if (new_status) {
01073 _active_box = EQUIP_ACTIVE_CHAR;
01074 _char_select.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
01075 }
01076 else {
01077 _active_box = EQUIP_ACTIVE_NONE;
01078 _char_select.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
01079 }
01080 }
01081
01082
01083
01084 void EquipWindow::_InitEquipmentList() {
01085
01086 _equip_list.SetCellSize(180.0f, 30.0f);
01087
01088 _equip_list.SetPosition(500.0f, 170.0f);
01089 _equip_list.SetFont("default");
01090
01091 _equip_list.SetCursorOffset(-52.0f, -20.0f);
01092 _equip_list.SetHorizontalWrapMode(VIDEO_WRAP_MODE_SHIFTED);
01093 _equip_list.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
01094 _equip_list.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER);
01095
01096 _UpdateEquipList();
01097 _equip_list.SetSelection(0);
01098
01099 _equip_list.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
01100 }
01101
01102
01103
01104 void EquipWindow::_InitCharSelect() {
01105
01106 vector<ustring> options;
01107 uint32 size = GlobalManager->GetActiveParty()->GetPartySize();
01108
01109 _char_select.SetCursorOffset(-50.0f, -6.0f);
01110 _char_select.SetFont("default");
01111 _char_select.SetHorizontalWrapMode(VIDEO_WRAP_MODE_SHIFTED);
01112 _char_select.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
01113 _char_select.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER);
01114 _char_select.SetSize(1, ((size >= 4) ? 4 : size));
01115
01116 _char_select.SetCellSize(360, 108);
01117 _char_select.SetPosition(72.0f, 109.0f);
01118
01119
01120 for (uint32 i = 0; i < size; i++) {
01121 options.push_back(MakeUnicodeString(" "));
01122 }
01123
01124
01125 _char_select.SetOptions(options);
01126 _char_select.SetSelection(0);
01127 _char_select.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
01128
01129 }
01130
01131
01132
01133 void EquipWindow::_InitEquipmentSelect() {
01134
01135 _equip_select.SetCellSize(105.0f,70.0f);
01136 _equip_select.SetPosition(680.0f, 145.0f);
01137 _equip_select.SetFont("default");
01138 _equip_select.SetSize(1,EQUIP_CATEGORY_SIZE);
01139
01140 _equip_select.SetCursorOffset(-132.0f, -20.0f);
01141 _equip_select.SetHorizontalWrapMode(VIDEO_WRAP_MODE_SHIFTED);
01142 _equip_select.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
01143 _equip_select.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER);
01144
01145
01146
01147 _equip_select.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
01148 _UpdateEquipList();
01149 _equip_select.SetSelection(EQUIP_WEAPON);
01150 }
01151
01152
01153
01154 void EquipWindow::Update() {
01155
01156 OptionBox *active_option = NULL;
01157
01158
01159 switch (_active_box) {
01160 case EQUIP_ACTIVE_CHAR:
01161 active_option = &_char_select;
01162 break;
01163 case EQUIP_ACTIVE_SELECT:
01164 active_option = &_equip_select;
01165 break;
01166 case EQUIP_ACTIVE_LIST:
01167 active_option = &_equip_list;
01168 break;
01169 }
01170
01171
01172 if (InputManager->ConfirmPress())
01173 {
01174 active_option->HandleConfirmKey();
01175 }
01176 else if (InputManager->CancelPress())
01177 {
01178 active_option->HandleCancelKey();
01179 }
01180 else if (InputManager->LeftPress())
01181 {
01182 active_option->HandleLeftKey();
01183 }
01184 else if (InputManager->RightPress())
01185 {
01186 active_option->HandleRightKey();
01187 }
01188 else if (InputManager->UpPress())
01189 {
01190 active_option->HandleUpKey();
01191 }
01192 else if (InputManager->DownPress())
01193 {
01194 active_option->HandleDownKey();
01195 }
01196
01197 uint32 event = active_option->GetEvent();
01198 active_option->Update();
01199 switch (_active_box) {
01200
01201 case EQUIP_ACTIVE_CHAR:
01202 {
01203 if (event == VIDEO_OPTION_CONFIRM) {
01204 _active_box = EQUIP_ACTIVE_SELECT;
01205 _char_select.SetCursorState(VIDEO_CURSOR_STATE_BLINKING);
01206 _equip_select.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
01207 MenuMode::_instance->_menu_sounds["confirm"].PlaySound();
01208 }
01209 else if (event == VIDEO_OPTION_CANCEL) {
01210 Activate(false);
01211 MenuMode::_instance->_menu_sounds["cancel"].PlaySound();
01212 }
01213 }
01214 break;
01215
01216
01217 case EQUIP_ACTIVE_SELECT:
01218 {
01219 if (event == VIDEO_OPTION_CONFIRM) {
01220 _active_box = EQUIP_ACTIVE_LIST;
01221 _UpdateEquipList();
01222 if (_equip_list.GetNumberOptions() > 0) {
01223 _equip_select.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
01224 _equip_list.SetSelection(0);
01225 _equip_list.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
01226 MenuMode::_instance->_menu_sounds["confirm"].PlaySound();
01227 }
01228 else {
01229 _active_box = EQUIP_ACTIVE_SELECT;
01230 MenuMode::_instance->_menu_sounds["cancel"].PlaySound();
01231 }
01232 }
01233 else if (event == VIDEO_OPTION_CANCEL) {
01234 _active_box = EQUIP_ACTIVE_CHAR;
01235 _char_select.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
01236 _equip_select.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
01237 MenuMode::_instance->_menu_sounds["cancel"].PlaySound();
01238 }
01239 }
01240 break;
01241
01242
01243 case EQUIP_ACTIVE_LIST:
01244 {
01245 if (event == VIDEO_OPTION_CONFIRM) {
01246
01247
01248
01249
01250
01251
01252
01253
01254
01255
01256
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279 _active_box = EQUIP_ACTIVE_SELECT;
01280 _equip_list.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
01281 _equip_select.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
01282 MenuMode::_instance->_menu_sounds["confirm"].PlaySound();
01283 }
01284 else if (event == VIDEO_OPTION_CANCEL) {
01285 _active_box = EQUIP_ACTIVE_SELECT;
01286 MenuMode::_instance->_menu_sounds["cancel"].PlaySound();
01287 _equip_list.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
01288 _equip_select.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
01289 }
01290 }
01291 break;
01292 }
01293
01294 _UpdateEquipList();
01295 }
01296
01297
01298
01299 void EquipWindow::_UpdateEquipList() {
01300 GlobalActor* actor = GlobalManager->GetActiveParty()->GetActorAtIndex(_char_select.GetSelection());
01301 GlobalCharacter* ch = (GlobalCharacter*)(actor);
01302 std::vector<ustring> options;
01303
01304 if (_active_box == EQUIP_ACTIVE_LIST) {
01305 uint32 gearsize = 0;
01306 vector<hoa_global::GlobalWeapon*> weapons;
01307 vector<hoa_global::GlobalArmor*> armor;
01308
01309 switch (_equip_select.GetSelection()) {
01310 case EQUIP_WEAPON:
01311 gearsize = GlobalManager->GetInventoryWeapons()->size();
01312
01313 for (uint32 j = 0; j < gearsize; j++) {
01314 options.push_back(GlobalManager->GetInventoryWeapons()->at(j)->GetName());
01315 }
01316
01317 break;
01318
01319 case EQUIP_HEADGEAR:
01320 gearsize = GlobalManager->GetInventoryHeadArmor()->size();
01321
01322 for (uint32 j = 0; j < gearsize; j++) {
01323 options.push_back(GlobalManager->GetInventoryHeadArmor()->at(j)->GetName());
01324 }
01325
01326 break;
01327
01328 case EQUIP_BODYARMOR:
01329 gearsize = GlobalManager->GetInventoryTorsoArmor()->size();
01330
01331 for (uint32 j = 0; j < gearsize; j++) {
01332 options.push_back(GlobalManager->GetInventoryTorsoArmor()->at(j)->GetName());
01333 }
01334
01335 break;
01336
01337 case EQUIP_OFFHAND:
01338 gearsize = GlobalManager->GetInventoryArmArmor()->size();
01339
01340 for (uint32 j = 0; j < gearsize; j++) {
01341 options.push_back(GlobalManager->GetInventoryArmArmor()->at(j)->GetName());
01342 }
01343
01344 break;
01345
01346 case EQUIP_LEGGINGS:
01347 gearsize = GlobalManager->GetInventoryLegArmor()->size();
01348
01349 for (uint32 j = 0; j < gearsize; j++) {
01350 options.push_back(GlobalManager->GetInventoryLegArmor()->at(j)->GetName());
01351 }
01352
01353 break;
01354 }
01355 _equip_list.SetSize(1, gearsize);
01356 _equip_list.SetOptions(options);
01357 }
01358
01359 else {
01360
01361 _equip_images.clear();
01362 StillImage i;
01363
01364 i.SetFilename(ch->GetWeaponEquipped()->GetIconImage().GetFilename());
01365 _equip_images.push_back(i);
01366
01367 i.SetFilename(ch->GetHeadArmorEquipped()->GetIconImage().GetFilename());
01368 _equip_images.push_back(i);
01369
01370 i.SetFilename(ch->GetTorsoArmorEquipped()->GetIconImage().GetFilename());
01371 _equip_images.push_back(i);
01372
01373 i.SetFilename(ch->GetArmArmorEquipped()->GetIconImage().GetFilename());
01374 _equip_images.push_back(i);
01375
01376 i.SetFilename(ch->GetLegArmorEquipped()->GetIconImage().GetFilename());
01377 _equip_images.push_back(i);
01378
01379 for (uint32 i = 0; i < EQUIP_CATEGORY_SIZE; i++) {
01380 _equip_images[i].SetDimensions(60, 60);
01381 VideoManager->LoadImage(_equip_images[i]);
01382 }
01383
01384
01385
01386 options.push_back(ch->GetWeaponEquipped()->GetName());
01387 options.push_back(ch->GetHeadArmorEquipped()->GetName());
01388 options.push_back(ch->GetTorsoArmorEquipped()->GetName());
01389 options.push_back(ch->GetArmArmorEquipped()->GetName());
01390 options.push_back(ch->GetLegArmorEquipped()->GetName());
01391
01392 _equip_select.SetOptions(options);
01393 }
01394
01395 }
01396
01397
01398
01399 void EquipWindow::Draw() {
01400 MenuWindow::Draw();
01401
01402
01403 _char_select.Draw();
01404
01405 if (_active_box == EQUIP_ACTIVE_LIST) {
01406 _equip_list.Draw();
01407 VideoManager->Move(660.0f, 135.0f);
01408 VideoManager->SetDrawFlags(VIDEO_X_CENTER, VIDEO_Y_CENTER, 0);
01409 switch (_equip_select.GetSelection()) {
01410 case EQUIP_WEAPON:
01411 VideoManager->DrawText(MakeUnicodeString("Weapons"));
01412 break;
01413 case EQUIP_HEADGEAR:
01414 VideoManager->DrawText(MakeUnicodeString("Headgear"));
01415 break;
01416 case EQUIP_BODYARMOR:
01417 VideoManager->DrawText(MakeUnicodeString("Body Armor"));
01418 break;
01419 case EQUIP_OFFHAND:
01420 VideoManager->DrawText(MakeUnicodeString("Offhand"));
01421 break;
01422 case EQUIP_LEGGINGS:
01423 VideoManager->DrawText(MakeUnicodeString("Leggings"));
01424 break;
01425 }
01426 }
01427 else {
01428 _equip_select.Draw();
01429
01430
01431 VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_TOP, 0);
01432 VideoManager->Move(450.0f, 170.0f);
01433 VideoManager->DrawText(MakeUnicodeString("Weapon"));
01434 VideoManager->MoveRelative(0.0f, 70.0f);
01435 VideoManager->DrawText(MakeUnicodeString("Headgear"));
01436 VideoManager->MoveRelative(0.0f, 70.0f);
01437 VideoManager->DrawText(MakeUnicodeString("Body Armor"));
01438 VideoManager->MoveRelative(0.0f, 70.0f);
01439 VideoManager->DrawText(MakeUnicodeString("Offhand"));
01440 VideoManager->MoveRelative(0.0f, 70.0f);
01441 VideoManager->DrawText(MakeUnicodeString("Leggings"));
01442
01443 VideoManager->MoveRelative(150.0f, -370.0f);
01444
01445 for (uint32 i = 0; i < _equip_images.size(); i++) {
01446 VideoManager->MoveRelative(0.0f, 70.0f);
01447 VideoManager->DrawImage(_equip_images[i]);
01448 }
01449 }
01450
01451 }
01452
01453
01454 FormationWindow::FormationWindow() {
01455
01456 string file_name = "dat/saved_game.lua";
01457 GlobalManager->SaveGame(file_name);
01458 cout << "Game saved!" << endl;
01459 }
01460
01461 FormationWindow::~FormationWindow() {
01462 }
01463
01464 void FormationWindow::Draw() {
01465 MenuWindow::Draw();
01466 }
01467
01468 }
01469
01470 }