Quake Map Component reflected
This commit is contained in:
@@ -13,67 +13,67 @@ public:
|
||||
|
||||
void Draw(Nuake::Entity entity) override
|
||||
{
|
||||
using namespace Nuake;
|
||||
|
||||
if (!entity.HasComponent<Nuake::QuakeMapComponent>())
|
||||
return;
|
||||
|
||||
Nuake::QuakeMapComponent& component = entity.GetComponent<Nuake::QuakeMapComponent>();
|
||||
BeginComponentTable(QUAKEMAP, Nuake::QuakeMapComponent);
|
||||
{
|
||||
{
|
||||
ImGui::Text("Map");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
std::string path = component.Path;
|
||||
ImGui::Button(component.Path.c_str(), ImVec2(ImGui::GetContentRegionAvail().x, 0));
|
||||
if (ImGui::BeginDragDropTarget())
|
||||
{
|
||||
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("_Map"))
|
||||
{
|
||||
char* file = (char*)payload->Data;
|
||||
std::string fullPath = std::string(file, 256);
|
||||
path = Nuake::FileSystem::AbsoluteToRelative(fullPath);
|
||||
|
||||
component.Path = path;
|
||||
}
|
||||
ImGui::EndDragDropTarget();
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ComponentTableReset(component.Path, "");
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
ImGui::Text("Collision");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::Checkbox("##Collison", &component.HasCollisions);
|
||||
ImGui::TableNextColumn();
|
||||
ComponentTableReset(component.HasCollisions, true);
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
ImGui::Text("Auto Rebuild");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::Checkbox("##AutoRebuild", &component.AutoRebuild);
|
||||
ImGui::TableNextColumn();
|
||||
ComponentTableReset(component.AutoRebuild, false);
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
ImGui::Text("Build");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
if (UI::SecondaryButton("Build Geometry"))
|
||||
{
|
||||
Nuake::QuakeMapBuilder builder;
|
||||
builder.BuildQuakeMap(entity, component.HasCollisions);
|
||||
}
|
||||
}
|
||||
}
|
||||
EndComponentTable();
|
||||
// using namespace Nuake;
|
||||
//
|
||||
// if (!entity.HasComponent<Nuake::QuakeMapComponent>())
|
||||
// return;
|
||||
//
|
||||
// Nuake::QuakeMapComponent& component = entity.GetComponent<Nuake::QuakeMapComponent>();
|
||||
// BeginComponentTable(QUAKEMAP, Nuake::QuakeMapComponent);
|
||||
// {
|
||||
// {
|
||||
// ImGui::Text("Map");
|
||||
// ImGui::TableNextColumn();
|
||||
//
|
||||
// std::string path = component.Path;
|
||||
// ImGui::Button(component.Path.c_str(), ImVec2(ImGui::GetContentRegionAvail().x, 0));
|
||||
// if (ImGui::BeginDragDropTarget())
|
||||
// {
|
||||
// if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("_Map"))
|
||||
// {
|
||||
// char* file = (char*)payload->Data;
|
||||
// std::string fullPath = std::string(file, 256);
|
||||
// path = Nuake::FileSystem::AbsoluteToRelative(fullPath);
|
||||
//
|
||||
// component.Path = path;
|
||||
// }
|
||||
// ImGui::EndDragDropTarget();
|
||||
// }
|
||||
//
|
||||
// ImGui::TableNextColumn();
|
||||
//
|
||||
// ComponentTableReset(component.Path, "");
|
||||
// }
|
||||
// ImGui::TableNextColumn();
|
||||
// {
|
||||
// ImGui::Text("Collision");
|
||||
// ImGui::TableNextColumn();
|
||||
//
|
||||
// ImGui::Checkbox("##Collison", &component.HasCollisions);
|
||||
// ImGui::TableNextColumn();
|
||||
// ComponentTableReset(component.HasCollisions, true);
|
||||
// }
|
||||
// ImGui::TableNextColumn();
|
||||
// {
|
||||
// ImGui::Text("Auto Rebuild");
|
||||
// ImGui::TableNextColumn();
|
||||
//
|
||||
// ImGui::Checkbox("##AutoRebuild", &component.AutoRebuild);
|
||||
// ImGui::TableNextColumn();
|
||||
// ComponentTableReset(component.AutoRebuild, false);
|
||||
// }
|
||||
// ImGui::TableNextColumn();
|
||||
// {
|
||||
// ImGui::Text("Build");
|
||||
// ImGui::TableNextColumn();
|
||||
//
|
||||
// if (UI::SecondaryButton("Build Geometry"))
|
||||
// {
|
||||
// Nuake::QuakeMapBuilder builder;
|
||||
// builder.BuildQuakeMap(entity, component.HasCollisions);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// EndComponentTable();
|
||||
}
|
||||
};
|
||||
@@ -1,7 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "Component.h"
|
||||
#include "FieldTypes.h"
|
||||
|
||||
#include "src/FileSystem/File.h"
|
||||
#include "src/Rendering/Mesh/Mesh.h"
|
||||
#include "src/Resource/Serializable.h"
|
||||
#include "src/Scene/Systems/QuakeMapBuilder.h"
|
||||
@@ -11,27 +13,39 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace Nuake {
|
||||
|
||||
class QuakeMapComponent : public Component
|
||||
{
|
||||
NUAKECOMPONENT(QuakeMapComponent, "Quake Map")
|
||||
|
||||
static void InitializeComponentClass()
|
||||
{
|
||||
BindComponentField<&QuakeMapComponent::HasCollisions>("HasCollisions", "Has Collisions");
|
||||
BindComponentField<&QuakeMapComponent::Path>("Path", "Path");
|
||||
BindComponentField<&QuakeMapComponent::AutoRebuild>("AutoRebuild", "Auto Rebuild");
|
||||
|
||||
BindAction<&QuakeMapComponent::ActionRebuild>("Rebuild", "Rebuild");
|
||||
}
|
||||
|
||||
public:
|
||||
bool HasCollisions = false;
|
||||
ResourceFile Path;
|
||||
bool AutoRebuild = false;
|
||||
float ScaleFactor = 1.f;
|
||||
|
||||
std::vector<Ref<Mesh>> m_Meshes;
|
||||
std::vector<Entity> m_Brushes;
|
||||
std::vector<int> m_SerializedBrushIDs;
|
||||
|
||||
std::string Path;
|
||||
float ScaleFactor = 1.0f;
|
||||
bool HasCollisions = false;
|
||||
bool AutoRebuild = false;
|
||||
void ActionRebuild();
|
||||
|
||||
json Serialize()
|
||||
{
|
||||
BEGIN_SERIALIZE();
|
||||
SERIALIZE_VAL(HasCollisions);
|
||||
SERIALIZE_VAL(Path);
|
||||
SERIALIZE_RES_FILE(Path);
|
||||
SERIALIZE_VAL(AutoRebuild);
|
||||
|
||||
for (uint32_t i = 0; i < std::size(m_Brushes); i++)
|
||||
@@ -64,7 +78,7 @@ namespace Nuake {
|
||||
}
|
||||
}
|
||||
|
||||
this->Path = j["Path"];
|
||||
DESERIALIZE_RES_FILE(Path);
|
||||
this->HasCollisions = j["HasCollisions"];
|
||||
return true;
|
||||
}
|
||||
@@ -81,4 +95,8 @@ namespace Nuake {
|
||||
m_SerializedBrushIDs.clear();
|
||||
}
|
||||
};
|
||||
|
||||
inline void QuakeMapComponent::ActionRebuild()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,9 +273,9 @@ namespace Nuake
|
||||
for (const auto& e : view)
|
||||
{
|
||||
auto& map = view.get<QuakeMapComponent>(e);
|
||||
if (map.AutoRebuild && !map.Path.empty() && FileSystem::FileExists(map.Path))
|
||||
if (map.AutoRebuild && map.Path.Exist())
|
||||
{
|
||||
if (auto file = FileSystem::GetFile(map.Path); file->Exist() && file->GetHasBeenModified())
|
||||
if (auto file = FileSystem::GetFile(map.Path.GetRelativePath()); file->Exist() && file->GetHasBeenModified())
|
||||
{
|
||||
file->SetHasBeenModified(false);
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Nuake {
|
||||
m_Scene->DestroyEntity(e);
|
||||
}
|
||||
|
||||
map_parser_load((FileSystem::Root + quakeMapC.Path).c_str());
|
||||
map_parser_load(quakeMapC.Path.GetAbsolutePath().c_str());
|
||||
geo_generator_run();
|
||||
|
||||
DefaultMaterial = MaterialManager::Get()->GetMaterial("default");
|
||||
|
||||
Reference in New Issue
Block a user