/* +------------------------------------------------------+ ____/ \____ /| - Open source game framework licensed to freely use, | \ / / | copy, modify and sell without restriction | +--\ ^__^ /--+ | | | ~/ \~ | | - created for | | ~~~~~~~~~~~~ | +------------------------------------------------------+ | SPACE ~~~~~ | / | ~~~~~~~ BOX |/ +-------------*/ #pragma once #include #include #include "glm/vec2.hpp" #include "json/json.hpp" #include "SDL.h" #include "Log.hpp" #include "filesystem.hpp" class Game; namespace sb { class Delegate; } class Input; class Box; class Configuration; struct Audio; namespace sb { class Display; } /*! * @deprecated Use an alternative to this class if possible because it will be removed soon. Global access to functionality in * this class should instead go through the Game class directly. */ class Node { public: 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; const Configuration& configuration() const; Configuration& configuration(); /*! * @return const reference to the Delegate object */ const sb::Delegate& delegate() const; /*! * @return the Delegate object */ sb::Delegate& delegate(); /*! * @deprecated use Node::delegate */ sb::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(float length = 0.0f); 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; bool active = true; }; /* Add Node class to the sb namespace. This should be the default location, but Node is left in the global namespace * for backward compatibility. */ namespace sb { using ::Node; }