asset browser plugins use extensions instead of ResourceType, so visual shader graphs can be handled by different plugin than text shader
This commit is contained in:
parent
956f21ef61
commit
1fc74ded20
|
@ -37,8 +37,7 @@ namespace
|
|||
{
|
||||
|
||||
|
||||
struct AnimationAssetBrowserPlugin : AssetBrowser::Plugin
|
||||
{
|
||||
struct AnimationAssetBrowserPlugin : AssetBrowser::IPlugin {
|
||||
explicit AnimationAssetBrowserPlugin(StudioApp& app)
|
||||
: m_app(app)
|
||||
{
|
||||
|
@ -46,13 +45,12 @@ struct AnimationAssetBrowserPlugin : AssetBrowser::Plugin
|
|||
}
|
||||
|
||||
const char* getLabel() const override { return "Animation"; }
|
||||
ResourceType getResourceType() const override { return Animation::TYPE; }
|
||||
|
||||
StudioApp& m_app;
|
||||
};
|
||||
|
||||
|
||||
struct PropertyAnimationPlugin : AssetBrowser::Plugin, AssetCompiler::IPlugin {
|
||||
struct PropertyAnimationPlugin : AssetBrowser::IPlugin, AssetCompiler::IPlugin {
|
||||
struct EditorWindow : AssetEditorWindow {
|
||||
EditorWindow(const Path& path, StudioApp& app)
|
||||
: AssetEditorWindow(app)
|
||||
|
@ -245,7 +243,6 @@ struct PropertyAnimationPlugin : AssetBrowser::Plugin, AssetCompiler::IPlugin {
|
|||
void createResource(OutputMemoryStream& blob) override {}
|
||||
bool compile(const Path& src) override { return m_app.getAssetCompiler().copyCompile(src); }
|
||||
const char* getLabel() const override { return "Property animation"; }
|
||||
ResourceType getResourceType() const override { return PropertyAnimation::TYPE; }
|
||||
|
||||
void openEditor(const Path& path) override {
|
||||
IAllocator& allocator = m_app.getAllocator();
|
||||
|
@ -336,12 +333,13 @@ struct StudioAppPlugin : StudioApp::IPlugin
|
|||
void init() override {
|
||||
PROFILE_FUNCTION();
|
||||
AssetCompiler& compiler = m_app.getAssetCompiler();
|
||||
const char* anp_exts[] = { "anp", nullptr };
|
||||
compiler.addPlugin(m_prop_anim_plugin, anp_exts);
|
||||
const char* anp_exts[] = { "anp" };
|
||||
const char* ani_exts[] = { "ani" };
|
||||
compiler.addPlugin(m_prop_anim_plugin, Span(anp_exts));
|
||||
|
||||
AssetBrowser& asset_browser = m_app.getAssetBrowser();
|
||||
asset_browser.addPlugin(m_animation_plugin);
|
||||
asset_browser.addPlugin(m_prop_anim_plugin);
|
||||
asset_browser.addPlugin(m_animation_plugin, Span(ani_exts));
|
||||
asset_browser.addPlugin(m_prop_anim_plugin, Span(anp_exts));
|
||||
|
||||
m_app.getPropertyGrid().addPlugin(m_animable_plugin);
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ static bool editInput(const char* label, u32* input_index, const Controller& con
|
|||
return changed;
|
||||
}
|
||||
|
||||
struct ControllerEditorImpl : ControllerEditor, AssetBrowser::Plugin, AssetCompiler::IPlugin {
|
||||
struct ControllerEditorImpl : ControllerEditor, AssetBrowser::IPlugin, AssetCompiler::IPlugin {
|
||||
struct SetInputEventType : EventType {
|
||||
SetInputEventType() {
|
||||
type = RuntimeHash("set_input");
|
||||
|
@ -1203,10 +1203,10 @@ struct ControllerEditorImpl : ControllerEditor, AssetBrowser::Plugin, AssetCompi
|
|||
{
|
||||
m_event_types.push(UniquePtr<SetInputEventType>::create(m_allocator));
|
||||
AssetCompiler& compiler = app.getAssetCompiler();
|
||||
const char* act_exts[] = { "act" };
|
||||
compiler.registerExtension("act", anim::Controller::TYPE);
|
||||
const char* act_exts[] = { "act", nullptr };
|
||||
compiler.addPlugin(*this, act_exts);
|
||||
app.getAssetBrowser().addPlugin(*this);
|
||||
compiler.addPlugin(*this, Span(act_exts));
|
||||
app.getAssetBrowser().addPlugin(*this, Span(act_exts));
|
||||
}
|
||||
|
||||
~ControllerEditorImpl() {
|
||||
|
@ -1229,7 +1229,6 @@ struct ControllerEditorImpl : ControllerEditor, AssetBrowser::Plugin, AssetCompi
|
|||
const char* getDefaultExtension() const override { return "act"; }
|
||||
bool compile(const Path& src) override { return m_app.getAssetCompiler().copyCompile(src); }
|
||||
const char* getLabel() const override { return "Animation Controller"; }
|
||||
ResourceType getResourceType() const override { return anim::Controller::TYPE; }
|
||||
|
||||
const EventType& getEventType(RuntimeHash type) const {
|
||||
for (const UniquePtr<EventType>& t : m_event_types) {
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace
|
|||
{
|
||||
|
||||
|
||||
struct AssetBrowserPlugin final : AssetBrowser::Plugin, AssetCompiler::IPlugin {
|
||||
struct AssetBrowserPlugin final : AssetBrowser::IPlugin, AssetCompiler::IPlugin {
|
||||
struct Meta {
|
||||
bool looped = true;
|
||||
float volume = 1.f;
|
||||
|
@ -172,7 +172,6 @@ struct AssetBrowserPlugin final : AssetBrowser::Plugin, AssetCompiler::IPlugin {
|
|||
}
|
||||
|
||||
const char* getLabel() const override { return "Audio"; }
|
||||
ResourceType getResourceType() const override { return Clip::TYPE; }
|
||||
|
||||
StudioApp& m_app;
|
||||
AssetBrowser& m_browser;
|
||||
|
@ -190,9 +189,9 @@ struct StudioAppPlugin : StudioApp::IPlugin
|
|||
|
||||
void init() override
|
||||
{
|
||||
m_app.getAssetBrowser().addPlugin(m_asset_browser_plugin);
|
||||
const char* extensions[] = { "ogg", "wav", nullptr };
|
||||
m_app.getAssetCompiler().addPlugin(m_asset_browser_plugin, extensions);
|
||||
const char* extensions[] = { "ogg", "wav" };
|
||||
m_app.getAssetCompiler().addPlugin(m_asset_browser_plugin, Span(extensions));
|
||||
m_app.getAssetBrowser().addPlugin(m_asset_browser_plugin, Span(extensions));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ static Span<const char> getSubresource(const char* str) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool AssetBrowser::Plugin::createTile(const char* in_path, const char* out_path, ResourceType type) {
|
||||
bool AssetBrowser::IPlugin::createTile(const char* in_path, const char* out_path, ResourceType type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -68,6 +68,7 @@ struct AssetBrowserImpl : AssetBrowser {
|
|||
FilePathHash file_path_hash;
|
||||
void* tex = nullptr;
|
||||
bool create_called = false;
|
||||
u64 extension = 0;
|
||||
};
|
||||
|
||||
struct ImmediateTile : FileInfo {
|
||||
|
@ -79,6 +80,7 @@ struct AssetBrowserImpl : AssetBrowser {
|
|||
, m_selected_resources(m_allocator)
|
||||
, m_dir_history(m_allocator)
|
||||
, m_plugins(m_allocator)
|
||||
, m_plugin_map(m_allocator)
|
||||
, m_app(app)
|
||||
, m_is_open(false)
|
||||
, m_show_thumbnails(true)
|
||||
|
@ -262,6 +264,10 @@ struct AssetBrowserImpl : AssetBrowser {
|
|||
tile.file_path_hash = path.getHash();
|
||||
tile.filepath = path.c_str();
|
||||
tile.clamped_filename = filename;
|
||||
Span<const char> ext = Path::getExtension(subres);
|
||||
tile.extension = 0;
|
||||
ASSERT(ext.length() <= sizeof(tile.extension));
|
||||
memcpy(&tile.extension, ext.begin(), ext.length());
|
||||
|
||||
m_file_infos.push(tile);
|
||||
}
|
||||
|
@ -400,7 +406,7 @@ struct AssetBrowserImpl : AssetBrowser {
|
|||
|
||||
tile.create_called = true;
|
||||
const AssetCompiler& compiler = m_app.getAssetCompiler();
|
||||
for (Plugin* plugin : m_plugins) {
|
||||
for (IPlugin* plugin : m_plugins) {
|
||||
ResourceType type = compiler.getResourceType(tile.filepath);
|
||||
if (plugin->createTile(tile.filepath, out_path, type)) break;
|
||||
}
|
||||
|
@ -455,8 +461,7 @@ struct AssetBrowserImpl : AssetBrowser {
|
|||
ImVec2 end_pos = screen_pos + img_size;
|
||||
dl->AddRectFilled(screen_pos, end_pos, 0xffFFffFF);
|
||||
|
||||
const ResourceType type = m_app.getAssetCompiler().getResourceType(tile.filepath);
|
||||
auto iter = m_plugins.find(type);
|
||||
auto iter = m_plugin_map.find(tile.extension);
|
||||
if (iter.isValid()) {
|
||||
const char* label = iter.value()->getLabel();
|
||||
ImGui::PushFont(m_app.getBoldFont());
|
||||
|
@ -637,7 +642,7 @@ struct AssetBrowserImpl : AssetBrowser {
|
|||
ImGui::Separator();
|
||||
static char filter[64] = "";
|
||||
ImGuiEx::filter("Filter", filter, sizeof(filter), -1, ImGui::IsWindowAppearing());
|
||||
for (Plugin* plugin : m_plugins) {
|
||||
for (IPlugin* plugin : m_plugins) {
|
||||
if (!plugin->canCreateResource()) continue;
|
||||
if (filter[0] && stristr(plugin->getLabel(), filter) == nullptr) continue;
|
||||
if (ImGui::BeginMenu(plugin->getLabel())) {
|
||||
|
@ -832,19 +837,22 @@ struct AssetBrowserImpl : AssetBrowser {
|
|||
}
|
||||
}
|
||||
|
||||
void removePlugin(Plugin& plugin) override
|
||||
{
|
||||
m_plugins.erase(plugin.getResourceType());
|
||||
void removePlugin(IPlugin& plugin) override {
|
||||
m_plugins.eraseItem(&plugin);
|
||||
m_plugin_map.eraseIf([&plugin](IPlugin* p){ return p == &plugin; });
|
||||
}
|
||||
|
||||
|
||||
void addPlugin(Plugin& plugin) override
|
||||
{
|
||||
m_plugins.insert(plugin.getResourceType(), &plugin);
|
||||
void addPlugin(IPlugin& plugin, Span<const char*> extensions) override {
|
||||
m_plugins.push(&plugin);
|
||||
for (const char* ext : extensions) {
|
||||
u64 key = 0;
|
||||
ASSERT(stringLength(ext) <= sizeof(key));
|
||||
memcpy(&key, ext, stringLength(ext));
|
||||
m_plugin_map.insert(key, &plugin);
|
||||
}
|
||||
}
|
||||
|
||||
static void copyDir(const char* src, const char* dest, IAllocator& allocator)
|
||||
{
|
||||
static void copyDir(const char* src, const char* dest, IAllocator& allocator) {
|
||||
PathInfo fi(src);
|
||||
StaticString<LUMIX_MAX_PATH> dst_dir(dest, "/", fi.m_basename);
|
||||
if (!os::makePath(dst_dir)) logError("Could not create ", dst_dir);
|
||||
|
@ -888,13 +896,12 @@ struct AssetBrowserImpl : AssetBrowser {
|
|||
return;
|
||||
}
|
||||
|
||||
const ResourceType type = m_app.getAssetCompiler().getResourceType(path);
|
||||
for (Plugin* p : m_plugins) {
|
||||
if (p->getResourceType() == type) {
|
||||
p->openEditor(path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Span<const char> ext = Path::getExtension(path.c_str());
|
||||
u64 key = 0;
|
||||
ASSERT(ext.length() <= sizeof(key));
|
||||
memcpy(&key, ext.begin(), ext.length());
|
||||
auto iter = m_plugin_map.find(key);
|
||||
if (iter.isValid()) iter.value()->openEditor(path);
|
||||
}
|
||||
|
||||
void selectResource(const Path& path, bool additive) {
|
||||
|
@ -1048,6 +1055,11 @@ struct AssetBrowserImpl : AssetBrowser {
|
|||
clampText(filename, 50);
|
||||
fi.clamped_filename = filename;
|
||||
fi.create_called = false;
|
||||
Span<const char> ext = Path::getExtension(filename);
|
||||
fi.extension = 0;
|
||||
ASSERT(ext.length() <= sizeof(fi.extension));
|
||||
memcpy(&fi.extension, ext.begin(), ext.length());
|
||||
|
||||
idx = m_immediate_tiles.size() - 1;
|
||||
}
|
||||
|
||||
|
@ -1056,29 +1068,6 @@ struct AssetBrowserImpl : AssetBrowser {
|
|||
}
|
||||
|
||||
bool resourceList(Span<char> buf, FilePathHash& selected_path_hash, ResourceType type, bool can_create_new, bool enter_submit) override {
|
||||
auto iter = m_plugins.find(type);
|
||||
if (!iter.isValid()) return false;
|
||||
|
||||
Plugin* plugin = iter.value();
|
||||
|
||||
static bool show_new_fs = false;
|
||||
if (can_create_new && plugin->canCreateResource() && ImGui::Selectable("New", false, ImGuiSelectableFlags_DontClosePopups)) {
|
||||
show_new_fs = true;
|
||||
}
|
||||
|
||||
FileSelector& file_selector = m_app.getFileSelector();
|
||||
if (file_selector.gui("Save As", &show_new_fs, plugin->getDefaultExtension(), true)) {
|
||||
OutputMemoryStream blob(m_allocator);
|
||||
plugin->createResource(blob);
|
||||
FileSystem& fs = m_app.getEngine().getFileSystem();
|
||||
if (!fs.saveContentSync(Path(file_selector.getPath()), blob)) {
|
||||
logError("Failed to write ", file_selector.getPath());
|
||||
return false;
|
||||
}
|
||||
copyString(buf, file_selector.getPath());
|
||||
return true;
|
||||
}
|
||||
|
||||
static char filter[128] = "";
|
||||
ImGuiEx::filter("Filter", filter, sizeof(filter), 200);
|
||||
|
||||
|
@ -1199,7 +1188,8 @@ struct AssetBrowserImpl : AssetBrowser {
|
|||
|
||||
EntityPtr m_dropped_entity = INVALID_ENTITY;
|
||||
char m_prefab_name[LUMIX_MAX_PATH] = "";
|
||||
HashMap<ResourceType, Plugin*> m_plugins;
|
||||
Array<IPlugin*> m_plugins;
|
||||
HashMap<u64, IPlugin*> m_plugin_map;
|
||||
Array<Path> m_selected_resources;
|
||||
int m_context_resource;
|
||||
char m_filter[128];
|
||||
|
|
|
@ -11,14 +11,13 @@ template <typename T> struct UniquePtr;
|
|||
struct LUMIX_EDITOR_API AssetBrowser : StudioApp::GUIPlugin {
|
||||
static constexpr int TILE_SIZE = 96;
|
||||
|
||||
struct LUMIX_EDITOR_API Plugin {
|
||||
struct LUMIX_EDITOR_API IPlugin {
|
||||
virtual bool canCreateResource() const { return false; }
|
||||
virtual void createResource(struct OutputMemoryStream& content) {}
|
||||
virtual const char* getDefaultExtension() const { return ""; }
|
||||
|
||||
virtual const char* getLabel() const = 0;
|
||||
virtual struct ResourceType getResourceType() const = 0;
|
||||
virtual bool createTile(const char* in_path, const char* out_path, ResourceType type);
|
||||
virtual bool createTile(const char* in_path, const char* out_path, struct ResourceType type);
|
||||
virtual void update() {}
|
||||
virtual void openEditor(const struct Path& path) {}
|
||||
};
|
||||
|
@ -29,8 +28,8 @@ struct LUMIX_EDITOR_API AssetBrowser : StudioApp::GUIPlugin {
|
|||
virtual void onInitFinished() = 0;
|
||||
virtual void openEditor(const Path& resource) = 0;
|
||||
virtual bool resourceInput(const char* str_id, Span<char> buf, ResourceType type, float width = -1) = 0;
|
||||
virtual void addPlugin(Plugin& plugin) = 0;
|
||||
virtual void removePlugin(Plugin& plugin) = 0;
|
||||
virtual void addPlugin(IPlugin& plugin, Span<const char*> extensions) = 0;
|
||||
virtual void removePlugin(IPlugin& plugin) = 0;
|
||||
virtual void openInExternalEditor(struct Resource* resource) const = 0;
|
||||
virtual void openInExternalEditor(const char* path) const = 0;
|
||||
virtual void locate(const Resource& resource) = 0;
|
||||
|
|
|
@ -802,14 +802,11 @@ struct AssetCompilerImpl : AssetCompiler {
|
|||
} while(removed);
|
||||
}
|
||||
|
||||
void addPlugin(IPlugin& plugin, const char** extensions) override
|
||||
{
|
||||
const char** i = extensions;
|
||||
while(*i) {
|
||||
const RuntimeHash hash(*i);
|
||||
void addPlugin(IPlugin& plugin, Span<const char*> extensions) override {
|
||||
for (const char* ext : extensions) {
|
||||
const RuntimeHash hash(ext);
|
||||
MutexGuard lock(m_plugin_mutex);
|
||||
m_plugins.insert(hash, &plugin);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ struct LUMIX_EDITOR_API AssetCompiler {
|
|||
virtual void onInitFinished() = 0;
|
||||
virtual void onGUI() = 0;
|
||||
virtual void update() = 0;
|
||||
virtual void addPlugin(IPlugin& plugin, const char** extensions) = 0;
|
||||
virtual void addPlugin(IPlugin& plugin, Span<const char*> extensions) = 0;
|
||||
virtual void removePlugin(IPlugin& plugin) = 0;
|
||||
virtual bool compile(const Path& path) = 0;
|
||||
virtual lua_State* getMeta(const Path& res) = 0;
|
||||
|
|
|
@ -6,14 +6,13 @@ EditorAssetPlugin::EditorAssetPlugin(const char* name, const char* ext, Resource
|
|||
: m_app(app)
|
||||
, m_name(name)
|
||||
, m_extension(ext)
|
||||
, m_resource_type(type)
|
||||
{
|
||||
AssetCompiler& compiler = app.getAssetCompiler();
|
||||
compiler.registerExtension(ext, type);
|
||||
const char* extensions[] = { ext, nullptr };
|
||||
compiler.addPlugin(*this, extensions);
|
||||
const char* extensions[] = { ext };
|
||||
compiler.addPlugin(*this, Span(extensions));
|
||||
AssetBrowser& browser = app.getAssetBrowser();
|
||||
browser.addPlugin(*this);
|
||||
browser.addPlugin(*this, Span(extensions));
|
||||
}
|
||||
|
||||
EditorAssetPlugin::~EditorAssetPlugin() {
|
||||
|
|
|
@ -7,22 +7,19 @@ namespace Lumix {
|
|||
// use this if you want an editor-only asset to be visible in asset browser
|
||||
// editor only assets do not inherit from Resource, e.g. particle system function
|
||||
// it can also be used as a base for normal asset plugin
|
||||
struct EditorAssetPlugin : AssetBrowser::Plugin, AssetCompiler::IPlugin {
|
||||
struct EditorAssetPlugin : AssetBrowser::IPlugin, AssetCompiler::IPlugin {
|
||||
EditorAssetPlugin(const char* name, const char* ext, ResourceType type, StudioApp& app, IAllocator& allocator);
|
||||
~EditorAssetPlugin();
|
||||
|
||||
bool compile(const Path& src) override { return true; }
|
||||
bool canCreateResource() const override { return true; }
|
||||
const char* getDefaultExtension() const override { return m_extension; }
|
||||
|
||||
const char* getLabel() const override { return m_name; }
|
||||
ResourceType getResourceType() const override { return m_resource_type; }
|
||||
|
||||
protected:
|
||||
StudioApp& m_app;
|
||||
const char* m_extension;
|
||||
const char* m_name;
|
||||
ResourceType m_resource_type;
|
||||
};
|
||||
|
||||
// common funcitonality for asset editor windows
|
||||
|
|
|
@ -24,8 +24,7 @@ namespace Lumix
|
|||
{
|
||||
|
||||
|
||||
struct AssetBrowserPlugin final : AssetBrowser::Plugin, AssetCompiler::IPlugin
|
||||
{
|
||||
struct AssetBrowserPlugin final : AssetBrowser::IPlugin, AssetCompiler::IPlugin {
|
||||
AssetBrowserPlugin(StudioApp& app, PrefabSystem& system)
|
||||
: system(system)
|
||||
, app(app)
|
||||
|
@ -35,7 +34,6 @@ struct AssetBrowserPlugin final : AssetBrowser::Plugin, AssetCompiler::IPlugin
|
|||
|
||||
bool compile(const Path& src) override { return app.getAssetCompiler().copyCompile(src); }
|
||||
const char* getLabel() const override { return "Prefab"; }
|
||||
ResourceType getResourceType() const override { return PrefabResource::TYPE; }
|
||||
|
||||
PrefabSystem& system;
|
||||
StudioApp& app;
|
||||
|
@ -648,9 +646,9 @@ static AssetBrowserPlugin* ab_plugin = nullptr;
|
|||
void PrefabSystem::createEditorPlugins(StudioApp& app, PrefabSystem& system)
|
||||
{
|
||||
ab_plugin = LUMIX_NEW(app.getAllocator(), AssetBrowserPlugin)(app, system);
|
||||
app.getAssetBrowser().addPlugin(*ab_plugin);
|
||||
const char* extensions[] = { "fab", nullptr };
|
||||
app.getAssetCompiler().addPlugin(*ab_plugin, extensions);
|
||||
const char* extensions[] = { "fab" };
|
||||
app.getAssetBrowser().addPlugin(*ab_plugin, Span(extensions));
|
||||
app.getAssetCompiler().addPlugin(*ab_plugin, Span(extensions));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ static const ComponentType GUI_TEXT_TYPE = reflection::getComponentType("gui_tex
|
|||
static const ComponentType GUI_BUTTON_TYPE = reflection::getComponentType("gui_button");
|
||||
static const ComponentType GUI_RENDER_TARGET_TYPE = reflection::getComponentType("gui_render_target");
|
||||
|
||||
struct SpritePlugin final : AssetBrowser::Plugin, AssetCompiler::IPlugin {
|
||||
struct SpritePlugin final : AssetBrowser::IPlugin, AssetCompiler::IPlugin {
|
||||
struct EditorWindow : AssetEditorWindow {
|
||||
EditorWindow(const Path& path, StudioApp& app)
|
||||
: AssetEditorWindow(app)
|
||||
|
@ -212,7 +212,6 @@ struct SpritePlugin final : AssetBrowser::Plugin, AssetCompiler::IPlugin {
|
|||
}
|
||||
|
||||
const char* getLabel() const override { return "Sprite"; }
|
||||
ResourceType getResourceType() const override { return Sprite::TYPE; }
|
||||
|
||||
StudioApp& m_app;
|
||||
};
|
||||
|
@ -919,13 +918,11 @@ struct StudioAppPlugin : StudioApp::IPlugin
|
|||
void init() override {
|
||||
PROFILE_FUNCTION();
|
||||
m_gui_editor.init();
|
||||
|
||||
m_app.addPlugin(m_gui_editor);
|
||||
|
||||
m_app.getAssetBrowser().addPlugin(m_sprite_plugin);
|
||||
|
||||
const char* sprite_exts[] = {"spr", nullptr};
|
||||
m_app.getAssetCompiler().addPlugin(m_sprite_plugin, sprite_exts);
|
||||
const char* exts[] = {"spr"};
|
||||
m_app.getAssetBrowser().addPlugin(m_sprite_plugin, Span(exts));
|
||||
m_app.getAssetCompiler().addPlugin(m_sprite_plugin, Span(exts));
|
||||
}
|
||||
|
||||
bool showGizmo(WorldView&, ComponentUID) override { return false; }
|
||||
|
|
|
@ -89,7 +89,7 @@ struct EditorWindow : AssetEditorWindow {
|
|||
};
|
||||
|
||||
|
||||
struct AssetPlugin : AssetBrowser::Plugin, AssetCompiler::IPlugin {
|
||||
struct AssetPlugin : AssetBrowser::IPlugin, AssetCompiler::IPlugin {
|
||||
explicit AssetPlugin(StudioApp& app)
|
||||
: m_app(app)
|
||||
{
|
||||
|
@ -104,7 +104,6 @@ struct AssetPlugin : AssetBrowser::Plugin, AssetCompiler::IPlugin {
|
|||
|
||||
bool compile(const Path& src) override { return m_app.getAssetCompiler().copyCompile(src); }
|
||||
const char* getLabel() const override { return "Lua script"; }
|
||||
ResourceType getResourceType() const override { return LuaScript::TYPE; }
|
||||
bool canCreateResource() const override { return true; }
|
||||
const char* getDefaultExtension() const override { return "lua"; }
|
||||
|
||||
|
@ -515,9 +514,9 @@ struct StudioAppPlugin : StudioApp::IPlugin
|
|||
AddComponentPlugin* add_cmp_plugin = LUMIX_NEW(m_app.getAllocator(), AddComponentPlugin)(m_app);
|
||||
m_app.registerComponent(ICON_FA_MOON, "lua_script", *add_cmp_plugin);
|
||||
|
||||
const char* exts[] = { "lua", nullptr };
|
||||
m_app.getAssetCompiler().addPlugin(m_asset_plugin, exts);
|
||||
m_app.getAssetBrowser().addPlugin(m_asset_plugin);
|
||||
const char* exts[] = { "lua" };
|
||||
m_app.getAssetCompiler().addPlugin(m_asset_plugin, Span(exts));
|
||||
m_app.getAssetBrowser().addPlugin(m_asset_plugin, Span(exts));
|
||||
m_app.addPlugin(m_console_plugin);
|
||||
m_app.getPropertyGrid().addPlugin(m_property_grid_plugin);
|
||||
}
|
||||
|
|
|
@ -830,7 +830,7 @@ struct PhysicsUIPlugin final : StudioApp::GUIPlugin
|
|||
};
|
||||
|
||||
|
||||
struct PhysicsGeometryPlugin final : AssetBrowser::Plugin
|
||||
struct PhysicsGeometryPlugin final : AssetBrowser::IPlugin
|
||||
{
|
||||
explicit PhysicsGeometryPlugin(StudioApp& app)
|
||||
: m_app(app)
|
||||
|
@ -839,12 +839,11 @@ struct PhysicsGeometryPlugin final : AssetBrowser::Plugin
|
|||
}
|
||||
|
||||
const char* getLabel() const override { return "Physics geometry"; }
|
||||
ResourceType getResourceType() const override { return PhysicsGeometry::TYPE; }
|
||||
|
||||
StudioApp& m_app;
|
||||
};
|
||||
|
||||
struct PhysicsMaterialPlugin final : AssetBrowser::Plugin, AssetCompiler::IPlugin {
|
||||
struct PhysicsMaterialPlugin final : AssetBrowser::IPlugin, AssetCompiler::IPlugin {
|
||||
struct EditorWindow : AssetEditorWindow {
|
||||
EditorWindow(const Path& path, StudioApp& app)
|
||||
: AssetEditorWindow(app)
|
||||
|
@ -925,7 +924,6 @@ struct PhysicsMaterialPlugin final : AssetBrowser::Plugin, AssetCompiler::IPlugi
|
|||
|
||||
bool compile(const Path& src) override { return m_app.getAssetCompiler().copyCompile(src); }
|
||||
const char* getLabel() const override { return "Physics material"; }
|
||||
ResourceType getResourceType() const override { return PhysicsMaterial::TYPE; }
|
||||
|
||||
void openEditor(const Path& path) override {
|
||||
IAllocator& allocator = m_app.getAllocator();
|
||||
|
@ -950,10 +948,11 @@ struct StudioAppPlugin : StudioApp::IPlugin
|
|||
void init() override
|
||||
{
|
||||
m_app.addPlugin(m_ui_plugin);
|
||||
m_app.getAssetBrowser().addPlugin(m_material_plugin);
|
||||
m_app.getAssetBrowser().addPlugin(m_geometry_plugin);
|
||||
const char* exts[] = { "pma", nullptr };
|
||||
m_app.getAssetCompiler().addPlugin(m_material_plugin, exts);
|
||||
const char* geom_exts[] = { "phy" };
|
||||
m_app.getAssetBrowser().addPlugin(m_geometry_plugin, Span(geom_exts));
|
||||
const char* mat_exts[] = { "pma" };
|
||||
m_app.getAssetBrowser().addPlugin(m_material_plugin, Span(mat_exts));
|
||||
m_app.getAssetCompiler().addPlugin(m_material_plugin, Span(mat_exts));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2672,7 +2672,7 @@ Node* ParticleEmitterEditorResource::addNode(Node::Type type) {
|
|||
} // anonymous namespace
|
||||
|
||||
struct ParticleEditorImpl : ParticleEditor {
|
||||
struct ParticleSystemPlugin final : AssetBrowser::Plugin, AssetCompiler::IPlugin {
|
||||
struct ParticleSystemPlugin final : AssetBrowser::IPlugin, AssetCompiler::IPlugin {
|
||||
explicit ParticleSystemPlugin(ParticleEditorImpl& editor, StudioApp& app)
|
||||
: m_app(app)
|
||||
, m_editor(editor)
|
||||
|
@ -2709,7 +2709,6 @@ struct ParticleEditorImpl : ParticleEditor {
|
|||
const char* getDefaultExtension() const override { return "par"; }
|
||||
void openEditor(const Path& path) override { m_editor.open(path.c_str()); }
|
||||
const char* getLabel() const override { return "Particle system"; }
|
||||
ResourceType getResourceType() const override { return ParticleSystemResource::TYPE; }
|
||||
|
||||
StudioApp& m_app;
|
||||
ParticleEditorImpl& m_editor;
|
||||
|
@ -2748,9 +2747,9 @@ struct ParticleEditorImpl : ParticleEditor {
|
|||
m_apply_action.init("Apply", "Particle editor apply", "particle_editor_apply", "", os::Keycode::E, Action::Modifiers::CTRL, true);
|
||||
app.addAction(&m_apply_action);
|
||||
|
||||
const char* particle_emitter_exts[] = {"par", nullptr};
|
||||
m_app.getAssetCompiler().addPlugin(m_particle_system_plugin, particle_emitter_exts);
|
||||
m_app.getAssetBrowser().addPlugin(m_particle_system_plugin);
|
||||
const char* particle_emitter_exts[] = {"par" };
|
||||
m_app.getAssetCompiler().addPlugin(m_particle_system_plugin, Span(particle_emitter_exts));
|
||||
m_app.getAssetBrowser().addPlugin(m_particle_system_plugin, Span(particle_emitter_exts));
|
||||
}
|
||||
|
||||
~ParticleEditorImpl() {
|
||||
|
|
|
@ -641,7 +641,7 @@ static bool saveAsLBC(const char* path, const u8* data, int w, int h, bool gener
|
|||
}
|
||||
|
||||
|
||||
struct FontPlugin final : AssetBrowser::Plugin, AssetCompiler::IPlugin
|
||||
struct FontPlugin final : AssetBrowser::IPlugin, AssetCompiler::IPlugin
|
||||
{
|
||||
FontPlugin(StudioApp& app)
|
||||
: m_app(app)
|
||||
|
@ -651,13 +651,12 @@ struct FontPlugin final : AssetBrowser::Plugin, AssetCompiler::IPlugin
|
|||
|
||||
bool compile(const Path& src) override { return m_app.getAssetCompiler().copyCompile(src); }
|
||||
const char* getLabel() const override { return "Font"; }
|
||||
ResourceType getResourceType() const override { return FontResource::TYPE; }
|
||||
|
||||
StudioApp& m_app;
|
||||
};
|
||||
|
||||
|
||||
struct PipelinePlugin final : AssetCompiler::IPlugin, AssetBrowser::Plugin {
|
||||
struct PipelinePlugin final : AssetCompiler::IPlugin, AssetBrowser::IPlugin {
|
||||
struct EditorWindow : AssetEditorWindow {
|
||||
EditorWindow(const Path& path, StudioApp& app, IAllocator& allocator)
|
||||
: AssetEditorWindow(app)
|
||||
|
@ -717,7 +716,6 @@ struct PipelinePlugin final : AssetCompiler::IPlugin, AssetBrowser::Plugin {
|
|||
|
||||
bool compile(const Path& src) override { return m_app.getAssetCompiler().copyCompile(src); }
|
||||
const char* getLabel() const override { return "Pipeline"; }
|
||||
ResourceType getResourceType() const override { return ResourceType("pipeline"); }
|
||||
|
||||
void openEditor(const struct Path& path) {
|
||||
IAllocator& allocator = m_app.getAllocator();
|
||||
|
@ -767,7 +765,7 @@ struct ParticleSystemPropertyPlugin final : PropertyGrid::IPlugin
|
|||
float m_time_scale = 1.f;
|
||||
};
|
||||
|
||||
struct MaterialPlugin final : AssetBrowser::Plugin, AssetCompiler::IPlugin {
|
||||
struct MaterialPlugin final : AssetBrowser::IPlugin, AssetCompiler::IPlugin {
|
||||
struct EditorWindow : AssetEditorWindow, SimpleUndoRedo {
|
||||
EditorWindow(const Path& path, StudioApp& app, IAllocator& allocator)
|
||||
: AssetEditorWindow(app)
|
||||
|
@ -1033,7 +1031,6 @@ struct MaterialPlugin final : AssetBrowser::Plugin, AssetCompiler::IPlugin {
|
|||
void createResource(OutputMemoryStream& blob) override { blob << "shader \"/pipelines/standard.shd\""; }
|
||||
bool compile(const Path& src) override { return m_app.getAssetCompiler().copyCompile(src); }
|
||||
const char* getLabel() const override { return "Material"; }
|
||||
ResourceType getResourceType() const override { return Material::TYPE; }
|
||||
|
||||
StudioApp& m_app;
|
||||
TagAllocator m_allocator;
|
||||
|
@ -1430,7 +1427,7 @@ struct TextureAssetEditorWindow : AssetEditorWindow, SimpleUndoRedo {
|
|||
TextureMeta m_meta;
|
||||
};
|
||||
|
||||
struct TexturePlugin final : AssetBrowser::Plugin, AssetCompiler::IPlugin {
|
||||
struct TexturePlugin final : AssetBrowser::IPlugin, AssetCompiler::IPlugin {
|
||||
explicit TexturePlugin(StudioApp& app)
|
||||
: m_app(app)
|
||||
, m_allocator(app.getAllocator(), "texture editor")
|
||||
|
@ -1772,7 +1769,6 @@ struct TexturePlugin final : AssetBrowser::Plugin, AssetCompiler::IPlugin {
|
|||
}
|
||||
|
||||
const char* getLabel() const override { return "Texture"; }
|
||||
ResourceType getResourceType() const override { return Texture::TYPE; }
|
||||
|
||||
TagAllocator m_allocator;
|
||||
StudioApp& m_app;
|
||||
|
@ -1853,7 +1849,7 @@ static void getTextureImage(DrawStream& stream, gpu::TextureHandle texture, u32
|
|||
stream.destroy(staging);
|
||||
}
|
||||
|
||||
struct ModelPlugin final : AssetBrowser::Plugin, AssetCompiler::IPlugin {
|
||||
struct ModelPlugin final : AssetBrowser::IPlugin, AssetCompiler::IPlugin {
|
||||
struct Meta {
|
||||
Meta(IAllocator& allocator) : clips(allocator) {}
|
||||
|
||||
|
@ -2882,7 +2878,6 @@ struct ModelPlugin final : AssetBrowser::Plugin, AssetCompiler::IPlugin {
|
|||
}
|
||||
|
||||
const char* getLabel() const override { return "Model"; }
|
||||
ResourceType getResourceType() const override { return Model::TYPE; }
|
||||
|
||||
void pushTileQueue(const Path& path)
|
||||
{
|
||||
|
@ -3190,16 +3185,11 @@ struct ModelPlugin final : AssetBrowser::Plugin, AssetCompiler::IPlugin {
|
|||
}
|
||||
|
||||
|
||||
bool createTile(const char* in_path, const char* out_path, ResourceType type) override
|
||||
{
|
||||
if (type == Shader::TYPE) return true;
|
||||
|
||||
bool createTile(const char* in_path, const char* out_path, ResourceType type) override {
|
||||
if (type != Model::TYPE && type != Material::TYPE && type != PrefabResource::TYPE) return false;
|
||||
|
||||
Path path(in_path);
|
||||
|
||||
if (!m_tile.queue.full())
|
||||
{
|
||||
if (!m_tile.queue.full()) {
|
||||
pushTileQueue(path);
|
||||
return true;
|
||||
}
|
||||
|
@ -3208,15 +3198,12 @@ struct ModelPlugin final : AssetBrowser::Plugin, AssetCompiler::IPlugin {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
struct TileData
|
||||
{
|
||||
struct TileData {
|
||||
TileData(IAllocator& allocator)
|
||||
: data(allocator)
|
||||
, paths(allocator)
|
||||
, queue()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
World* world = nullptr;
|
||||
UniquePtr<Pipeline> pipeline;
|
||||
|
@ -3240,7 +3227,7 @@ struct ModelPlugin final : AssetBrowser::Plugin, AssetCompiler::IPlugin {
|
|||
};
|
||||
|
||||
|
||||
struct ShaderPlugin final : AssetBrowser::Plugin, AssetCompiler::IPlugin {
|
||||
struct ShaderPlugin final : AssetBrowser::IPlugin, AssetCompiler::IPlugin {
|
||||
struct EditorWindow : AssetEditorWindow {
|
||||
EditorWindow(const Path& path, StudioApp& app)
|
||||
: AssetEditorWindow(app)
|
||||
|
@ -3379,11 +3366,11 @@ struct ShaderPlugin final : AssetBrowser::Plugin, AssetCompiler::IPlugin {
|
|||
|
||||
void openEditor(const Path& path) override {
|
||||
UniquePtr<EditorWindow> win = UniquePtr<EditorWindow>::create(m_app.getAllocator(), path, m_app);
|
||||
m_app.getAssetBrowser().addWindow(win.move());
|
||||
}
|
||||
|
||||
bool compile(const Path& src) override { return m_app.getAssetCompiler().copyCompile(src); }
|
||||
const char* getLabel() const override { return "Shader"; }
|
||||
ResourceType getResourceType() const override { return Shader::TYPE; }
|
||||
|
||||
StudioApp& m_app;
|
||||
};
|
||||
|
@ -5234,32 +5221,32 @@ struct StudioAppPlugin : StudioApp::IPlugin
|
|||
|
||||
AssetCompiler& asset_compiler = m_app.getAssetCompiler();
|
||||
|
||||
const char* shader_exts[] = {"shd", nullptr};
|
||||
asset_compiler.addPlugin(m_shader_plugin, shader_exts);
|
||||
const char* shader_exts[] = {"shd"};
|
||||
asset_compiler.addPlugin(m_shader_plugin, Span(shader_exts));
|
||||
|
||||
const char* texture_exts[] = { "png", "jpg", "jpeg", "tga", "raw", "ltc", nullptr};
|
||||
asset_compiler.addPlugin(m_texture_plugin, texture_exts);
|
||||
const char* texture_exts[] = {"png", "jpg", "jpeg", "tga", "raw", "ltc"};
|
||||
asset_compiler.addPlugin(m_texture_plugin, Span(texture_exts));
|
||||
|
||||
const char* pipeline_exts[] = {"pln", nullptr};
|
||||
asset_compiler.addPlugin(m_pipeline_plugin, pipeline_exts);
|
||||
const char* pipeline_exts[] = {"pln"};
|
||||
asset_compiler.addPlugin(m_pipeline_plugin, Span(pipeline_exts));
|
||||
|
||||
const char* material_exts[] = {"mat", nullptr};
|
||||
asset_compiler.addPlugin(m_material_plugin, material_exts);
|
||||
const char* material_exts[] = {"mat"};
|
||||
asset_compiler.addPlugin(m_material_plugin, Span(material_exts));
|
||||
|
||||
m_model_plugin.m_texture_plugin = &m_texture_plugin;
|
||||
const char* model_exts[] = {"fbx", nullptr};
|
||||
asset_compiler.addPlugin(m_model_plugin, model_exts);
|
||||
const char* model_exts[] = {"fbx"};
|
||||
asset_compiler.addPlugin(m_model_plugin, Span(model_exts));
|
||||
|
||||
const char* fonts_exts[] = {"ttf", nullptr};
|
||||
asset_compiler.addPlugin(m_font_plugin, fonts_exts);
|
||||
const char* fonts_exts[] = {"ttf"};
|
||||
asset_compiler.addPlugin(m_font_plugin, Span(fonts_exts));
|
||||
|
||||
AssetBrowser& asset_browser = m_app.getAssetBrowser();
|
||||
asset_browser.addPlugin(m_model_plugin);
|
||||
asset_browser.addPlugin(m_material_plugin);
|
||||
asset_browser.addPlugin(m_font_plugin);
|
||||
asset_browser.addPlugin(m_shader_plugin);
|
||||
asset_browser.addPlugin(m_texture_plugin);
|
||||
asset_browser.addPlugin(m_pipeline_plugin);
|
||||
asset_browser.addPlugin(m_model_plugin, Span(model_exts));
|
||||
asset_browser.addPlugin(m_material_plugin, Span(material_exts));
|
||||
asset_browser.addPlugin(m_font_plugin, Span(fonts_exts));
|
||||
asset_browser.addPlugin(m_shader_plugin, Span(shader_exts));
|
||||
asset_browser.addPlugin(m_texture_plugin, Span(texture_exts));
|
||||
asset_browser.addPlugin(m_pipeline_plugin, Span(pipeline_exts));
|
||||
|
||||
m_app.addPlugin(m_scene_view);
|
||||
m_app.addPlugin(m_game_view);
|
||||
|
|
Loading…
Reference in a new issue