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 void AddFilePath(const std::filesystem::directory_entry& file);
46
47 void SetCurrentAssetDirectory(const std::filesystem::path& path);
48 void SetFilesFromCurrentDirectory();
49 void ProcessFolderClicks(const std::filesystem::path& path);
50 void ProcessFileClicks(AssetBrowserItem& item);
51 void RenderTopBar();
52 void RenderPathPart(const std::filesystem::path& path);
53 void RenderPath();
54 void RenderContextMenuFileTypeSpecificEntries(const std::filesystem::path& path);
55 void RenderAssetContextMenu(bool isFolder, const std::filesystem::path& path, size_t index);
56 void RenderCurrentDirectoryContextMenu();
57 void RenderAssetTemplates(const std::filesystem::path& path);
58 size_t SortFile(bool isFolder, size_t indexToSort);
59 void TryRenameFile();
60 void RenderFolders();
61 void RenderFiles();
62 void RenderAssets(float height);
63 void RenderSidebar(float height);
64 void RenderSidebarSubdirectory(const std::filesystem::directory_entry& entry);
65 void RenderFile(size_t fileIndex);
66 void FilterSearch();
67 void AfterCreate(const std::filesystem::path& path);
68 ImTextureID GetIcon(const AssetType assetType) const;
69 private:
70 std::filesystem::directory_entry currentDirectory;
71 // TODO: Handle when the current mounting point
72 const Grindstone::Editor::FileManager::MountPoint* currentMountingPoint = nullptr;
73
74 struct IconsIds {
75 ImTextureID folderIcon;
76 ImTextureID fileIcons[static_cast<uint16_t>(AssetType::Count)];
77 } iconIds;
78
79 bool isShowingPanel = true;
80 EngineCore* engineCore = nullptr;
81 ImguiEditor* editor = nullptr;
82 bool isRenamingFolder;
83 size_t indexToRename;
84 std::string pathRenameNewName;
85 std::string searchText;
86 std::string searchTextLower;
87 std::vector<std::filesystem::path> folders;
88 std::vector<AssetBrowserItem> files;
89 std::chrono::time_point<std::chrono::system_clock> lastRefreshedAssetsTime;
90 };
91}
Definition ImguiRenderer.hpp:12
Definition EngineCore.hpp:58
Definition Uuid.hpp:7
Definition FileManager.hpp:10