Merge branch 'PrismLauncher:develop' into mrpack-export

This commit is contained in:
TheKodeToad 2023-03-18 14:02:05 +00:00 committed by GitHub
commit 1893871a99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
46 changed files with 785 additions and 334 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
use flake

View File

@ -158,7 +158,7 @@ jobs:
- name: Retrieve ccache cache (Windows MinGW-w64)
if: runner.os == 'Windows' && matrix.msystem != '' && inputs.build_type == 'Debug'
uses: actions/cache@v3.2.6
uses: actions/cache@v3.3.1
with:
path: '${{ github.workspace }}\.ccache'
key: ${{ matrix.os }}-mingw-w64-ccache-${{ github.run_id }}
@ -550,31 +550,6 @@ jobs:
run: |
ccache -s
snap:
runs-on: ubuntu-20.04
steps:
- name: Checkout
if: inputs.build_type == 'Debug'
uses: actions/checkout@v3
with:
submodules: 'true'
- name: Set short version
shell: bash
if: inputs.build_type == 'Debug'
run: |
ver_short=`git rev-parse --short HEAD`
echo "VERSION=$ver_short" >> $GITHUB_ENV
- name: Package Snap (Linux)
id: snapcraft
if: inputs.build_type == 'Debug'
uses: snapcore/action-build@v1
- name: Upload Snap (Linux)
if: inputs.build_type == 'Debug'
uses: actions/upload-artifact@v3
with:
name: prismlauncher_${{ env.VERSION }}_amd64.snap
path: ${{ steps.snapcraft.outputs.snap }}
flatpak:
runs-on: ubuntu-latest
container:

6
.gitignore vendored
View File

@ -11,10 +11,12 @@ html/
*.pro.user
CMakeLists.txt.user
CMakeLists.txt.user.*
CMakeSettings.json
/.project
/.settings
/.idea
/.vscode
/.vs
cmake-build-*/
Debug
@ -22,6 +24,10 @@ Debug
build
/build-*
# direnv / Nix
.direnv/
.pre-commit-config.yaml
# Install dirs
install
/install-*

View File

@ -1,53 +1,3 @@
# Build Instructions
Full build instructions will be available on [the website](https://prismlauncher.org/wiki/development/build-instructions/).
If you would like to contribute or fix an issue with the Build instructions you will be able to do so [here](https://github.com/PrismLauncher/website/blob/master/src/wiki/development/build-instructions.md).
## Getting the source
Clone the source code using git, and grab all the submodules. This is generic for all platforms you want to build on.
```
git clone --recursive https://github.com/PrismLauncher/PrismLauncher
cd PrismLauncher
```
## Linux
This guide will mostly mention dependant packages by their Debian naming and commands are done by a user in the sudoers file.
### Dependencies
- A C++ compiler capable of building C++17 code (can be found in the package `build-essential`).
- Qt Development tools 5.12 or newer (on Debian 11 or Debian-based distributions, `qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libqt5core5a libqt5network5 libqt5gui5`).
- `cmake` 3.15 or newer.
- `extra-cmake-modules`.
- zlib (`zlib1g-dev` on Debian 11 or Debian-based distributions).
- Java Development Kit (Java JDK) (`openjdk-17-jdk` on Debian 11 or Debian-based distributions).
- Mesa GL headers (`libgl1-mesa-dev` on Debian 11 or Debian-based distributions).
- (Optional) `scdoc` to generate man pages.
In conclusion, to check if all you need is installed (including optional):
```
sudo apt install build-essential qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libqt5core5a libqt5network5 libqt5gui5 cmake extra-cmake-modules zlib1g-dev openjdk-17-jdk libgl1-mesa-dev scdoc
```
### Compiling
#### Building and installing on the system
This is usually the suggested way to build the client.
```
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="/usr" -DENABLE_LTO=ON
cmake --build build -j$(nproc)
sudo cmake --install build
```
#### Building a portable binary
```
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=install
cmake --build build -j$(nproc)
cmake --install build
cmake --install build --component portable
```
Full build instructions are available on [the website](https://prismlauncher.org/wiki/development/build-instructions/).

View File

@ -174,7 +174,7 @@ set(Launcher_SUBREDDIT_URL "https://www.reddit.com/r/PrismLauncher/" CACHE STRIN
# Builds
set(Launcher_FORCE_BUNDLED_LIBS OFF CACHE BOOL "Prevent using system libraries, if they are available as submodules")
set(Launcher_QT_VERSION_MAJOR "5" CACHE STRING "Major Qt version to build against")
set(Launcher_QT_VERSION_MAJOR "6" CACHE STRING "Major Qt version to build against")
# API Keys
# NOTE: These API keys are here for convenience. If you rebrand this software or intend to break the terms of service
@ -442,12 +442,11 @@ add_subdirectory(libraries/gamemode)
add_subdirectory(libraries/murmur2) # Hash for usage with the CurseForge API
if (NOT ghc_filesystem_FOUND)
message(STATUS "Using bundled ghc_filesystem")
set(GHC_FILESYSTEM_WITH_INSTALL OFF) # Workaround ghc::filesystem bug
add_subdirectory(libraries/filesystem) # Implementation of std::filesystem for old C++, for usage in old macOS
add_library(ghcFilesystem::ghc_filesystem ALIAS ghc_filesystem)
else()
message(STATUS "Using system ghc_filesystem")
endif()
add_subdirectory(libraries/qdcss) # css parser
############################### Built Artifacts ###############################

110
flake.lock generated
View File

@ -3,11 +3,11 @@
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1668681692,
"narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=",
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "009399224d5e398d03b22badca40a37ac85412a1",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
@ -16,6 +16,58 @@
"type": "github"
}
},
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1676283394,
"narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1660459072,
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"libnbtplusplus": {
"flake": false,
"locked": {
@ -34,11 +86,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1671417167,
"narHash": "sha256-JkHam6WQOwZN1t2C2sbp1TqMv3TVRjzrdoejqfefwrM=",
"lastModified": 1678693419,
"narHash": "sha256-bbSv5yqZAW6dz+3f3f3pOUZbxpPN+3OgCljgn7P+nnQ=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "bb31220cca6d044baa6dc2715b07497a2a7c4bc7",
"rev": "8e3fad82be64c06fbfb9fd43993aec9ef4623936",
"type": "github"
},
"original": {
@ -48,11 +100,55 @@
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1673800717,
"narHash": "sha256-SFHraUqLSu5cC6IxTprex/nTsI81ZQAtDvlBvGDWfnA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "2f9fd351ec37f5d479556cd48be4ca340da59b8f",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-22.11",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat_2",
"flake-utils": [
"flake-utils"
],
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1678376203,
"narHash": "sha256-3tyYGyC8h7fBwncLZy5nCUjTJPrHbmNwp47LlNLOHSM=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "1a20b9708962096ec2481eeb2ddca29ed747770a",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"libnbtplusplus": "libnbtplusplus",
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks"
}
}
},

102
flake.nix
View File

@ -3,35 +3,89 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
libnbtplusplus = { url = "github:PrismLauncher/libnbtplusplus"; flake = false; };
flake-utils.url = "github:numtide/flake-utils";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
libnbtplusplus = {
url = "github:PrismLauncher/libnbtplusplus";
flake = false;
};
};
outputs = { self, nixpkgs, libnbtplusplus, ... }:
let
# User-friendly version number.
version = builtins.substring 0 8 self.lastModifiedDate;
outputs = {
self,
nixpkgs,
flake-utils,
pre-commit-hooks,
libnbtplusplus,
...
}: let
# User-friendly version number.
version = builtins.substring 0 8 self.lastModifiedDate;
# Supported systems (qtbase is currently broken for "aarch64-darwin")
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" ];
# Supported systems (qtbase is currently broken for "aarch64-darwin")
supportedSystems = with flake-utils.lib.system; [
x86_64-linux
x86_64-darwin
aarch64-linux
];
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
# Nixpkgs instantiated for supported systems.
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
packagesFn = pkgs: rec {
prismlauncher-qt5 = pkgs.libsForQt5.callPackage ./nix { inherit version self libnbtplusplus; };
prismlauncher = pkgs.qt6Packages.callPackage ./nix { inherit version self libnbtplusplus; };
packagesFn = pkgs: {
prismlauncher-qt5 = pkgs.libsForQt5.callPackage ./nix {
inherit version self libnbtplusplus;
};
in
{
packages = forAllSystems (system:
let packages = packagesFn pkgs.${system}; in
packages // { default = packages.prismlauncher; }
);
prismlauncher = pkgs.qt6Packages.callPackage ./nix {
inherit version self libnbtplusplus;
};
};
in
flake-utils.lib.eachSystem supportedSystems (system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
markdownlint.enable = true;
overlay = final: packagesFn;
alejandra.enable = true;
deadnix.enable = true;
clang-format = {
enable =
false; # As most of the codebase is **not** formatted, we don't want clang-format yet
types_or = ["c" "c++"];
};
};
};
};
packages = let
packages = packagesFn pkgs;
in
packages // {default = packages.prismlauncher;};
devShells.default = pkgs.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
packages = with pkgs; [
nodePackages.markdownlint-cli
alejandra
deadnix
clang-tools
];
inputsFrom = [self.packages.${system}.default];
buildInputs = with pkgs; [ccache ninja];
};
})
// {
overlays.default = final: _: (packagesFn final);
};
}

View File

@ -32,6 +32,7 @@ modules:
config-opts:
- -DLauncher_BUILD_PLATFORM=flatpak
- -DCMAKE_BUILD_TYPE=Debug
- -DLauncher_QT_VERSION_MAJOR=5
build-options:
env:
JAVA_HOME: /usr/lib/sdk/openjdk17/jvm/openjdk-17

View File

@ -7,6 +7,7 @@
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
* Copyright (C) 2022 Lenny McLennington <lenny@sneed.church>
* Copyright (C) 2022 Tayou <tayou@gmx.net>
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -225,7 +226,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
m_serverToJoin = parser.value("server");
m_profileToUse = parser.value("profile");
m_liveCheck = parser.isSet("alive");
m_instanceIdToShowWindowOf = parser.value("show");
for (auto zip_path : parser.values("import")){
@ -346,7 +347,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
import.command = "import";
import.args.insert("path", zip_url.toString());
m_peerInstance->sendMessage(import.serialize(), timeout);
}
}
}
}
else
@ -515,6 +516,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
m_settings->registerSetting("InstanceDir", "instances");
m_settings->registerSetting({"CentralModsDir", "ModsDir"}, "mods");
m_settings->registerSetting("IconsDir", "icons");
m_settings->registerSetting("DownloadsDir", QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
// Editors
m_settings->registerSetting("JsonEditor", QString());
@ -660,6 +662,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
m_settings->set("FlameKeyOverride", flameKey);
m_settings->reset("CFKeyOverride");
}
m_settings->registerSetting("ModrinthToken", "");
m_settings->registerSetting("UserAgentOverride", "");
// Init page provider
@ -1548,6 +1551,15 @@ QString Application::getFlameAPIKey()
return BuildConfig.FLAME_API_KEY;
}
QString Application::getModrinthAPIToken()
{
QString tokenOverride = m_settings->get("ModrinthToken").toString();
if (!tokenOverride.isEmpty())
return tokenOverride;
return QString();
}
QString Application::getUserAgent()
{
QString uaOverride = m_settings->get("UserAgentOverride").toString();

View File

@ -3,6 +3,7 @@
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
* Copyright (C) 2022 Tayou <tayou@gmx.net>
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -177,6 +178,7 @@ public:
QString getMSAClientID();
QString getFlameAPIKey();
QString getModrinthAPIToken();
QString getUserAgent();
QString getUserAgentUncached();

View File

@ -1045,6 +1045,7 @@ target_link_libraries(Launcher_logic
nbt++
${ZLIB_LIBRARIES}
tomlplusplus::tomlplusplus
qdcss
BuildConfig
Katabasis
Qt${QT_VERSION_MAJOR}::Widgets

View File

@ -36,9 +36,10 @@ public:
values.append(new VersionPage(onesix.get()));
values.append(ManagedPackPage::createPage(onesix.get()));
auto modsPage = new ModFolderPage(onesix.get(), onesix->loaderModList());
modsPage->setFilter("%1 (*.zip *.jar *.litemod)");
modsPage->setFilter("%1 (*.zip *.jar *.litemod *.nilmod)");
values.append(modsPage);
values.append(new CoreModFolderPage(onesix.get(), onesix->coreModList()));
values.append(new NilModFolderPage(onesix.get(), onesix->nilModList()));
values.append(new ResourcePackPage(onesix.get(), onesix->resourcePackList()));
values.append(new TexturePackPage(onesix.get(), onesix->texturePackList()));
values.append(new ShaderPackPage(onesix.get(), onesix->shaderPackList()));

View File

@ -320,7 +320,7 @@ std::optional<QStringList> MMCZip::extractSubDir(QuaZip *zip, const QString & su
if (relative_file_name.isEmpty()) {
target_file_path = target + '/';
} else {
target_file_path = FS::PathCombine(target_top_dir.path(), sub_path, relative_file_name);
target_file_path = FS::PathCombine(target_top_dir.toLocalFile(), sub_path, relative_file_name);
if (relative_file_name.endsWith('/') && !target_file_path.endsWith('/'))
target_file_path += '/';
}

View File

@ -290,6 +290,11 @@ QString MinecraftInstance::coreModsDir() const
return FS::PathCombine(gameRoot(), "coremods");
}
QString MinecraftInstance::nilModsDir() const
{
return FS::PathCombine(gameRoot(), "nilmods");
}
QString MinecraftInstance::resourcePacksDir() const
{
return FS::PathCombine(gameRoot(), "resourcepacks");
@ -1125,6 +1130,18 @@ std::shared_ptr<ModFolderModel> MinecraftInstance::coreModList() const
return m_core_mod_list;
}
std::shared_ptr<ModFolderModel> MinecraftInstance::nilModList() const
{
if (!m_nil_mod_list)
{
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
m_nil_mod_list.reset(new ModFolderModel(nilModsDir(), is_indexed, false));
m_nil_mod_list->disableInteraction(isRunning());
connect(this, &BaseInstance::runningStatusChanged, m_nil_mod_list.get(), &ModFolderModel::disableInteraction);
}
return m_nil_mod_list;
}
std::shared_ptr<ResourcePackFolderModel> MinecraftInstance::resourcePackList() const
{
if (!m_resource_pack_list)

View File

@ -84,6 +84,7 @@ public:
QString shaderPacksDir() const;
QString modsRoot() const override;
QString coreModsDir() const;
QString nilModsDir() const;
QString modsCacheLocation() const;
QString libDir() const;
QString worldDir() const;
@ -116,6 +117,7 @@ public:
////// Mod Lists //////
std::shared_ptr<ModFolderModel> loaderModList() const;
std::shared_ptr<ModFolderModel> coreModList() const;
std::shared_ptr<ModFolderModel> nilModList() const;
std::shared_ptr<ResourcePackFolderModel> resourcePackList() const;
std::shared_ptr<TexturePackFolderModel> texturePackList() const;
std::shared_ptr<ShaderPackFolderModel> shaderPackList() const;
@ -170,6 +172,7 @@ protected: // data
std::shared_ptr<PackProfile> m_components;
mutable std::shared_ptr<ModFolderModel> m_loader_mod_list;
mutable std::shared_ptr<ModFolderModel> m_core_mod_list;
mutable std::shared_ptr<ModFolderModel> m_nil_mod_list;
mutable std::shared_ptr<ResourcePackFolderModel> m_resource_pack_list;
mutable std::shared_ptr<ShaderPackFolderModel> m_shader_pack_list;
mutable std::shared_ptr<TexturePackFolderModel> m_texture_pack_list;

View File

@ -55,6 +55,12 @@ void ScanModFolders::executeTask()
if(!cores->update()) {
m_coreModsDone = true;
}
auto nils = m_inst->nilModList();
connect(nils.get(), &ModFolderModel::updateFinished, this, &ScanModFolders::nilModsDone);
if(!nils->update()) {
m_nilModsDone = true;
}
checkDone();
}
@ -70,9 +76,15 @@ void ScanModFolders::coreModsDone()
checkDone();
}
void ScanModFolders::nilModsDone()
{
m_nilModsDone = true;
checkDone();
}
void ScanModFolders::checkDone()
{
if(m_modsDone && m_coreModsDone) {
if(m_modsDone && m_coreModsDone && m_nilModsDone) {
emitSucceeded();
}
}

View File

@ -33,10 +33,12 @@ public:
private slots:
void coreModsDone();
void modsDone();
void nilModsDone();
private:
void checkDone();
private: // DATA
bool m_modsDone = false;
bool m_nilModsDone = false;
bool m_coreModsDone = false;
};

View File

@ -50,7 +50,7 @@
#include "minecraft/mod/tasks/ModFolderLoadTask.h"
#include "modplatform/ModIndex.h"
ModFolderModel::ModFolderModel(const QString &dir, bool is_indexed) : ResourceFolderModel(QDir(dir)), m_is_indexed(is_indexed)
ModFolderModel::ModFolderModel(const QString &dir, bool is_indexed, bool create_dir) : ResourceFolderModel(QDir(dir), nullptr, create_dir), m_is_indexed(is_indexed)
{
m_column_sort_keys = { SortType::ENABLED, SortType::NAME, SortType::VERSION, SortType::DATE, SortType::PROVIDER };
}

View File

@ -75,7 +75,7 @@ public:
Enable,
Toggle
};
ModFolderModel(const QString &dir, bool is_indexed = false);
ModFolderModel(const QString &dir, bool is_indexed = false, bool create_dir = true);
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;

View File

@ -37,6 +37,9 @@ void Resource::parseFile()
if (file_name.endsWith(".zip") || file_name.endsWith(".jar")) {
m_type = ResourceType::ZIPFILE;
file_name.chop(4);
} else if (file_name.endsWith(".nilmod")) {
m_type = ResourceType::ZIPFILE;
file_name.chop(7);
} else if (file_name.endsWith(".litemod")) {
m_type = ResourceType::LITEMOD;
file_name.chop(8);

View File

@ -12,9 +12,11 @@
#include "tasks/Task.h"
ResourceFolderModel::ResourceFolderModel(QDir dir, QObject* parent) : QAbstractListModel(parent), m_dir(dir), m_watcher(this)
ResourceFolderModel::ResourceFolderModel(QDir dir, QObject* parent, bool create_dir) : QAbstractListModel(parent), m_dir(dir), m_watcher(this)
{
FS::ensureFolderPathExists(m_dir.absolutePath());
if (create_dir) {
FS::ensureFolderPathExists(m_dir.absolutePath());
}
m_dir.setFilter(QDir::Readable | QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs);
m_dir.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware);

View File

@ -24,7 +24,7 @@ class QSortFilterProxyModel;
class ResourceFolderModel : public QAbstractListModel {
Q_OBJECT
public:
ResourceFolderModel(QDir, QObject* parent = nullptr);
ResourceFolderModel(QDir, QObject* parent = nullptr, bool create_dir = true);
~ResourceFolderModel() override;
/** Starts watching the paths for changes.

View File

@ -3,6 +3,7 @@
#include <quazip/quazip.h>
#include <quazip/quazipfile.h>
#include <toml++/toml.h>
#include <qdcss.h>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
@ -285,6 +286,32 @@ ModDetails ReadLiteModInfo(QByteArray contents)
return details;
}
// https://git.sleeping.town/unascribed/NilLoader/src/commit/d7fc87b255fc31019ff90f80d45894927fac6efc/src/main/java/nilloader/api/NilMetadata.java#L64
ModDetails ReadNilModInfo(QByteArray contents, QString fname)
{
ModDetails details;
QDCSS cssData = QDCSS(contents);
auto name = cssData.get("@nilmod.name");
auto desc = cssData.get("@nilmod.description");
auto authors = cssData.get("@nilmod.authors");
if (name->has_value()) {
details.name = name->value();
}
if (desc->has_value()) {
details.description = desc->value();
}
if (authors->has_value()) {
details.authors.append(authors->value());
}
details.version = cssData.get("@nilmod.version")->value_or("?");
details.mod_id = fname.remove(".nilmod.css");
return details;
}
bool process(Mod& mod, ProcessingLevel level)
{
switch (mod.type()) {
@ -401,6 +428,32 @@ bool processZIP(Mod& mod, ProcessingLevel level)
mod.setDetails(details);
return true;
} else if (zip.setCurrentFile("META-INF/nil/mappings.json")) {
// nilloader uses the filename of the metadata file for the modid, so we can't know the exact filename
// thankfully, there is a good file to use as a canary so we don't look for nil meta all the time
QString foundNilMeta;
for (auto& fname : zip.getFileNameList()) {
// nilmods can shade nilloader to be able to run as a standalone agent - which includes nilloader's own meta file
if (fname.endsWith(".nilmod.css") && fname != "nilloader.nilmod.css") {
foundNilMeta = fname;
break;
}
}
if (zip.setCurrentFile(foundNilMeta)) {
if (!file.open(QIODevice::ReadOnly)) {
zip.close();
return false;
}
details = ReadNilModInfo(file.readAll(), foundNilMeta);
file.close();
zip.close();
mod.setDetails(details);
return true;
}
}
zip.close();

View File

@ -79,7 +79,7 @@ void FlameHasher::executeTask()
// CF-specific
auto should_filter_out = [](char c) { return (c == 9 || c == 10 || c == 13 || c == 32); };
std::ifstream file_stream(StringUtils::toStdString(m_path), std::ifstream::binary);
std::ifstream file_stream(StringUtils::toStdString(m_path).c_str(), std::ifstream::binary);
// TODO: This is very heavy work, but apparently QtConcurrent can't use move semantics, so we can't boop this to another thread.
// How do we make this non-blocking then?
m_hash = QString::number(MurmurHash2(std::move(file_stream), 4 * MiB, should_filter_out));

View File

@ -1,8 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* PolyMC - Minecraft Launcher
* Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -113,10 +114,15 @@ void Download::executeTask()
}
request.setHeader(QNetworkRequest::UserAgentHeader, APPLICATION->getUserAgent().toUtf8());
if (APPLICATION->capabilities() & Application::SupportsFlame
&& request.url().host().contains("api.curseforge.com")) {
// TODO remove duplication
if (APPLICATION->capabilities() & Application::SupportsFlame && request.url().host() == QUrl(BuildConfig.FLAME_BASE_URL).host()) {
request.setRawHeader("x-api-key", APPLICATION->getFlameAPIKey().toUtf8());
};
} else if (request.url().host() == QUrl(BuildConfig.MODRINTH_PROD_URL).host() ||
request.url().host() == QUrl(BuildConfig.MODRINTH_STAGING_URL).host()) {
QString token = APPLICATION->getModrinthAPIToken();
if (!token.isNull())
request.setRawHeader("Authorization", token.toUtf8());
}
QNetworkReply* rep = m_network->get(request);

View File

@ -1,8 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* PolyMC - Minecraft Launcher
* Prism Launcher - Minecraft Launcher
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -216,10 +217,16 @@ namespace Net {
}
request.setHeader(QNetworkRequest::UserAgentHeader, APPLICATION->getUserAgent().toUtf8());
if (APPLICATION->capabilities() & Application::SupportsFlame
&& request.url().host().contains("api.curseforge.com")) {
// TODO remove duplication
if (APPLICATION->capabilities() & Application::SupportsFlame && request.url().host() == QUrl(BuildConfig.FLAME_BASE_URL).host()) {
request.setRawHeader("x-api-key", APPLICATION->getFlameAPIKey().toUtf8());
} else if (request.url().host() == QUrl(BuildConfig.MODRINTH_PROD_URL).host() ||
request.url().host() == QUrl(BuildConfig.MODRINTH_STAGING_URL).host()) {
QString token = APPLICATION->getModrinthAPIToken();
if (!token.isNull())
request.setRawHeader("Authorization", token.toUtf8());
}
//TODO other types of post requests ?
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
QNetworkReply* rep = m_network->post(request, m_post_data);

View File

@ -184,7 +184,7 @@ void BlockedModsDialog::directoryChanged(QString path)
/// @brief add the user downloads folder and the global mods folder to the filesystem watcher
void BlockedModsDialog::setupWatch()
{
const QString downloadsFolder = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
const QString downloadsFolder = APPLICATION->settings()->get("DownloadsDir").toString();
const QString modsFolder = APPLICATION->settings()->get("CentralModsDir").toString();
m_watcher.addPath(downloadsFolder);
m_watcher.addPath(modsFolder);

View File

@ -1,9 +1,10 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* PolyMC - Minecraft Launcher
* Prism Launcher - Minecraft Launcher
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
* Copyright (c) 2022 Lenny McLennington <lenny@sneed.church>
* Copyright (C) 2023 TheKodeToad <TheKodeToad@proton.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -147,6 +148,8 @@ void APIPage::loadSettings()
ui->metaURL->setText(metaURL);
QString flameKey = s->get("FlameKeyOverride").toString();
ui->flameKey->setText(flameKey);
QString modrinthToken = s->get("ModrinthToken").toString();
ui->modrinthToken->setText(modrinthToken);
QString customUserAgent = s->get("UserAgentOverride").toString();
ui->userAgentLineEdit->setText(customUserAgent);
}
@ -177,6 +180,8 @@ void APIPage::applySettings()
s->set("MetaURLOverride", metaURL);
QString flameKey = ui->flameKey->text();
s->set("FlameKeyOverride", flameKey);
QString modrinthToken = ui->modrinthToken->text();
s->set("ModrinthToken", modrinthToken);
s->set("UserAgentOverride", ui->userAgentLineEdit->text());
}

View File

@ -195,6 +195,51 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_modrinth">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>&amp;Modrinth API</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Note: you only need to set this to access private data. Read the &lt;a href=&quot;https://docs.modrinth.com/api-spec/#section/Authentication&quot;&gt;documentation&lt;/a&gt; for more information.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Enter a custom API token for Modrinth here.</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLineEdit" name="modrinthToken">
<property name="enabled">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>(None)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_flame">
<property name="enabled">
@ -203,16 +248,16 @@
<property name="title">
<string>&amp;CurseForge Core API</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Note: you probably don't need to set this if CurseForge already works.</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Enter a custom API Key for CurseForge here.</string>
</property>

View File

@ -140,8 +140,8 @@ void LauncherPage::on_instDirBrowseBtn_clicked()
if (result == QMessageBox::Ok)
{
ui->instDirTextBox->setText(cooked_dir);
}
}
}
}
else
{
ui->instDirTextBox->setText(cooked_dir);
@ -160,6 +160,7 @@ void LauncherPage::on_iconsDirBrowseBtn_clicked()
ui->iconsDirTextBox->setText(cooked_dir);
}
}
void LauncherPage::on_modsDirBrowseBtn_clicked()
{
QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Mods Folder"), ui->modsDirTextBox->text());
@ -172,6 +173,17 @@ void LauncherPage::on_modsDirBrowseBtn_clicked()
}
}
void LauncherPage::on_downloadsDirBrowseBtn_clicked()
{
QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Downloads Folder"), ui->downloadsDirTextBox->text());
if (!raw_dir.isEmpty() && QDir(raw_dir).exists())
{
QString cooked_dir = FS::NormalizePath(raw_dir);
ui->downloadsDirTextBox->setText(cooked_dir);
}
}
void LauncherPage::on_metadataDisableBtn_clicked()
{
ui->metadataWarningLabel->setHidden(!ui->metadataDisableBtn->isChecked());
@ -204,6 +216,7 @@ void LauncherPage::applySettings()
s->set("InstanceDir", ui->instDirTextBox->text());
s->set("CentralModsDir", ui->modsDirTextBox->text());
s->set("IconsDir", ui->iconsDirTextBox->text());
s->set("DownloadsDir", ui->downloadsDirTextBox->text());
auto sortMode = (InstSortMode)ui->sortingModeGroup->checkedId();
switch (sortMode)
@ -260,6 +273,7 @@ void LauncherPage::loadSettings()
ui->instDirTextBox->setText(s->get("InstanceDir").toString());
ui->modsDirTextBox->setText(s->get("CentralModsDir").toString());
ui->iconsDirTextBox->setText(s->get("IconsDir").toString());
ui->downloadsDirTextBox->setText(s->get("DownloadsDir").toString());
QString sortMode = s->get("InstSortMode").toString();

View File

@ -88,6 +88,7 @@ slots:
void on_instDirBrowseBtn_clicked();
void on_modsDirBrowseBtn_clicked();
void on_iconsDirBrowseBtn_clicked();
void on_downloadsDirBrowseBtn_clicked();
void on_metadataDisableBtn_clicked();
/*!

View File

@ -38,7 +38,7 @@
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="featuresTab">
<attribute name="title">
@ -67,13 +67,6 @@
<string>Folders</string>
</property>
<layout class="QGridLayout" name="foldersBoxLayout">
<item row="1" column="2">
<widget class="QToolButton" name="modsDirBrowseBtn">
<property name="text">
<string notr="true">...</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="instDirBrowseBtn">
<property name="text">
@ -81,29 +74,12 @@
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="iconsDirBrowseBtn">
<property name="text">
<string notr="true">...</string>
</property>
</widget>
<item row="1" column="1">
<widget class="QLineEdit" name="modsDirTextBox"/>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="instDirTextBox"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelIconsDir">
<property name="text">
<string>&amp;Icons:</string>
</property>
<property name="buddy">
<cstring>iconsDirTextBox</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="modsDirTextBox"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="labelInstDir">
<property name="text">
@ -117,6 +93,20 @@
<item row="2" column="1">
<widget class="QLineEdit" name="iconsDirTextBox"/>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="iconsDirBrowseBtn">
<property name="text">
<string notr="true">...</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="modsDirBrowseBtn">
<property name="text">
<string notr="true">...</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelModsDir">
<property name="text">
@ -127,6 +117,36 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelIconsDir">
<property name="text">
<string>&amp;Icons:</string>
</property>
<property name="buddy">
<cstring>iconsDirTextBox</cstring>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelDownloadsDir">
<property name="text">
<string>&amp;Downloads:</string>
</property>
<property name="buddy">
<cstring>downloadsDirTextBox</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="downloadsDirTextBox"/>
</item>
<item row="3" column="2">
<widget class="QToolButton" name="downloadsDirBrowseBtn">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -273,3 +273,12 @@ bool CoreModFolderPage::shouldDisplay() const
}
return false;
}
NilModFolderPage::NilModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolderModel> mods, QWidget* parent)
: ModFolderPage(inst, mods, parent)
{}
bool NilModFolderPage::shouldDisplay() const
{
return m_model->dir().exists();
}

View File

@ -81,3 +81,16 @@ class CoreModFolderPage : public ModFolderPage {
virtual bool shouldDisplay() const override;
};
class NilModFolderPage : public ModFolderPage {
public:
explicit NilModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolderModel> mods, QWidget* parent = 0);
virtual ~NilModFolderPage() = default;
virtual QString displayName() const override { return tr("Nilmods"); }
virtual QIcon icon() const override { return APPLICATION->getThemedIcon("coremods"); }
virtual QString id() const override { return "nilmods"; }
virtual QString helpPage() const override { return "Nilmods"; }
virtual bool shouldDisplay() const override;
};

View File

@ -140,3 +140,11 @@ A TOML language parser. Used by Forge 1.14+ to store mod metadata.
See [github repo](https://github.com/marzer/tomlplusplus).
Licenced under the MIT licence.
## qdcss
A quick and dirty css parser, used by NilLoader to store mod metadata.
Translated (and heavily trimmed down) from [the original Java code](https://github.com/unascribed/NilLoader/blob/trunk/src/main/java/nilloader/api/lib/qdcss/QDCSS.java) from NilLoader
Licensed under LGPL version 3.

@ -1 +1 @@
Subproject commit cd6805e94dd5d6346be1b75a54cdc27787319dd2
Subproject commit 8a2edd6d92ed820521d42c94d179462bf06b5ed3

View File

@ -8,10 +8,10 @@
> Redistribution and use in source and binary forms, with or without
> modification, are permitted provided that the following conditions are met:
>
> * Redistributions of source code must retain the above copyright notice, this
> * Redistributions of source code must retain the above copyright notice, this
> list of conditions and the following disclaimer.
>
> * Redistributions in binary form must reproduce the above copyright notice,
> * Redistributions in binary form must reproduce the above copyright notice,
> this list of conditions and the following disclaimer in the documentation
> and/or other materials provided with the distribution.
>
@ -36,12 +36,12 @@ Cryptographic methods for Qt.
> Redistribution and use in source and binary forms, with or without
> modification, are permitted provided that the following conditions are met:
>
> * Redistributions of source code must retain the above copyright
> * Redistributions of source code must retain the above copyright
> notice, this list of conditions and the following disclaimer.
> * Redistributions in binary form must reproduce the above copyright
> * Redistributions in binary form must reproduce the above copyright
> notice, this list of conditions and the following disclaimer in the
> documentation and/or other materials provided with the distribution.
> * Neither the name of the Rathenau Instituut, Andre Somers nor the
> * Neither the name of the Rathenau Instituut, Andre Somers nor the
> names of its contributors may be used to endorse or promote products
> derived from this software without specific prior written permission.
>
@ -62,7 +62,7 @@ Configurable settings storage, Twitter XAuth specialization, new demos, cleanups
> "Hi Akos,
>
> I'm writing this mail to confirm that my contributions to the O2 library, available here https://github.com/pipacs/o2, can be freely distributed according to the project's license (as shown in the LICENSE file).
> I'm writing this mail to confirm that my contributions to the O2 library, available here <https://github.com/pipacs/o2>, can be freely distributed according to the project's license (as shown in the LICENSE file).
>
> Regards,
> -mandeep"

View File

@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 3.9.4)
project(qdcss)
if(QT_VERSION_MAJOR EQUAL 5)
find_package(Qt5 COMPONENTS Core REQUIRED)
elseif(Launcher_QT_VERSION_MAJOR EQUAL 6)
find_package(Qt6 COMPONENTS Core Core5Compat REQUIRED)
list(APPEND qdcss_LIBS Qt${QT_VERSION_MAJOR}::Core5Compat)
endif()
set(QDCSS_SOURCES
include/qdcss.h
src/qdcss.cpp
)
add_library(qdcss STATIC ${QDCSS_SOURCES})
target_include_directories(qdcss PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(qdcss Qt${QT_VERSION_MAJOR}::Core ${qdcss_LIBS})

72
libraries/qdcss/LICENSE Normal file
View File

@ -0,0 +1,72 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License.
"The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version".
The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.

View File

@ -0,0 +1,25 @@
// SPDX-FileCopyrightText: 2023 kumquat-ir 66188216+kumquat-ir@users.noreply.github.com
//
// SPDX-License-Identifier: LGPL-3.0-only
#ifndef QDCSS_H
#define QDCSS_H
#include <QMap>
#include <QString>
#include <QStringList>
#include <optional>
class QDCSS {
// these are all we need to parse a couple string values out of a css string
// lots more in the original code, yet to be ported
// https://github.com/unascribed/NilLoader/blob/trunk/src/main/java/nilloader/api/lib/qdcss/QDCSS.java
public:
QDCSS(QString);
std::optional<QString>* get(QString);
private:
QMap<QString, QStringList> m_data;
};
#endif // QDCSS_H

View File

@ -0,0 +1,53 @@
// SPDX-FileCopyrightText: 2023 kumquat-ir 66188216+kumquat-ir@users.noreply.github.com
//
// SPDX-License-Identifier: LGPL-3.0-only
#include "qdcss.h"
#include <QRegularExpression>
#include <QRegularExpressionMatch>
#include <QRegularExpressionMatchIterator>
QRegularExpression ruleset_re = QRegularExpression(R"([#.]?(@?\w+?)\s*\{(.*?)\})", QRegularExpression::DotMatchesEverythingOption);
QRegularExpression rule_re = QRegularExpression(R"((\S+?)\s*:\s*(?:\"(.*?)(?<!\\)\"|'(.*?)(?<!\\)'|(\S+?))\s*(?:;|$))");
QDCSS::QDCSS(QString s)
{
// not much error handling over here...
// the original java code used indeces returned by the matcher for them, but QRE does not expose those
QRegularExpressionMatchIterator ruleset_i = ruleset_re.globalMatch(s);
while (ruleset_i.hasNext()) {
QRegularExpressionMatch ruleset = ruleset_i.next();
QString selector = ruleset.captured(1);
QString rules = ruleset.captured(2);
QRegularExpressionMatchIterator rule_i = rule_re.globalMatch(rules);
while (rule_i.hasNext()) {
QRegularExpressionMatch rule = rule_i.next();
QString property = rule.captured(1);
QString value;
if (!rule.captured(2).isNull()) {
value = rule.captured(2);
} else if (!rule.captured(3).isNull()) {
value = rule.captured(3);
} else {
value = rule.captured(4);
}
QString key = selector + "." + property;
if (!m_data.contains(key)) {
m_data.insert(key, QStringList());
}
m_data.find(key)->append(value);
}
}
}
std::optional<QString>* QDCSS::get(QString key)
{
auto found = m_data.find(key);
if (found == m_data.end() || found->empty()) {
return new std::optional<QString>;
}
return new std::optional<QString>(found->back());
}

@ -1 +1 @@
Subproject commit 0a90913abf9390b9e08ab6d3b40ac11634553f38
Subproject commit 7eb2ffcc09f8e9890dc0b77ff8ab00fc53b1f2b8

View File

@ -1,52 +1,54 @@
{ lib
, stdenv
, cmake
, jdk8
, jdk17
, zlib
, file
, wrapQtAppsHook
, xorg
, libpulseaudio
, qtbase
, qtsvg
, qtwayland
, libGL
, quazip
, glfw
, openal
, extra-cmake-modules
, tomlplusplus
, ghc_filesystem
, cmark
, msaClientID ? ""
, jdks ? [ jdk17 jdk8 ]
{
lib,
stdenv,
cmake,
jdk8,
jdk17,
zlib,
file,
wrapQtAppsHook,
xorg,
libpulseaudio,
qtbase,
qtsvg,
qtwayland,
libGL,
quazip,
glfw,
openal,
extra-cmake-modules,
tomlplusplus,
ghc_filesystem,
cmark,
msaClientID ? "",
jdks ? [jdk17 jdk8],
# flake
, self
, version
, libnbtplusplus
self,
version,
libnbtplusplus,
}:
stdenv.mkDerivation rec {
pname = "prismlauncher";
inherit version;
src = lib.cleanSource self;
nativeBuildInputs = [ extra-cmake-modules cmake file jdk17 wrapQtAppsHook ];
buildInputs = [
qtbase
qtsvg
zlib
quazip
ghc_filesystem
tomlplusplus
cmark
] ++ lib.optional (lib.versionAtLeast qtbase.version "6") qtwayland;
nativeBuildInputs = [extra-cmake-modules cmake file jdk17 wrapQtAppsHook];
buildInputs =
[
qtbase
qtsvg
zlib
quazip
ghc_filesystem
tomlplusplus
cmark
]
++ lib.optional (lib.versionAtLeast qtbase.version "6") qtwayland;
cmakeFlags = lib.optionals (msaClientID != "") [ "-DLauncher_MSA_CLIENT_ID=${msaClientID}" ]
++ lib.optionals (lib.versionAtLeast qtbase.version "6") [ "-DLauncher_QT_VERSION_MAJOR=6" ];
cmakeFlags =
lib.optionals (msaClientID != "") ["-DLauncher_MSA_CLIENT_ID=${msaClientID}"]
++ lib.optionals (lib.versionOlder qtbase.version "6") ["-DLauncher_QT_VERSION_MAJOR=5"];
dontWrapQtApps = true;
postUnpack = ''
@ -57,30 +59,27 @@ stdenv.mkDerivation rec {
chown -R $USER: source/libraries/libnbtplusplus
'';
postInstall =
let
libpath = with xorg;
lib.makeLibraryPath [
libX11
libXext
libXcursor
libXrandr
libXxf86vm
libpulseaudio
libGL
glfw
openal
stdenv.cc.cc.lib
];
in
''
# xorg.xrandr needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128
wrapQtApp $out/bin/prismlauncher \
--set LD_LIBRARY_PATH /run/opengl-driver/lib:${libpath} \
--prefix PRISMLAUNCHER_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks} \
--prefix PATH : ${lib.makeBinPath [xorg.xrandr]}
'';
postInstall = let
libpath = with xorg;
lib.makeLibraryPath [
libX11
libXext
libXcursor
libXrandr
libXxf86vm
libpulseaudio
libGL
glfw
openal
stdenv.cc.cc.lib
];
in ''
# xorg.xrandr needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128
wrapQtApp $out/bin/prismlauncher \
--set LD_LIBRARY_PATH /run/opengl-driver/lib:${libpath} \
--prefix PRISMLAUNCHER_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks} \
--prefix PATH : ${lib.makeBinPath [xorg.xrandr]}
'';
meta = with lib; {
homepage = "https://prismlauncher.org/";
@ -93,6 +92,6 @@ stdenv.mkDerivation rec {
platforms = platforms.linux;
changelog = "https://github.com/PrismLauncher/PrismLauncher/releases/tag/${version}";
license = licenses.gpl3Only;
maintainers = with maintainers; [ minion3665 Scrumplex ];
maintainers = with maintainers; [minion3665 Scrumplex];
};
}

View File

@ -6,4 +6,4 @@ let
sha256 = narHash;
};
in
import flake-compat { src = ../.; }
import flake-compat {src = ../.;}

View File

@ -114,7 +114,8 @@ VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "@Launcher_VERSION_NAME4@
;--------------------------------
; Shell Associate Macros
!macro APP_SETUP DESCRIPTION ICON APP_ID APP_NAME APP_EXE COMMANDTEXT COMMAND ; VERB APP_COMPANY
!macro APP_SETUP_Def DESCRIPTION ICON APP_ID APP_NAME APP_EXE COMMANDTEXT COMMAND
; setup APP_ID
WriteRegStr ShCtx "Software\Classes\${APP_ID}" "" `${DESCRIPTION}`
WriteRegStr ShCtx "Software\Classes\${APP_ID}\DefaultIcon" "" `${ICON}`
@ -123,24 +124,28 @@ VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "@Launcher_VERSION_NAME4@
WriteRegStr ShCtx "Software\Classes\${APP_ID}\shell\open" "" `${COMMANDTEXT}`
WriteRegStr ShCtx "Software\Classes\${APP_ID}\shell\open\command" "" `${COMMAND}`
; if you want the app to use it's own implementation of a verb
;WriteRegStr ShCtx "Software\Classes\${APP_ID}\shell\${VERB}" "" "${DESCRIPTION}"
;WriteRegStr ShCtx "Software\Classes\${APP_ID}\shell\${VERB}\command" "" `${COMMAND}`
WriteRegStr ShCtx "Software\Classes\Applications\${APP_EXE}\shell\open\command" "" `${COMMAND}`
WriteRegStr ShCtx "Software\Classes\Applications\${APP_EXE}" "FriendlyAppName" `${APP_NAME}` ; [Optional]
;WriteRegStr ShCtx "Software\Classes\Applications\${APP_EXE}" "ApplicationCompany" `${APP_COMPANY}` ; [Optional]
;WriteRegNone ShCtx "Software\Classes\Applications\${APP_EXE}\SupportedTypes" ".${EXT}" ; [Optional] Only allow "Open With" with specific extension(s) on WinXP+
# Register "Default Programs" [Optional]
!ifdef REGISTER_DEFAULTPROGRAMS
WriteRegStr ShCtx "Software\Classes\Applications\${APP_EXE}\Capabilities" "ApplicationDescription" `${DESCRIPTION}`
WriteRegStr ShCtx "Software\RegisteredApplications" `${APP_NAME}` "Software\Classes\Applications\${APP_EXE}\Capabilities"
!endif
!macroend
!macro APP_ASSOCIATE EXT APP_ID APP_EXE OVERWIRTE
!macro APP_SETUP DESCRIPTION ICON APP_ID APP_NAME APP_EXE COMMANDTEXT COMMAND
!insertmacro APP_SETUP_Def `${DESCRIPTION}` `${ICON}` `${APP_ID}` `${APP_NAME}` `${APP_EXE}` `${COMMANDTEXT}` `${COMMAND}`
!macroend
!macro APP_SETUP_DEFAULT DESCRIPTION ICON APP_ID APP_NAME APP_EXE COMMANDTEXT COMMAND
!insertmacro APP_SETUP_Def `${DESCRIPTION}` `${ICON}` `${APP_ID}` `${APP_NAME}` `${APP_EXE}` `${COMMANDTEXT}` `${COMMAND}`
# Register "Default Programs"
WriteRegStr ShCtx "Software\Classes\Applications\${APP_EXE}\Capabilities" "ApplicationDescription" `${DESCRIPTION}`
WriteRegStr ShCtx "Software\RegisteredApplications" `${APP_NAME}` "Software\Classes\Applications\${APP_EXE}\Capabilities"
!macroend
!macro APP_ASSOCIATE_Def EXT APP_ID APP_EXE OVERWIRTE
; Backup the previously associated file class
${If} ${OVERWIRTE} == true
ReadRegStr $R0 ShCtx "Software\Classes\${EXT}" ""
@ -151,10 +156,20 @@ VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "@Launcher_VERSION_NAME4@
WriteRegNone ShCtx "Software\Classes\${EXT}\OpenWithList" "${APP_EXE}" ; Win2000+
WriteRegNone ShCtx "Software\Classes\${EXT}\OpenWithProgids" "${APP_ID}" ; WinXP+
# Register "Default Programs" [Optional]
!ifdef REGISTER_DEFAULTPROGRAMS
!macroend
!macro APP_ASSOCIATE EXT APP_ID APP_EXE OVERWIRTE
!insertmacro APP_ASSOCIATE_Def `${EXT}` `${APP_ID}` `${APP_EXE}` `${OVERWIRTE}`
!macroend
!macro APP_ASSOCIATE_DEFAULT EXT APP_ID APP_EXE OVERWIRTE
!insertmacro APP_ASSOCIATE_Def `${EXT}` `${APP_ID}` `${APP_EXE}` `${OVERWIRTE}`
# Register "Default Programs"
WriteRegStr ShCtx "Software\Classes\Applications\${APP_EXE}\Capabilities\FileAssociations" "${EXT}" "${APP_ID}"
!endif
!macroend
@ -191,12 +206,10 @@ VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "@Launcher_VERSION_NAME4@
DeleteRegKey /IfEmpty HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\${EXT}\OpenWithProgids"
DeleteRegKey /IfEmpty HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\${EXT}\OpenWithList"
DeleteRegKey /IfEmpty HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\${EXT}"
;DeleteRegKey HKCU "Software\Microsoft\Windows\Roaming\OpenWith\FileExts\.${EXT}"
;DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\.${EXT}"
!macroend
!macro APP_TEARDOWN APP_ID APP_NAME APP_EXE
!macro APP_TEARDOWN_Def APP_ID APP_NAME APP_EXE
# Unregister file type
ClearErrors
@ -208,13 +221,6 @@ VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "@Launcher_VERSION_NAME4@
# Unregister "Open With"
DeleteRegKey ShCtx "Software\Classes\Applications\${APP_EXE}"
# Unregister "Default Programs"
!ifdef REGISTER_DEFAULTPROGRAMS
DeleteRegValue ShCtx "Software\RegisteredApplications" `${APP_NAME}`
DeleteRegKey ShCtx "Software\Classes\Applications\${APP_EXE}\Capabilities"
DeleteRegKey /IfEmpty ShCtx "Software\Classes\Applications\${APP_EXE}"
!endif
DeleteRegKey ShCtx `Software\Classes\${APP_ID}`
DeleteRegKey ShCtx "Software\Classes\Applications\${APP_EXE}"
@ -227,6 +233,23 @@ VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "@Launcher_VERSION_NAME4@
!macroend
!macro APP_TEARDOWN APP_ID APP_NAME APP_EXE
!insertmacro APP_TEARDOWN_Def `${APP_ID}` `${APP_NAME}` `${APP_EXE}`
!macroend
!macro APP_TEARDOWN_DEFAULT APP_ID APP_NAME APP_EXE
!insertmacro APP_TEARDOWN_Def `${APP_ID}` `${APP_NAME}` `${APP_EXE}`
# Unregister "Default Programs"
DeleteRegValue ShCtx "Software\RegisteredApplications" `${APP_NAME}`
DeleteRegKey ShCtx "Software\Classes\Applications\${APP_EXE}\Capabilities"
DeleteRegKey /IfEmpty ShCtx "Software\Classes\Applications\${APP_EXE}"
!macroend
; !defines for use with SHChangeNotify
!ifdef SHCNE_ASSOCCHANGED
!undef SHCNE_ASSOCCHANGED
@ -308,21 +331,19 @@ Section /o "Desktop Shortcut" DESKTOP_SHORTCUTS
SectionEnd
!define APP_ID "@Launcher_CommonName@.App"
!define APP_EXE "@Launcher_APP_BINARY_NAME@.exe"
!define APP_ICON "$INSTDIR\${APP_EXE},0"
!define APP_DESCRIPTION "@Launcher_DisplayName@"
!define APP_NAME "@Launcher_DisplayName@"
!define APP_CMD_TEXT "Minecraft Modpack"
!define APPID "@Launcher_CommonName@.App"
!define APPEXE "@Launcher_APP_BINARY_NAME@.exe"
!define APPICON "$INSTDIR\${APPEXE},0"
!define APPDESCRIPTION "@Launcher_DisplayName@"
!define APPNAME "@Launcher_DisplayName@"
!define APPCMDTEXT "@Launcher_DisplayName@"
!define REGISTER_DEFAULTPROGRAMS ; value doesn't matter
Section /o "Shell Association (Open-With dialog)" SHELL_ASSOC
Section -ShellAssoc
!insertmacro APP_SETUP `${APP_DESCRIPTION}` `${APP_ICON}` `${APP_ID}` `${APP_CMD_TEXT}` `${APP_EXE}` `${APP_CMD_TEXT}` '$INSTDIR\${APP_EXE} -I "%1"'
!insertmacro APP_SETUP `${APPDESCRIPTION}` `${APPICON}` `${APPID}` `${APPCMDTEXT}` `${APPEXE}` `${APPCMDTEXT}` '$INSTDIR\${APPEXE} -I "%1"'
!insertmacro APP_ASSOCIATE ".zip" `${APP_ID}` `${APP_EXE}` false
!insertmacro APP_ASSOCIATE ".mrpack" `${APP_ID}` `${APP_EXE}` true
!insertmacro APP_ASSOCIATE_DEFAULT ".mrpack" `${APPID}` `${APPEXE}` true
!insertmacro APP_ASSOCIATE ".zip" `${APPID}` `${APPEXE}` false
!insertmacro NotifyShell_AssocChanged
SectionEnd
@ -361,10 +382,10 @@ SectionEnd
Section -un.ShellAssoc
!insertmacro APP_TEARDOWN `${APP_ID}` `${APP_NAME}` `${APP_EXE}`
!insertmacro APP_TEARDOWN_DEFAULT `${APPID}` `${APPNAME}` `${APPEXE}`
!insertmacro APP_UNASSOCIATE ".zip" `${APP_ID}`
!insertmacro APP_UNASSOCIATE ".mrpack" `${APP_ID}`
!insertmacro APP_UNASSOCIATE ".zip" `${APPID}`
!insertmacro APP_UNASSOCIATE ".mrpack" `${APPID}`
!insertmacro NotifyShell_AssocChanged
SectionEnd

View File

@ -1,55 +0,0 @@
name: prismlauncher
license: GPL-3.0-only
base: core20
website: https://prismlauncher.org/
source-code: https://github.com/PrismLauncher/PrismLauncher
issues: https://github.com/PrismLauncher/PrismLauncher/issues
donation: https://opencollective.com/prismlauncher
contact: https://discord.gg/prismlauncher
summary: A custom Minecraft launcher with modpack support
adopt-info: prismlauncher
grade: devel
confinement: strict
architectures:
- build-on: amd64
- build-on: arm64
parts:
prismlauncher:
parse-info:
- usr/share/metainfo/org.prismlauncher.PrismLauncher.metainfo.xml
plugin: cmake
build-packages:
- default-jdk-headless
stage-packages:
- openjdk-17-jre
- openjdk-8-jre
source: .
override-pull: |
snapcraftctl pull
# Fix the icon reference in the desktop file
sed -i.bak -e 's|Icon=org.prismlauncher.PrismLauncher|Icon=/usr/share/icons/hicolor/scalable/apps/org.prismlauncher.PrismLauncher.svg|g' program_info/org.prismlauncher.PrismLauncher.desktop.in
# Remove the build directory so that local development doesn't interfere with Snap compilation
rm -rf build
cmake-generator: Ninja
cmake-parameters:
- "-DCMAKE_INSTALL_PREFIX=/usr"
- "-DCMAKE_BUILD_TYPE=RelWithDebInfo"
- "-DENABLE_LTO=ON"
- "-DLauncher_BUILD_PLATFORM=snap"
apps:
prismlauncher:
common-id: org.prismlauncher.PrismLauncher
desktop: usr/share/applications/org.prismlauncher.PrismLauncher.desktop
command: usr/bin/prismlauncher
extensions:
- kde-neon
plugs:
- home
- opengl
- network
- network-bind
- audio-playback