Skip to content

Commit

Permalink
Merge branch 'PrismLauncher:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhelvetican authored Jul 28, 2024
2 parents 86e70bb + 6352362 commit 7baf9e0
Show file tree
Hide file tree
Showing 87 changed files with 904 additions and 338 deletions.
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion launcher/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)

m_settings->registerSetting("NumberOfConcurrentTasks", 10);
m_settings->registerSetting("NumberOfConcurrentDownloads", 6);
m_settings->registerSetting("NumberOfManualRetries", 1);
m_settings->registerSetting("RequestTimeout", 60);

QString defaultMonospace;
Expand Down Expand Up @@ -662,6 +663,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
// Minecraft mods
m_settings->registerSetting("ModMetadataDisabled", false);
m_settings->registerSetting("ModDependenciesDisabled", false);
m_settings->registerSetting("SkipModpackUpdatePrompt", false);

// Minecraft offline player name
m_settings->registerSetting("LastOfflinePlayerName", "");
Expand Down Expand Up @@ -816,7 +818,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
m_icons.reset(new IconList(instFolders, setting->get().toString()));
connect(setting.get(), &Setting::SettingChanged,
[&](const Setting&, QVariant value) { m_icons->directoryChanged(value.toString()); });
qDebug() << "<> Instance icons intialized.";
qDebug() << "<> Instance icons initialized.";
}

// Themes
Expand Down
26 changes: 26 additions & 0 deletions launcher/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1691,4 +1691,30 @@ QString getPathNameInLocal8bit(const QString& file)
}
#endif

QString getUniqueResourceName(const QString& filePath)
{
auto newFileName = filePath;
if (!newFileName.endsWith(".disabled")) {
return newFileName; // prioritize enabled mods
}
newFileName.chop(9);
if (!QFile::exists(newFileName)) {
return filePath;
}
QFileInfo fileInfo(filePath);
auto baseName = fileInfo.completeBaseName();
auto path = fileInfo.absolutePath();

int counter = 1;
do {
if (counter == 1) {
newFileName = FS::PathCombine(path, baseName + ".duplicate");
} else {
newFileName = FS::PathCombine(path, baseName + ".duplicate" + QString::number(counter));
}
counter++;
} while (QFile::exists(newFileName));

return newFileName;
}
} // namespace FS
2 changes: 2 additions & 0 deletions launcher/FileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -560,4 +560,6 @@ uintmax_t hardLinkCount(const QString& path);
QString getPathNameInLocal8bit(const QString& file);
#endif

QString getUniqueResourceName(const QString& filePath);

} // namespace FS
28 changes: 22 additions & 6 deletions launcher/InstanceList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,13 @@ void InstanceList::undoTrashInstance()

auto top = m_trashHistory.pop();

while (QDir(top.polyPath).exists()) {
while (QDir(top.path).exists()) {
top.id += "1";
top.polyPath += "1";
top.path += "1";
}

qDebug() << "Moving" << top.trashPath << "back to" << top.polyPath;
QFile(top.trashPath).rename(top.polyPath);
qDebug() << "Moving" << top.trashPath << "back to" << top.path;
QFile(top.trashPath).rename(top.path);

m_instanceGroupIndex[top.id] = top.groupName;
increaseGroupCount(top.groupName);
Expand Down Expand Up @@ -635,8 +635,8 @@ InstancePtr InstanceList::loadInstance(const InstanceId& id)

QString inst_type = instanceSettings->get("InstanceType").toString();

// NOTE: Some PolyMC versions didn't save the InstanceType properly. We will just bank on the probability that this is probably a OneSix
// instance
// NOTE: Some launcher versions didn't save the InstanceType properly. We will just bank on the probability that this is probably a
// OneSix instance
if (inst_type == "OneSix" || inst_type.isEmpty()) {
inst.reset(new MinecraftInstance(m_globalSettings, instanceSettings, instanceRoot));
} else {
Expand Down Expand Up @@ -710,6 +710,12 @@ void InstanceList::saveGroupList()
groupsArr.insert(name, groupObj);
}
toplevel.insert("groups", groupsArr);
// empty string represents ungrouped "group"
if (m_collapsedGroups.contains("")) {
QJsonObject ungrouped;
ungrouped.insert("hidden", QJsonValue(true));
toplevel.insert("ungrouped", ungrouped);
}
QJsonDocument doc(toplevel);
try {
FS::write(groupFileName, doc.toJson());
Expand Down Expand Up @@ -805,6 +811,16 @@ void InstanceList::loadGroupList()
increaseGroupCount(groupName);
}
}

bool ungroupedHidden = false;
if (rootObj.value("ungrouped").isObject()) {
QJsonObject ungrouped = rootObj.value("ungrouped").toObject();
ungroupedHidden = ungrouped.value("hidden").toBool(false);
}
if (ungroupedHidden) {
// empty string represents ungrouped "group"
m_collapsedGroups.insert("");
}
m_groupsLoaded = true;
qDebug() << "Group list loaded.";
}
Expand Down
2 changes: 1 addition & 1 deletion launcher/InstanceList.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ enum class GroupsState { NotLoaded, Steady, Dirty };

struct TrashHistoryItem {
QString id;
QString polyPath;
QString path;
QString trashPath;
QString groupName;
};
Expand Down
5 changes: 5 additions & 0 deletions launcher/InstanceTask.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "InstanceTask.h"

#include "Application.h"
#include "settings/SettingsObject.h"
#include "ui/dialogs/CustomMessageBox.h"

#include <QPushButton>
Expand All @@ -22,6 +24,9 @@ InstanceNameChange askForChangingInstanceName(QWidget* parent, const QString& ol

ShouldUpdate askIfShouldUpdate(QWidget* parent, QString original_version_name)
{
if (APPLICATION->settings()->get("SkipModpackUpdatePrompt").toBool())
return ShouldUpdate::SkipUpdating;

auto info = CustomMessageBox::selectable(
parent, QObject::tr("Similar modpack was found!"),
QObject::tr(
Expand Down
8 changes: 6 additions & 2 deletions launcher/java/JavaUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ QList<QString> JavaUtils::FindJavaPaths()
return javas;
}

#elif defined(Q_OS_LINUX)
#elif defined(Q_OS_LINUX) || defined(Q_OS_OPENBSD) || defined(Q_OS_FREEBSD)
QList<QString> JavaUtils::FindJavaPaths()
{
QList<QString> javas;
Expand All @@ -419,6 +419,7 @@ QList<QString> JavaUtils::FindJavaPaths()
scanJavaDir(snap + dirPath);
}
};
#if defined(Q_OS_LINUX)
// oracle RPMs
scanJavaDirs("/usr/java");
// general locations used by distro packaging
Expand All @@ -437,7 +438,10 @@ QList<QString> JavaUtils::FindJavaPaths()
scanJavaDirs("/opt/ibm"); // IBM Semeru Certified Edition
// flatpak
scanJavaDirs("/app/jdk");

#elif defined(Q_OS_OPENBSD) || defined(Q_OS_FREEBSD)
// ports install to /usr/local on OpenBSD & FreeBSD
scanJavaDirs("/usr/local");
#endif
auto home = qEnvironmentVariable("HOME");

// javas downloaded by IntelliJ
Expand Down
12 changes: 10 additions & 2 deletions launcher/meta/BaseEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,21 @@ class ParsingValidator : public Net::Validator {
virtual ~ParsingValidator() {};

public: /* methods */
bool init(QNetworkRequest&) override { return true; }
bool init(QNetworkRequest&) override
{
m_data.clear();
return true;
}
bool write(QByteArray& data) override
{
this->m_data.append(data);
return true;
}
bool abort() override { return true; }
bool abort() override
{
m_data.clear();
return true;
}
bool validate(QNetworkReply&) override
{
auto fname = m_entity->localFilename();
Expand Down
Loading

0 comments on commit 7baf9e0

Please sign in to comment.