Improvements from linux side. Built standalone linux executable and included in source
This commit is contained in:
parent
429e93d9dc
commit
ca327be658
BIN
linux_installer.zip
Normal file
BIN
linux_installer.zip
Normal file
Binary file not shown.
@ -31,18 +31,18 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
delete net;
|
||||
delete reply;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
// Kick off the installation
|
||||
void MainWindow::on_install_update_button_clicked()
|
||||
{
|
||||
if (ConfirmationPopup()) {
|
||||
QNetworkRequest request(downloadUrl);
|
||||
reply = net->get(request);
|
||||
|
||||
// connect(reply, SIGNAL(&QNetworkReply::errorOccurred), this, SLOT(Error(QNetworkReply::NetworkError)));
|
||||
connect(reply, &QNetworkReply::errorOccurred, this, [this](QNetworkReply::NetworkError) {
|
||||
reply->deleteLater();
|
||||
QMessageBox::warning(nullptr, "Error", reply->errorString());
|
||||
@ -53,11 +53,13 @@ void MainWindow::on_install_update_button_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
// Callback from network manager on download. Update the progress bar as we download
|
||||
void MainWindow::UpdateProgress(qint64 read, qint64 total) {
|
||||
ui->mf_progress_bar->setMaximum(total);
|
||||
ui->mf_progress_bar->setValue(read);
|
||||
}
|
||||
|
||||
// This is a callback to when the download is completed by the network manager
|
||||
void MainWindow::FinishedDownloading() {
|
||||
QByteArray data = reply->readAll();
|
||||
|
||||
@ -86,11 +88,13 @@ void MainWindow::FinishedDownloading() {
|
||||
}
|
||||
}
|
||||
|
||||
// Build the unzip command depending on the users operating system
|
||||
std::string MainWindow::BuildUnzipCmd() {
|
||||
std::stringstream ss;
|
||||
#ifdef WIN64
|
||||
ss << "tar -xf " << downloadLocation.toStdString() << " -C " << modsDir.toStdString();
|
||||
#elif __unix__
|
||||
qDebug() << "DL Loc: " << downloadLocation << " modsDir: " << modsDir;
|
||||
ss << "unzip " << downloadLocation.toStdString() << " -d " << modsDir.toStdString();
|
||||
#endif
|
||||
return ss.str();
|
||||
@ -134,11 +138,13 @@ void MainWindow::Install() {
|
||||
PostInstallMode();
|
||||
}
|
||||
|
||||
// Callback for downloading
|
||||
void MainWindow::Error(QNetworkReply::NetworkError code) {
|
||||
reply->deleteLater();
|
||||
QMessageBox::warning(nullptr, "Error", reply->errorString());
|
||||
}
|
||||
|
||||
// Setup the window to be ready to update/install the mods folder
|
||||
void MainWindow::PreInstallMode() {
|
||||
ui->mf_progress_bar->setEnabled(false);
|
||||
ui->install_update_button->setText("Update / Install");
|
||||
@ -147,6 +153,7 @@ void MainWindow::PreInstallMode() {
|
||||
ui->close_launcher->setVisible(false);
|
||||
}
|
||||
|
||||
// Set window variables after installation and unzipping
|
||||
void MainWindow::PostInstallMode() {
|
||||
ui->mf_progress_bar->setEnabled(false);
|
||||
ui->install_update_button->setEnabled(false);
|
||||
@ -155,19 +162,22 @@ void MainWindow::PostInstallMode() {
|
||||
ui->close_launcher->setVisible(true);
|
||||
}
|
||||
|
||||
// Make sure the user is sure they are OK with the current configuration
|
||||
bool MainWindow::ConfirmationPopup() {
|
||||
// This is the preinstall pop up box
|
||||
QString tInstallFabric = "YOU MUST HAVE FABRIC INSTALLED PRIOR TO USING THIS INSTALLER";
|
||||
QString tempInstallPath = "Install to: " + modsDir;
|
||||
QString tempDlSrvr = "Grab mods.zip from: " + downloadUrl.toString();
|
||||
QString formatted = tempInstallPath.append("\n").append(tempDlSrvr);
|
||||
QString deleteAll = "This installer will DELETE YOUR EXISTING MODS DIRECTORY. Back it up if you care about it beforehand!";
|
||||
QString formatted = tInstallFabric.append(tempInstallPath).append("\n").append("\n").append(tempDlSrvr).append("\n").append(deleteAll);
|
||||
QMessageBox::StandardButton reply = QMessageBox::question(nullptr, "Confirm install options...", formatted);
|
||||
|
||||
return reply == QMessageBox::Yes;
|
||||
}
|
||||
|
||||
// This handles setting data prior to the install period dependent on the users operating system.
|
||||
void MainWindow::UpdateOSAgnosticInformation() {
|
||||
#ifdef _WIN64
|
||||
isLinux = false;
|
||||
char* appDataLoc = std::getenv("APPDATA");
|
||||
if (appDataLoc) {
|
||||
std::filesystem::path execPath(appDataLoc);
|
||||
@ -179,9 +189,9 @@ void MainWindow::UpdateOSAgnosticInformation() {
|
||||
QMessageBox::warning(nullptr, "Warning", "Unable to resolve APPDATA environment variable. You must manually set the .minecraft folder location");
|
||||
}
|
||||
#elif __unix__
|
||||
isLinux = true;
|
||||
downloadLocation = getenv("HOME");
|
||||
modsDir = downloadLocation + "/.minecraft/"; // Default value
|
||||
downloadLocation.append("/mods.zip");
|
||||
#endif
|
||||
|
||||
// Update the UI to reflect the default values correctly
|
||||
@ -189,18 +199,14 @@ void MainWindow::UpdateOSAgnosticInformation() {
|
||||
ui->mcInstallDir->setText(modsDir);
|
||||
}
|
||||
|
||||
|
||||
// This just closes the application but DOES call the destructor.
|
||||
// It technically segfaults on the way out for some odd reason; but the pointers are cleaned up. Who knows!
|
||||
void MainWindow::on_close_launcher_clicked()
|
||||
{
|
||||
delete reply;
|
||||
delete net;
|
||||
QApplication::quit();
|
||||
}
|
||||
|
||||
// unused
|
||||
void MainWindow::on_changeInstallPathButton_triggered(QAction *arg1){}
|
||||
|
||||
|
||||
// This is called if the users default .minecraft path cannot be found (by a user pressing the button of course)
|
||||
void MainWindow::on_changeInstallPathButton_clicked()
|
||||
{
|
||||
QString directory = QFileDialog::getExistingDirectory(this, tr("Find Files"), QDir::currentPath());
|
||||
|
@ -35,8 +35,6 @@ private slots:
|
||||
|
||||
void on_close_launcher_clicked();
|
||||
|
||||
void on_changeInstallPathButton_triggered(QAction *arg1);
|
||||
|
||||
void on_changeInstallPathButton_clicked();
|
||||
|
||||
void on_sf_dl_server_textChanged();
|
||||
@ -48,7 +46,5 @@ private:
|
||||
QString modsDir = "Set .minecraft path here...";
|
||||
QString downloadLocation;
|
||||
QNetworkReply* reply = nullptr;
|
||||
|
||||
bool isLinux = true;
|
||||
};
|
||||
#endif // MAINWINDOW_H
|
||||
|
Loading…
Reference in New Issue
Block a user