aboutsummaryrefslogtreecommitdiffstats
path: root/include/game.h
blob: 0ee63aa7a92099c4cd7da77f0c6c9917441b87d7 (plain)
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
#ifndef POSTMODERN_GAME_H
#define POSTMODERN_GAME_H 1

#include <string>
#include <memory>
#include <unordered_map>
#include <deque>
#include <termios.h>

#include "screen.h"

class Game {
private:
    static bool m_running;

    static std::unordered_map<std::string, std::shared_ptr<Screen>> m_screens;
    static std::deque<std::weak_ptr<Screen>> m_order;
    static bool m_dirty;

    static void update();
    static void render();
protected:
public:
    static void init();
    static void loop();

    static void addScreen(const std::string &key, std::shared_ptr<Screen> value);
    static bool pushScreen(const std::string &key);
    static bool popScreen();
    static bool popUpto(const std::string &key);
    static bool popUptoIncluding(const std::string &key);
    static void popAll();

    static void stop() { m_running = false; }
};

#endif