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