mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-09 20:08:57 +03:00
Added live reloading for quake maps
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <ShlObj.h>
|
||||
#include "filewatch/FileWatch.hpp"
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
@@ -196,6 +197,29 @@ namespace Nuake
|
||||
|
||||
Ref<Directory> FileSystem::RootDirectory;
|
||||
|
||||
File::File(Ref<Directory> 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<filewatch::FileWatch<std::string>>(
|
||||
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> directory)
|
||||
{
|
||||
for (const auto& entry : std::filesystem::directory_iterator(directory->FullPath))
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
namespace filewatch
|
||||
{
|
||||
template<typename T>
|
||||
class FileWatch;
|
||||
}
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
class FileDialog
|
||||
@@ -80,6 +86,9 @@ namespace Nuake
|
||||
std::string RelativePath;
|
||||
std::string AbsolutePath;
|
||||
Ref<Directory> Parent;
|
||||
bool Modified = false;
|
||||
|
||||
Ref<filewatch::FileWatch<std::string>> 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<Directory> 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<Directory> parentDir, const std::string& absolutePath, const std::string& name, const std::string& type);
|
||||
};
|
||||
|
||||
class Directory
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Nuake
|
||||
TAB = 258,
|
||||
BACKSPACE = 259,
|
||||
INSERT = 260,
|
||||
DELETE = 261,
|
||||
DELETE_KEY = 261,
|
||||
RIGHT = 262,
|
||||
LEFT = 263,
|
||||
DOWN = 264,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -261,6 +261,24 @@ namespace Nuake
|
||||
|
||||
void Scene::Update(Timestep ts)
|
||||
{
|
||||
const auto& view = m_Registry.view<QuakeMapComponent>();
|
||||
for (const auto& e : view)
|
||||
{
|
||||
auto& map = view.get<QuakeMapComponent>(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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user