7 Commits
beta ... master

Author SHA1 Message Date
38d9805150 revert d760bc2f83
revert Загрузить файлы в «Ui-TEMP»
2025-11-04 15:48:24 +00:00
d760bc2f83 Загрузить файлы в «Ui-TEMP» 2025-11-04 15:47:41 +00:00
0ebf7e07a7 Обновить README.md 2025-09-04 12:41:52 +00:00
52ef710cd7 Удалить main.cpp 2025-09-01 08:15:11 +00:00
4b2026e96b Удалить LauncherWindow.h 2025-09-01 08:15:06 +00:00
4c0c566ff9 Удалить LauncherWindow.cpp 2025-09-01 08:15:01 +00:00
6cfadfc4b6 Удалить CppProperties.json 2025-09-01 08:14:34 +00:00
5 changed files with 2 additions and 183 deletions

View File

@@ -1,21 +0,0 @@
{
"configurations": [
{
"inheritEnvironments": [
"msvc_x86"
],
"name": "x86-Debug",
"includePath": [
"${env.INCLUDE}",
"${workspaceRoot}\\**"
],
"defines": [
"WIN32",
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"intelliSenseMode": "windows-msvc-x86"
}
]
}

View File

@@ -1,114 +0,0 @@
#include "LauncherWindow.h"
#include <QVBoxLayout>
#include <QDir>
#include <QStandardPaths>
#include <QDesktopServices>
#include <QMessageBox>
#include <QDebug>
#include <QFile>
LauncherWindow::LauncherWindow(QWidget *parent)
: QMainWindow(parent)
{
setupUI();
networkManager = new QNetworkAccessManager(this);
connect(networkManager, &QNetworkAccessManager::finished, this, &LauncherWindow::onDownloadFinished);
}
LauncherWindow::~LauncherWindow()
{
}
void LauncherWindow::setupUI()
{
QWidget *centralWidget = new QWidget(this);
setCentralWidget(centralWidget);
QVBoxLayout *layout = new QVBoxLayout(centralWidget);
usernameLineEdit = new QLineEdit(this);
usernameLineEdit->setPlaceholderText("Введите ваш никнейм");
layout->addWidget(usernameLineEdit);
launchButton = new QPushButton("Запустить Minecraft", this);
connect(launchButton, &QPushButton::clicked, this, &LauncherWindow::launchMinecraft);
layout->addWidget(launchButton);
modsFolderButton = new QPushButton("Открыть папку с модами", this);
connect(modsFolderButton, &QPushButton::clicked, this, &LauncherWindow::openModsFolder);
layout->addWidget(modsFolderButton);
downloadModsButton = new QPushButton("Загрузить моды с GitHub", this);
connect(downloadModsButton, &QPushButton::clicked, this, &LauncherWindow::downloadMods);
layout->addWidget(downloadModsButton);
setWindowTitle("Minecraft Launcher");
resize(300, 200);
}
QString LauncherWindow::getMinecraftPath()
{
#ifdef Q_OS_WIN
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/.minecraft";
#elif defined(Q_OS_MAC)
return QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/Library/Application Support/minecraft";
#else
return QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + "/.minecraft";
#endif
}
void LauncherWindow::launchMinecraft()
{
QString username = usernameLineEdit->text();
if (username.isEmpty()) {
QMessageBox::warning(this, "Ошибка", "Пожалуйста, введите никнейм.");
return;
}
// Это упрощенная команда запуска. Для современных версий Minecraft
// может потребоваться более сложная команда с указанием версии,
// аутентификацией и путями к библиотекам.
// Здесь мы используем гипотетическую команду для демонстрации.
QString command = "java -jar \"" + getMinecraftPath() + "/versions/1.19.2/1.19.2.jar\" --username " + username;
QProcess *process = new QProcess(this);
process->startDetached(command);
}
void LauncherWindow::openModsFolder()
{
QString modsPath = getMinecraftPath() + "/mods";
QDir modsDir(modsPath);
if (!modsDir.exists()) {
modsDir.mkpath(".");
}
QDesktopServices::openUrl(QUrl::fromLocalFile(modsPath));
}
void LauncherWindow::downloadMods()
{
// URL для загрузки ZIP-архива с модами из репозитория GitHub
// Замените на URL вашего репозитория
QUrl url("https://github.com/user/repo/archive/refs/heads/main.zip");
QNetworkRequest request(url);
networkManager->get(request);
}
void LauncherWindow::onDownloadFinished(QNetworkReply *reply)
{
if (reply->error()) {
QMessageBox::critical(this, "Ошибка загрузки", "Не удалось загрузить моды: " + reply->errorString());
return;
}
QFile *file = new QFile(getMinecraftPath() + "/mods/mods.zip");
if (file->open(QIODevice::WriteOnly)) {
file->write(reply->readAll());
file->close();
QMessageBox::information(this, "Загрузка завершена", "Моды успешно загружены в папку mods. Распакуйте архив.");
} else {
QMessageBox::critical(this, "Ошибка", "Не удалось сохранить архив с модами.");
}
delete file;
reply->deleteLater();
}

View File

@@ -1,37 +0,0 @@
#ifndef LAUNCHERWINDOW_H
#define LAUNCHERWINDOW_H
#include <QMainWindow>
#include <QPushButton>
#include <QLineEdit>
#include <QProcess>
#include <QNetworkAccessManager>
#include <QNetworkReply>
class LauncherWindow : public QMainWindow
{
Q_OBJECT
public:
LauncherWindow(QWidget *parent = nullptr);
~LauncherWindow();
private slots:
void launchMinecraft();
void openModsFolder();
void downloadMods();
void onDownloadFinished(QNetworkReply *reply);
private:
void setupUI();
QString getMinecraftPath();
QPushButton *launchButton;
QPushButton *modsFolderButton;
QPushButton *downloadModsButton;
QLineEdit *usernameLineEdit;
QNetworkAccessManager *networkManager;
};
#endif // LAUNCHERWINDOW_H

View File

@@ -1,3 +1,4 @@
# minecraft-launcher
Первая итерация самописного лаунчера для запуска сборок Minecraft

View File

@@ -1,10 +0,0 @@
#include "LauncherWindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
LauncherWindow w;
w.show();
return a.exec();
}