spacebox/src/Node.hpp

70 lines
1.4 KiB
C++

#ifndef Node_h_
#define Node_h_
#include <iostream>
#include "glm/vec2.hpp"
#include "json/json.hpp"
#include "SDL.h"
#include "Box.hpp"
#include "filesystem.hpp"
struct Game;
struct Delegate;
struct Display;
struct Input;
struct Node
{
Node *parent;
bool active = true;
Node();
Node(Node*);
void set_parent(Node*);
virtual void reset() { deactivate(); }
virtual void activate() { active = true; }
virtual void deactivate() { active = false; }
bool is_active() const;
nlohmann::json& get_configuration();
Delegate& get_delegate();
const Display& get_display() const;
const SDL_Renderer* get_renderer() const;
SDL_Renderer* get_renderer();
const SDL_Window* get_window() const;
SDL_Window* get_window();
const Input& get_input() const;
Input& get_input();
const Game* get_root() const;
Box get_window_box();
void suppress_input();
void suppress_input_temporarily(int = 0);
void unsuppress_input();
void print_branch();
virtual std::string get_class_name() { return "Node"; };
virtual ~Node();
template<typename T = Game>
T* get_root()
{
if (parent == NULL)
{
return static_cast<T*>(this);
}
else
{
return parent->get_root<T>();
}
}
};
#include "Configuration.hpp"
#include "Delegate.hpp"
#include "Display.hpp"
#include "Input.hpp"
#endif