summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MultiMC.pro3
-rw-r--r--gui/consolewindow.cpp24
-rw-r--r--gui/consolewindow.h4
-rw-r--r--gui/consolewindow.ui7
-rw-r--r--gui/mainwindow.cpp2
-rw-r--r--logic/MinecraftProcess.cpp8
-rw-r--r--main.cpp2
7 files changed, 43 insertions, 7 deletions
diff --git a/MultiMC.pro b/MultiMC.pro
index b3b7faff..b82b2294 100644
--- a/MultiMC.pro
+++ b/MultiMC.pro
@@ -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
diff --git a/gui/consolewindow.cpp b/gui/consolewindow.cpp
index 811900a2..f2bc662a 100644
--- a/gui/consolewindow.cpp
+++ b/gui/consolewindow.cpp
@@ -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();
+} \ No newline at end of file
diff --git a/gui/consolewindow.h b/gui/consolewindow.h
index 60bec69f..d4485a45 100644
--- a/gui/consolewindow.h
+++ b/gui/consolewindow.h
@@ -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;
};
diff --git a/gui/consolewindow.ui b/gui/consolewindow.ui
index 9a766543..8dc80015 100644
--- a/gui/consolewindow.ui
+++ b/gui/consolewindow.ui
@@ -63,6 +63,13 @@
</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">
<string>Close</string>
diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp
index 4ccc12b6..75996c5d 100644
--- a/gui/mainwindow.cpp
+++ b/gui/mainwindow.cpp
@@ -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)));
diff --git a/logic/MinecraftProcess.cpp b/logic/MinecraftProcess.cpp
index 3d82008b..6ac5b886 100644
--- a/logic/MinecraftProcess.cpp
+++ b/logic/MinecraftProcess.cpp
@@ -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()
diff --git a/main.cpp b/main.cpp
index 72b0f225..12ef1ce7 100644
--- a/main.cpp
+++ b/main.cpp
@@ -71,7 +71,7 @@ private slots:
//FIXME: report error
return;
}
- console = new ConsoleWindow();
+ console = new ConsoleWindow(proc);
console->show();
connect(proc, SIGNAL(ended()), SLOT(onTerminated()));