Asset browser
This commit is contained in:
parent
393422a0a3
commit
6d9a8e484c
|
@ -0,0 +1,84 @@
|
|||
#include "SHpch.h"
|
||||
#include "SHAssetBrowser.h"
|
||||
|
||||
#include "Editor/IconsMaterialDesign.h"
|
||||
#include "Editor/SHImGuiHelpers.hpp"
|
||||
#include <imgui.h>
|
||||
|
||||
#include "Assets/SHAssetManager.h"
|
||||
#include "Editor/DragDrop/SHDragDrop.hpp"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
SHAssetBrowser::SHAssetBrowser()
|
||||
:SHEditorWindow("\xee\x8b\x87 Asset Browser", ImGuiWindowFlags_MenuBar)
|
||||
{
|
||||
}
|
||||
|
||||
void SHAssetBrowser::Init()
|
||||
{
|
||||
SHEditorWindow::Init();
|
||||
}
|
||||
|
||||
void SHAssetBrowser::Update()
|
||||
{
|
||||
SHEditorWindow::Update();
|
||||
if(Begin())
|
||||
{
|
||||
DrawMenuBar();
|
||||
auto const& assets = SHAssetManager::GetAllAssets();
|
||||
if(ImGui::BeginTable("AssetBrowserTable", 3))
|
||||
{
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TableHeader("Asset ID");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TableHeader("Name");
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TableHeader("Type");
|
||||
for(SHAsset const& asset : assets)
|
||||
{
|
||||
DrawAsset(asset);
|
||||
}
|
||||
ImGui::EndTable();
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void SHAssetBrowser::DrawMenuBar()
|
||||
{
|
||||
if(ImGui::BeginMenuBar())
|
||||
{
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
}
|
||||
|
||||
void SHAssetBrowser::DrawAsset(SHAsset const& asset)
|
||||
{
|
||||
ImGui::PushID(asset.id);
|
||||
ImGui::BeginGroup();
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Selectable(std::format("{}", asset.id).data(), false, ImGuiSelectableFlags_SpanAllColumns);
|
||||
if(SHDragDrop::BeginSource())
|
||||
{
|
||||
auto id = asset.id;
|
||||
ImGui::Text("Moving Asset: %zu", id);
|
||||
SHDragDrop::SetPayload<AssetID>(DRAG_RESOURCE, &id);
|
||||
SHDragDrop::EndSource();
|
||||
}
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%s", asset.name.c_str());
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::Text("%s", "Type");
|
||||
|
||||
ImGui::EndGroup();
|
||||
ImGui::PopID();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
|
||||
#include "Assets/SHAsset.h"
|
||||
#include "Editor/EditorWindow/SHEditorWindow.h"
|
||||
|
||||
namespace SHADE
|
||||
{
|
||||
class SHAssetBrowser final : public SHEditorWindow
|
||||
{
|
||||
public:
|
||||
SHAssetBrowser();
|
||||
|
||||
void Init();
|
||||
void Update();
|
||||
|
||||
void Refresh();
|
||||
private:
|
||||
void DrawMenuBar();
|
||||
void DrawAsset(SHAsset const& asset);
|
||||
|
||||
float idColumnWidth, nameColumnWidth, typeColumnWidth;
|
||||
|
||||
};
|
||||
}
|
|
@ -84,8 +84,8 @@ namespace SHADE
|
|||
}
|
||||
ImGui::Separator();
|
||||
// Render Scripts
|
||||
SHScriptEngine* scriptEngine = static_cast<SHScriptEngine*>(SHSystemManager::GetSystem<SHScriptEngine>());
|
||||
scriptEngine->RenderScriptsInInspector(eid);
|
||||
SHScriptEngine* scriptEngine = static_cast<SHScriptEngine*>(SHSystemManager::GetSystem<SHScriptEngine>());
|
||||
scriptEngine->RenderScriptsInInspector(eid);
|
||||
ImGui::Separator();
|
||||
if(ImGui::BeginMenu(std::format("{} Add Component", ICON_MD_LIBRARY_ADD).data()))
|
||||
{
|
||||
|
|
|
@ -3,4 +3,5 @@
|
|||
#include "HierarchyPanel/SHHierarchyPanel.h" //Hierarchy Panel
|
||||
#include "Inspector/SHEditorInspector.h" //Inspector
|
||||
#include "Profiling/SHEditorProfiler.h" //Profiler
|
||||
#include "ViewportWindow/SHEditorViewport.h" //Editor Viewport
|
||||
#include "ViewportWindow/SHEditorViewport.h" //Editor Viewport
|
||||
#include "AssetBrowser/SHAssetBrowser.h" //Asset Browser
|
|
@ -30,6 +30,7 @@ namespace SHADE
|
|||
void SHEditorViewport::Update()
|
||||
{
|
||||
SHEditorWindow::Update();
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f,0.0f));
|
||||
if(Begin())
|
||||
{
|
||||
ImGuizmo::SetDrawlist();
|
||||
|
@ -55,7 +56,7 @@ namespace SHADE
|
|||
ImGuizmo::SetRect(beginCursorPos.x , beginCursorPos.y, beginContentRegionAvailable.x, beginContentRegionAvailable.y);
|
||||
transformGizmo.Draw();
|
||||
ImGui::End();
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
void SHEditorViewport::Exit()
|
||||
|
|
|
@ -92,6 +92,7 @@ namespace SHADE
|
|||
SHEditorWindowManager::CreateEditorWindow<SHHierarchyPanel>();
|
||||
SHEditorWindowManager::CreateEditorWindow<SHEditorInspector>();
|
||||
SHEditorWindowManager::CreateEditorWindow<SHEditorProfiler>();
|
||||
SHEditorWindowManager::CreateEditorWindow<SHAssetBrowser>();
|
||||
SHEditorWindowManager::CreateEditorWindow<SHEditorViewport>();
|
||||
|
||||
io = &ImGui::GetIO();
|
||||
|
|
Loading…
Reference in New Issue