VEX Engine
Retro looking game engine made in vulkan mostly because i wanted to understand it better.
Loading...
Searching...
No Matches
AssetBrowser.hpp
Go to the documentation of this file.
1
6
7#pragma once
8#include <imgui.h>
9#include <filesystem>
10#include <string>
11#include <algorithm>
12#include <vector>
13
14namespace vex {
15
17 struct BrowserIcons {
18 ImTextureID folder = 0;
19 ImTextureID file = 0;
20 ImTextureID mesh = 0;
21 ImTextureID texture = 0;
22 ImTextureID scene = 0;
23 ImTextureID text = 0;
24 ImTextureID ui = 0;
25 ImTextureID audio = 0;
26 };
27
30 public:
35 AssetBrowser(const std::string& rootPath);
36
45 std::string Draw(const BrowserIcons& icons, float& thumbnailSize, bool showBottomBar = true, float height = 0.0f);
46
52 int GetJSONAssetType(const std::string path);
53
59 std::string GetExtension(const std::string path);
60
63 void setPadding(float padding) { m_padding = padding; }
64
67 std::string getCurrentPath() const { return m_currentPath.string(); }
68
69 private:
70 std::filesystem::path m_rootPath;
71 std::filesystem::path m_currentPath;
72
73 float m_padding = 16.0f;
74
75 std::filesystem::path m_copiedPath;
76 bool m_isCut = false;
77
78 bool m_renaming = false;
79 std::filesystem::path m_renamePath;
80 char m_renameBuffer[256] = "";
81
82 char m_searchBuffer[256] = "";
83
90 ImTextureID GetIcon(const std::filesystem::directory_entry& entry, const BrowserIcons& icons);
91 };
92}
AssetBrowser(const std::string &rootPath)
Constructs the AssetBrowser.
std::string Draw(const BrowserIcons &icons, float &thumbnailSize, bool showBottomBar=true, float height=0.0f)
Draws the Asset Browser UI and handles interaction.
void setPadding(float padding)
Sets the padding between asset icons in the browser.
int GetJSONAssetType(const std::string path)
Determines the type of a JSON asset (e.g., scene, material, etc.).
ImTextureID GetIcon(const std::filesystem::directory_entry &entry, const BrowserIcons &icons)
Gets the appropriate icon texture ID for a given directory entry.
std::string getCurrentPath() const
Gets the currently viewed directory path.
std::string GetExtension(const std::string path)
Extracts the file extension from a path.
Structure holding texture IDs for various asset types displayed in the browser.