mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-07 11:34:46 +00:00
Creating a callback type
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user