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 private:
79 AssetBrowserInspectType assetBrowserInspectType;
80 std::filesystem::directory_entry currentDirectory;
81 // TODO: Handle when the current mounting point
82 const Grindstone::Editor::FileManager::MountPoint* currentMountingPoint = nullptr;
83
84 bool isShowingPanel = true;
85 EngineCore* engineCore = nullptr;
86 ImguiEditor* editor = nullptr;
87 bool isRenamingFolder;
88 size_t indexToRename;
89 std::string pathRenameNewName;
90 std::string searchText;
91 std::string searchTextLower;
92 std::vector<std::filesystem::path> folders;
93 std::vector<AssetBrowserItem> files;
94 std::chrono::time_point<std::chrono::system_clock> lastRefreshedAssetsTime;
95 };
96}
Definition ImguiRenderer.hpp:12
Definition EngineCore.hpp:59
Definition Uuid.hpp:7
Definition FileManager.hpp:10