<commit_before>﻿#include "stdafx.hpp"

#include "Scene/SceneManager.hpp"

#include "Cameras/CameraManager.hpp"
#include "FlexEngine.hpp"
#include "Graphics/Renderer.hpp"
#include "Helpers.hpp"
#include "Scene/BaseScene.hpp"

namespace flex
{
	SceneManager::SceneManager() :
		m_SavedDirStr(RelativePathToAbsolute(RESOURCE_LOCATION "scenes/saved")),
		m_DefaultDirStr(RelativePathToAbsolute(RESOURCE_LOCATION "scenes/default"))
	{
		if (!DirectoryExists(m_SavedDirStr))
		{
			CreateDirectoryRecursive(m_SavedDirStr);
		}
	}

	SceneManager::~SceneManager()
	{
	}

	void SceneManager::AddScene(BaseScene* newScene)
	{
		bool unique = true;
		std::for_each(m_Scenes.begin(), m_Scenes.end(), [&unique, newScene](BaseScene* scene) mutable
		{
			if (scene->GetRelativeFilePath().compare(newScene->GetRelativeFilePath()) == 0)
			{
				unique = false;
			}
		});

		if (unique)
		{
			m_Scenes.push_back(newScene);
		}
		else
		{
			PrintError("Attempt to add already existing scene to SceneManager: %s\n", newScene->GetName().c_str());
		}
	}

	void SceneManager::InitializeCurrentScene()
	{
		assert(!m_Scenes.empty());

		//g_EngineInstance->PreSceneChange();

		CurrentScene()->Initialize();

		g_Renderer->OnPreSceneChange();
		g_EngineInstance->OnSceneChanged();
		g_CameraManager->OnSceneChanged();
		g_Renderer->OnPostSceneChange();
	}

	void SceneManager::PostInitializeCurrentScene()
	{
		assert(!m_Scenes.empty());

		CurrentScene()->PostInitialize();

		std::string currentSceneName = CurrentScene()->GetName();
		Print("Loaded scene %s\n", currentSceneName.c_str());
	}

	void SceneManager::RemoveScene(BaseScene* scene)
	{<commit_msg>Fix crash occurring when no common.ini exists<commit_after>﻿#include "stdafx.hpp"

#include "Scene/SceneManager.hpp"

#include "Cameras/CameraManager.hpp"
#include "FlexEngine.hpp"
#include "Graphics/Renderer.hpp"
#include "Helpers.hpp"
#include "Scene/BaseScene.hpp"

namespace flex
{
	SceneManager::SceneManager() :
		m_SavedDirStr(RelativePathToAbsolute(RESOURCE_LOCATION "scenes/saved")),
		m_DefaultDirStr(RelativePathToAbsolute(RESOURCE_LOCATION "scenes/default"))
	{
		if (!DirectoryExists(m_SavedDirStr))
		{
			CreateDirectoryRecursive(m_SavedDirStr);
		}
	}

	SceneManager::~SceneManager()
	{
	}

	void SceneManager::AddScene(BaseScene* newScene)
	{
		bool unique = true;
		std::for_each(m_Scenes.begin(), m_Scenes.end(), [&unique, newScene](BaseScene* scene) mutable
		{
			if (scene->GetRelativeFilePath().compare(newScene->GetRelativeFilePath()) == 0)
			{
				unique = false;
			}
		});

		if (unique)
		{
			m_Scenes.push_back(newScene);
		}
		else
		{
			PrintError("Attempt to add already existing scene to SceneManager: %s\n", newScene->GetName().c_str());
		}
	}

	void SceneManager::InitializeCurrentScene()
	{
		assert(!m_Scenes.empty());

		//g_EngineInstance->PreSceneChange();

		if (m_CurrentSceneIndex == InvalidID)
		{
			m_CurrentSceneIndex = 0;
		}

		CurrentScene()->Initialize();

		g_Renderer->OnPreSceneChange();
		g_EngineInstance->OnSceneChanged();
		g_CameraManager->OnSceneChanged();
		g_Renderer->OnPostSceneChange();
	}

	void SceneManager::PostInitializeCurrentScene()
	{
		assert(!m_Scenes.empty());

		CurrentScene()->PostInitialize();

		std::string currentSceneName = CurrentScene()->GetName();
		Print("Loaded scene %s\n", currentSceneName.c_str());
	}

	void SceneManager::RemoveScene(BaseScene* scene)
	{
{'fraction_non_alphanumeric': 0.14765694076038904, 'fraction_numerical': 0.0008841732979664014, 'mean_word_length': 5.539499036608863, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4905546', 'n_tokens_mistral': 1261, 'n_tokens_neox': 1143, 'n_words': 169}