mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2024-12-25 15:16:02 +00:00
Made instace killing actually work
This commit is contained in:
parent
b44e70d58d
commit
f897a200e2
@ -40,7 +40,8 @@ FORMS += gui/mainwindow.ui \
|
||||
gui/settingsdialog.ui \
|
||||
gui/modeditwindow.ui \
|
||||
gui/instancesettings.ui \
|
||||
gui/logindialog.ui
|
||||
gui/logindialog.ui \
|
||||
gui/consolewindow.ui
|
||||
|
||||
RESOURCES += \
|
||||
multimc.qrc
|
||||
|
@ -2,11 +2,13 @@
|
||||
#include "ui_consolewindow.h"
|
||||
|
||||
#include <QScrollBar>
|
||||
#include <QMessageBox>
|
||||
|
||||
ConsoleWindow::ConsoleWindow(QWidget *parent) :
|
||||
ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::ConsoleWindow),
|
||||
m_mayclose(true)
|
||||
m_mayclose(true),
|
||||
proc(mcproc)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
@ -40,6 +42,9 @@ void ConsoleWindow::write(QString data, MessageLevel::Enum mode)
|
||||
else if (mode == MessageLevel::Error)
|
||||
while(iter.hasNext())
|
||||
writeColor(iter.next(), "red");
|
||||
else if (mode == MessageLevel::Warning)
|
||||
while(iter.hasNext())
|
||||
writeColor(iter.next(), "orange");
|
||||
// TODO: implement other MessageLevels
|
||||
else
|
||||
while(iter.hasNext())
|
||||
@ -72,3 +77,18 @@ void ConsoleWindow::closeEvent(QCloseEvent * event)
|
||||
else
|
||||
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();
|
||||
}
|
@ -13,7 +13,7 @@ class ConsoleWindow : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConsoleWindow(QWidget *parent = 0);
|
||||
explicit ConsoleWindow(MinecraftProcess *proc, QWidget *parent = 0);
|
||||
~ConsoleWindow();
|
||||
|
||||
/**
|
||||
@ -48,12 +48,14 @@ public slots:
|
||||
|
||||
private slots:
|
||||
void on_closeButton_clicked();
|
||||
void on_btnKillMinecraft_clicked();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *);
|
||||
|
||||
private:
|
||||
Ui::ConsoleWindow *ui;
|
||||
MinecraftProcess *proc;
|
||||
bool m_mayclose;
|
||||
};
|
||||
|
||||
|
@ -62,6 +62,13 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnKillMinecraft">
|
||||
<property name="text">
|
||||
<string>Kill Minecraft</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="closeButton">
|
||||
<property name="text">
|
||||
|
@ -538,7 +538,7 @@ void MainWindow::launchInstance(BaseInstance *instance, LoginResponse response)
|
||||
if(!proc)
|
||||
return;
|
||||
|
||||
console = new ConsoleWindow();
|
||||
console = new ConsoleWindow(proc);
|
||||
console->show();
|
||||
connect(proc, SIGNAL(log(QString, MessageLevel::Enum)),
|
||||
console, SLOT(write(QString, MessageLevel::Enum)));
|
||||
|
@ -120,7 +120,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));
|
||||
|
||||
@ -141,6 +146,7 @@ void MinecraftProcess::finish(int code, ExitStatus status)
|
||||
void MinecraftProcess::killMinecraft()
|
||||
{
|
||||
killed = true;
|
||||
kill();
|
||||
}
|
||||
|
||||
void MinecraftProcess::launch()
|
||||
|
Loading…
Reference in New Issue
Block a user