17#include <imgui_internal.h>
18#include <imgui_stdlib.h>
23 "glsl",
"cmn",
"frag",
"vert",
"cmp",
"geom",
"tesc",
"tese",
26 "layout",
"looknfeel",
"scheme",
"xsd",
"imageset",
"xcf",
"txt",
"anims",
28 "mtl",
"md5anim",
"bvh",
33 "png",
"jpg",
"jpeg",
"tga",
"raw",
"dds"
37 "wav",
"ogg",
"mp3",
"mid"
41 "glsl",
"vert",
"frag",
"geom",
"comp",
"cmn",
"tesc",
"tese"
144 const std::filesystem::path p(directoryPath.
string());
145 if ( std::filesystem::is_directory(p))
148 directoryOut.
_path = directoryPath;
150 for (
auto&& x : std::filesystem::directory_iterator(p))
152 if (std::filesystem::is_regular_file(x.path()))
161 else if (std::filesystem::is_directory(x.path()))
163 auto& childDirectory = directoryOut.
_children.emplace_back(std::make_unique<Directory>());
172 ImGuiTreeNodeFlags nodeFlags = (open ? ImGuiTreeNodeFlags_DefaultOpen : 0);
175 nodeFlags |= ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen;
178 if (ImGui::TreeNodeEx(dir.
_name.
string().c_str(), nodeFlags))
180 if (ImGui::IsItemClicked() || ImGui::IsItemToggledOpen()) {
184 for (
const auto& childDirectory : dir.
_children) {
197 static bool previewTexture =
false;
198 static bool spawnMesh =
false;
202 const auto isSoundFile = [](
const char* extension) {
203 for (
const char* ext : g_soundExtensions) {
212 const auto isShaderFile = [](
const char* extension) {
213 for (
const char* ext : g_shaderExtensions) {
222 const auto openFileInEditor = [&](
const ResourcePath& path,
const File& file) {
225 if (textEditor.
empty())
238 constexpr U8 buttonSize = 64u;
241 const ImVec2 uv0{ 0.f, flipImages ? 1.f : 0.f };
242 const ImVec2 uv1{ 1.f, flipImages ? 0.f : 1.f };
244 ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f);
247 ImGui::BeginChild(
"Folders", ImVec2(ImGui::GetContentRegionAvail().x * 0.3f, -1),
true, ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_HorizontalScrollbar);
248 if (ImGui::BeginMenuBar()) {
249 if (ImGui::BeginMenu(
"Menu")) {
250 ImGui::MenuItem(
"Refresh",
nullptr,
nullptr,
false);
264 ImGui::BeginChild(
"Contents", ImVec2(0, -1),
true, ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_HorizontalScrollbar);
265 if (ImGui::BeginMenuBar()) {
266 if (ImGui::BeginMenu(
"Menu")) {
267 ImGui::MenuItem(
"Refresh",
nullptr,
nullptr,
false);
276 bool lockTextureQueue =
false;
282 for (
const char* extension : g_imageExtensions)
289 if (it == std::cend(
_loadedTextures) || it->second == INVALID_HANDLE<Texture>)
302 lockTextureQueue =
true;
318 bool hasTooltip =
false;
319 if (tex != INVALID_HANDLE<Texture>)
321 const U16 w =
Get(tex)->width();
322 const U16 h =
Get(tex)->height();
325 if (ImGui::ImageButton(
Get(tex)->resourceName().c_str(),
to_TexID(tex), ImVec2(buttonSize, buttonSize / aspect), uv0, uv1))
329 previewTexture =
true;
335 const U16 w =
Get(icon)->width();
336 const U16 h =
Get(icon)->height();
339 const bool modifierPressed = imguiContext.IO.KeyShift;
340 const ImVec4 bgColour(modifierPressed ? 1.f : 0.f, 0.f, 0.f, modifierPressed ? 1.f : 0.f);
341 if (ImGui::ImageButton(
Get(icon)->resourceName().c_str(),
to_TexID(icon), ImVec2(buttonSize, buttonSize / aspect), uv0, uv1, bgColour, ImVec4(1, 1, 1, 1)))
351 if (ImGui::IsItemHovered())
353 ImGui::SetTooltip(
"Hold down [Shift] to spawn directly at the camera position");
356 else if (isSoundFile(file._extension.c_str()))
366 }
else if (isShaderFile(file._extension.c_str())) {
388 static string pathString =
"";
390 pathString = file._path.string();
391 if (!hasTooltip && ImGui::IsItemHovered())
393 ImGui::SetTooltip( pathString.c_str() );
396 ImGui::Text( pathString.c_str() );
400 if (lockTextureQueue)
410 previewTexture =
false;
418 ImGui::PopStyleVar();
424 textureResource.assetName( textureName );
425 textureResource.assetLocation(texturePath);
428 descriptor._textureOptions._useDDSCache =
false;
436 model.assetLocation(modelPath);
437 model.assetName( modelName );
#define PROFILE_SCOPE_AUTO(CATEGORY)
static Camera * playerCamera(const Divide::ProjectManager *mgr, const bool skipOverride=false) noexcept
const CameraSnapshot & snapshot() const noexcept
Returns the internal camera snapshot data (eye, orientation, etc)
Handle< Texture > _soundIcon
eastl::stack< EditorFileEntry > _textureLoadQueue
void drawInternal() override
std::array< Handle< Texture >, to_base(GeometryFormat::COUNT)+1 > _geometryIcons
Handle< Texture > _shaderIcon
void getDirectoryStructureForPath(const ResourcePath &directoryPath, Directory &directoryOut) const
ContentExplorerWindow(Editor &parent, const Descriptor &descriptor)
Handle< Mesh > _spawnMesh
bool _textureLoadQueueLocked
Handle< Texture > _previewTexture
vector< Directory > _currentDirectories
void printDirectoryStructure(const Directory &dir, bool open) const
Handle< Texture > _fileIcon
void update(U64 deltaTimeUS)
Handle< Texture > getTextureForPath(const ResourcePath &texturePath, std::string_view textureName) const
const Directory * _selectedDir
Handle< Mesh > getModelForPath(const ResourcePath &modelPath, std::string_view modelName) const
hashMap< size_t, Handle< Texture > > _loadedTextures
const Descriptor & descriptor() const noexcept
PlatformContext & context() noexcept
Kernel & kernel() noexcept
constexpr Optick::Category::Type GUI
bool CompareIgnoreCase(const char *a, const char *b) noexcept
bool IsValidFile(const ResourcePath &name)
constexpr const char * g_soundExtensions[]
constexpr const char * g_imageExtensions[]
constexpr const char * g_extensions[]
constexpr const char * g_shaderExtensions[]
Handle console commands that start with a forward slash.
ImTextureID to_TexID(Handle< Texture > handle)
FileError openFile(const std::string_view cmd, const ResourcePath &filePath, const std::string_view fileName)
FORCE_INLINE void DestroyResource(Handle< T > &handle, const bool immediate=false)
ResourcePath getTopLevelFolderName(const ResourcePath &filePath)
bool hasExtension(const ResourcePath &filePath, const std::string_view extensionNoDot)
const char *const g_geometryExtensions[]
@ RES_LOADED
The resource is available for usage.
constexpr F32 to_F32(const T value)
string getExtension(const std::string_view fileName)
GeometryFormat GetGeometryFormatForExtension(const char *extension) noexcept
static const vec3< F32 > VECTOR3_UNIT
constexpr U64 _ID(const char *const str, const U64 value=val_64_const) noexcept
FORCE_INLINE Handle< T > CreateResource(const ResourceDescriptor< T > &descriptor, bool &wasInCache, std::atomic_uint &taskCounter)
::value constexpr T CLAMPED(T n, T min, T max) noexcept
constexpr I32 to_I32(const T value)
FORCE_INLINE T * Get(const Handle< T > handle)
Project const SceneEntry & entry
constexpr auto to_base(const Type value) -> Type
vector< Directory_uptr > _children
PropertyDescriptor< T > _propertyDescriptor
StringReturnType< N > string() const noexcept
bool empty() const noexcept