aboutsummaryrefslogtreecommitdiff
path: root/launcher
diff options
context:
space:
mode:
Diffstat (limited to 'launcher')
-rw-r--r--launcher/Application.cpp18
-rw-r--r--launcher/Application.h2
-rw-r--r--launcher/CMakeLists.txt16
-rw-r--r--launcher/FileSystem.cpp29
-rw-r--r--launcher/FileSystem.h1
-rw-r--r--launcher/InstanceCopyPrefs.cpp135
-rw-r--r--launcher/InstanceCopyPrefs.h41
-rw-r--r--launcher/InstanceCopyTask.cpp10
-rw-r--r--launcher/InstanceCopyTask.h16
-rw-r--r--launcher/JavaCommon.cpp2
-rw-r--r--launcher/MMCStrings.h8
-rw-r--r--launcher/StringUtils.cpp (renamed from launcher/MMCStrings.cpp)42
-rw-r--r--launcher/StringUtils.h32
-rw-r--r--launcher/java/JavaInstall.cpp7
-rw-r--r--launcher/java/JavaInstallList.cpp1
-rw-r--r--launcher/java/JavaVersion.cpp7
-rw-r--r--launcher/launch/LaunchTask.cpp1
-rw-r--r--launcher/main.cpp2
-rw-r--r--launcher/minecraft/MinecraftInstance.cpp1
-rw-r--r--launcher/minecraft/mod/tasks/LocalModUpdateTask.cpp2
-rw-r--r--launcher/modplatform/flame/FlameInstanceCreationTask.cpp54
-rw-r--r--launcher/modplatform/flame/FlameInstanceCreationTask.h3
-rw-r--r--launcher/modplatform/helpers/HashUtils.cpp61
-rw-r--r--launcher/modplatform/helpers/HashUtils.h15
-rw-r--r--launcher/modplatform/modpacksch/FTBPackInstallTask.cpp60
-rw-r--r--launcher/modplatform/modpacksch/FTBPackInstallTask.h3
-rw-r--r--launcher/modplatform/packwiz/Packwiz.cpp26
-rw-r--r--launcher/modplatform/packwiz/Packwiz.h4
-rw-r--r--launcher/resources/backgrounds/backgrounds.qrc4
-rw-r--r--launcher/resources/backgrounds/kitteh-spooky.png (renamed from launcher/resources/backgrounds/kitteh-ween.png)bin94677 -> 94677 bytes
-rw-r--r--launcher/resources/backgrounds/rory-flat-spooky.pngbin0 -> 66906 bytes
-rw-r--r--launcher/resources/backgrounds/rory-spooky.pngbin0 -> 95940 bytes
-rw-r--r--launcher/ui/MainWindow.cpp39
-rw-r--r--launcher/ui/MainWindow.h2
-rw-r--r--launcher/ui/dialogs/BlockedModsDialog.cpp178
-rw-r--r--launcher/ui/dialogs/BlockedModsDialog.h35
-rw-r--r--launcher/ui/dialogs/BlockedModsDialog.ui37
-rw-r--r--launcher/ui/dialogs/CopyInstanceDialog.cpp100
-rw-r--r--launcher/ui/dialogs/CopyInstanceDialog.h19
-rw-r--r--launcher/ui/dialogs/CopyInstanceDialog.ui121
-rw-r--r--launcher/ui/dialogs/ExportInstanceDialog.cpp9
-rw-r--r--launcher/ui/dialogs/ModDownloadDialog.cpp21
-rw-r--r--launcher/ui/dialogs/ModDownloadDialog.h28
-rw-r--r--launcher/ui/pages/instance/ExternalResourcesPage.ui6
-rw-r--r--launcher/ui/pages/instance/VersionPage.ui6
-rw-r--r--launcher/ui/pages/modplatform/ModPage.cpp91
-rw-r--r--launcher/ui/pages/modplatform/ModPage.h1
-rw-r--r--launcher/ui/pages/modplatform/ModPage.ui4
-rw-r--r--launcher/ui/pages/modplatform/atlauncher/AtlFilterModel.cpp5
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModPage.cpp23
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModPage.h5
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModel.cpp1
-rw-r--r--launcher/ui/pages/modplatform/ftb/FtbFilterModel.cpp5
-rw-r--r--launcher/ui/pages/modplatform/legacy_ftb/ListModel.cpp4
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthModPage.cpp2
55 files changed, 1101 insertions, 244 deletions
diff --git a/launcher/Application.cpp b/launcher/Application.cpp
index 579942f4..45cd9422 100644
--- a/launcher/Application.cpp
+++ b/launcher/Application.cpp
@@ -563,7 +563,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
// Memory
m_settings->registerSetting({"MinMemAlloc", "MinMemoryAlloc"}, 512);
- m_settings->registerSetting({"MaxMemAlloc", "MaxMemoryAlloc"}, 4096);
+ m_settings->registerSetting({"MaxMemAlloc", "MaxMemoryAlloc"}, suitableMaxMem());
m_settings->registerSetting("PermGen", 128);
// Java Settings
@@ -611,6 +611,8 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
// The cat
m_settings->registerSetting("TheCat", false);
+ m_settings->registerSetting("ToolbarsLocked", false);
+
m_settings->registerSetting("InstSortMode", "Name");
m_settings->registerSetting("SelectedInstance", QString());
@@ -1589,3 +1591,17 @@ QString Application::getUserAgentUncached()
return BuildConfig.USER_AGENT_UNCACHED;
}
+
+int Application::suitableMaxMem()
+{
+ float totalRAM = (float)Sys::getSystemRam() / (float)Sys::mebibyte;
+ int maxMemoryAlloc;
+
+ // If totalRAM < 6GB, use (totalRAM / 1.5), else 4GB
+ if (totalRAM < (4096 * 1.5))
+ maxMemoryAlloc = (int) (totalRAM / 1.5);
+ else
+ maxMemoryAlloc = 4096;
+
+ return maxMemoryAlloc;
+}
diff --git a/launcher/Application.h b/launcher/Application.h
index 78ab8fbd..4c2f62d4 100644
--- a/launcher/Application.h
+++ b/launcher/Application.h
@@ -200,6 +200,8 @@ public:
void ShowGlobalSettings(class QWidget * parent, QString open_page = QString());
+ int suitableMaxMem();
+
signals:
void updateAllowedChanged(bool status);
void globalSettingsAboutToOpen();
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt
index bc1f5d5e..8db93429 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -24,13 +24,15 @@ set(CORE_SOURCES
NullInstance.h
MMCZip.h
MMCZip.cpp
- MMCStrings.h
- MMCStrings.cpp
+ StringUtils.h
+ StringUtils.cpp
RuntimeContext.h
# Basic instance manipulation tasks (derived from InstanceTask)
InstanceCreationTask.h
InstanceCreationTask.cpp
+ InstanceCopyPrefs.h
+ InstanceCopyPrefs.cpp
InstanceCopyTask.h
InstanceCopyTask.cpp
InstanceImportTask.h
@@ -1064,7 +1066,7 @@ if(INSTALL_BUNDLE STREQUAL "full")
# Image formats
install(
DIRECTORY "${QT_PLUGINS_DIR}/imageformats"
- CONFIGURATIONS Debug RelWithDebInfo
+ CONFIGURATIONS Debug RelWithDebInfo ""
DESTINATION ${PLUGIN_DEST_DIR}
COMPONENT Runtime
REGEX "tga|tiff|mng" EXCLUDE
@@ -1082,7 +1084,7 @@ if(INSTALL_BUNDLE STREQUAL "full")
# Icon engines
install(
DIRECTORY "${QT_PLUGINS_DIR}/iconengines"
- CONFIGURATIONS Debug RelWithDebInfo
+ CONFIGURATIONS Debug RelWithDebInfo ""
DESTINATION ${PLUGIN_DEST_DIR}
COMPONENT Runtime
REGEX "fontawesome" EXCLUDE
@@ -1100,7 +1102,7 @@ if(INSTALL_BUNDLE STREQUAL "full")
# Platform plugins
install(
DIRECTORY "${QT_PLUGINS_DIR}/platforms"
- CONFIGURATIONS Debug RelWithDebInfo
+ CONFIGURATIONS Debug RelWithDebInfo ""
DESTINATION ${PLUGIN_DEST_DIR}
COMPONENT Runtime
REGEX "minimal|linuxfb|offscreen" EXCLUDE
@@ -1119,7 +1121,7 @@ if(INSTALL_BUNDLE STREQUAL "full")
if(EXISTS "${QT_PLUGINS_DIR}/styles")
install(
DIRECTORY "${QT_PLUGINS_DIR}/styles"
- CONFIGURATIONS Debug RelWithDebInfo
+ CONFIGURATIONS Debug RelWithDebInfo ""
DESTINATION ${PLUGIN_DEST_DIR}
COMPONENT Runtime
)
@@ -1137,7 +1139,7 @@ if(INSTALL_BUNDLE STREQUAL "full")
if(EXISTS "${QT_PLUGINS_DIR}/tls")
install(
DIRECTORY "${QT_PLUGINS_DIR}/tls"
- CONFIGURATIONS Debug RelWithDebInfo
+ CONFIGURATIONS Debug RelWithDebInfo ""
DESTINATION ${PLUGIN_DEST_DIR}
COMPONENT Runtime
)
diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp
index 4026d6c1..4a8f4bd3 100644
--- a/launcher/FileSystem.cpp
+++ b/launcher/FileSystem.cpp
@@ -44,7 +44,9 @@
#include <QStandardPaths>
#include <QTextStream>
#include <QUrl>
+
#include "DesktopServices.h"
+#include "StringUtils.h"
#if defined Q_OS_WIN32
#include <objbase.h>
@@ -79,22 +81,6 @@ namespace fs = std::filesystem;
namespace fs = ghc::filesystem;
#endif
-#if defined Q_OS_WIN32
-
-std::wstring toStdString(QString s)
-{
- return s.toStdWString();
-}
-
-#else
-
-std::string toStdString(QString s)
-{
- return s.toStdString();
-}
-
-#endif
-
namespace FS {
void ensureExists(const QDir& dir)
@@ -163,6 +149,9 @@ bool ensureFolderPathExists(QString foldernamepath)
return success;
}
+/// @brief Copies a directory and it's contents from src to dest
+/// @param offset subdirectory form src to copy to dest
+/// @return if there was an error during the filecopy
bool copy::operator()(const QString& offset)
{
using copy_opts = fs::copy_options;
@@ -191,7 +180,7 @@ bool copy::operator()(const QString& offset)
auto dst_path = PathCombine(dst, relative_dst_path);
ensureFilePathExists(dst_path);
- fs::copy(toStdString(src_path), toStdString(dst_path), opt, err);
+ fs::copy(StringUtils::toStdString(src_path), StringUtils::toStdString(dst_path), opt, err);
if (err) {
qWarning() << "Failed to copy files:" << QString::fromStdString(err.message());
qDebug() << "Source file:" << src_path;
@@ -213,7 +202,7 @@ bool copy::operator()(const QString& offset)
}
// If the root src is not a directory, the previous iterator won't run.
- if (!fs::is_directory(toStdString(src)))
+ if (!fs::is_directory(StringUtils::toStdString(src)))
copy_file(src, "");
return err.value() == 0;
@@ -223,7 +212,7 @@ bool deletePath(QString path)
{
std::error_code err;
- fs::remove_all(toStdString(path), err);
+ fs::remove_all(StringUtils::toStdString(path), err);
if (err) {
qWarning() << "Failed to remove files:" << QString::fromStdString(err.message());
@@ -414,7 +403,7 @@ bool overrideFolder(QString overwritten_path, QString override_path)
fs::copy_options opt = copy_opts::recursive | copy_opts::overwrite_existing;
// FIXME: hello traveller! Apparently std::copy does NOT overwrite existing files on GNU libstdc++ on Windows?
- fs::copy(toStdString(override_path), toStdString(overwritten_path), opt, err);
+ fs::copy(StringUtils::toStdString(override_path), StringUtils::toStdString(overwritten_path), opt, err);
if (err) {
qCritical() << QString("Failed to apply override from %1 to %2").arg(override_path, overwritten_path);
diff --git a/launcher/FileSystem.h b/launcher/FileSystem.h
index b46f3281..b7e175fd 100644
--- a/launcher/FileSystem.h
+++ b/launcher/FileSystem.h
@@ -75,6 +75,7 @@ bool ensureFilePathExists(QString filenamepath);
*/
bool ensureFolderPathExists(QString filenamepath);
+/// @brief Copies a directory and it's contents from src to dest
class copy {
public:
copy(const QString& src, const QString& dst)
diff --git a/launcher/InstanceCopyPrefs.cpp b/launcher/InstanceCopyPrefs.cpp
new file mode 100644
index 00000000..7b93a516
--- /dev/null
+++ b/launcher/InstanceCopyPrefs.cpp
@@ -0,0 +1,135 @@
+//
+// Created by marcelohdez on 10/22/22.
+//
+
+#include "InstanceCopyPrefs.h"
+
+bool InstanceCopyPrefs::allTrue() const
+{
+ return copySaves &&
+ keepPlaytime &&
+ copyGameOptions &&
+ copyResourcePacks &&
+ copyShaderPacks &&
+ copyServers &&
+ copyMods &&
+ copyScreenshots;
+}
+
+// Returns a single RegEx string of the selected folders/files to filter out (ex: ".minecraft/saves|.minecraft/server.dat")
+QString InstanceCopyPrefs::getSelectedFiltersAsRegex() const
+{
+ QStringList filters;
+
+ if(!copySaves)
+ filters << "saves";
+
+ if(!copyGameOptions)
+ filters << "options.txt";
+
+ if(!copyResourcePacks)
+ filters << "resourcepacks" << "texturepacks";
+
+ if(!copyShaderPacks)
+ filters << "shaderpacks";
+
+ if(!copyServers)
+ filters << "servers.dat" << "servers.dat_old" << "server-resource-packs";
+
+ if(!copyMods)
+ filters << "coremods" << "mods" << "config";
+
+ if(!copyScreenshots)
+ filters << "screenshots";
+
+ // If we have any filters to add, join them as a single regex string to return:
+ if (!filters.isEmpty()) {
+ const QString MC_ROOT = "[.]?minecraft/";
+ // Ensure first filter starts with root, then join other filters with OR regex before root (ex: ".minecraft/saves|.minecraft/mods"):
+ return MC_ROOT + filters.join("|" + MC_ROOT);
+ }
+
+ return {};
+}
+
+// ======= Getters =======
+bool InstanceCopyPrefs::isCopySavesEnabled() const
+{
+ return copySaves;
+}
+
+bool InstanceCopyPrefs::isKeepPlaytimeEnabled() const
+{
+ return keepPlaytime;
+}
+
+bool InstanceCopyPrefs::isCopyGameOptionsEnabled() const
+{
+ return copyGameOptions;
+}
+
+bool InstanceCopyPrefs::isCopyResourcePacksEnabled() const
+{
+ return copyResourcePacks;
+}
+
+bool InstanceCopyPrefs::isCopyShaderPacksEnabled() const
+{
+ return copyShaderPacks;
+}
+
+bool InstanceCopyPrefs::isCopyServersEnabled() const
+{
+ return copyServers;
+}
+
+bool InstanceCopyPrefs::isCopyModsEnabled() const
+{
+ return copyMods;
+}
+
+bool InstanceCopyPrefs::isCopyScreenshotsEnabled() const
+{
+ return copyScreenshots;
+}
+
+// ======= Setters =======
+void InstanceCopyPrefs::enableCopySaves(bool b)
+{
+ copySaves = b;
+}
+
+void InstanceCopyPrefs::enableKeepPlaytime(bool b)
+{
+ keepPlaytime = b;
+}
+
+void InstanceCopyPrefs::enableCopyGameOptions(bool b)
+{
+ copyGameOptions = b;
+}
+
+void InstanceCopyPrefs::enableCopyResourcePacks(bool b)
+{
+ copyResourcePacks = b;
+}
+
+void InstanceCopyPrefs::enableCopyShaderPacks(bool b)
+{
+ copyShaderPacks = b;
+}
+
+void InstanceCopyPrefs::enableCopyServers(bool b)
+{
+ copyServers = b;
+}
+
+void InstanceCopyPrefs::enableCopyMods(bool b)
+{
+ copyMods = b;
+}
+
+void InstanceCopyPrefs::enableCopyScreenshots(bool b)
+{
+ copyScreenshots = b;
+}
diff --git a/launcher/InstanceCopyPrefs.h b/launcher/InstanceCopyPrefs.h
new file mode 100644
index 00000000..6988b2df
--- /dev/null
+++ b/launcher/InstanceCopyPrefs.h
@@ -0,0 +1,41 @@
+//
+// Created by marcelohdez on 10/22/22.
+//
+
+#pragma once
+
+#include <QStringList>
+
+struct InstanceCopyPrefs {
+ public:
+ [[nodiscard]] bool allTrue() const;
+ [[nodiscard]] QString getSelectedFiltersAsRegex() const;
+ // Getters
+ [[nodiscard]] bool isCopySavesEnabled() const;
+ [[nodiscard]] bool isKeepPlaytimeEnabled() const;
+ [[nodiscard]] bool isCopyGameOptionsEnabled() const;
+ [[nodiscard]] bool isCopyResourcePacksEnabled() const;
+ [[nodiscard]] bool isCopyShaderPacksEnabled() const;
+ [[nodiscard]] bool isCopyServersEnabled() const;
+ [[nodiscard]] bool isCopyModsEnabled() const;
+ [[nodiscard]] bool isCopyScreenshotsEnabled() const;
+ // Setters
+ void enableCopySaves(bool b);
+ void enableKeepPlaytime(bool b);
+ void enableCopyGameOptions(bool b);
+ void enableCopyResourcePacks(bool b);
+ void enableCopyShaderPacks(bool b);
+ void enableCopyServers(bool b);
+ void enableCopyMods(bool b);
+ void enableCopyScreenshots(bool b);
+
+ protected: // data
+ bool copySaves = true;
+ bool keepPlaytime = true;
+ bool copyGameOptions = true;
+ bool copyResourcePacks = true;
+ bool copyShaderPacks = true;
+ bool copyServers = true;
+ bool copyMods = true;
+ bool copyScreenshots = true;
+};
diff --git a/launcher/InstanceCopyTask.cpp b/launcher/InstanceCopyTask.cpp
index b1e33884..a4ea947d 100644
--- a/launcher/InstanceCopyTask.cpp
+++ b/launcher/InstanceCopyTask.cpp
@@ -5,15 +5,17 @@
#include "pathmatcher/RegexpMatcher.h"
#include <QtConcurrentRun>
-InstanceCopyTask::InstanceCopyTask(InstancePtr origInstance, bool copySaves, bool keepPlaytime)
+InstanceCopyTask::InstanceCopyTask(InstancePtr origInstance, const InstanceCopyPrefs& prefs)
{
m_origInstance = origInstance;
- m_keepPlaytime = keepPlaytime;
+ m_keepPlaytime = prefs.isKeepPlaytimeEnabled();
- if(!copySaves)
+ QString filters = prefs.getSelectedFiltersAsRegex();
+ if (!filters.isEmpty())
{
+ // Set regex filter:
// FIXME: get this from the original instance type...
- auto matcherReal = new RegexpMatcher("[.]?minecraft/saves");
+ auto matcherReal = new RegexpMatcher(filters);
matcherReal->caseSensitive(false);
m_matcher.reset(matcherReal);
}
diff --git a/launcher/InstanceCopyTask.h b/launcher/InstanceCopyTask.h
index 82901732..1f29b854 100644
--- a/launcher/InstanceCopyTask.h
+++ b/launcher/InstanceCopyTask.h
@@ -1,20 +1,21 @@
#pragma once
-#include "tasks/Task.h"
-#include "net/NetJob.h"
-#include <QUrl>
#include <QFuture>
#include <QFutureWatcher>
-#include "settings/SettingsObject.h"
-#include "BaseVersion.h"
+#include <QUrl>
#include "BaseInstance.h"
+#include "BaseVersion.h"
+#include "InstanceCopyPrefs.h"
#include "InstanceTask.h"
+#include "net/NetJob.h"
+#include "settings/SettingsObject.h"
+#include "tasks/Task.h"
class InstanceCopyTask : public InstanceTask
{
Q_OBJECT
public:
- explicit InstanceCopyTask(InstancePtr origInstance, bool copySaves, bool keepPlaytime);
+ explicit InstanceCopyTask(InstancePtr origInstance, const InstanceCopyPrefs& prefs);
protected:
//! Entry point for tasks.
@@ -22,7 +23,8 @@ protected:
void copyFinished();
void copyAborted();
-private: /* data */
+private:
+ /* data */
InstancePtr m_origInstance;
QFuture<bool> m_copyFuture;
QFutureWatcher<bool> m_copyFutureWatcher;
diff --git a/launcher/JavaCommon.cpp b/launcher/JavaCommon.cpp
index aa4d1123..52cc868a 100644
--- a/launcher/JavaCommon.cpp
+++ b/launcher/JavaCommon.cpp
@@ -36,7 +36,7 @@
#include "JavaCommon.h"
#include "java/JavaUtils.h"
#include "ui/dialogs/CustomMessageBox.h"
-#include <MMCStrings.h>
+
#include <QRegularExpression>
bool JavaCommon::checkJVMArgs(QString jvmargs, QWidget *parent)
diff --git a/launcher/MMCStrings.h b/launcher/MMCStrings.h
deleted file mode 100644
index 48052a00..00000000
--- a/launcher/MMCStrings.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma once
-
-#include <QString>
-
-namespace Strings
-{
- int naturalCompare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs);
-}
diff --git a/launcher/MMCStrings.cpp b/launcher/StringUtils.cpp
index dc91c8d6..0f3c3669 100644
--- a/launcher/MMCStrings.cpp
+++ b/launcher/StringUtils.cpp
@@ -1,26 +1,28 @@
-#include "MMCStrings.h"
+#include "StringUtils.h"
+
+/// If you're wondering where these came from exactly, then know you're not the only one =D
/// TAKEN FROM Qt, because it doesn't expose it intelligently
-static inline QChar getNextChar(const QString &s, int location)
+static inline QChar getNextChar(const QString& s, int location)
{
return (location < s.length()) ? s.at(location) : QChar();
}
/// TAKEN FROM Qt, because it doesn't expose it intelligently
-int Strings::naturalCompare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs)
+int StringUtils::naturalCompare(const QString& s1, const QString& s2, Qt::CaseSensitivity cs)
{
- for (int l1 = 0, l2 = 0; l1 <= s1.count() && l2 <= s2.count(); ++l1, ++l2)
- {
+ int l1 = 0, l2 = 0;
+ while (l1 <= s1.count() && l2 <= s2.count()) {
// skip spaces, tabs and 0's
QChar c1 = getNextChar(s1, l1);
while (c1.isSpace())
c1 = getNextChar(s1, ++l1);
+
QChar c2 = getNextChar(s2, l2);
while (c2.isSpace())
c2 = getNextChar(s2, ++l2);
- if (c1.isDigit() && c2.isDigit())
- {
+ if (c1.isDigit() && c2.isDigit()) {
while (c1.digitValue() == 0)
c1 = getNextChar(s1, ++l1);
while (c2.digitValue() == 0)
@@ -30,11 +32,8 @@ int Strings::naturalCompare(const QString &s1, const QString &s2, Qt::CaseSensit
int lookAheadLocation2 = l2;
int currentReturnValue = 0;
// find the last digit, setting currentReturnValue as we go if it isn't equal
- for (QChar lookAhead1 = c1, lookAhead2 = c2;
- (lookAheadLocation1 <= s1.length() && lookAheadLocation2 <= s2.length());
- lookAhead1 = getNextChar(s1, ++lookAheadLocation1),
- lookAhead2 = getNextChar(s2, ++lookAheadLocation2))
- {
+ for (QChar lookAhead1 = c1, lookAhead2 = c2; (lookAheadLocation1 <= s1.length() && lookAheadLocation2 <= s2.length());
+ lookAhead1 = getNextChar(s1, ++lookAheadLocation1), lookAhead2 = getNextChar(s2, ++lookAheadLocation2)) {
bool is1ADigit = !lookAhead1.isNull() && lookAhead1.isDigit();
bool is2ADigit = !lookAhead2.isNull() && lookAhead2.isDigit();
if (!is1ADigit && !is2ADigit)
@@ -43,14 +42,10 @@ int Strings::naturalCompare(const QString &s1, const QString &s2, Qt::CaseSensit
return -1;
if (!is2ADigit)
return 1;
- if (currentReturnValue == 0)
- {
- if (lookAhead1 < lookAhead2)
- {
+ if (currentReturnValue == 0) {
+ if (lookAhead1 < lookAhead2) {
currentReturnValue = -1;
- }
- else if (lookAhead1 > lookAhead2)
- {
+ } else if (lookAhead1 > lookAhead2) {
currentReturnValue = 1;
}
}
@@ -58,19 +53,24 @@ int Strings::naturalCompare(const QString &s1, const QString &s2, Qt::CaseSensit
if (currentReturnValue != 0)
return currentReturnValue;
}
- if (cs == Qt::CaseInsensitive)
- {
+
+ if (cs == Qt::CaseInsensitive) {
if (!c1.isLower())
c1 = c1.toLower();
if (!c2.isLower())
c2 = c2.toLower();
}
+
int r = QString::localeAwareCompare(c1, c2);
if (r < 0)
return -1;
if (r > 0)
return 1;
+
+ l1 += 1;
+ l2 += 1;
}
+
// The two strings are the same (02 == 2) so fall back to the normal sort
return QString::compare(s1, s2, cs);
}
diff --git a/launcher/StringUtils.h b/launcher/StringUtils.h
new file mode 100644
index 00000000..1799605b
--- /dev/null
+++ b/launcher/StringUtils.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#include <QString>
+
+namespace StringUtils {
+
+#if defined Q_OS_WIN32
+using string = std::wstring;
+
+inline string toStdString(QString s)
+{
+ return s.toStdWString();
+}
+inline QString fromStdString(string s)
+{
+ return QString::fromStdWString(s);
+}
+#else
+using string = std::string;
+
+inline string toStdString(QString s)
+{
+ return s.toStdString();
+}
+inline QString fromStdString(string s)
+{
+ return QString::fromStdString(s);
+}
+#endif
+
+int naturalCompare(const QString& s1, const QString& s2, Qt::CaseSensitivity cs);
+} // namespace StringUtils
diff --git a/launcher/java/JavaInstall.cpp b/launcher/java/JavaInstall.cpp
index 5bcf7bcb..d5932bcb 100644
--- a/launcher/java/JavaInstall.cpp
+++ b/launcher/java/JavaInstall.cpp
@@ -1,9 +1,10 @@
#include "