Add PluginArgs for plugin system

This commit is contained in:
2017-05-21 00:15:47 -05:00
parent 6aab7bf2f2
commit bc69e67a5b
9 changed files with 56 additions and 28 deletions

View File

@@ -17,7 +17,8 @@ const QString ImportTilesheetWizardPage::TILESHEET_NAME = "projectName";
const QString ImportTilesheetWizardPage::IMPORT_PATH = "projectPath";
const QString ImportTilesheetWizardPage::BPP = "bpp";
ImportTilesheetWizardPage::ImportTilesheetWizardPage() {
ImportTilesheetWizardPage::ImportTilesheetWizardPage(studio::PluginArgs args) {
m_project = args.project;
addLineEdit(tr("&Tile Sheet Name:"), TILESHEET_NAME + "*", "", [this](QString) {
auto importPath = field(IMPORT_PATH).toString();
if (QFile(importPath).exists()) {
@@ -37,12 +38,17 @@ ImportTilesheetWizardPage::ImportTilesheetWizardPage() {
int ImportTilesheetWizardPage::accept() {
auto tilesheetName = field(TILESHEET_NAME).toString();
auto importPath = field(IMPORT_PATH).toString();
if (QFile(importPath).exists()) {
return 0;
QFile importFile(importPath);
if (importFile.exists()) {
return importImage(importFile, field(TILESHEET_NAME).toString());
} else {
return 1;
}
}
int ImportTilesheetWizardPage::importImage(QFile &src, QString tilesetName) {
return 1;
}
}
}

View File

@@ -18,11 +18,15 @@ class ImportTilesheetWizardPage: public studio::WizardFormPage {
static const QString TILESHEET_NAME;
static const QString IMPORT_PATH;
static const QString BPP;
studio::Project *m_project = nullptr;
public:
ImportTilesheetWizardPage();
ImportTilesheetWizardPage(studio::PluginArgs args);
int accept();
private:
int importImage(QFile &src, QString dest);
};
}

View File

@@ -6,8 +6,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <nostalgia/studio/studio.hpp>
#include "import_tilesheet_wizard.hpp"
#include "plugin.hpp"
@@ -18,14 +16,19 @@ namespace nostalgia {
namespace core {
Plugin::Plugin() {
addImportWizard(
tr("Tile Sheet"),
[]() {
QVector<QWizardPage*> pgs;
pgs.push_back(new ImportTilesheetWizardPage());
return pgs;
}
QVector<studio::WizardMaker> Plugin::importWizards(studio::PluginArgs args) {
return {
{
tr("Tile Sheet"),
[args]() {
QVector<QWizardPage*> pgs;
pgs.push_back(new ImportTilesheetWizardPage(args));
return pgs;
}
}
);
};
}
}

View File

@@ -22,6 +22,8 @@ class Plugin: public QObject, studio::Plugin {
public:
Plugin();
QVector<studio::WizardMaker> importWizards(studio::PluginArgs args) override;
};
}