LumixEngine/src/editor/asset_browser.h

82 lines
2.1 KiB
C
Raw Normal View History

2015-09-14 18:03:45 +02:00
#pragma once
2016-01-13 00:48:20 +01:00
2015-09-14 18:03:45 +02:00
#include "core/array.h"
#include "core/path.h"
#include "core/mt/sync.h"
2015-09-14 18:03:45 +02:00
namespace Lumix
{
class Material;
class Resource;
class WorldEditor;
}
2015-09-20 17:30:37 +02:00
class FileSystemWatcher;
2015-09-29 22:21:43 +02:00
class Metadata;
2015-09-20 17:30:37 +02:00
2016-01-14 00:09:57 +01:00
class LUMIX_EDITOR_API AssetBrowser
2015-09-14 18:03:45 +02:00
{
public:
class IPlugin
{
public:
virtual ~IPlugin() {}
virtual bool onGUI(Lumix::Resource* resource, Lumix::uint32 type) = 0;
virtual Lumix::uint32 getResourceType(const char* ext) = 0;
virtual void onResourceUnloaded(Lumix::Resource* resource) = 0;
virtual const char* getName() const = 0;
virtual bool hasResourceManager(Lumix::uint32 type) const = 0;
};
2015-09-14 18:03:45 +02:00
public:
2015-09-29 22:21:43 +02:00
AssetBrowser(Lumix::WorldEditor& editor, Metadata& metadata);
2015-09-20 17:30:37 +02:00
~AssetBrowser();
2015-10-03 01:14:38 +02:00
void onGUI();
void update();
const Lumix::Array<Lumix::Path>& getResources(int type) const;
2016-01-13 00:48:20 +01:00
int getTypeIndexFromManagerType(Lumix::uint32 type) const;
void selectResource(const Lumix::Path& resource);
2016-01-13 00:52:31 +01:00
bool resourceInput(const char* label, const char* str_id, char* buf, int max_size, Lumix::uint32 type);
void addPlugin(IPlugin& plugin);
void openInExternalEditor(Lumix::Resource* resource);
2016-02-18 20:06:10 +01:00
void openInExternalEditor(const char* path);
void enableUpdate(bool enable) { m_is_update_enabled = enable; }
2015-09-14 18:03:45 +02:00
2015-09-19 01:18:52 +02:00
public:
bool m_is_opened;
2015-09-14 18:03:45 +02:00
private:
2015-09-20 17:30:37 +02:00
void onFileChanged(const char* path);
2015-09-14 18:03:45 +02:00
void findResources();
2016-02-18 20:06:10 +01:00
void processDir(const char* path, int base_length);
2015-09-14 18:03:45 +02:00
void addResource(const char* path, const char* filename);
2015-10-03 01:14:38 +02:00
void onGUIResource();
void unloadResource();
void selectResource(Lumix::Resource* resource);
2016-01-13 00:48:20 +01:00
int getResourceTypeIndex(const char* ext);
Lumix::uint32 getResourceType(const char* path) const;
2015-09-14 18:03:45 +02:00
private:
2015-09-29 22:21:43 +02:00
Metadata& m_metadata;
Lumix::Array<Lumix::Path> m_changed_files;
Lumix::Array<Lumix::Path> m_history;
Lumix::Array<IPlugin*> m_plugins;
Lumix::MT::SpinMutex m_changed_files_mutex;
2015-09-14 18:03:45 +02:00
Lumix::Array<Lumix::Array<Lumix::Path> > m_resources;
Lumix::Resource* m_selected_resource;
2015-09-14 18:03:45 +02:00
Lumix::WorldEditor& m_editor;
2016-02-18 20:06:10 +01:00
FileSystemWatcher* m_watchers[2];
2015-09-21 22:35:36 +02:00
int m_current_type;
char m_filter[128];
Lumix::Path m_wanted_resource;
bool m_autoreload_changed_resource;
bool m_is_focus_requested;
bool m_activate;
bool m_is_update_enabled;
2015-09-14 18:03:45 +02:00
};