115 lines
2.6 KiB
C++
115 lines
2.6 KiB
C++
/* +------------------------------------------------------+
|
|
____/ \____ /| - Open source game framework licensed to freely use, |
|
|
\ / / | copy, modify and sell without restriction |
|
|
+--\ ^__^ /--+ | |
|
|
| ~/ \~ | | - created for <https://foam.shampoo.ooo> |
|
|
| ~~~~~~~~~~~~ | +------------------------------------------------------+
|
|
| SPACE ~~~~~ | /
|
|
| ~~~~~~~ BOX |/
|
|
+-------------*/
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <iostream>
|
|
#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<typename T = Game>
|
|
T* get_root()
|
|
{
|
|
if (parent == nullptr)
|
|
{
|
|
return static_cast<T*>(this);
|
|
}
|
|
else
|
|
{
|
|
return parent->get_root<T>();
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|