Converted last components to new component drawing system
This commit is contained in:
@@ -6,19 +6,20 @@
|
||||
#include <src/Scene/Components/BoneComponent.h>
|
||||
#include <src/Scene/Entities/ImGuiHelper.h>
|
||||
|
||||
class BonePanel : ComponentPanel
|
||||
class BonePanel
|
||||
{
|
||||
public:
|
||||
BonePanel() {}
|
||||
|
||||
void Draw(Nuake::Entity entity) override
|
||||
static void Draw(Nuake::Entity& entity, entt::meta_any& componentInstance)
|
||||
{
|
||||
using namespace Nuake;
|
||||
|
||||
if (!entity.HasComponent<BoneComponent>())
|
||||
|
||||
Nuake::BoneComponent* componentPtr = componentInstance.try_cast<Nuake::BoneComponent>();
|
||||
if (componentPtr == nullptr)
|
||||
{
|
||||
return;
|
||||
|
||||
auto& component = entity.GetComponent<BoneComponent>();
|
||||
}
|
||||
Nuake::BoneComponent& component = *componentPtr;
|
||||
|
||||
BeginComponentTable(BONE, BoneComponent);
|
||||
{
|
||||
{
|
||||
|
||||
@@ -3,17 +3,20 @@
|
||||
#include <src/Scene/Components/CameraComponent.h>
|
||||
#include "src/FileSystem/FileSystem.h"
|
||||
|
||||
class CameraPanel : ComponentPanel {
|
||||
class CameraPanel {
|
||||
|
||||
public:
|
||||
CameraPanel() {}
|
||||
|
||||
void Draw(Nuake::Entity entity) override
|
||||
static void Draw(Nuake::Entity& entity, entt::meta_any& componentInstance)
|
||||
{
|
||||
if (!entity.HasComponent<Nuake::CameraComponent>())
|
||||
using namespace Nuake;
|
||||
|
||||
Nuake::CameraComponent* componentPtr = componentInstance.try_cast<Nuake::CameraComponent>();
|
||||
if (componentPtr == nullptr)
|
||||
{
|
||||
return;
|
||||
|
||||
auto& component = entity.GetComponent<Nuake::CameraComponent>();
|
||||
}
|
||||
Nuake::CameraComponent& component = *componentPtr;
|
||||
|
||||
BeginComponentTable(CAMERA, Nuake::CameraComponent);
|
||||
{
|
||||
{
|
||||
|
||||
@@ -3,48 +3,47 @@
|
||||
|
||||
#include <src/Scene/Components/CapsuleColliderComponent.h>
|
||||
|
||||
class CapsuleColliderPanel : ComponentPanel
|
||||
class CapsuleColliderPanel
|
||||
{
|
||||
public:
|
||||
CapsuleColliderPanel() = default;
|
||||
|
||||
void Draw(Nuake::Entity entity) override
|
||||
static void Draw(Nuake::Entity& entity, entt::meta_any& componentInstance)
|
||||
{
|
||||
using namespace Nuake;
|
||||
|
||||
if (!entity.HasComponent<CapsuleColliderComponent>())
|
||||
|
||||
Nuake::CapsuleColliderComponent* componentPtr = componentInstance.try_cast<Nuake::CapsuleColliderComponent>();
|
||||
if (componentPtr == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto& [Capsule, Radius, Height, IsTrigger] = entity.GetComponent<CapsuleColliderComponent>();
|
||||
Nuake::CapsuleColliderComponent& component = *componentPtr;
|
||||
|
||||
BeginComponentTable(CAPSULE COLLIDER, CapsuleColliderComponent)
|
||||
{
|
||||
{
|
||||
ImGui::Text("Radius");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::DragFloat("##Radius", &Radius, 0.01f, 0.001f);
|
||||
Radius = std::max(Radius, 0.001f);
|
||||
ImGui::DragFloat("##Radius", &component.Radius, 0.01f, 0.001f);
|
||||
component.Radius = std::max(component.Radius, 0.001f);
|
||||
ImGui::TableNextColumn();
|
||||
ComponentTableReset(Radius, 0.5f)
|
||||
ComponentTableReset(component.Radius, 0.5f)
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
ImGui::Text("Height");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::DragFloat("##Height", &Height, 0.01f, 0.001f);
|
||||
Height = std::max(Height, 0.001f);
|
||||
ImGui::DragFloat("##Height", &component.Height, 0.01f, 0.001f);
|
||||
component.Height = std::max(component.Height, 0.001f);
|
||||
ImGui::TableNextColumn();
|
||||
ComponentTableReset(Height, 1.0f)
|
||||
ComponentTableReset(component.Height, 1.0f)
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
ImGui::Text("Is Trigger");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::Checkbox("##isTrigger", &IsTrigger);
|
||||
ImGui::Checkbox("##isTrigger", &component.IsTrigger);
|
||||
ImGui::TableNextColumn();
|
||||
ComponentTableReset(IsTrigger, false);
|
||||
ComponentTableReset(component.IsTrigger, false);
|
||||
}
|
||||
}
|
||||
EndComponentTable()
|
||||
|
||||
@@ -3,18 +3,20 @@
|
||||
#include <src/Scene/Components/CharacterControllerComponent.h>
|
||||
#include "src/FileSystem/FileSystem.h"
|
||||
|
||||
class CharacterControllerPanel : ComponentPanel {
|
||||
|
||||
class CharacterControllerPanel
|
||||
{
|
||||
public:
|
||||
CharacterControllerPanel() {}
|
||||
|
||||
void Draw(Nuake::Entity entity) override
|
||||
static void Draw(Nuake::Entity& entity, entt::meta_any& componentInstance)
|
||||
{
|
||||
if (!entity.HasComponent<Nuake::CharacterControllerComponent>())
|
||||
return;
|
||||
using namespace Nuake;
|
||||
|
||||
auto& component = entity.GetComponent<Nuake::CharacterControllerComponent>();
|
||||
|
||||
Nuake::CharacterControllerComponent* componentPtr = componentInstance.try_cast<Nuake::CharacterControllerComponent>();
|
||||
if (componentPtr == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Nuake::CharacterControllerComponent& component = *componentPtr;
|
||||
|
||||
BeginComponentTable(CHARACTER CONTROLLER, Nuake::CharacterControllerComponent);
|
||||
{
|
||||
{
|
||||
|
||||
@@ -93,5 +93,7 @@ ImGui::Text(##name);
|
||||
|
||||
class ComponentPanel {
|
||||
public:
|
||||
virtual void Draw(Nuake::Entity entity) = 0;
|
||||
};
|
||||
virtual void Draw(Nuake::Entity entity);
|
||||
};
|
||||
|
||||
inline void ComponentPanel::Draw(Nuake::Entity entity) {}
|
||||
|
||||
@@ -3,48 +3,47 @@
|
||||
|
||||
#include <src/Scene/Components/CylinderColliderComponent.h>
|
||||
|
||||
class CylinderColliderPanel : ComponentPanel
|
||||
class CylinderColliderPanel
|
||||
{
|
||||
public:
|
||||
CylinderColliderPanel() = default;
|
||||
|
||||
void Draw(Nuake::Entity entity) override
|
||||
static void Draw(Nuake::Entity& entity, entt::meta_any& componentInstance)
|
||||
{
|
||||
using namespace Nuake;
|
||||
|
||||
if (!entity.HasComponent<CylinderColliderComponent>())
|
||||
|
||||
Nuake::CylinderColliderComponent* componentPtr = componentInstance.try_cast<Nuake::CylinderColliderComponent>();
|
||||
if (componentPtr == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto& [Cylinder, Radius, Height, IsTrigger] = entity.GetComponent<CylinderColliderComponent>();
|
||||
Nuake::CylinderColliderComponent& component = *componentPtr;
|
||||
|
||||
BeginComponentTable(CYLINDER COLLIDER, CylinderColliderComponent)
|
||||
{
|
||||
{
|
||||
ImGui::Text("Radius");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::DragFloat("##Radius", &Radius, 0.01f, 0.001f);
|
||||
Radius = std::max(Radius, 0.001f);
|
||||
ImGui::DragFloat("##Radius", &component.Radius, 0.01f, 0.001f);
|
||||
component.Radius = std::max(component.Radius, 0.001f);
|
||||
ImGui::TableNextColumn();
|
||||
ComponentTableReset(Radius, 0.5f)
|
||||
ComponentTableReset(component.Radius, 0.5f)
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
ImGui::Text("Height");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::DragFloat("##Height", &Height, 0.01f, 0.0001f);
|
||||
Height = std::max(Height, 0.001f);
|
||||
ImGui::DragFloat("##Height", &component.Height, 0.01f, 0.0001f);
|
||||
component.Height = std::max(component.Height, 0.001f);
|
||||
ImGui::TableNextColumn();
|
||||
ComponentTableReset(Height, 1.0f)
|
||||
ComponentTableReset(component.Height, 1.0f)
|
||||
}
|
||||
ImGui::TableNextColumn();
|
||||
{
|
||||
ImGui::Text("Is Trigger");
|
||||
ImGui::TableNextColumn();
|
||||
|
||||
ImGui::Checkbox("##isTrigger", &IsTrigger);
|
||||
ImGui::Checkbox("##isTrigger", &component.IsTrigger);
|
||||
ImGui::TableNextColumn();
|
||||
ComponentTableReset(IsTrigger, false);
|
||||
ComponentTableReset(component.IsTrigger, false);
|
||||
}
|
||||
}
|
||||
EndComponentTable()
|
||||
|
||||
@@ -2,17 +2,18 @@
|
||||
#include "ComponentPanel.h"
|
||||
#include "src/Scene/Components/LightComponent.h"
|
||||
|
||||
class LightPanel :ComponentPanel {
|
||||
|
||||
class LightPanel
|
||||
{
|
||||
public:
|
||||
LightPanel() { }
|
||||
|
||||
void Draw(Nuake::Entity entity) override
|
||||
static void Draw(Nuake::Entity& entity, entt::meta_any& componentInstance)
|
||||
{
|
||||
if (!entity.HasComponent<Nuake::LightComponent>())
|
||||
return;
|
||||
|
||||
Nuake::LightComponent& component = entity.GetComponent<Nuake::LightComponent>();
|
||||
Nuake::LightComponent* componentPtr = componentInstance.try_cast<Nuake::LightComponent>();
|
||||
if (componentPtr == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Nuake::LightComponent& component = *componentPtr;
|
||||
|
||||
BeginComponentTable(LIGHT, Nuake::LightComponent);
|
||||
{
|
||||
|
||||
@@ -9,23 +9,25 @@
|
||||
#include <src/Resource/ResourceLoader.h>
|
||||
#include <src/Core/String.h>
|
||||
|
||||
class MeshColliderPanel : ComponentPanel {
|
||||
private:
|
||||
Scope<ModelResourceInspector> _modelInspector;
|
||||
bool _expanded = false;
|
||||
class MeshColliderPanel : ComponentPanel
|
||||
{
|
||||
public:
|
||||
MeshColliderPanel()
|
||||
{
|
||||
CreateScope<ModelResourceInspector>();
|
||||
}
|
||||
|
||||
void Draw(Nuake::Entity entity) override
|
||||
static void Draw(Nuake::Entity& entity, entt::meta_any& componentInstance)
|
||||
{
|
||||
using namespace Nuake;
|
||||
if (!entity.HasComponent<MeshColliderComponent>())
|
||||
|
||||
Nuake::MeshColliderComponent* componentPtr = componentInstance.try_cast<Nuake::MeshColliderComponent>();
|
||||
if (componentPtr == nullptr)
|
||||
{
|
||||
return;
|
||||
|
||||
MeshColliderComponent& component = entity.GetComponent<MeshColliderComponent>();
|
||||
}
|
||||
Nuake::MeshColliderComponent& component = *componentPtr;
|
||||
|
||||
BeginComponentTable(MESH, MeshColliderComponent);
|
||||
{
|
||||
ImGui::Text("Model");
|
||||
|
||||
@@ -26,13 +26,17 @@ public:
|
||||
CreateScope<ModelResourceInspector>();
|
||||
}
|
||||
|
||||
void Draw(Nuake::Entity entity) override
|
||||
void Draw(Nuake::Entity& entity, entt::meta_any& componentInstance)
|
||||
{
|
||||
using namespace Nuake;
|
||||
if (!entity.HasComponent<ModelComponent>())
|
||||
|
||||
Nuake::ModelComponent* componentPtr = componentInstance.try_cast<Nuake::ModelComponent>();
|
||||
if (componentPtr == nullptr)
|
||||
{
|
||||
return;
|
||||
|
||||
ModelComponent& component = entity.GetComponent<ModelComponent>();
|
||||
}
|
||||
Nuake::ModelComponent& component = *componentPtr;
|
||||
|
||||
BeginComponentTable(MESH, ModelComponent);
|
||||
{
|
||||
ImGui::Text("Model");
|
||||
|
||||
@@ -8,21 +8,20 @@
|
||||
#include <src/Core/Maths.h>
|
||||
#include <src/AI/RecastConfig.h>
|
||||
|
||||
class NavMeshVolumePanel : ComponentPanel {
|
||||
|
||||
class NavMeshVolumePanel
|
||||
{
|
||||
public:
|
||||
NavMeshVolumePanel() {}
|
||||
|
||||
void Draw(Nuake::Entity entity) override
|
||||
static void Draw(Nuake::Entity& entity, entt::meta_any& componentInstance)
|
||||
{
|
||||
using namespace Nuake;
|
||||
|
||||
if (!entity.HasComponent<NavMeshVolumeComponent>())
|
||||
|
||||
Nuake::NavMeshVolumeComponent* componentPtr = componentInstance.try_cast<Nuake::NavMeshVolumeComponent>();
|
||||
if (componentPtr == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto& component = entity.GetComponent<NavMeshVolumeComponent>();
|
||||
Nuake::NavMeshVolumeComponent& component = *componentPtr;
|
||||
|
||||
BeginComponentTable(NAVMESH VOLUME, NavMeshVolumeComponent);
|
||||
{
|
||||
{
|
||||
|
||||
@@ -8,13 +8,50 @@
|
||||
#include <src/Scene/Components/NetScriptComponent.h>
|
||||
#include <src/Scene/Entities/ImGuiHelper.h>
|
||||
|
||||
const std::string NET_TEMPLATE_SCRIPT_FIRST = R"(using Nuake.Net;
|
||||
|
||||
void NetScriptPanel::Draw(Nuake::Entity entity)
|
||||
namespace NuakeShowcase
|
||||
{
|
||||
if (!entity.HasComponent<Nuake::NetScriptComponent>())
|
||||
return;
|
||||
class )";
|
||||
|
||||
auto& component = entity.GetComponent<Nuake::NetScriptComponent>();
|
||||
const std::string NET_TEMPLATE_SCRIPT_SECOND = R"( : Entity
|
||||
{
|
||||
public override void OnInit()
|
||||
{
|
||||
// Called once at the start of the game
|
||||
}
|
||||
|
||||
|
||||
public override void OnUpdate(float dt)
|
||||
{
|
||||
// Called every frame
|
||||
}
|
||||
|
||||
public override void OnFixedUpdate(float dt)
|
||||
{
|
||||
// Called every fixed update
|
||||
}
|
||||
|
||||
|
||||
public override void OnDestroy()
|
||||
{
|
||||
// Called at the end of the game fixed update
|
||||
}
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
void NetScriptPanel::Draw(Nuake::Entity& entity, entt::meta_any& componentInstance)
|
||||
{
|
||||
using namespace Nuake;
|
||||
|
||||
Nuake::NetScriptComponent* componentPtr = componentInstance.try_cast<Nuake::NetScriptComponent>();
|
||||
if (componentPtr == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Nuake::NetScriptComponent& component = *componentPtr;
|
||||
|
||||
BeginComponentTable(.NETSCRIPT, Nuake::NetScriptComponent);
|
||||
{
|
||||
{
|
||||
|
||||
@@ -1,45 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "ComponentPanel.h"
|
||||
|
||||
|
||||
const std::string NET_TEMPLATE_SCRIPT_FIRST = R"(using Nuake.Net;
|
||||
|
||||
namespace NuakeShowcase
|
||||
class NetScriptPanel
|
||||
{
|
||||
class )";
|
||||
|
||||
const std::string NET_TEMPLATE_SCRIPT_SECOND = R"( : Entity
|
||||
{
|
||||
public override void OnInit()
|
||||
{
|
||||
// Called once at the start of the game
|
||||
}
|
||||
|
||||
|
||||
public override void OnUpdate(float dt)
|
||||
{
|
||||
// Called every frame
|
||||
}
|
||||
|
||||
public override void OnFixedUpdate(float dt)
|
||||
{
|
||||
// Called every fixed update
|
||||
}
|
||||
|
||||
|
||||
public override void OnDestroy()
|
||||
{
|
||||
// Called at the end of the game fixed update
|
||||
}
|
||||
}
|
||||
}
|
||||
)";
|
||||
|
||||
|
||||
class NetScriptPanel : ComponentPanel {
|
||||
|
||||
public:
|
||||
NetScriptPanel() {}
|
||||
|
||||
void Draw(Nuake::Entity entity) override;
|
||||
static void Draw(Nuake::Entity& entity, entt::meta_any& componentInstance);
|
||||
};
|
||||
@@ -28,6 +28,17 @@ EditorSelectionPanel::EditorSelectionPanel()
|
||||
virtualScene = CreateRef<Scene>();
|
||||
virtualScene->SetName("Virtual Scene");
|
||||
virtualScene->CreateEntity("Camera").AddComponent<CameraComponent>();
|
||||
|
||||
RegisterComponentDrawer<LightComponent, &LightPanel::Draw>();
|
||||
RegisterComponentDrawer<ModelComponent, &MeshPanel::Draw>(&meshPanel);
|
||||
RegisterComponentDrawer<CameraComponent, &CameraPanel::Draw>();
|
||||
RegisterComponentDrawer<MeshColliderComponent, &MeshColliderPanel::Draw>();
|
||||
RegisterComponentDrawer<CapsuleColliderComponent, &CapsuleColliderPanel::Draw>();
|
||||
RegisterComponentDrawer<NetScriptComponent, &NetScriptPanel::Draw>();
|
||||
RegisterComponentDrawer<CylinderColliderComponent, &CylinderColliderPanel::Draw>();
|
||||
RegisterComponentDrawer<CharacterControllerComponent, &CharacterControllerPanel::Draw>();
|
||||
RegisterComponentDrawer<BoneComponent, &BonePanel::Draw>();
|
||||
RegisterComponentDrawer<NavMeshVolumeComponent, &NavMeshVolumePanel::Draw>();
|
||||
|
||||
RegisterTypeDrawer<bool, &EditorSelectionPanel::DrawFieldTypeBool>(this);
|
||||
RegisterTypeDrawer<float, &EditorSelectionPanel::DrawFieldTypeFloat>(this);
|
||||
@@ -156,28 +167,6 @@ void EditorSelectionPanel::DrawEntity(Nuake::Entity entity)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Draw each component properties panels.
|
||||
mLightPanel.Draw(entity);
|
||||
mNetScriptPanel.Draw(entity);
|
||||
// mAudioEmitterPanel.Draw(entity);
|
||||
// mParticleEmitterPanel.Draw(entity);
|
||||
// mSpritePanel.Draw(entity);
|
||||
mMeshPanel.Draw(entity);
|
||||
// mSkinnedModelPanel.Draw(entity);
|
||||
mBonePanel.Draw(entity);
|
||||
// mQuakeMapPanel.Draw(entity);
|
||||
mCameraPanel.Draw(entity);
|
||||
// mRigidbodyPanel.Draw(entity);
|
||||
// mBoxColliderPanel.Draw(entity);
|
||||
// mSphereColliderPanel.Draw(entity);
|
||||
mCapsuleColliderPanel.Draw(entity);
|
||||
mCylinderColliderPanel.Draw(entity);
|
||||
mMeshColliderPanel.Draw(entity);
|
||||
mCharacterControllerPanel.Draw(entity);
|
||||
mNavMeshVolumePanel.Draw(entity);
|
||||
// mUiPanel.Draw(entity);
|
||||
|
||||
using namespace Nuake;
|
||||
|
||||
float availWidth = ImGui::GetContentRegionAvail().x;
|
||||
|
||||
@@ -33,16 +33,7 @@ class EditorSelectionPanel
|
||||
|
||||
private:
|
||||
TransformPanel mTransformPanel;
|
||||
LightPanel mLightPanel;
|
||||
NetScriptPanel mNetScriptPanel;
|
||||
MeshPanel mMeshPanel;
|
||||
CameraPanel mCameraPanel;
|
||||
MeshColliderPanel mMeshColliderPanel;
|
||||
CapsuleColliderPanel mCapsuleColliderPanel;
|
||||
CylinderColliderPanel mCylinderColliderPanel;
|
||||
CharacterControllerPanel mCharacterControllerPanel;
|
||||
BonePanel mBonePanel;
|
||||
NavMeshVolumePanel mNavMeshVolumePanel;
|
||||
MeshPanel meshPanel;
|
||||
|
||||
Ref<Nuake::File> currentFile;
|
||||
Ref<Nuake::Resource> selectedResource;
|
||||
|
||||
Reference in New Issue
Block a user