summaryrefslogtreecommitdiffstats
path: root/data
diff options
context:
space:
mode:
authorOrochimarufan <orochimarufan.x3@gmail.com>2013-02-22 18:18:23 +0100
committerOrochimarufan <orochimarufan.x3@gmail.com>2013-02-22 18:18:23 +0100
commit3a173648e789f30b2843241ee38e694d16e10358 (patch)
tree9941f7025d8f3f5ff19c515bde8ae3ebca98a4a8 /data
parent10c707363b3f19a8862b5ebd2858bcaad1304a13 (diff)
downloadMultiMC-3a173648e789f30b2843241ee38e694d16e10358.tar
MultiMC-3a173648e789f30b2843241ee38e694d16e10358.tar.gz
MultiMC-3a173648e789f30b2843241ee38e694d16e10358.tar.lz
MultiMC-3a173648e789f30b2843241ee38e694d16e10358.tar.xz
MultiMC-3a173648e789f30b2843241ee38e694d16e10358.zip
Implement ConsoleWindow
Diffstat (limited to 'data')
-rw-r--r--data/minecraftprocess.cpp38
-rw-r--r--data/minecraftprocess.h6
2 files changed, 40 insertions, 4 deletions
diff --git a/data/minecraftprocess.cpp b/data/minecraftprocess.cpp
index 4cbe7208..d08b767c 100644
--- a/data/minecraftprocess.cpp
+++ b/data/minecraftprocess.cpp
@@ -117,9 +117,33 @@ MinecraftProcess::MinecraftProcess(InstancePtr inst, QString user, QString sessi
this->setWorkingDirectory(mcDir.absolutePath());
m_prepostlaunchprocess.setWorkingDirectory(mcDir.absolutePath());
- //TODO: do console redirection
+ // std channels
+ connect(this, SIGNAL(readyReadStandardError()), SLOT(on_stdErr()));
+ connect(this, SIGNAL(readyReadStandardOutput()), SLOT(on_stdOut()));
}
+// console window
+void MinecraftProcess::on_stdErr()
+{
+ if (m_console != nullptr)
+ m_console->write(readAllStandardError(), ConsoleWindow::ERROR);
+}
+
+void MinecraftProcess::on_stdOut()
+{
+ if (m_console != nullptr)
+ m_console->write(readAllStandardOutput(), ConsoleWindow::DEFAULT);
+}
+
+void MinecraftProcess::log(QString text)
+{
+ if (m_console != nullptr)
+ m_console->write(text);
+ else
+ qDebug(qPrintable(text));
+}
+
+// exit handler
void MinecraftProcess::finish(int code, ExitStatus status)
{
if (status != NormalExit)
@@ -127,6 +151,8 @@ void MinecraftProcess::finish(int code, ExitStatus status)
//TODO: error handling
}
+ log("Minecraft exited.");
+
m_prepostlaunchprocess.processEnvironment().insert("INST_EXITCODE", QString(code));
// run post-exit
@@ -140,6 +166,9 @@ void MinecraftProcess::finish(int code, ExitStatus status)
}
}
+ if (m_console != nullptr)
+ m_console->setMayClose(true);
+
emit ended();
}
@@ -162,14 +191,17 @@ void MinecraftProcess::launch()
genArgs();
- qDebug("Minecraft folder is: '%s'", qPrintable(workingDirectory()));
- qDebug("Instance launched with arguments: '%s'", qPrintable(m_arguments.join("' '")));
+ log(QString("Minecraft folder is: '%1'").arg(workingDirectory()));
+ log(QString("Instance launched with arguments: '%1'").arg(m_arguments.join("' '")));
start(m_instance->getJavaPath(), m_arguments);
if (!waitForStarted())
{
//TODO: error handling
}
+
+ if(m_console != nullptr)
+ m_console->setMayClose(false);
}
void MinecraftProcess::genArgs()
diff --git a/data/minecraftprocess.h b/data/minecraftprocess.h
index 99a3bed6..bede9486 100644
--- a/data/minecraftprocess.h
+++ b/data/minecraftprocess.h
@@ -19,7 +19,7 @@
#include <QProcess>
-class ConsoleWindow;
+#include "gui/consolewindow.h"
#include "instance.h"
@@ -86,9 +86,13 @@ protected:
QStringList m_arguments;
void genArgs();
+ void log(QString text);
protected slots:
void finish(int, QProcess::ExitStatus status);
+ void on_stdErr();
+ void on_stdOut();
+
};
#endif // MINECRAFTPROCESS_H