X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FVictoryState.cpp;h=831f08eef002b268f50c6c831ce235fa926195cc;hb=467fd239cfa26ba057fd1959ca8908f618cd9287;hp=3516bdeaf5150802642f5022864fe120e3712134;hpb=e1dab8a680a76f8621e967a693dbf2b481ba8f75;p=l2e.git diff --git a/src/battle/states/VictoryState.cpp b/src/battle/states/VictoryState.cpp index 3516bde..831f08e 100644 --- a/src/battle/states/VictoryState.cpp +++ b/src/battle/states/VictoryState.cpp @@ -5,6 +5,9 @@ #include "../Hero.h" #include "../../app/Application.h" #include "../../app/Input.h" +#include "../../common/Capsule.h" +#include "../../common/GameConfig.h" +#include "../../common/GameState.h" #include "../../common/Hero.h" #include "../../math/Vector.h" #include "../../graphics/Font.h" @@ -38,6 +41,8 @@ void VictoryState::LoadResults() { s << "Gets " << battle->GoldReward() << " gold"; lines.push_back(s.str()); + lines.push_back(""); + for (std::vector::const_iterator i(battle->HeroesBegin()), end(battle->HeroesEnd()); i != end; ++i) { @@ -47,6 +52,20 @@ void VictoryState::LoadResults() { s << hero.Name() << " next level " << hero.NextLevel(); lines.push_back(s.str()); } + + if (battle->HasCapsule()) { + const Capsule &capsule = battle->GetCapsule(); + if (capsule.Health() > 0) { + s.str(""); + s << capsule.Name() << " next level " << capsule.Master().NextLevel(); + lines.push_back(s.str()); + } + } + + lines.push_back(""); + s.str(""); + s << parent->Game().state->money << " gold"; + lines.push_back(s.str()); } void VictoryState::OnExitState(SDL_Surface *screen) { @@ -54,7 +73,7 @@ void VictoryState::OnExitState(SDL_Surface *screen) { } void VictoryState::OnResumeState(SDL_Surface *screen) { - timer = GraphicsTimers().StartCountdown(1500); + } void VictoryState::OnPauseState(SDL_Surface *screen) { @@ -77,7 +96,36 @@ void VictoryState::OnResize(int width, int height) { void VictoryState::HandleEvents(const Input &input) { - if (timer.Finished()) { + if (input.JustPressed(Input::ACTION_A)) { + ++cursor; + timer = GraphicsTimers().StartInterval(150); + } else if (input.IsDown(Input::ACTION_A) + && timer.JustHit()) { + if (timer.Iteration() > 3) { + ++cursor; + stalling = false; + } else { + stalling = true; + } + } else if (input.JustPressed(Input::SHOULDER_LEFT)) { + ++cursor; + timer = GraphicsTimers().StartInterval(150); + } else if (input.IsDown(Input::SHOULDER_LEFT) + && timer.JustHit()) { + if (timer.Iteration() > 3) { + ++cursor; + stalling = false; + } else { + stalling = true; + } + } + if (timer.JustHit() + && !input.IsDown(Input::ACTION_A) + && !input.IsDown(Input::SHOULDER_LEFT)) { + timer.Clear(); + stalling = false; + } + if (cursor >= int(lines.size())) { Ctrl().PopState(); // pop self } } @@ -89,6 +137,7 @@ void VictoryState::UpdateWorld(Uint32 deltaT) { void VictoryState::Render(SDL_Surface *screen) { parent->RenderBackground(screen); + parent->RenderHeroes(screen); RenderFrame(screen); RenderLines(screen); } @@ -101,12 +150,31 @@ void VictoryState::RenderFrame(SDL_Surface *screen) { void VictoryState::RenderLines(SDL_Surface *screen) { // naive implementation const Font &font = *parent->Res().normalFont; + const Vector lineBreak = Vector( + 0, font.CharHeight() * 5 / 4); + const int start = cursor > 7 ? cursor - 8 : 0; Vector position = textPosition; - for (vector::const_iterator - i(lines.begin()), end(lines.end()); - i != end; ++i) { - font.DrawString(i->c_str(), screen, position); - position.Y() += font.CharHeight(); + + int end = cursor + 1; + + if (start > 0) { + if (timer.Running() && !stalling) { + position += lineBreak; + const int correction = timer.IterationElapsed(); + if (correction > 0) { + // ++start; + position.Y() -= lineBreak.Y() * correction / timer.TargetTime(); + } else { + --end; + } + } + } + + if (end > int(lines.size())) end = lines.size(); + + for (int i = start; i < end; ++i) { + font.DrawString(lines[i].c_str(), screen, position); + position += lineBreak; } }