diff --git a/Editor/src/Windows/EditorInterface.cpp b/Editor/src/Windows/EditorInterface.cpp index e5be80d9..3b2d0958 100644 --- a/Editor/src/Windows/EditorInterface.cpp +++ b/Editor/src/Windows/EditorInterface.cpp @@ -818,7 +818,7 @@ namespace Nuake { m_IsRenaming = true; } - if (!m_IsRenaming && Selection.Type == EditorSelectionType::Entity && Input::IsKeyPressed(Key::DELETE)) + if (!m_IsRenaming && Selection.Type == EditorSelectionType::Entity && Input::IsKeyPressed(Key::DELETE_KEY)) { QueueDeletion = Selection.Entity; } diff --git a/Nuake/src/Core/FileSystem.cpp b/Nuake/src/Core/FileSystem.cpp index 3347005f..f531aaad 100644 --- a/Nuake/src/Core/FileSystem.cpp +++ b/Nuake/src/Core/FileSystem.cpp @@ -20,6 +20,7 @@ #include #include #include +#include "filewatch/FileWatch.hpp" namespace Nuake { @@ -196,6 +197,29 @@ namespace Nuake Ref FileSystem::RootDirectory; + 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) + { + this->Water = CreateRef>( + AbsolutePath, [&](const std::string& path, const filewatch::Event& event) + { + std::cout << path << ' ' << filewatch::event_to_string(event) << '\n'; + if (event == filewatch::Event::modified) + { + SetHasBeenModified(true); + } + } + ); + } + } + void FileSystem::ScanDirectory(Ref directory) { for (const auto& entry : std::filesystem::directory_iterator(directory->FullPath)) diff --git a/Nuake/src/Core/FileSystem.h b/Nuake/src/Core/FileSystem.h index c9d73ba2..ece1b7be 100644 --- a/Nuake/src/Core/FileSystem.h +++ b/Nuake/src/Core/FileSystem.h @@ -7,6 +7,12 @@ #include #include +namespace filewatch +{ + template + class FileWatch; +} + namespace Nuake { class FileDialog @@ -80,6 +86,9 @@ namespace Nuake std::string RelativePath; std::string AbsolutePath; Ref Parent; + bool Modified = false; + + Ref> Water; public: std::string GetExtension() const { return Type; } @@ -155,7 +164,8 @@ namespace Nuake return FileType::Unkown; } - + bool GetHasBeenModified() const { return Modified; } + void SetHasBeenModified(bool value) { Modified = value; } std::string GetFileTypeAsString() const { std::string ext = GetExtension(); @@ -222,14 +232,7 @@ namespace Nuake return FileSystem::FileExists(AbsolutePath, true); } - 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; - } + File(Ref parentDir, const std::string& absolutePath, const std::string& name, const std::string& type); }; class Directory diff --git a/Nuake/src/Core/Input.h b/Nuake/src/Core/Input.h index 4629c9b5..cadab931 100644 --- a/Nuake/src/Core/Input.h +++ b/Nuake/src/Core/Input.h @@ -65,7 +65,7 @@ namespace Nuake TAB = 258, BACKSPACE = 259, INSERT = 260, - DELETE = 261, + DELETE_KEY = 261, RIGHT = 262, LEFT = 263, DOWN = 264, diff --git a/Nuake/src/Rendering/Mesh/SkinnedMesh.cpp b/Nuake/src/Rendering/Mesh/SkinnedMesh.cpp index 619b3f7e..ce4e294e 100644 --- a/Nuake/src/Rendering/Mesh/SkinnedMesh.cpp +++ b/Nuake/src/Rendering/Mesh/SkinnedMesh.cpp @@ -179,7 +179,7 @@ namespace Nuake try { DESERIALIZE_VEC2(v["UV"], vertex.uv) } - catch (std::exception& e) { + catch (std::exception& /*e*/) { vertex.uv = { 0.0, 0.0 }; } DESERIALIZE_VEC3(v["Position"], vertex.position) diff --git a/Nuake/src/Resource/Project.h b/Nuake/src/Resource/Project.h index 3bf66efe..7b9072bb 100644 --- a/Nuake/src/Resource/Project.h +++ b/Nuake/src/Resource/Project.h @@ -19,7 +19,7 @@ namespace Nuake bool SmoothCamera = false; float SmoothCameraSpeed = 0.2f; Color PrimaryColor = Color(97.0f / 255.0f, 0, 1.0f, 1.0f); - int PhysicsStep = 90.0f; + int PhysicsStep = 90; int MaxPhysicsSubStep = 32; int MaxPhysicsBodies = 4096; int MaxPhysicsContactConstraints = 2048; diff --git a/Nuake/src/Scene/Scene.cpp b/Nuake/src/Scene/Scene.cpp index 6fd4ff4e..94becc7e 100644 --- a/Nuake/src/Scene/Scene.cpp +++ b/Nuake/src/Scene/Scene.cpp @@ -261,6 +261,24 @@ namespace Nuake void Scene::Update(Timestep ts) { + const auto& view = m_Registry.view(); + for (const auto& e : view) + { + auto& map = view.get(e); + if (map.AutoRebuild && !map.Path.empty()) + { + if (auto file = FileSystem::GetFile(map.Path); file->IsValid() && file->GetHasBeenModified()) + { + file->SetHasBeenModified(false); + + Entity entity = Entity(e, this); + QuakeMapBuilder builder; + builder.BuildQuakeMap(entity, map.HasCollisions); + } + } + } + + for (auto& system : m_Systems) { system->Update(ts); diff --git a/premake5.lua b/premake5.lua index 7dedbf0b..7c411606 100644 --- a/premake5.lua +++ b/premake5.lua @@ -70,7 +70,8 @@ project "Nuake" "%{prj.name}/src/Vendors/katana-parser/*.h", "%{prj.name}/src/Vendors/katana-parser/*.c", "%{prj.name}/src/Vendors/incbin/*.c", - "%{prj.name}/src/Vendors/incbin/*.h" + "%{prj.name}/src/Vendors/incbin/*.h", + "%{prj.name}/src/Vendors/filewatch/*.hpp" } includedirs