NOISSUE Refactors and moving of things
This commit is contained in:
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -7,7 +7,7 @@ BaseProfiler::BaseProfiler(InstancePtr instance, QObject *parent)
|
||||
{
|
||||
}
|
||||
|
||||
void BaseProfiler::beginProfiling(MinecraftProcess *process)
|
||||
void BaseProfiler::beginProfiling(BaseProcess *process)
|
||||
{
|
||||
beginProfilingImpl(process);
|
||||
}
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
|
@ -9,7 +9,7 @@ public:
|
||||
JProfiler(InstancePtr instance, QObject *parent = 0);
|
||||
|
||||
protected:
|
||||
void beginProfilingImpl(MinecraftProcess *process);
|
||||
void beginProfilingImpl(BaseProcess *process);
|
||||
};
|
||||
|
||||
class JProfilerFactory : public BaseProfilerFactory
|
||||
|
@ -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)));
|
||||
|
@ -9,7 +9,7 @@ public:
|
||||
JVisualVM(InstancePtr instance, QObject *parent = 0);
|
||||
|
||||
protected:
|
||||
void beginProfilingImpl(MinecraftProcess *process);
|
||||
void beginProfilingImpl(BaseProcess *process);
|
||||
};
|
||||
|
||||
class JVisualVMFactory : public BaseProfilerFactory
|
||||
|
@ -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();
|
||||
|
@ -9,6 +9,7 @@ public:
|
||||
explicit MCEditTool(InstancePtr instance, QObject *parent = 0);
|
||||
|
||||
protected:
|
||||
QString getSave() const;
|
||||
void runImpl() override;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user