Adds scene management system with GameObjects and Components. Improves asset loading by scanning assets in a background thread and queuing textures for upload. Also displays a progress bar in the file browser for texture loading. Adds basic component system with TagComponent to identify GameObjects by a user defined name.
72 lines
2.3 KiB
C++
72 lines
2.3 KiB
C++
// File: src/FileBrowser.h
|
|
#pragma once
|
|
|
|
#include <functional>
|
|
#include <string>
|
|
#include <vector>
|
|
#include <memory>
|
|
#include "systems/AssetManager.h" // for ResourceTreeNode
|
|
#include "systems/assets/Texture2D.h" // for Texture2D
|
|
#include "imgui.h"
|
|
|
|
namespace OX {
|
|
|
|
/// Configuration for look & feel
|
|
struct FileBrowserConfig
|
|
{
|
|
float thumbnailSize = 64.0f;
|
|
float padding = 8.0f;
|
|
float labelHeight = 20.0f;
|
|
ImU32 bgColor = IM_COL32(40,40,40,255);
|
|
ImU32 highlightColor = IM_COL32(75,75,75,255);
|
|
bool showGrid = true;
|
|
bool showThumbnails = true;
|
|
bool allowMultiple = false;
|
|
// … add more theming or behavioral flags here
|
|
};
|
|
|
|
/// FileBrowser widget, supports grid & list, filtering, breadcrumbs, callbacks.
|
|
class FileBrowser
|
|
{
|
|
public:
|
|
using FileSelectedCallback = std::function<void(const std::string& path)>;
|
|
|
|
FileBrowser();
|
|
~FileBrowser();
|
|
|
|
/// Draw the entire browser window
|
|
void Draw(const char* title = "File Browser");
|
|
|
|
/// Set a filter string (wildcards, substrings, etc.)
|
|
void SetFilter(const std::string& filter);
|
|
|
|
/// Called whenever the user clicks on a file (not directory)
|
|
void SetFileSelectedCallback(FileSelectedCallback cb);
|
|
|
|
|
|
|
|
/// Access to tweak colors/sizes
|
|
FileBrowserConfig& Config() { return _cfg; }
|
|
|
|
private:
|
|
// helpers
|
|
void DrawToolbar();
|
|
void DrawBreadcrumbs();
|
|
void DrawGridView(const std::shared_ptr<ResourceTreeNode>& node);
|
|
void DrawListView(const std::shared_ptr<ResourceTreeNode>& node);
|
|
[[nodiscard]] bool PassesFilter(const std::string& name) const;
|
|
void SetProgress(float p);
|
|
ImTextureID GetIconTexture(const ResourceTreeNode&); // stub for folder/file icons
|
|
|
|
// state
|
|
FileBrowserConfig _cfg;
|
|
std::string _currentPath = "res://";
|
|
std::string _filter;
|
|
bool _gridMode = true;
|
|
FileSelectedCallback _onFileSelected;
|
|
float _lastProgress;
|
|
size_t _maxQueueSize;
|
|
|
|
};
|
|
} // namespace OX
|