Creating a callback type

This commit is contained in:
Zoe Roux
2021-05-21 16:02:00 +02:00
parent 2fcb33a39e
commit 2be7c36902
10 changed files with 62 additions and 116 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ namespace WAL
void Scene::removeAll(std::function<bool (const Entity &)> &predicate)
{
this->_entities.erase(std::remove_if(this->_entities.begin(), this->_entities.end(), predicate), this->_entities.end());
// this->_entities.erase(std::remove_if(this->_entities.begin(), this->_entities.end(), predicate), this->_entities.end());
}
}
-32
View File
@@ -1,32 +0,0 @@
//
// Created by Zoe Roux on 2021-05-14.
//
#include "SceneManager.hpp"
namespace WAL
{
Scene &WAL::SceneManager::addScene(WAL::Scene &&scene)
{
this->_scenes.push_front(scene);
return this->getCurrent();
}
Scene &SceneManager::addBackScene(Scene &&scene)
{
this->_scenes.insert(++this->_scenes.begin(), scene);
return *(this->_scenes.begin() + 1);
}
Scene &SceneManager::getCurrent()
{
if (this->_scenes.empty())
throw NotFoundError("No scene exists.");
return this->_scenes.front();
}
void SceneManager::closeCurrent()
{
this->_scenes.pop_front();
}
}
-42
View File
@@ -1,42 +0,0 @@
//
// Created by Zoe Roux on 2021-05-14.
//
#pragma once
#include <queue>
#include "Scene/Scene.hpp"
namespace WAL
{
//! @brief A class to manage scenes
class SceneManager
{
private:
std::deque<Scene> _scenes = {};
public:
//! @brief Add a scene to the container and move to it.
//! @return The newly added scene, to chain call.
Scene &addScene(Scene &&scene);
//! @brief Add a scene before the current scene. This could be useful for lobbies or scene where the next scene can be constructed.
//! @return The newly added scene, to chain call.
Scene &addBackScene(Scene &&scene);
//! @breif Get the current scene
Scene &getCurrent();
//! @brief Remove the current scene and switch to the previous scene on the stack.
void closeCurrent();
//! @brief A default constructor
SceneManager() = default;
//! @brief A scene manager is copy constructable
SceneManager(const SceneManager &) = default;
//! @brief A default destructor.
~SceneManager() = default;
//! @brief A scene manager is assignable
SceneManager &operator=(const SceneManager &) = default;
};
}