2022-05-28 02:04:10 +02:00

56 lines
980 B
C++

#pragma once
#include "AMI.h"
#include "AppState.h"
#include "MissionSelect.h"
#include "defines.h"
#include <SDL2/SDL.h>
#include <memory>
class SDLManager {
public:
SDLManager();
~SDLManager();
};
#ifndef NDEBUG
class KeyboardHandler {
public:
void handle_keyup(const SDL_Event& ev, AppState& state);
};
#endif // !NDEBUG
class App {
public:
App();
~App();
int run();
private:
void init_sdl();
void init_state();
void handle_events();
void render();
// The SDLManager initializes & quits SDL and its subsystems. Thus, it must be
// the first member of the class, so that its constructor is called before the
// others and its destructor is called after the others.
SDLManager sdl_manager;
std::unique_ptr<AppState> state;
std::unique_ptr<MissionSelect> mission_select;
std::unique_ptr<AMI> ami;
bool running;
SDL_Window* window;
SDL_Renderer* renderer;
#ifndef NDEBUG
KeyboardHandler keyboard_handler;
#endif // !NDEBUG
};