From 578018607aecfa3e21ec9d05a7ec6e28b9d5cc1c Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 9 Dec 2015 14:32:34 +0100 Subject: [PATCH] Moved decision of which map to load to Config.ini --- resources/DefaultConfig.ini | 1 + src/Game/Game.cpp | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/resources/DefaultConfig.ini b/resources/DefaultConfig.ini index ac7e9ec2..535e109b 100644 --- a/resources/DefaultConfig.ini +++ b/resources/DefaultConfig.ini @@ -1,5 +1,6 @@ [Debug] LogLevel=1 +LoadMap= [Video] Fullscreen=false diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 4dcf0416..38660e73 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -37,6 +37,10 @@ Game::Game(int argc, char* argv[]) // Create a world m_World = new World(); + std::string mapToLoad = m_Config->Get("Debug.LoadMap", ""); + if (!mapToLoad.empty()) { + ResourceManager::Load(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("Schema/Entities/Test.xml")->PopulateWorld(m_World); + std::string mapToLoad = m_Config->Get("Debug.LoadMap", ""); + if (!mapToLoad.empty()) { + delete m_World; + m_World = new World(); + ResourceManager::Release("EntityXMLFile", mapToLoad); + ResourceManager::Load(mapToLoad)->PopulateWorld(m_World); + } } return false;