3 #include "../BattleState.h"
4 #include "../../app/Application.h"
5 #include "../../app/Input.h"
6 #include "../../math/Vector.h"
7 #include "../../graphics/Font.h"
8 #include "../../graphics/Frame.h"
12 using app::Application;
15 using graphics::Frame;
21 void RunState::OnEnterState(SDL_Surface *screen) {
22 OnResize(screen->w, screen->h);
25 void RunState::OnExitState(SDL_Surface *screen) {
29 void RunState::OnResumeState(SDL_Surface *screen) {
30 timer = GraphicsTimers().StartCountdown(2500);
33 void RunState::OnPauseState(SDL_Surface *screen) {
38 void RunState::OnResize(int width, int height) {
39 const Resources &res = battle->Res();
40 const Frame &frame = *res.titleFrame;
41 const Font &font = *res.titleFont;
43 framePosition = battle->ScreenOffset();
44 frameSize = Vector<int> (
46 frame.BorderHeight() * 2 + font.CharHeight());
48 textPosition = Vector<int>(
49 (battle->Width() - strlen(res.escapeText) * font.CharWidth()) / 2,
50 frame.BorderHeight());
54 void RunState::HandleEvents(const Input &input) {
55 if (timer.Finished()) {
57 Ctrl().PopState(); // pop self
62 void RunState::UpdateWorld(Uint32 deltaT) {
66 void RunState::Render(SDL_Surface *screen) {
67 battle->RenderBackground(screen);
68 battle->RenderMonsters(screen);
69 battle->RenderHeroes(screen);
70 battle->RenderSmallHeroTags(screen);
71 RenderTitleBar(screen);
74 void RunState::RenderTitleBar(SDL_Surface *screen) {
75 const Resources &res = battle->Res();
76 res.titleFrame->Draw(screen, framePosition, frameSize.X(), frameSize.Y());
77 res.titleFont->DrawString(res.escapeText, screen, textPosition);