00001
00002
00003
00004
00005
00006
00007
00009
00010 #include <iostream>
00011 #include <sstream>
00012
00013 #include "utils.h"
00014 #include "audio.h"
00015 #include "video.h"
00016 #include "input.h"
00017 #include "system.h"
00018 #include "global.h"
00019 #include "mode_manager.h"
00020
00021 #include "shop.h"
00022 #include "shop_windows.h"
00023
00024 using namespace std;
00025
00026 using namespace hoa_utils;
00027 using namespace hoa_audio;
00028 using namespace hoa_video;
00029 using namespace hoa_input;
00030 using namespace hoa_system;
00031 using namespace hoa_global;
00032 using namespace hoa_mode_manager;
00033
00034 namespace hoa_shop {
00035
00036 namespace private_shop {
00037
00038
00039
00040
00041
00042 ShopActionWindow::ShopActionWindow() {
00043
00044 MenuWindow::Create(200, 600, ~VIDEO_MENU_EDGE_RIGHT);
00045 MenuWindow::SetPosition(112, 684);
00046 MenuWindow::SetAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP);
00047 MenuWindow::SetDisplayMode(VIDEO_MENU_INSTANT);
00048 MenuWindow::Show();
00049
00050
00051 options.SetOwner(this);
00052 options.SetPosition(25.0f, 600.0f);
00053 options.SetSize(1, 5);
00054 options.SetCellSize(150.0f, 50.0f);
00055 options.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER);
00056 options.SetFont("default");
00057 options.SetSelectMode(VIDEO_SELECT_SINGLE);
00058 options.SetCursorOffset(-50.0f, 20.0f);
00059 options.SetVerticalWrapMode(VIDEO_WRAP_MODE_NONE);
00060
00061 vector<ustring> text;
00062 text.push_back(MakeUnicodeString("Buy"));
00063 text.push_back(MakeUnicodeString("Sell"));
00064 text.push_back(MakeUnicodeString("Confirm"));
00065 text.push_back(MakeUnicodeString("Menu"));
00066 text.push_back(MakeUnicodeString("Leave"));
00067 options.SetOptions(text);
00068 options.SetSelection(0);
00069
00070
00071 text_box.SetOwner(this);
00072 text_box.SetPosition(25.0f, 85.0f);
00073 text_box.SetDimensions(150.0f, 65.0f);
00074 text_box.SetDisplaySpeed(30);
00075 text_box.SetFont("default");
00076 text_box.SetDisplayMode(VIDEO_TEXT_INSTANT);
00077 text_box.SetTextAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP);
00078 UpdateFinanceText();
00079 }
00080
00081
00082
00083 ShopActionWindow::~ShopActionWindow() {
00084 MenuWindow::Destroy();
00085 }
00086
00087
00088
00089 void ShopActionWindow::Update() {
00090 MenuWindow::Update(SystemManager->GetUpdateTime());
00091 options.Update();
00092
00093 if (InputManager->ConfirmPress()) {
00094 options.HandleConfirmKey();
00095 if (options.GetSelection() == 0) {
00096 options.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00097 current_shop->_list_window.hide_options = false;
00098 current_shop->_info_window.SetObject(current_shop->_all_objects[0]);
00099 current_shop->_list_window.Show();
00100 current_shop->_sell_window.Hide();
00101 current_shop->_list_window.object_list.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
00102 current_shop->_state = SHOP_STATE_LIST;
00103 current_shop->_shop_sounds["confirm"].PlaySound();
00104 }
00105 else if (options.GetSelection() == 1) {
00106 if (GlobalManager->GetInventory()->empty() == false) {
00107 options.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00108 current_shop->_sell_window.UpdateSellList();
00109 current_shop->_sell_window.object_list.SetSelection(0);
00110 current_shop->_sell_window.hide_options = false;
00111 current_shop->_info_window.SetObject(current_shop->_current_inv[0]);
00112 current_shop->_sell_window.Show();
00113 current_shop->_list_window.Hide();
00114 current_shop->_sell_window.object_list.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
00115 current_shop->_state = SHOP_STATE_SELL;
00116 current_shop->_shop_sounds["confirm"].PlaySound();
00117 }
00118 else {
00119 current_shop->_shop_sounds["cancel"].PlaySound();
00120 }
00121 }
00122 else if (options.GetSelection() == 2) {
00123 options.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00124 current_shop->_state = SHOP_STATE_CONFIRM;
00125 current_shop->_confirm_window.options.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
00126 current_shop->_confirm_window.Show();
00127 }
00128 else if (options.GetSelection() == 3) {
00129 current_shop->_shop_sounds["confirm"].PlaySound();
00130
00131
00132 }
00133 else if (options.GetSelection() == 4) {
00134 ModeManager->Pop();
00135 current_shop->_shop_sounds["cancel"].PlaySound();
00136 }
00137 else {
00138 if (SHOP_DEBUG)
00139 cerr << "SHOP WARNING: invalid selection in action window: " << options.GetSelection() << endl;
00140 ModeManager->Pop();
00141 }
00142 }
00143 else if (InputManager->CancelPress()) {
00144 ModeManager->Pop();
00145 current_shop->_shop_sounds["cancel"].PlaySound();
00146 }
00147 else if (InputManager->UpPress()) {
00148 options.HandleUpKey();
00149 }
00150 else if (InputManager->DownPress()) {
00151 options.HandleDownKey();
00152 }
00153 }
00154
00155
00156
00157 void ShopActionWindow::UpdateFinanceText() {
00158 if (current_shop != NULL) {
00159 text_box.SetDisplayText(MakeUnicodeString(
00160 "Funds: " + NumberToString(GlobalManager->GetDrunes()) +
00161 "\nCosts: " + NumberToString(current_shop->GetPurchaseCost()) +
00162 "\nRefund: " + NumberToString(current_shop->GetSalesRevenue()) +
00163 "\nTotal: " + NumberToString(current_shop->GetTotalRemaining())
00164 ));
00165 }
00166 }
00167
00168
00169
00170 void ShopActionWindow::Draw() {
00171 hoa_video::MenuWindow::Draw();
00172 options.Draw();
00173 text_box.Draw();
00174 }
00175
00176
00177
00178
00179
00180 ObjectListWindow::ObjectListWindow() {
00181 MenuWindow::Create(600, 400, VIDEO_MENU_EDGE_ALL, VIDEO_MENU_EDGE_LEFT | VIDEO_MENU_EDGE_BOTTOM);
00182 MenuWindow::SetPosition(312, 684);
00183 MenuWindow::SetAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP);
00184 MenuWindow::SetDisplayMode(VIDEO_MENU_INSTANT);
00185 MenuWindow::Show();
00186
00187 object_list.SetOwner(this);
00188 object_list.SetCellSize(500.0f, 50.0f);
00189 object_list.SetPosition(50.0f, 400.0f);
00190 object_list.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER);
00191 object_list.SetFont("default");
00192 object_list.SetSelectMode(VIDEO_SELECT_SINGLE);
00193 object_list.SetCursorOffset(-50.0f, 20.0f);
00194 object_list.SetHorizontalWrapMode(VIDEO_WRAP_MODE_NONE);
00195
00196 hide_options = true;
00197 }
00198
00199
00200
00201 ObjectListWindow::~ObjectListWindow() {
00202 MenuWindow::Destroy();
00203 }
00204
00205 void ObjectListWindow::Clear() {
00206 option_text.clear();
00207 object_list.SetOptions(option_text);
00208 }
00209
00210
00211
00212 void ObjectListWindow::AddEntry(hoa_utils::ustring name, uint32 price, uint32 quantity) {
00213 option_text.push_back(name + MakeUnicodeString("<R>") + MakeUnicodeString(NumberToString(price)) + MakeUnicodeString(" x") + MakeUnicodeString(NumberToString(quantity)));
00214 }
00215
00216
00217
00218 void ObjectListWindow::ConstructList() {
00219 object_list.SetSize(1, option_text.size());
00220 object_list.SetOptions(option_text);
00221 object_list.SetSelection(0);
00222 }
00223
00224
00225
00226 void ObjectListWindow::RefreshList() {
00227 Clear();
00228 for (uint32 i = 0; i < current_shop->_all_objects.size(); i++) {
00229 current_shop->_list_window.AddEntry(current_shop->_all_objects[i]->GetName(),
00230 current_shop->_all_objects[i]->GetPrice(),
00231 current_shop->_all_objects_quantities[i]);
00232 }
00233 ConstructList();
00234 }
00235
00236
00237
00238 void ObjectListWindow::Update() {
00239 MenuWindow::Update(SystemManager->GetUpdateTime());
00240 object_list.Update();
00241
00242 if (InputManager->ConfirmPress()) {
00243 object_list.HandleConfirmKey();
00244 current_shop->_state = SHOP_STATE_CONFIRM;
00245 object_list.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00246 current_shop->_info_window.SetObject(NULL);
00247 current_shop->_confirm_window.options.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
00248 current_shop->_confirm_window.Show();
00249 current_shop->_shop_sounds["confirm"].PlaySound();
00250 }
00251 else if (InputManager->CancelPress()) {
00252 hide_options = true;
00253 current_shop->_state = SHOP_STATE_ACTION;
00254 current_shop->_action_window.options.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
00255 object_list.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00256 current_shop->_info_window.SetObject(NULL);
00257 current_shop->_shop_sounds["cancel"].PlaySound();
00258 }
00259 else if (InputManager->UpPress()) {
00260 object_list.HandleUpKey();
00261 current_shop->_info_window.SetObject(current_shop->_all_objects[object_list.GetSelection()]);
00262 }
00263 else if (InputManager->DownPress()) {
00264 object_list.HandleDownKey();
00265 current_shop->_info_window.SetObject(current_shop->_all_objects[object_list.GetSelection()]);
00266 }
00267 else if (InputManager->LeftPress()) {
00268 int x = object_list.GetSelection();
00269 if (current_shop->_all_objects_quantities[x] > 0) {
00270 current_shop->_all_objects_quantities[x]--;
00271 current_shop->_purchases_cost -= current_shop->_all_objects[x]->GetPrice();
00272 object_list.SetOptionText(x, current_shop->_all_objects[x]->GetName() + MakeUnicodeString("<R>") + MakeUnicodeString(NumberToString(current_shop->_all_objects[x]->GetPrice())) + MakeUnicodeString(" x") + MakeUnicodeString(NumberToString(current_shop->_all_objects_quantities[x])));
00273 current_shop->_action_window.UpdateFinanceText();
00274 }
00275 }
00276 else if (InputManager->RightPress()) {
00277 int x = object_list.GetSelection();
00278 if (current_shop->_all_objects[x]->GetPrice() <= current_shop->GetTotalRemaining()) {
00279 current_shop->_all_objects_quantities[x]++;
00280 current_shop->_purchases_cost += current_shop->_all_objects[x]->GetPrice();
00281 object_list.SetOptionText(x, current_shop->_all_objects[x]->GetName() + MakeUnicodeString("<R>") + MakeUnicodeString(NumberToString(current_shop->_all_objects[x]->GetPrice())) + MakeUnicodeString(" x") + MakeUnicodeString(NumberToString(current_shop->_all_objects_quantities[x])));
00282 current_shop->_action_window.UpdateFinanceText();
00283 }
00284 }
00285 }
00286
00287
00288
00289 void ObjectListWindow::Draw() {
00290 MenuWindow::Draw();
00291
00292 if (current_shop->_state == SHOP_STATE_LIST && hide_options == false && option_text.empty() == false) {
00293 object_list.Draw();
00294 }
00295 }
00296
00297
00298
00299
00300
00301 ObjectSellListWindow::ObjectSellListWindow() {
00302 MenuWindow::Create(600, 400, VIDEO_MENU_EDGE_ALL, VIDEO_MENU_EDGE_LEFT | VIDEO_MENU_EDGE_BOTTOM);
00303 MenuWindow::SetPosition(312, 684);
00304 MenuWindow::SetAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP);
00305 MenuWindow::SetDisplayMode(VIDEO_MENU_INSTANT);
00306 MenuWindow::Show();
00307
00308 object_list.SetOwner(this);
00309 object_list.SetCellSize(500.0f, 50.0f);
00310 object_list.SetPosition(50.0f, 400.0f);
00311 object_list.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER);
00312 object_list.SetFont("default");
00313 object_list.SetSelectMode(VIDEO_SELECT_SINGLE);
00314 object_list.SetCursorOffset(-50.0f, 20.0f);
00315 object_list.SetHorizontalWrapMode(VIDEO_WRAP_MODE_NONE);
00316
00317 hide_options = true;
00318 }
00319
00320
00321
00322 ObjectSellListWindow::~ObjectSellListWindow() {
00323 MenuWindow::Destroy();
00324 }
00325
00326
00327
00328 void ObjectSellListWindow::Clear() {
00329 option_text.clear();
00330 current_shop->_current_inv.clear();
00331 object_list.SetOptions(option_text);
00332 }
00333
00334
00335
00336 void ObjectSellListWindow::AddEntry(hoa_utils::ustring name, uint32 count, uint32 price, uint32 sell_count) {
00337 std::string text = " x" + NumberToString(count) + "<R>x" + NumberToString(sell_count) + " " + NumberToString(price);
00338
00339 option_text.push_back(name + MakeUnicodeString(" x") + MakeUnicodeString(NumberToString(count)) + MakeUnicodeString("<R>x") + MakeUnicodeString(NumberToString(sell_count)) + MakeUnicodeString(" ") + MakeUnicodeString(NumberToString(price)));
00340 }
00341
00342
00343
00344 void ObjectSellListWindow::Update() {
00345 MenuWindow::Update(SystemManager->GetUpdateTime());
00346 object_list.Update();
00347
00348 if (InputManager->ConfirmPress()) {
00349 object_list.HandleConfirmKey();
00350 hide_options = true;
00351 object_list.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00352 current_shop->_state = SHOP_STATE_CONFIRM;
00353 current_shop->_confirm_window.options.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
00354 current_shop->_confirm_window.Show();
00355 current_shop->_shop_sounds["confirm"].PlaySound();
00356 }
00357 else if (InputManager->CancelPress()) {
00358 hide_options = true;
00359 current_shop->_state = SHOP_STATE_ACTION;
00360 current_shop->_action_window.options.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
00361 object_list.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00362 current_shop->_info_window.SetObject(NULL);
00363 current_shop->_shop_sounds["cancel"].PlaySound();
00364 }
00365 else if (InputManager->UpPress()) {
00366 object_list.HandleUpKey();
00367 current_shop->_info_window.SetObject(current_shop->_current_inv[object_list.GetSelection()]);
00368 }
00369 else if (InputManager->DownPress()) {
00370 object_list.HandleDownKey();
00371 current_shop->_info_window.SetObject(current_shop->_current_inv[object_list.GetSelection()]);
00372 }
00373 else if (InputManager->LeftPress()) {
00374 int x = object_list.GetSelection();
00375 if (current_shop->_sell_objects_quantities[x] > 0) {
00376 current_shop->_sell_objects_quantities[x]--;
00377 current_shop->_sales_revenue -= (current_shop->_current_inv[x]->GetPrice() / 2);
00378 current_shop->_action_window.UpdateFinanceText();
00379 }
00380 }
00381 else if (InputManager->RightPress()) {
00382 uint32 x = object_list.GetSelection();
00383 if (current_shop->_current_inv[x]->GetCount() > current_shop->_sell_objects_quantities[x]) {
00384 current_shop->_sell_objects_quantities[x]++;
00385 current_shop->_sales_revenue += (current_shop->_current_inv[x]->GetPrice() / 2);
00386 current_shop->_action_window.UpdateFinanceText();
00387 }
00388 }
00389
00390 UpdateSellList();
00391 }
00392
00393
00394
00395 void ObjectSellListWindow::UpdateSellList() {
00396 Clear();
00397 std::map<uint32, GlobalObject*>* inv = GlobalManager->GetInventory();
00398 std::map<uint32, GlobalObject*>::iterator iter;
00399
00400 int x = 0;
00401 for (iter = inv->begin(); iter != inv->end(); iter++) {
00402 current_shop->_current_inv.push_back(iter->second);
00403 AddEntry(iter->second->GetName(), iter->second->GetCount(), iter->second->GetPrice() / 2, current_shop->_sell_objects_quantities[x]);
00404 x++;
00405 }
00406 object_list.SetSize(1, option_text.size());
00407 object_list.SetOptions(option_text);
00408 }
00409
00410
00411
00412 void ObjectSellListWindow::Draw() {
00413 MenuWindow::Draw();
00414
00415 if (current_shop->_state == SHOP_STATE_SELL) {
00416 if (hide_options == false && option_text.empty() == false) {
00417 object_list.Draw();
00418 }
00419 }
00420 }
00421
00422
00423
00424
00425
00426 ObjectInfoWindow::ObjectInfoWindow() {
00427
00428 MenuWindow::Create(600, 216, ~VIDEO_MENU_EDGE_TOP);
00429 MenuWindow::SetPosition(312, 300);
00430 MenuWindow::SetAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP);
00431 MenuWindow::SetDisplayMode(VIDEO_MENU_INSTANT);
00432 MenuWindow::Show();
00433
00434
00435 _object = NULL;
00436
00437
00438 description.SetOwner(this);
00439 description.SetPosition(25.0f, 100.0f);
00440 description.SetDimensions(550.0f, 80.0f);
00441 description.SetDisplaySpeed(30);
00442 description.SetFont("default");
00443 description.SetDisplayMode(VIDEO_TEXT_INSTANT);
00444 description.SetTextAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP);
00445
00446
00447 properties.SetOwner(this);
00448 properties.SetPosition(50.0f, 150.0f);
00449 properties.SetDimensions(300.0f, 80.0f);
00450 properties.SetDisplaySpeed(30);
00451 properties.SetFont("default");
00452 properties.SetDisplayMode(VIDEO_TEXT_INSTANT);
00453 properties.SetTextAlignment(VIDEO_X_RIGHT, VIDEO_Y_TOP);
00454 }
00455
00456
00457
00458 ObjectInfoWindow::~ObjectInfoWindow() {
00459 MenuWindow::Destroy();
00460 }
00461
00462
00463
00464 void ObjectInfoWindow::SetObject(GlobalObject* obj) {
00465 _object = obj;
00466 if (obj == NULL) {
00467 description.ClearText();
00468 properties.ClearText();
00469 return;
00470 }
00471
00472 description.SetDisplayText(_object->GetDescription());
00473
00474
00475 switch (obj->GetObjectType()) {
00476 case GLOBAL_OBJECT_WEAPON:
00477 GlobalWeapon *weapon;
00478 weapon = dynamic_cast<GlobalWeapon*>(obj);
00479 properties.SetDisplayText(
00480 "PHYS ATK: " + NumberToString(weapon->GetPhysicalAttack()) + "\n" +
00481 "META ATK: " + NumberToString(weapon->GetMetaphysicalAttack())
00482 );
00483 break;
00484 case GLOBAL_OBJECT_HEAD_ARMOR:
00485 case GLOBAL_OBJECT_TORSO_ARMOR:
00486 case GLOBAL_OBJECT_ARM_ARMOR:
00487 case GLOBAL_OBJECT_LEG_ARMOR:
00488 GlobalArmor *armor;
00489 armor = dynamic_cast<GlobalArmor*>(obj);
00490 properties.SetDisplayText(
00491 "PHYS DEF: " + NumberToString(armor->GetPhysicalDefense()) + "\n" +
00492 "META DEF: " + NumberToString(armor->GetMetaphysicalDefense())
00493 );
00494 break;
00495 default:
00496 properties.ClearText();
00497 break;
00498 }
00499 }
00500
00501
00502
00503 void ObjectInfoWindow::Draw() {
00504 MenuWindow::Draw();
00505
00506 if (_object == NULL) {
00507 return;
00508 }
00509
00510
00511 VideoManager->Move(350, 200);
00512 VideoManager->DrawImage(_object->GetIconImage());
00513 VideoManager->MoveRelative(60, 20);
00514 VideoManager->DrawText(_object->GetName());
00515
00516
00517 description.Draw();
00518 properties.Draw();
00519 }
00520
00521
00522
00523
00524
00525 ConfirmWindow::ConfirmWindow() {
00526
00527 MenuWindow::Create(400, 200);
00528 MenuWindow::SetPosition(512, 384);
00529 MenuWindow::SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
00530 MenuWindow::SetDisplayMode(VIDEO_MENU_INSTANT);
00531
00532
00533 options.SetOwner(this);
00534 options.SetPosition(100.0f, 100.0f);
00535 options.SetSize(2, 1);
00536 options.SetCellSize(150.0f, 50.0f);
00537 options.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER);
00538 options.SetFont("default");
00539 options.SetSelectMode(VIDEO_SELECT_SINGLE);
00540 options.SetCursorOffset(-50.0f, 20.0f);
00541 options.SetVerticalWrapMode(VIDEO_WRAP_MODE_NONE);
00542
00543 vector<ustring> text;
00544 text.push_back(MakeUnicodeString("Confirm"));
00545 text.push_back(MakeUnicodeString("Cancel"));
00546 options.SetOptions(text);
00547 options.SetSelection(0);
00548 }
00549
00550
00551
00552 ConfirmWindow::~ConfirmWindow() {
00553 MenuWindow::Destroy();
00554 }
00555
00556
00557
00558 void ConfirmWindow::Update() {
00559 options.Update();
00560
00561 if (InputManager->LeftPress()) {
00562 options.HandleLeftKey();
00563 }
00564 else if (InputManager->RightPress()) {
00565 options.HandleRightKey();
00566 }
00567
00568 if (InputManager->CancelPress()) {
00569 current_shop->_shop_sounds["cancel"].PlaySound();
00570 options.SetSelection(0);
00571 current_shop->_action_window.options.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
00572 options.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00573 current_shop->_state = SHOP_STATE_ACTION;
00574 }
00575 else if (InputManager->ConfirmPress()) {
00576 if (options.GetSelection() == 0) {
00577 for (uint32 ctr = 0; ctr < current_shop->_current_inv.size(); ctr++) {
00578 if (current_shop->_sell_objects_quantities[ctr] > 0) {
00579 GlobalManager->DecrementObjectCount(current_shop->_current_inv[ctr]->GetID(), current_shop->_sell_objects_quantities[ctr]);
00580 }
00581 }
00582
00583 for (uint32 ctr = 0; ctr < current_shop->_all_objects.size(); ctr++) {
00584 if (current_shop->_all_objects_quantities[ctr] > 0) {
00585 GlobalManager->AddToInventory(current_shop->_all_objects[ctr]->GetID(), current_shop->_all_objects_quantities[ctr]);
00586 }
00587 current_shop->_all_objects_quantities[ctr] = 0;
00588 }
00589
00590 std::map<uint32, GlobalObject*>* inv = GlobalManager->GetInventory();
00591 std::map<uint32, GlobalObject*>::iterator iter;
00592
00593 current_shop->_sell_objects_quantities.clear();
00594 for (iter = inv->begin(); iter != inv->end(); iter++) {
00595 current_shop->_sell_objects_quantities.push_back(0);
00596 }
00597
00598 GlobalManager->SubtractDrunes(current_shop->GetPurchaseCost());
00599 GlobalManager->AddDrunes(current_shop->GetSalesRevenue());
00600 current_shop->_purchases_cost = 0;
00601 current_shop->_sales_revenue = 0;
00602 current_shop->_shop_sounds["coins"].PlaySound();
00603 current_shop->_action_window.UpdateFinanceText();
00604 current_shop->_info_window.SetObject(NULL);
00605 current_shop->_list_window.RefreshList();
00606 current_shop->_sell_window.UpdateSellList();
00607 current_shop->_state = SHOP_STATE_LIST;
00608 }
00609 else {
00610 current_shop->_shop_sounds["cancel"].PlaySound();
00611 }
00612
00613
00614 options.SetSelection(0);
00615 current_shop->_action_window.options.SetCursorState(VIDEO_CURSOR_STATE_VISIBLE);
00616 options.SetCursorState(VIDEO_CURSOR_STATE_HIDDEN);
00617 current_shop->_state = SHOP_STATE_ACTION;
00618 }
00619 }
00620
00621
00622
00623 void ConfirmWindow::Draw() {
00624 if (current_shop->_state == SHOP_STATE_CONFIRM) {
00625 MenuWindow::Draw();
00626 options.Draw();
00627 VideoManager->PushState();
00628 VideoManager->SetDrawFlags(VIDEO_X_CENTER, VIDEO_Y_CENTER, 0);
00629 VideoManager->Move(512, 450);
00630 VideoManager->DrawText("Finalize transactions?");
00631 VideoManager->PopState();
00632 }
00633 }
00634
00635 }
00636
00637 }