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"
|
2015-11-13 16:52:42 +01:00
|
|
|
#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:
|
2015-12-30 12:17:34 +01:00
|
|
|
class IPlugin
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~IPlugin() {}
|
|
|
|
|
|
|
|
virtual bool onGUI(Lumix::Resource* resource, Lumix::uint32 type) = 0;
|
2015-12-30 12:38:25 +01:00
|
|
|
virtual Lumix::uint32 getResourceType(const char* ext) = 0;
|
2015-12-30 12:17:34 +01:00
|
|
|
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();
|
2015-09-20 20:28:51 +02:00
|
|
|
void update();
|
2015-12-30 12:17:34 +01:00
|
|
|
const Lumix::Array<Lumix::Path>& getResources(int type) const;
|
2016-01-13 00:48:20 +01:00
|
|
|
int getTypeIndexFromManagerType(Lumix::uint32 type) const;
|
2015-10-09 00:28:53 +02:00
|
|
|
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);
|
2015-12-30 12:17:34 +01:00
|
|
|
void addPlugin(IPlugin& plugin);
|
2015-12-30 12:38:25 +01:00
|
|
|
void openInExternalEditor(Lumix::Resource* resource);
|
2016-02-18 20:06:10 +01:00
|
|
|
void openInExternalEditor(const char* path);
|
2016-02-21 14:35:15 +01:00
|
|
|
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();
|
2015-09-20 20:28:51 +02:00
|
|
|
void unloadResource();
|
|
|
|
void selectResource(Lumix::Resource* resource);
|
2016-01-13 00:48:20 +01:00
|
|
|
int getResourceTypeIndex(const char* ext);
|
2015-12-30 12:17:34 +01:00
|
|
|
|
|
|
|
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;
|
2015-09-20 20:28:51 +02:00
|
|
|
Lumix::Array<Lumix::Path> m_changed_files;
|
2015-10-30 00:59:48 +01:00
|
|
|
Lumix::Array<Lumix::Path> m_history;
|
2015-12-30 12:17:34 +01:00
|
|
|
Lumix::Array<IPlugin*> m_plugins;
|
2015-10-29 18:09:09 +01:00
|
|
|
Lumix::MT::SpinMutex m_changed_files_mutex;
|
2015-09-14 18:03:45 +02:00
|
|
|
Lumix::Array<Lumix::Array<Lumix::Path> > m_resources;
|
2015-09-20 20:28:51 +02:00
|
|
|
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];
|
2015-10-09 00:28:53 +02:00
|
|
|
Lumix::Path m_wanted_resource;
|
2015-09-20 20:28:51 +02:00
|
|
|
bool m_autoreload_changed_resource;
|
2015-10-17 20:13:59 +02:00
|
|
|
bool m_is_focus_requested;
|
2016-02-12 21:55:02 +01:00
|
|
|
bool m_activate;
|
2016-02-21 14:35:15 +01:00
|
|
|
bool m_is_update_enabled;
|
2015-09-14 18:03:45 +02:00
|
|
|
};
|