++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
void VictoryState::RenderLines(SDL_Surface *screen) {
// naive implementation
const Font &font = *parent->Res().normalFont;
+ const Vector<int> lineBreak = Vector<int>(
+ 0, font.CharHeight() * 5 / 4);
+ const int start = cursor > 7 ? cursor - 8 : 0;
Vector<int> 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;
}
}