From c91812c65e965e88118aeed8edea62026be57e98 Mon Sep 17 00:00:00 2001 From: Antoine Pilote Date: Tue, 3 Sep 2024 23:49:22 -0400 Subject: [PATCH] Moved FileSystem stuff into seprate files and a FileSystem Folder --- Editor/src/Commands/Commands/Commands.cpp | 2 +- .../src/ComponentsPanel/AudioEmitterPanel.h | 2 +- Editor/src/ComponentsPanel/BonePanel.h | 2 +- Editor/src/ComponentsPanel/BoxColliderPanel.h | 2 +- Editor/src/ComponentsPanel/CameraPanel.h | 2 +- .../CharacterControllerPanel.h | 2 +- Editor/src/ComponentsPanel/MeshPanel.h | 2 + Editor/src/ComponentsPanel/NetScriptPanel.cpp | 2 +- .../ComponentsPanel/ParticleEmitterPanel.h | 2 +- Editor/src/ComponentsPanel/QuakeMapPanel.h | 2 +- Editor/src/ComponentsPanel/RigidbodyPanel.h | 2 +- Editor/src/ComponentsPanel/ScriptPanel.cpp | 2 +- .../src/ComponentsPanel/SphereColliderPanel.h | 2 +- Editor/src/ComponentsPanel/SpritePanel.h | 2 +- Editor/src/Misc/ThumbnailManager.cpp | 12 +- Editor/src/Windows/EditorInterface.cpp | 2 +- Editor/src/Windows/EditorInterface.h | 2 +- Editor/src/Windows/EditorSelectionPanel.cpp | 2 +- Editor/src/Windows/EditorSelectionPanel.h | 2 +- Editor/src/Windows/FileSystemUI.h | 2 +- Editor/src/Windows/MapImporterWindow.cpp | 15 +- Editor/src/Windows/MapImporterWindow.h | 4 +- Editor/src/Windows/NewProjectWindow.cpp | 2 +- Editor/src/Windows/ProjectInterface.cpp | 2 +- .../ProjectSettings/ProjectSettingsWindow.cpp | 2 +- Editor/src/Windows/WelcomeWindow.cpp | 2 +- Nuake/Engine.cpp | 2 +- Nuake/src/Audio/AudioManager.cpp | 2 +- Nuake/src/Core/FileSystem.h | 252 ------------------ Nuake/src/Core/OS.cpp | 2 + Nuake/src/Core/OS.h | 2 +- Nuake/src/Core/ResourceManager.h | 8 - Nuake/src/FileSystem/Directory.cpp | 3 + Nuake/src/FileSystem/Directory.h | 23 ++ Nuake/src/FileSystem/File.cpp | 149 +++++++++++ Nuake/src/FileSystem/File.h | 41 +++ Nuake/src/{Core => FileSystem}/FileSystem.cpp | 19 +- Nuake/src/FileSystem/FileSystem.h | 63 +++++ Nuake/src/FileSystem/FileTypes.h | 22 ++ Nuake/src/Rendering/Shaders/Shader.cpp | 2 +- Nuake/src/Rendering/Textures/Material.h | 2 +- .../Rendering/Textures/MaterialManager.cpp | 2 +- Nuake/src/Rendering/Textures/Texture.cpp | 2 +- Nuake/src/Resource/FGD/FGDFile.cpp | 2 +- Nuake/src/Resource/FGD/FGDSerializer.cpp | 2 +- Nuake/src/Resource/Model.cpp | 2 +- Nuake/src/Resource/ModelLoader.cpp | 2 +- Nuake/src/Resource/Project.cpp | 2 +- Nuake/src/Resource/ResourceLoader.cpp | 105 ++++++++ Nuake/src/Resource/ResourceLoader.h | 107 +------- Nuake/src/Resource/ResourceManager.h | 3 - Nuake/src/Resource/SkinnedModel.cpp | 2 +- Nuake/src/Scene/Components/ModelComponent.h | 1 + .../src/Scene/Components/NetScriptComponent.h | 2 +- .../src/Scene/Components/SpriteComponent.cpp | 2 +- .../Scene/Components/WrenScriptComponent.h | 4 +- Nuake/src/Scene/Scene.cpp | 4 +- Nuake/src/Scene/SceneManager.cpp | 34 +++ Nuake/src/Scene/SceneManager.h | 28 ++ Nuake/src/Scene/Systems/QuakeMapBuilder.cpp | 2 +- Nuake/src/Scripting/ScriptingEngine.cpp | 2 +- Nuake/src/Scripting/ScriptingEngineNet.cpp | 2 +- Nuake/src/Scripting/WrenScript.cpp | 3 +- 63 files changed, 553 insertions(+), 431 deletions(-) delete mode 100644 Nuake/src/Core/FileSystem.h delete mode 100644 Nuake/src/Core/ResourceManager.h create mode 100644 Nuake/src/FileSystem/Directory.cpp create mode 100644 Nuake/src/FileSystem/Directory.h create mode 100644 Nuake/src/FileSystem/File.cpp create mode 100644 Nuake/src/FileSystem/File.h rename Nuake/src/{Core => FileSystem}/FileSystem.cpp (96%) create mode 100644 Nuake/src/FileSystem/FileSystem.h create mode 100644 Nuake/src/FileSystem/FileTypes.h create mode 100644 Nuake/src/Resource/ResourceLoader.cpp create mode 100644 Nuake/src/Scene/SceneManager.cpp create mode 100644 Nuake/src/Scene/SceneManager.h diff --git a/Editor/src/Commands/Commands/Commands.cpp b/Editor/src/Commands/Commands/Commands.cpp index 682200ac..523bf033 100644 --- a/Editor/src/Commands/Commands/Commands.cpp +++ b/Editor/src/Commands/Commands/Commands.cpp @@ -1,7 +1,7 @@ #include "Commands.h" #include -#include "src/Core/FileSystem.h" +#include "src/FileSystem/FileSystem.h" namespace NuakeEditor { diff --git a/Editor/src/ComponentsPanel/AudioEmitterPanel.h b/Editor/src/ComponentsPanel/AudioEmitterPanel.h index 1083a53f..df3611db 100644 --- a/Editor/src/ComponentsPanel/AudioEmitterPanel.h +++ b/Editor/src/ComponentsPanel/AudioEmitterPanel.h @@ -1,7 +1,7 @@ #pragma once #include "ComponentPanel.h" -#include +#include "src/FileSystem/FileSystem.h" #include #include #include diff --git a/Editor/src/ComponentsPanel/BonePanel.h b/Editor/src/ComponentsPanel/BonePanel.h index cd80a554..dd1e075b 100644 --- a/Editor/src/ComponentsPanel/BonePanel.h +++ b/Editor/src/ComponentsPanel/BonePanel.h @@ -1,7 +1,7 @@ #pragma once #include "ComponentPanel.h" -#include +#include "src/FileSystem/FileSystem.h" #include #include #include diff --git a/Editor/src/ComponentsPanel/BoxColliderPanel.h b/Editor/src/ComponentsPanel/BoxColliderPanel.h index c210f651..0021fca7 100644 --- a/Editor/src/ComponentsPanel/BoxColliderPanel.h +++ b/Editor/src/ComponentsPanel/BoxColliderPanel.h @@ -1,7 +1,7 @@ #pragma once #include "ComponentPanel.h" -#include +#include "src/FileSystem/FileSystem.h" #include #include #include diff --git a/Editor/src/ComponentsPanel/CameraPanel.h b/Editor/src/ComponentsPanel/CameraPanel.h index d07831bb..e162b40d 100644 --- a/Editor/src/ComponentsPanel/CameraPanel.h +++ b/Editor/src/ComponentsPanel/CameraPanel.h @@ -1,7 +1,7 @@ #pragma once #include "ComponentPanel.h" #include -#include +#include "src/FileSystem/FileSystem.h" class CameraPanel : ComponentPanel { diff --git a/Editor/src/ComponentsPanel/CharacterControllerPanel.h b/Editor/src/ComponentsPanel/CharacterControllerPanel.h index 78ba6c91..7739efd3 100644 --- a/Editor/src/ComponentsPanel/CharacterControllerPanel.h +++ b/Editor/src/ComponentsPanel/CharacterControllerPanel.h @@ -1,7 +1,7 @@ #pragma once #include "ComponentPanel.h" #include -#include +#include "src/FileSystem/FileSystem.h" class CharacterControllerPanel : ComponentPanel { diff --git a/Editor/src/ComponentsPanel/MeshPanel.h b/Editor/src/ComponentsPanel/MeshPanel.h index 7cc6570d..a38639f3 100644 --- a/Editor/src/ComponentsPanel/MeshPanel.h +++ b/Editor/src/ComponentsPanel/MeshPanel.h @@ -8,6 +8,8 @@ #include #include +#include + #include #include diff --git a/Editor/src/ComponentsPanel/NetScriptPanel.cpp b/Editor/src/ComponentsPanel/NetScriptPanel.cpp index f21dad6b..a9cfe740 100644 --- a/Editor/src/ComponentsPanel/NetScriptPanel.cpp +++ b/Editor/src/ComponentsPanel/NetScriptPanel.cpp @@ -1,7 +1,7 @@ #include "NetScriptPanel.h" #include "../Windows/FileSystemUI.h" #include -#include +#include "src/FileSystem/FileSystem.h" #include #include diff --git a/Editor/src/ComponentsPanel/ParticleEmitterPanel.h b/Editor/src/ComponentsPanel/ParticleEmitterPanel.h index 17d39d8e..d45495de 100644 --- a/Editor/src/ComponentsPanel/ParticleEmitterPanel.h +++ b/Editor/src/ComponentsPanel/ParticleEmitterPanel.h @@ -1,7 +1,7 @@ #pragma once #include "ComponentPanel.h" -#include +#include "src/FileSystem/FileSystem.h" #include #include #include diff --git a/Editor/src/ComponentsPanel/QuakeMapPanel.h b/Editor/src/ComponentsPanel/QuakeMapPanel.h index 0d1ae920..f326b4ff 100644 --- a/Editor/src/ComponentsPanel/QuakeMapPanel.h +++ b/Editor/src/ComponentsPanel/QuakeMapPanel.h @@ -2,7 +2,7 @@ #include "ComponentPanel.h" #include #include "src/Scene/Systems/QuakeMapBuilder.h" -#include +#include "src/FileSystem/FileSystem.h" #include #include diff --git a/Editor/src/ComponentsPanel/RigidbodyPanel.h b/Editor/src/ComponentsPanel/RigidbodyPanel.h index 5e5c2280..89a10b30 100644 --- a/Editor/src/ComponentsPanel/RigidbodyPanel.h +++ b/Editor/src/ComponentsPanel/RigidbodyPanel.h @@ -1,7 +1,7 @@ #pragma once #include "ComponentPanel.h" #include -#include +#include "src/FileSystem/FileSystem.h" class RigidbodyPanel : ComponentPanel { diff --git a/Editor/src/ComponentsPanel/ScriptPanel.cpp b/Editor/src/ComponentsPanel/ScriptPanel.cpp index 9d3c7f82..45eacdb8 100644 --- a/Editor/src/ComponentsPanel/ScriptPanel.cpp +++ b/Editor/src/ComponentsPanel/ScriptPanel.cpp @@ -1,7 +1,7 @@ #include "ScriptPanel.h" #include "../Windows/FileSystemUI.h" #include -#include +#include "src/FileSystem/FileSystem.h" void ScriptPanel::Draw(Nuake::Entity entity) { diff --git a/Editor/src/ComponentsPanel/SphereColliderPanel.h b/Editor/src/ComponentsPanel/SphereColliderPanel.h index 5033b7db..6374df31 100644 --- a/Editor/src/ComponentsPanel/SphereColliderPanel.h +++ b/Editor/src/ComponentsPanel/SphereColliderPanel.h @@ -1,7 +1,7 @@ #pragma once #include "ComponentPanel.h" #include -#include +#include "src/FileSystem/FileSystem.h" #include class SphereColliderPanel : ComponentPanel { diff --git a/Editor/src/ComponentsPanel/SpritePanel.h b/Editor/src/ComponentsPanel/SpritePanel.h index 676368ef..b21c58e0 100644 --- a/Editor/src/ComponentsPanel/SpritePanel.h +++ b/Editor/src/ComponentsPanel/SpritePanel.h @@ -1,7 +1,7 @@ #pragma once #include "ComponentPanel.h" -#include +#include "src/FileSystem/FileSystem.h" #include #include #include diff --git a/Editor/src/Misc/ThumbnailManager.cpp b/Editor/src/Misc/ThumbnailManager.cpp index 6c34834e..f0606fe7 100644 --- a/Editor/src/Misc/ThumbnailManager.cpp +++ b/Editor/src/Misc/ThumbnailManager.cpp @@ -1,14 +1,18 @@ #include "ThumbnailManager.h" -#include -#include +#include +#include #include #include -#include -#include +#include + #include +#include + +#include +#include #include diff --git a/Editor/src/Windows/EditorInterface.cpp b/Editor/src/Windows/EditorInterface.cpp index 5cc1d8ec..960e39ed 100644 --- a/Editor/src/Windows/EditorInterface.cpp +++ b/Editor/src/Windows/EditorInterface.cpp @@ -46,7 +46,7 @@ #include #include -#include "src/Core/FileSystem.h" +#include "src/FileSystem/FileSystem.h" #include #include #include "../Commands/Commands/Commands.h" diff --git a/Editor/src/Windows/EditorInterface.h b/Editor/src/Windows/EditorInterface.h index 857da5a3..e8745690 100644 --- a/Editor/src/Windows/EditorInterface.h +++ b/Editor/src/Windows/EditorInterface.h @@ -4,7 +4,7 @@ #include "src/Vendors/imgui/imgui.h" #include -#include "src/Core/FileSystem.h" +#include "src/FileSystem/FileSystem.h" #include "../Actions/EditorSelection.h" #include "EditorSelectionPanel.h" diff --git a/Editor/src/Windows/EditorSelectionPanel.cpp b/Editor/src/Windows/EditorSelectionPanel.cpp index 40dd4e90..fcbc8baa 100644 --- a/Editor/src/Windows/EditorSelectionPanel.cpp +++ b/Editor/src/Windows/EditorSelectionPanel.cpp @@ -58,7 +58,7 @@ void EditorSelectionPanel::Draw(EditorSelection selection) ResolveFile(selection.File); } - if (!selection.File->IsValid()) + if (!selection.File->Exist()) { std::string text = "File is invalid"; auto windowWidth = ImGui::GetWindowSize().x; diff --git a/Editor/src/Windows/EditorSelectionPanel.h b/Editor/src/Windows/EditorSelectionPanel.h index 57d108d8..5171010f 100644 --- a/Editor/src/Windows/EditorSelectionPanel.h +++ b/Editor/src/Windows/EditorSelectionPanel.h @@ -2,7 +2,7 @@ #include "../Actions/EditorSelection.h" #include "src/Scene/Entities/Entity.h" -#include "src/Core/FileSystem.h" +#include "src/FileSystem/FileSystem.h" #include #include "../ComponentsPanel/TransformPanel.h" diff --git a/Editor/src/Windows/FileSystemUI.h b/Editor/src/Windows/FileSystemUI.h index 0945a29d..d6c9c4d8 100644 --- a/Editor/src/Windows/FileSystemUI.h +++ b/Editor/src/Windows/FileSystemUI.h @@ -1,5 +1,5 @@ #pragma once -#include +#include "src/FileSystem/FileSystem.h" #include #include "EditorInterface.h" diff --git a/Editor/src/Windows/MapImporterWindow.cpp b/Editor/src/Windows/MapImporterWindow.cpp index 6f917bc5..54e938fd 100644 --- a/Editor/src/Windows/MapImporterWindow.cpp +++ b/Editor/src/Windows/MapImporterWindow.cpp @@ -1,11 +1,16 @@ #include "MapImporterWindow.h" -#include + #include "../Misc/InterfaceFonts.h" -#include -#include -#include -#include + #include +#include +#include +#include +#include + +#include + +#include void MapImporterWindow::Draw() { diff --git a/Editor/src/Windows/MapImporterWindow.h b/Editor/src/Windows/MapImporterWindow.h index 220a2adc..c58e2373 100644 --- a/Editor/src/Windows/MapImporterWindow.h +++ b/Editor/src/Windows/MapImporterWindow.h @@ -1,7 +1,7 @@ #pragma once -#include -#include +#include "src/FileSystem/FileSystem.h" +#include "src/FileSystem/FileSystem.h" #include class MapImporterWindow diff --git a/Editor/src/Windows/NewProjectWindow.cpp b/Editor/src/Windows/NewProjectWindow.cpp index b1dc8bb0..c7f6eaa2 100644 --- a/Editor/src/Windows/NewProjectWindow.cpp +++ b/Editor/src/Windows/NewProjectWindow.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include "src/FileSystem/FileSystem.h" #include #include #include diff --git a/Editor/src/Windows/ProjectInterface.cpp b/Editor/src/Windows/ProjectInterface.cpp index 1edd1a7d..ccc0b87c 100644 --- a/Editor/src/Windows/ProjectInterface.cpp +++ b/Editor/src/Windows/ProjectInterface.cpp @@ -1,7 +1,7 @@ #include "ProjectInterface.h" #include #include "Engine.h" -#include "src/Core/FileSystem.h" +#include "src/FileSystem/FileSystem.h" #include #include //#include "ImGuiTextHelper.h" diff --git a/Editor/src/Windows/ProjectSettings/ProjectSettingsWindow.cpp b/Editor/src/Windows/ProjectSettings/ProjectSettingsWindow.cpp index 71c92ada..890b99d0 100644 --- a/Editor/src/Windows/ProjectSettings/ProjectSettingsWindow.cpp +++ b/Editor/src/Windows/ProjectSettings/ProjectSettingsWindow.cpp @@ -1,7 +1,7 @@ #include "ProjectSettingsWindow.h" #include #include "../../Misc/InterfaceFonts.h" -#include +#include "src/FileSystem/FileSystem.h" #include "../EditorInterface.h" #include "../../Commands/Commands/Commands.h" #include diff --git a/Editor/src/Windows/WelcomeWindow.cpp b/Editor/src/Windows/WelcomeWindow.cpp index 43209450..9569e59c 100644 --- a/Editor/src/Windows/WelcomeWindow.cpp +++ b/Editor/src/Windows/WelcomeWindow.cpp @@ -5,7 +5,7 @@ #include "../Misc/InterfaceFonts.h" #include -#include +#include "src/FileSystem/FileSystem.h" #include #include #include diff --git a/Nuake/Engine.cpp b/Nuake/Engine.cpp index 36aee3bf..53618beb 100644 --- a/Nuake/Engine.cpp +++ b/Nuake/Engine.cpp @@ -4,7 +4,7 @@ #include "src/AI/NavManager.h" #include "src/Audio/AudioManager.h" -#include "src/Core/FileSystem.h" +#include "src/FileSystem/FileSystem.h" #include "src/Core/Input.h" #include "src/Rendering/Renderer.h" #include "src/Rendering/Renderer2D.h" diff --git a/Nuake/src/Audio/AudioManager.cpp b/Nuake/src/Audio/AudioManager.cpp index 1f8f6dc2..63a066de 100644 --- a/Nuake/src/Audio/AudioManager.cpp +++ b/Nuake/src/Audio/AudioManager.cpp @@ -1,6 +1,6 @@ #include "AudioManager.h" #include "src/Core/Logger.h" -#include "src/Core/FileSystem.h" +#include "src/FileSystem/FileSystem.h" #include #include "soloud_speech.h" diff --git a/Nuake/src/Core/FileSystem.h b/Nuake/src/Core/FileSystem.h deleted file mode 100644 index 5da31878..00000000 --- a/Nuake/src/Core/FileSystem.h +++ /dev/null @@ -1,252 +0,0 @@ -#pragma once -#include "Core.h" -#include "String.h" - -#include -#include -#include -#include - -namespace filewatch -{ - template - class FileWatch; -} - -namespace Nuake -{ - class FileDialog - { - public: - static std::string OpenFile(const char* filter); - static std::string SaveFile(const char* filter); - static std::string OpenFolder(); - }; - - class Directory; - class File; - - class FileSystem - { - public: - static std::string Root; - - static Ref RootDirectory; - static Ref> RootFileWatch; - - static void SetRootDirectory(const std::string path); - - static void Scan(); - static std::string AbsoluteToRelative(const std::string& path); - static std::string RelativeToAbsolute(const std::string& path); - static std::string GetParentPath(const std::string& fullPath); - static Ref GetFileTree(); - static Ref GetFile(const std::string& path); - static std::string GetFileNameFromPath(const std::string& path); - static void ScanDirectory(Ref directory); - static void GetDirectories(); - - static bool MakeDirectory(const std::string& path, bool absolute = false); - static bool DirectoryExists(const std::string& path, bool absolute = false); - static bool FileExists(const std::string& path, bool absolute = false); - - static std::string ReadFile(const std::string& path, bool absolute = false); - - static std::ofstream fileWriter; - static bool BeginWriteFile(const std::string path, bool absolute = false); - static bool WriteLine(const std::string line); - static void EndWriteFile(); - static uintmax_t DeleteFileFromPath(const std::string& path); - static uintmax_t DeleteFolder(const std::string& path); - static std::string GetConfigFolderPath(); - }; - - enum class FileType - { - Unkown, - Image, - Material, - Mesh, - Script, - NetScript, - Project, - Prefab, - Scene, - Wad, - Map, - Assembly, - Solution, - Audio - }; - - class File - { - private: - std::string Type; - std::string Name; - std::string RelativePath; - std::string AbsolutePath; - Ref Parent; - bool Modified = false; - - Ref> Water; - public: - - std::string GetExtension() const { return Type; } - std::string GetName() const { return Name; } - std::string GetRelativePath() const { return RelativePath; } - std::string GetAbsolutePath() const { return AbsolutePath; } - Ref GetParent() const { return Parent; } - FileType GetFileType() const - { - std::string ext = GetExtension(); - if (ext == ".png" || ext == ".jpg") - { - return FileType::Image; - } - if (ext == ".ogg" || ext == ".wav") - { - return FileType::Audio; - } - if (ext == ".material") - { - return FileType::Material; - } - - if (ext == ".scene") - { - return FileType::Scene; - } - - if (ext == ".project") - { - return FileType::Project; - } - - if (ext == ".script") - { - return FileType::Script; - } - - if (ext == ".prefab") - { - return FileType::Prefab; - } - - if (ext == ".wad") - { - return FileType::Wad; - } - - if (ext == ".map") - { - return FileType::Map; - } - - if (ext == ".dll") - { - return FileType::Assembly; - } - - if (ext == ".cs") - { - return FileType::NetScript; - } - - if (ext == ".sln") - { - return FileType::Solution; - } - - if (ext == ".mesh") - { - return FileType::Mesh; - } - - return FileType::Unkown; - } - bool GetHasBeenModified() const { return Modified; } - void SetHasBeenModified(bool value) { Modified = value; } - std::string GetFileTypeAsString() const - { - std::string ext = GetExtension(); - if (ext == ".png" || ext == "jpg") - { - return "Image"; - } - - if (ext == ".material") - { - return "Material"; - } - - if (ext == ".scene") - { - return "Scene"; - } - - if (ext == ".project") - { - return "Project"; - } - - if (ext == ".script") - { - return "Script"; - } - - if (ext == ".prefab") - { - return "Prefab"; - } - - if (ext == ".wad") - { - return "Wad"; - } - - if (ext == ".map") - { - return "Map"; - } - - if (ext == ".map") - { - return "Assembly"; - } - - if (ext == ".cs") - { - return "C# Script"; - } - - return "File"; - } - - std::string Read() - { - return FileSystem::ReadFile(AbsolutePath, true); - } - - bool IsValid() - { - return FileSystem::FileExists(AbsolutePath, true); - } - - File(Ref parentDir, const std::string& absolutePath, const std::string& name, const std::string& type); - }; - - class Directory - { - public: - std::string Name; - std::string FullPath; - Ref Parent; - std::vector> Directories; - std::vector> Files; - - Directory(const std::string& path); - Directory() = default; - ~Directory() = default; - }; -} diff --git a/Nuake/src/Core/OS.cpp b/Nuake/src/Core/OS.cpp index d03f3308..6b309198 100644 --- a/Nuake/src/Core/OS.cpp +++ b/Nuake/src/Core/OS.cpp @@ -18,6 +18,8 @@ #include #endif +#include "src/FileSystem/File.h" + #include "GLFW/glfw3.h" #include "GLFW/glfw3native.h" diff --git a/Nuake/src/Core/OS.h b/Nuake/src/Core/OS.h index d7b1a391..6396b647 100644 --- a/Nuake/src/Core/OS.h +++ b/Nuake/src/Core/OS.h @@ -1,7 +1,7 @@ #pragma once #include -#include "FileSystem.h" +#include "src/FileSystem/FileSystem.h" namespace Nuake { diff --git a/Nuake/src/Core/ResourceManager.h b/Nuake/src/Core/ResourceManager.h deleted file mode 100644 index b177ae00..00000000 --- a/Nuake/src/Core/ResourceManager.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -namespace Nuake { - class ResourceManager - { - - }; -} \ No newline at end of file diff --git a/Nuake/src/FileSystem/Directory.cpp b/Nuake/src/FileSystem/Directory.cpp new file mode 100644 index 00000000..c63bb4f3 --- /dev/null +++ b/Nuake/src/FileSystem/Directory.cpp @@ -0,0 +1,3 @@ +#include "Directory.h" + +using namespace Nuake; \ No newline at end of file diff --git a/Nuake/src/FileSystem/Directory.h b/Nuake/src/FileSystem/Directory.h new file mode 100644 index 00000000..49b9f668 --- /dev/null +++ b/Nuake/src/FileSystem/Directory.h @@ -0,0 +1,23 @@ +#pragma once +#include "src/Core/Core.h" + +namespace Nuake +{ + class File; + + class Directory + { + public: + std::string Name; + std::string FullPath; + Ref Parent; + std::vector> Directories; + std::vector> Files; + + public: + Directory(const std::string& path); + + Directory() = default; + ~Directory() = default; + }; +} \ No newline at end of file diff --git a/Nuake/src/FileSystem/File.cpp b/Nuake/src/FileSystem/File.cpp new file mode 100644 index 00000000..a44e13ca --- /dev/null +++ b/Nuake/src/FileSystem/File.cpp @@ -0,0 +1,149 @@ +#include "File.h" + +#include "src/FileSystem/FileSystem.h" + + +using namespace Nuake; + +File::File(Ref parentDir, const std::string& fullPath, const std::string& fileName, const std::string& fileType) : + name(fileName), + type(fileType), + absolutePath(fullPath), + relativePath(FileSystem::AbsoluteToRelative(fullPath)), + modified(false) +{ } + +FileType File::GetFileType() const +{ + const std::string_view ext = GetExtension(); + if (ext == ".png" || ext == ".jpg") + { + return FileType::Image; + } + if (ext == ".ogg" || ext == ".wav") + { + return FileType::Audio; + } + if (ext == ".material") + { + return FileType::Material; + } + + if (ext == ".scene") + { + return FileType::Scene; + } + + if (ext == ".project") + { + return FileType::Project; + } + + if (ext == ".script") + { + return FileType::Script; + } + + if (ext == ".prefab") + { + return FileType::Prefab; + } + + if (ext == ".wad") + { + return FileType::Wad; + } + + if (ext == ".map") + { + return FileType::Map; + } + + if (ext == ".dll") + { + return FileType::Assembly; + } + + if (ext == ".cs") + { + return FileType::NetScript; + } + + if (ext == ".sln") + { + return FileType::Solution; + } + + if (ext == ".mesh") + { + return FileType::Mesh; + } + + return FileType::Unkown; +} + +std::string File::GetFileTypeAsString() const +{ + std::string ext = GetExtension(); + if (ext == ".png" || ext == "jpg") + { + return "Image"; + } + + if (ext == ".material") + { + return "Material"; + } + + if (ext == ".scene") + { + return "Scene"; + } + + if (ext == ".project") + { + return "Project"; + } + + if (ext == ".script") + { + return "Script"; + } + + if (ext == ".prefab") + { + return "Prefab"; + } + + if (ext == ".wad") + { + return "Wad"; + } + + if (ext == ".map") + { + return "Map"; + } + + if (ext == ".map") + { + return "Assembly"; + } + + if (ext == ".cs") + { + return "C# Script"; + } + + return "File"; +} + +std::string File::Read() const +{ + return FileSystem::ReadFile(absolutePath, true); +} + +bool File::Exist() const +{ + return FileSystem::FileExists(absolutePath, true); +} \ No newline at end of file diff --git a/Nuake/src/FileSystem/File.h b/Nuake/src/FileSystem/File.h new file mode 100644 index 00000000..1a8489a6 --- /dev/null +++ b/Nuake/src/FileSystem/File.h @@ -0,0 +1,41 @@ +#pragma once +#include "src/Core/Core.h" + +#include "Directory.h" +#include "FileTypes.h" + +namespace Nuake +{ + class File + { + public: + File(Ref parentDir, const std::string& absolutePath, const std::string& name, const std::string& type); + ~File() = default; + + public: + std::string GetName() const { return name; } + std::string GetExtension() const { return type; } + std::string GetRelativePath() const { return relativePath; } + std::string GetAbsolutePath() const { return absolutePath; } + Ref GetParent() const { return parent; } + + bool GetHasBeenModified() const { return modified; } + void SetHasBeenModified(bool value) { modified = value; } + + FileType GetFileType() const; + std::string GetFileTypeAsString() const; + + std::string Read() const; + bool Exist() const; + + private: + std::string type; + std::string name; + std::string relativePath; + std::string absolutePath; + bool modified; + + Ref parent; + + }; +} diff --git a/Nuake/src/Core/FileSystem.cpp b/Nuake/src/FileSystem/FileSystem.cpp similarity index 96% rename from Nuake/src/Core/FileSystem.cpp rename to Nuake/src/FileSystem/FileSystem.cpp index 681d8ed6..3da547b8 100644 --- a/Nuake/src/Core/FileSystem.cpp +++ b/Nuake/src/FileSystem/FileSystem.cpp @@ -1,7 +1,7 @@ #include "FileSystem.h" #include "Engine.h" -#include "OS.h" +#include "src/Core/OS.h" #include @@ -22,6 +22,9 @@ #include #include "filewatch/FileWatch.hpp" +#include "Directory.h" +#include "File.h" + namespace Nuake { namespace fs = std::filesystem; @@ -198,19 +201,7 @@ namespace Nuake Ref FileSystem::RootDirectory; Ref> FileSystem::RootFileWatch; - File::File(Ref parentDir, const std::string& absolutePath, const std::string& name, const std::string& type) - { - AbsolutePath = absolutePath; - Parent = parentDir; - RelativePath = FileSystem::AbsoluteToRelative(absolutePath); - Name = name; - Type = type; - - if (GetFileType() != FileType::Unkown) - { - - } - } + void FileSystem::ScanDirectory(Ref directory) { diff --git a/Nuake/src/FileSystem/FileSystem.h b/Nuake/src/FileSystem/FileSystem.h new file mode 100644 index 00000000..b16d3fd1 --- /dev/null +++ b/Nuake/src/FileSystem/FileSystem.h @@ -0,0 +1,63 @@ +#pragma once +#include "src/Core/Core.h" +#include "String.h" + +#include +#include +#include +#include + +namespace filewatch +{ + template + class FileWatch; +} + +namespace Nuake +{ + class FileDialog + { + public: + static std::string OpenFile(const char* filter); + static std::string SaveFile(const char* filter); + static std::string OpenFolder(); + }; + + class Directory; + class File; + + class FileSystem + { + public: + static std::string Root; + + static Ref RootDirectory; + static Ref> RootFileWatch; + + static void SetRootDirectory(const std::string path); + + static void Scan(); + static std::string AbsoluteToRelative(const std::string& path); + static std::string RelativeToAbsolute(const std::string& path); + static std::string GetParentPath(const std::string& fullPath); + static Ref GetFileTree(); + static Ref GetFile(const std::string& path); + static std::string GetFileNameFromPath(const std::string& path); + static void ScanDirectory(Ref directory); + static void GetDirectories(); + + static bool MakeDirectory(const std::string& path, bool absolute = false); + static bool DirectoryExists(const std::string& path, bool absolute = false); + static bool FileExists(const std::string& path, bool absolute = false); + + static std::string ReadFile(const std::string& path, bool absolute = false); + + static std::ofstream fileWriter; + static bool BeginWriteFile(const std::string path, bool absolute = false); + static bool WriteLine(const std::string line); + static void EndWriteFile(); + static uintmax_t DeleteFileFromPath(const std::string& path); + static uintmax_t DeleteFolder(const std::string& path); + static std::string GetConfigFolderPath(); + }; +} diff --git a/Nuake/src/FileSystem/FileTypes.h b/Nuake/src/FileSystem/FileTypes.h new file mode 100644 index 00000000..cdfd667c --- /dev/null +++ b/Nuake/src/FileSystem/FileTypes.h @@ -0,0 +1,22 @@ +#pragma once + +namespace Nuake +{ + enum class FileType + { + Unkown, + Image, + Material, + Mesh, + Script, + NetScript, + Project, + Prefab, + Scene, + Wad, + Map, + Assembly, + Solution, + Audio + }; +} diff --git a/Nuake/src/Rendering/Shaders/Shader.cpp b/Nuake/src/Rendering/Shaders/Shader.cpp index 17285b79..f385c303 100644 --- a/Nuake/src/Rendering/Shaders/Shader.cpp +++ b/Nuake/src/Rendering/Shaders/Shader.cpp @@ -1,6 +1,6 @@ #include "src/Core/Core.h" #include "Shader.h" -#include "src/Core/FileSystem.h" +#include "src/FileSystem/FileSystem.h" #include "src/Core/Logger.h" #include diff --git a/Nuake/src/Rendering/Textures/Material.h b/Nuake/src/Rendering/Textures/Material.h index c829a638..d3f10e01 100644 --- a/Nuake/src/Rendering/Textures/Material.h +++ b/Nuake/src/Rendering/Textures/Material.h @@ -7,7 +7,7 @@ #include "Texture.h" #include #include "src/Resource/Resource.h" -#include "src/Core/FileSystem.h" +#include "src/FileSystem/FileSystem.h" namespace Nuake { diff --git a/Nuake/src/Rendering/Textures/MaterialManager.cpp b/Nuake/src/Rendering/Textures/MaterialManager.cpp index 0babe031..d87a5932 100644 --- a/Nuake/src/Rendering/Textures/MaterialManager.cpp +++ b/Nuake/src/Rendering/Textures/MaterialManager.cpp @@ -7,7 +7,7 @@ #include "json/json.hpp" #include "../Rendering/Textures/Material.h" -#include "src/Core/FileSystem.h" +#include "src/FileSystem/FileSystem.h" #include "src/Core/Logger.h" namespace Nuake diff --git a/Nuake/src/Rendering/Textures/Texture.cpp b/Nuake/src/Rendering/Textures/Texture.cpp index a4e8354d..87fcb697 100644 --- a/Nuake/src/Rendering/Textures/Texture.cpp +++ b/Nuake/src/Rendering/Textures/Texture.cpp @@ -2,7 +2,7 @@ #include "src/Core/Logger.h" #include #include -#include +#include "src/FileSystem/FileSystem.h" namespace Nuake { diff --git a/Nuake/src/Resource/FGD/FGDFile.cpp b/Nuake/src/Resource/FGD/FGDFile.cpp index 58c40633..2b49a989 100644 --- a/Nuake/src/Resource/FGD/FGDFile.cpp +++ b/Nuake/src/Resource/FGD/FGDFile.cpp @@ -1,6 +1,6 @@ #include "FGDFile.h" #include -#include +#include "src/FileSystem/FileSystem.h" #include "Engine.h" namespace Nuake { diff --git a/Nuake/src/Resource/FGD/FGDSerializer.cpp b/Nuake/src/Resource/FGD/FGDSerializer.cpp index 78a3fbbc..c9554e97 100644 --- a/Nuake/src/Resource/FGD/FGDSerializer.cpp +++ b/Nuake/src/Resource/FGD/FGDSerializer.cpp @@ -1,5 +1,5 @@ #include "FDGSerializer.h" -#include +#include "src/FileSystem/FileSystem.h" namespace Nuake { bool FGDSerializer::BeginFGDFile(const std::string path) diff --git a/Nuake/src/Resource/Model.cpp b/Nuake/src/Resource/Model.cpp index 0f2f26cd..3b306259 100644 --- a/Nuake/src/Resource/Model.cpp +++ b/Nuake/src/Resource/Model.cpp @@ -1,5 +1,5 @@ #include "src/Resource/Model.h" -#include "src/Core/FileSystem.h" +#include "src/FileSystem/FileSystem.h" #include "src/Core/Logger.h" #include "src/Rendering/Mesh/Mesh.h" #include "src/Resource/ModelLoader.h" diff --git a/Nuake/src/Resource/ModelLoader.cpp b/Nuake/src/Resource/ModelLoader.cpp index eaa31159..db713525 100644 --- a/Nuake/src/Resource/ModelLoader.cpp +++ b/Nuake/src/Resource/ModelLoader.cpp @@ -1,6 +1,6 @@ #include "src/Resource/ModelLoader.h" -#include "src/Core/FileSystem.h" +#include "src/FileSystem/FileSystem.h" #include "src/Core/Logger.h" #include "src/Core/String.h" diff --git a/Nuake/src/Resource/Project.cpp b/Nuake/src/Resource/Project.cpp index ef91a7d3..56c4214b 100644 --- a/Nuake/src/Resource/Project.cpp +++ b/Nuake/src/Resource/Project.cpp @@ -1,5 +1,5 @@ #include "Project.h" -#include "src/Core/FileSystem.h" +#include "src/FileSystem/FileSystem.h" #include "Engine.h" #include "src/Core/Logger.h" #include "src/Audio/AudioManager.h" diff --git a/Nuake/src/Resource/ResourceLoader.cpp b/Nuake/src/Resource/ResourceLoader.cpp new file mode 100644 index 00000000..92988a4e --- /dev/null +++ b/Nuake/src/Resource/ResourceLoader.cpp @@ -0,0 +1,105 @@ +#include "ResourceLoader.h" +#include "src/Core/Logger.h" +#include "src/Core/String.h" +#include "src/Resource/Resource.h" +#include "src/Resource/ResourceManager.h" +#include "src/Rendering/Textures/Material.h" +#include "src/Resource/Model.h" + +using namespace Nuake; + +Ref ResourceLoader::LoadMaterial(const std::string& path) +{ + const std::string FILE_NOT_FOUND = "[Resource Loader] File doesn't exists. \n "; + const std::string WRONG_EXTENSION = "[Resource Loader] Resource type mismatch file extension. \n expected: "; + const std::string MATERIAL_EXT = ".material"; + if (path.empty()) + { + Logger::Log(FILE_NOT_FOUND + path, "resource", LOG_TYPE::WARNING); + return nullptr; + } + + if (!FileSystem::FileExists(path)) + { + Logger::Log(FILE_NOT_FOUND + path, "resource", LOG_TYPE::WARNING); + return nullptr; + } + + if (!String::EndsWith(path, MATERIAL_EXT)) + { + std::string message = WRONG_EXTENSION + MATERIAL_EXT + " actual: " + path; + Logger::Log(message, "resource", LOG_TYPE::WARNING); + } + + std::string content = FileSystem::ReadFile(path); + json j = json::parse(content); + + UUID uuid = ReadUUID(j); + + // Check if resource is already loaded. + if (ResourceManager::IsResourceLoaded(uuid)) + { + return ResourceManager::GetResource(uuid); + } + + Ref material = CreateRef(); + material->ID = uuid; + material->Path = path; + material->Deserialize(j); + ResourceManager::RegisterResource(material); + + return material; +} + +Ref ResourceLoader::LoadModel(const std::string& path) +{ + const std::string FILE_NOT_FOUND = "[Resource Loader] File doesn't exists. \n "; + const std::string WRONG_EXTENSION = "[Resource Loader] Resource type mismatch file extension. \n expected: "; + const std::string MESH_EXT = ".mesh"; + if (path.empty()) + { + Logger::Log(FILE_NOT_FOUND + path, "resource", LOG_TYPE::WARNING); + return nullptr; + } + + if (!FileSystem::FileExists(path)) + { + Logger::Log(FILE_NOT_FOUND + path, "resource", LOG_TYPE::WARNING); + return nullptr; + } + + if (!String::EndsWith(path, MESH_EXT)) + { + std::string message = WRONG_EXTENSION + MESH_EXT + " actual: " + path; + Logger::Log(message, "resource", LOG_TYPE::WARNING); + } + + std::string content = FileSystem::ReadFile(path); + json j = json::parse(content); + + UUID uuid = ReadUUID(j); + + // Check if resource is already loaded. + if (ResourceManager::IsResourceLoaded(uuid)) + { + return ResourceManager::GetResource(uuid); + } + + Ref model = CreateRef(); + model->ID = uuid; + model->Path = path; + model->Deserialize(j); + ResourceManager::RegisterResource(model); + + return model; +} + +UUID ResourceLoader::ReadUUID(json j) +{ + if (j.contains("UUID")) + { + return UUID(j["UUID"]); + } + + return UUID(); +} diff --git a/Nuake/src/Resource/ResourceLoader.h b/Nuake/src/Resource/ResourceLoader.h index 8573f8bb..e8f74c05 100644 --- a/Nuake/src/Resource/ResourceLoader.h +++ b/Nuake/src/Resource/ResourceLoader.h @@ -1,13 +1,13 @@ #pragma once #include "src/Core/Core.h" -#include "src/Core/Logger.h" -#include "src/Resource/Resource.h" -#include "src/Resource/ResourceManager.h" -#include "src/Rendering/Textures/Material.h" -#include "src/Resource/Model.h" +#include "src/Resource/UUID.h" +#include "src/Resource/Serializable.h" namespace Nuake { + class Material; + class Model; + class ResourceLoader { private: @@ -19,101 +19,10 @@ namespace Nuake ResourceLoader() = default; ~ResourceLoader() = default; - static Ref LoadMaterial(const std::string& path) - { - const std::string FILE_NOT_FOUND = "[Resource Loader] File doesn't exists. \n "; - const std::string WRONG_EXTENSION = "[Resource Loader] Resource type mismatch file extension. \n expected: "; - const std::string MATERIAL_EXT = ".material"; - if (path.empty()) - { - Logger::Log(FILE_NOT_FOUND + path, "resource", LOG_TYPE::WARNING); - return nullptr; - } - - if (!FileSystem::FileExists(path)) - { - Logger::Log(FILE_NOT_FOUND + path, "resource", LOG_TYPE::WARNING); - return nullptr; - } - - if (!String::EndsWith(path, MATERIAL_EXT)) - { - std::string message = WRONG_EXTENSION + MATERIAL_EXT + " actual: " + path; - Logger::Log(message, "resource", LOG_TYPE::WARNING); - } - - std::string content = FileSystem::ReadFile(path); - json j = json::parse(content); - - UUID uuid = ReadUUID(j); - - // Check if resource is already loaded. - if (ResourceManager::IsResourceLoaded(uuid)) - { - return ResourceManager::GetResource(uuid); - } - - Ref material = CreateRef(); - material->ID = uuid; - material->Path = path; - material->Deserialize(j); - ResourceManager::RegisterResource(material); - - return material; - } - - static Ref LoadModel(const std::string& path) - { - const std::string FILE_NOT_FOUND = "[Resource Loader] File doesn't exists. \n "; - const std::string WRONG_EXTENSION = "[Resource Loader] Resource type mismatch file extension. \n expected: "; - const std::string MESH_EXT = ".mesh"; - if (path.empty()) - { - Logger::Log(FILE_NOT_FOUND + path, "resource", LOG_TYPE::WARNING); - return nullptr; - } - - if (!FileSystem::FileExists(path)) - { - Logger::Log(FILE_NOT_FOUND + path, "resource", LOG_TYPE::WARNING); - return nullptr; - } - - if (!String::EndsWith(path, MESH_EXT)) - { - std::string message = WRONG_EXTENSION + MESH_EXT + " actual: " + path; - Logger::Log(message, "resource", LOG_TYPE::WARNING); - } - - std::string content = FileSystem::ReadFile(path); - json j = json::parse(content); - - UUID uuid = ReadUUID(j); - - // Check if resource is already loaded. - if (ResourceManager::IsResourceLoaded(uuid)) - { - return ResourceManager::GetResource(uuid); - } - - Ref model = CreateRef(); - model->ID = uuid; - model->Path = path; - model->Deserialize(j); - ResourceManager::RegisterResource(model); - - return model; - } + static Ref LoadMaterial(const std::string& path); + static Ref LoadModel(const std::string& path); private: - static UUID ReadUUID(json j) - { - if (j.contains("UUID")) - { - return UUID(j["UUID"]); - } - - return UUID(); - } + static UUID ReadUUID(json j); }; } \ No newline at end of file diff --git a/Nuake/src/Resource/ResourceManager.h b/Nuake/src/Resource/ResourceManager.h index 42170350..4fc8ddc4 100644 --- a/Nuake/src/Resource/ResourceManager.h +++ b/Nuake/src/Resource/ResourceManager.h @@ -15,9 +15,6 @@ namespace Nuake public: static Ref GetResource(const UUID& uuid); - template - static Ref LoadResource(const std::string& path); - static void RegisterResource(Ref resource) { m_Resources[resource->ID] = resource; diff --git a/Nuake/src/Resource/SkinnedModel.cpp b/Nuake/src/Resource/SkinnedModel.cpp index 61961500..87e52205 100644 --- a/Nuake/src/Resource/SkinnedModel.cpp +++ b/Nuake/src/Resource/SkinnedModel.cpp @@ -1,7 +1,7 @@ #include "src/Resource/ModelLoader.h" #include "src/Resource/SkinnedModel.h" -#include "src/Core/FileSystem.h" +#include "src/FileSystem/FileSystem.h" #include "src/Core/Logger.h" diff --git a/Nuake/src/Scene/Components/ModelComponent.h b/Nuake/src/Scene/Components/ModelComponent.h index 6b099968..2296ba90 100644 --- a/Nuake/src/Scene/Components/ModelComponent.h +++ b/Nuake/src/Scene/Components/ModelComponent.h @@ -1,5 +1,6 @@ #pragma once +#include "src/Core/String.h" #include "src/Resource/Model.h" #include "src/Resource/ResourceLoader.h" #include "src/Resource/Serializable.h" diff --git a/Nuake/src/Scene/Components/NetScriptComponent.h b/Nuake/src/Scene/Components/NetScriptComponent.h index bda833a9..752f7e41 100644 --- a/Nuake/src/Scene/Components/NetScriptComponent.h +++ b/Nuake/src/Scene/Components/NetScriptComponent.h @@ -2,7 +2,7 @@ #pragma once #include "src/Core/Core.h" #include "src/Core/Maths.h" -#include "src/Core/FileSystem.h" +#include "src/FileSystem/FileSystem.h" #include "src/Core/Logger.h" #include "src/Resource/Serializable.h" #include "src/Resource/File.h" diff --git a/Nuake/src/Scene/Components/SpriteComponent.cpp b/Nuake/src/Scene/Components/SpriteComponent.cpp index 2c4b7341..c2892e6c 100644 --- a/Nuake/src/Scene/Components/SpriteComponent.cpp +++ b/Nuake/src/Scene/Components/SpriteComponent.cpp @@ -1,6 +1,6 @@ #include "SpriteComponent.h" -#include "src/Core/FileSystem.h" +#include "src/FileSystem/FileSystem.h" #include "src/Rendering/Textures/TextureManager.h" #include "src/Rendering/Textures/MaterialManager.h" #include "src/Rendering/Textures/Material.h" diff --git a/Nuake/src/Scene/Components/WrenScriptComponent.h b/Nuake/src/Scene/Components/WrenScriptComponent.h index 609a962b..d9a0771b 100644 --- a/Nuake/src/Scene/Components/WrenScriptComponent.h +++ b/Nuake/src/Scene/Components/WrenScriptComponent.h @@ -1,7 +1,9 @@ #pragma once #include "src/Scripting/WrenScript.h" #include "src/Resource/Serializable.h" -#include "src/Core/FileSystem.h" +#include "src/FileSystem/FileSystem.h" +#include "src/FileSystem/File.h" + #include "src/Core/Logger.h" namespace Nuake diff --git a/Nuake/src/Scene/Scene.cpp b/Nuake/src/Scene/Scene.cpp index 9c24c685..6b0d72c8 100644 --- a/Nuake/src/Scene/Scene.cpp +++ b/Nuake/src/Scene/Scene.cpp @@ -22,7 +22,7 @@ #include "Engine.h" #include "src/Core/Maths.h" -#include "src/Core/FileSystem.h" +#include "src/FileSystem/FileSystem.h" #include "src/Scene/Components.h" #include "src/Scene/Components/BoxCollider.h" @@ -271,7 +271,7 @@ namespace Nuake auto& map = view.get(e); if (map.AutoRebuild && !map.Path.empty() && FileSystem::FileExists(map.Path)) { - if (auto file = FileSystem::GetFile(map.Path); file->IsValid() && file->GetHasBeenModified()) + if (auto file = FileSystem::GetFile(map.Path); file->Exist() && file->GetHasBeenModified()) { file->SetHasBeenModified(false); diff --git a/Nuake/src/Scene/SceneManager.cpp b/Nuake/src/Scene/SceneManager.cpp new file mode 100644 index 00000000..30f3a644 --- /dev/null +++ b/Nuake/src/Scene/SceneManager.cpp @@ -0,0 +1,34 @@ +#include "SceneManager.h" +#include + +using namespace Nuake; + +SceneManager& SceneManager::Get() +{ + static SceneManager instance; + return instance; +} + +bool SceneManager::IsSceneLoaded(const UUID& uuid) const +{ + return scenes.find(uuid) != scenes.end(); +} + +Ref SceneManager::GetScene(const UUID& uuid) const +{ + if (!IsSceneLoaded(uuid)) + { + return nullptr; + } + + return Ref(); +} + +Ref SceneManager::LoadScene(Ref file) +{ + + return Ref(); +} + + + diff --git a/Nuake/src/Scene/SceneManager.h b/Nuake/src/Scene/SceneManager.h new file mode 100644 index 00000000..6a743a26 --- /dev/null +++ b/Nuake/src/Scene/SceneManager.h @@ -0,0 +1,28 @@ +#pragma once +#include "src/Core/Core.h" +#include "src/Resource/UUID.h" + + +namespace Nuake +{ + class File; + class Scene; + + class SceneManager + { + public: + static SceneManager& Get(); + + SceneManager() = default; + ~SceneManager() = default; + + bool IsSceneLoaded(const UUID& uuid) const; + Ref GetScene(const UUID& uuid) const; + + Ref LoadScene(Ref file); + void UnloadScene(const UUID& uuid); + + private: + std::map> scenes; + }; +} \ No newline at end of file diff --git a/Nuake/src/Scene/Systems/QuakeMapBuilder.cpp b/Nuake/src/Scene/Systems/QuakeMapBuilder.cpp index 995d3992..914b207c 100644 --- a/Nuake/src/Scene/Systems/QuakeMapBuilder.cpp +++ b/Nuake/src/Scene/Systems/QuakeMapBuilder.cpp @@ -1,7 +1,7 @@ #include "QuakeMapBuilder.h" #include "src/Rendering/Mesh/Mesh.h" -#include "src/Core/FileSystem.h" +#include "src/FileSystem/FileSystem.h" #include "src/Core/String.h" #include "src/Scene/Scene.h" #include "src/Scene/Entities/Entity.h" diff --git a/Nuake/src/Scripting/ScriptingEngine.cpp b/Nuake/src/Scripting/ScriptingEngine.cpp index 84f20df2..e317e073 100644 --- a/Nuake/src/Scripting/ScriptingEngine.cpp +++ b/Nuake/src/Scripting/ScriptingEngine.cpp @@ -1,7 +1,7 @@ #include "ScriptingEngine.h" #include "WrenScript.h" -#include "src/Core/FileSystem.h" +#include "src/FileSystem/FileSystem.h" #include "src/Scripting/Modules/ScriptModule.h" #include "src/Scripting/Modules/EngineModule.h" diff --git a/Nuake/src/Scripting/ScriptingEngineNet.cpp b/Nuake/src/Scripting/ScriptingEngineNet.cpp index e78e5ad7..eb1e534e 100644 --- a/Nuake/src/Scripting/ScriptingEngineNet.cpp +++ b/Nuake/src/Scripting/ScriptingEngineNet.cpp @@ -1,7 +1,7 @@ #include "ScriptingEngineNet.h" #include "src/Core/Logger.h" -#include "src/Core/FileSystem.h" +#include "src/FileSystem/FileSystem.h" #include "src/Core/OS.h" #include "src/Threading/JobSystem.h" #include "src/Resource/Project.h" diff --git a/Nuake/src/Scripting/WrenScript.cpp b/Nuake/src/Scripting/WrenScript.cpp index 827681d9..3e613d57 100644 --- a/Nuake/src/Scripting/WrenScript.cpp +++ b/Nuake/src/Scripting/WrenScript.cpp @@ -2,7 +2,8 @@ #include "src/Core/Logger.h" #include "src/Core/String.h" -#include "src/Core/FileSystem.h" +#include "src/FileSystem/FileSystem.h" +#include "src/FileSystem/File.h" #include