Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into concurrent

This commit is contained in:
Trial97 2023-10-26 13:45:47 +03:00
commit 04acd27dab
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318
42 changed files with 119 additions and 56 deletions

4
.clang-tidy Normal file
View File

@ -0,0 +1,4 @@
Checks:
- modernize-use-using
SystemHeaders: false

View File

@ -388,7 +388,7 @@ QString BaseInstance::name() const
QString BaseInstance::windowTitle() const QString BaseInstance::windowTitle() const
{ {
return BuildConfig.LAUNCHER_DISPLAYNAME + ": " + name().replace(QRegularExpression("\\s+"), " "); return BuildConfig.LAUNCHER_DISPLAYNAME + ": " + name();
} }
// FIXME: why is this here? move it to MinecraftInstance!!! // FIXME: why is this here? move it to MinecraftInstance!!!

View File

@ -64,7 +64,7 @@ class LaunchTask;
class BaseInstance; class BaseInstance;
// pointer for lazy people // pointer for lazy people
typedef std::shared_ptr<BaseInstance> InstancePtr; using InstancePtr = std::shared_ptr<BaseInstance>;
/*! /*!
* \brief Base class for instances. * \brief Base class for instances.

View File

@ -51,7 +51,7 @@ class BaseVersionList : public QAbstractListModel {
ArchitectureRole, ArchitectureRole,
SortRole SortRole
}; };
typedef QList<int> RoleList; using RoleList = QList<int>;
explicit BaseVersionList(QObject* parent = 0); explicit BaseVersionList(QObject* parent = 0);

View File

@ -123,26 +123,35 @@ namespace fs = ghc::filesystem;
#if defined(__MINGW32__) #if defined(__MINGW32__)
typedef struct _DUPLICATE_EXTENTS_DATA { struct _DUPLICATE_EXTENTS_DATA {
HANDLE FileHandle; HANDLE FileHandle;
LARGE_INTEGER SourceFileOffset; LARGE_INTEGER SourceFileOffset;
LARGE_INTEGER TargetFileOffset; LARGE_INTEGER TargetFileOffset;
LARGE_INTEGER ByteCount; LARGE_INTEGER ByteCount;
} DUPLICATE_EXTENTS_DATA, *PDUPLICATE_EXTENTS_DATA; };
typedef struct _FSCTL_GET_INTEGRITY_INFORMATION_BUFFER { using DUPLICATE_EXTENTS_DATA = _DUPLICATE_EXTENTS_DATA;
using PDUPLICATE_EXTENTS_DATA = _DUPLICATE_EXTENTS_DATA*;
struct _FSCTL_GET_INTEGRITY_INFORMATION_BUFFER {
WORD ChecksumAlgorithm; // Checksum algorithm. e.g. CHECKSUM_TYPE_UNCHANGED, CHECKSUM_TYPE_NONE, CHECKSUM_TYPE_CRC32 WORD ChecksumAlgorithm; // Checksum algorithm. e.g. CHECKSUM_TYPE_UNCHANGED, CHECKSUM_TYPE_NONE, CHECKSUM_TYPE_CRC32
WORD Reserved; // Must be 0 WORD Reserved; // Must be 0
DWORD Flags; // FSCTL_INTEGRITY_FLAG_xxx DWORD Flags; // FSCTL_INTEGRITY_FLAG_xxx
DWORD ChecksumChunkSizeInBytes; DWORD ChecksumChunkSizeInBytes;
DWORD ClusterSizeInBytes; DWORD ClusterSizeInBytes;
} FSCTL_GET_INTEGRITY_INFORMATION_BUFFER, *PFSCTL_GET_INTEGRITY_INFORMATION_BUFFER; };
typedef struct _FSCTL_SET_INTEGRITY_INFORMATION_BUFFER { using FSCTL_GET_INTEGRITY_INFORMATION_BUFFER = _FSCTL_GET_INTEGRITY_INFORMATION_BUFFER;
using PFSCTL_GET_INTEGRITY_INFORMATION_BUFFER = _FSCTL_GET_INTEGRITY_INFORMATION_BUFFER*;
struct _FSCTL_SET_INTEGRITY_INFORMATION_BUFFER {
WORD ChecksumAlgorithm; // Checksum algorithm. e.g. CHECKSUM_TYPE_UNCHANGED, CHECKSUM_TYPE_NONE, CHECKSUM_TYPE_CRC32 WORD ChecksumAlgorithm; // Checksum algorithm. e.g. CHECKSUM_TYPE_UNCHANGED, CHECKSUM_TYPE_NONE, CHECKSUM_TYPE_CRC32
WORD Reserved; // Must be 0 WORD Reserved; // Must be 0
DWORD Flags; // FSCTL_INTEGRITY_FLAG_xxx DWORD Flags; // FSCTL_INTEGRITY_FLAG_xxx
} FSCTL_SET_INTEGRITY_INFORMATION_BUFFER, *PFSCTL_SET_INTEGRITY_INFORMATION_BUFFER; };
using FSCTL_SET_INTEGRITY_INFORMATION_BUFFER = _FSCTL_SET_INTEGRITY_INFORMATION_BUFFER;
using PFSCTL_SET_INTEGRITY_INFORMATION_BUFFER = _FSCTL_SET_INTEGRITY_INFORMATION_BUFFER*;
#endif #endif

View File

@ -172,7 +172,7 @@ class ExportToZipTask : public Task {
void setExcludeFiles(QStringList excludeFiles) { m_exclude_files = excludeFiles; } void setExcludeFiles(QStringList excludeFiles) { m_exclude_files = excludeFiles; }
void addExtraFile(QString fileName, QByteArray data) { m_extra_files.insert(fileName, data); } void addExtraFile(QString fileName, QByteArray data) { m_extra_files.insert(fileName, data); }
typedef std::optional<QString> ZipResult; using ZipResult = std::optional<QString>;
protected: protected:
virtual void executeTask() override; virtual void executeTask() override;

View File

@ -10,7 +10,7 @@ class VersionProxyModel : public QAbstractProxyModel {
Q_OBJECT Q_OBJECT
public: public:
enum Column { Name, ParentVersion, Branch, Type, Architecture, Path, Time }; enum Column { Name, ParentVersion, Branch, Type, Architecture, Path, Time };
typedef QHash<BaseVersionList::ModelRoles, std::shared_ptr<Filter>> FilterMap; using FilterMap = QHash<BaseVersionList::ModelRoles, std::shared_ptr<Filter>>;
public: public:
VersionProxyModel(QObject* parent = 0); VersionProxyModel(QObject* parent = 0);

View File

@ -22,8 +22,8 @@ struct JavaCheckResult {
enum class Validity { Errored, ReturnedInvalidData, Valid } validity = Validity::Errored; enum class Validity { Errored, ReturnedInvalidData, Valid } validity = Validity::Errored;
}; };
typedef shared_qobject_ptr<QProcess> QProcessPtr; using QProcessPtr = shared_qobject_ptr<QProcess>;
typedef shared_qobject_ptr<JavaChecker> JavaCheckerPtr; using JavaCheckerPtr = shared_qobject_ptr<JavaChecker>;
class JavaChecker : public QObject { class JavaChecker : public QObject {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -20,7 +20,7 @@
#include "tasks/Task.h" #include "tasks/Task.h"
class JavaCheckerJob; class JavaCheckerJob;
typedef shared_qobject_ptr<JavaCheckerJob> JavaCheckerJobPtr; using JavaCheckerJobPtr = shared_qobject_ptr<JavaCheckerJob>;
// FIXME: this just seems horribly redundant // FIXME: this just seems horribly redundant
class JavaCheckerJob : public Task { class JavaCheckerJob : public Task {

View File

@ -42,4 +42,4 @@ struct JavaInstall : public BaseVersion {
bool recommended = false; bool recommended = false;
}; };
typedef std::shared_ptr<JavaInstall> JavaInstallPtr; using JavaInstallPtr = std::shared_ptr<JavaInstall>;

View File

@ -6,7 +6,7 @@
class Agent; class Agent;
typedef std::shared_ptr<Agent> AgentPtr; using AgentPtr = std::shared_ptr<Agent>;
class Agent { class Agent {
public: public:

View File

@ -105,4 +105,4 @@ class Component : public QObject, public ProblemProvider {
bool m_loaded = false; bool m_loaded = false;
}; };
typedef shared_qobject_ptr<Component> ComponentPtr; using ComponentPtr = shared_qobject_ptr<Component>;

View File

@ -52,7 +52,7 @@
class Library; class Library;
class MinecraftInstance; class MinecraftInstance;
typedef std::shared_ptr<Library> LibraryPtr; using LibraryPtr = std::shared_ptr<Library>;
class Library { class Library {
friend class OneSixVersionFormat; friend class OneSixVersionFormat;

View File

@ -710,7 +710,7 @@ QString MinecraftInstance::createLaunchScript(AuthSessionPtr session, MinecraftS
{ {
QString windowParams; QString windowParams;
if (settings()->get("LaunchMaximized").toBool()) if (settings()->get("LaunchMaximized").toBool())
windowParams = "max"; windowParams = "maximized";
else else
windowParams = windowParams =
QString("%1x%2").arg(settings()->get("MinecraftWinWidth").toInt()).arg(settings()->get("MinecraftWinHeight").toInt()); QString("%1x%2").arg(settings()->get("MinecraftWinWidth").toInt()).arg(settings()->get("MinecraftWinHeight").toInt());
@ -718,6 +718,19 @@ QString MinecraftInstance::createLaunchScript(AuthSessionPtr session, MinecraftS
launchScript += "windowParams " + windowParams + "\n"; launchScript += "windowParams " + windowParams + "\n";
} }
// launcher info
{
launchScript += "launcherBrand " + BuildConfig.LAUNCHER_NAME + "\n";
launchScript += "launcherVersion " + BuildConfig.printableVersionString() + "\n";
}
// instance info
{
launchScript += "instanceName " + name() + "\n";
launchScript += "instanceIconKey " + name() + "\n";
launchScript += "instanceIconPath icon.png\n"; // we already save a copy here
}
// legacy auth // legacy auth
if (session) { if (session) {
launchScript += "userName " + session->player_name + "\n"; launchScript += "userName " + session->player_name + "\n";

View File

@ -174,4 +174,4 @@ class MinecraftInstance : public BaseInstance {
mutable std::shared_ptr<GameOptions> m_game_options; mutable std::shared_ptr<GameOptions> m_game_options;
}; };
typedef std::shared_ptr<MinecraftInstance> MinecraftInstancePtr; using MinecraftInstancePtr = std::shared_ptr<MinecraftInstance>;

View File

@ -5,7 +5,7 @@
struct MojangDownloadInfo { struct MojangDownloadInfo {
// types // types
typedef std::shared_ptr<MojangDownloadInfo> Ptr; using Ptr = std::shared_ptr<MojangDownloadInfo>;
// data // data
/// Local filesystem path. WARNING: not used, only here so we can pass through mojang files unmolested! /// Local filesystem path. WARNING: not used, only here so we can pass through mojang files unmolested!
@ -23,7 +23,7 @@ struct MojangLibraryDownloadInfo {
MojangLibraryDownloadInfo() {} MojangLibraryDownloadInfo() {}
// types // types
typedef std::shared_ptr<MojangLibraryDownloadInfo> Ptr; using Ptr = std::shared_ptr<MojangLibraryDownloadInfo>;
// methods // methods
MojangDownloadInfo* getDownloadInfo(QString classifier) MojangDownloadInfo* getDownloadInfo(QString classifier)
@ -42,7 +42,7 @@ struct MojangLibraryDownloadInfo {
struct MojangAssetIndexInfo : public MojangDownloadInfo { struct MojangAssetIndexInfo : public MojangDownloadInfo {
// types // types
typedef std::shared_ptr<MojangAssetIndexInfo> Ptr; using Ptr = std::shared_ptr<MojangAssetIndexInfo>;
// methods // methods
MojangAssetIndexInfo() {} MojangAssetIndexInfo() {}

View File

@ -38,7 +38,7 @@
#include "VersionFile.h" #include "VersionFile.h"
namespace ProfileUtils { namespace ProfileUtils {
typedef QStringList PatchOrder; using PatchOrder = QStringList;
/// Read and parse a OneSix format order file /// Read and parse a OneSix format order file
bool readOverrideOrders(QString path, PatchOrder& order); bool readOverrideOrders(QString path, PatchOrder& order);

View File

@ -43,4 +43,4 @@ struct AuthSession {
bool demo = false; bool demo = false;
}; };
typedef std::shared_ptr<AuthSession> AuthSessionPtr; using AuthSessionPtr = std::shared_ptr<AuthSession>;

View File

@ -54,7 +54,7 @@ class Task;
class AccountTask; class AccountTask;
class MinecraftAccount; class MinecraftAccount;
typedef shared_qobject_ptr<MinecraftAccount> MinecraftAccountPtr; using MinecraftAccountPtr = shared_qobject_ptr<MinecraftAccount>;
Q_DECLARE_METATYPE(MinecraftAccountPtr) Q_DECLARE_METATYPE(MinecraftAccountPtr)
/** /**

View File

@ -26,4 +26,4 @@ struct MinecraftServerTarget {
static MinecraftServerTarget parse(const QString& fullAddress); static MinecraftServerTarget parse(const QString& fullAddress);
}; };
typedef std::shared_ptr<MinecraftServerTarget> MinecraftServerTargetPtr; using MinecraftServerTargetPtr = std::shared_ptr<MinecraftServerTarget>;

View File

@ -4,7 +4,7 @@
#include <QtNetwork/QtNetwork> #include <QtNetwork/QtNetwork>
#include "tasks/Task.h" #include "tasks/Task.h"
typedef shared_qobject_ptr<class SkinDelete> SkinDeletePtr; using SkinDeletePtr = shared_qobject_ptr<class SkinDelete>;
class SkinDelete : public Task { class SkinDelete : public Task {
Q_OBJECT Q_OBJECT

View File

@ -5,7 +5,7 @@
#include <memory> #include <memory>
#include "tasks/Task.h" #include "tasks/Task.h"
typedef shared_qobject_ptr<class SkinUpload> SkinUploadPtr; using SkinUploadPtr = shared_qobject_ptr<class SkinUpload>;
class SkinUpload : public Task { class SkinUpload : public Task {
Q_OBJECT Q_OBJECT

View File

@ -45,7 +45,7 @@ struct Modpack {
QIcon icon; QIcon icon;
}; };
typedef QList<Modpack> ModpackList; using ModpackList = QList<Modpack>;
Modpack parseDirectory(QString path); Modpack parseDirectory(QString path);

View File

@ -31,7 +31,7 @@ struct Modpack {
QString packCode; QString packCode;
}; };
typedef QList<Modpack> ModpackList; using ModpackList = QList<Modpack>;
} // namespace LegacyFTB } // namespace LegacyFTB

View File

@ -87,7 +87,7 @@ class NetRequest : public NetAction {
std::unique_ptr<Sink> m_sink; std::unique_ptr<Sink> m_sink;
Options m_options; Options m_options;
typedef const QLoggingCategory& (*logCatFunc)(); using logCatFunc = const QLoggingCategory& (*)();
logCatFunc logCat = taskUploadLogC; logCatFunc logCat = taskUploadLogC;
std::chrono::steady_clock m_clock; std::chrono::steady_clock m_clock;

View File

@ -51,4 +51,4 @@ class NewsEntry : public QObject {
QString link; QString link;
}; };
typedef std::shared_ptr<NewsEntry> NewsEntryPtr; using NewsEntryPtr = std::shared_ptr<NewsEntry>;

View File

@ -4,7 +4,7 @@
class IPathMatcher { class IPathMatcher {
public: public:
typedef std::shared_ptr<IPathMatcher> Ptr; using Ptr = std::shared_ptr<IPathMatcher>;
public: public:
virtual ~IPathMatcher() {} virtual ~IPathMatcher() {}

View File

@ -26,8 +26,8 @@
class Setting; class Setting;
class SettingsObject; class SettingsObject;
typedef std::shared_ptr<SettingsObject> SettingsObjectPtr; using SettingsObjectPtr = std::shared_ptr<SettingsObject>;
typedef std::weak_ptr<SettingsObject> SettingsObjectWeakPtr; using SettingsObjectWeakPtr = std::weak_ptr<SettingsObject>;
/*! /*!
* \brief The SettingsObject handles communicating settings between the application and a * \brief The SettingsObject handles communicating settings between the application and a

View File

@ -77,7 +77,7 @@ struct TaskStepProgress {
Q_DECLARE_METATYPE(TaskStepProgress) Q_DECLARE_METATYPE(TaskStepProgress)
typedef QList<std::shared_ptr<TaskStepProgress>> TaskStepProgressList; using TaskStepProgressList = QList<std::shared_ptr<TaskStepProgress>>;
class Task : public QObject, public QRunnable { class Task : public QObject, public QRunnable {
Q_OBJECT Q_OBJECT

View File

@ -43,7 +43,7 @@
#include "FileIgnoreProxy.h" #include "FileIgnoreProxy.h"
class BaseInstance; class BaseInstance;
typedef std::shared_ptr<BaseInstance> InstancePtr; using InstancePtr = std::shared_ptr<BaseInstance>;
namespace Ui { namespace Ui {
class ExportInstanceDialog; class ExportInstanceDialog;

View File

@ -59,7 +59,7 @@ class AccessibleInstanceView : public QAccessibleTableInterface, public QAccessi
protected: protected:
// maybe vector // maybe vector
typedef QHash<int, QAccessible::Id> ChildCache; using ChildCache = QHash<int, QAccessible::Id>;
mutable ChildCache childToId; mutable ChildCache childToId;
virtual ~AccessibleInstanceView(); virtual ~AccessibleInstanceView();

View File

@ -77,4 +77,4 @@ class BasePage {
bool isOpened = false; bool isOpened = false;
}; };
typedef std::shared_ptr<BasePage> BasePagePtr; using BasePagePtr = std::shared_ptr<BasePage>;

View File

@ -26,7 +26,7 @@ class BasePageProvider {
}; };
class GenericPageProvider : public BasePageProvider { class GenericPageProvider : public BasePageProvider {
typedef std::function<BasePage*()> PageCreator; using PageCreator = std::function<BasePage*()>;
public: public:
explicit GenericPageProvider(const QString& dialogTitle) : m_dialogTitle(dialogTitle) {} explicit GenericPageProvider(const QString& dialogTitle) : m_dialogTitle(dialogTitle) {}

View File

@ -68,8 +68,8 @@
#include <FileSystem.h> #include <FileSystem.h>
#include "RWStorage.h" #include "RWStorage.h"
typedef RWStorage<QString, QIcon> SharedIconCache; using SharedIconCache = RWStorage<QString, QIcon>;
typedef std::shared_ptr<SharedIconCache> SharedIconCachePtr; using SharedIconCachePtr = std::shared_ptr<SharedIconCache>;
class ThumbnailingResult : public QObject { class ThumbnailingResult : public QObject {
Q_OBJECT Q_OBJECT

View File

@ -24,8 +24,8 @@
namespace Atl { namespace Atl {
typedef QMap<QString, QIcon> LogoMap; using LogoMap = QMap<QString, QIcon>;
typedef std::function<void(QString)> LogoCallback; using LogoCallback = std::function<void(QString)>;
class ListModel : public QAbstractListModel { class ListModel : public QAbstractListModel {
Q_OBJECT Q_OBJECT

View File

@ -19,8 +19,8 @@
namespace Flame { namespace Flame {
typedef QMap<QString, QIcon> LogoMap; using LogoMap = QMap<QString, QIcon>;
typedef std::function<void(QString)> LogoCallback; using LogoCallback = std::function<void(QString)>;
class ListModel : public QAbstractListModel { class ListModel : public QAbstractListModel {
Q_OBJECT Q_OBJECT

View File

@ -13,8 +13,8 @@
namespace LegacyFTB { namespace LegacyFTB {
typedef QMap<QString, QIcon> FTBLogoMap; using FTBLogoMap = QMap<QString, QIcon>;
typedef std::function<void(QString)> LogoCallback; using LogoCallback = std::function<void(QString)>;
class FilterModel : public QSortFilterProxyModel { class FilterModel : public QSortFilterProxyModel {
Q_OBJECT Q_OBJECT

View File

@ -42,7 +42,7 @@
namespace Technic { namespace Technic {
typedef std::function<void(QString)> LogoCallback; using LogoCallback = std::function<void(QString)>;
class ListModel : public QAbstractListModel { class ListModel : public QAbstractListModel {
Q_OBJECT Q_OBJECT

View File

@ -64,8 +64,7 @@ bool JavaWizardPage::validatePage()
} }
case JavaSettingsWidget::ValidationStatus::AllOK: { case JavaSettingsWidget::ValidationStatus::AllOK: {
settings->set("JavaPath", m_java_widget->javaPath()); settings->set("JavaPath", m_java_widget->javaPath());
return true; } /* fallthrough */
}
case JavaSettingsWidget::ValidationStatus::JavaBad: { case JavaSettingsWidget::ValidationStatus::JavaBad: {
// Memory // Memory
auto s = APPLICATION->settings(); auto s = APPLICATION->settings();

2
libraries/.clang-tidy Normal file
View File

@ -0,0 +1,2 @@
# We don't care about linting third-party code.
Checks: -*

View File

@ -105,13 +105,16 @@ public final class EntryPoint {
return ExitCode.ABORT; return ExitCode.ABORT;
} }
setProperties(params);
String launcherType = params.getString("launcher");
try { try {
LegacyProxy.applyOnlineFixes(params); LegacyProxy.applyOnlineFixes(params);
Launcher launcher; Launcher launcher;
String type = params.getString("launcher");
switch (type) { switch (launcherType) {
case "standard": case "standard":
launcher = new StandardLauncher(params); launcher = new StandardLauncher(params);
break; break;
@ -121,7 +124,7 @@ public final class EntryPoint {
break; break;
default: default:
throw new IllegalArgumentException("Invalid launcher type: " + type); throw new IllegalArgumentException("Invalid launcher type: " + launcherType);
} }
launcher.launch(); launcher.launch();
@ -138,6 +141,39 @@ public final class EntryPoint {
} }
} }
private static void setProperties(Parameters params) {
String launcherBrand = params.getString("launcherBrand", null);
String launcherVersion = params.getString("launcherVersion", null);
String name = params.getString("instanceName", null);
String iconId = params.getString("instanceIconKey", null);
String iconPath = params.getString("instanceIconPath", null);
String windowTitle = params.getString("windowTitle", null);
String windowDimensions = params.getString("windowParams", null);
if (launcherBrand != null)
System.setProperty("minecraft.launcher.brand", launcherBrand);
if (launcherVersion != null)
System.setProperty("minecraft.launcher.version", launcherVersion);
// set useful properties for mods
if (name != null)
System.setProperty("org.prismlauncher.instance.name", name);
if (iconId != null)
System.setProperty("org.prismlauncher.instance.icon.id", iconId);
if (iconPath != null)
System.setProperty("org.prismlauncher.instance.icon.path", iconPath);
if (windowTitle != null)
System.setProperty("org.prismlauncher.window.title", windowTitle);
if (windowDimensions != null)
System.setProperty("org.prismlauncher.window.dimensions", windowDimensions);
// set multimc properties for compatibility
if (name != null)
System.setProperty("multimc.instance.title", name);
if (iconId != null)
System.setProperty("multimc.instance.icon", iconId);
}
private static PreLaunchAction parseLine(String input, Parameters params) throws ParseException { private static PreLaunchAction parseLine(String input, Parameters params) throws ParseException {
switch (input) { switch (input) {
case "": case "":

View File

@ -83,7 +83,7 @@ public abstract class AbstractLauncher implements Launcher {
String windowParams = params.getString("windowParams", null); String windowParams = params.getString("windowParams", null);
if ("max".equals(windowParams) || windowParams == null) { if ("maximized".equals(windowParams) || windowParams == null) {
maximize = windowParams != null; maximize = windowParams != null;
width = DEFAULT_WINDOW_WIDTH; width = DEFAULT_WINDOW_WIDTH;