Moved decision of which map to load to Config.ini

This commit is contained in:
sippeangelo
2015-12-09 14:32:34 +01:00
parent 58d827f7d0
commit 578018607a
2 changed files with 12 additions and 4 deletions
+1
View File
@@ -1,5 +1,6 @@
[Debug]
LogLevel=1
LoadMap=
[Video]
Fullscreen=false
+11 -4
View File
@@ -37,6 +37,10 @@ Game::Game(int argc, char* argv[])
// Create a world
m_World = new World();
std::string mapToLoad = m_Config->Get<std::string>("Debug.LoadMap", "");
if (!mapToLoad.empty()) {
ResourceManager::Load<EntityXMLFile>(mapToLoad)->PopulateWorld(m_World);
}
m_LastTime = glfwGetTime();
@@ -75,10 +79,13 @@ void Game::Tick()
bool Game::testOnKeyUp(const Events::KeyUp& e)
{
if (e.KeyCode == GLFW_KEY_R) {
delete m_World;
m_World = new World();
ResourceManager::Release("EntityXMLFile", "Schema/Entities/Test.xml");
ResourceManager::Load<EntityXMLFile>("Schema/Entities/Test.xml")->PopulateWorld(m_World);
std::string mapToLoad = m_Config->Get<std::string>("Debug.LoadMap", "");
if (!mapToLoad.empty()) {
delete m_World;
m_World = new World();
ResourceManager::Release("EntityXMLFile", mapToLoad);
ResourceManager::Load<EntityXMLFile>(mapToLoad)->PopulateWorld(m_World);
}
}
return false;