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 and
6 // 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    battle_finish.cpp
12 *** \author  Tyler Olsen, roots@allacrost.org
13 *** \brief   Source file for battle finish menu
14 *** ***************************************************************************/
15 
16 #include "mode_manager.h"
17 #include "input.h"
18 #include "system.h"
19 #include "video.h"
20 
21 #include "battle.h"
22 #include "battle_actions.h"
23 #include "battle_actors.h"
24 #include "battle_finish.h"
25 #include "battle_utils.h"
26 
27 #include "boot.h"
28 
29 using namespace std;
30 
31 using namespace hoa_utils;
32 
33 using namespace hoa_audio;
34 using namespace hoa_video;
35 using namespace hoa_gui;
36 using namespace hoa_input;
37 using namespace hoa_mode_manager;
38 using namespace hoa_system;
39 using namespace hoa_global;
40 
41 namespace hoa_battle {
42 
43 namespace private_battle {
44 
45 ////////////////////////////////////////////////////////////////////////////////
46 // FinishDefeat class
47 ////////////////////////////////////////////////////////////////////////////////
48 
FinishDefeat()49 FinishDefeat::FinishDefeat() :
50 	_number_retry_times(0)
51 {
52 	_options_window.Create(512.0f, 64.0f);
53 	_options_window.SetPosition(512.0f, 60.0f);
54 	_options_window.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_TOP);
55 
56 	_tooltip_window.Create(512.0f, 112.0f);
57 	_tooltip_window.SetPosition(512.0f, 124.0f);
58 	_tooltip_window.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_TOP);
59 
60 	_outcome_message.SetPosition(512.0f, 384.0f);
61 	_outcome_message.SetDimensions(400.0f, 100.0f);
62 	_outcome_message.SetDisplaySpeed(30);
63 	_outcome_message.SetTextStyle(TextStyle("text24", Color::white));
64 	_outcome_message.SetDisplayMode(VIDEO_TEXT_INSTANT);
65 	_outcome_message.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
66 	_outcome_message.SetTextAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
67 	_outcome_message.SetDisplayText(Translate("But the heroes were defeated..."));
68 
69 	_options.AddOption(UTranslate("Retry"));
70 	_options.AddOption(UTranslate("Restart"));
71 	_options.AddOption(UTranslate("Return"));
72 	_options.AddOption(UTranslate("Retire"));
73 	_options.SetPosition(270.0f, 130.0f);
74 	_options.SetDimensions(128.0f, 200.0f, 1, 4, 1, 4);
75 	_options.SetTextStyle(TextStyle("title22", Color::white, VIDEO_TEXT_SHADOW_DARK));
76 	_options.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
77 	_options.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
78 	_options.SetSelectMode(VIDEO_SELECT_SINGLE);
79 	_options.SetHorizontalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
80 	_options.SetCursorOffset(-60.0f, 25.0f);
81 	_options.SetSelection(0);
82 	_options.SetOwner(&_options_window);
83 	// TEMP: these two options are disabled because their features are not yet implemented
84 	_options.EnableOption(0, false);
85 	_options.EnableOption(1, false);
86 }
87 
88 
89 
Update()90 void FinishDefeat::Update() {
91 	if (InputManager->ConfirmPress()) {
92 		switch (_options.GetSelection()) {
93 			case DEFEAT_OPTION_RETRY:
94 				// TODO: feature not yet implemented. Reset the battle from the beginning.
95 				_number_retry_times++;
96 				break;
97 			case DEFEAT_OPTION_RESTART:
98 				// TODO: feature not yet implemented. Either auto-load last saved game or enter save
99 				// mode and allow user to select file to load (but do not allow user to save a file)
100 				break;
101 			case DEFEAT_OPTION_RETURN:
102 				ModeManager->PopAll();
103 				ModeManager->Push(new hoa_boot::BootMode());
104 				break;
105 			case DEFEAT_OPTION_RETIRE:
106 				SystemManager->ExitGame();
107 				break;
108 			default:
109 				IF_PRINT_WARNING(BATTLE_DEBUG) << "invalid option selection: " << _options.GetSelection() << endl;
110 				break;
111 		}
112 	}
113 
114 	else if (InputManager->LeftPress()) {
115 		_options.InputLeft();
116 	}
117 	else if (InputManager->RightPress()) {
118 		_options.InputRight();
119 	}
120 }
121 
122 
123 
Draw()124 void FinishDefeat::Draw() {
125 	_options_window.Draw();
126 	_tooltip_window.Draw();
127 	_outcome_message.Draw();
128 	_options.Draw();
129 	_tooltip.Draw();
130 }
131 
132 ////////////////////////////////////////////////////////////////////////////////
133 // FinishWindow class
134 ////////////////////////////////////////////////////////////////////////////////
135 
FinishWindow()136 FinishWindow::FinishWindow()
137 {
138 	//CD: We should really move all this to Initialize() instead
139 
140 	// TODO: declare the MenuSkin to be used
141 	//Just like the ones in Menu Mode
142 	float start_x = (1024 - 800) / 2 + 144;
143 	float start_y = 768 - ((768 - 600) / 2 + 15);
144 
145 	if (!MenuWindow::Create(480.0f, 560.0f))
146 		IF_PRINT_WARNING(BATTLE_DEBUG) << "the call to MenuWindow::Create() failed" << endl;
147 
148 	MenuWindow::SetPosition(start_x, start_y);
149 
150 	for (int32 i = 0; i < 4; ++i)
151 	{
152 		for (int32 j = 0; j < 8; ++j)
153 			_growth_gained[i][j] = 0;
154 	}
155 
156 	_state = FINISH_INVALID;
157 
158 	//Create character windows
159 	_InitCharacterWindows(start_x, start_y);
160 	//Create items and xp & money window
161 	_InitSpoilsWindows(start_x, start_y);
162 	//Initalize victory text (but don't set the string yet)
163 	_InitVictoryText();
164 	//Retry, quit, etc.
165 	_InitLoseOptions();
166 }
167 
168 
169 
~FinishWindow()170 FinishWindow::~FinishWindow() {
171 	_character_window[0].Destroy();
172 	_character_window[1].Destroy();
173 	_character_window[2].Destroy();
174 	_character_window[3].Destroy();
175 
176 	_xp_and_money_window.Destroy();
177 	_items_window.Destroy();
178 
179 	MenuWindow::Destroy();
180 }
181 
182 
183 
Initialize(bool victory)184 void FinishWindow::Initialize(bool victory) {
185 	MenuWindow::Show();
186 
187 	_victory_money = 0;
188 	_victory_xp = 0;
189 	_victory_items.clear();
190 
191 	for (uint32 i = 0; i < BattleMode::CurrentInstance()->_character_actors.size(); i++) {
192 		_characters.push_back(BattleMode::CurrentInstance()->_character_actors[i]->GetGlobalCharacter());
193 		_character_growths.push_back(_characters[i]->GetGrowth());
194 		_char_portraits[i].Load("img/portraits/map/" + BattleMode::CurrentInstance()->_character_actors[i]->GetFilename() + ".png", 100.0f, 100.0f);
195 	}
196 
197 	if (victory) {
198 		_state = FINISH_WIN_ANNOUNCE;
199 		_finish_outcome.SetDisplayText("The heroes are victorious!");
200 		_TallyXPMoneyAndItems();
201 	}
202 	else {
203 		_state = FINISH_LOSE_ANNOUNCE;
204 		_finish_outcome.SetDisplayText("The heroes have been defeated...");
205 	}
206 }
207 
_InitCharacterWindows(float start_x,float start_y)208 void FinishWindow::_InitCharacterWindows(float start_x, float start_y)
209 {
210 	_character_window[0].Create(480.0f, 140.0f, ~VIDEO_MENU_EDGE_BOTTOM, VIDEO_MENU_EDGE_BOTTOM);
211 	_character_window[0].SetPosition(start_x, start_y - 12.0f);
212 	_character_window[0].Show();
213 
214 	_character_window[1].Create(480.0f, 140.0f, ~VIDEO_MENU_EDGE_BOTTOM, VIDEO_MENU_EDGE_BOTTOM);
215 	_character_window[1].SetPosition(start_x, start_y - 12.0f - 140.0f);
216 	_character_window[1].Show();
217 
218 	_character_window[2].Create(480.0f, 140.0f, ~VIDEO_MENU_EDGE_BOTTOM, VIDEO_MENU_EDGE_BOTTOM);
219 	_character_window[2].SetPosition(start_x, start_y - 11.0f - 140.0f * 2.0f);
220 	_character_window[2].Show();
221 
222 	_character_window[3].Create(480.0f, 140.0f, VIDEO_MENU_EDGE_ALL, ~VIDEO_MENU_EDGE_ALL);//~VIDEO_MENU_EDGE_BOTTOM, VIDEO_MENU_EDGE_BOTTOM);
223 	_character_window[3].SetPosition(start_x, start_y - 10.0f - 140.0f * 3.0f);
224 	_character_window[3].Show();
225 }
226 
227 
_InitSpoilsWindows(float start_x,float start_y)228 void FinishWindow::_InitSpoilsWindows(float start_x, float start_y)
229 {
230 	_xp_and_money_window.Create(480.0f, 72.0f, VIDEO_MENU_EDGE_ALL, ~VIDEO_MENU_EDGE_ALL);
231 	_xp_and_money_window.SetPosition(start_x, start_y + 50.0f);
232 	_xp_and_money_window.Show();
233 
234 	_items_window.Create(480.0f, 560.0f, ~VIDEO_MENU_EDGE_TOP, VIDEO_MENU_EDGE_TOP);
235 	_items_window.SetPosition(start_x, start_y - 13.0f);
236 	_items_window.Show();
237 }
238 
239 
_InitLoseOptions()240 void FinishWindow::_InitLoseOptions()
241 {
242 	vector<ustring> lose_text;
243 	lose_text.push_back(UTranslate("Retry the battle"));
244 	lose_text.push_back(UTranslate("Load from last save point"));
245 	lose_text.push_back(UTranslate("Return to main menu"));
246 	lose_text.push_back(UTranslate("Exit the game"));
247 	_lose_options.SetOptions(lose_text);
248 	_lose_options.SetPosition(270.0f, 130.0f);
249 	_lose_options.SetDimensions(128.0f, 200.0f, 1, 4, 1, 4);
250 	_lose_options.SetTextStyle(TextStyle("text22", Color::white, VIDEO_TEXT_SHADOW_DARK));
251 	_lose_options.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
252 	_lose_options.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
253 	_lose_options.SetSelectMode(VIDEO_SELECT_SINGLE);
254 	_lose_options.SetHorizontalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
255 	_lose_options.SetCursorOffset(-60.0f, 25.0f);
256 	_lose_options.SetSelection(0);
257 	_lose_options.SetOwner(this);
258 	_lose_options.EnableOption(0, false);
259 	_lose_options.EnableOption(1, false);
260 }
261 
262 
_InitVictoryText()263 void FinishWindow::_InitVictoryText()
264 {
265 	_finish_outcome.SetPosition(512.0f, 384.0f);
266 	_finish_outcome.SetDimensions(400.0f, 100.0f);
267 	_finish_outcome.SetDisplaySpeed(30);
268 	_finish_outcome.SetTextStyle(TextStyle("text24", Color::white));
269 	_finish_outcome.SetDisplayMode(VIDEO_TEXT_INSTANT);
270 	_finish_outcome.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
271 	_finish_outcome.SetTextAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
272 }
273 
274 // ----- Tallies all the stuff we've won (xp, money, items)
275 
_TallyXPMoneyAndItems()276 void FinishWindow::_TallyXPMoneyAndItems()
277 {
278 	GlobalEnemy* ge;
279 	vector<GlobalObject*> objects;
280 	map<GlobalObject*, int32>::iterator iter;
281 
282 	deque<BattleEnemy*>& all_enemies = BattleMode::CurrentInstance()->GetEnemyActors();
283 	for (uint32 i = 0; i < all_enemies.size(); ++i)
284 	{
285 		ge = all_enemies[i]->GetGlobalEnemy();
286 		_victory_money += ge->GetDrunesDropped();
287 		_victory_xp += ge->GetExperiencePoints();
288 		ge->DetermineDroppedObjects(objects);
289 
290 		for (uint32 j = 0; j < objects.size(); ++j)
291 		{
292 			iter = _victory_items.find(objects[j]);
293 			if (iter != _victory_items.end())
294 			{
295 				iter->second++;
296 			}
297 			else
298 			{
299 				_victory_items.insert(make_pair(objects[j], 1));
300 			}
301 		}
302 		// also add 1 SP per enemy to each character in the party
303 		GlobalParty *party = GlobalManager->GetActiveParty();
304 		for (uint32 i = 0; i < party->GetPartySize(); ++i)
305 			party->GetActorAtIndex(i)->AddSkillPoints(1);
306 	}
307 
308 	deque<BattleCharacter*>& all_characters = BattleMode::CurrentInstance()->GetCharacterActors();
309 	uint32 num_alive_characters = 0;
310 	for (uint32 i = 0; i < all_characters.size(); ++i)
311 	{
312 		if (all_characters[i]->IsAlive())
313 		{
314 			++num_alive_characters;
315 		}
316 	}
317 	_victory_xp /= num_alive_characters;
318 }
319 
_ClearLearnedSkills()320 void FinishWindow::_ClearLearnedSkills()
321 {
322 	for (uint32 i = 0; i < _characters.size(); ++i)
323 	{
324 		_character_growths[i]->GetSkillsLearned()->clear();
325 	}
326 }
327 
328 // ----- UPDATE METHODS
329 
Update()330 void FinishWindow::Update() {
331 	MenuWindow::Update(SystemManager->GetUpdateTime());
332 
333 	switch (_state) {
334 		case FINISH_WIN_ANNOUNCE:
335 			_UpdateAnnounceWin();
336 			break;
337 		case FINISH_WIN_SHOW_GROWTH:
338 		case FINISH_WIN_RESOLVE_GROWTH:
339 		case FINISH_WIN_SHOW_SKILLS:
340 		case FINISH_WIN_SHOW_SPOILS:
341 		case FINISH_WIN_RESOLVE_SPOILS:
342 			_UpdateWinWaitForOK();
343 			break;
344 		case FINISH_WIN_COUNTDOWN_GROWTH:
345 			_UpdateWinGrowth();
346 			break;
347 		case FINISH_WIN_COUNTDOWN_SPOILS:
348 			_UpdateWinSpoils();
349 			break;
350 		case FINISH_WIN_COMPLETE:
351 			BattleMode::CurrentInstance()->Exit();
352 			break;
353 		case FINISH_LOSE_ANNOUNCE:
354 			_UpdateAnnounceLose();
355 			break;
356 		case FINISH_LOSE_CONFIRM:
357 			_UpdateLoseConfirm();
358 			break;
359 		case FINISH_INVALID:
360 		case FINISH_TOTAL:
361 		default:
362 			if (BATTLE_DEBUG)
363 				cerr << "BATTLE ERROR: In FinishWindow::Update(), the window state was invalid: " << _state << endl;
364 			return;
365 	}
366 } // void FinishWindow::Update()
367 
368 
369 
_UpdateAnnounceWin()370 void FinishWindow::_UpdateAnnounceWin() {
371 //	This block is for gradual text. Currently, battle mode uses full text.
372 // This block causes the game to freeze at the end of battle.
373 /*	if (_finish_outcome.IsFinished() == false) {
374 		_finish_outcome.Update(SystemManager->GetUpdateTime());
375 
376 		if (InputManager->ConfirmPress())
377 			_finish_outcome.ForceFinish();
378 		return;
379 	} */
380 
381 	if (InputManager->ConfirmPress())
382 		_state = FINISH_WIN_SHOW_GROWTH;
383 }
384 
385 // If OK was pressed, just move to the next state
_UpdateWinWaitForOK()386 void FinishWindow::_UpdateWinWaitForOK()
387 {
388 	if (InputManager->ConfirmPress())
389 	{
390 		switch (_state)
391 		{
392 			case FINISH_WIN_SHOW_GROWTH:
393 				_state = FINISH_WIN_COUNTDOWN_GROWTH;
394 				break;
395 			case FINISH_WIN_RESOLVE_GROWTH:
396 				_state = FINISH_WIN_SHOW_SKILLS;
397 				break;
398 			case FINISH_WIN_SHOW_SKILLS:
399 				_state = FINISH_WIN_SHOW_SPOILS;
400 				_ClearLearnedSkills(); //so we don't render them every battle
401 				break;
402 			case FINISH_WIN_SHOW_SPOILS:
403 				_state = FINISH_WIN_COUNTDOWN_SPOILS;
404 				break;
405 			case FINISH_WIN_RESOLVE_SPOILS:
406 				_state = FINISH_WIN_COMPLETE;
407 				break;
408 			default:
409 				if (BATTLE_DEBUG)
410 					cerr << "BATTLE ERROR: In FinishWindow::_UpdateWinWaitForOK(), the window state was invalid: " << _state << endl;
411 				return;
412 		}
413 	}
414 }
415 
_UpdateWinGrowth()416 void FinishWindow::_UpdateWinGrowth() {
417 	static uint32 time_of_next_update = SDL_GetTicks();
418 	uint32 xp_to_add = 1;
419 
420 	if (InputManager->ConfirmPress())
421 	{
422 		xp_to_add = _victory_xp;
423 		_victory_xp = 0;
424 	}
425 	else if (SDL_GetTicks() < time_of_next_update)
426 	{
427 		return;
428 	}
429 	else
430 	{
431 		--_victory_xp;
432 	}
433 
434 	for (uint32 i = 0; i < _characters.size(); ++i)
435 	{
436 		if (_characters[i]->IsAlive())
437 		{
438 			if (_characters[i]->AddExperiencePoints(xp_to_add))
439 			{
440 				do {
441 					//Record growth stats for each character for rendering
442 					//HP
443 					_growth_gained[i][0] += _character_growths[i]->GetHitPointsGrowth();
444 					//SP
445 					_growth_gained[i][1] += _character_growths[i]->GetSkillPointsGrowth();
446 					//STR
447 					_growth_gained[i][2] += _character_growths[i]->GetStrengthGrowth();
448 					//VIG
449 					_growth_gained[i][3] += _character_growths[i]->GetVigorGrowth();
450 					//FOR
451 					_growth_gained[i][4] += _character_growths[i]->GetFortitudeGrowth();
452 					//PRO
453 					_growth_gained[i][5] += _character_growths[i]->GetProtectionGrowth();
454 					//AGI
455 					_growth_gained[i][6] += _character_growths[i]->GetAgilityGrowth();
456 					//EVD
457 					_growth_gained[i][7] += static_cast<int>(_character_growths[i]->GetEvadeGrowth());
458 
459 					if (_character_growths[i]->IsExperienceLevelGained())
460 					{
461 						//Play Sound
462 					}
463 					_character_growths[i]->AcknowledgeGrowth();
464 				} while(_character_growths[i]->IsGrowthDetected());
465 			}
466 		}
467 	}
468 
469 	//We've allocated all the XP
470 	if (!_victory_xp)
471 		_state = FINISH_WIN_RESOLVE_GROWTH;
472 
473 	//Every 50 milliseconds we update
474 	time_of_next_update += 50;
475 }
476 
_UpdateWinSpoils()477 void FinishWindow::_UpdateWinSpoils() {
478 	static uint32 time_of_next_update = SDL_GetTicks();
479 	uint32 money_to_add = 1;
480 
481 	if (InputManager->ConfirmPress())
482 	{
483 		money_to_add = _victory_money;
484 		_victory_money = 0;
485 	}
486 	else if (SDL_GetTicks() < time_of_next_update)
487 	{
488 		return;
489 	}
490 	else
491 	{
492 		--_victory_money;
493 	}
494 
495 	GlobalManager->AddDrunes(money_to_add);
496 
497 	if (!_victory_money)
498 	{
499 		std::map<GlobalObject*, int32>::iterator iter;
500 
501 		for (iter = _victory_items.begin(); iter != _victory_items.end(); ++iter)
502 		{
503 			GlobalManager->AddToInventory(iter->first->GetID(), iter->second);
504 		}
505 
506 		_state = FINISH_WIN_RESOLVE_SPOILS;
507 	}
508 
509 	//Every 50 milliseconds we update
510 	time_of_next_update += 50;
511 }
512 
513 
514 
_UpdateAnnounceLose()515 void FinishWindow::_UpdateAnnounceLose() {
516 	_lose_options.Update();
517 
518 //	This block is for gradual text. Currently, battle mode uses full text.
519 // This block causes the game to freeze at the end of battle.
520 /*	if (_finish_outcome.IsFinished() == false) {
521 		_finish_outcome.Update(SystemManager->GetUpdateTime());
522 
523 		if (InputManager->ConfirmPress())
524 			_finish_outcome.ForceFinish();
525 		return;
526 	} */
527 
528 	if (InputManager->UpPress()) {
529 		_lose_options.InputUp();
530 	}
531 	else if (InputManager->DownPress()) {
532 		_lose_options.InputDown();
533 	}
534 	else if (InputManager->ConfirmPress()) {
535 		switch (_lose_options.GetSelection()) {
536 			case 0: // Retry the battle
537 				// TODO
538 				break;
539 			case 1: // Load from last save point
540 				// TODO
541 				break;
542 			case 2: // Return to main menu
543 			case 3: // Exit game
544 				_state = FINISH_LOSE_CONFIRM;
545 				break;
546 		}
547 	}
548 
549 }
550 
551 
_UpdateLoseConfirm()552 void FinishWindow::_UpdateLoseConfirm() {
553 	if (_lose_options.GetSelection() == 2) {
554 		// Remove all game modes on the stack and return to boot mode
555 		ModeManager->PopAll();
556 		ModeManager->Push(new hoa_boot::BootMode());
557 	}
558 	else {
559 		SystemManager->ExitGame();
560 	}
561 }
562 
563 // ----- DRAW METHODS
564 
Draw()565 void FinishWindow::Draw() {
566 	VideoManager->DisableSceneLighting();
567 	//VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_TOP, VIDEO_BLEND, 0);
568 	//TEMP!
569 	//Two different window arrangements for win and lose would be best
570 	//Win has all the elaborate windows, lose just has the game over options
571 	//MenuWindow::Draw();
572 	//_items_window.Draw();
573 
574 	//TEMP!!!
575 	//Just so everyone has an idea of the potential setup for the finishwindow
576 
577 	switch (_state) {
578 		case FINISH_WIN_ANNOUNCE:
579 			_DrawAnnounceWin();
580 			break;
581 		case FINISH_WIN_SHOW_GROWTH:
582 		case FINISH_WIN_COUNTDOWN_GROWTH:
583 		case FINISH_WIN_RESOLVE_GROWTH:
584 			_character_window[0].Draw();
585 			_character_window[1].Draw();
586 			_character_window[2].Draw();
587 			_character_window[3].Draw();
588 
589 			_xp_and_money_window.Draw();
590 			_DrawWinGrowth();
591 			break;
592 		case FINISH_WIN_SHOW_SKILLS:
593 			_character_window[0].Draw();
594 			_character_window[1].Draw();
595 			_character_window[2].Draw();
596 			_character_window[3].Draw();
597 
598 			_xp_and_money_window.Draw();
599 			_DrawWinSkills();
600 			break;
601 		case FINISH_WIN_SHOW_SPOILS:
602 		case FINISH_WIN_COUNTDOWN_SPOILS:
603 		case FINISH_WIN_RESOLVE_SPOILS:
604 			_items_window.Draw();
605 			_xp_and_money_window.Draw();
606 			_DrawWinSpoils();
607 			break;
608 		case FINISH_LOSE_ANNOUNCE:
609 			_DrawAnnounceLose();
610 			break;
611 		case FINISH_LOSE_CONFIRM:
612 			_DrawLoseConfirm();
613 			break;
614 		case FINISH_WIN_COMPLETE:
615 			break;
616 		case FINISH_INVALID:
617 		case FINISH_TOTAL:
618 		default:
619 			if (BATTLE_DEBUG)
620 				cerr << "BATTLE ERROR: In FinishWindow::Draw(), the window state was invalid: " << _state << endl;
621 			return;
622 	}
623 }
624 
625 
_DrawAnnounceWin()626 void FinishWindow::_DrawAnnounceWin() {
627 	VideoManager->SetDrawFlags(VIDEO_X_CENTER, VIDEO_Y_CENTER, 0);
628 	VideoManager->Move(512.0f, 384.0f);
629 // 	_finish_outcome.Draw();
630 	VideoManager->Text()->Draw(UTranslate("Victory!!!"), TextStyle("title24"));
631 }
632 
633 
634 
_DrawWinGrowth()635 void FinishWindow::_DrawWinGrowth() {
636 	//Draw XP Earned
637 	VideoManager->SetDrawFlags(VIDEO_X_CENTER, VIDEO_Y_CENTER, 0);
638 	VideoManager->Move(496, 683);
639 	VideoManager->Text()->Draw(UTranslate("XP Gained: ") + MakeUnicodeString(NumberToString(_victory_xp)));
640 
641 	//Now draw char info
642 	VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_CENTER, 0);
643 	//VideoManager->Move(265, 580);
644 	VideoManager->Move(270, 595);
645 
646 	ustring display_text;
647 	for (uint32 i = 0; i < _characters.size(); ++i)
648 	{
649 		//Portraits
650 		_char_portraits[i].Draw();
651 
652 		VideoManager->MoveRelative(5,-55);
653 		VideoManager->Text()->Draw(UTranslate("Lv. ") +
654 			MakeUnicodeString(NumberToString(_characters[i]->GetExperienceLevel())));
655 		VideoManager->MoveRelative(0, -15);
656 		VideoManager->Text()->Draw(UTranslate("XP To Next: ") +
657 			MakeUnicodeString(NumberToString(_characters[i]->GetExperienceForNextLevel() - _characters[i]->GetExperiencePoints())));
658 
659 		//First column
660 		//VideoManager->MoveRelative(150, 40);
661 		//VideoManager->MoveRelative(150, 25);
662 		VideoManager->MoveRelative(140, 105);
663 
664 		//HP
665 		display_text = UTranslate("HP: ") +
666 			MakeUnicodeString(NumberToString(_characters[i]->GetMaxHitPoints()));
667 		if (_growth_gained[i][0])
668 		{
669 			display_text += MakeUnicodeString(" (") +
670 			MakeUnicodeString(NumberToString(_growth_gained[i][0])) + MakeUnicodeString(")");
671 		}
672 		VideoManager->Text()->Draw(display_text);
673 
674 		//SP
675 		VideoManager->MoveRelative(0, -26);
676 		display_text = UTranslate("SP: ") +
677 			MakeUnicodeString(NumberToString(_characters[i]->GetMaxSkillPoints()));
678 		if (_growth_gained[i][1])
679 		{
680 			display_text += MakeUnicodeString(" (") +
681 			MakeUnicodeString(NumberToString(_growth_gained[i][1])) + MakeUnicodeString(")");
682 		}
683 		VideoManager->Text()->Draw(display_text);
684 
685 		//STR
686 		VideoManager->MoveRelative(0, -26);
687 		display_text = UTranslate("STR: ") +
688 			MakeUnicodeString(NumberToString(_characters[i]->GetStrength()));
689 		if (_growth_gained[i][2])
690 		{
691 			display_text += MakeUnicodeString(" (") +
692 			MakeUnicodeString(NumberToString(_growth_gained[i][2])) + MakeUnicodeString(")");
693 		}
694 		VideoManager->Text()->Draw(display_text);
695 
696 		//VIG
697 		VideoManager->MoveRelative(0, -26);
698 		display_text = UTranslate("VIG: ") +
699 			MakeUnicodeString(NumberToString(_characters[i]->GetVigor()));
700 		if (_growth_gained[i][3])
701 		{
702 			display_text += MakeUnicodeString(" (") +
703 			MakeUnicodeString(NumberToString(_growth_gained[i][3])) + MakeUnicodeString(")");
704 		}
705 		VideoManager->Text()->Draw(display_text);
706 
707 		//Second Column
708 		//FOR
709 		VideoManager->MoveRelative(155, 78);
710 		display_text = UTranslate("FOR: ") +
711 			MakeUnicodeString(NumberToString(_characters[i]->GetStrength()));
712 		if (_growth_gained[i][4])
713 		{
714 			display_text += MakeUnicodeString(" (") +
715 			MakeUnicodeString(NumberToString(_growth_gained[i][4])) + MakeUnicodeString(")");
716 		}
717 		VideoManager->Text()->Draw(display_text);
718 
719 		//PRO
720 		VideoManager->MoveRelative(0, -26);
721 		display_text = UTranslate("PRO: ") +
722 			MakeUnicodeString(NumberToString(_characters[i]->GetProtection()));
723 		if (_growth_gained[i][5])
724 		{
725 			display_text += MakeUnicodeString(" (") +
726 			MakeUnicodeString(NumberToString(_growth_gained[i][5])) + MakeUnicodeString(")");
727 		}
728 		VideoManager->Text()->Draw(display_text);
729 
730 		//AGI
731 		VideoManager->MoveRelative(0, -26);
732 		display_text = UTranslate("AGI: ") +
733 			MakeUnicodeString(NumberToString(_characters[i]->GetAgility()));
734 		if (_growth_gained[i][6])
735 		{
736 			display_text += MakeUnicodeString(" (") +
737 			MakeUnicodeString(NumberToString(_growth_gained[i][6])) + MakeUnicodeString(")");
738 		}
739 		VideoManager->Text()->Draw(display_text);
740 
741 		//EVD
742 		VideoManager->MoveRelative(0, -26);
743 		display_text = UTranslate("EVD: ") +
744 			MakeUnicodeString(NumberToString(_characters[i]->GetEvade()));
745 		if (_growth_gained[i][7])
746 		{
747 			display_text += MakeUnicodeString(" (") +
748 			MakeUnicodeString(NumberToString(_growth_gained[i][7])) + MakeUnicodeString(")");
749 		}
750 		VideoManager->Text()->Draw(display_text);
751 
752 		VideoManager->MoveRelative(-300,-140 + 43);
753 	}
754 }
755 
_DrawWinSkills()756 void FinishWindow::_DrawWinSkills()
757 {
758 	//Draw XP Earned
759 	VideoManager->SetDrawFlags(VIDEO_X_CENTER, VIDEO_Y_CENTER, 0);
760 	VideoManager->Move(496, 683);
761 	VideoManager->Text()->Draw(UTranslate("XP Gained: ") + MakeUnicodeString(NumberToString(_victory_xp)));
762 
763 	//Now draw char info
764 	VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_CENTER, 0);
765 	//VideoManager->Move(265, 580);
766 	VideoManager->Move(270, 595);
767 
768 	std::vector<GlobalSkill*>* skills_learned = NULL;
769 	ustring display_text;
770 	for (uint32 i = 0; i < _characters.size(); ++i)
771 	{
772 		//Portrait
773 		_char_portraits[i].Draw();
774 		//TEMP
775 		VideoManager->MoveRelative(140, 35);
776 		VideoManager->Text()->Draw(UTranslate("Skills Learned"));
777 		VideoManager->MoveRelative(50, -30);
778 
779 		skills_learned = _character_growths[i]->GetSkillsLearned();
780 
781 		for (uint32 j = 0; j < skills_learned->size(); ++j)
782 		{
783 			VideoManager->Text()->Draw(skills_learned->at(j)->GetName());
784 			VideoManager->MoveRelative(0, -20);
785 		}
786 
787 		VideoManager->MoveRelative(-190, -5 + (20 * (float)(skills_learned->size())) - 140);
788 	}
789 }
790 
_DrawWinSpoils()791 void FinishWindow::_DrawWinSpoils()
792 {
793 	//VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_CENTER, 0);
794 	//VideoManager->Move(496, 683);
795 	//VideoManager->Move(96, 683);
796 	VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_CENTER, 0);
797 	VideoManager->Move(280, 683);
798 	VideoManager->Text()->Draw(UTranslate("Drunes: ") + MakeUnicodeString(NumberToString(_victory_money)));
799 
800 	VideoManager->SetDrawFlags(VIDEO_X_RIGHT, VIDEO_Y_CENTER, 0);
801 	VideoManager->Move(712, 683);
802 	VideoManager->Text()->Draw(MakeUnicodeString("$ ") + MakeUnicodeString(NumberToString(GlobalManager->GetDrunes())));
803 
804 	VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_TOP, 0);
805 	//VideoManager->Move(700, 640);
806 	VideoManager->Move(475, 640);
807 	VideoManager->Text()->Draw(UTranslate("Items"));
808 	//VideoManager->MoveRelative(-140, -25);
809 	VideoManager->MoveRelative(-200, -35);
810 
811 	std::map<GlobalObject*, int32>::iterator iter;
812 
813 	for (iter = _victory_items.begin(); iter != _victory_items.end(); ++iter)
814 	{
815 		VideoManager->Text()->Draw(iter->first->GetName());
816 		VideoManager->SetDrawFlags(VIDEO_X_RIGHT, VIDEO_Y_TOP, 0);
817 		VideoManager->MoveRelative(425, 0);
818 		VideoManager->Text()->Draw(MakeUnicodeString(NumberToString(iter->second)));
819 		VideoManager->MoveRelative(-425, -25);
820 		VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_TOP, 0);
821 	}
822 }
823 
824 
825 
_DrawAnnounceLose()826 void FinishWindow::_DrawAnnounceLose() {
827 
828 	_lose_options.Draw();
829 
830 }
831 
832 
833 
_DrawLoseConfirm()834 void FinishWindow::_DrawLoseConfirm() {
835 
836 }
837 
838 } // namespace private_battle
839 
840 } // namespace hoa_battle
841