modules update
This commit is contained in:
parent
de8fe18ed2
commit
6d62b85c10
@ -2,7 +2,7 @@ qt_add_executable(PunkLauncher
|
|||||||
main.cpp
|
main.cpp
|
||||||
ui/mainwindow.cpp
|
ui/mainwindow.cpp
|
||||||
launcher/launcher.cpp
|
launcher/launcher.cpp
|
||||||
launcher/forge1.12.2/getArgs.cpp
|
launcher/profile_handler/forge1_12_2.cpp
|
||||||
backend/backend.cpp
|
backend/backend.cpp
|
||||||
settings/settings.cpp
|
settings/settings.cpp
|
||||||
../resources/resources.qrc
|
../resources/resources.qrc
|
||||||
|
@ -7,45 +7,47 @@
|
|||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
#include <qjsonobject.h>
|
||||||
|
|
||||||
#include "forge1.12.2/getArgs.h"
|
#include "profile_handler/forge1_12_2.h"
|
||||||
|
#include "../ui/mainwindow.h"
|
||||||
|
#include "../../resources/ui_mainwindow.h"
|
||||||
|
|
||||||
|
|
||||||
Launcher::Launcher(QObject *mainwindow) : QObject(mainwindow), process(new QProcess(this)), mainwindow(mainwindow), get_args(new getArgs()) {
|
Launcher::Launcher(QObject *mainwindow) : QObject(mainwindow), process(new QProcess(this)), mainwindow(mainwindow), get_args(new forge1_12_2()) {
|
||||||
// Подключение сигналов для отладки
|
|
||||||
/*
|
|
||||||
connect(process, &QProcess::readyReadStandardOutput, [this]() {
|
|
||||||
qDebug() << "Standard Output: " << process->readAllStandardOutput();
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(process, &QProcess::readyReadStandardError, [this]() {
|
|
||||||
qDebug() << "Standard Error: " << process->readAllStandardError();
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
|
||||||
[this](int exitCode, QProcess::ExitStatus status) {
|
|
||||||
qDebug() << "Process finished with exit code:" << exitCode
|
|
||||||
<< "and status:" << status;
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Launcher::~Launcher() {
|
Launcher::~Launcher() {
|
||||||
delete process;
|
delete process;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Launcher::startProcess(
|
|
||||||
QString &workingDir,
|
|
||||||
QString &executablePath,
|
|
||||||
QString &RAM,
|
|
||||||
QString &username,
|
|
||||||
QString &uuid,
|
|
||||||
QString &access_token,
|
|
||||||
QString garbarge_collector) {
|
|
||||||
QStringList arguments = get_args->getCrossPlatformArgs(RAM, username, uuid, access_token, garbarge_collector);
|
|
||||||
|
|
||||||
process->setWorkingDirectory(workingDir);
|
void Launcher::startProcess(QString &username, QString &uuid, QString &access_token) {
|
||||||
process->start(executablePath, arguments);
|
// Подготовка параметров запуска
|
||||||
|
MainWindow *mainWindow = qobject_cast<MainWindow *>(mainwindow);
|
||||||
|
QString selected_profile = mainWindow->ui->selected_profile->currentText();
|
||||||
|
QDir exe_dir(QCoreApplication::applicationDirPath());
|
||||||
|
client_dir = exe_dir.absolutePath() + "/" + selected_profile;
|
||||||
|
json_settings = mainWindow->settings->loadFromJson(selected_profile);
|
||||||
|
java_path = json_settings["java_path"].toString();
|
||||||
|
RAM = json_settings["RAM"].toString();
|
||||||
|
garbarge_collector = json_settings["garbarge_collector"].toString();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Выбор профиля
|
||||||
|
//
|
||||||
|
if (selected_profile == "CyberExtrieme") {
|
||||||
|
arguments = get_args->getCrossPlatformArgs(RAM, username, uuid, access_token, garbarge_collector);
|
||||||
|
java_path = java_path.isEmpty() ?
|
||||||
|
exe_dir.absolutePath() + "/java/zulu8.84.0.15-ca-jre8.0.442-linux_x64/bin/java" : java_path;
|
||||||
|
RAM = RAM.isEmpty() ? "4096M" : RAM;
|
||||||
|
garbarge_collector = garbarge_collector.isEmpty() ? "default_collector" : garbarge_collector;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Запуск процесса
|
||||||
|
process->setWorkingDirectory(client_dir);
|
||||||
|
process->start(java_path, arguments);
|
||||||
|
|
||||||
if (!process->waitForStarted()) {
|
if (!process->waitForStarted()) {
|
||||||
qDebug() << "Failed to start process";
|
qDebug() << "Failed to start process";
|
||||||
@ -53,17 +55,11 @@ void Launcher::startProcess(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *mainwindowWidget = qobject_cast<QWidget*>(mainwindow);
|
|
||||||
|
|
||||||
// Скрытие лаунчера при запуске
|
// Скрытие лаунчера
|
||||||
connect(process,
|
connect(process,
|
||||||
QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
||||||
[mainwindowWidget](int, QProcess::ExitStatus) { mainwindowWidget->show(); });
|
[mainWindow](int, QProcess::ExitStatus) { mainWindow->show(); });
|
||||||
|
mainWindow->hide();
|
||||||
if (mainwindowWidget) {
|
|
||||||
mainwindowWidget->hide();
|
|
||||||
} else {
|
|
||||||
qDebug() << "Parent object is not a QWidget.";
|
|
||||||
}
|
|
||||||
qDebug() << "Process started successfully";
|
qDebug() << "Process started successfully";
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,9 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
#include "forge1.12.2/getArgs.h"
|
#include "profile_handler/forge1_12_2.h"
|
||||||
|
|
||||||
class Launcher : public QObject {
|
class Launcher : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -15,20 +16,20 @@ class Launcher : public QObject {
|
|||||||
public:
|
public:
|
||||||
explicit Launcher(QObject *mainwindow = nullptr);
|
explicit Launcher(QObject *mainwindow = nullptr);
|
||||||
~Launcher();
|
~Launcher();
|
||||||
|
void startProcess(QString &username, QString &uuid, QString &access_token);
|
||||||
void startProcess(
|
|
||||||
QString &workingDir,
|
|
||||||
QString &executablePath,
|
|
||||||
QString &RAM,
|
|
||||||
QString &username,
|
|
||||||
QString &uuid,
|
|
||||||
QString &access_token,
|
|
||||||
QString garbarge_collector);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QProcess *process;
|
QProcess *process;
|
||||||
QObject *mainwindow;
|
QObject *mainwindow;
|
||||||
getArgs *get_args;
|
forge1_12_2 *get_args;
|
||||||
|
|
||||||
|
// Переменные для запуска клиента
|
||||||
|
QString client_dir;
|
||||||
|
QString RAM;
|
||||||
|
QString java_path;
|
||||||
|
QString garbarge_collector;
|
||||||
|
QJsonObject json_settings;
|
||||||
|
QStringList arguments;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "getArgs.h"
|
#include "forge1_12_2.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
@ -9,13 +9,13 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
|
|
||||||
getArgs::getArgs() {
|
forge1_12_2::forge1_12_2() {
|
||||||
}
|
}
|
||||||
|
|
||||||
getArgs::~getArgs() {
|
forge1_12_2::~forge1_12_2() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList getArgs::getCrossPlatformArgs(QString &RAM, QString &username, QString &uuid, QString &access_token, QString &garbarge_collector) {
|
QStringList forge1_12_2::getCrossPlatformArgs(QString &RAM, QString &username, QString &uuid, QString &access_token, QString &garbarge_collector) {
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
arguments
|
arguments
|
||||||
<< "-Djava.library.path=../versions/1.12.2-forge-14.23.5.2860/natives"
|
<< "-Djava.library.path=../versions/1.12.2-forge-14.23.5.2860/natives"
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef GETARGS_H
|
#ifndef FORGE1_12_2_H
|
||||||
#define GETARGS_H
|
#define FORGE1_12_2_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
@ -8,12 +8,12 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
|
|
||||||
class getArgs : public QObject {
|
class forge1_12_2 : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit getArgs();
|
explicit forge1_12_2();
|
||||||
~getArgs();
|
~forge1_12_2();
|
||||||
|
|
||||||
QStringList getCrossPlatformArgs(QString &RAM, QString &username, QString &uuid, QString &access_token, QString &garbarge_collector);
|
QStringList getCrossPlatformArgs(QString &RAM, QString &username, QString &uuid, QString &access_token, QString &garbarge_collector);
|
||||||
|
|
@ -47,15 +47,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
|
||||||
connect(process, &QProcess::readyReadStandardOutput, this, [this]() {
|
|
||||||
qDebug() << "Standard Output: " << process->readAllStandardOutput();
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(process, &QProcess::readyReadStandardError, this, [this]() {
|
|
||||||
qDebug() << "Standard Error: " << process->readAllStandardError();
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -178,38 +169,5 @@ void MainWindow::on_settings_apply_btn_clicked() {
|
|||||||
|
|
||||||
|
|
||||||
void MainWindow::on_start_btn_clicked() {
|
void MainWindow::on_start_btn_clicked() {
|
||||||
// Обновление переменных запуска клиента
|
launcher->startProcess(this->username, this->uuid, this->access_token);
|
||||||
QString selected_profile = ui->selected_profile->currentText();
|
|
||||||
QDir exe_dir(QCoreApplication::applicationDirPath());
|
|
||||||
client_dir = exe_dir.absolutePath() + "/" + selected_profile;
|
|
||||||
|
|
||||||
|
|
||||||
json_settings = settings->loadFromJson(selected_profile);
|
|
||||||
java_path = json_settings["java_path"].toString();
|
|
||||||
RAM = json_settings["RAM"].toString();
|
|
||||||
garbarge_collector = json_settings["garbarge_collector"].toString();
|
|
||||||
|
|
||||||
// Значения по умолчанию
|
|
||||||
if (selected_profile == "CyberExtrieme") {
|
|
||||||
java_path = java_path.isEmpty() ?
|
|
||||||
exe_dir.absolutePath() + "/java/zing24.12.0.0-6-jre8.0.432/bin/java" : java_path;
|
|
||||||
RAM = RAM.isEmpty() ?
|
|
||||||
"4096M" : RAM;
|
|
||||||
garbarge_collector = garbarge_collector.isEmpty() ?
|
|
||||||
"default_collector" : garbarge_collector;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Запуск клиента
|
|
||||||
launcher->startProcess(
|
|
||||||
this->client_dir,
|
|
||||||
this->java_path,
|
|
||||||
this->RAM,
|
|
||||||
this->username,
|
|
||||||
this->uuid,
|
|
||||||
this->access_token,
|
|
||||||
this->garbarge_collector
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,8 @@ class MainWindow : public QMainWindow {
|
|||||||
public:
|
public:
|
||||||
MainWindow(QWidget *parent = nullptr);
|
MainWindow(QWidget *parent = nullptr);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
Settings *settings;
|
||||||
|
Ui::MainWindow *ui;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent *event) override;
|
void mousePressEvent(QMouseEvent *event) override;
|
||||||
@ -40,23 +42,15 @@ private slots:
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
|
||||||
QProcess *process;
|
QProcess *process;
|
||||||
Launcher *launcher;
|
Launcher *launcher;
|
||||||
Backend *backend;
|
Backend *backend;
|
||||||
Settings *settings;
|
|
||||||
|
|
||||||
bool isDragging = false;
|
bool isDragging = false;
|
||||||
QPoint dragStartPosition;
|
QPoint dragStartPosition;
|
||||||
QString username;
|
QString username;
|
||||||
QString uuid;
|
QString uuid;
|
||||||
QString access_token;
|
QString access_token;
|
||||||
|
|
||||||
// Переменные для запуска клиента
|
|
||||||
QString client_dir;
|
|
||||||
QString RAM;
|
|
||||||
QString java_path;
|
|
||||||
QString garbarge_collector;
|
|
||||||
QJsonObject json_settings;
|
QJsonObject json_settings;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user