/* /\ +--------------------------------------------------------------+ ____/ \____ /| - zlib/MIT/Unlicenced game framework licensed to freely use, | \ / / | copy, and modify without restriction | +--\ ^__^ /--+ | | | ~/ \~ | | - originally created at [http://nugget.fun] | | ~~~~~~~~~~~~ | +--------------------------------------------------------------+ | SPACE ~~~~~ | / | ~~~~~~~ BOX |/ +-------------*/ #ifndef SB_NODE_H_ #define SB_NODE_H_ #include #include #include "glm/vec2.hpp" #include "json/json.hpp" #include "SDL.h" #include "Log.hpp" #include "filesystem.hpp" class Game; class Delegate; class Input; class Box; struct Audio; namespace sb { class Display; } class Node { public: Node(); Node(Node*); void set_parent(Node*); virtual void reset() { deactivate(); } virtual void activate() { active = true; } virtual void deactivate() { active = false; } void set_canvas(SDL_Texture*); SDL_Texture* get_canvas(); bool is_active() const; const nlohmann::json& configuration() const; nlohmann::json& configuration(); Delegate& get_delegate(); const sb::Display& get_display() const; const SDL_Renderer* get_renderer() const; SDL_Renderer* get_renderer(); const SDL_Window* window() const; SDL_Window* window(); const Input& get_input() const; Input& get_input(); Audio& get_audio(); const Game* get_root() const; Box window_box(bool = false); void suppress_input(); void suppress_input_temporarily(int = 0); void unsuppress_input(); const std::string get_branch_as_string() const; virtual std::string class_name() const { return "Node"; }; virtual ~Node(); template T* get_root() { if (parent == nullptr) { return static_cast(this); } else { return parent->get_root(); } } private: Node* parent; std::shared_ptr canvas; bool active = true; }; #endif