-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscreen.hh
44 lines (32 loc) · 870 Bytes
/
screen.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef _GRAVITY_SCREEN_HH_
#define _GRAVITY_SCREEN_HH_
#include "widget.hh"
#include "renderer.hh"
#include <SDL2/SDL.h>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
class Screen {
protected:
vector<Widget*> widgets;
public:
Screen(SDL_Window *window) :
window(window)
{}
virtual ~Screen() {
for (auto w : this->widgets)
delete w;
}
SDL_Window *window;
map<string, string> state;
virtual void SwitchScreen(const map<string, string> &lastState) = 0;
virtual void HandleEvent(const SDL_Event &e) = 0;
virtual void HandleWidgetEvent(int event_type, Widget *widget) {}
virtual void Reset() = 0;
virtual void Save(ostream &s) const = 0;
virtual void Load(istream &s) = 0;
virtual void Advance(float dt) = 0;
virtual void Render(Renderer *renderer) = 0;
};
#endif /* _GRAVITY_SCREEN_HH_ */