summaryrefslogtreecommitdiffstats
path: root/logic
diff options
context:
space:
mode:
Diffstat (limited to 'logic')
-rw-r--r--logic/InstanceLauncher.cpp7
-rw-r--r--logic/MinecraftProcess.cpp17
-rw-r--r--logic/MinecraftProcess.h20
3 files changed, 32 insertions, 12 deletions
diff --git a/logic/InstanceLauncher.cpp b/logic/InstanceLauncher.cpp
index f587e583..534d07d1 100644
--- a/logic/InstanceLauncher.cpp
+++ b/logic/InstanceLauncher.cpp
@@ -48,12 +48,9 @@ void InstanceLauncher::onLoginComplete()
return;
}
console = new ConsoleWindow(proc);
- console->show();
-
- connect(proc, SIGNAL(ended()), SLOT(onTerminated()));
- connect(proc, SIGNAL(log(QString, MessageLevel::Enum)), console,
- SLOT(write(QString, MessageLevel::Enum)));
+ connect(console, SIGNAL(isClosing()), this, SLOT(onTerminated()));
+ proc->setLogin(result.username, result.session_id);
proc->launch();
}
diff --git a/logic/MinecraftProcess.cpp b/logic/MinecraftProcess.cpp
index 6c86c73a..b3b587e8 100644
--- a/logic/MinecraftProcess.cpp
+++ b/logic/MinecraftProcess.cpp
@@ -101,7 +101,7 @@ void MinecraftProcess::on_stdOut()
for (int i = 0; i < lines.size() - 1; i++)
{
QString &line = lines[i];
- emit log(line /*.replace(username, "<Username>").replace(sessionID, "<Session ID>")*/,
+ emit log(line.replace(username, "<Username>").replace(sessionID, "<Session ID>"),
getLevel(line, MessageLevel::Message));
}
if (!complete)
@@ -139,7 +139,8 @@ void MinecraftProcess::finish(int code, ExitStatus status)
m_prepostlaunchprocess.waitForFinished();
if (m_prepostlaunchprocess.exitStatus() != NormalExit)
{
- // TODO: error handling
+ emit postlaunch_failed(m_instance, m_prepostlaunchprocess.exitCode(),
+ m_prepostlaunchprocess.exitStatus());
}
}
m_instance->cleanupAfterRun();
@@ -160,7 +161,9 @@ void MinecraftProcess::launch()
m_prepostlaunchprocess.waitForFinished();
if (m_prepostlaunchprocess.exitStatus() != NormalExit)
{
- // TODO: error handling
+ m_instance->cleanupAfterRun();
+ emit prelaunch_failed(m_instance, m_prepostlaunchprocess.exitCode(),
+ m_prepostlaunchprocess.exitStatus());
return;
}
}
@@ -171,15 +174,15 @@ void MinecraftProcess::launch()
QString JavaPath = m_instance->settings().get("JavaPath").toString();
emit log(QString("Java path: '%1'").arg(JavaPath));
emit log(QString("Arguments: '%1'").arg(
- m_args.join("' '") /*.replace(username, "<Username>").replace(sessionID, "<Session
-ID>")*/));
+ m_args.join("' '").replace(username, "<Username>").replace(sessionID, "<Session ID>")));
start(JavaPath, m_args);
if (!waitForStarted())
{
//: Error message displayed if instace can't start
- emit log(tr("Could not launch minecraft!"));
+ emit log(tr("Could not launch minecraft!"), MessageLevel::Error);
+ m_instance->cleanupAfterRun();
+ emit launch_failed(m_instance);
return;
- // TODO: error handling
}
}
diff --git a/logic/MinecraftProcess.h b/logic/MinecraftProcess.h
index bba97692..6d4a1eb7 100644
--- a/logic/MinecraftProcess.h
+++ b/logic/MinecraftProcess.h
@@ -58,6 +58,11 @@ public:
*/
void launch();
+ BaseInstance *instance()
+ {
+ return m_instance;
+ }
+
void setMinecraftWorkdir(QString path);
void setMinecraftArguments(QStringList args);
@@ -72,6 +77,21 @@ public:
signals:
/**
+ * @brief emitted when Minecraft immediately fails to run
+ */
+ void launch_failed(BaseInstance *);
+
+ /**
+ * @brief emitted when the PreLaunchCommand fails
+ */
+ void prelaunch_failed(BaseInstance *, int code, QProcess::ExitStatus status);
+
+ /**
+ * @brief emitted when the PostLaunchCommand fails
+ */
+ void postlaunch_failed(BaseInstance *, int code, QProcess::ExitStatus status);
+
+ /**
* @brief emitted when mc has finished and the PostLaunchCommand was run
*/
void ended(BaseInstance *, int code, QProcess::ExitStatus status);