![]() |
Kale
|
#include <Scene.hpp>
Public Member Functions | |
Scene () | |
Scene (const std::string &filename) | |
const std::list< std::shared_ptr< Node > > & | getNodes () const |
Color | getBgColor () const |
const Camera & | getCamera () const |
Vector2f | getViewport () const |
Rect | getSceneBounds () const |
![]() | |
virtual void | onWindowLostFocus () |
virtual void | onWindowGainedFocus () |
virtual void | onControllerConnect (unsigned int controller) |
virtual void | onControllerDisconnect (unsigned int controller) |
virtual void | onControllerButtonPress (unsigned int controller, ControllerButton button) |
virtual void | onControllerButtonRelease (unsigned int controller, ControllerButton button) |
virtual void | onControllerHandle (unsigned int controller, ControllerAxis handle, float position) |
virtual void | onControllerJoystick (unsigned int controller, ControllerAxis joystick, Vector2f position) |
virtual void | onKeyPress (Key key) |
virtual void | onKeyRelease (Key key) |
virtual void | onMouseMove (Vector2f pos) |
virtual void | onMouseScroll (float scroll) |
virtual void | onLeftClick () |
virtual void | onMiddleClick () |
virtual void | onRightClick () |
virtual void | onLeftClickRelease () |
virtual void | onMiddleClickRelease () |
virtual void | onRightClickRelease () |
virtual void | onTouchBegin (unsigned int touch, Vector2f pos) |
virtual void | onTouchMove (unsigned int touch, Vector2f pos) |
virtual void | onTouchEnd (unsigned int touch) |
Static Public Member Functions | |
static void | addNodeSaveStateConstructor (const std::string &key, std::function< std::shared_ptr< Node >(JSON)> constructor) |
Protected Member Functions | |
template<typename T > | |
void | addNode (std::shared_ptr< T > &node) |
void | removeNode (std::shared_ptr< Node > &node) |
template<typename T > | |
void | removeNode (std::shared_ptr< T > &node) |
virtual void | onPresent () |
virtual void | onSceneChange () |
virtual void | onUpdate (size_t threadNum, float deltaTime) |
virtual void | onPreUpdate (size_t threadNum, float deltaTime) |
void | onWindowResize (Vector2ui oldSize, Vector2ui newSize) override |
Protected Attributes | |
Vector4f | bgColor = 0xFFFFFF |
Camera | camera |
Vector2f | viewport |
Rect | sceneBounds |
Private Member Functions | |
void | render (float deltaTime) const |
void | update (size_t threadNum, float deltaTime) |
void | updateNodeStructures () |
Private Attributes | |
std::list< std::shared_ptr< Node > > | nodes |
std::vector< std::list< std::shared_ptr< Node > > > | updateNodes |
std::vector< std::list< std::shared_ptr< Node > > > | preUpdateNodes |
std::vector< std::pair< float, float > > | threadedNodePerformanceTimes |
std::queue< std::shared_ptr< Node > > | nodesToAdd |
std::queue< std::shared_ptr< Node > > | nodesToRemove |
std::mutex | nodeQueueUpdateMutex |
std::mutex | nodePreUpdateMutex |
std::condition_variable | nodePreUpdateCondVar |
size_t | nodesPreUpdated |
size_t | generation |
Transform | worldToScreen |
Static Private Attributes | |
static std::unordered_map< std::string, std::function< std::shared_ptr< Node >(JSON)> > | nodeMap |
Friends | |
class | Application |
class | Node |
The main scene class for the game This class handles rendering and nodes management
Scene::Scene | ( | const std::string & | filename | ) |
Color Scene::getBgColor | ( | ) | const |
const Camera & Scene::getCamera | ( | ) | const |
const std::list< std::shared_ptr< Node > > & Scene::getNodes | ( | ) | const |
Rect Scene::getSceneBounds | ( | ) | const |
Due to the engine being scaled from 1080p, when dealing with wide or tall windows the screen space may start from a negative number or an unusually large number. This function returns the scene bounds (the x coordinates of the left and right points on the scene display)
Vector2f Scene::getViewport | ( | ) | const |
|
protectedvirtual |
|
protectedvirtual |
Called before all nodes are pre updated. Do NOT write code directly in here, this function is called once on each thread every frame. If you must run code every frame outside of a node, then make sure you're only running your required code on one thread by using an if statement on threadNum.
threadNum | The thread this function is being called on |
deltaTime | The microseconds since the last update |
|
protectedvirtual |
|
protectedvirtual |
Called before all nodes are updated. Do NOT write code directly in here, this function is called once on each thread every frame. If you must run code every frame outside of a node, then make sure you're only running your required code on one thread by using an if statement on threadNum.
threadNum | The thread this function is being called on |
deltaTime | The microseconds since the last update |
Called when the event is fired
Reimplemented from Kale::EventHandler.
|
protected |
Removes a node from the scene
node | The node to remove |
|
private |
|
private |
|
private |
|
friend |
|
protected |
|
protected |
|
private |
|
inlinestaticprivate |
A map of strings to a constructor taking a JSON to initialize a node. All nodes capable of save states must be present in this map prior to the first scene's presentation. The best way to do this is via a node setup function, which can be added from application's onBegin to Application.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
protected |
|
private |
|
private |
|
protected |
The viewport of the world (the width and height of the screen in the world's coordinates) This always has a height of 1080p and the width is dependant on the screen's aspect ratio. It is recommended to code all nodes based off of the 1080p height and let the engine do the scaling
|
private |