]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/states/RunState.cpp
switched some (x,y) and (w,h) pairs to vectors
[l2e.git] / src / battle / states / RunState.cpp
index 08c45e80cd8fb97f1a35f9cbc88783204da4a4a8..e1f6f4bcdd89058dc65b260849202e872606df54 100644 (file)
 #include "../BattleState.h"
 #include "../../app/Application.h"
 #include "../../app/Input.h"
-#include "../../geometry/operators.h"
-#include "../../geometry/Point.h"
+#include "../../geometry/Vector.h"
+#include "../../graphics/Font.h"
+#include "../../graphics/Frame.h"
+
+#include <cstring>
 
 using app::Application;
 using app::Input;
-using geometry::Point;
 using geometry::Vector;
 
 namespace battle {
@@ -45,8 +47,8 @@ void RunState::Resize(int width, int height) {
 
 void RunState::HandleEvents(const Input &input) {
        if (timer.Finished()) {
+               battle->SetRunaway();
                ctrl->PopState(); // pop self
-               ctrl->PopState(); // pop battle
        }
 }
 
@@ -60,7 +62,18 @@ void RunState::Render(SDL_Surface *screen) {
        battle->RenderBackground(screen, offset);
        battle->RenderMonsters(screen, offset);
        battle->RenderHeroes(screen, offset);
-       // render small tags
+       battle->RenderSmallHeroTags(screen, offset);
+       RenderTitleBar(screen, offset);
+}
+
+void RunState::RenderTitleBar(SDL_Surface *screen, const Vector<int> &offset) {
+       int height(battle->Res().titleFrame->BorderHeight() * 2 + battle->Res().titleFont->CharHeight());
+       battle->Res().titleFrame->Draw(screen, offset, battle->Width(), height);
+
+       Vector<int> textPosition(
+                       (battle->Width() - (std::strlen(battle->Res().escapeText) * battle->Res().titleFont->CharWidth())) / 2,
+                       battle->Res().titleFrame->BorderHeight());
+       battle->Res().titleFont->DrawString(battle->Res().escapeText, screen, textPosition + offset);
 }
 
 }