diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-09-08 16:21:49 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-09-08 16:21:49 +0200 |
commit | 499ee1e36569fca73bdb809183242b03da69f3ef (patch) | |
tree | 8d29f00958da54ade7e560b98e43fae89dfff0d4 /logic | |
parent | 7e1cf22ce61e8a5450e5dc74993e471c20b2742f (diff) | |
parent | dab2bbe4e79cfd8b3b72b8d2fd0e5bd66e0281a9 (diff) | |
download | MultiMC-499ee1e36569fca73bdb809183242b03da69f3ef.tar MultiMC-499ee1e36569fca73bdb809183242b03da69f3ef.tar.gz MultiMC-499ee1e36569fca73bdb809183242b03da69f3ef.tar.lz MultiMC-499ee1e36569fca73bdb809183242b03da69f3ef.tar.xz MultiMC-499ee1e36569fca73bdb809183242b03da69f3ef.zip |
Merge branch 'master' of https://github.com/Stiepen22/MultiMC5 into develop
Conflicts:
AppSettings.cpp
MultiMC.pro
main.cpp
Diffstat (limited to 'logic')
-rw-r--r-- | logic/MinecraftProcess.cpp | 43 | ||||
-rw-r--r-- | logic/MinecraftProcess.h | 9 |
2 files changed, 42 insertions, 10 deletions
diff --git a/logic/MinecraftProcess.cpp b/logic/MinecraftProcess.cpp index d34be835..c33d34a8 100644 --- a/logic/MinecraftProcess.cpp +++ b/logic/MinecraftProcess.cpp @@ -84,17 +84,14 @@ void MinecraftProcess::on_stdErr() for(int i = 0; i < lines.size() - 1; i++) { QString & line = lines[i]; - MessageLevel::Enum level = MessageLevel::Error; - if(line.contains("[INFO]") || line.contains("[CONFIG]") || line.contains("[FINE]") || line.contains("[FINER]") || line.contains("[FINEST]") ) - level = MessageLevel::Message; - if(line.contains("[SEVERE]") || line.contains("[WARNING]") || line.contains("[STDERR]")) - level = MessageLevel::Error; - emit log(lines[i].toLocal8Bit(), level); + emit log(line.replace(username, "<Username>").replace(sessionID, "<Session ID>").toLocal8Bit(), getLevel(line, MessageLevel::Error)); } if(!complete) m_err_leftover = lines.last(); } + + void MinecraftProcess::on_stdOut() { QByteArray data = readAllStandardOutput(); @@ -106,7 +103,7 @@ void MinecraftProcess::on_stdOut() for(int i = 0; i < lines.size() - 1; i++) { QString & line = lines[i]; - emit log(lines[i].toLocal8Bit(), MessageLevel::Message); + emit log(line.replace(username, "<Username>").replace(sessionID, "<Session ID>").toLocal8Bit(), getLevel(line, MessageLevel::Message)); } if(!complete) m_out_leftover = lines.last(); @@ -120,7 +117,12 @@ void MinecraftProcess::finish(int code, ExitStatus status) //TODO: error handling } - emit log("Minecraft exited."); + // TODO: Localization + + if (!killed) + emit log("Minecraft exited."); + else + emit log("Minecraft was killed by user.", MessageLevel::Error); m_prepostlaunchprocess.processEnvironment().insert("INST_EXITCODE", QString(code)); @@ -138,6 +140,12 @@ void MinecraftProcess::finish(int code, ExitStatus status) emit ended(); } +void MinecraftProcess::killMinecraft() +{ + killed = true; + kill(); +} + void MinecraftProcess::launch() { if (!m_instance->settings().get("PreLaunchCommand").toString().isEmpty()) @@ -156,7 +164,7 @@ void MinecraftProcess::launch() emit log(QString("Minecraft folder is: '%1'").arg(workingDirectory())); 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("' '"))); + emit log(QString("Arguments: '%1'").arg(m_args.join("' '").replace(username, "<Username>").replace(sessionID, "<Session ID>"))); start(JavaPath, m_args); if (!waitForStarted()) { @@ -166,4 +174,19 @@ void MinecraftProcess::launch() } } - +MessageLevel::Enum MinecraftProcess::getLevel(const QString &line, MessageLevel::Enum level) +{ + + if(line.contains("[INFO]") || line.contains("[CONFIG]") || line.contains("[FINE]") || line.contains("[FINER]") || line.contains("[FINEST]") ) + level = MessageLevel::Message; + if(line.contains("[SEVERE]") || line.contains("[STDERR]")) + level = MessageLevel::Error; + if(line.contains("[WARNING]")) + level = MessageLevel::Warning; + if(line.contains("Exception in thread") || line.contains(" at ")) + level = MessageLevel::Fatal; + if(line.contains("[DEBUG]")) + level = MessageLevel::Debug; + return level; + +}
\ No newline at end of file diff --git a/logic/MinecraftProcess.h b/logic/MinecraftProcess.h index 516bf986..a1dfa23f 100644 --- a/logic/MinecraftProcess.h +++ b/logic/MinecraftProcess.h @@ -59,6 +59,10 @@ public: void setMinecraftArguments(QStringList args); + void killMinecraft(); + + inline void setLogin(QString user, QString sid) { username = user; sessionID = sid; } + signals: /** * @brief emitted when mc has finished and the PostLaunchCommand was run @@ -83,4 +87,9 @@ protected slots: void finish(int, QProcess::ExitStatus status); void on_stdErr(); void on_stdOut(); +private: + bool killed; + MessageLevel::Enum getLevel(const QString &message, MessageLevel::Enum defaultLevel); + QString sessionID; + QString username; }; |