diff options
author | Sky <git@bunnies.cc> | 2013-10-26 11:13:14 +0100 |
---|---|---|
committer | Sky <git@bunnies.cc> | 2013-10-26 11:13:14 +0100 |
commit | 1f28a3b8af228ec40412571859f15ea216ccb52a (patch) | |
tree | 975225cfc5981d9f8e5b79ba224db02782aa4faf /gui | |
parent | cf07b90bdaf7dda2cbdd8ae9a7212c04badd0b09 (diff) | |
parent | c467ebf1327d6266fc51443edfac6f0b536b6602 (diff) | |
download | MultiMC-1f28a3b8af228ec40412571859f15ea216ccb52a.tar MultiMC-1f28a3b8af228ec40412571859f15ea216ccb52a.tar.gz MultiMC-1f28a3b8af228ec40412571859f15ea216ccb52a.tar.lz MultiMC-1f28a3b8af228ec40412571859f15ea216ccb52a.tar.xz MultiMC-1f28a3b8af228ec40412571859f15ea216ccb52a.zip |
Merge branch 'develop'
Diffstat (limited to 'gui')
-rw-r--r-- | gui/consolewindow.cpp | 13 | ||||
-rw-r--r-- | gui/consolewindow.h | 2 | ||||
-rw-r--r-- | gui/mainwindow.cpp | 73 | ||||
-rw-r--r-- | gui/mainwindow.h | 11 |
4 files changed, 83 insertions, 16 deletions
diff --git a/gui/consolewindow.cpp b/gui/consolewindow.cpp index deeedd65..6ed4a0ec 100644 --- a/gui/consolewindow.cpp +++ b/gui/consolewindow.cpp @@ -14,7 +14,7 @@ ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) : { MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); - connect(mcproc, SIGNAL(ended()), this, SLOT(onEnded())); + connect(mcproc, SIGNAL(ended(BaseInstance*)), this, SLOT(onEnded(BaseInstance*))); } ConsoleWindow::~ConsoleWindow() @@ -109,9 +109,14 @@ void ConsoleWindow::on_btnKillMinecraft_clicked() r_u_sure.close(); } -void ConsoleWindow::onEnded() +void ConsoleWindow::onEnded(BaseInstance *instance) { ui->btnKillMinecraft->setEnabled(false); - // TODO: Check why this doesn't work - if (!proc->exitCode()) this->close(); + + // TODO: Might need an option to forcefully close, even on an error + if(instance->settings().get("AutoCloseConsole").toBool()) + { + // TODO: Check why this doesn't work + if (!proc->exitCode()) this->close(); + } } diff --git a/gui/consolewindow.h b/gui/consolewindow.h index 6a6c9e50..e8790c92 100644 --- a/gui/consolewindow.h +++ b/gui/consolewindow.h @@ -49,7 +49,7 @@ public slots: private slots: void on_closeButton_clicked(); void on_btnKillMinecraft_clicked(); - void onEnded(); + void onEnded(BaseInstance *instance); protected: void closeEvent(QCloseEvent *); diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index cce16a93..46fd5bd7 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -155,6 +155,12 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi // FIXME: stop using POINTERS everywhere connect(MMC->instances().get(), SIGNAL(dataIsInvalid()), SLOT(selectionBad())); + m_statusLeft = new QLabel(tr("Instance type"), this); + m_statusRight = new QLabel(tr("Assets information"), this); + m_statusRight->setAlignment(Qt::AlignRight); + statusBar()->addPermanentWidget(m_statusLeft, 1); + statusBar()->addPermanentWidget(m_statusRight, 0); + // run the things that load and download other things... FIXME: this is NOT the place // FIXME: invisible actions in the background = NOPE. { @@ -168,6 +174,11 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi MMC->lwjgllist()->loadList(); } assets_downloader = new OneSixAssets(); + connect(assets_downloader, SIGNAL(indexStarted()), SLOT(assetsIndexStarted())); + connect(assets_downloader, SIGNAL(filesStarted()), SLOT(assetsFilesStarted())); + connect(assets_downloader, SIGNAL(filesProgress(int, int, int)), SLOT(assetsFilesProgress(int, int, int))); + connect(assets_downloader, SIGNAL(failed()), SLOT(assetsFailed())); + connect(assets_downloader, SIGNAL(finished()), SLOT(assetsFinished())); assets_downloader->start(); } } @@ -433,6 +444,7 @@ void MainWindow::closeEvent(QCloseEvent *event) // settings->getConfig().setValue("MainWindowGeometry", saveGeometry()); // settings->getConfig().setValue("MainWindowState", saveState()); QMainWindow::closeEvent(event); + QApplication::exit(); } /* void MainWindow::on_instanceView_customContextMenuRequested(const QPoint &pos) @@ -630,11 +642,18 @@ void MainWindow::launchInstance(BaseInstance *instance, LoginResponse response) this->hide(); } + console = new ConsoleWindow(proc); - console->show(); + connect(proc, SIGNAL(log(QString, MessageLevel::Enum)), console, SLOT(write(QString, MessageLevel::Enum))); - connect(proc, SIGNAL(ended()), this, SLOT(instanceEnded())); + connect(proc, SIGNAL(ended(BaseInstance*)), this, SLOT(instanceEnded(BaseInstance*))); + + if (instance->settings().get("ShowConsole").toBool()) + { + console->show(); + } + proc->setLogin(response.username, response.session_id); proc->launch(); } @@ -747,8 +766,7 @@ void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex & m_selectedInstance->menuActionEnabled("actionEditInstMods")); ui->actionChangeInstMCVersion->setEnabled( m_selectedInstance->menuActionEnabled("actionChangeInstMCVersion")); - statusBar()->clearMessage(); - statusBar()->showMessage(m_selectedInstance->getStatusbarDescription()); + m_statusLeft->setText(m_selectedInstance->getStatusbarDescription()); auto ico = MMC->icons()->getIcon(iconKey); ui->actionChangeInstIcon->setIcon(ico); } @@ -784,10 +802,15 @@ void MainWindow::on_actionEditInstNotes_triggered() } } -void MainWindow::instanceEnded() +void MainWindow::instanceEnded(BaseInstance *instance) { this->show(); ui->actionLaunchInstance->setEnabled(m_selectedInstance); + + if (instance->settings().get("AutoCloseConsole").toBool()) + { + console->close(); + } } void MainWindow::checkSetDefaultJava() @@ -822,18 +845,48 @@ void MainWindow::checkSetDefaultJava() vselect.setResizeOn(2); vselect.exec(); - if (!vselect.selectedVersion()) + if (vselect.selectedVersion()) + java = std::dynamic_pointer_cast<JavaVersion>(vselect.selectedVersion()); + else { QMessageBox::warning(this, tr("Invalid version selected"), tr("You didn't select a valid Java version, so MultiMC will " "select the default. " "You can change this in the settings dialog.")); - JavaUtils ju; java = ju.GetDefaultJava(); } - - java = std::dynamic_pointer_cast<JavaVersion>(vselect.selectedVersion()); - MMC->settings()->set("JavaPath", java->path); + if(java) + MMC->settings()->set("JavaPath", java->path); + else + MMC->settings()->set("JavaPath", QString("java")); } } + +void MainWindow::assetsIndexStarted() +{ + m_statusRight->setText(tr("Checking assets...")); +} + +void MainWindow::assetsFilesStarted() +{ + m_statusRight->setText(tr("Downloading assets...")); +} + +void MainWindow::assetsFilesProgress(int succeeded, int failed, int total) +{ + QString status = tr("Downloading assets: %1 / %2").arg(succeeded + failed).arg(total); + if(failed > 0) status += tr(" (%1 failed)").arg(failed); + status += tr("..."); + m_statusRight->setText(status); +} + +void MainWindow::assetsFailed() +{ + m_statusRight->setText(tr("Failed to update assets.")); +} + +void MainWindow::assetsFinished() +{ + m_statusRight->setText(tr("Assets up to date.")); +} diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 4490d474..6715acbb 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -112,10 +112,16 @@ private slots: void on_actionChangeInstLWJGLVersion_triggered(); - void instanceEnded(); + void instanceEnded(BaseInstance *instance); void on_actionInstanceSettings_triggered(); + void assetsIndexStarted(); + void assetsFilesStarted(); + void assetsFilesProgress(int, int, int); + void assetsFailed(); + void assetsFinished(); + public slots: void instanceActivated(QModelIndex); @@ -150,6 +156,9 @@ private: LoginResponse m_activeLogin; Task *m_versionLoadTask; + + QLabel *m_statusLeft; + QLabel *m_statusRight; }; #endif // MAINWINDOW_H |