mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2024-09-03 05:29:10 +00:00
Merge branch 'master' of https://github.com/Stiepen22/MultiMC5 into develop
Conflicts: AppSettings.cpp MultiMC.pro main.cpp
This commit is contained in:
commit
499ee1e365
@ -194,6 +194,9 @@ void MultiMC::initGlobalSettings()
|
|||||||
|
|
||||||
// The cat
|
// The cat
|
||||||
m_settings->registerSetting(new Setting("TheCat", false));
|
m_settings->registerSetting(new Setting("TheCat", false));
|
||||||
|
|
||||||
|
// Shall the main window hide on instance launch
|
||||||
|
m_settings->registerSetting(new Setting("NoHide", false));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiMC::initHttpMetaCache()
|
void MultiMC::initHttpMetaCache()
|
||||||
|
@ -2,13 +2,16 @@
|
|||||||
#include "ui_consolewindow.h"
|
#include "ui_consolewindow.h"
|
||||||
|
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
ConsoleWindow::ConsoleWindow(QWidget *parent) :
|
ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::ConsoleWindow),
|
ui(new Ui::ConsoleWindow),
|
||||||
m_mayclose(true)
|
m_mayclose(true),
|
||||||
|
proc(mcproc)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
connect(mcproc, SIGNAL(ended()), this, SLOT(onEnded()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ConsoleWindow::~ConsoleWindow()
|
ConsoleWindow::~ConsoleWindow()
|
||||||
@ -20,7 +23,7 @@ void ConsoleWindow::writeColor(QString text, const char *color)
|
|||||||
{
|
{
|
||||||
// append a paragraph
|
// append a paragraph
|
||||||
if (color != nullptr)
|
if (color != nullptr)
|
||||||
ui->text->appendHtml(QString("<font color=%1>%2</font>").arg(color).arg(text));
|
ui->text->appendHtml(QString("<font color=\"%1\">%2</font>").arg(color).arg(text));
|
||||||
else
|
else
|
||||||
ui->text->appendPlainText(text);
|
ui->text->appendPlainText(text);
|
||||||
// scroll down
|
// scroll down
|
||||||
@ -40,6 +43,15 @@ void ConsoleWindow::write(QString data, MessageLevel::Enum mode)
|
|||||||
else if (mode == MessageLevel::Error)
|
else if (mode == MessageLevel::Error)
|
||||||
while(iter.hasNext())
|
while(iter.hasNext())
|
||||||
writeColor(iter.next(), "red");
|
writeColor(iter.next(), "red");
|
||||||
|
else if (mode == MessageLevel::Warning)
|
||||||
|
while(iter.hasNext())
|
||||||
|
writeColor(iter.next(), "orange");
|
||||||
|
else if (mode == MessageLevel::Fatal)
|
||||||
|
while(iter.hasNext())
|
||||||
|
writeColor(iter.next(), "pink");
|
||||||
|
else if (mode == MessageLevel::Debug)
|
||||||
|
while(iter.hasNext())
|
||||||
|
writeColor(iter.next(), "green");
|
||||||
// TODO: implement other MessageLevels
|
// TODO: implement other MessageLevels
|
||||||
else
|
else
|
||||||
while(iter.hasNext())
|
while(iter.hasNext())
|
||||||
@ -72,3 +84,25 @@ void ConsoleWindow::closeEvent(QCloseEvent * event)
|
|||||||
else
|
else
|
||||||
QDialog::closeEvent(event);
|
QDialog::closeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConsoleWindow::on_btnKillMinecraft_clicked()
|
||||||
|
{
|
||||||
|
ui->btnKillMinecraft->setEnabled(false);
|
||||||
|
QMessageBox r_u_sure;
|
||||||
|
r_u_sure.setText("Kill Minecraft?");
|
||||||
|
r_u_sure.setInformativeText("This can cause the instance to get corrupted and should only be used if Minecraft is frozen for some reason");
|
||||||
|
r_u_sure.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||||
|
r_u_sure.setDefaultButton(QMessageBox::Yes);
|
||||||
|
if (r_u_sure.exec() == QMessageBox::Yes)
|
||||||
|
proc->killMinecraft();
|
||||||
|
else
|
||||||
|
ui->btnKillMinecraft->setEnabled(true);
|
||||||
|
r_u_sure.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConsoleWindow::onEnded()
|
||||||
|
{
|
||||||
|
ui->btnKillMinecraft->setEnabled(false);
|
||||||
|
// TODO: Check why this doesn't work
|
||||||
|
if (!proc->exitCode()) this->close();
|
||||||
|
}
|
||||||
|
@ -13,7 +13,7 @@ class ConsoleWindow : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ConsoleWindow(QWidget *parent = 0);
|
explicit ConsoleWindow(MinecraftProcess *proc, QWidget *parent = 0);
|
||||||
~ConsoleWindow();
|
~ConsoleWindow();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,12 +48,15 @@ public slots:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_closeButton_clicked();
|
void on_closeButton_clicked();
|
||||||
|
void on_btnKillMinecraft_clicked();
|
||||||
|
void onEnded();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *);
|
void closeEvent(QCloseEvent *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ConsoleWindow *ui;
|
Ui::ConsoleWindow *ui;
|
||||||
|
MinecraftProcess *proc;
|
||||||
bool m_mayclose;
|
bool m_mayclose;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -62,6 +62,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btnKillMinecraft">
|
||||||
|
<property name="text">
|
||||||
|
<string>Kill Minecraft</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="closeButton">
|
<widget class="QPushButton" name="closeButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -488,7 +488,10 @@ void MainWindow::doLogin(const QString& errorMsg)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_activeLogin = {loginDlg->getUsername(), QString("Offline"), qint64(-1)};
|
QString user = loginDlg->getUsername();
|
||||||
|
if (user.length() == 0)
|
||||||
|
user = QString("Offline");
|
||||||
|
m_activeLogin = {user, QString("Offline"), qint64(-1)};
|
||||||
m_activeInst = m_selectedInstance;
|
m_activeInst = m_selectedInstance;
|
||||||
launchInstance(m_activeInst, m_activeLogin);
|
launchInstance(m_activeInst, m_activeLogin);
|
||||||
}
|
}
|
||||||
@ -534,10 +537,22 @@ void MainWindow::launchInstance(BaseInstance *instance, LoginResponse response)
|
|||||||
if(!proc)
|
if(!proc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
console = new ConsoleWindow();
|
// Prepare GUI: If it shall stay open disable the required parts
|
||||||
|
if (MMC->settings()->get("NoHide").toBool())
|
||||||
|
{
|
||||||
|
ui->actionLaunchInstance->setEnabled(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
console = new ConsoleWindow(proc);
|
||||||
console->show();
|
console->show();
|
||||||
connect(proc, SIGNAL(log(QString, MessageLevel::Enum)),
|
connect(proc, SIGNAL(log(QString, MessageLevel::Enum)),
|
||||||
console, SLOT(write(QString, MessageLevel::Enum)));
|
console, SLOT(write(QString, MessageLevel::Enum)));
|
||||||
|
connect(proc, SIGNAL(ended()), this, SLOT(instanceEnded()));
|
||||||
|
proc->setLogin(m_activeLogin.username, m_activeLogin.sessionID);
|
||||||
proc->launch();
|
proc->launch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -664,3 +679,9 @@ void MainWindow::on_actionEditInstNotes_triggered()
|
|||||||
linst->setNotes(noteedit.getText());
|
linst->setNotes(noteedit.getText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::instanceEnded()
|
||||||
|
{
|
||||||
|
this->show();
|
||||||
|
ui->actionLaunchInstance->setEnabled(m_selectedInstance);
|
||||||
|
}
|
||||||
|
@ -111,6 +111,8 @@ private slots:
|
|||||||
|
|
||||||
void on_actionChangeInstLWJGLVersion_triggered();
|
void on_actionChangeInstLWJGLVersion_triggered();
|
||||||
|
|
||||||
|
void instanceEnded();
|
||||||
|
|
||||||
void on_actionInstanceSettings_triggered();
|
void on_actionInstanceSettings_triggered();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@ -128,6 +130,7 @@ protected:
|
|||||||
bool eventFilter(QObject *obj, QEvent *ev);
|
bool eventFilter(QObject *obj, QEvent *ev);
|
||||||
void setCatBackground(bool enabled);
|
void setCatBackground(bool enabled);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
KCategoryDrawer * drawer;
|
KCategoryDrawer * drawer;
|
||||||
KCategorizedView * view;
|
KCategorizedView * view;
|
||||||
|
@ -84,17 +84,14 @@ void MinecraftProcess::on_stdErr()
|
|||||||
for(int i = 0; i < lines.size() - 1; i++)
|
for(int i = 0; i < lines.size() - 1; i++)
|
||||||
{
|
{
|
||||||
QString & line = lines[i];
|
QString & line = lines[i];
|
||||||
MessageLevel::Enum level = MessageLevel::Error;
|
emit log(line.replace(username, "<Username>").replace(sessionID, "<Session ID>").toLocal8Bit(), getLevel(line, 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);
|
|
||||||
}
|
}
|
||||||
if(!complete)
|
if(!complete)
|
||||||
m_err_leftover = lines.last();
|
m_err_leftover = lines.last();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void MinecraftProcess::on_stdOut()
|
void MinecraftProcess::on_stdOut()
|
||||||
{
|
{
|
||||||
QByteArray data = readAllStandardOutput();
|
QByteArray data = readAllStandardOutput();
|
||||||
@ -106,7 +103,7 @@ void MinecraftProcess::on_stdOut()
|
|||||||
for(int i = 0; i < lines.size() - 1; i++)
|
for(int i = 0; i < lines.size() - 1; i++)
|
||||||
{
|
{
|
||||||
QString & line = lines[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)
|
if(!complete)
|
||||||
m_out_leftover = lines.last();
|
m_out_leftover = lines.last();
|
||||||
@ -120,7 +117,12 @@ void MinecraftProcess::finish(int code, ExitStatus status)
|
|||||||
//TODO: error handling
|
//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));
|
m_prepostlaunchprocess.processEnvironment().insert("INST_EXITCODE", QString(code));
|
||||||
|
|
||||||
@ -138,6 +140,12 @@ void MinecraftProcess::finish(int code, ExitStatus status)
|
|||||||
emit ended();
|
emit ended();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MinecraftProcess::killMinecraft()
|
||||||
|
{
|
||||||
|
killed = true;
|
||||||
|
kill();
|
||||||
|
}
|
||||||
|
|
||||||
void MinecraftProcess::launch()
|
void MinecraftProcess::launch()
|
||||||
{
|
{
|
||||||
if (!m_instance->settings().get("PreLaunchCommand").toString().isEmpty())
|
if (!m_instance->settings().get("PreLaunchCommand").toString().isEmpty())
|
||||||
@ -156,7 +164,7 @@ void MinecraftProcess::launch()
|
|||||||
emit log(QString("Minecraft folder is: '%1'").arg(workingDirectory()));
|
emit log(QString("Minecraft folder is: '%1'").arg(workingDirectory()));
|
||||||
QString JavaPath = m_instance->settings().get("JavaPath").toString();
|
QString JavaPath = m_instance->settings().get("JavaPath").toString();
|
||||||
emit log(QString("Java path: '%1'").arg(JavaPath));
|
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);
|
start(JavaPath, m_args);
|
||||||
if (!waitForStarted())
|
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;
|
||||||
|
|
||||||
|
}
|
@ -59,6 +59,10 @@ public:
|
|||||||
|
|
||||||
void setMinecraftArguments(QStringList args);
|
void setMinecraftArguments(QStringList args);
|
||||||
|
|
||||||
|
void killMinecraft();
|
||||||
|
|
||||||
|
inline void setLogin(QString user, QString sid) { username = user; sessionID = sid; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* @brief emitted when mc has finished and the PostLaunchCommand was run
|
* @brief emitted when mc has finished and the PostLaunchCommand was run
|
||||||
@ -83,4 +87,9 @@ protected slots:
|
|||||||
void finish(int, QProcess::ExitStatus status);
|
void finish(int, QProcess::ExitStatus status);
|
||||||
void on_stdErr();
|
void on_stdErr();
|
||||||
void on_stdOut();
|
void on_stdOut();
|
||||||
|
private:
|
||||||
|
bool killed;
|
||||||
|
MessageLevel::Enum getLevel(const QString &message, MessageLevel::Enum defaultLevel);
|
||||||
|
QString sessionID;
|
||||||
|
QString username;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user