X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FVictoryState.cpp;h=831f08eef002b268f50c6c831ce235fa926195cc;hb=467fd239cfa26ba057fd1959ca8908f618cd9287;hp=c1e5ea422c646826c12ca0aa34b46540230dc115;hpb=c97ea32c4101fcdadedbfa5eabf8098210306b4b;p=l2e.git diff --git a/src/battle/states/VictoryState.cpp b/src/battle/states/VictoryState.cpp index c1e5ea4..831f08e 100644 --- a/src/battle/states/VictoryState.cpp +++ b/src/battle/states/VictoryState.cpp @@ -100,20 +100,30 @@ void VictoryState::HandleEvents(const Input &input) { ++cursor; timer = GraphicsTimers().StartInterval(150); } else if (input.IsDown(Input::ACTION_A) - && timer.JustHit() - && timer.Iteration() > 3) { - ++cursor; + && 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() - && timer.Iteration() > 3) { - ++cursor; + && timer.JustHit()) { + if (timer.Iteration() > 3) { + ++cursor; + stalling = false; + } else { + stalling = true; + } } - if (!input.IsDown(Input::ACTION_A) + 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 @@ -140,10 +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 (int i = 0; i <= cursor && i < int(lines.size()); ++i) { + + 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.Y() += font.CharHeight(); + position += lineBreak; } }