diff options
Diffstat (limited to 'launcher/minecraft')
-rw-r--r-- | launcher/minecraft/MinecraftInstance.cpp | 9 | ||||
-rw-r--r-- | launcher/minecraft/World.cpp | 23 | ||||
-rw-r--r-- | launcher/minecraft/World.h | 5 | ||||
-rw-r--r-- | launcher/minecraft/WorldList.cpp | 18 | ||||
-rw-r--r-- | launcher/minecraft/WorldList.h | 4 | ||||
-rw-r--r-- | launcher/minecraft/launch/LauncherPartLaunch.cpp | 1 |
6 files changed, 57 insertions, 3 deletions
diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 7c289300..fd933df7 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -34,6 +34,7 @@ */ #include "MinecraftInstance.h" +#include "BuildConfig.h" #include "minecraft/launch/CreateGameFolders.h" #include "minecraft/launch/ExtractNatives.h" #include "minecraft/launch/PrintInstanceInfo.h" @@ -55,6 +56,7 @@ #include "launch/steps/PreLaunchCommand.h" #include "launch/steps/TextPrint.h" #include "launch/steps/CheckJava.h" +#include "launch/steps/QuitAfterGameStop.h" #include "minecraft/launch/LauncherPartLaunch.h" #include "minecraft/launch/DirectJavaLaunch.h" @@ -470,7 +472,7 @@ QStringList MinecraftInstance::processMinecraftArgs( } // blatant self-promotion. - token_mapping["profile_name"] = token_mapping["version_name"] = "PolyMC"; + token_mapping["profile_name"] = token_mapping["version_name"] = BuildConfig.LAUNCHER_NAME; token_mapping["version_type"] = profile->getMinecraftVersionType(); @@ -971,6 +973,11 @@ shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPt { process->setCensorFilter(createCensorFilterFromSession(session)); } + if(APPLICATION->settings()->get("QuitAfterGameStop").toBool()) + { + auto step = new QuitAfterGameStop(pptr); + process->appendStep(step); + } m_launchProcess = process; emit launchTaskChanged(m_launchProcess); return m_launchProcess; diff --git a/launcher/minecraft/World.cpp b/launcher/minecraft/World.cpp index 2937c116..dc756e06 100644 --- a/launcher/minecraft/World.cpp +++ b/launcher/minecraft/World.cpp @@ -17,6 +17,7 @@ #include <QString> #include <QDebug> #include <QSaveFile> +#include <QDirIterator> #include "World.h" #include "GZip.h" @@ -187,6 +188,26 @@ bool putLevelDatDataToFS(const QFileInfo &file, QByteArray & data) return f.commit(); } +int64_t calculateWorldSize(const QFileInfo &file) +{ + if (file.isFile() && file.suffix() == "zip") + { + return file.size(); + } + else if(file.isDir()) + { + QDirIterator it(file.absoluteFilePath(), QDir::Files, QDirIterator::Subdirectories); + int64_t total = 0; + while (it.hasNext()) + { + total += it.fileInfo().size(); + it.next(); + } + return total; + } + return -1; +} + World::World(const QFileInfo &file) { repath(file); @@ -196,6 +217,7 @@ void World::repath(const QFileInfo &file) { m_containerFile = file; m_folderName = file.fileName(); + m_size = calculateWorldSize(file); if(file.isFile() && file.suffix() == "zip") { m_iconFile = QString(); @@ -482,6 +504,7 @@ void World::loadFromLevelDat(QByteArray data) if(randomSeed) { qDebug() << "Seed:" << *randomSeed; } + qDebug() << "Size:" << m_size; qDebug() << "GameType:" << m_gameType.toLogString(); } diff --git a/launcher/minecraft/World.h b/launcher/minecraft/World.h index 35e32788..0f587620 100644 --- a/launcher/minecraft/World.h +++ b/launcher/minecraft/World.h @@ -52,6 +52,10 @@ public: { return m_iconFile; } + int64_t bytes() const + { + return m_size; + } QDateTime lastPlayed() const { return m_lastPlayed; @@ -105,6 +109,7 @@ protected: QString m_iconFile; QDateTime levelDatTime; QDateTime m_lastPlayed; + int64_t m_size; int64_t m_randomSeed = 0; GameType m_gameType; bool is_valid = false; diff --git a/launcher/minecraft/WorldList.cpp b/launcher/minecraft/WorldList.cpp index dcdbc321..344bea63 100644 --- a/launcher/minecraft/WorldList.cpp +++ b/launcher/minecraft/WorldList.cpp @@ -14,6 +14,8 @@ */ #include "WorldList.h" + +#include "Application.h" #include <FileSystem.h> #include <QMimeData> #include <QUrl> @@ -150,7 +152,7 @@ bool WorldList::resetIcon(int row) int WorldList::columnCount(const QModelIndex &parent) const { - return 3; + return 4; } QVariant WorldList::data(const QModelIndex &index, int role) const @@ -164,6 +166,8 @@ QVariant WorldList::data(const QModelIndex &index, int role) const if (row < 0 || row >= worlds.size()) return QVariant(); + QLocale locale; + auto & world = worlds[row]; switch (role) { @@ -179,6 +183,9 @@ QVariant WorldList::data(const QModelIndex &index, int role) const case LastPlayedColumn: return world.lastPlayed(); + case SizeColumn: + return locale.formattedDataSize(world.bytes()); + default: return QVariant(); } @@ -207,6 +214,10 @@ QVariant WorldList::data(const QModelIndex &index, int role) const { return world.lastPlayed(); } + case SizeRole: + { + return locale.formattedDataSize(world.bytes()); + } case IconFileRole: { return world.iconFile(); @@ -229,6 +240,9 @@ QVariant WorldList::headerData(int section, Qt::Orientation orientation, int rol return tr("Game Mode"); case LastPlayedColumn: return tr("Last Played"); + case SizeColumn: + //: World size on disk + return tr("Size"); default: return QVariant(); } @@ -242,6 +256,8 @@ QVariant WorldList::headerData(int section, Qt::Orientation orientation, int rol return tr("Game mode of the world."); case LastPlayedColumn: return tr("Date and time the world was last played."); + case SizeColumn: + return tr("Size of the world on disk."); default: return QVariant(); } diff --git a/launcher/minecraft/WorldList.h b/launcher/minecraft/WorldList.h index 8e238ee3..5138e583 100644 --- a/launcher/minecraft/WorldList.h +++ b/launcher/minecraft/WorldList.h @@ -32,7 +32,8 @@ public: { NameColumn, GameModeColumn, - LastPlayedColumn + LastPlayedColumn, + SizeColumn }; enum Roles @@ -43,6 +44,7 @@ public: NameRole, GameModeRole, LastPlayedRole, + SizeRole, IconFileRole }; diff --git a/launcher/minecraft/launch/LauncherPartLaunch.cpp b/launcher/minecraft/launch/LauncherPartLaunch.cpp index d15d7e9d..173f29b5 100644 --- a/launcher/minecraft/launch/LauncherPartLaunch.cpp +++ b/launcher/minecraft/launch/LauncherPartLaunch.cpp @@ -170,6 +170,7 @@ void LauncherPartLaunch::on_state(LoggedProcess::State state) { if (APPLICATION->settings()->get("CloseAfterLaunch").toBool()) APPLICATION->showMainWindow(); + m_parent->setPid(-1); // if the exit code wasn't 0, report this as a crash auto exitCode = m_process.exitCode(); |