Grindstone Game Engine v0.2.0
An open source game engine and toolkit.
Loading...
Searching...
No Matches
AssetBrowserPanel.hpp
1#pragma once
2
3#include <chrono>
4#include <filesystem>
5#include <vector>
6
7#include <entt/entt.hpp>
8
9#include <Editor/FileManager.hpp>
10
11namespace Grindstone {
12 class EngineCore;
13}
14
16 class Texture;
17}
18
19namespace Grindstone::Editor {
20 class ComponentInspector;
21}
22
24 class ImguiEditor;
25 class ImguiRenderer;
26 class AssetBrowserPanel {
27 public:
28 AssetBrowserPanel(ImguiRenderer* imguiRenderer, EngineCore* engineCore, ImguiEditor* editor);
29 void Render();
30 private:
31
32 struct AssetBrowserItem {
33 struct Subasset {
35 std::string name;
36 AssetType assetType;
37 };
38
39 std::filesystem::path filepath;
40 std::filesystem::path filename;
41 AssetType defaultAssetType;
42 std::string defaultAssetName;
43 Grindstone::Uuid defaultUuid;
44 bool isSubassetListOpen;
45 std::vector<Subasset> subassets;
46 };
47
48 enum class AssetBrowserInspectType {
49 All,
50 Plugin,
51 Directory,
52 };
53
54 void AddFilePath(const std::filesystem::directory_entry& file);
55
56 void SetAllPlugins();
57 void SetCurrentPlugin(const std::string& pluginName);
58 void SetCurrentAssetDirectory(const std::filesystem::path& path);
59 void SetFilesFromCurrentDirectory();
60 void ProcessFolderClicks(const std::filesystem::path& path);
61 void ProcessFileClicks(AssetBrowserItem& item);
62 void RenderTopBar();
63 void RenderPathPart(const std::filesystem::path& path);
64 void RenderBreadcrumbs();
65 void RenderContextMenuFileTypeSpecificEntries(const std::filesystem::path& path);
66 void RenderAssetContextMenu(bool isFolder, const std::filesystem::path& path, size_t index);
67 void RenderCurrentDirectoryContextMenu();
68 void RenderAssetTemplates(const std::filesystem::path& path);
69 size_t SortFile(bool isFolder, size_t indexToSort);
70 void TryRenameFile();
71 void RenderAllPlugins();
72 void RenderPlugins();
73 void RenderFolders();
74 void RenderFiles();
75 void RenderAssets(float height);
76 void RenderSidebar(float height);
77 void RenderSidebarSubdirectory(const std::string& pluginName, const std::filesystem::directory_entry& entry);
78 void RenderFile(size_t fileIndex);
79 void FilterSearch();
80 void AfterCreate(const std::filesystem::path& path);
81 private:
82 AssetBrowserInspectType assetBrowserInspectType;
83 std::filesystem::directory_entry currentDirectory;
84 std::string currentPluginName;
85 // TODO: Handle when the current mounting point
86 const Grindstone::Editor::FileManager::MountPoint* currentMountingPoint = nullptr;
87
88 bool isShowingPanel = true;
89 EngineCore* engineCore = nullptr;
90 ImguiEditor* editor = nullptr;
91 bool isRenamingFolder;
92 size_t indexToRename;
93 std::string pathRenameNewName;
94 std::string searchText;
95 std::string searchTextLower;
96 std::vector<std::filesystem::path> folders;
97 std::vector<AssetBrowserItem> files;
98 std::chrono::time_point<std::chrono::system_clock> lastRefreshedAssetsTime;
99 };
100}
Definition ImguiRenderer.hpp:12
Definition EngineCore.hpp:63
Definition Uuid.hpp:7
Definition EditorManager.hpp:32
Definition AssetRegistry.hpp:13
Definition Buffer.hpp:9
Definition Assert.hpp:16
Definition FileManager.hpp:10