]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/states/VictoryState.cpp
fade out after victory
[l2e.git] / src / battle / states / VictoryState.cpp
index 59d4495f68c5d4c0c4ef7349b229016235dc83f2..ddc940b4c4d04bcb0ca0bd9e4b4517d09ecdbcb9 100644 (file)
@@ -11,6 +11,7 @@
 #include "../../common/GameState.h"
 #include "../../common/Upgrade.h"
 #include "../../math/Vector.h"
+#include "../../graphics/ColorFade.h"
 #include "../../graphics/Font.h"
 #include "../../graphics/Frame.h"
 
@@ -21,6 +22,7 @@ using app::Application;
 using app::Input;
 using common::GameState;
 using common::Upgrade;
+using graphics::ColorFade;
 using graphics::Font;
 using graphics::Frame;
 using math::Vector;
@@ -201,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);
        }
 }
 
@@ -227,7 +233,7 @@ void VictoryState::RenderLines(SDL_Surface *screen) {
        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;
+       int start = cursor > 7 ? cursor - 8 : 0;
        Vector<int> position = textPosition;
 
        int end = cursor + 1;
@@ -238,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);