X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FVictoryState.cpp;h=ddc940b4c4d04bcb0ca0bd9e4b4517d09ecdbcb9;hb=9a7ac49b7e3b7cd4a09b016ceec116830a3458f9;hp=e2cc99fb27cc3e7799d0dde3728958c4a1f45538;hpb=b9e715649b41cb69ea1b2d2a588522541eb87b46;p=l2e.git diff --git a/src/battle/states/VictoryState.cpp b/src/battle/states/VictoryState.cpp index e2cc99f..ddc940b 100644 --- a/src/battle/states/VictoryState.cpp +++ b/src/battle/states/VictoryState.cpp @@ -3,6 +3,7 @@ #include "../Battle.h" #include "../BattleState.h" #include "../Hero.h" +#include "../Resources.h" #include "../../app/Application.h" #include "../../app/Input.h" #include "../../common/Capsule.h" @@ -10,19 +11,27 @@ #include "../../common/GameState.h" #include "../../common/Upgrade.h" #include "../../math/Vector.h" +#include "../../graphics/ColorFade.h" #include "../../graphics/Font.h" #include "../../graphics/Frame.h" +#include #include using app::Application; using app::Input; using common::GameState; using common::Upgrade; +using graphics::ColorFade; using graphics::Font; using graphics::Frame; using math::Vector; +using std::left; +using std::right; +using std::setfill; +using std::setw; using std::string; +using std::stringstream; using std::vector; namespace battle { @@ -33,15 +42,19 @@ void VictoryState::OnEnterState(SDL_Surface *screen) { } void VictoryState::LoadResults() { - // TODO: localization + const Resources &res = parent->Res(); lines.clear(); - std::stringstream s; - s << "Gets " << battle->ExpReward() << " EXP"; + stringstream s; + s << res.victoryGetsText << ' ' + << battle->ExpReward() << ' ' + << res.victoryExpText << '.'; lines.push_back(s.str()); s.str(""); - s << "Gets " << battle->GoldReward() << " gold"; + s << res.victoryGetsText << ' ' + << battle->GoldReward() << ' ' + << res.victoryGoldText << '.'; lines.push_back(s.str()); lines.push_back(""); @@ -49,55 +62,82 @@ void VictoryState::LoadResults() { GameState &state = *parent->Game().state; vector upgrade; battle->ApplyRewards(state, upgrade); - for (std::vector::const_iterator + for (vector::const_iterator i(upgrade.begin()), end(upgrade.end()); i != end; ++i) { LoadResult(*i, lines); } + s.str(""); + s << state.money << ' ' << res.victoryGoldText; + string goldStr = s.str(); + lines.push_back(""); s.str(""); - s << state.money << " gold"; + s << right << setw(28) << setfill(' ') << goldStr; lines.push_back(s.str()); } void VictoryState::LoadResult( const Upgrade &u, vector &lines) { - std::stringstream s; + const Resources &res = parent->Res(); + stringstream s; switch (u.GetType()) { case Upgrade::LEVEL_UP: - s << u.Name() << " levels up."; + s << left << setw(6) << setfill(' ') << u.Name() + << res.victoryLevelUpText << '.'; break; case Upgrade::MAX_HEALTH: - s << "Max. HP increases by " << u.Amount(); + s << res.victoryMHPText << ' ' + << res.victoryUpgradeText << ' ' + << u.Amount() << '.'; break; case Upgrade::MAX_MAGIC: - s << "Max. MP increases by " << u.Amount(); + s << res.victoryMMPText << ' ' + << res.victoryUpgradeText << ' ' + << u.Amount() << '.'; break; case Upgrade::ATTACK: - s << "ATP increases by " << u.Amount(); + s << res.victoryATPText << ' ' + << res.victoryUpgradeText << ' ' + << u.Amount() << '.'; break; case Upgrade::DEFENSE: - s << "DFP increases by " << u.Amount(); + s << res.victoryDFPText << ' ' + << res.victoryUpgradeText << ' ' + << u.Amount() << '.'; break; case Upgrade::STRENGTH: - s << "STR increases by " << u.Amount(); + s << res.victorySTRText << ' ' + << res.victoryUpgradeText << ' ' + << u.Amount() << '.'; break; case Upgrade::AGILITY: - s << "AGL increases by " << u.Amount(); + s << res.victoryAGLText << ' ' + << res.victoryUpgradeText << ' ' + << u.Amount() << '.'; break; case Upgrade::INTELLIGENCE: - s << "INT increases by " << u.Amount(); + s << res.victoryINTText << ' ' + << res.victoryUpgradeText << ' ' + << u.Amount() << '.'; break; case Upgrade::GUT: - s << "GUT increases by " << u.Amount(); + s << res.victoryGUTText << ' ' + << res.victoryUpgradeText << ' ' + << u.Amount() << '.'; break; case Upgrade::MAGIC_RESISTANCE: - s << "MGR increases by " << u.Amount(); + s << res.victoryMGRText << ' ' + << res.victoryUpgradeText << ' ' + << u.Amount() << '.'; break; case Upgrade::LEVEL_NEXT: - s << u.Name() << " next level " << u.Amount(); + s << setw(7) << setfill(' ') + << left << u.Name() << ' ' + << res.victoryNextLevelText + << ' ' << u.Amount(); break; default: s << "unknown upgrade type " << u.GetType(); @@ -163,7 +203,11 @@ void VictoryState::HandleEvents(const Input &input) { stalling = false; } if (cursor >= int(lines.size())) { - Ctrl().PopState(); // pop self + timer.Clear(); + ColorFade *fade = new ColorFade(this, 0, 650); + fade->SetLeadInTime(150); + fade->SetDoublePop(); + Ctrl().PushState(fade); } } @@ -189,7 +233,7 @@ void VictoryState::RenderLines(SDL_Surface *screen) { const Font &font = *parent->Res().normalFont; const Vector lineBreak = Vector( 0, font.CharHeight() * 5 / 4); - const int start = cursor > 7 ? cursor - 8 : 0; + int start = cursor > 7 ? cursor - 8 : 0; Vector position = textPosition; int end = cursor + 1; @@ -200,13 +244,17 @@ void VictoryState::RenderLines(SDL_Surface *screen) { position += lineBreak; const int correction = timer.IterationElapsed(); if (correction > 0) { - // ++start; position.Y() -= lineBreak.Y() * correction / timer.TargetTime(); } } } - if (end > int(lines.size())) end = lines.size(); + if (end > int(lines.size())) { + end = lines.size(); + } + if (start > int(lines.size()) - 9) { + start = lines.size() - 9; + } for (int i = start; i < end; ++i) { font.DrawString(lines[i].c_str(), screen, position);