aboutsummaryrefslogtreecommitdiff
path: root/src/crepe
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe')
-rw-r--r--src/crepe/api/Scene.cpp4
-rw-r--r--src/crepe/api/Scene.h9
-rw-r--r--src/crepe/api/SceneManager.cpp2
-rw-r--r--src/crepe/api/SceneManager.h2
-rw-r--r--src/crepe/api/SceneManager.hpp6
5 files changed, 12 insertions, 11 deletions
diff --git a/src/crepe/api/Scene.cpp b/src/crepe/api/Scene.cpp
index 88aa82d..849945e 100644
--- a/src/crepe/api/Scene.cpp
+++ b/src/crepe/api/Scene.cpp
@@ -2,6 +2,4 @@
using namespace crepe;
-Scene::Scene(ComponentManager & mgr, const std::string & name)
- : component_manager(mgr),
- name(name) {}
+Scene::Scene(ComponentManager & mgr) : component_manager(mgr) {}
diff --git a/src/crepe/api/Scene.h b/src/crepe/api/Scene.h
index 6647135..45595c7 100644
--- a/src/crepe/api/Scene.h
+++ b/src/crepe/api/Scene.h
@@ -19,7 +19,7 @@ protected:
* \param mgr Reference to the ComponentManager
* \param name Name of the scene
*/
- Scene(ComponentManager & mgr, const std::string & name);
+ Scene(ComponentManager & mgr);
//! SceneManager instances Scene
friend class SceneManager;
@@ -29,8 +29,11 @@ public:
public:
//! Load the scene
virtual void load_scene() = 0;
- //! The scene name
- const std::string name;
+ /**
+ * \brief Get the scene's name
+ * \return The scene's name
+ */
+ virtual std::string get_name() = 0;
protected:
//! Reference to the ComponentManager
diff --git a/src/crepe/api/SceneManager.cpp b/src/crepe/api/SceneManager.cpp
index 7fb5cb0..1f783ad 100644
--- a/src/crepe/api/SceneManager.cpp
+++ b/src/crepe/api/SceneManager.cpp
@@ -18,7 +18,7 @@ void SceneManager::load_next_scene() {
auto it = find_if(this->scenes.begin(), this->scenes.end(),
[&next_scene = this->next_scene](unique_ptr<Scene> & scene) {
- return scene->name == next_scene;
+ return scene.get()->get_name() == next_scene;
});
// next scene not found
diff --git a/src/crepe/api/SceneManager.h b/src/crepe/api/SceneManager.h
index 16d6004..ebf77e7 100644
--- a/src/crepe/api/SceneManager.h
+++ b/src/crepe/api/SceneManager.h
@@ -29,7 +29,7 @@ public:
* \param name Name of new scene
*/
template <typename T>
- void add_scene(const std::string & name);
+ void add_scene();
/**
* \brief Set the next scene
*
diff --git a/src/crepe/api/SceneManager.hpp b/src/crepe/api/SceneManager.hpp
index 714f690..94e5946 100644
--- a/src/crepe/api/SceneManager.hpp
+++ b/src/crepe/api/SceneManager.hpp
@@ -5,16 +5,16 @@
namespace crepe {
template <typename T>
-void SceneManager::add_scene(const std::string & name) {
+void SceneManager::add_scene() {
using namespace std;
static_assert(is_base_of<Scene, T>::value, "T must be derived from Scene");
- Scene * scene = new T(this->component_manager, name);
+ Scene * scene = new T(this->component_manager);
this->scenes.emplace_back(unique_ptr<Scene>(scene));
// The first scene added, is the one that will be loaded at the beginning
if (next_scene.empty()) {
- next_scene = name;
+ next_scene = scene->get_name();
}
}