Compare commits

...

17 Commits

6 changed files with 0 additions and 245 deletions

60
.gitignore vendored
View File

@@ -1,60 +0,0 @@
# ---> C++
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
# ---> Java
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

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 +0,0 @@
# 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();
}