add button for opening mod folder
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
#include "launcherbackend.h"
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QStandardPaths>
|
||||
#include <QUrl>
|
||||
#include <algorithm>
|
||||
|
||||
LauncherBackend::LauncherBackend(QObject *parent)
|
||||
@@ -117,6 +119,26 @@ void LauncherBackend::launchGame(int profileIndex, int versionIndex)
|
||||
emit launched(profile.name, version.name, version.serverUrl);
|
||||
}
|
||||
|
||||
QString LauncherBackend::minecraftDir() const
|
||||
{
|
||||
#if defined(Q_OS_WIN)
|
||||
return QDir::homePath() + "/AppData/Roaming/.minecraft";
|
||||
#elif defined(Q_OS_MACOS)
|
||||
return QDir::homePath() + "/Library/Application Support/minecraft";
|
||||
#else // Linux и прочие Unix-системы
|
||||
return QDir::homePath() + "/.minecraft";
|
||||
#endif
|
||||
}
|
||||
|
||||
void LauncherBackend::openMinecraftFolder()
|
||||
{
|
||||
const QString modsDir = minecraftDir() + "/mods";
|
||||
QDir().mkpath(modsDir);
|
||||
|
||||
if (!QDesktopServices::openUrl(QUrl::fromLocalFile(modsDir)))
|
||||
emit launchError("Не удалось открыть папку с модами");
|
||||
}
|
||||
|
||||
void LauncherBackend::loadData()
|
||||
{
|
||||
auto loadFile = [](const QString &path, auto handler) {
|
||||
|
||||
Reference in New Issue
Block a user