summaryrefslogtreecommitdiffstats
path: root/logic
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-05-18 19:07:01 +0200
committerPetr Mrázek <peterix@gmail.com>2014-05-18 19:07:01 +0200
commit911ac19a56fa1a5f8dd4798385022813cd0b9d07 (patch)
tree607971d32b1c6e18bb5d6570800fa7e3bd11878d /logic
parent7f2a16917e347db2ffcdd5a148feda71f6f3a47e (diff)
downloadMultiMC-911ac19a56fa1a5f8dd4798385022813cd0b9d07.tar
MultiMC-911ac19a56fa1a5f8dd4798385022813cd0b9d07.tar.gz
MultiMC-911ac19a56fa1a5f8dd4798385022813cd0b9d07.tar.lz
MultiMC-911ac19a56fa1a5f8dd4798385022813cd0b9d07.tar.xz
MultiMC-911ac19a56fa1a5f8dd4798385022813cd0b9d07.zip
Screenshot upload dialog(s) now have the console window as parent.
Diffstat (limited to 'logic')
-rw-r--r--logic/BaseInstance.h2
-rw-r--r--logic/LegacyInstance.cpp12
-rw-r--r--logic/LegacyInstance.h2
-rw-r--r--logic/MinecraftProcess.cpp2
-rw-r--r--logic/MinecraftProcess.h19
-rw-r--r--logic/OneSixInstance.cpp13
-rw-r--r--logic/OneSixInstance.h2
7 files changed, 21 insertions, 31 deletions
diff --git a/logic/BaseInstance.h b/logic/BaseInstance.h
index d38ae409..16791592 100644
--- a/logic/BaseInstance.h
+++ b/logic/BaseInstance.h
@@ -163,7 +163,7 @@ public:
virtual std::shared_ptr<Task> doUpdate() = 0;
/// returns a valid minecraft process, ready for launch with the given account.
- virtual MinecraftProcess *prepareForLaunch(AuthSessionPtr account) = 0;
+ virtual bool prepareForLaunch(AuthSessionPtr account, QString & launchScript) = 0;
/// do any necessary cleanups after the instance finishes. also runs before
/// 'prepareForLaunch'
diff --git a/logic/LegacyInstance.cpp b/logic/LegacyInstance.cpp
index d06b8827..6648e059 100644
--- a/logic/LegacyInstance.cpp
+++ b/logic/LegacyInstance.cpp
@@ -50,16 +50,13 @@ std::shared_ptr<Task> LegacyInstance::doUpdate()
return std::shared_ptr<Task>(new LegacyUpdate(this, this));
}
-MinecraftProcess *LegacyInstance::prepareForLaunch(AuthSessionPtr account)
+bool LegacyInstance::prepareForLaunch(AuthSessionPtr account, QString & launchScript)
{
- MinecraftProcess *proc = new MinecraftProcess(this);
-
QIcon icon = MMC->icons()->getIcon(iconKey());
auto pixmap = icon.pixmap(128, 128);
pixmap.save(PathCombine(minecraftRoot(), "icon.png"), "PNG");
// create the launch script
- QString launchScript;
{
// window size
QString windowParams;
@@ -79,12 +76,7 @@ MinecraftProcess *LegacyInstance::prepareForLaunch(AuthSessionPtr account)
launchScript += "lwjgl " + lwjgl + "\n";
launchScript += "launcher legacy\n";
}
- proc->setLaunchScript(launchScript);
-
- // set the process work path
- proc->setWorkdir(minecraftRoot());
-
- return proc;
+ return true;
}
void LegacyInstance::cleanupAfterRun()
diff --git a/logic/LegacyInstance.h b/logic/LegacyInstance.h
index badaf7e3..aa80968e 100644
--- a/logic/LegacyInstance.h
+++ b/logic/LegacyInstance.h
@@ -79,7 +79,7 @@ public:
virtual void setShouldUpdate(bool val) override;
virtual std::shared_ptr<Task> doUpdate() override;
- virtual MinecraftProcess *prepareForLaunch(AuthSessionPtr account) override;
+ virtual bool prepareForLaunch(AuthSessionPtr account, QString & launchScript) override;
virtual void cleanupAfterRun() override;
virtual QDialog *createModEditDialog(QWidget *parent) override;
diff --git a/logic/MinecraftProcess.cpp b/logic/MinecraftProcess.cpp
index e43e5830..b268a4cc 100644
--- a/logic/MinecraftProcess.cpp
+++ b/logic/MinecraftProcess.cpp
@@ -34,7 +34,7 @@
#define IBUS "@im=ibus"
// constructor
-MinecraftProcess::MinecraftProcess(BaseInstance *inst) : m_instance(inst)
+MinecraftProcess::MinecraftProcess(InstancePtr inst) : m_instance(inst)
{
connect(this, SIGNAL(finished(int, QProcess::ExitStatus)),
SLOT(finish(int, QProcess::ExitStatus)));
diff --git a/logic/MinecraftProcess.h b/logic/MinecraftProcess.h
index d47a6cd2..b61ef380 100644
--- a/logic/MinecraftProcess.h
+++ b/logic/MinecraftProcess.h
@@ -52,8 +52,13 @@ public:
* @brief MinecraftProcess constructor
* @param inst the Instance pointer to launch
*/
- MinecraftProcess(BaseInstance *inst);
+ MinecraftProcess(InstancePtr inst);
+ virtual ~MinecraftProcess()
+ {
+
+ };
+
/**
* @brief start the launcher part with the provided launch script
*/
@@ -69,7 +74,7 @@ public:
*/
void abort();
- BaseInstance *instance()
+ InstancePtr instance()
{
return m_instance;
}
@@ -97,22 +102,22 @@ signals:
/**
* @brief emitted when Minecraft immediately fails to run
*/
- void launch_failed(BaseInstance *);
+ void launch_failed(InstancePtr);
/**
* @brief emitted when the PreLaunchCommand fails
*/
- void prelaunch_failed(BaseInstance *, int code, QProcess::ExitStatus status);
+ void prelaunch_failed(InstancePtr, int code, QProcess::ExitStatus status);
/**
* @brief emitted when the PostLaunchCommand fails
*/
- void postlaunch_failed(BaseInstance *, int code, QProcess::ExitStatus status);
+ void postlaunch_failed(InstancePtr, int code, QProcess::ExitStatus status);
/**
* @brief emitted when mc has finished and the PostLaunchCommand was run
*/
- void ended(BaseInstance *, int code, QProcess::ExitStatus status);
+ void ended(InstancePtr, int code, QProcess::ExitStatus status);
/**
* @brief emitted when we want to log something
@@ -122,7 +127,7 @@ signals:
void log(QString text, MessageLevel::Enum level = MessageLevel::MultiMC);
protected:
- BaseInstance *m_instance = nullptr;
+ InstancePtr m_instance;
QString m_err_leftover;
QString m_out_leftover;
QProcess m_prepostlaunchprocess;
diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp
index 24d54446..6f3018cb 100644
--- a/logic/OneSixInstance.cpp
+++ b/logic/OneSixInstance.cpp
@@ -189,7 +189,7 @@ QStringList OneSixInstance::processMinecraftArgs(AuthSessionPtr session)
return parts;
}
-MinecraftProcess *OneSixInstance::prepareForLaunch(AuthSessionPtr session)
+bool OneSixInstance::prepareForLaunch(AuthSessionPtr account, QString &launchScript)
{
I_D(OneSixInstance);
@@ -200,7 +200,6 @@ MinecraftProcess *OneSixInstance::prepareForLaunch(AuthSessionPtr session)
auto version = d->version;
if (!version)
return nullptr;
- QString launchScript;
{
auto libs = version->getActiveNormalLibs();
for (auto lib : libs)
@@ -212,7 +211,7 @@ MinecraftProcess *OneSixInstance::prepareForLaunch(AuthSessionPtr session)
}
launchScript += "mainClass " + version->mainClass + "\n";
- for (auto param : processMinecraftArgs(session))
+ for (auto param : processMinecraftArgs(account))
{
launchScript += "param " + param + "\n";
}
@@ -240,13 +239,7 @@ MinecraftProcess *OneSixInstance::prepareForLaunch(AuthSessionPtr session)
}
launchScript += "natives " + natives_dir.absolutePath() + "\n";
launchScript += "launcher onesix\n";
-
- // create the process and set its parameters
- MinecraftProcess *proc = new MinecraftProcess(this);
- proc->setWorkdir(minecraftRoot());
- proc->setLaunchScript(launchScript);
- // proc->setNativeFolder(natives_dir.absolutePath());
- return proc;
+ return true;
}
void OneSixInstance::cleanupAfterRun()
diff --git a/logic/OneSixInstance.h b/logic/OneSixInstance.h
index 4e9d62a1..13a392c2 100644
--- a/logic/OneSixInstance.h
+++ b/logic/OneSixInstance.h
@@ -40,7 +40,7 @@ public:
virtual QString instanceConfigFolder() const override;
virtual std::shared_ptr<Task> doUpdate() override;
- virtual MinecraftProcess *prepareForLaunch(AuthSessionPtr session) override;
+ virtual bool prepareForLaunch(AuthSessionPtr account, QString & launchScript) override;
virtual void cleanupAfterRun() override;