#include "../Hero.h"
#include "../../app/Application.h"
#include "../../app/Input.h"
+#include "../../common/GameConfig.h"
+#include "../../common/GameState.h"
#include "../../common/Hero.h"
#include "../../math/Vector.h"
#include "../../graphics/Font.h"
s << hero.Name() << " next level " << hero.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) {
}
void VictoryState::OnResumeState(SDL_Surface *screen) {
- timer = GraphicsTimers().StartCountdown(1500);
+
}
void VictoryState::OnPauseState(SDL_Surface *screen) {
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()
+ && timer.Iteration() > 3) {
+ ++cursor;
+ } 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;
+ }
+ if (!input.IsDown(Input::ACTION_A)
+ && !input.IsDown(Input::SHOULDER_LEFT)) {
+ timer.Clear();
+ }
+ if (cursor >= int(lines.size())) {
Ctrl().PopState(); // pop self
}
}
void VictoryState::Render(SDL_Surface *screen) {
parent->RenderBackground(screen);
+ parent->RenderHeroes(screen);
RenderFrame(screen);
RenderLines(screen);
}
// naive implementation
const Font &font = *parent->Res().normalFont;
Vector<int> position = textPosition;
- for (vector<string>::const_iterator
- i(lines.begin()), end(lines.end());
- i != end; ++i) {
- font.DrawString(i->c_str(), screen, position);
+ for (int i = 0; i <= cursor && i < int(lines.size()); ++i) {
+ font.DrawString(lines[i].c_str(), screen, position);
position.Y() += font.CharHeight();
}
}