]> git.localhorst.tv Git - l2e.git/commitdiff
show battle results interactively
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 6 Feb 2013 07:01:45 +0000 (08:01 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 6 Feb 2013 07:01:45 +0000 (08:01 +0100)
src/battle/BattleState.h
src/battle/states/VictoryState.cpp
src/battle/states/VictoryState.h

index cfd344dea4bce431b8f9a67adb534d1097a23520..24b7c94d5c6fbf6bc4365625d15953bf6fcfff26 100644 (file)
@@ -61,6 +61,7 @@ public:
 public:
        Battle &GetBattle() { return battle; }
        const Battle &GetBattle() const { return battle; }
+       const common::GameConfig &Game() const { return *game; }
        const Resources &Res() const { return *res; }
        AttackTypeMenu &GetAttackTypeMenu() { return attackTypeMenu; }
        MoveMenu &GetMoveMenu() { return moveMenu; }
index 3516bdeaf5150802642f5022864fe120e3712134..dca0bf2ee3da96bc727be6ee793c8fd58246007b 100644 (file)
@@ -5,6 +5,8 @@
 #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"
@@ -47,6 +49,11 @@ void VictoryState::LoadResults() {
                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) {
@@ -54,7 +61,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 +84,26 @@ 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()
+                       && 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
        }
 }
@@ -89,6 +115,7 @@ void VictoryState::UpdateWorld(Uint32 deltaT) {
 
 void VictoryState::Render(SDL_Surface *screen) {
        parent->RenderBackground(screen);
+       parent->RenderHeroes(screen);
        RenderFrame(screen);
        RenderLines(screen);
 }
@@ -102,10 +129,8 @@ void VictoryState::RenderLines(SDL_Surface *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();
        }
 }
index bb872a2774adf314370bca421dbbd8810a1eb2e5..d14ec76e9a9c69467862558bb99aaf9f646d5c04 100644 (file)
@@ -22,7 +22,8 @@ public:
                        Battle *battle,
                        BattleState *parent)
        : battle(battle)
-       , parent(parent) { }
+       , parent(parent)
+       , cursor(0) { }
 
 public:
        virtual void HandleEvents(const app::Input &);
@@ -50,6 +51,7 @@ private:
        math::Vector<int> framePosition;
        math::Vector<int> frameSize;
        math::Vector<int> textPosition;
+       int cursor;
 
 };