From f7a85d53abebe6dbadbd41c13995375c5df9c347 Mon Sep 17 00:00:00 2001 From: Nigel Barink Date: Thu, 10 Nov 2022 21:50:27 +0100 Subject: [PATCH] Editor Asset explorer setup --- .gitattributes | 1 + Editor/rsc/AssetIcon.png | 3 ++ Editor/rsc/AssetIcon.xcf | 3 ++ Editor/rsc/FodlerIcon.xcf | 3 ++ Editor/rsc/FolderIcon.png | 3 ++ Editor/src/EditorContext.h | 3 ++ Editor/src/SceneRuntime.h | 5 +-- Editor/src/UI/widgets.cpp | 45 ++++++++++++++++++- .../src/Graphics/Primitives/Texture.cpp | 2 +- .../src/Graphics/Primitives/Texture.h | 2 +- YoggieEngine/src/Scene/Entity.cpp | 2 +- YoggieEngine/src/Scene/Entity.h | 3 +- YoggieEngine/src/Scene/UUID.h | 16 +++++++ 13 files changed, 83 insertions(+), 8 deletions(-) create mode 100644 Editor/rsc/AssetIcon.png create mode 100644 Editor/rsc/AssetIcon.xcf create mode 100644 Editor/rsc/FodlerIcon.xcf create mode 100644 Editor/rsc/FolderIcon.png create mode 100644 YoggieEngine/src/Scene/UUID.h diff --git a/.gitattributes b/.gitattributes index 795b5cd..afa1ec1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,3 @@ *.png filter=lfs diff=lfs merge=lfs -text *.webp filter=lfs diff=lfs merge=lfs -text +*.xcf filter=lfs diff=lfs merge=lfs -text diff --git a/Editor/rsc/AssetIcon.png b/Editor/rsc/AssetIcon.png new file mode 100644 index 0000000..4cb1982 --- /dev/null +++ b/Editor/rsc/AssetIcon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2f65939ddd3e842974ab709229158ac0b9c6d3580ba01c9da1bcf0877bcb7a37 +size 1837 diff --git a/Editor/rsc/AssetIcon.xcf b/Editor/rsc/AssetIcon.xcf new file mode 100644 index 0000000..f75db54 --- /dev/null +++ b/Editor/rsc/AssetIcon.xcf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0dd30c52ce2c8aefd21d0f3fafb8e741d73c9a9c04a1886de2cd4a9a2e5445ca +size 7661 diff --git a/Editor/rsc/FodlerIcon.xcf b/Editor/rsc/FodlerIcon.xcf new file mode 100644 index 0000000..c06be4e --- /dev/null +++ b/Editor/rsc/FodlerIcon.xcf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fd9c3848217aa46051e27a33aa94121fe55a46d98202a46e2f31ce58a3703523 +size 6044 diff --git a/Editor/rsc/FolderIcon.png b/Editor/rsc/FolderIcon.png new file mode 100644 index 0000000..f875aba --- /dev/null +++ b/Editor/rsc/FolderIcon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a6e30ad8960099ac9ac9513c05c7f88aea732eb659959fcf2b6a801ef1cfd2a4 +size 1169 diff --git a/Editor/src/EditorContext.h b/Editor/src/EditorContext.h index 2175397..910db25 100644 --- a/Editor/src/EditorContext.h +++ b/Editor/src/EditorContext.h @@ -1,4 +1,7 @@ #pragma once +#include "Project/Project.h" + + struct EditorContext { std::shared_ptr CurrentProject; diff --git a/Editor/src/SceneRuntime.h b/Editor/src/SceneRuntime.h index 5f3a716..bb21133 100644 --- a/Editor/src/SceneRuntime.h +++ b/Editor/src/SceneRuntime.h @@ -3,7 +3,7 @@ #include "../../YoggieEngine/src/Graphics/Memory/Framebuffer.h" #include "../../YoggieEngine/src/PerfCounter.h" #include "../../YoggieEngine/src/Scene/Entity.h" -#include "Project.h" +#include "Project/Project.h" class EditorRuntime : public ApplicationRuntime { @@ -14,7 +14,7 @@ public: CurrentProject = std::make_shared("Random"); framebuffer = new Framebuffer(); - + // Create a level and load it as the current level auto importer = ModelImporter(); @@ -31,7 +31,6 @@ public: auto& rendercube2 = cube2.AddComponent(); rendercube2.mesh = *(Model->renderable->mesh); - // create an ambient light source auto AmbientLight = MainScene.AddEntity("AmbientLight"); auto light = AmbientLight.AddComponent(); diff --git a/Editor/src/UI/widgets.cpp b/Editor/src/UI/widgets.cpp index dd38810..e89a28b 100644 --- a/Editor/src/UI/widgets.cpp +++ b/Editor/src/UI/widgets.cpp @@ -3,6 +3,7 @@ #include #include "../../YoggieEngine/src/Scene/Components.h" #include "../../YoggieEngine/src/Scene/Entity.h" + class Editor; void ComponentView(const std::string& componentName, voidFunction func) @@ -169,7 +170,49 @@ void Console() { } void AssetsFinder() { + static YoggieEngine::Texture folderIcon ("rsc/folderIcon.png"); + static YoggieEngine::Texture AssetIcon("rsc/assetIcon.png"); + static int iconSize = 60; + ImGui::Begin("Asset-Finder", false); - ImGui::Dummy(ImVec2{ 128, 128 }); + ImGui::DragInt("IconSize", &iconSize, 1, 30, 90); + + + if (ImGui::BeginTable("##resources", 3)) + { + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.f, 0.f, 0.f, 0.f)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.f, 0.f, 0.f, 0.f)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(1.f, 1.f, 1.f, 0.2f)); + + for (int row = 0; row < 4; row++) { + ImGui::TableNextRow(); + for (int column = 0; column < 3; column++) { + ImGui::TableSetColumnIndex(column); + + if (column % 2) { + ImGui::ImageButton( + (ImTextureID)folderIcon.GetID(), + ImVec2{ (float)iconSize,(float)iconSize }); + ImGui::Text("Folder %d", row); + } + else { + ImGui::ImageButton( + (ImTextureID)AssetIcon.GetID(), + ImVec2{ (float)iconSize, (float)iconSize }); + ImGui::Text("Asset %d", row); + } + + + } + } + + ImGui::PopStyleColor(3); + ImGui::EndTable(); + + } + + + + ImGui::End(); } \ No newline at end of file diff --git a/YoggieEngine/src/Graphics/Primitives/Texture.cpp b/YoggieEngine/src/Graphics/Primitives/Texture.cpp index 623feb0..d46dc9f 100644 --- a/YoggieEngine/src/Graphics/Primitives/Texture.cpp +++ b/YoggieEngine/src/Graphics/Primitives/Texture.cpp @@ -15,7 +15,7 @@ namespace YoggieEngine { glGenTextures(1, &Id); glBindTexture(GL_TEXTURE_2D, Id); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); glGenerateMipmap(GL_TEXTURE_2D); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); diff --git a/YoggieEngine/src/Graphics/Primitives/Texture.h b/YoggieEngine/src/Graphics/Primitives/Texture.h index ab77f06..0cf622f 100644 --- a/YoggieEngine/src/Graphics/Primitives/Texture.h +++ b/YoggieEngine/src/Graphics/Primitives/Texture.h @@ -6,7 +6,7 @@ namespace YoggieEngine { void Bind(); void Unbind(); - + const unsigned int GetID() const { return Id; } private: unsigned int Id; }; diff --git a/YoggieEngine/src/Scene/Entity.cpp b/YoggieEngine/src/Scene/Entity.cpp index 7477e7c..0fb8c57 100644 --- a/YoggieEngine/src/Scene/Entity.cpp +++ b/YoggieEngine/src/Scene/Entity.cpp @@ -3,7 +3,7 @@ namespace YoggieEngine { Entity::Entity(entt::entity e, Scene* scene) - : m_entity(e), m_scene(scene) + : m_entity(e), m_scene(scene) { } diff --git a/YoggieEngine/src/Scene/Entity.h b/YoggieEngine/src/Scene/Entity.h index ca9b785..879d8be 100644 --- a/YoggieEngine/src/Scene/Entity.h +++ b/YoggieEngine/src/Scene/Entity.h @@ -1,10 +1,11 @@ #pragma once +typedef uint64_t ENTITY_UUID; namespace YoggieEngine { class Scene; class Entity { public: Entity() = default; - Entity(entt::entity e, Scene* scene); + Entity(entt::entity e, Scene* scene) ; Entity(const Entity& other) = default; template diff --git a/YoggieEngine/src/Scene/UUID.h b/YoggieEngine/src/Scene/UUID.h new file mode 100644 index 0000000..913cc0b --- /dev/null +++ b/YoggieEngine/src/Scene/UUID.h @@ -0,0 +1,16 @@ +#pragma once +#include + +class UUID { + +public: + static uint64_t Generate() + { + return ++last; + } + +private: + static uint64_t last ; + +}; +