diff options
author | Jan Dalheimer <jan@dalheimer.de> | 2014-02-16 12:52:35 +0100 |
---|---|---|
committer | Jan Dalheimer <jan@dalheimer.de> | 2014-02-16 12:52:35 +0100 |
commit | 9c87bc6c4b99f0c93f2b18039208dcf9f3fb4d79 (patch) | |
tree | cac60e920a67584cf90805382db4464c0e23b03e /logic/tools/BaseExternalTool.cpp | |
parent | f26b7dedad70a46769b4c96122a7615b328a9fbb (diff) | |
download | MultiMC-9c87bc6c4b99f0c93f2b18039208dcf9f3fb4d79.tar MultiMC-9c87bc6c4b99f0c93f2b18039208dcf9f3fb4d79.tar.gz MultiMC-9c87bc6c4b99f0c93f2b18039208dcf9f3fb4d79.tar.lz MultiMC-9c87bc6c4b99f0c93f2b18039208dcf9f3fb4d79.tar.xz MultiMC-9c87bc6c4b99f0c93f2b18039208dcf9f3fb4d79.zip |
Restructure
Diffstat (limited to 'logic/tools/BaseExternalTool.cpp')
-rw-r--r-- | logic/tools/BaseExternalTool.cpp | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/logic/tools/BaseExternalTool.cpp b/logic/tools/BaseExternalTool.cpp new file mode 100644 index 00000000..69cddd00 --- /dev/null +++ b/logic/tools/BaseExternalTool.cpp @@ -0,0 +1,77 @@ +#include "BaseExternalTool.h" + +#include <QProcess> +#include <QDir> +#include <QInputDialog> + +#ifdef Q_OS_WIN +#include <windows.h> +#endif + +#include "logic/BaseInstance.h" +#include "MultiMC.h" + +BaseExternalTool::BaseExternalTool(BaseInstance *instance, QObject *parent) + : QObject(parent), m_instance(instance) +{ +} + +BaseExternalTool::~BaseExternalTool() +{ +} + +qint64 BaseExternalTool::pid(QProcess *process) +{ +#ifdef Q_OS_WIN + struct _PROCESS_INFORMATION *procinfo = process->pid(); + return procinfo->dwProcessId; +#else + return process->pid(); +#endif +} + +QString BaseExternalTool::getSave() const +{ + QDir saves(m_instance->minecraftRoot() + "/saves"); + QStringList worlds = saves.entryList(QDir::Dirs | QDir::NoDotAndDotDot); + QMutableListIterator<QString> it(worlds); + while (it.hasNext()) + { + it.next(); + if (!QDir(saves.absoluteFilePath(it.value())).exists("level.dat")) + { + it.remove(); + } + } + bool ok = true; + const QString save = QInputDialog::getItem( + MMC->activeWindow(), tr("MCEdit"), tr("Choose which world to open:"), + worlds, 0, false, &ok); + if (ok) + { + return saves.absoluteFilePath(save); + } + return QString(); +} + + +BaseDetachedTool::BaseDetachedTool(BaseInstance *instance, QObject *parent) + : BaseExternalTool(instance, parent) +{ + +} + +void BaseDetachedTool::run() +{ + runImpl(); +} + + +BaseExternalToolFactory::~BaseExternalToolFactory() +{ +} + +BaseDetachedTool *BaseDetachedToolFactory::createDetachedTool(BaseInstance *instance, QObject *parent) +{ + return qobject_cast<BaseDetachedTool *>(createTool(instance, parent)); +} |