Elevate Engine 1
Loading...
Searching...
No Matches
AssetBrowserPanel.h
Go to the documentation of this file.
1#pragma once
2
3#include <filesystem>
4#include <unordered_map>
5#include <vector>
6
9
10namespace Elevate::Editor {
11
12 enum FileType {
14 File = 1,
16 Image = 3
17 };
18
19 struct FileMetadata {
21 std::string iconPath;
22
23 FileMetadata() = default;
25 {
26 this->type = type;
27 this->iconPath = iconPath;
28 }
29
30 static FileType ParseFileType(std::string typeStr) {
31 if (typeStr == "DIRECTORY") {
33 }
34 else if (typeStr == "FILE") {
35 return FileType::File;
36 }
37 else if (typeStr == "IMAGE") {
38 return FileType::Image;
39 }
40 else {
41 return FileType::Internal;
42 }
43 }
44 };
45
46 struct FileItem {
47 std::string name;
48 std::string path;
49 std::string extension;
50 std::string iconPath;
52
53 FileItem() = default;
54 FileItem(std::string filePath, std::string fileName, std::string fileExtension, std::string icon, FileType type) :
55 path(filePath), name(fileName), extension(fileExtension), iconPath(icon), type(type) { }
56 };
57
58 struct BrowserPath {
59 std::filesystem::path Path;
60 std::string DisplayName;
61 };
62
64 {
65 public:
67
68 void OnUpdate() override;
69 void OnImGuiRender() override;
70
71 private:
72 // Update the paths at the top of the browser
73 void UpdateRelatedPaths();
74 void AddParentPaths(std::filesystem::path path);
75
76 void LoadFileItemsList();
77 void LoadExtensionsMeta(std::string filepath = "editor://Config/file_browser.json");
78
79 std::filesystem::path m_CurrentPath = ".";
80 std::vector<BrowserPath> m_relatedPaths;
81
82 // < Path , Texture >
83 std::unordered_map<std::string, TexturePtr> m_currentTextures;
84 std::vector<std::string> m_ignoredExtensions;
85 TexturePtr m_folderTexture;
86
87 std::vector<FileItem> m_FileItems;
88 std::unordered_map<std::string, FileMetadata> m_FileMetadata;
89
90 bool m_shouldUpdate = true;
91 };
92}
std::shared_ptr< Texture > TexturePtr
Definition Texture.h:13
FileItem(std::string filePath, std::string fileName, std::string fileExtension, std::string icon, FileType type)
static FileType ParseFileType(std::string typeStr)
FileMetadata(FileType type, std::string iconPath)