]> git.localhorst.tv Git - l2e.git/blobdiff - src/app/Application.cpp
made application and battle state resizable
[l2e.git] / src / app / Application.cpp
index 37f3135c48d8f4d3c92d1b323481f343d913157f..e06e231d785535488554f9b09975410f8942f667 100644 (file)
@@ -13,7 +13,7 @@
 
 namespace app {
 
-Application::Application(SDL_Surface *screen, State *initialState)
+Application::Application(sdl::InitScreen *screen, State *initialState)
 : screen(screen)
 , states()
 , last(SDL_GetTicks()) {
@@ -42,7 +42,7 @@ void Application::PushState(State *s) {
 
 void Application::RealPushState(State *s) {
        states.push(s);
-       s->EnterState(*this, screen);
+       s->EnterState(*this, screen->Screen());
 }
 
 void Application::PopState(void) {
@@ -94,6 +94,10 @@ void Application::HandleEvents(void) {
                        case SDL_QUIT:
                                PopAllStates();
                                break;
+                       case SDL_VIDEORESIZE:
+                               screen->Resize(event.resize.w, event.resize.h);
+                               CurrentState()->Resize(event.resize.w, event.resize.h);
+                               break;
                        default:
                                CurrentState()->HandleEvent(event);
                                break;
@@ -110,8 +114,8 @@ void Application::UpdateWorld(Uint32 deltaT) {
 
 void Application::Render(void) {
        if (!CurrentState()) return;
-       CurrentState()->Render(screen);
-       SDL_Flip(screen);
+       CurrentState()->Render(screen->Screen());
+       screen->Flip();
 }
 
 }