[nostalgia] Rename Studio Plugins to Modules, add support for builtin Studio modules, make existing modules builtin
This commit is contained in:
parent
6497b40e64
commit
7a837502a1
@ -108,7 +108,7 @@ else()
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
set(NOSTALGIA_DIST_BIN bin)
|
||||
set(NOSTALGIA_DIST_LIB lib)
|
||||
set(NOSTALGIA_DIST_PLUGIN lib/nostalgia/plugins)
|
||||
set(NOSTALGIA_DIST_PLUGIN lib/nostalgia/modules)
|
||||
set(NOSTALGIA_DIST_RESOURCES share)
|
||||
endif()
|
||||
|
||||
|
@ -3,13 +3,13 @@ set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
add_library(
|
||||
NostalgiaCore-Studio SHARED
|
||||
NostalgiaCore-Studio OBJECT
|
||||
imgconv.cpp
|
||||
import_tilesheet_wizard.cpp
|
||||
module.cpp
|
||||
new_tilesheet_wizard.cpp
|
||||
newpalettewizard.cpp
|
||||
paletteeditor.cpp
|
||||
plugin.cpp
|
||||
tilesheeteditor.cpp
|
||||
util.cpp
|
||||
rsrc.qrc
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2019 gtalent2@gmail.com
|
||||
* Copyright 2016 - 2020 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -12,11 +12,11 @@
|
||||
#include "paletteeditor.hpp"
|
||||
#include "tilesheeteditor.hpp"
|
||||
|
||||
#include "plugin.hpp"
|
||||
#include "module.hpp"
|
||||
|
||||
namespace nostalgia::core {
|
||||
|
||||
QVector<studio::WizardMaker> Plugin::newWizards(const studio::Context *ctx) {
|
||||
QVector<studio::WizardMaker> Module::newWizards(const studio::Context *ctx) {
|
||||
return {
|
||||
{
|
||||
tr("Palette"),
|
||||
@ -37,7 +37,7 @@ QVector<studio::WizardMaker> Plugin::newWizards(const studio::Context *ctx) {
|
||||
};
|
||||
}
|
||||
|
||||
QVector<studio::WizardMaker> Plugin::importWizards(const studio::Context *ctx) {
|
||||
QVector<studio::WizardMaker> Module::importWizards(const studio::Context *ctx) {
|
||||
return {
|
||||
{
|
||||
tr("Tile Sheet"),
|
||||
@ -51,7 +51,7 @@ QVector<studio::WizardMaker> Plugin::importWizards(const studio::Context *ctx) {
|
||||
};
|
||||
}
|
||||
|
||||
QVector<studio::EditorMaker> Plugin::editors(const studio::Context *ctx) {
|
||||
QVector<studio::EditorMaker> Module::editors(const studio::Context *ctx) {
|
||||
return {
|
||||
{
|
||||
{"ng"},
|
@ -14,10 +14,10 @@
|
||||
|
||||
namespace nostalgia::core {
|
||||
|
||||
class Plugin: public QObject, studio::Plugin {
|
||||
class Module: public QObject, public studio::Module {
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "net.drinkingtea.nostalgia.core.studio.Plugin" FILE "core-studio.json")
|
||||
Q_INTERFACES(nostalgia::studio::Plugin)
|
||||
Q_PLUGIN_METADATA(IID "net.drinkingtea.nostalgia.core.studio.Module" FILE "core-studio.json")
|
||||
Q_INTERFACES(nostalgia::studio::Module)
|
||||
|
||||
public:
|
||||
QVector<studio::WizardMaker> newWizards(const studio::Context *ctx) override;
|
@ -15,6 +15,7 @@ add_executable(
|
||||
target_link_libraries(
|
||||
nostalgia-studio
|
||||
QDarkStyle
|
||||
NostalgiaCore-Studio
|
||||
NostalgiaStudio
|
||||
NostalgiaPack
|
||||
)
|
||||
|
22
src/nostalgia/studio/builtinmodules.hpp
Normal file
22
src/nostalgia/studio/builtinmodules.hpp
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2016 - 2020 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nostalgia/core/studio/module.hpp>
|
||||
|
||||
namespace nostalgia::studio {
|
||||
|
||||
[[maybe_unused]] // GCC warns about the existence of this "unused" constexpr list in a header file...
|
||||
constexpr auto BuiltinModules = {
|
||||
[] {
|
||||
return new core::Module();
|
||||
},
|
||||
};
|
||||
|
||||
}
|
@ -5,7 +5,7 @@ add_library(
|
||||
NostalgiaStudio SHARED
|
||||
editor.cpp
|
||||
wizard.cpp
|
||||
plugin.cpp
|
||||
module.cpp
|
||||
project.cpp
|
||||
)
|
||||
|
||||
@ -26,7 +26,7 @@ install(
|
||||
FILES
|
||||
editor.hpp
|
||||
wizard.hpp
|
||||
plugin.hpp
|
||||
module.hpp
|
||||
project.hpp
|
||||
${CMAKE_CURRENT_BINARY_DIR}/nostalgiastudio_export.h
|
||||
DESTINATION
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2019 gtalent2@gmail.com
|
||||
* Copyright 2016 - 2020 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -7,23 +7,23 @@
|
||||
*/
|
||||
|
||||
#include "context.hpp"
|
||||
#include "plugin.hpp"
|
||||
#include "module.hpp"
|
||||
|
||||
namespace nostalgia::studio {
|
||||
|
||||
QVector<WizardMaker> Plugin::newWizards(const Context*) {
|
||||
QVector<WizardMaker> Module::newWizards(const Context*) {
|
||||
return {};
|
||||
}
|
||||
|
||||
QVector<WizardMaker> Plugin::importWizards(const Context*) {
|
||||
QVector<WizardMaker> Module::importWizards(const Context*) {
|
||||
return {};
|
||||
}
|
||||
|
||||
QWidget *Plugin::makeEditor(QString, const Context*) {
|
||||
QWidget *Module::makeEditor(QString, const Context*) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QVector<EditorMaker> Plugin::editors(const Context*) {
|
||||
QVector<EditorMaker> Module::editors(const Context*) {
|
||||
return {};
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2019 gtalent2@gmail.com
|
||||
* Copyright 2016 - 2020 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -22,10 +22,10 @@ struct EditorMaker {
|
||||
std::function<class Editor*(QString)> make;
|
||||
};
|
||||
|
||||
class Plugin {
|
||||
class Module {
|
||||
|
||||
public:
|
||||
virtual ~Plugin() = default;
|
||||
virtual ~Module() = default;
|
||||
|
||||
virtual QVector<WizardMaker> newWizards(const class Context *ctx);
|
||||
|
||||
@ -39,6 +39,6 @@ class Plugin {
|
||||
|
||||
}
|
||||
|
||||
#define PluginInterface_iid "net.drinkingtea.nostalgia.studio.Plugin"
|
||||
#define PluginInterface_iid "net.drinkingtea.nostalgia.studio.Module"
|
||||
|
||||
Q_DECLARE_INTERFACE(nostalgia::studio::Plugin, PluginInterface_iid)
|
||||
Q_DECLARE_INTERFACE(nostalgia::studio::Module, PluginInterface_iid)
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2019 gtalent2@gmail.com
|
||||
* Copyright 2016 - 2020 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
#include "context.hpp"
|
||||
#include "project.hpp"
|
||||
#include "plugin.hpp"
|
||||
#include "module.hpp"
|
||||
#include "wizard.hpp"
|
||||
|
||||
namespace nostalgia::studio {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2019 gtalent2@gmail.com
|
||||
* Copyright 2016 - 2020 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -70,7 +70,7 @@ MainWindow::MainWindow(QString profilePath) {
|
||||
setupProjectExplorer();
|
||||
statusBar(); // setup status bar
|
||||
|
||||
loadPlugins();
|
||||
loadModules();
|
||||
|
||||
readState();
|
||||
}
|
||||
@ -79,41 +79,48 @@ MainWindow::~MainWindow() {
|
||||
closeProject();
|
||||
}
|
||||
|
||||
void MainWindow::loadPlugins() {
|
||||
for (auto dir : m_profile.pluginsPath) {
|
||||
void MainWindow::loadModules() {
|
||||
for (auto p : BuiltinModules) {
|
||||
loadModule(p());
|
||||
}
|
||||
for (auto dir : m_profile.modulesPath) {
|
||||
QFileInfo dirInfo(m_profilePath);
|
||||
dir = dirInfo.absolutePath() + "/" + dir;
|
||||
if (dirInfo.exists()) {
|
||||
qDebug() << "Checking plugin directory:" << dir;
|
||||
loadPluginDir(dir);
|
||||
qDebug() << "Checking module directory:" << dir;
|
||||
loadModuleDir(dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::loadPluginDir(QString dir) {
|
||||
for (auto pluginPath : QDir(dir).entryList()) {
|
||||
pluginPath = dir + '/' + pluginPath;
|
||||
if (QLibrary::isLibrary(pluginPath)) {
|
||||
loadPlugin(pluginPath);
|
||||
void MainWindow::loadModuleDir(QString dir) {
|
||||
for (auto modulePath : QDir(dir).entryList()) {
|
||||
modulePath = dir + '/' + modulePath;
|
||||
if (QLibrary::isLibrary(modulePath)) {
|
||||
loadModule(modulePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::loadPlugin(QString pluginPath) {
|
||||
qDebug() << "Loading plugin:" << pluginPath;
|
||||
QPluginLoader loader(pluginPath);
|
||||
auto plugin = qobject_cast<Plugin*>(loader.instance());
|
||||
if (plugin) {
|
||||
m_plugins.push_back(plugin);
|
||||
auto editorMakers = plugin->editors(&m_ctx);
|
||||
void MainWindow::loadModule(QString modulePath) {
|
||||
qDebug() << "Loading module:" << modulePath;
|
||||
QPluginLoader loader(modulePath);
|
||||
auto module = qobject_cast<Module*>(loader.instance());
|
||||
if (module) {
|
||||
loadModule(module);
|
||||
} else {
|
||||
qInfo() << loader.errorString();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::loadModule(Module *module) {
|
||||
m_modules.push_back(module);
|
||||
auto editorMakers = module->editors(&m_ctx);
|
||||
for (const auto &em : editorMakers) {
|
||||
for (const auto &ext : em.fileTypes) {
|
||||
m_editorMakers[ext] = em;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
qInfo() << loader.errorString();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setupMenu() {
|
||||
@ -492,8 +499,8 @@ void MainWindow::showNewWizard() {
|
||||
}
|
||||
);
|
||||
|
||||
// add plugin options
|
||||
for (auto p : m_plugins) {
|
||||
// add module options
|
||||
for (auto p : m_modules) {
|
||||
for (auto w : p->newWizards(&m_ctx)) {
|
||||
ws->addOption(w);
|
||||
}
|
||||
@ -590,7 +597,7 @@ void MainWindow::showImportWizard() {
|
||||
auto ws = new WizardSelect();
|
||||
wizard.addPage(ws);
|
||||
|
||||
for (auto p : m_plugins) {
|
||||
for (auto p : m_modules) {
|
||||
for (auto w : p->importWizards(&m_ctx)) {
|
||||
ws->addOption(w);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2019 gtalent2@gmail.com
|
||||
* Copyright 2016 - 2020 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -25,9 +25,10 @@
|
||||
#include <ox/std/types.hpp>
|
||||
|
||||
#include "lib/context.hpp"
|
||||
#include "lib/plugin.hpp"
|
||||
#include "lib/module.hpp"
|
||||
#include "lib/project.hpp"
|
||||
|
||||
#include "builtinmodules.hpp"
|
||||
#include "oxfstreeview.hpp"
|
||||
|
||||
namespace nostalgia::studio {
|
||||
@ -47,7 +48,7 @@ ox::Error model(T *io, NostalgiaStudioState *obj) {
|
||||
struct NostalgiaStudioProfile {
|
||||
QString appName;
|
||||
QString orgName;
|
||||
QVector<QString> pluginsPath;
|
||||
QVector<QString> modulesPath;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@ -56,7 +57,7 @@ ox::Error model(T *io, NostalgiaStudioProfile *obj) {
|
||||
oxReturnError(io->setTypeInfo("NostalgiaStudioProfile", 3));
|
||||
oxReturnError(io->field("app_name", &obj->appName));
|
||||
oxReturnError(io->field("org_name", &obj->orgName));
|
||||
oxReturnError(io->field("plugins_path", &obj->pluginsPath));
|
||||
oxReturnError(io->field("modules_path", &obj->modulesPath));
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -82,7 +83,7 @@ class MainWindow: public QMainWindow {
|
||||
QPointer<QMenu> m_viewMenu;
|
||||
QVector<QPointer<QDockWidget>> m_dockWidgets;
|
||||
QTreeView *m_projectExplorer = nullptr;
|
||||
QVector<Plugin*> m_plugins;
|
||||
QVector<Module*> m_modules;
|
||||
QHash<QString, EditorMaker> m_editorMakers;
|
||||
QPointer<OxFSModel> m_oxfsView = nullptr;
|
||||
QTabWidget *m_tabs = nullptr;
|
||||
@ -95,11 +96,13 @@ class MainWindow: public QMainWindow {
|
||||
virtual ~MainWindow();
|
||||
|
||||
private:
|
||||
void loadPlugins();
|
||||
void loadModules();
|
||||
|
||||
void loadPluginDir(QString path);
|
||||
void loadModuleDir(QString path);
|
||||
|
||||
void loadPlugin(QString path);
|
||||
void loadModule(QString path);
|
||||
|
||||
void loadModule(Module *module);
|
||||
|
||||
void setupMenu();
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"app_name": "Nostalgia Studio",
|
||||
"org_name": "Drinking Tea",
|
||||
"plugins_path": [
|
||||
"../lib/nostalgia/plugins",
|
||||
"modules_path": [
|
||||
"../lib/nostalgia/modules",
|
||||
"../Plugins",
|
||||
"../../../out/build/x64-Debug",
|
||||
"../../../out/build/x64-Release"
|
||||
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"app_name": "Nostalgia Studio",
|
||||
"org_name": "Drinking Tea",
|
||||
"plugins_path": [
|
||||
"../lib/nostalgia/plugins",
|
||||
"modules_path": [
|
||||
"../lib/nostalgia/modules",
|
||||
"../Plugins"
|
||||
]
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2019 gtalent2@gmail.com
|
||||
* Copyright 2016 - 2020 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -10,6 +10,6 @@
|
||||
|
||||
#include "lib/context.hpp"
|
||||
#include "lib/editor.hpp"
|
||||
#include "lib/plugin.hpp"
|
||||
#include "lib/module.hpp"
|
||||
#include "lib/project.hpp"
|
||||
#include "lib/wizard.hpp"
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
add_library(
|
||||
NostalgiaWorld-Studio SHARED
|
||||
NostalgiaWorld-Studio OBJECT
|
||||
consts.cpp
|
||||
newworldwizard.cpp
|
||||
worldstudioplugin.cpp
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2019 gtalent2@gmail.com
|
||||
* Copyright 2016 - 2020 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 - 2020 gtalent2@gmail.com
|
||||
* Copyright 2016 - 2020 gary@drinkingtea.net
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@ -14,10 +14,10 @@
|
||||
|
||||
namespace nostalgia::world {
|
||||
|
||||
class WorldEditorPlugin: public QObject, public studio::Plugin {
|
||||
class WorldEditorPlugin: public QObject, public studio::Module {
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "net.drinkingtea.nostalgia.world.studio.Plugin" FILE "world-studio.json")
|
||||
Q_INTERFACES(nostalgia::studio::Plugin)
|
||||
Q_PLUGIN_METADATA(IID "net.drinkingtea.nostalgia.world.studio.Module" FILE "world-studio.json")
|
||||
Q_INTERFACES(nostalgia::studio::Module)
|
||||
|
||||
public:
|
||||
QVector<studio::WizardMaker> newWizards(const studio::Context *ctx) override;
|
||||
|
Loading…
Reference in New Issue
Block a user