diff options
author | Petr Mrázek <peterix@gmail.com> | 2015-01-27 22:31:07 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2015-04-02 00:14:06 +0200 |
commit | 791221e923586bb717396ecf18bd13e57034df99 (patch) | |
tree | 9f608af07375b38626c8964671620477158341ba /logic/tools | |
parent | 593111b14463e9d5d08256061b981b5ab1cfb710 (diff) | |
download | MultiMC-791221e923586bb717396ecf18bd13e57034df99.tar MultiMC-791221e923586bb717396ecf18bd13e57034df99.tar.gz MultiMC-791221e923586bb717396ecf18bd13e57034df99.tar.lz MultiMC-791221e923586bb717396ecf18bd13e57034df99.tar.xz MultiMC-791221e923586bb717396ecf18bd13e57034df99.zip |
NOISSUE Refactors and moving of things
Diffstat (limited to 'logic/tools')
-rw-r--r-- | logic/tools/BaseExternalTool.cpp | 25 | ||||
-rw-r--r-- | logic/tools/BaseExternalTool.h | 2 | ||||
-rw-r--r-- | logic/tools/BaseProfiler.cpp | 2 | ||||
-rw-r--r-- | logic/tools/BaseProfiler.h | 6 | ||||
-rw-r--r-- | logic/tools/JProfiler.cpp | 4 | ||||
-rw-r--r-- | logic/tools/JProfiler.h | 2 | ||||
-rw-r--r-- | logic/tools/JVisualVM.cpp | 4 | ||||
-rw-r--r-- | logic/tools/JVisualVM.h | 2 | ||||
-rw-r--r-- | logic/tools/MCEditTool.cpp | 33 | ||||
-rw-r--r-- | logic/tools/MCEditTool.h | 1 |
10 files changed, 44 insertions, 37 deletions
diff --git a/logic/tools/BaseExternalTool.cpp b/logic/tools/BaseExternalTool.cpp index 23f154e2..04edece8 100644 --- a/logic/tools/BaseExternalTool.cpp +++ b/logic/tools/BaseExternalTool.cpp @@ -30,31 +30,6 @@ qint64 BaseExternalTool::pid(QProcess *process) #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(InstancePtr instance, QObject *parent) : BaseExternalTool(instance, parent) { diff --git a/logic/tools/BaseExternalTool.h b/logic/tools/BaseExternalTool.h index 5f112970..8b8b2790 100644 --- a/logic/tools/BaseExternalTool.h +++ b/logic/tools/BaseExternalTool.h @@ -5,7 +5,6 @@ class BaseInstance; class SettingsObject; -class MinecraftProcess; class QProcess; class BaseExternalTool : public QObject @@ -19,7 +18,6 @@ protected: InstancePtr m_instance; qint64 pid(QProcess *process); - QString getSave() const; }; class BaseDetachedTool : public BaseExternalTool diff --git a/logic/tools/BaseProfiler.cpp b/logic/tools/BaseProfiler.cpp index 7cd1c5c7..d3c8d41e 100644 --- a/logic/tools/BaseProfiler.cpp +++ b/logic/tools/BaseProfiler.cpp @@ -7,7 +7,7 @@ BaseProfiler::BaseProfiler(InstancePtr instance, QObject *parent) { } -void BaseProfiler::beginProfiling(MinecraftProcess *process) +void BaseProfiler::beginProfiling(BaseProcess *process) { beginProfilingImpl(process); } diff --git a/logic/tools/BaseProfiler.h b/logic/tools/BaseProfiler.h index dd841da4..decaa5b8 100644 --- a/logic/tools/BaseProfiler.h +++ b/logic/tools/BaseProfiler.h @@ -4,7 +4,7 @@ class BaseInstance; class SettingsObject; -class MinecraftProcess; +class BaseProcess; class QProcess; class BaseProfiler : public BaseExternalTool @@ -15,13 +15,13 @@ public: public slots: - void beginProfiling(MinecraftProcess *process); + void beginProfiling(BaseProcess *process); void abortProfiling(); protected: QProcess *m_profilerProcess; - virtual void beginProfilingImpl(MinecraftProcess *process) = 0; + virtual void beginProfilingImpl(BaseProcess *process) = 0; virtual void abortProfilingImpl(); signals: diff --git a/logic/tools/JProfiler.cpp b/logic/tools/JProfiler.cpp index 659d80b6..7cdf0268 100644 --- a/logic/tools/JProfiler.cpp +++ b/logic/tools/JProfiler.cpp @@ -4,7 +4,7 @@ #include <QMessageBox> #include "logic/settings/SettingsObject.h" -#include "logic/MinecraftProcess.h" +#include "logic/BaseProcess.h" #include "logic/BaseInstance.h" #include "MultiMC.h" @@ -12,7 +12,7 @@ JProfiler::JProfiler(InstancePtr instance, QObject *parent) : BaseProfiler(insta { } -void JProfiler::beginProfilingImpl(MinecraftProcess *process) +void JProfiler::beginProfilingImpl(BaseProcess *process) { int port = MMC->settings()->get("JProfilerPort").toInt(); QProcess *profiler = new QProcess(this); diff --git a/logic/tools/JProfiler.h b/logic/tools/JProfiler.h index 3085511b..0763a799 100644 --- a/logic/tools/JProfiler.h +++ b/logic/tools/JProfiler.h @@ -9,7 +9,7 @@ public: JProfiler(InstancePtr instance, QObject *parent = 0); protected: - void beginProfilingImpl(MinecraftProcess *process); + void beginProfilingImpl(BaseProcess *process); }; class JProfilerFactory : public BaseProfilerFactory diff --git a/logic/tools/JVisualVM.cpp b/logic/tools/JVisualVM.cpp index f47294d7..312be863 100644 --- a/logic/tools/JVisualVM.cpp +++ b/logic/tools/JVisualVM.cpp @@ -4,7 +4,7 @@ #include <QStandardPaths> #include "logic/settings/SettingsObject.h" -#include "logic/MinecraftProcess.h" +#include "logic/BaseProcess.h" #include "logic/BaseInstance.h" #include "MultiMC.h" @@ -12,7 +12,7 @@ JVisualVM::JVisualVM(InstancePtr instance, QObject *parent) : BaseProfiler(insta { } -void JVisualVM::beginProfilingImpl(MinecraftProcess *process) +void JVisualVM::beginProfilingImpl(BaseProcess *process) { QProcess *profiler = new QProcess(this); profiler->setArguments(QStringList() << "--openpid" << QString::number(pid(process))); diff --git a/logic/tools/JVisualVM.h b/logic/tools/JVisualVM.h index a646c681..2a273568 100644 --- a/logic/tools/JVisualVM.h +++ b/logic/tools/JVisualVM.h @@ -9,7 +9,7 @@ public: JVisualVM(InstancePtr instance, QObject *parent = 0); protected: - void beginProfilingImpl(MinecraftProcess *process); + void beginProfilingImpl(BaseProcess *process); }; class JVisualVMFactory : public BaseProfilerFactory diff --git a/logic/tools/MCEditTool.cpp b/logic/tools/MCEditTool.cpp index e44ce784..c918d5d0 100644 --- a/logic/tools/MCEditTool.cpp +++ b/logic/tools/MCEditTool.cpp @@ -4,9 +4,12 @@ #include <QProcess> #include <QDesktopServices> #include <QUrl> +// FIXME: mixing logic and UI!!!! +#include <QInputDialog> #include "logic/settings/SettingsObject.h" #include "logic/BaseInstance.h" +#include "logic/minecraft/MinecraftInstance.h" #include "MultiMC.h" MCEditTool::MCEditTool(InstancePtr instance, QObject *parent) @@ -14,6 +17,36 @@ MCEditTool::MCEditTool(InstancePtr instance, QObject *parent) { } +QString MCEditTool::getSave() const +{ + // FIXME: mixing logic and UI!!!! + auto mcInstance = std::dynamic_pointer_cast<MinecraftInstance>(m_instance); + if(!mcInstance) + { + return QString(); + } + QDir saves(mcInstance->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(); +} + void MCEditTool::runImpl() { const QString mceditPath = MMC->settings()->get("MCEditPath").toString(); diff --git a/logic/tools/MCEditTool.h b/logic/tools/MCEditTool.h index 810caf25..b5cfc64e 100644 --- a/logic/tools/MCEditTool.h +++ b/logic/tools/MCEditTool.h @@ -9,6 +9,7 @@ public: explicit MCEditTool(InstancePtr instance, QObject *parent = 0); protected: + QString getSave() const; void runImpl() override; }; |