Added UI component, resource & system. Now renders on screen and live reloads

This commit is contained in:
Antoine Pilote
2024-09-10 22:27:15 -04:00
parent 552fe0ee04
commit ebedefb6a7
21 changed files with 366 additions and 66 deletions

View File

@@ -0,0 +1,51 @@
#pragma once
#include "ComponentPanel.h"
#include "src/FileSystem/FileSystem.h"
#include <src/Core/Maths.h>
#include <src/Scene/Components/UIComponent.h>
#include <src/Scene/Entities/ImGuiHelper.h>
class UIPanel : ComponentPanel
{
public:
UIPanel() = default;
~UIPanel() = default;
void Draw(Nuake::Entity entity) override
{
using namespace Nuake;
if (!entity.HasComponent<UIComponent>())
return;
auto& component = entity.GetComponent<UIComponent>();
BeginComponentTable(UI EMITTER, UIComponent);
{
{
ImGui::Text("HTML File");
ImGui::TableNextColumn();
std::string path = component.UIFilePath;
ImGui::Button(component.UIFilePath.c_str(), ImVec2(ImGui::GetContentRegionAvail().x, 0));
if (ImGui::BeginDragDropTarget())
{
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("_UIFile"))
{
char* file = (char*)payload->Data;
std::string fullPath = std::string(file, 256);
path = Nuake::FileSystem::AbsoluteToRelative(fullPath);
component.UIFilePath = path;
}
ImGui::EndDragDropTarget();
}
ImGui::TableNextColumn();
ComponentTableReset(component.UIFilePath, "");
}
}
EndComponentTable();
}
};

View File

@@ -138,6 +138,7 @@ void EditorSelectionPanel::DrawEntity(Nuake::Entity entity)
mMeshColliderPanel.Draw(entity);
mCharacterControllerPanel.Draw(entity);
mNavMeshVolumePanel.Draw(entity);
mUiPanel.Draw(entity);
using namespace Nuake;

View File

@@ -25,6 +25,7 @@
#include "../ComponentsPanel/AudioEmitterPanel.h"
#include "../ComponentsPanel/NetScriptPanel.h"
#include "../ComponentsPanel/NavMeshVolumePanel.h"
#include "../ComponentsPanel/UIPanel.h"
#include <src/Scene/Components/WrenScriptComponent.h>
#include <src/Resource/Prefab.h>
@@ -58,6 +59,7 @@ private:
BonePanel mBonePanel;
AudioEmitterPanel mAudioEmitterPanel;
NavMeshVolumePanel mNavMeshVolumePanel;
UIPanel mUiPanel;
Ref<Nuake::File> currentFile;
Ref<Nuake::Resource> selectedResource;

View File

@@ -270,7 +270,6 @@ namespace Nuake
OS::OpenIn(file->GetAbsolutePath());
break;
}
}
Editor->Selection = EditorSelection(file);
@@ -320,6 +319,10 @@ namespace Nuake
{
dragType = "_AudioFile";
}
else if (fileExtension == ".html")
{
dragType = "_UIFile";
}
ImGui::SetDragDropPayload(dragType.c_str(), (void*)(pathBuffer), sizeof(pathBuffer));
ImGui::Text(file->GetName().c_str());