aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/ISSUE_TEMPLATE/bug_report.yml4
-rw-r--r--.github/ISSUE_TEMPLATE/rfc.yml5
-rw-r--r--.github/ISSUE_TEMPLATE/suggestion.yml2
-rw-r--r--.github/workflows/backport.yml4
-rw-r--r--.github/workflows/build.yml51
-rw-r--r--.github/workflows/pr-comment.yml61
-rw-r--r--.github/workflows/trigger_builds.yml10
-rw-r--r--.github/workflows/trigger_release.yml93
-rw-r--r--.gitignore4
-rw-r--r--CMakeLists.txt10
-rw-r--r--README.md20
-rw-r--r--buildconfig/BuildConfig.h6
-rw-r--r--cmake/UnitTest.cmake66
-rw-r--r--flake.lock30
-rw-r--r--flake.nix74
-rw-r--r--launcher/Application.cpp14
-rw-r--r--launcher/Application.h2
-rw-r--r--launcher/CMakeLists.txt62
-rw-r--r--launcher/DesktopServices.cpp82
-rw-r--r--launcher/InstanceImportTask.cpp9
-rw-r--r--launcher/InstanceImportTask.h3
-rw-r--r--launcher/JavaCommon.cpp11
-rw-r--r--launcher/LaunchController.cpp11
-rw-r--r--launcher/java/JavaChecker.cpp2
-rw-r--r--launcher/java/JavaInstallList.cpp2
-rw-r--r--launcher/java/JavaUtils.cpp4
-rw-r--r--launcher/launch/LaunchTask.cpp44
-rw-r--r--launcher/launch/steps/CheckJava.cpp50
-rw-r--r--launcher/launch/steps/QuitAfterGameStop.cpp26
-rw-r--r--launcher/launch/steps/QuitAfterGameStop.h35
-rw-r--r--launcher/minecraft/Agent.h36
-rw-r--r--launcher/minecraft/ComponentUpdateTask.cpp2
-rw-r--r--launcher/minecraft/LaunchProfile.cpp78
-rw-r--r--launcher/minecraft/LaunchProfile.h54
-rw-r--r--launcher/minecraft/MinecraftInstance.cpp56
-rw-r--r--launcher/minecraft/MojangVersionFormat.cpp44
-rw-r--r--launcher/minecraft/OneSixVersionFormat.cpp24
-rw-r--r--launcher/minecraft/PackProfile.cpp17
-rw-r--r--launcher/minecraft/PackProfile.h3
-rw-r--r--launcher/minecraft/VersionFile.cpp41
-rw-r--r--launcher/minecraft/VersionFile.h45
-rw-r--r--launcher/minecraft/World.cpp23
-rw-r--r--launcher/minecraft/World.h5
-rw-r--r--launcher/minecraft/WorldList.cpp18
-rw-r--r--launcher/minecraft/WorldList.h4
-rw-r--r--launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp2
-rw-r--r--launcher/minecraft/launch/LauncherPartLaunch.cpp1
-rw-r--r--launcher/minecraft/launch/VerifyJavaInstall.cpp109
-rw-r--r--launcher/minecraft/launch/VerifyJavaInstall.h36
-rw-r--r--launcher/minecraft/mod/LocalModParseTask.cpp2
-rw-r--r--launcher/minecraft/update/LibrariesTask.cpp4
-rw-r--r--launcher/modplatform/ModAPI.h56
-rw-r--r--launcher/modplatform/ModIndex.h42
-rw-r--r--launcher/modplatform/flame/FlameAPI.h32
-rw-r--r--launcher/modplatform/flame/FlameModIndex.cpp63
-rw-r--r--launcher/modplatform/flame/FlameModIndex.h50
-rw-r--r--launcher/modplatform/helpers/NetworkModAPI.cpp60
-rw-r--r--launcher/modplatform/helpers/NetworkModAPI.h13
-rw-r--r--launcher/modplatform/modrinth/ModrinthAPI.h66
-rw-r--r--launcher/modplatform/modrinth/ModrinthPackIndex.cpp71
-rw-r--r--launcher/modplatform/modrinth/ModrinthPackIndex.h50
-rw-r--r--launcher/modplatform/technic/SolderPackInstallTask.cpp137
-rw-r--r--launcher/modplatform/technic/SolderPackInstallTask.h47
-rw-r--r--launcher/modplatform/technic/SolderPackManifest.cpp58
-rw-r--r--launcher/modplatform/technic/SolderPackManifest.h49
-rw-r--r--launcher/resources/multimc/scalable/discord.svg117
-rw-r--r--launcher/resources/pe_light/scalable/launcher.svg18
-rw-r--r--launcher/tasks/SequentialTask.cpp50
-rw-r--r--launcher/tasks/SequentialTask.h28
-rw-r--r--launcher/tasks/Task.h68
-rw-r--r--launcher/tasks/Task_test.cpp68
-rw-r--r--launcher/ui/dialogs/AboutDialog.cpp78
-rw-r--r--launcher/ui/dialogs/AboutDialog.ui11
-rw-r--r--launcher/ui/dialogs/ProgressDialog.cpp22
-rw-r--r--launcher/ui/dialogs/ProgressDialog.h5
-rw-r--r--launcher/ui/dialogs/ProgressDialog.ui45
-rw-r--r--launcher/ui/dialogs/UpdateDialog.ui2
-rw-r--r--launcher/ui/pages/global/AccountListPage.cpp7
-rw-r--r--launcher/ui/pages/global/JavaPage.cpp3
-rw-r--r--launcher/ui/pages/global/JavaPage.ui16
-rw-r--r--launcher/ui/pages/global/LauncherPage.cpp23
-rw-r--r--launcher/ui/pages/global/MinecraftPage.cpp2
-rw-r--r--launcher/ui/pages/global/MinecraftPage.ui14
-rw-r--r--launcher/ui/pages/instance/InstanceSettingsPage.cpp4
-rw-r--r--launcher/ui/pages/instance/InstanceSettingsPage.ui10
-rw-r--r--launcher/ui/pages/instance/ModFolderPage.cpp44
-rw-r--r--launcher/ui/pages/instance/VersionPage.cpp35
-rw-r--r--launcher/ui/pages/instance/VersionPage.h1
-rw-r--r--launcher/ui/pages/instance/VersionPage.ui9
-rw-r--r--launcher/ui/pages/modplatform/ModModel.cpp231
-rw-r--r--launcher/ui/pages/modplatform/ModModel.h84
-rw-r--r--launcher/ui/pages/modplatform/ModPage.cpp171
-rw-r--r--launcher/ui/pages/modplatform/ModPage.h69
-rw-r--r--launcher/ui/pages/modplatform/ModPage.ui (renamed from launcher/ui/pages/modplatform/modrinth/ModrinthPage.ui)4
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModModel.cpp268
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModModel.h78
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModPage.cpp240
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModPage.h72
-rw-r--r--launcher/ui/pages/modplatform/flame/FlameModPage.ui97
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp289
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthModel.h80
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp227
-rw-r--r--launcher/ui/pages/modplatform/modrinth/ModrinthPage.h72
-rw-r--r--launcher/ui/pages/modplatform/technic/TechnicData.h46
-rw-r--r--launcher/ui/pages/modplatform/technic/TechnicModel.cpp130
-rw-r--r--launcher/ui/pages/modplatform/technic/TechnicModel.h44
-rw-r--r--launcher/ui/pages/modplatform/technic/TechnicPage.cpp143
-rw-r--r--launcher/ui/pages/modplatform/technic/TechnicPage.h11
-rw-r--r--launcher/ui/pages/modplatform/technic/TechnicPage.ui132
-rw-r--r--launcher/ui/widgets/CustomCommands.ui2
-rw-r--r--packages/nix/polymc/default.nix17
-rw-r--r--program_info/CMakeLists.txt1
-rw-r--r--program_info/LICENSE57
-rw-r--r--program_info/polymc.6.txt (renamed from doc/polymc.1.txt)4
114 files changed, 3197 insertions, 2247 deletions
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index eb560f0e..1ede3f74 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -1,6 +1,6 @@
name: Bug Report
description: File a bug report
-labels: [bug, needs-triage]
+labels: [bug]
body:
- type: markdown
attributes:
@@ -8,7 +8,7 @@ body:
If you need help with running Minecraft, please visit us on our Discord before making a bug report.
Before submitting a bug report, please make sure you have read this *entire* form, and that:
- * You have read the [FAQ](https://github.com/PolyMC/PolyMC/wiki/FAQ) and it has not answered your question
+ * You have read the [PolyMC wiki](https://polymc.org/wiki/) and it has not answered your question.
* Your bug is not caused by Minecraft or any mods you have installed.
* Your issue has not been reported before, [make sure to use the search function!](https://github.com/PolyMC/PolyMC/issues)
diff --git a/.github/ISSUE_TEMPLATE/rfc.yml b/.github/ISSUE_TEMPLATE/rfc.yml
index 664430fe..0a40d01d 100644
--- a/.github/ISSUE_TEMPLATE/rfc.yml
+++ b/.github/ISSUE_TEMPLATE/rfc.yml
@@ -1,7 +1,7 @@
# Template based on https://gitlab.archlinux.org/archlinux/rfcs/-/blob/0ba3b61e987e197f8d1901709409b8564958f78a/rfcs/0000-template.rst
name: Request for Comment (RFC)
description: Propose a larger change and start a discussion.
-labels: [RFC]
+labels: [rfc]
body:
- type: markdown
attributes:
@@ -21,8 +21,7 @@ body:
Introduce the topic. If this is a not-well-known section of PolyMC, a detailed explanation of the background is recommended.
Some example points of discussion:
- What specific problems are you facing right now that you're trying to address?
- - Are there any previous discussions? Link to them and summarize them (don't
- - force your readers to read them though!).
+ - Are there any previous discussions? Link to them and summarize them (don't force your readers to read them though!).
- Is there any precedent set by other software? If so, link to resources.
placeholder: I don't like cats. I think many users also don't like cats.
validations:
diff --git a/.github/ISSUE_TEMPLATE/suggestion.yml b/.github/ISSUE_TEMPLATE/suggestion.yml
index b58a6672..48f157b3 100644
--- a/.github/ISSUE_TEMPLATE/suggestion.yml
+++ b/.github/ISSUE_TEMPLATE/suggestion.yml
@@ -1,6 +1,6 @@
name: Suggestion
description: Make a suggestion
-labels: [idea, needs-triage]
+labels: [enhancement]
body:
- type: markdown
attributes:
diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml
index e1a7cffa..fa287a2c 100644
--- a/.github/workflows/backport.yml
+++ b/.github/workflows/backport.yml
@@ -9,7 +9,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout
- uses: actions/checkout@v1
+ uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
- name: Backport PR by cherry-pick-ing
uses: Nathanmalnoury/gh-backport-action@master
with:
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 1a4e0a25..0123c99a 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -16,8 +16,9 @@ jobs:
include:
- os: ubuntu-20.04
- qt_version: 5.12.8
- qt_host: linux
+
+ - os: ubuntu-20.04
+ portable: true
- os: ubuntu-20.04
qt_version: 5.15.2
@@ -27,12 +28,10 @@ jobs:
- os: windows-2022
name: "Windows-i686"
msystem: mingw32
- portable: false
- os: windows-2022
name: "Windows-x86_64"
msystem: mingw64
- portable: false
- os: windows-2022
name: "Windows-i686-portable"
@@ -58,7 +57,7 @@ jobs:
steps:
- name: Checkout
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
with:
submodules: 'true'
@@ -91,7 +90,7 @@ jobs:
- name: Cache Qt
if: runner.os != 'Windows'
id: cache-qt
- uses: actions/cache@v2
+ uses: actions/cache@v3
with:
path: "${{ github.workspace }}/Qt/"
key: ${{ runner.os }}-${{ matrix.qt_version }}-${{ matrix.qt_arch }}-qt_cache
@@ -140,7 +139,6 @@ jobs:
run: |
cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_PORTABLE=OFF -G Ninja
-
- name: Configure CMake on Windows portable
if: runner.os == 'Windows' && matrix.portable == true
shell: msys2 {0}
@@ -148,10 +146,15 @@ jobs:
cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -G Ninja
- name: Configure CMake on Linux
- if: runner.os == 'Linux'
+ if: runner.os == 'Linux' && matrix.portable != true
run: |
cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DLauncher_PORTABLE=OFF -DENABLE_LTO=ON -G Ninja
+ - name: Configure CMake on Linux Portable
+ if: runner.os == 'Linux' && matrix.portable == true
+ run: |
+ cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -G Ninja
+
- name: Build
if: runner.os != 'Windows'
run: |
@@ -175,10 +178,15 @@ jobs:
cmake --install ${{ env.BUILD_DIR }}
- name: Install on Linux
- if: runner.os == 'Linux'
+ if: runner.os == 'Linux' && matrix.portable != true
run: |
DESTDIR=${{ env.INSTALL_DIR }} cmake --install ${{ env.BUILD_DIR }}
+ - name: Install on Linux portable
+ if: runner.os == 'Linux' && matrix.portable == true
+ run: |
+ cmake --install ${{ env.BUILD_DIR }}
+
- name: Bundle AppImage
if: matrix.app_image == true
shell: bash
@@ -219,21 +227,34 @@ jobs:
tar -czf ../PolyMC.tar.gz *
- name: tar on Linux
- if: runner.os == 'Linux' && matrix.app_image != true
+ if: runner.os == 'Linux' && matrix.app_image != true && matrix.portable != true
run: |
cd ${{ env.INSTALL_DIR }}
tar -czf ../PolyMC.tar.gz *
+ - name: tar on Linux portable
+ if: runner.os == 'Linux' && matrix.app_image != true && matrix.portable == true
+ run: |
+ cd ${{ env.INSTALL_DIR }}
+ tar -czf ../PolyMC-portable.tar.gz *
+
- name: Upload Linux tar.gz
- if: runner.os == 'Linux' && matrix.app_image != true
- uses: actions/upload-artifact@v2
+ if: runner.os == 'Linux' && matrix.app_image != true && matrix.portable != true
+ uses: actions/upload-artifact@v3
with:
name: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}
path: PolyMC.tar.gz
+ - name: Upload Linux Portable tar.gz
+ if: runner.os == 'Linux' && matrix.app_image != true && matrix.portable == true
+ uses: actions/upload-artifact@v3
+ with:
+ name: PolyMC-${{ runner.os }}-Portable-${{ env.VERSION }}-${{ inputs.build_type }}
+ path: PolyMC-portable.tar.gz
+
- name: Upload AppImage for Linux
if: matrix.app_image == true
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage
path: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage
@@ -254,14 +275,14 @@ jobs:
- name: Upload package for Windows
if: runner.os == 'Windows'
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: PolyMC-${{ matrix.name }}-${{ env.VERSION }}-${{ inputs.build_type }}
path: ${{ env.INSTALL_DIR }}/**
- name: Upload package for macOS
if: runner.os == 'macOS'
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v3
with:
name: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}
path: PolyMC.tar.gz
diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml
new file mode 100644
index 00000000..7e8e4d99
--- /dev/null
+++ b/.github/workflows/pr-comment.yml
@@ -0,0 +1,61 @@
+name: Comment on pull request
+on:
+ workflow_run:
+ workflows: ['Test workflow with upload']
+ types: [completed]
+jobs:
+ pr_comment:
+ if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/github-script@v5
+ with:
+ # This snippet is public-domain, taken from
+ # https://github.com/oprypin/nightly.link/blob/master/.github/workflows/pr-comment.yml
+ script: |
+ async function upsertComment(owner, repo, issue_number, purpose, body) {
+ const {data: comments} = await github.rest.issues.listComments(
+ {owner, repo, issue_number});
+
+ const marker = `<!-- bot: ${purpose} -->`;
+ body = marker + "\n" + body;
+
+ const existing = comments.filter((c) => c.body.includes(marker));
+ if (existing.length > 0) {
+ const last = existing[existing.length - 1];
+ core.info(`Updating comment ${last.id}`);
+ await github.rest.issues.updateComment({
+ owner, repo,
+ body,
+ comment_id: last.id,
+ });
+ } else {
+ core.info(`Creating a comment in issue / PR #${issue_number}`);
+ await github.rest.issues.createComment({issue_number, body, owner, repo});
+ }
+ }
+
+ const {owner, repo} = context.repo;
+ const run_id = ${{github.event.workflow_run.id}};
+
+ const pull_requests = ${{ toJSON(github.event.workflow_run.pull_requests) }};
+ if (!pull_requests.length) {
+ return core.error("This workflow doesn't match any pull requests!");
+ }
+
+ const artifacts = await github.paginate(
+ github.rest.actions.listWorkflowRunArtifacts, {owner, repo, run_id});
+ if (!artifacts.length) {
+ return core.error(`No artifacts found`);
+ }
+ let body = `Download the artifacts for this pull request:\n`;
+ for (const art of artifacts) {
+ body += `\n* [${art.name}.zip](https://nightly.link/${owner}/${repo}/actions/artifacts/${art.id}.zip)`;
+ }
+
+ core.info("Review thread message body:", body);
+
+ for (const pr of pull_requests) {
+ await upsertComment(owner, repo, pr.number,
+ "nightly-link", body);
+ }
diff --git a/.github/workflows/trigger_builds.yml b/.github/workflows/trigger_builds.yml
index 1561b9d6..3ec6bb95 100644
--- a/.github/workflows/trigger_builds.yml
+++ b/.github/workflows/trigger_builds.yml
@@ -9,12 +9,16 @@ on:
- '**/LICENSE'
- 'flake.lock'
- '**.nix'
+ - 'packages/**'
+ - '.github/ISSUE_TEMPLATE/**'
pull_request:
paths-ignore:
- '**.md'
- '**/LICENSE'
- 'flake.lock'
- '**.nix'
+ - 'packages/**'
+ - '.github/ISSUE_TEMPLATE/**'
workflow_dispatch:
jobs:
@@ -24,9 +28,3 @@ jobs:
uses: ./.github/workflows/build.yml
with:
build_type: Debug
-
- build_release:
- name: Build Release
- uses: ./.github/workflows/build.yml
- with:
- build_type: Release
diff --git a/.github/workflows/trigger_release.yml b/.github/workflows/trigger_release.yml
index b487e731..149cb632 100644
--- a/.github/workflows/trigger_release.yml
+++ b/.github/workflows/trigger_release.yml
@@ -19,81 +19,52 @@ jobs:
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- - name: Grab and store version
- run: |
- tag_name=$(echo ${{ github.ref }} | grep -oE "[^/]+$")
- echo "VERSION=$tag_name" >> $GITHUB_ENV
- - name: Create release
- id: create_release
- uses: softprops/action-gh-release@v1
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ - name: Checkout
+ uses: actions/checkout@v3
with:
- tag_name: ${{ github.ref }}
- name: PolyMC ${{ env.VERSION }}
- draft: true
- prerelease: false
-
- upload_release:
- needs: create_release
- runs-on: ubuntu-latest
- steps:
-
+ submodules: 'true'
+ path: 'PolyMC-source'
- name: Download artifacts
- uses: actions/download-artifact@v2
-
+ uses: actions/download-artifact@v3
- name: Grab and store version
run: |
tag_name=$(echo ${{ github.ref }} | grep -oE "[^/]+$")
echo "VERSION=$tag_name" >> $GITHUB_ENV
-
- name: Package artifacts properly
run: |
+ mv ${{ github.workspace }}/PolyMC-source PolyMC-${{ env.VERSION }}
mv PolyMC-Linux*/PolyMC.tar.gz PolyMC-Linux-${{ env.VERSION }}.tar.gz
mv PolyMC-*.AppImage/PolyMC-*.AppImage PolyMC-Linux-${{ env.VERSION }}-x86_64.AppImage
- mv PolyMC-Windows* PolyMC-Windows-${{ env.VERSION }}
mv PolyMC-macOS*/PolyMC.tar.gz PolyMC-macOS-${{ env.VERSION }}.tar.gz
- cd PolyMC-Windows-${{ env.VERSION }}
- zip -r -9 ../PolyMC-Windows-${{ env.VERSION }}.zip *
- cd ..
+ tar -czf PolyMC-${{ env.VERSION }}.tar.gz PolyMC-${{ env.VERSION }}
- - name: Upload Linux asset
- uses: actions/upload-release-asset@v1
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- with:
- upload_url: ${{ needs.create_release.outputs.upload_url }}
- asset_name: PolyMC-Linux-${{ env.VERSION }}.tar.gz
- asset_path: PolyMC-Linux-${{ env.VERSION }}.tar.gz
- asset_content_type: application/gzip
-
- - name: Upload Linux AppImage asset
- uses: actions/upload-release-asset@v1
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- with:
- upload_url: ${{ needs.create_release.outputs.upload_url }}
- asset_name: PolyMC-Linux-${{ env.VERSION }}-x86_64.AppImage
- asset_path: PolyMC-Linux-${{ env.VERSION }}-x86_64.AppImage
- asset_content_type: application/x-executable
-
- - name: Upload Windows asset
- uses: actions/upload-release-asset@v1
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- with:
- upload_url: ${{ needs.create_release.outputs.upload_url }}
- asset_name: PolyMC-Windows-${{ env.VERSION }}.zip
- asset_path: PolyMC-Windows-${{ env.VERSION }}.zip
- asset_content_type: application/zip
+ for d in PolyMC-Windows-*; do
+ cd "${d}" || continue
+ ARCH="$(echo -n ${d} | cut -d '-' -f 3)"
+ PORT="$(echo -n ${d} | grep -o portable || true)"
+ NAME="PolyMC-Windows-${ARCH}"
+ test -z "${PORT}" || NAME="${NAME}-portable"
+ zip -r -9 "../${NAME}-${{ env.VERSION }}.zip" *
+ cd ..
+ done
- - name: Upload macOS asset
- uses: actions/upload-release-asset@v1
+ - name: Create release
+ id: create_release
+ uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
- upload_url: ${{ needs.create_release.outputs.upload_url }}
- asset_name: PolyMC-macOS-${{ env.VERSION }}.tar.gz
- asset_path: PolyMC-macOS-${{ env.VERSION }}.tar.gz
- asset_content_type: application/gzip
+ tag_name: ${{ github.ref }}
+ name: PolyMC ${{ env.VERSION }}
+ draft: true
+ prerelease: false
+ files: |
+ PolyMC-Linux-${{ env.VERSION }}.tar.gz
+ PolyMC-Linux-${{ env.VERSION }}-x86_64.AppImage
+ PolyMC-Windows-i686-${{ env.VERSION }}.zip
+ PolyMC-Windows-i686-portable-${{ env.VERSION }}.zip
+ PolyMC-Windows-x86_64-${{ env.VERSION }}.zip
+ PolyMC-Windows-x86_64-portable-${{ env.VERSION }}.zip
+ PolyMC-macOS-${{ env.VERSION }}.tar.gz
+ PolyMC-${{ env.VERSION }}.tar.gz
diff --git a/.gitignore b/.gitignore
index ba90e8f8..c9a762f5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,3 +42,7 @@ run/
# Nix/NixOS
result/
+
+# Flatpak
+.flatpak-builder
+flatbuild
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9ff47353..c711fa4d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,7 +6,7 @@ if(WIN32)
endif()
project(Launcher)
-enable_testing()
+include(CTest)
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BUILD_DIR}" IS_IN_SOURCE_BUILD)
if(IS_IN_SOURCE_BUILD)
@@ -69,7 +69,7 @@ set(Launcher_HELP_URL "https://polymc.org/wiki/%1" CACHE STRING "URL (with arg %
######## Set version numbers ########
set(Launcher_VERSION_MAJOR 1)
set(Launcher_VERSION_MINOR 1)
-set(Launcher_VERSION_HOTFIX 0)
+set(Launcher_VERSION_HOTFIX 1)
# Build number
set(Launcher_VERSION_BUILD -1 CACHE STRING "Build number. -1 for no build number.")
@@ -96,7 +96,7 @@ set(Launcher_BUG_TRACKER_URL "https://github.com/PolyMC/PolyMC/issues" CACHE STR
set(Launcher_TRANSLATIONS_URL "https://hosted.weblate.org/projects/polymc/polymc/" CACHE STRING "URL for the translations platform.")
# Matrix Space
-set(Launcher_MATRIX_URL "https://matrix.to/#/#polymc:polymc.org" CACHE STRING "URL to the Matrix Space")
+set(Launcher_MATRIX_URL "https://matrix.to/#/#polymc:matrix.org" CACHE STRING "URL to the Matrix Space")
# Discord URL
set(Launcher_DISCORD_URL "https://discord.gg/Z52pwxWCHP" CACHE STRING "URL for the Discord guild.")
@@ -104,7 +104,7 @@ set(Launcher_DISCORD_URL "https://discord.gg/Z52pwxWCHP" CACHE STRING "URL for t
# Subreddit URL
-set(Launcher_SUBREDDIT_URL "" CACHE STRING "URL for the subreddit.")
+set(Launcher_SUBREDDIT_URL "https://www.reddit.com/r/PolyMCLauncher/" CACHE STRING "URL for the subreddit.")
# Builds
# TODO: Launcher_FORCE_BUNDLED_LIBS should be off in the future, but as of QuaZip 1.2, we can't do that yet.
@@ -220,6 +220,7 @@ elseif(UNIX)
set(LAUNCHER_DESKTOP_DEST_DIR "share/applications" CACHE STRING "Path to the desktop file directory")
set(LAUNCHER_METAINFO_DEST_DIR "share/metainfo" CACHE STRING "Path to the metainfo directory")
set(LAUNCHER_ICON_DEST_DIR "share/icons/hicolor/scalable/apps" CACHE STRING "Path to the scalable icon directory")
+ set(LAUNCHER_MAN_DEST_DIR "share/man/man6" CACHE STRING "Path to the man page directory")
# jars path is determined on runtime, relative to "Application root path", generally /usr for Launcher_PORTABLE=0
set(Launcher_APP_BINARY_DEFS "-DLAUNCHER_JARS_LOCATION=${JARS_DEST_DIR}")
@@ -227,6 +228,7 @@ elseif(UNIX)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${Launcher_Desktop} DESTINATION ${LAUNCHER_DESKTOP_DEST_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${Launcher_MetaInfo} DESTINATION ${LAUNCHER_METAINFO_DEST_DIR})
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${Launcher_SVG} DESTINATION ${LAUNCHER_ICON_DEST_DIR})
+ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${Launcher_ManPage} DESTINATION ${LAUNCHER_MAN_DEST_DIR} RENAME "${Launcher_APP_BINARY_NAME}.6")
endif()
# install as bundle with no dependencies included
diff --git a/README.md b/README.md
index a114869c..4c73c47e 100644
--- a/README.md
+++ b/README.md
@@ -33,14 +33,22 @@ Feel free to create an issue if you need help. However, you might find it easier
For people who don't want to use Discord, we have a Matrix Space which is bridged to the Discord server:
-[![PolyMC Space](https://img.shields.io/matrix/polymc:polymc.org?label=PolyMC%20Space&server_fqdn=matrix.polymc.org)](https://matrix.to/#/#polymc:polymc.org)
+[![PolyMC Space](https://img.shields.io/matrix/polymc:matrix.org?label=PolyMC%20space)](https://matrix.to/#/#polymc:matrix.org)
If there are any issues with the space or you are using a client that does not support the feature here are the individual rooms:
-[![Support](https://img.shields.io/matrix/support:polymc.org?label=%23support&server_fqdn=matrix.polymc.org)](https://matrix.to/#/#support:polymc.org)
-[![Discussion](https://img.shields.io/matrix/discussion:polymc.org?label=%23discussion&server_fqdn=matrix.polymc.org)](https://matrix.to/#/#discussion:polymc.org)
-[![Development](https://img.shields.io/matrix/development:polymc.org?label=%23development&server_fqdn=matrix.polymc.org)](https://matrix.to/#/#development:polymc.org)
-[![News](https://img.shields.io/matrix/news:polymc.org?label=%23news&server_fqdn=matrix.polymc.org)](https://matrix.to/#/#news:polymc.org)
+[![Development](https://img.shields.io/matrix/polymc-development:matrix.org?label=PolyMC%20Development)](https://matrix.to/#/#polymc-development:matrix.org)
+[![Discussion](https://img.shields.io/matrix/polymc-discussion:matrix.org?label=PolyMC%20Discussion)](https://matrix.to/#/#polymc-discussion:matrix.org)
+[![Github](https://img.shields.io/matrix/polymc-github:matrix.org?label=PolyMC%20Github)](https://matrix.to/#/#polymc-github:matrix.org)
+[![Maintainers](https://img.shields.io/matrix/polymc-maintainers:matrix.org?label=PolyMC%20Maintainers)](https://matrix.to/#/#polymc-maintainers:matrix.org)
+[![News](https://img.shields.io/matrix/polymc-news:matrix.org?label=PolyMC%20News)](https://matrix.to/#/#polymc-news:matrix.org)
+[![Offtopic](https://img.shields.io/matrix/polymc-offtopic:matrix.org?label=PolyMC%20Offtopic)](https://matrix.to/#/#polymc-offtopic:matrix.org)
+[![Support](https://img.shields.io/matrix/polymc-support:matrix.org?label=PolyMC%20Support)](https://matrix.to/#/#polymc-support:matrix.org)
+[![Voice](https://img.shields.io/matrix/polymc-voice:matrix.org?label=PolyMC%20Voice)](https://matrix.to/#/#polymc-voice:matrix.org)
+
+we also have a subreddit you can post your issues and suggestions on:
+
+[r/PolyMCLauncher](https://www.reddit.com/r/PolyMCLauncher/)
# Development
@@ -77,4 +85,4 @@ All launcher code is available under the GPL-3 license.
[Source for the website](https://github.com/PolyMC/polymc.github.io) is hosted under the AGPL-3 License.
-The logo and related assets are under the CC BY-NC-SA 4.0 license.
+The logo and related assets are under the CC BY-SA 4.0 license.
diff --git a/buildconfig/BuildConfig.h b/buildconfig/BuildConfig.h
index 2fb71f14..6304387c 100644
--- a/buildconfig/BuildConfig.h
+++ b/buildconfig/BuildConfig.h
@@ -140,6 +140,12 @@ public:
QString ATL_DOWNLOAD_SERVER_URL = "https://download.nodecdn.net/containers/atl/";
+ QString TECHNIC_API_BASE_URL = "https://api.technicpack.net/";
+ /**
+ * The build that is reported to the Technic API.
+ */
+ QString TECHNIC_API_BUILD = "multimc";
+
/**
* \brief Converts the Version to a string.
* \return The version number in string format (major.minor.revision.build).
diff --git a/cmake/UnitTest.cmake b/cmake/UnitTest.cmake
index 9f2bc269..7d7bd4ad 100644
--- a/cmake/UnitTest.cmake
+++ b/cmake/UnitTest.cmake
@@ -5,44 +5,46 @@ set(TEST_RESOURCE_PATH ${CMAKE_CURRENT_LIST_DIR})
message(${TEST_RESOURCE_PATH})
function(add_unit_test name)
- set(options "")
- set(oneValueArgs DATA)
- set(multiValueArgs SOURCES LIBS)
+ if(BUILD_TESTING)
+ set(options "")
+ set(oneValueArgs DATA)
+ set(multiValueArgs SOURCES LIBS)
- cmake_parse_arguments(OPT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
+ cmake_parse_arguments(OPT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
- if(WIN32)
- add_executable(${name}_test ${OPT_SOURCES} ${TEST_RESOURCE_PATH}/UnitTest/test.rc)
- else()
- add_executable(${name}_test ${OPT_SOURCES})
- endif()
-
- if(NOT "${OPT_DATA}" STREQUAL "")
- set(TEST_DATA_PATH "${CMAKE_CURRENT_BINARY_DIR}/data")
- set(TEST_DATA_PATH_SRC "${CMAKE_CURRENT_SOURCE_DIR}/${OPT_DATA}")
- message("From ${TEST_DATA_PATH_SRC} to ${TEST_DATA_PATH}")
- string(REGEX REPLACE "[/\\:]" "_" DATA_TARGET_NAME "${TEST_DATA_PATH_SRC}")
- if(UNIX)
- # on unix we get the third / from the filename
- set(TEST_DATA_URL "file://${TEST_DATA_PATH}")
+ if(WIN32)
+ add_executable(${name}_test ${OPT_SOURCES} ${TEST_RESOURCE_PATH}/UnitTest/test.rc)
else()
- # we don't on windows, so we have to add it ourselves
- set(TEST_DATA_URL "file:///${TEST_DATA_PATH}")
+ add_executable(${name}_test ${OPT_SOURCES})
endif()
- if(NOT TARGET "${DATA_TARGET_NAME}")
- add_custom_target(${DATA_TARGET_NAME})
- add_dependencies(${name}_test ${DATA_TARGET_NAME})
- add_custom_command(
- TARGET ${DATA_TARGET_NAME}
- COMMAND ${CMAKE_COMMAND} "-DTEST_DATA_URL=${TEST_DATA_URL}" -DSOURCE=${TEST_DATA_PATH_SRC} -DDESTINATION=${TEST_DATA_PATH} -P ${TEST_RESOURCE_PATH}/UnitTest/generate_test_data.cmake
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- )
+
+ if(NOT "${OPT_DATA}" STREQUAL "")
+ set(TEST_DATA_PATH "${CMAKE_CURRENT_BINARY_DIR}/data")
+ set(TEST_DATA_PATH_SRC "${CMAKE_CURRENT_SOURCE_DIR}/${OPT_DATA}")
+ message("From ${TEST_DATA_PATH_SRC} to ${TEST_DATA_PATH}")
+ string(REGEX REPLACE "[/\\:]" "_" DATA_TARGET_NAME "${TEST_DATA_PATH_SRC}")
+ if(UNIX)
+ # on unix we get the third / from the filename
+ set(TEST_DATA_URL "file://${TEST_DATA_PATH}")
+ else()
+ # we don't on windows, so we have to add it ourselves
+ set(TEST_DATA_URL "file:///${TEST_DATA_PATH}")
+ endif()
+ if(NOT TARGET "${DATA_TARGET_NAME}")
+ add_custom_target(${DATA_TARGET_NAME})
+ add_dependencies(${name}_test ${DATA_TARGET_NAME})
+ add_custom_command(
+ TARGET ${DATA_TARGET_NAME}
+ COMMAND ${CMAKE_COMMAND} "-DTEST_DATA_URL=${TEST_DATA_URL}" -DSOURCE=${TEST_DATA_PATH_SRC} -DDESTINATION=${TEST_DATA_PATH} -P ${TEST_RESOURCE_PATH}/UnitTest/generate_test_data.cmake
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ )
+ endif()
endif()
- endif()
- target_link_libraries(${name}_test Qt5::Test ${OPT_LIBS})
+ target_link_libraries(${name}_test Qt5::Test ${OPT_LIBS})
- target_include_directories(${name}_test PRIVATE "${TEST_RESOURCE_PATH}/UnitTest/")
+ target_include_directories(${name}_test PRIVATE "${TEST_RESOURCE_PATH}/UnitTest/")
- add_test(NAME ${name} COMMAND ${name}_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+ add_test(NAME ${name} COMMAND ${name}_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+ endif()
endfunction()
diff --git a/flake.lock b/flake.lock
index f2205416..e3c490fd 100644
--- a/flake.lock
+++ b/flake.lock
@@ -3,11 +3,11 @@
"flake-compat": {
"flake": false,
"locked": {
- "lastModified": 1641205782,
- "narHash": "sha256-4jY7RCWUoZ9cKD8co0/4tFARpWB+57+r1bLLvXNJliY=",
+ "lastModified": 1648199409,
+ "narHash": "sha256-JwPKdC2PoVBkG6E+eWw3j6BMR6sL3COpYWfif7RVb8Y=",
"owner": "edolstra",
"repo": "flake-compat",
- "rev": "b7547d3eed6f32d06102ead8991ec52ab0a4f1a7",
+ "rev": "64a525ee38886ab9028e6f61790de0832aa3ef03",
"type": "github"
},
"original": {
@@ -16,21 +16,6 @@
"type": "github"
}
},
- "flake-utils": {
- "locked": {
- "lastModified": 1642700792,
- "narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
- "owner": "numtide",
- "repo": "flake-utils",
- "rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
- "type": "github"
- },
- "original": {
- "owner": "numtide",
- "repo": "flake-utils",
- "type": "github"
- }
- },
"libnbtplusplus": {
"flake": false,
"locked": {
@@ -49,16 +34,16 @@
},
"nixpkgs": {
"locked": {
- "lastModified": 1643169865,
- "narHash": "sha256-+KIpNRazbc8Gac9jdWCKQkFv9bjceaLaLhlwqUEYu8c=",
+ "lastModified": 1648219316,
+ "narHash": "sha256-Ctij+dOi0ZZIfX5eMhgwugfvB+WZSrvVNAyAuANOsnQ=",
"owner": "nixos",
"repo": "nixpkgs",
- "rev": "945ec499041db73043f745fad3b2a3a01e826081",
+ "rev": "30d3d79b7d3607d56546dd2a6b49e156ba0ec634",
"type": "github"
},
"original": {
"owner": "nixos",
- "ref": "nixos-unstable",
+ "ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
@@ -82,7 +67,6 @@
"root": {
"inputs": {
"flake-compat": "flake-compat",
- "flake-utils": "flake-utils",
"libnbtplusplus": "libnbtplusplus",
"nixpkgs": "nixpkgs",
"quazip": "quazip"
diff --git a/flake.nix b/flake.nix
index 5f95b4e6..e59d6be8 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,50 +1,34 @@
{
- description = "PolyMC flake";
- inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
- inputs.flake-utils.url = "github:numtide/flake-utils";
- inputs.flake-compat = {
- url = "github:edolstra/flake-compat";
- flake = false;
- };
- inputs.libnbtplusplus = {
- url = "github:multimc/libnbtplusplus";
- flake = false;
- };
- inputs.quazip = {
- url = "github:stachenov/quazip";
- flake = false;
+ description = "A custom launcher for Minecraft that allows you to easily manage multiple installations of Minecraft at once (Fork of MultiMC)";
+
+ inputs = {
+ nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
+ flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
+ libnbtplusplus = { url = "github:multimc/libnbtplusplus"; flake = false; };
+ quazip = { url = "github:stachenov/quazip"; flake = false; };
};
- outputs = args@{ self, nixpkgs, flake-utils, libnbtplusplus, quazip, ... }:
+ outputs = { self, nixpkgs, libnbtplusplus, quazip, ... }:
let
- systems = [
- "aarch64-linux"
- # "aarch64-darwin" # qtbase is currently broken
- "i686-linux"
- "x86_64-darwin"
- "x86_64-linux"
- ];
- in {
- overlay = final: prev: {
- inherit (self.packages.${final.system}) polymc;
- };
- } // flake-utils.lib.eachSystem systems (system:
- let pkgs = import nixpkgs { inherit system; };
- in {
- packages = {
- polymc = pkgs.libsForQt5.callPackage ./packages/nix/polymc {
- inherit self;
- submoduleQuazip = quazip;
- submoduleNbt = libnbtplusplus;
- };
- };
- apps = {
- polymc = flake-utils.lib.mkApp {
- name = "polymc";
- drv = self.packages.${system}.polymc;
- };
- };
- defaultPackage = self.packages.${system}.polymc;
- defaultApp = self.apps.${system}.polymc;
- });
+ # Generate a user-friendly version number.
+ version = builtins.substring 0 8 self.lastModifiedDate;
+
+ # System types to support (qtbase is currently broken for "aarch64-darwin")
+ supportedSystems = [ "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 system types.
+ pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
+ in
+ {
+ packages = forAllSystems (system: { polymc = pkgs.${system}.libsForQt5.callPackage ./packages/nix/polymc { inherit version self quazip libnbtplusplus; }; });
+ defaultPackage = forAllSystems (system: self.packages.${system}.polymc);
+
+ apps = forAllSystems (system: { polymc = { type = "app"; program = "${self.defaultPackage.${system}}/bin/polymc"; }; });
+ defaultApp = forAllSystems (system: self.apps.${system}.polymc);
+
+ overlay = final: prev: { polymc = self.defaultPackage.${final.system}; };
+ };
}
diff --git a/launcher/Application.cpp b/launcher/Application.cpp
index 33b1774c..9cca534c 100644
--- a/launcher/Application.cpp
+++ b/launcher/Application.cpp
@@ -682,6 +682,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
m_settings->registerSetting("JavaVendor", "");
m_settings->registerSetting("LastHostname", "");
m_settings->registerSetting("JvmArgs", "");
+ m_settings->registerSetting("IgnoreJavaCompatibility", false);
// Native library workarounds
m_settings->registerSetting("UseNativeOpenAL", false);
@@ -695,6 +696,9 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
// Minecraft launch method
m_settings->registerSetting("MCLaunchMethod", "LauncherPart");
+ // Minecraft offline player name
+ m_settings->registerSetting("LastOfflinePlayerName", "");
+
// Wrapper command for launch
m_settings->registerSetting("WrapperCommand", "");
@@ -727,6 +731,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
m_settings->registerSetting("PastebinURL", "https://0x0.st");
m_settings->registerSetting("CloseAfterLaunch", false);
+ m_settings->registerSetting("QuitAfterGameStop", false);
// Custom MSA credentials
m_settings->registerSetting("MSAClientIDOverride", "");
@@ -1139,6 +1144,15 @@ std::vector<ITheme *> Application::getValidApplicationThemes()
return ret;
}
+bool Application::isFlatpak()
+{
+ #ifdef Q_OS_LINUX
+ return QFile::exists("/.flatpak-info");
+ #else
+ return false;
+ #endif
+}
+
void Application::setApplicationTheme(const QString& name, bool initial)
{
auto systemPalette = qApp->palette();
diff --git a/launcher/Application.h b/launcher/Application.h
index c3e29ef5..54d9ba5f 100644
--- a/launcher/Application.h
+++ b/launcher/Application.h
@@ -104,6 +104,8 @@ public:
QIcon getThemedIcon(const QString& name);
+ bool isFlatpak();
+
void setIconTheme(const QString& name);
std::vector<ITheme *> getValidApplicationThemes();
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt
index 98cb0a3b..42348792 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -144,6 +144,8 @@ set(LAUNCH_SOURCES
launch/steps/TextPrint.h
launch/steps/Update.cpp
launch/steps/Update.h
+ launch/steps/QuitAfterGameStop.cpp
+ launch/steps/QuitAfterGameStop.h
launch/LaunchStep.cpp
launch/LaunchStep.h
launch/LaunchTask.cpp
@@ -346,28 +348,30 @@ set(MINECRAFT_SOURCES
mojang/PackageManifest.h
mojang/PackageManifest.cpp
- )
+ minecraft/Agent.h)
add_unit_test(GradleSpecifier
SOURCES minecraft/GradleSpecifier_test.cpp
LIBS Launcher_logic
)
-add_executable(PackageManifest
- mojang/PackageManifest_test.cpp
-)
-target_link_libraries(PackageManifest
- Launcher_logic
- Qt5::Test
-)
-target_include_directories(PackageManifest
- PRIVATE ../cmake/UnitTest/
-)
-add_test(
- NAME PackageManifest
- COMMAND PackageManifest
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-)
+if(BUILD_TESTING)
+ add_executable(PackageManifest
+ mojang/PackageManifest_test.cpp
+ )
+ target_link_libraries(PackageManifest
+ Launcher_logic
+ Qt5::Test
+ )
+ target_include_directories(PackageManifest
+ PRIVATE ../cmake/UnitTest/
+ )
+ add_test(
+ NAME PackageManifest
+ COMMAND PackageManifest
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ )
+endif()
add_unit_test(MojangVersionFormat
SOURCES minecraft/MojangVersionFormat_test.cpp
@@ -409,6 +413,11 @@ set(TASKS_SOURCES
tasks/SequentialTask.cpp
)
+add_unit_test(Task
+ SOURCES tasks/Task_test.cpp
+ LIBS Launcher_logic
+ )
+
set(SETTINGS_SOURCES
# Settings
settings/INIFile.cpp
@@ -485,6 +494,16 @@ set(META_SOURCES
meta/Index.h
)
+set(API_SOURCES
+ modplatform/ModAPI.h
+
+ modplatform/flame/FlameAPI.h
+ modplatform/modrinth/ModrinthAPI.h
+
+ modplatform/helpers/NetworkModAPI.h
+ modplatform/helpers/NetworkModAPI.cpp
+)
+
set(FTB_SOURCES
modplatform/legacy_ftb/PackFetchTask.h
modplatform/legacy_ftb/PackFetchTask.cpp
@@ -525,6 +544,8 @@ set(TECHNIC_SOURCES
modplatform/technic/SingleZipPackInstallTask.cpp
modplatform/technic/SolderPackInstallTask.h
modplatform/technic/SolderPackInstallTask.cpp
+ modplatform/technic/SolderPackManifest.h
+ modplatform/technic/SolderPackManifest.cpp
modplatform/technic/TechnicPackProcessor.h
modplatform/technic/TechnicPackProcessor.cpp
)
@@ -564,6 +585,7 @@ set(LOGIC_SOURCES
${TOOLS_SOURCES}
${META_SOURCES}
${ICONS_SOURCES}
+ ${API_SOURCES}
${FTB_SOURCES}
${FLAME_SOURCES}
${MODRINTH_SOURCES}
@@ -713,6 +735,11 @@ SET(LAUNCHER_SOURCES
ui/pages/modplatform/VanillaPage.cpp
ui/pages/modplatform/VanillaPage.h
+ ui/pages/modplatform/ModPage.cpp
+ ui/pages/modplatform/ModPage.h
+ ui/pages/modplatform/ModModel.cpp
+ ui/pages/modplatform/ModModel.h
+
ui/pages/modplatform/atlauncher/AtlFilterModel.cpp
ui/pages/modplatform/atlauncher/AtlFilterModel.h
ui/pages/modplatform/atlauncher/AtlListModel.cpp
@@ -871,13 +898,12 @@ qt5_wrap_ui(LAUNCHER_UI
ui/pages/modplatform/atlauncher/AtlOptionalModDialog.ui
ui/pages/modplatform/atlauncher/AtlPage.ui
ui/pages/modplatform/VanillaPage.ui
+ ui/pages/modplatform/ModPage.ui
ui/pages/modplatform/flame/FlamePage.ui
- ui/pages/modplatform/flame/FlameModPage.ui
ui/pages/modplatform/legacy_ftb/Page.ui
ui/pages/modplatform/ImportPage.ui
ui/pages/modplatform/ftb/FtbPage.ui
ui/pages/modplatform/technic/TechnicPage.ui
- ui/pages/modplatform/modrinth/ModrinthPage.ui
ui/widgets/InstanceCardWidget.ui
ui/widgets/CustomCommands.ui
ui/widgets/MCModInfoFrame.ui
diff --git a/launcher/DesktopServices.cpp b/launcher/DesktopServices.cpp
index dcc1b0ce..c29cbe7d 100644
--- a/launcher/DesktopServices.cpp
+++ b/launcher/DesktopServices.cpp
@@ -1,8 +1,43 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 dada513 <dada513@protonmail.com>
+ *
+ * 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
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2022 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#include "DesktopServices.h"
#include <QDir>
#include <QDesktopServices>
#include <QProcess>
#include <QDebug>
+#include "Application.h"
/**
* This shouldn't exist, but until QTBUG-9328 and other unreported bugs are fixed, it needs to be a thing.
@@ -84,7 +119,14 @@ bool openDirectory(const QString &path, bool ensureExists)
return QDesktopServices::openUrl(QUrl::fromLocalFile(dir.absolutePath()));
};
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
- return IndirectOpen(f);
+ if(!APPLICATION->isFlatpak())
+ {
+ return IndirectOpen(f);
+ }
+ else
+ {
+ return f();
+ }
#else
return f();
#endif
@@ -98,7 +140,14 @@ bool openFile(const QString &path)
return QDesktopServices::openUrl(QUrl::fromLocalFile(path));
};
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
- return IndirectOpen(f);
+ if(!APPLICATION->isFlatpak())
+ {
+ return IndirectOpen(f);
+ }
+ else
+ {
+ return f();
+ }
#else
return f();
#endif
@@ -109,10 +158,17 @@ bool openFile(const QString &application, const QString &path, const QString &wo
qDebug() << "Opening file" << path << "using" << application;
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
// FIXME: the pid here is fake. So if something depends on it, it will likely misbehave
- return IndirectOpen([&]()
+ if(!APPLICATION->isFlatpak())
{
- return QProcess::startDetached(application, QStringList() << path, workingDirectory);
- }, pid);
+ return IndirectOpen([&]()
+ {
+ return QProcess::startDetached(application, QStringList() << path, workingDirectory);
+ }, pid);
+ }
+ else
+ {
+ return QProcess::startDetached(application, QStringList() << path, workingDirectory, pid);
+ }
#else
return QProcess::startDetached(application, QStringList() << path, workingDirectory, pid);
#endif
@@ -122,11 +178,18 @@ bool run(const QString &application, const QStringList &args, const QString &wor
{
qDebug() << "Running" << application << "with args" << args.join(' ');
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
+ if(!APPLICATION->isFlatpak())
+ {
// FIXME: the pid here is fake. So if something depends on it, it will likely misbehave
return IndirectOpen([&]()
{
return QProcess::startDetached(application, args, workingDirectory);
}, pid);
+ }
+ else
+ {
+ return QProcess::startDetached(application, args, workingDirectory, pid);
+ }
#else
return QProcess::startDetached(application, args, workingDirectory, pid);
#endif
@@ -140,7 +203,14 @@ bool openUrl(const QUrl &url)
return QDesktopServices::openUrl(url);
};
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
- return IndirectOpen(f);
+ if(!APPLICATION->isFlatpak())
+ {
+ return IndirectOpen(f);
+ }
+ else
+ {
+ return f();
+ }
#else
return f();
#endif
diff --git a/launcher/InstanceImportTask.cpp b/launcher/InstanceImportTask.cpp
index a825e8d4..1a13c997 100644
--- a/launcher/InstanceImportTask.cpp
+++ b/launcher/InstanceImportTask.cpp
@@ -40,6 +40,14 @@ InstanceImportTask::InstanceImportTask(const QUrl sourceUrl)
m_sourceUrl = sourceUrl;
}
+bool InstanceImportTask::abort()
+{
+ m_filesNetJob->abort();
+ m_extractFuture.cancel();
+
+ return false;
+}
+
void InstanceImportTask::executeTask()
{
if (m_sourceUrl.isLocalFile())
@@ -241,6 +249,7 @@ void InstanceImportTask::processFlame()
QString forgeVersion;
QString fabricVersion;
+ // TODO: is Quilt relevant here?
for(auto &loader: pack.minecraft.modLoaders)
{
auto id = loader.id;
diff --git a/launcher/InstanceImportTask.h b/launcher/InstanceImportTask.h
index a1990647..365c3dc4 100644
--- a/launcher/InstanceImportTask.h
+++ b/launcher/InstanceImportTask.h
@@ -37,6 +37,9 @@ class InstanceImportTask : public InstanceTask
public:
explicit InstanceImportTask(const QUrl sourceUrl);
+ bool canAbort() const override { return true; }
+ bool abort() override;
+
protected:
//! Entry point for tasks.
virtual void executeTask() override;
diff --git a/launcher/JavaCommon.cpp b/launcher/JavaCommon.cpp
index a6542fa7..17278d86 100644
--- a/launcher/JavaCommon.cpp
+++ b/launcher/JavaCommon.cpp
@@ -17,6 +17,17 @@ bool JavaCommon::checkJVMArgs(QString jvmargs, QWidget *parent)
QMessageBox::Warning)->exec();
return false;
}
+ // block lunacy with passing required version to the JVM
+ if (jvmargs.contains(QRegExp("-version:.*"))) {
+ auto warnStr = QObject::tr(
+ "You tried to pass required Java version argument to the JVM (using \"-version:xxx\"). This is not safe and will not be allowed.\n"
+ "This message will be displayed until you remove this from the JVM arguments.");
+ CustomMessageBox::selectable(
+ parent, QObject::tr("JVM arguments warning"),
+ warnStr,
+ QMessageBox::Warning)->exec();
+ return false;
+ }
return true;
}
diff --git a/launcher/LaunchController.cpp b/launcher/LaunchController.cpp
index 792d8381..4cb62e69 100644
--- a/launcher/LaunchController.cpp
+++ b/launcher/LaunchController.cpp
@@ -71,7 +71,10 @@ void LaunchController::executeTask()
return;
}
- JavaCommon::checkJVMArgs(m_instance->settings()->get("JvmArgs").toString(), m_parentWidget);
+ if(!JavaCommon::checkJVMArgs(m_instance->settings()->get("JvmArgs").toString(), m_parentWidget)) {
+ emitFailed(tr("Invalid Java arguments specified. Please fix this first."));
+ return;
+ }
login();
}
@@ -166,13 +169,14 @@ void LaunchController::login() {
if(!m_session->wants_online) {
// we ask the user for a player name
bool ok = false;
- QString usedname = m_session->player_name;
+ QString lastOfflinePlayerName = APPLICATION->settings()->get("LastOfflinePlayerName").toString();
+ QString usedname = lastOfflinePlayerName.isEmpty() ? m_session->player_name : lastOfflinePlayerName;
QString name = QInputDialog::getText(
m_parentWidget,
tr("Player name"),
tr("Choose your offline mode player name."),
QLineEdit::Normal,
- m_session->player_name,
+ usedname,
&ok
);
if (!ok)
@@ -183,6 +187,7 @@ void LaunchController::login() {
if (name.length())
{
usedname = name;
+ APPLICATION->settings()->set("LastOfflinePlayerName", usedname);
}
m_session->MakeOffline(usedname);
// offline flavored game from here :3
diff --git a/launcher/java/JavaChecker.cpp b/launcher/java/JavaChecker.cpp
index 35ddc35c..946599c5 100644
--- a/launcher/java/JavaChecker.cpp
+++ b/launcher/java/JavaChecker.cpp
@@ -129,7 +129,7 @@ void JavaChecker::finished(int exitcode, QProcess::ExitStatus status)
auto os_arch = results["os.arch"];
auto java_version = results["java.version"];
auto java_vendor = results["java.vendor"];
- bool is_64 = os_arch == "x86_64" || os_arch == "amd64";
+ bool is_64 = os_arch == "x86_64" || os_arch == "amd64" || os_arch == "aarch64" || os_arch == "arm64";
result.validity = JavaCheckResult::Validity::Valid;
diff --git a/launcher/java/JavaInstallList.cpp b/launcher/java/JavaInstallList.cpp
index a0a60871..9b745095 100644
--- a/launcher/java/JavaInstallList.cpp
+++ b/launcher/java/JavaInstallList.cpp
@@ -183,7 +183,7 @@ void JavaListLoadTask::javaCheckerFinished()
JavaInstallPtr javaVersion(new JavaInstall());
javaVersion->id = result.javaVersion;
- javaVersion->arch = result.mojangPlatform;
+ javaVersion->arch = result.realPlatform;
javaVersion->path = result.path;
candidates.append(javaVersion);
diff --git a/launcher/java/JavaUtils.cpp b/launcher/java/JavaUtils.cpp
index 6e5dfeae..65a8b1db 100644
--- a/launcher/java/JavaUtils.cpp
+++ b/launcher/java/JavaUtils.cpp
@@ -153,7 +153,7 @@ QStringList addJavasFromEnv(QList<QString> javas)
{
QByteArray env = qgetenv("POLYMC_JAVA_PATHS");
#if defined(Q_OS_WIN32)
- QList<QString> javaPaths = QString::fromLocal8Bit(env).split(QLatin1String(";"));
+ QList<QString> javaPaths = QString::fromLocal8Bit(env).replace("\\", "/").split(QLatin1String(";"));
#else
QList<QString> javaPaths = QString::fromLocal8Bit(env).split(QLatin1String(":"));
#endif
@@ -355,7 +355,7 @@ QList<QString> JavaUtils::FindJavaPaths()
}
}
- return candidates;
+ return addJavasFromEnv(candidates);
}
#elif defined(Q_OS_MAC)
diff --git a/launcher/launch/LaunchTask.cpp b/launcher/launch/LaunchTask.cpp
index 231a6398..d5442a2b 100644
--- a/launcher/launch/LaunchTask.cpp
+++ b/launcher/launch/LaunchTask.cpp
@@ -1,18 +1,38 @@
-/* Copyright 2013-2021 MultiMC Contributors
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
- * Authors: Orochimarufan <orochimarufan.x3@gmail.com>
+ * 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
+ * the Free Software Foundation, version 3.
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Authors: Orochimarufan <orochimarufan.x3@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
#include "launch/LaunchTask.h"
@@ -212,7 +232,7 @@ shared_qobject_ptr<LogModel> LaunchTask::getLogModel()
m_logModel->setMaxLines(m_instance->getConsoleMaxLines());
m_logModel->setStopOnOverflow(m_instance->shouldStopOnConsoleOverflow());
// FIXME: should this really be here?
- m_logModel->setOverflowMessage(tr("PolyMC stopped watching the game log because the log length surpassed %1 lines.\n"
+ m_logModel->setOverflowMessage(tr("Stopped watching the game log because the log length surpassed %1 lines.\n"
"You may have to fix your mods because the game is still logging to files and"
" likely wasting harddrive space at an alarming rate!").arg(m_logModel->getMaxLines()));
}
diff --git a/launcher/launch/steps/CheckJava.cpp b/launcher/launch/steps/CheckJava.cpp
index d3f2148c..3226fae7 100644
--- a/launcher/launch/steps/CheckJava.cpp
+++ b/launcher/launch/steps/CheckJava.cpp
@@ -1,16 +1,36 @@
-/* Copyright 2013-2021 MultiMC Contributors
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * 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
+ * the Free Software Foundation, version 3.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
#include "CheckJava.h"
@@ -87,14 +107,14 @@ void CheckJava::checkJavaFinished(JavaCheckResult result)
// Error message displayed if java can't start
emit logLine(QString("Could not start java:"), MessageLevel::Error);
emit logLines(result.errorLog.split('\n'), MessageLevel::Error);
- emit logLine("\nCheck your PolyMC Java settings.", MessageLevel::Launcher);
+ emit logLine(QString("\nCheck your Java settings."), MessageLevel::Launcher);
printSystemInfo(false, false);
emitFailed(QString("Could not start java!"));
return;
}
case JavaCheckResult::Validity::ReturnedInvalidData:
{
- emit logLine(QString("Java checker returned some invalid data PolyMC doesn't understand:"), MessageLevel::Error);
+ emit logLine(QString("Java checker returned some invalid data we don't understand:"), MessageLevel::Error);
emit logLines(result.outLog.split('\n'), MessageLevel::Warning);
emit logLine("\nMinecraft might not start properly.", MessageLevel::Launcher);
printSystemInfo(false, false);
@@ -104,7 +124,8 @@ void CheckJava::checkJavaFinished(JavaCheckResult result)
case JavaCheckResult::Validity::Valid:
{
auto instance = m_parent->instance();
- printJavaInfo(result.javaVersion.toString(), result.mojangPlatform, result.javaVendor);
+ printJavaInfo(result.javaVersion.toString(), result.realPlatform, result.javaVendor);
+ printSystemInfo(true, result.is_64bit);
instance->settings()->set("JavaVersion", result.javaVersion.toString());
instance->settings()->set("JavaArchitecture", result.mojangPlatform);
instance->settings()->set("JavaVendor", result.javaVendor);
@@ -117,8 +138,7 @@ void CheckJava::checkJavaFinished(JavaCheckResult result)
void CheckJava::printJavaInfo(const QString& version, const QString& architecture, const QString & vendor)
{
- emit logLine(QString("Java is version %1, using %2-bit architecture, from %3.\n\n").arg(version, architecture, vendor), MessageLevel::Launcher);
- printSystemInfo(true, architecture == "64");
+ emit logLine(QString("Java is version %1, using %2 architecture, from %3.\n\n").arg(version, architecture, vendor), MessageLevel::Launcher);
}
void CheckJava::printSystemInfo(bool javaIsKnown, bool javaIs64bit)
diff --git a/launcher/launch/steps/QuitAfterGameStop.cpp b/launcher/launch/steps/QuitAfterGameStop.cpp
new file mode 100644
index 00000000..f9eced99
--- /dev/null
+++ b/launcher/launch/steps/QuitAfterGameStop.cpp
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 dada513 <dada513@protonmail.com>
+ *
+ * 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
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include "QuitAfterGameStop.h"
+#include <launch/LaunchTask.h>
+#include "Application.h"
+
+void QuitAfterGameStop::executeTask()
+{
+ APPLICATION->quit();
+}
diff --git a/launcher/launch/steps/QuitAfterGameStop.h b/launcher/launch/steps/QuitAfterGameStop.h
new file mode 100644
index 00000000..1ce14da9
--- /dev/null
+++ b/launcher/launch/steps/QuitAfterGameStop.h
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 dada513 <dada513@protonmail.com>
+ *
+ * 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
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <launch/LaunchStep.h>
+
+class QuitAfterGameStop: public LaunchStep
+{
+ Q_OBJECT
+public:
+ explicit QuitAfterGameStop(LaunchTask *parent) :LaunchStep(parent){};
+ virtual ~QuitAfterGameStop() {};
+
+ virtual void executeTask();
+ virtual bool canAbort() const
+ {
+ return false;
+ }
+};
diff --git a/launcher/minecraft/Agent.h b/launcher/minecraft/Agent.h
new file mode 100644
index 00000000..01109daf
--- /dev/null
+++ b/launcher/minecraft/Agent.h
@@ -0,0 +1,36 @@
+#pragma once
+
+#include <QString>
+
+#include "Library.h"
+
+class Agent;
+
+typedef std::shared_ptr<Agent> AgentPtr;
+
+class Agent {
+public:
+ Agent(LibraryPtr library, QString &argument)
+ {
+ m_library = library;
+ m_argument = argument;
+ }
+
+public: /* methods */
+
+ LibraryPtr library() {
+ return m_library;
+ }
+ QString argument() {
+ return m_argument;
+ }
+
+protected: /* data */
+
+ /// The library pointing to the jar this Java agent is contained within
+ LibraryPtr m_library;
+
+ /// The argument to the Java agent, passed after an = if present
+ QString m_argument;
+
+};
diff --git a/launcher/minecraft/ComponentUpdateTask.cpp b/launcher/minecraft/ComponentUpdateTask.cpp
index 8bc05a1b..ff7ed0af 100644
--- a/launcher/minecraft/ComponentUpdateTask.cpp
+++ b/launcher/minecraft/ComponentUpdateTask.cpp
@@ -591,7 +591,7 @@ void ComponentUpdateTask::resolveDependencies(bool checkOnly)
{
component->m_version = "3.1.2";
}
- else if (add.uid == "net.fabricmc.intermediary")
+ else if (add.uid == "net.fabricmc.intermediary" || add.uid == "org.quiltmc.hashed")
{
auto minecraft = std::find_if(components.begin(), components.end(), [](ComponentPtr & cmp){
return cmp->getID() == "net.minecraft";
diff --git a/launcher/minecraft/LaunchProfile.cpp b/launcher/minecraft/LaunchProfile.cpp
index 41705187..39a342ca 100644
--- a/launcher/minecraft/LaunchProfile.cpp
+++ b/launcher/minecraft/LaunchProfile.cpp
@@ -1,3 +1,38 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
+ *
+ * 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
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "LaunchProfile.h"
#include <Version.h>
@@ -7,11 +42,13 @@ void LaunchProfile::clear()
m_minecraftVersionType.clear();
m_minecraftAssets.reset();
m_minecraftArguments.clear();
+ m_addnJvmArguments.clear();
m_tweakers.clear();
m_mainClass.clear();
m_appletClass.clear();
m_libraries.clear();
m_mavenFiles.clear();
+ m_agents.clear();
m_traits.clear();
m_jarMods.clear();
m_mainJar.reset();
@@ -45,6 +82,11 @@ void LaunchProfile::applyMinecraftArguments(const QString& minecraftArguments)
applyString(minecraftArguments, this->m_minecraftArguments);
}
+void LaunchProfile::applyAddnJvmArguments(const QStringList& addnJvmArguments)
+{
+ this->m_addnJvmArguments.append(addnJvmArguments);
+}
+
void LaunchProfile::applyMinecraftVersionType(const QString& type)
{
applyString(type, this->m_minecraftVersionType);
@@ -126,6 +168,11 @@ void LaunchProfile::applyMods(const QList<LibraryPtr>& mods)
}
}
+void LaunchProfile::applyCompatibleJavaMajors(QList<int>& javaMajor)
+{
+ m_compatibleJavaMajors.append(javaMajor);
+}
+
void LaunchProfile::applyLibrary(LibraryPtr library)
{
if(!library->isActive())
@@ -174,6 +221,22 @@ void LaunchProfile::applyMavenFile(LibraryPtr mavenFile)
m_mavenFiles.append(Library::limitedCopy(mavenFile));
}
+void LaunchProfile::applyAgent(AgentPtr agent)
+{
+ auto lib = agent->library();
+ if(!lib->isActive())
+ {
+ return;
+ }
+
+ if(lib->isNative())
+ {
+ return;
+ }
+
+ m_agents.append(agent);
+}
+
const LibraryPtr LaunchProfile::getMainJar() const
{
return m_mainJar;
@@ -255,6 +318,11 @@ QString LaunchProfile::getMinecraftArguments() const
return m_minecraftArguments;
}
+const QStringList & LaunchProfile::getAddnJvmArguments() const
+{
+ return m_addnJvmArguments;
+}
+
const QList<LibraryPtr> & LaunchProfile::getJarMods() const
{
return m_jarMods;
@@ -275,6 +343,16 @@ const QList<LibraryPtr> & LaunchProfile::getMavenFiles() const
return m_mavenFiles;
}
+const QList<AgentPtr> & LaunchProfile::getAgents() const
+{
+ return m_agents;
+}
+
+const QList<int> & LaunchProfile::getCompatibleJavaMajors() const
+{
+ return m_compatibleJavaMajors;
+}
+
void LaunchProfile::getLibraryFiles(
const QString& architecture,
QStringList& jars,
diff --git a/launcher/minecraft/LaunchProfile.h b/launcher/minecraft/LaunchProfile.h
index c1752531..b55cf661 100644
--- a/launcher/minecraft/LaunchProfile.h
+++ b/launcher/minecraft/LaunchProfile.h
@@ -1,6 +1,42 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
+ *
+ * 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
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
#include <QString>
#include "Library.h"
+#include "Agent.h"
#include <ProblemProvider.h>
class LaunchProfile: public ProblemProvider
@@ -13,6 +49,7 @@ public: /* application of profile variables from patches */
void applyMainClass(const QString& mainClass);
void applyAppletClass(const QString& appletClass);
void applyMinecraftArguments(const QString& minecraftArguments);
+ void applyAddnJvmArguments(const QStringList& minecraftArguments);
void applyMinecraftVersionType(const QString& type);
void applyMinecraftAssets(MojangAssetIndexInfo::Ptr assets);
void applyTraits(const QSet<QString> &traits);
@@ -21,6 +58,8 @@ public: /* application of profile variables from patches */
void applyMods(const QList<LibraryPtr> &jarMods);
void applyLibrary(LibraryPtr library);
void applyMavenFile(LibraryPtr library);
+ void applyAgent(AgentPtr agent);
+ void applyCompatibleJavaMajors(QList<int>& javaMajor);
void applyMainJar(LibraryPtr jar);
void applyProblemSeverity(ProblemSeverity severity);
/// clear the profile
@@ -33,12 +72,15 @@ public: /* getters for profile variables */
QString getMinecraftVersionType() const;
MojangAssetIndexInfo::Ptr getMinecraftAssets() const;
QString getMinecraftArguments() const;
+ const QStringList & getAddnJvmArguments() const;
const QSet<QString> & getTraits() const;
const QStringList & getTweakers() const;
const QList<LibraryPtr> & getJarMods() const;
const QList<LibraryPtr> & getLibraries() const;
const QList<LibraryPtr> & getNativeLibraries() const;
const QList<LibraryPtr> & getMavenFiles() const;
+ const QList<AgentPtr> & getAgents() const;
+ const QList<int> & getCompatibleJavaMajors() const;
const LibraryPtr getMainJar() const;
void getLibraryFiles(
const QString & architecture,
@@ -69,6 +111,12 @@ private:
*/
QString m_minecraftArguments;
+ /**
+ * Additional arguments to pass to the JVM in addition to those the user has configured,
+ * memory settings, etc.
+ */
+ QStringList m_addnJvmArguments;
+
/// A list of all tweaker classes
QStringList m_tweakers;
@@ -84,6 +132,9 @@ private:
/// the list of maven files to be placed in the libraries folder, but not acted upon
QList<LibraryPtr> m_mavenFiles;
+ /// the list of java agents to add to JVM arguments
+ QList<AgentPtr> m_agents;
+
/// the main jar
LibraryPtr m_mainJar;
@@ -99,6 +150,9 @@ private:
/// the list of mods
QList<LibraryPtr> m_mods;
+ /// compatible java major versions
+ QList<int> m_compatibleJavaMajors;
+
ProblemSeverity m_problemSeverity = ProblemSeverity::None;
};
diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp
index 6db12c42..3ba79178 100644
--- a/launcher/minecraft/MinecraftInstance.cpp
+++ b/launcher/minecraft/MinecraftInstance.cpp
@@ -1,4 +1,40 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
+ *
+ * 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
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "MinecraftInstance.h"
+#include "BuildConfig.h"
#include "minecraft/launch/CreateGameFolders.h"
#include "minecraft/launch/ExtractNatives.h"
#include "minecraft/launch/PrintInstanceInfo.h"
@@ -20,6 +56,7 @@
#include "launch/steps/PreLaunchCommand.h"
#include "launch/steps/TextPrint.h"
#include "launch/steps/CheckJava.h"
+#include "launch/steps/QuitAfterGameStop.h"
#include "minecraft/launch/LauncherPartLaunch.h"
#include "minecraft/launch/DirectJavaLaunch.h"
@@ -88,6 +125,7 @@ MinecraftInstance::MinecraftInstance(SettingsObjectPtr globalSettings, SettingsO
m_settings->registerOverride(globalSettings->getSetting("JavaPath"), javaOrLocation);
m_settings->registerOverride(globalSettings->getSetting("JvmArgs"), javaOrArgs);
+ m_settings->registerOverride(globalSettings->getSetting("IgnoreJavaCompatibility"), javaOrLocation);
// special!
m_settings->registerPassthrough(globalSettings->getSetting("JavaTimestamp"), javaOrLocation);
@@ -292,6 +330,17 @@ QStringList MinecraftInstance::extraArguments() const
list.append({"-Dfml.ignoreInvalidMinecraftCertificates=true",
"-Dfml.ignorePatchDiscrepancies=true"});
}
+ auto addn = m_components->getProfile()->getAddnJvmArguments();
+ if (!addn.isEmpty()) {
+ list.append(addn);
+ }
+ auto agents = m_components->getProfile()->getAgents();
+ for (auto agent : agents)
+ {
+ QStringList jar, temp1, temp2, temp3;
+ agent->library()->getApplicableFiles(currentSystem, jar, temp1, temp2, temp3, getLocalLibraryPath());
+ list.append("-javaagent:"+jar[0]+(agent->argument().isEmpty() ? "" : "="+agent->argument()));
+ }
return list;
}
@@ -434,7 +483,7 @@ QStringList MinecraftInstance::processMinecraftArgs(
}
// blatant self-promotion.
- token_mapping["profile_name"] = token_mapping["version_name"] = "PolyMC";
+ token_mapping["profile_name"] = token_mapping["version_name"] = BuildConfig.LAUNCHER_NAME;
token_mapping["version_type"] = profile->getMinecraftVersionType();
@@ -935,6 +984,11 @@ shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPt
{
process->setCensorFilter(createCensorFilterFromSession(session));
}
+ if(APPLICATION->settings()->get("QuitAfterGameStop").toBool())
+ {
+ auto step = new QuitAfterGameStop(pptr);
+ process->appendStep(step);
+ }
m_launchProcess = process;
emit launchTaskChanged(m_launchProcess);
return m_launchProcess;
diff --git a/launcher/minecraft/MojangVersionFormat.cpp b/launcher/minecraft/MojangVersionFormat.cpp
index ff5409fd..94c58676 100644
--- a/launcher/minecraft/MojangVersionFormat.cpp
+++ b/launcher/minecraft/MojangVersionFormat.cpp
@@ -1,3 +1,38 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
+ *
+ * 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
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "MojangVersionFormat.h"
#include "OneSixVersionFormat.h"
#include "MojangDownloadInfo.h"
@@ -183,6 +218,15 @@ void MojangVersionFormat::readVersionProperties(const QJsonObject &in, VersionFi
);
}
}
+
+ if (in.contains("compatibleJavaMajors"))
+ {
+ for (auto compatible : requireArray(in.value("compatibleJavaMajors")))
+ {
+ out->compatibleJavaMajors.append(requireInteger(compatible));
+ }
+ }
+
if(in.contains("downloads"))
{
auto downloadsObj = requireObject(in, "downloads");
diff --git a/launcher/minecraft/OneSixVersionFormat.cpp b/launcher/minecraft/OneSixVersionFormat.cpp
index 0329d70e..879f18c1 100644
--- a/launcher/minecraft/OneSixVersionFormat.cpp
+++ b/launcher/minecraft/OneSixVersionFormat.cpp
@@ -1,5 +1,6 @@
#include "OneSixVersionFormat.h"
#include <Json.h>
+#include "minecraft/Agent.h"
#include "minecraft/ParseUtils.h"
#include <minecraft/MojangVersionFormat.h>
@@ -108,6 +109,14 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
}
}
+ if (root.contains("+jvmArgs"))
+ {
+ for (auto arg : requireArray(root.value("+jvmArgs")))
+ {
+ out->addnJvmArguments.append(requireString(arg));
+ }
+ }
+
if (root.contains("jarMods"))
{
@@ -176,6 +185,21 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
readLibs("mavenFiles", out->mavenFiles);
}
+ if(root.contains("+agents")) {
+ for (auto agentVal : requireArray(root.value("+agents")))
+ {
+ QJsonObject agentObj = requireObject(agentVal);
+ auto lib = libraryFromJson(*out, agentObj, filename);
+ QString arg = "";
+ if (agentObj.contains("argument"))
+ {
+ readString(agentObj, "argument", arg);
+ }
+ AgentPtr agent(new Agent(lib, arg));
+ out->agents.append(agent);
+ }
+ }
+
// if we have mainJar, just use it
if(root.contains("mainJar"))
{
diff --git a/launcher/minecraft/PackProfile.cpp b/launcher/minecraft/PackProfile.cpp
index d516e555..d53f41e1 100644
--- a/launcher/minecraft/PackProfile.cpp
+++ b/launcher/minecraft/PackProfile.cpp
@@ -970,3 +970,20 @@ void PackProfile::disableInteraction(bool disable)
}
}
}
+
+ModAPI::ModLoaderType PackProfile::getModLoader()
+{
+ if (!getComponentVersion("net.minecraftforge").isEmpty())
+ {
+ return ModAPI::Forge;
+ }
+ else if (!getComponentVersion("net.fabricmc.fabric-loader").isEmpty())
+ {
+ return ModAPI::Fabric;
+ }
+ else if (!getComponentVersion("org.quiltmc.quilt-loader").isEmpty())
+ {
+ return ModAPI::Quilt;
+ }
+ return ModAPI::Unspecified;
+}
diff --git a/launcher/minecraft/PackProfile.h b/launcher/minecraft/PackProfile.h
index 989d1c6a..ab4cd5c8 100644
--- a/launcher/minecraft/PackProfile.h
+++ b/launcher/minecraft/PackProfile.h
@@ -28,6 +28,7 @@
#include "BaseVersion.h"
#include "MojangDownloadInfo.h"
#include "net/Mode.h"
+#include "modplatform/ModAPI.h"
class MinecraftInstance;
struct PackProfileData;
@@ -117,6 +118,8 @@ public:
// todo(merged): is this the best approach
void appendComponent(ComponentPtr component);
+ ModAPI::ModLoaderType getModLoader();
+
private:
void scheduleSave();
bool saveIsScheduled() const;
diff --git a/launcher/minecraft/VersionFile.cpp b/launcher/minecraft/VersionFile.cpp
index d0a1a507..9db30ba2 100644
--- a/launcher/minecraft/VersionFile.cpp
+++ b/launcher/minecraft/VersionFile.cpp
@@ -1,3 +1,38 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
+ *
+ * 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
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include <QJsonArray>
#include <QJsonDocument>
@@ -32,10 +67,12 @@ void VersionFile::applyTo(LaunchProfile *profile)
profile->applyMainClass(mainClass);
profile->applyAppletClass(appletClass);
profile->applyMinecraftArguments(minecraftArguments);
+ profile->applyAddnJvmArguments(addnJvmArguments);
profile->applyTweakers(addTweakers);
profile->applyJarMods(jarMods);
profile->applyMods(mods);
profile->applyTraits(traits);
+ profile->applyCompatibleJavaMajors(compatibleJavaMajors);
for (auto library : libraries)
{
@@ -45,6 +82,10 @@ void VersionFile::applyTo(LaunchProfile *profile)
{
profile->applyMavenFile(mavenFile);
}
+ for (auto agent : agents)
+ {
+ profile->applyAgent(agent);
+ }
profile->applyProblemSeverity(getProblemSeverity());
}
diff --git a/launcher/minecraft/VersionFile.h b/launcher/minecraft/VersionFile.h
index 239a4069..d4b29719 100644
--- a/launcher/minecraft/VersionFile.h
+++ b/launcher/minecraft/VersionFile.h
@@ -1,3 +1,38 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
+ *
+ * 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
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
#include <QString>
@@ -10,6 +45,7 @@
#include "minecraft/Rule.h"
#include "ProblemProvider.h"
#include "Library.h"
+#include "Agent.h"
#include <meta/JsonFormat.h>
class PackProfile;
@@ -57,6 +93,12 @@ public: /* data */
/// Mojang: Minecraft launch arguments (may contain placeholders for variable substitution)
QString minecraftArguments;
+ /// PolyMC: Additional JVM launch arguments
+ QStringList addnJvmArguments;
+
+ /// Mojang: list of compatible java majors
+ QList<int> compatibleJavaMajors;
+
/// Mojang: type of the Minecraft version
QString type;
@@ -78,6 +120,9 @@ public: /* data */
/// PolyMC: list of maven files to put in the libraries folder, but not in classpath
QList<LibraryPtr> mavenFiles;
+ /// PolyMC: list of agents to add to JVM arguments
+ QList<AgentPtr> agents;
+
/// The main jar (Minecraft version library, normally)
LibraryPtr mainJar;
diff --git a/launcher/minecraft/World.cpp b/launcher/minecraft/World.cpp
index 2937c116..dc756e06 100644
--- a/launcher/minecraft/World.cpp
+++ b/launcher/minecraft/World.cpp
@@ -17,6 +17,7 @@
#include <QString>
#include <QDebug>
#include <QSaveFile>
+#include <QDirIterator>
#include "World.h"
#include "GZip.h"
@@ -187,6 +188,26 @@ bool putLevelDatDataToFS(const QFileInfo &file, QByteArray & data)
return f.commit();
}
+int64_t calculateWorldSize(const QFileInfo &file)
+{
+ if (file.isFile() && file.suffix() == "zip")
+ {
+ return file.size();
+ }
+ else if(file.isDir())
+ {
+ QDirIterator it(file.absoluteFilePath(), QDir::Files, QDirIterator::Subdirectories);
+ int64_t total = 0;
+ while (it.hasNext())
+ {
+ total += it.fileInfo().size();
+ it.next();
+ }
+ return total;
+ }
+ return -1;
+}
+
World::World(const QFileInfo &file)
{
repath(file);
@@ -196,6 +217,7 @@ void World::repath(const QFileInfo &file)
{
m_containerFile = file;
m_folderName = file.fileName();
+ m_size = calculateWorldSize(file);
if(file.isFile() && file.suffix() == "zip")
{
m_iconFile = QString();
@@ -482,6 +504,7 @@ void World::loadFromLevelDat(QByteArray data)
if(randomSeed) {
qDebug() << "Seed:" << *randomSeed;
}
+ qDebug() << "Size:" << m_size;
qDebug() << "GameType:" << m_gameType.toLogString();
}
diff --git a/launcher/minecraft/World.h b/launcher/minecraft/World.h
index 35e32788..0f587620 100644
--- a/launcher/minecraft/World.h
+++ b/launcher/minecraft/World.h
@@ -52,6 +52,10 @@ public:
{
return m_iconFile;
}
+ int64_t bytes() const
+ {
+ return m_size;
+ }
QDateTime lastPlayed() const
{
return m_lastPlayed;
@@ -105,6 +109,7 @@ protected:
QString m_iconFile;
QDateTime levelDatTime;
QDateTime m_lastPlayed;
+ int64_t m_size;
int64_t m_randomSeed = 0;
GameType m_gameType;
bool is_valid = false;
diff --git a/launcher/minecraft/WorldList.cpp b/launcher/minecraft/WorldList.cpp
index dcdbc321..344bea63 100644
--- a/launcher/minecraft/WorldList.cpp
+++ b/launcher/minecraft/WorldList.cpp
@@ -14,6 +14,8 @@
*/
#include "WorldList.h"
+
+#include "Application.h"
#include <FileSystem.h>
#include <QMimeData>
#include <QUrl>
@@ -150,7 +152,7 @@ bool WorldList::resetIcon(int row)
int WorldList::columnCount(const QModelIndex &parent) const
{
- return 3;
+ return 4;
}
QVariant WorldList::data(const QModelIndex &index, int role) const
@@ -164,6 +166,8 @@ QVariant WorldList::data(const QModelIndex &index, int role) const
if (row < 0 || row >= worlds.size())
return QVariant();
+ QLocale locale;
+
auto & world = worlds[row];
switch (role)
{
@@ -179,6 +183,9 @@ QVariant WorldList::data(const QModelIndex &index, int role) const
case LastPlayedColumn:
return world.lastPlayed();
+ case SizeColumn:
+ return locale.formattedDataSize(world.bytes());
+
default:
return QVariant();
}
@@ -207,6 +214,10 @@ QVariant WorldList::data(const QModelIndex &index, int role) const
{
return world.lastPlayed();
}
+ case SizeRole:
+ {
+ return locale.formattedDataSize(world.bytes());
+ }
case IconFileRole:
{
return world.iconFile();
@@ -229,6 +240,9 @@ QVariant WorldList::headerData(int section, Qt::Orientation orientation, int rol
return tr("Game Mode");
case LastPlayedColumn:
return tr("Last Played");
+ case SizeColumn:
+ //: World size on disk
+ return tr("Size");
default:
return QVariant();
}
@@ -242,6 +256,8 @@ QVariant WorldList::headerData(int section, Qt::Orientation orientation, int rol
return tr("Game mode of the world.");
case LastPlayedColumn:
return tr("Date and time the world was last played.");
+ case SizeColumn:
+ return tr("Size of the world on disk.");
default:
return QVariant();
}
diff --git a/launcher/minecraft/WorldList.h b/launcher/minecraft/WorldList.h
index 8e238ee3..5138e583 100644
--- a/launcher/minecraft/WorldList.h
+++ b/launcher/minecraft/WorldList.h
@@ -32,7 +32,8 @@ public:
{
NameColumn,
GameModeColumn,
- LastPlayedColumn
+ LastPlayedColumn,
+ SizeColumn
};
enum Roles
@@ -43,6 +44,7 @@ public:
NameRole,
GameModeRole,
LastPlayedRole,
+ SizeRole,
IconFileRole
};
diff --git a/launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp b/launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp
index 07eeb7dc..589768e3 100644
--- a/launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp
+++ b/launcher/minecraft/auth/steps/XboxAuthorizationStep.cpp
@@ -65,7 +65,7 @@ void XboxAuthorizationStep::onRequestDone(
if(!processSTSError(error, data, headers)) {
emit finished(
AccountTaskState::STATE_FAILED_SOFT,
- tr("Failed to get authorization for %1 services. Error %1.").arg(m_authorizationKind, error)
+ tr("Failed to get authorization for %1 services. Error %2.").arg(m_authorizationKind, error)
);
}
return;
diff --git a/launcher/minecraft/launch/LauncherPartLaunch.cpp b/launcher/minecraft/launch/LauncherPartLaunch.cpp
index d15d7e9d..173f29b5 100644
--- a/launcher/minecraft/launch/LauncherPartLaunch.cpp
+++ b/launcher/minecraft/launch/LauncherPartLaunch.cpp
@@ -170,6 +170,7 @@ void LauncherPartLaunch::on_state(LoggedProcess::State state)
{
if (APPLICATION->settings()->get("CloseAfterLaunch").toBool())
APPLICATION->showMainWindow();
+
m_parent->setPid(-1);
// if the exit code wasn't 0, report this as a crash
auto exitCode = m_process.exitCode();
diff --git a/launcher/minecraft/launch/VerifyJavaInstall.cpp b/launcher/minecraft/launch/VerifyJavaInstall.cpp
index 15acf678..99809f82 100644
--- a/launcher/minecraft/launch/VerifyJavaInstall.cpp
+++ b/launcher/minecraft/launch/VerifyJavaInstall.cpp
@@ -1,50 +1,75 @@
-#include "VerifyJavaInstall.h"
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
+ *
+ * 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
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
-#include <launch/LaunchTask.h>
-#include <minecraft/MinecraftInstance.h>
-#include <minecraft/PackProfile.h>
-#include <minecraft/VersionFilterData.h>
+#include "VerifyJavaInstall.h"
-#ifdef major
- #undef major
-#endif
-#ifdef minor
- #undef minor
-#endif
+#include "java/JavaVersion.h"
+#include "minecraft/PackProfile.h"
+#include "minecraft/MinecraftInstance.h"
void VerifyJavaInstall::executeTask() {
- auto m_inst = std::dynamic_pointer_cast<MinecraftInstance>(m_parent->instance());
-
- auto javaVersion = m_inst->getJavaVersion();
- auto minecraftComponent = m_inst->getPackProfile()->getComponent("net.minecraft");
-
- // Java 17 requirement
- if (minecraftComponent->getReleaseDateTime() >= g_VersionFilterData.java17BeginsDate) {
- if (javaVersion.major() < 17) {
- emit logLine("Minecraft 1.18 Pre Release 2 and above require the use of Java 17",
- MessageLevel::Fatal);
- emitFailed(tr("Minecraft 1.18 Pre Release 2 and above require the use of Java 17"));
- return;
- }
- }
- // Java 16 requirement
- else if (minecraftComponent->getReleaseDateTime() >= g_VersionFilterData.java16BeginsDate) {
- if (javaVersion.major() < 16) {
- emit logLine("Minecraft 21w19a and above require the use of Java 16",
- MessageLevel::Fatal);
- emitFailed(tr("Minecraft 21w19a and above require the use of Java 16"));
- return;
- }
+ auto instance = std::dynamic_pointer_cast<MinecraftInstance>(m_parent->instance());
+ auto packProfile = instance->getPackProfile();
+ auto settings = instance->settings();
+ auto storedVersion = settings->get("JavaVersion").toString();
+ auto ignoreCompatibility = settings->get("IgnoreJavaCompatibility").toBool();
+
+ auto compatibleMajors = packProfile->getProfile()->getCompatibleJavaMajors();
+
+ JavaVersion javaVersion(storedVersion);
+
+ if (compatibleMajors.isEmpty() || compatibleMajors.contains(javaVersion.major()))
+ {
+ emitSucceeded();
+ return;
}
- // Java 8 requirement
- else if (minecraftComponent->getReleaseDateTime() >= g_VersionFilterData.java8BeginsDate) {
- if (javaVersion.major() < 8) {
- emit logLine("Minecraft 17w13a and above require the use of Java 8",
- MessageLevel::Fatal);
- emitFailed(tr("Minecraft 17w13a and above require the use of Java 8"));
- return;
- }
+
+
+ if (ignoreCompatibility)
+ {
+ emit logLine(tr("Java major version is incompatible. Things might break."), MessageLevel::Warning);
+ emitSucceeded();
+ return;
}
- emitSucceeded();
+ emit logLine(tr("This instance is not compatible with Java version %1.\n"
+ "Please switch to one of the following Java versions for this instance:").arg(javaVersion.major()),
+ MessageLevel::Error);
+ for (auto major : compatibleMajors)
+ {
+ emit logLine(tr("Java version %1").arg(major), MessageLevel::Error);
+ }
+ emitFailed(QString("Incompatible Java major version"));
}
diff --git a/launcher/minecraft/launch/VerifyJavaInstall.h b/launcher/minecraft/launch/VerifyJavaInstall.h
index a553106d..9139c0fa 100644
--- a/launcher/minecraft/launch/VerifyJavaInstall.h
+++ b/launcher/minecraft/launch/VerifyJavaInstall.h
@@ -1,6 +1,42 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
+ *
+ * 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
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#pragma once
#include <launch/LaunchStep.h>
+#include <launch/LaunchTask.h>
class VerifyJavaInstall : public LaunchStep {
Q_OBJECT
diff --git a/launcher/minecraft/mod/LocalModParseTask.cpp b/launcher/minecraft/mod/LocalModParseTask.cpp
index 757a2187..f01da8ae 100644
--- a/launcher/minecraft/mod/LocalModParseTask.cpp
+++ b/launcher/minecraft/mod/LocalModParseTask.cpp
@@ -391,7 +391,7 @@ void LocalModParseTask::processAsZip()
zip.close();
return;
}
- else if (zip.setCurrentFile("fabric.mod.json"))
+ else if (zip.setCurrentFile("fabric.mod.json")) // TODO: Support quilt.mod.json
{
if (!file.open(QIODevice::ReadOnly))
{
diff --git a/launcher/minecraft/update/LibrariesTask.cpp b/launcher/minecraft/update/LibrariesTask.cpp
index 667dd5d9..26679110 100644
--- a/launcher/minecraft/update/LibrariesTask.cpp
+++ b/launcher/minecraft/update/LibrariesTask.cpp
@@ -48,6 +48,10 @@ void LibrariesTask::executeTask()
libArtifactPool.append(profile->getLibraries());
libArtifactPool.append(profile->getNativeLibraries());
libArtifactPool.append(profile->getMavenFiles());
+ for (auto agent : profile->getAgents())
+ {
+ libArtifactPool.append(agent->library());
+ }
libArtifactPool.append(profile->getMainJar());
processArtifactPool(libArtifactPool, failedLocalLibraries, inst->getLocalLibraryPath());
diff --git a/launcher/modplatform/ModAPI.h b/launcher/modplatform/ModAPI.h
new file mode 100644
index 00000000..1a562172
--- /dev/null
+++ b/launcher/modplatform/ModAPI.h
@@ -0,0 +1,56 @@
+#pragma once
+
+#include <QString>
+#include <QList>
+
+namespace ModPlatform {
+class ListModel;
+}
+
+class ModAPI {
+ protected:
+ using CallerType = ModPlatform::ListModel;
+
+ public:
+ virtual ~ModAPI() = default;
+
+ // https://docs.curseforge.com/?http#tocS_ModLoaderType
+ enum ModLoaderType { Unspecified = 0, Forge = 1, Cauldron = 2, LiteLoader = 3, Fabric = 4, Quilt = 5 };
+
+ struct SearchArgs {
+ int offset;
+ QString search;
+ QString sorting;
+ ModLoaderType mod_loader;
+ QString version;
+ };
+
+ virtual void searchMods(CallerType* caller, SearchArgs&& args) const = 0;
+
+
+ struct VersionSearchArgs {
+ QString addonId;
+ QList<QString> mcVersions;
+ ModLoaderType loader;
+ };
+
+ virtual void getVersions(CallerType* caller, VersionSearchArgs&& args) const = 0;
+
+ static auto getModLoaderString(ModLoaderType type) -> const QString {
+ switch (type) {
+ case Unspecified:
+ break;
+ case Forge:
+ return "forge";
+ case Cauldron:
+ return "cauldron";
+ case LiteLoader:
+ return "liteloader";
+ case Fabric:
+ return "fabric";
+ case Quilt:
+ return "quilt";
+ }
+ return "";
+ }
+};
diff --git a/launcher/modplatform/ModIndex.h b/launcher/modplatform/ModIndex.h
new file mode 100644
index 00000000..7e1cf254
--- /dev/null
+++ b/launcher/modplatform/ModIndex.h
@@ -0,0 +1,42 @@
+#pragma once
+
+#include <QList>
+#include <QMetaType>
+#include <QString>
+#include <QVariant>
+#include <QVector>
+
+namespace ModPlatform {
+
+struct ModpackAuthor {
+ QString name;
+ QString url;
+};
+
+struct IndexedVersion {
+ QVariant addonId;
+ QVariant fileId;
+ QString version;
+ QVector<QString> mcVersion;
+ QString downloadUrl;
+ QString date;
+ QString fileName;
+ QVector<QString> loaders = {};
+};
+
+struct IndexedPack {
+ QVariant addonId;
+ QString name;
+ QString description;
+ QList<ModpackAuthor> authors;
+ QString logoName;
+ QString logoUrl;
+ QString websiteUrl;
+
+ bool versionsLoaded = false;
+ QVector<IndexedVersion> versions;
+};
+
+} // namespace ModPlatform
+
+Q_DECLARE_METATYPE(ModPlatform::IndexedPack)
diff --git a/launcher/modplatform/flame/FlameAPI.h b/launcher/modplatform/flame/FlameAPI.h
new file mode 100644
index 00000000..8654a693
--- /dev/null
+++ b/launcher/modplatform/flame/FlameAPI.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#include "modplatform/helpers/NetworkModAPI.h"
+
+class FlameAPI : public NetworkModAPI {
+ private:
+ inline auto getModSearchURL(SearchArgs& args) const -> QString override
+ {
+ return QString(
+ "https://addons-ecs.forgesvc.net/api/v2/addon/search?"
+ "gameId=432&"
+ "categoryId=0&"
+ "sectionId=6&"
+
+ "index=%1&"
+ "pageSize=25&"
+ "searchFilter=%2&"
+ "sort=%3&"
+ "modLoaderType=%4&"
+ "gameVersion=%5")
+ .arg(args.offset)
+ .arg(args.search)
+ .arg(args.sorting)
+ .arg(args.mod_loader)
+ .arg(args.version);
+ };
+
+ inline auto getVersionsURL(VersionSearchArgs& args) const -> QString override
+ {
+ return QString("https://addons-ecs.forgesvc.net/api/v2/addon/%1/files").arg(args.addonId);
+ };
+};
diff --git a/launcher/modplatform/flame/FlameModIndex.cpp b/launcher/modplatform/flame/FlameModIndex.cpp
index 4adaf5f1..e86b64dd 100644
--- a/launcher/modplatform/flame/FlameModIndex.cpp
+++ b/launcher/modplatform/flame/FlameModIndex.cpp
@@ -1,13 +1,11 @@
-#include <QObject>
#include "FlameModIndex.h"
+
#include "Json.h"
-#include "net/NetJob.h"
-#include "BaseInstance.h"
#include "minecraft/MinecraftInstance.h"
#include "minecraft/PackProfile.h"
+#include "net/NetJob.h"
-
-void FlameMod::loadIndexedPack(FlameMod::IndexedPack & pack, QJsonObject & obj)
+void FlameMod::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj)
{
pack.addonId = Json::requireInteger(obj, "id");
pack.name = Json::requireString(obj, "name");
@@ -16,10 +14,10 @@ void FlameMod::loadIndexedPack(FlameMod::IndexedPack & pack, QJsonObject & obj)
bool thumbnailFound = false;
auto attachments = Json::requireArray(obj, "attachments");
- for(auto attachmentRaw: attachments) {
+ for (auto attachmentRaw : attachments) {
auto attachmentObj = Json::requireObject(attachmentRaw);
bool isDefault = attachmentObj.value("isDefault").toBool(false);
- if(isDefault) {
+ if (isDefault) {
thumbnailFound = true;
pack.logoName = Json::requireString(attachmentObj, "title");
pack.logoUrl = Json::requireString(attachmentObj, "thumbnailUrl");
@@ -27,37 +25,35 @@ void FlameMod::loadIndexedPack(FlameMod::IndexedPack & pack, QJsonObject & obj)
}
}
- if(!thumbnailFound) {
- throw JSONValidationError(QString("Pack without an icon, skipping: %1").arg(pack.name));
- }
-
+ if (!thumbnailFound) { throw JSONValidationError(QString("Pack without an icon, skipping: %1").arg(pack.name)); }
auto authors = Json::requireArray(obj, "authors");
- for(auto authorIter: authors) {
+ for (auto authorIter : authors) {
auto author = Json::requireObject(authorIter);
- FlameMod::ModpackAuthor packAuthor;
+ ModPlatform::ModpackAuthor packAuthor;
packAuthor.name = Json::requireString(author, "name");
packAuthor.url = Json::requireString(author, "url");
pack.authors.append(packAuthor);
}
}
-void FlameMod::loadIndexedPackVersions(FlameMod::IndexedPack & pack, QJsonArray & arr, const shared_qobject_ptr<QNetworkAccessManager>& network, BaseInstance * inst)
+void FlameMod::loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
+ QJsonArray& arr,
+ const shared_qobject_ptr<QNetworkAccessManager>& network,
+ BaseInstance* inst)
{
- QVector<FlameMod::IndexedVersion> unsortedVersions;
- bool hasFabric = !((MinecraftInstance *)inst)->getPackProfile()->getComponentVersion("net.fabricmc.fabric-loader").isEmpty();
- QString mcVersion = ((MinecraftInstance *)inst)->getPackProfile()->getComponentVersion("net.minecraft");
+ QVector<ModPlatform::IndexedVersion> unsortedVersions;
+ bool hasFabric = !(dynamic_cast<MinecraftInstance*>(inst))->getPackProfile()->getComponentVersion("net.fabricmc.fabric-loader").isEmpty();
+ QString mcVersion = (dynamic_cast<MinecraftInstance*>(inst))->getPackProfile()->getComponentVersion("net.minecraft");
- for(auto versionIter: arr) {
+ for (auto versionIter : arr) {
auto obj = versionIter.toObject();
auto versionArray = Json::requireArray(obj, "gameVersion");
- if (versionArray.isEmpty()) {
- continue;
- }
+ if (versionArray.isEmpty()) { continue; }
- FlameMod::IndexedVersion file;
- for(auto mcVer : versionArray){
+ ModPlatform::IndexedVersion file;
+ for (auto mcVer : versionArray) {
file.mcVersion.append(mcVer.toString());
}
@@ -70,29 +66,28 @@ void FlameMod::loadIndexedPackVersions(FlameMod::IndexedPack & pack, QJsonArray
auto modules = Json::requireArray(obj, "modules");
bool is_valid_fabric_version = false;
- for(auto m : modules){
- auto fname = Json::requireString(m.toObject(),"foldername");
+ for (auto m : modules) {
+ auto fname = Json::requireString(m.toObject(), "foldername");
// FIXME: This does not work properly when a mod supports more than one mod loader, since
+ // FIXME: This also doesn't deal with Quilt mods at the moment
// they bundle the meta files for all of them in the same arquive, even when that version
// doesn't support the given mod loader.
- if(hasFabric){
- if(fname == "fabric.mod.json"){
+ if (hasFabric) {
+ if (fname == "fabric.mod.json") {
is_valid_fabric_version = true;
break;
}
- }
- else break;
+ } else
+ break;
// NOTE: Since we're not validating forge versions, we can just skip this loop.
}
- if(hasFabric && !is_valid_fabric_version)
- continue;
+ if (hasFabric && !is_valid_fabric_version) continue;
unsortedVersions.append(file);
}
- auto orderSortPredicate = [](const IndexedVersion & a, const IndexedVersion & b) -> bool
- {
- //dates are in RFC 3339 format
+ auto orderSortPredicate = [](const ModPlatform::IndexedVersion& a, const ModPlatform::IndexedVersion& b) -> bool {
+ // dates are in RFC 3339 format
return a.date > b.date;
};
std::sort(unsortedVersions.begin(), unsortedVersions.end(), orderSortPredicate);
diff --git a/launcher/modplatform/flame/FlameModIndex.h b/launcher/modplatform/flame/FlameModIndex.h
index 0293bb23..d3171d94 100644
--- a/launcher/modplatform/flame/FlameModIndex.h
+++ b/launcher/modplatform/flame/FlameModIndex.h
@@ -3,48 +3,18 @@
//
#pragma once
-#include <QList>
-#include <QMetaType>
-#include <QString>
-#include <QVector>
-#include <QNetworkAccessManager>
-#include <QObjectPtr.h>
-#include "net/NetJob.h"
-#include "BaseInstance.h"
-
-namespace FlameMod {
- struct ModpackAuthor {
- QString name;
- QString url;
- };
- struct IndexedVersion {
- int addonId;
- int fileId;
- QString version;
- QVector<QString> mcVersion;
- QString downloadUrl;
- QString date;
- QString fileName;
- };
+#include "modplatform/ModIndex.h"
- struct IndexedPack
- {
- int addonId;
- QString name;
- QString description;
- QList<ModpackAuthor> authors;
- QString logoName;
- QString logoUrl;
- QString websiteUrl;
-
- bool versionsLoaded = false;
- QVector<IndexedVersion> versions;
- };
+#include "BaseInstance.h"
+#include <QNetworkAccessManager>
- void loadIndexedPack(IndexedPack & m, QJsonObject & obj);
- void loadIndexedPackVersions(IndexedPack &pack, QJsonArray &arr, const shared_qobject_ptr<QNetworkAccessManager> &network, BaseInstance *inst);
+namespace FlameMod {
-}
+void loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj);
+void loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
+ QJsonArray& arr,
+ const shared_qobject_ptr<QNetworkAccessManager>& network,
+ BaseInstance* inst);
-Q_DECLARE_METATYPE(FlameMod::IndexedPack)
+} // namespace FlameMod
diff --git a/launcher/modplatform/helpers/NetworkModAPI.cpp b/launcher/modplatform/helpers/NetworkModAPI.cpp
new file mode 100644
index 00000000..6829b837
--- /dev/null
+++ b/launcher/modplatform/helpers/NetworkModAPI.cpp
@@ -0,0 +1,60 @@
+#include "NetworkModAPI.h"
+
+#include "ui/pages/modplatform/ModModel.h"
+
+#include "Application.h"
+#include "net/NetJob.h"
+
+void NetworkModAPI::searchMods(CallerType* caller, SearchArgs&& args) const
+{
+ auto netJob = new NetJob(QString("%1::Search").arg(caller->debugName()), APPLICATION->network());
+ auto searchUrl = getModSearchURL(args);
+
+ auto response = new QByteArray();
+ netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), response));
+
+ QObject::connect(netJob, &NetJob::started, caller, [caller, netJob] { caller->setActiveJob(netJob); });
+ QObject::connect(netJob, &NetJob::failed, caller, &CallerType::searchRequestFailed);
+ QObject::connect(netJob, &NetJob::succeeded, caller, [caller, response] {
+ QJsonParseError parse_error{};
+ QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error);
+ if (parse_error.error != QJsonParseError::NoError) {
+ qWarning() << "Error while parsing JSON response from " << caller->debugName() << " at " << parse_error.offset
+ << " reason: " << parse_error.errorString();
+ qWarning() << *response;
+ return;
+ }
+
+ caller->searchRequestFinished(doc);
+ });
+
+ netJob->start();
+}
+
+void NetworkModAPI::getVersions(CallerType* caller, VersionSearchArgs&& args) const
+{
+ auto netJob = new NetJob(QString("%1::ModVersions(%2)").arg(caller->debugName()).arg(args.addonId), APPLICATION->network());
+ auto response = new QByteArray();
+
+ netJob->addNetAction(Net::Download::makeByteArray(getVersionsURL(args), response));
+
+ QObject::connect(netJob, &NetJob::succeeded, caller, [response, caller, args] {
+ QJsonParseError parse_error{};
+ QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error);
+ if (parse_error.error != QJsonParseError::NoError) {
+ qWarning() << "Error while parsing JSON response from " << caller->debugName() << " at " << parse_error.offset
+ << " reason: " << parse_error.errorString();
+ qWarning() << *response;
+ return;
+ }
+
+ caller->versionRequestSucceeded(doc, args.addonId);
+ });
+
+ QObject::connect(netJob, &NetJob::finished, caller, [response, netJob] {
+ netJob->deleteLater();
+ delete response;
+ });
+
+ netJob->start();
+}
diff --git a/launcher/modplatform/helpers/NetworkModAPI.h b/launcher/modplatform/helpers/NetworkModAPI.h
new file mode 100644
index 00000000..000620b2
--- /dev/null
+++ b/launcher/modplatform/helpers/NetworkModAPI.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#include "modplatform/ModAPI.h"
+
+class NetworkModAPI : public ModAPI {
+ public:
+ void searchMods(CallerType* caller, SearchArgs&& args) const override;
+ void getVersions(CallerType* caller, VersionSearchArgs&& args) const override;
+
+ protected:
+ virtual auto getModSearchURL(SearchArgs& args) const -> QString = 0;
+ virtual auto getVersionsURL(VersionSearchArgs& args) const -> QString = 0;
+};
diff --git a/launcher/modplatform/modrinth/ModrinthAPI.h b/launcher/modplatform/modrinth/ModrinthAPI.h
new file mode 100644
index 00000000..eefa4a85
--- /dev/null
+++ b/launcher/modplatform/modrinth/ModrinthAPI.h
@@ -0,0 +1,66 @@
+#pragma once
+
+#include "modplatform/helpers/NetworkModAPI.h"
+
+#include <QDebug>
+
+class ModrinthAPI : public NetworkModAPI {
+ public:
+ inline auto getAuthorURL(const QString& name) const -> QString { return "https://modrinth.com/user/" + name; };
+
+ private:
+ inline auto getModSearchURL(SearchArgs& args) const -> QString override
+ {
+ if (!validateModLoader(args.mod_loader)) {
+ qWarning() << "Modrinth only have Forge and Fabric-compatible mods!";
+ return "";
+ }
+
+ return QString(
+ "https://api.modrinth.com/v2/search?"
+ "offset=%1&"
+ "limit=25&"
+ "query=%2&"
+ "index=%3&"
+ "facets=[[\"categories:%4\"],[\"versions:%5\"],[\"project_type:mod\"]]")
+ .arg(args.offset)
+ .arg(args.search)
+ .arg(args.sorting)
+ .arg(getModLoaderString(args.mod_loader))
+ .arg(args.version);
+ };
+
+ inline auto getVersionsURL(VersionSearchArgs& args) const -> QString override
+ {
+ return QString("https://api.modrinth.com/v2/project/%1/version?"
+ "game_versions=[%2]"
+ "loaders=[%3]")
+ .arg(args.addonId)
+ .arg(getGameVersionsString(args.mcVersions))
+ .arg(getModLoaderString(args.loader));
+ };
+
+ inline auto getGameVersionsString(QList<QString> mcVersions) const -> QString
+ {
+ QString s;
+ for(int i = 0; i < mcVersions.count(); i++){
+ s += mcVersions.at(i);
+ if(i < mcVersions.count() - 1)
+ s += ",";
+ }
+ return s;
+ }
+
+ static auto getModLoaderString(ModLoaderType type) -> const QString
+ {
+ if (type == Unspecified)
+ return "fabric, forge, quilt";
+ return ModAPI::getModLoaderString(type);
+ }
+
+ inline auto validateModLoader(ModLoaderType modLoader) const -> bool
+ {
+ return modLoader == Unspecified || modLoader == Forge || modLoader == Fabric || modLoader == Quilt;
+ }
+
+};
diff --git a/launcher/modplatform/modrinth/ModrinthPackIndex.cpp b/launcher/modplatform/modrinth/ModrinthPackIndex.cpp
index 9581ca04..a3c2f166 100644
--- a/launcher/modplatform/modrinth/ModrinthPackIndex.cpp
+++ b/launcher/modplatform/modrinth/ModrinthPackIndex.cpp
@@ -1,50 +1,56 @@
-#include <QObject>
#include "ModrinthPackIndex.h"
+#include "ModrinthAPI.h"
#include "Json.h"
-#include "net/NetJob.h"
-#include "BaseInstance.h"
#include "minecraft/MinecraftInstance.h"
#include "minecraft/PackProfile.h"
+#include "net/NetJob.h"
+static ModrinthAPI api;
-void Modrinth::loadIndexedPack(Modrinth::IndexedPack & pack, QJsonObject & obj)
+void Modrinth::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj)
{
pack.addonId = Json::requireString(obj, "project_id");
pack.name = Json::requireString(obj, "title");
- pack.websiteUrl = Json::ensureString(obj, "page_url", "");
+
+ QString slug = Json::ensureString(obj, "slug", "");
+ if (!slug.isEmpty())
+ pack.websiteUrl = "https://modrinth.com/mod/" + Json::ensureString(obj, "slug", "");
+ else
+ pack.websiteUrl = "";
+
pack.description = Json::ensureString(obj, "description", "");
pack.logoUrl = Json::requireString(obj, "icon_url");
- pack.logoName = pack.addonId;
+ pack.logoName = pack.addonId.toString();
- Modrinth::ModpackAuthor modAuthor;
+ ModPlatform::ModpackAuthor modAuthor;
modAuthor.name = Json::requireString(obj, "author");
- modAuthor.url = "https://modrinth.com/user/"+modAuthor.name;
- pack.author = modAuthor;
+ modAuthor.url = api.getAuthorURL(modAuthor.name);
+ pack.authors.append(modAuthor);
}
-void Modrinth::loadIndexedPackVersions(Modrinth::IndexedPack & pack, QJsonArray & arr, const shared_qobject_ptr<QNetworkAccessManager>& network, BaseInstance * inst)
+void Modrinth::loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
+ QJsonArray& arr,
+ const shared_qobject_ptr<QNetworkAccessManager>& network,
+ BaseInstance* inst)
{
- QVector<Modrinth::IndexedVersion> unsortedVersions;
- bool hasFabric = !((MinecraftInstance *)inst)->getPackProfile()->getComponentVersion("net.fabricmc.fabric-loader").isEmpty();
- QString mcVersion = ((MinecraftInstance *)inst)->getPackProfile()->getComponentVersion("net.minecraft");
+ QVector<ModPlatform::IndexedVersion> unsortedVersions;
+ QString mcVersion = (static_cast<MinecraftInstance*>(inst))->getPackProfile()->getComponentVersion("net.minecraft");
- for(auto versionIter: arr) {
+ for (auto versionIter : arr) {
auto obj = versionIter.toObject();
- Modrinth::IndexedVersion file;
- file.addonId = Json::requireString(obj,"project_id") ;
+ ModPlatform::IndexedVersion file;
+ file.addonId = Json::requireString(obj, "project_id");
file.fileId = Json::requireString(obj, "id");
file.date = Json::requireString(obj, "date_published");
auto versionArray = Json::requireArray(obj, "game_versions");
- if (versionArray.empty()) {
- continue;
- }
- for(auto mcVer : versionArray){
+ if (versionArray.empty()) { continue; }
+ for (auto mcVer : versionArray) {
file.mcVersion.append(mcVer.toString());
}
- auto loaders = Json::requireArray(obj,"loaders");
- for(auto loader : loaders){
+ auto loaders = Json::requireArray(obj, "loaders");
+ for (auto loader : loaders) {
file.loaders.append(loader.toString());
}
file.version = Json::requireString(obj, "name");
@@ -55,21 +61,11 @@ void Modrinth::loadIndexedPackVersions(Modrinth::IndexedPack & pack, QJsonArray
// Find correct file (needed in cases where one version may have multiple files)
// Will default to the last one if there's no primary (though I think Modrinth requires that
// at least one file is primary, idk)
- while (i < files.count()){
+ // NOTE: files.count() is 1-indexed, so we need to subtract 1 to become 0-indexed
+ while (i < files.count() - 1){
auto parent = files[i].toObject();
auto fileName = Json::requireString(parent, "filename");
- // Grab the correct mod loader
- if(hasFabric){
- if(fileName.contains("forge",Qt::CaseInsensitive)){
- i++;
- continue;
- }
- } else if(fileName.contains("fabric", Qt::CaseInsensitive)){
- i++;
- continue;
- }
-
// Grab the primary file, if available
if(Json::requireBoolean(parent, "primary"))
break;
@@ -78,16 +74,15 @@ void Modrinth::loadIndexedPackVersions(Modrinth::IndexedPack & pack, QJsonArray
}
auto parent = files[i].toObject();
- if(parent.contains("url")) {
+ if (parent.contains("url")) {
file.downloadUrl = Json::requireString(parent, "url");
file.fileName = Json::requireString(parent, "filename");
unsortedVersions.append(file);
}
}
- auto orderSortPredicate = [](const IndexedVersion & a, const IndexedVersion & b) -> bool
- {
- //dates are in RFC 3339 format
+ auto orderSortPredicate = [](const ModPlatform::IndexedVersion& a, const ModPlatform::IndexedVersion& b) -> bool {
+ // dates are in RFC 3339 format
return a.date > b.date;
};
std::sort(unsortedVersions.begin(), unsortedVersions.end(), orderSortPredicate);
diff --git a/launcher/modplatform/modrinth/ModrinthPackIndex.h b/launcher/modplatform/modrinth/ModrinthPackIndex.h
index 3a4cd270..fd17847a 100644
--- a/launcher/modplatform/modrinth/ModrinthPackIndex.h
+++ b/launcher/modplatform/modrinth/ModrinthPackIndex.h
@@ -1,48 +1,16 @@
#pragma once
-#include <QList>
-#include <QMetaType>
-#include <QString>
-#include <QVector>
-#include <QNetworkAccessManager>
-#include <QObjectPtr.h>
-#include "net/NetJob.h"
+#include "modplatform/ModIndex.h"
+
#include "BaseInstance.h"
+#include <QNetworkAccessManager>
namespace Modrinth {
-struct ModpackAuthor {
- QString name;
- QString url;
-};
-
-struct IndexedVersion {
- QString addonId;
- QString fileId;
- QString version;
- QVector<QString> mcVersion;
- QString downloadUrl;
- QString date;
- QString fileName;
- QVector<QString> loaders;
-};
-
-struct IndexedPack
-{
- QString addonId;
- QString name;
- QString description;
- ModpackAuthor author;
- QString logoName;
- QString logoUrl;
- QString websiteUrl;
-
- bool versionsLoaded = false;
- QVector<IndexedVersion> versions;
-};
-
-void loadIndexedPack(IndexedPack & m, QJsonObject & obj);
-void loadIndexedPackVersions(IndexedPack &pack, QJsonArray &arr, const shared_qobject_ptr<QNetworkAccessManager> &network, BaseInstance *inst);
-}
+void loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj);
+void loadIndexedPackVersions(ModPlatform::IndexedPack& pack,
+ QJsonArray& arr,
+ const shared_qobject_ptr<QNetworkAccessManager>& network,
+ BaseInstance* inst);
-Q_DECLARE_METATYPE(Modrinth::IndexedPack)
+} // namespace Modrinth
diff --git a/launcher/modplatform/technic/SolderPackInstallTask.cpp b/launcher/modplatform/technic/SolderPackInstallTask.cpp
index b5c91582..89dbf4ca 100644
--- a/launcher/modplatform/technic/SolderPackInstallTask.cpp
+++ b/launcher/modplatform/technic/SolderPackInstallTask.cpp
@@ -1,16 +1,36 @@
-/* Copyright 2013-2021 MultiMC Contributors
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (c) 2021-2022 Jamie Mansfield <jmansfield@cadixdev.org>
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * 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
+ * the Free Software Foundation, version 3.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
#include "SolderPackInstallTask.h"
@@ -19,16 +39,23 @@
#include <Json.h>
#include <QtConcurrentRun>
#include <MMCZip.h>
+
#include "TechnicPackProcessor.h"
+#include "SolderPackManifest.h"
+#include "net/ChecksumValidator.h"
Technic::SolderPackInstallTask::SolderPackInstallTask(
shared_qobject_ptr<QNetworkAccessManager> network,
- const QUrl &sourceUrl,
+ const QUrl &solderUrl,
+ const QString &pack,
+ const QString &version,
const QString &minecraftVersion
) {
- m_sourceUrl = sourceUrl;
- m_minecraftVersion = minecraftVersion;
+ m_solderUrl = solderUrl;
+ m_pack = pack;
+ m_version = version;
m_network = network;
+ m_minecraftVersion = minecraftVersion;
}
bool Technic::SolderPackInstallTask::abort() {
@@ -41,34 +68,12 @@ bool Technic::SolderPackInstallTask::abort() {
void Technic::SolderPackInstallTask::executeTask()
{
- setStatus(tr("Finding recommended version:\n%1").arg(m_sourceUrl.toString()));
- m_filesNetJob = new NetJob(tr("Finding recommended version"), m_network);
- m_filesNetJob->addNetAction(Net::Download::makeByteArray(m_sourceUrl, &m_response));
- auto job = m_filesNetJob.get();
- connect(job, &NetJob::succeeded, this, &Technic::SolderPackInstallTask::versionSucceeded);
- connect(job, &NetJob::failed, this, &Technic::SolderPackInstallTask::downloadFailed);
- m_filesNetJob->start();
-}
-
-void Technic::SolderPackInstallTask::versionSucceeded()
-{
- try
- {
- QJsonDocument doc = Json::requireDocument(m_response);
- QJsonObject obj = Json::requireObject(doc);
- QString version = Json::requireString(obj, "recommended", "__placeholder__");
- m_sourceUrl = m_sourceUrl.toString() + '/' + version;
- }
- catch (const JSONValidationError &e)
- {
- emitFailed(e.cause());
- m_filesNetJob.reset();
- return;
- }
+ setStatus(tr("Resolving modpack files"));
- setStatus(tr("Resolving modpack files:\n%1").arg(m_sourceUrl.toString()));
m_filesNetJob = new NetJob(tr("Resolving modpack files"), m_network);
- m_filesNetJob->addNetAction(Net::Download::makeByteArray(m_sourceUrl, &m_response));
+ auto sourceUrl = QString("%1/modpack/%2/%3").arg(m_solderUrl.toString(), m_pack, m_version);
+ m_filesNetJob->addNetAction(Net::Download::makeByteArray(sourceUrl, &m_response));
+
auto job = m_filesNetJob.get();
connect(job, &NetJob::succeeded, this, &Technic::SolderPackInstallTask::fileListSucceeded);
connect(job, &NetJob::failed, this, &Technic::SolderPackInstallTask::downloadFailed);
@@ -77,38 +82,47 @@ void Technic::SolderPackInstallTask::versionSucceeded()
void Technic::SolderPackInstallTask::fileListSucceeded()
{
- setStatus(tr("Downloading modpack:"));
- QStringList modUrls;
- try
- {
- QJsonDocument doc = Json::requireDocument(m_response);
- QJsonObject obj = Json::requireObject(doc);
- QString minecraftVersion = Json::ensureString(obj, "minecraft", QString(), "__placeholder__");
- if (!minecraftVersion.isEmpty())
- m_minecraftVersion = minecraftVersion;
- QJsonArray mods = Json::requireArray(obj, "mods", "'mods'");
- for (auto mod: mods)
- {
- QJsonObject modObject = Json::requireObject(mod);
- modUrls.append(Json::requireString(modObject, "url", "'url'"));
- }
+ setStatus(tr("Downloading modpack"));
+
+ QJsonParseError parse_error {};
+ QJsonDocument doc = QJsonDocument::fromJson(m_response, &parse_error);
+ if (parse_error.error != QJsonParseError::NoError) {
+ qWarning() << "Error while parsing JSON response from Solder at " << parse_error.offset << " reason: " << parse_error.errorString();
+ qWarning() << m_response;
+ return;
}
- catch (const JSONValidationError &e)
- {
- emitFailed(e.cause());
+ auto obj = doc.object();
+
+ TechnicSolder::PackBuild build;
+ try {
+ TechnicSolder::loadPackBuild(build, obj);
+ }
+ catch (const JSONValidationError& e) {
+ emitFailed(tr("Could not understand pack manifest:\n") + e.cause());
m_filesNetJob.reset();
return;
}
+
+ if (!build.minecraft.isEmpty())
+ m_minecraftVersion = build.minecraft;
+
m_filesNetJob = new NetJob(tr("Downloading modpack"), m_network);
+
int i = 0;
- for (auto &modUrl: modUrls)
- {
+ for (const auto &mod : build.mods) {
auto path = FS::PathCombine(m_outputDir.path(), QString("%1").arg(i));
- m_filesNetJob->addNetAction(Net::Download::makeFile(modUrl, path));
+
+ auto dl = Net::Download::makeFile(mod.url, path);
+ if (!mod.md5.isEmpty()) {
+ auto rawMd5 = QByteArray::fromHex(mod.md5.toLatin1());
+ dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Md5, rawMd5));
+ }
+ m_filesNetJob->addNetAction(dl);
+
i++;
}
- m_modCount = modUrls.size();
+ m_modCount = build.mods.size();
connect(m_filesNetJob.get(), &NetJob::succeeded, this, &Technic::SolderPackInstallTask::downloadSucceeded);
connect(m_filesNetJob.get(), &NetJob::progress, this, &Technic::SolderPackInstallTask::downloadProgressChanged);
@@ -206,6 +220,5 @@ void Technic::SolderPackInstallTask::extractFinished()
void Technic::SolderPackInstallTask::extractAborted()
{
emitFailed(tr("Instance import has been aborted."));
- return;
}
diff --git a/launcher/modplatform/technic/SolderPackInstallTask.h b/launcher/modplatform/technic/SolderPackInstallTask.h
index 9b2058d8..117a7bd6 100644
--- a/launcher/modplatform/technic/SolderPackInstallTask.h
+++ b/launcher/modplatform/technic/SolderPackInstallTask.h
@@ -1,16 +1,36 @@
-/* Copyright 2013-2021 MultiMC Contributors
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (c) 2021-2022 Jamie Mansfield <jmansfield@cadixdev.org>
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * 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
+ * the Free Software Foundation, version 3.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
#pragma once
@@ -27,7 +47,7 @@ namespace Technic
{
Q_OBJECT
public:
- explicit SolderPackInstallTask(shared_qobject_ptr<QNetworkAccessManager> network, const QUrl &sourceUrl, const QString &minecraftVersion);
+ explicit SolderPackInstallTask(shared_qobject_ptr<QNetworkAccessManager> network, const QUrl &solderUrl, const QString& pack, const QString& version, const QString &minecraftVersion);
bool canAbort() const override { return true; }
bool abort() override;
@@ -37,7 +57,6 @@ namespace Technic
virtual void executeTask() override;
private slots:
- void versionSucceeded();
void fileListSucceeded();
void downloadSucceeded();
void downloadFailed(QString reason);
@@ -51,7 +70,9 @@ namespace Technic
shared_qobject_ptr<QNetworkAccessManager> m_network;
NetJob::Ptr m_filesNetJob;
- QUrl m_sourceUrl;
+ QUrl m_solderUrl;
+ QString m_pack;
+ QString m_version;
QString m_minecraftVersion;
QByteArray m_response;
QTemporaryDir m_outputDir;
diff --git a/launcher/modplatform/technic/SolderPackManifest.cpp b/launcher/modplatform/technic/SolderPackManifest.cpp
new file mode 100644
index 00000000..16fe0b0e
--- /dev/null
+++ b/launcher/modplatform/technic/SolderPackManifest.cpp
@@ -0,0 +1,58 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
+ *
+ * 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
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#include "SolderPackManifest.h"
+
+#include "Json.h"
+
+namespace TechnicSolder {
+
+void loadPack(Pack& v, QJsonObject& obj)
+{
+ v.recommended = Json::requireString(obj, "recommended");
+ v.latest = Json::requireString(obj, "latest");
+
+ auto builds = Json::requireArray(obj, "builds");
+ for (const auto buildRaw : builds) {
+ auto build = Json::requireString(buildRaw);
+ v.builds.append(build);
+ }
+}
+
+static void loadPackBuildMod(PackBuildMod& b, QJsonObject& obj)
+{
+ b.name = Json::requireString(obj, "name");
+ b.version = Json::requireString(obj, "version");
+ b.md5 = Json::requireString(obj, "md5");
+ b.url = Json::requireString(obj, "url");
+}
+
+void loadPackBuild(PackBuild& v, QJsonObject& obj)
+{
+ v.minecraft = Json::requireString(obj, "minecraft");
+
+ auto mods = Json::requireArray(obj, "mods");
+ for (const auto modRaw : mods) {
+ auto modObj = Json::requireObject(modRaw);
+ PackBuildMod mod;
+ loadPackBuildMod(mod, modObj);
+ v.mods.append(mod);
+ }
+}
+
+}
diff --git a/launcher/modplatform/technic/SolderPackManifest.h b/launcher/modplatform/technic/SolderPackManifest.h
new file mode 100644
index 00000000..09f18df0
--- /dev/null
+++ b/launcher/modplatform/technic/SolderPackManifest.h
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
+ *
+ * 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
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <QString>
+#include <QVector>
+#include <QJsonObject>
+
+namespace TechnicSolder {
+
+struct Pack {
+ QString recommended;
+ QString latest;
+ QVector<QString> builds;
+};
+
+void loadPack(Pack& v, QJsonObject& obj);
+
+struct PackBuildMod {
+ QString name;
+ QString version;
+ QString md5;
+ QString url;
+};
+
+struct PackBuild {
+ QString minecraft;
+ QVector<PackBuildMod> mods;
+};
+
+void loadPackBuild(PackBuild& v, QJsonObject& obj);
+
+}
diff --git a/launcher/resources/multimc/scalable/discord.svg b/launcher/resources/multimc/scalable/discord.svg
index 067be1e8..e37c3b84 100644
--- a/launcher/resources/multimc/scalable/discord.svg
+++ b/launcher/resources/multimc/scalable/discord.svg
@@ -1,108 +1,11 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-
-<svg
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://creativecommons.org/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:svg="http://www.w3.org/2000/svg"
- xmlns="http://www.w3.org/2000/svg"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
- width="128mm"
- height="128mm"
- viewBox="0 0 453.54331 453.54331"
- id="svg2"
- version="1.1"
- inkscape:version="0.91 r13725"
- sodipodi:docname="discord.svg">
- <defs
- id="defs4">
- <linearGradient
- inkscape:collect="always"
- id="linearGradient4166">
- <stop
- style="stop-color:#7593d7;stop-opacity:1"
- offset="0"
- id="stop4168" />
- <stop
- style="stop-color:#4f6aa3;stop-opacity:1"
- offset="1"
- id="stop4170" />
- </linearGradient>
- <linearGradient
- inkscape:collect="always"
- xlink:href="#linearGradient4166"
- id="linearGradient4174"
- x1="351.42856"
- y1="513.79077"
- x2="351.42856"
- y2="943.79077"
- gradientUnits="userSpaceOnUse"
- gradientTransform="translate(24.999996,-5.8267714e-6)" />
- </defs>
- <sodipodi:namedview
- id="base"
- pagecolor="#ffffff"
- bordercolor="#666666"
- borderopacity="1.0"
- inkscape:pageopacity="0.0"
- inkscape:pageshadow="2"
- inkscape:zoom="0.98994949"
- inkscape:cx="249.4082"
- inkscape:cy="153.28604"
- inkscape:document-units="px"
- inkscape:current-layer="layer1"
- showgrid="false"
- fit-margin-top="0"
- fit-margin-left="0"
- fit-margin-right="0"
- fit-margin-bottom="0"
- inkscape:snap-nodes="true"
- inkscape:snap-bbox="true"
- inkscape:bbox-paths="false"
- inkscape:snap-bbox-edge-midpoints="false"
- inkscape:bbox-nodes="true"
- inkscape:snap-bbox-midpoints="false"
- inkscape:snap-page="true"
- inkscape:window-width="1911"
- inkscape:window-height="2120"
- inkscape:window-x="2970"
- inkscape:window-y="0"
- inkscape:window-maximized="0">
- <inkscape:grid
- type="xygrid"
- id="grid4155" />
- </sodipodi:namedview>
- <metadata
- id="metadata7">
- <rdf:RDF>
- <cc:Work
- rdf:about="">
- <dc:format>image/svg+xml</dc:format>
- <dc:type
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
- <dc:title></dc:title>
- </cc:Work>
- </rdf:RDF>
- </metadata>
- <g
- inkscape:label="Layer 1"
- inkscape:groupmode="layer"
- id="layer1"
- transform="translate(-1.4285583,-500.24745)">
- <path
- style="fill:url(#linearGradient4174);fill-opacity:1;fill-rule:evenodd"
- d="m 73.928594,513.79076 a 37.5,37.5 0 0 0 -37.36914,34.88476 l -0.13086,0.11524 0,2.5 0,302.5 0.11914,0.11914 a 37.5,37.5 0 0 0 -0.11914,2.38086 37.5,37.5 0 0 0 37.5,37.5 37.5,37.5 0 0 0 2.41406,-0.0859 l 0.0859,0.0859 250.000006,0 -10,-40 100,90 0,-392.5 0,-2.5 -0.0918,-0.0918 a 37.5,37.5 0 0 0 -34.77734,-34.77734 l -0.13086,-0.13086 -2.5,0 -302.500006,0 -0.13477,0.11914 a 37.5,37.5 0 0 0 -2.36523,-0.11914 z"
- id="path4157"
- inkscape:connector-curvature="0" />
- <path
- style="opacity:1;fill:#ffffff;fill-rule:evenodd"
- d="m 262.51367,111.60742 -3.53515,4.79688 c 20.92905,7.8755 41.53825,15.82838 52.90625,26.01172 -54.51023,-27.29925 -111.94069,-29.57156 -173.11524,0.25195 13.83558,-12.04023 34.12183,-19.9521 56.31641,-26.64258 l -2.39844,-3.78711 c -19.87573,2.47189 -39.74673,4.97961 -57.48273,19.75608 -1.26426,1.0533 -2.43875,1.7112 -3.75946,3.35134 -1.04157,1.68882 -1.47654,2.94289 -2.20384,4.4259 -16.51968,33.6846 -29.13904,71.47893 -29.23561,122.47449 13.7929,19.97074 35.85963,31.20604 66.79492,33.08203 l 14.01563,-19.0664 c -16.32939,-4.839 -28.63498,-12.99042 -36.86914,-24.4961 68.24127,41.30702 122.04171,25.27927 169.32617,-0.50585 -10.12692,12.60017 -23.08016,21.50538 -39.39649,26.01171 l 14.52149,17.80469 c 31.64413,-2.6726 53.44205,-13.71547 66.03906,-32.57812 -1.25854,-42.6757 -9.40904,-79.47015 -23.71494,-111.01207 -2.51316,-5.54105 -4.27674,-11.49413 -8.10537,-16.14028 -3.45571,-4.1936 -7.96544,-7.13252 -12.90109,-9.9657 -12.42806,-7.13399 -28.6789,-11.32721 -47.20243,-13.77258 z m -76.00195,82.42383 c 12.33462,8e-5 22.33381,10.55717 22.33398,23.58008 -1.7e-4,13.02291 -9.99936,23.58 -22.33398,23.58008 -12.33462,-7e-5 -22.33382,-10.55716 -22.33399,-23.58008 1.7e-4,-13.02292 9.99937,-23.58001 22.33399,-23.58008 z m 79.54883,0 c 12.33462,8e-5 22.33381,10.55717 22.33398,23.58008 -1.7e-4,13.02291 -9.99936,23.58 -22.33398,23.58008 -12.33462,-7e-5 -22.33382,-10.55716 -22.33399,-23.58008 1.7e-4,-13.02292 9.99937,-23.58001 22.33399,-23.58008 z"
- transform="translate(1.4285583,500.24745)"
- id="path4176"
- inkscape:connector-curvature="0"
- sodipodi:nodetypes="ccccccscsccccccccsasccccccccccc" />
- </g>
+<?xml version="1.0" encoding="UTF-8"?>
+<svg fill="none" version="1.1" viewBox="0 0 71 71" xmlns="http://www.w3.org/2000/svg">
+ <g transform="translate(0 8.0294)" clip-path="url(#clip0)">
+ <path d="m60.104 4.8978c-4.5253-2.0764-9.378-3.6062-14.452-4.4824-0.0924-0.01691-0.1847 0.025349-0.2323 0.10987-0.6241 1.11-1.3154 2.5581-1.7995 3.6963-5.4572-0.817-10.886-0.817-16.232 0-0.4842-1.1635-1.2006-2.5863-1.8275-3.6963-0.0476-0.0817-0.1399-0.12396-0.2323-0.10987-5.071 0.87338-9.9237 2.4032-14.452 4.4824-0.0392 0.0169-0.0728 0.0451-0.0951 0.0817-9.2046 13.751-11.726 27.165-10.489 40.412 0.005597 0.0648 0.041978 0.1268 0.092353 0.1662 6.0729 4.4598 11.956 7.1673 17.729 8.9619 0.0924 0.0282 0.1903-0.0056 0.2491-0.0817 1.3657-1.865 2.5831-3.8315 3.6269-5.8995 0.0616-0.1211 0.0028-0.2648-0.1231-0.3127-1.931-0.7325-3.7697-1.6256-5.5384-2.6398-0.1399-0.0817-0.1511-0.2818-0.0224-0.3776 0.3722-0.2789 0.7445-0.5691 1.0999-0.8621 0.0643-0.0535 0.1539-0.0648 0.2295-0.031 11.62 5.3051 24.199 5.3051 35.682 0 0.0756-0.0366 0.1652-0.0253 0.2323 0.0282 0.3555 0.293 0.7277 0.586 1.1027 0.8649 0.1287 0.0958 0.1203 0.2959-0.0196 0.3776-1.7687 1.0339-3.6074 1.9073-5.5412 2.637-0.1259 0.0479-0.1819 0.1944-0.1203 0.3155 1.0662 2.0651 2.2836 4.0316 3.6241 5.8967 0.056 0.0789 0.1567 0.1127 0.2491 0.0845 5.8014-1.7946 11.684-4.5021 17.757-8.9619 0.0532-0.0394 0.0868-0.0986 0.0924-0.1634 1.4804-15.315-2.4796-28.618-10.498-40.412-0.0196-0.0394-0.0531-0.0676-0.0923-0.0845zm-36.379 32.428c-3.4983 0-6.3808-3.2117-6.3808-7.156s2.8266-7.156 6.3808-7.156c3.5821 0 6.4367 3.2399 6.3807 7.156 0 3.9443-2.8266 7.156-6.3807 7.156zm23.592 0c-3.4982 0-6.3807-3.2117-6.3807-7.156s2.8265-7.156 6.3807-7.156c3.5822 0 6.4367 3.2399 6.3808 7.156 0 3.9443-2.7986 7.156-6.3808 7.156z" fill="#5865f2"/>
+ </g>
+ <defs>
+ <clipPath id="clip0">
+ <rect width="71" height="55" fill="#fff"/>
+ </clipPath>
+ </defs>
</svg>
diff --git a/launcher/resources/pe_light/scalable/launcher.svg b/launcher/resources/pe_light/scalable/launcher.svg
index c192d503..a9dfe87a 100644
--- a/launcher/resources/pe_light/scalable/launcher.svg
+++ b/launcher/resources/pe_light/scalable/launcher.svg
@@ -3,18 +3,18 @@
<svg width="64" height="64" version="1.1" viewBox="0 0 16.933 16.933" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<linearGradient id="linearGradient84726" x1="4.4979" x2="12.435" y1="3.8011" y2="9.5681" gradientUnits="userSpaceOnUse">
- <stop stop-color="#88b858" offset="0"/>
- <stop stop-color="#72b147" offset=".5"/>
- <stop stop-color="#5a9a30" offset="1"/>
+ <stop stop-color="#dedede" offset="0"/>
+ <stop stop-color="#d2d2d2" offset=".5"/>
+ <stop stop-color="#c0c0c0" offset="1"/>
</linearGradient>
</defs>
<g>
- <path d="m3.561 16.016s0-3.5642 4.9056-3.5642c4.9069 0 4.9056 3.5642 4.9056 3.5642z" fill="#765338"/>
- <path d="m8.4667 12.452-4.9056 3.5642-3.0319-9.3311z" fill="#b7835a"/>
- <path d="m8.4667 12.452 7.9375-5.7669-3.0319 9.3311z" fill="#5b422d"/>
- <path d="m8.8308 12.716-0.36417 0.26458-0.36417-0.26458c0-0.26458 0.36417-0.26458 0.36417-0.26458s0.36417 0 0.36417 0.26458z" fill="#72b147"/>
- <path d="m8.4667 12.452s-2e-7 -5.7669 7.9375-5.7669l-0.22507 0.69269-0.91853 1.1965-0.91853 0.13819-0.91853 1.1965-0.91853 0.13819-0.91853 1.1965-0.91853 0.13819-0.91853 1.1965-0.91853 0.13819z" fill="#5a9a30"/>
- <path d="m8.1025 12.716-0.91853-0.13819-0.91853-1.1965-0.91853-0.13819-0.91853-1.1965-0.91853-0.13819-0.91853-1.1965-0.91853-0.13819-0.91853-1.1965-0.22507-0.69269c7.9375 1e-7 7.9375 5.7669 7.9375 5.7669z" fill="#88b858"/>
+ <path d="m3.561 16.016s0-3.5642 4.9056-3.5642c4.9069 0 4.9056 3.5642 4.9056 3.5642z" fill="#8f8f8f"/>
+ <path d="m8.4667 12.452-4.9056 3.5642-3.0319-9.3311z" fill="#c2c2c2"/>
+ <path d="m8.4667 12.452 7.9375-5.7669-3.0319 9.3311z" fill="#7c7c7c"/>
+ <path d="m8.8308 12.716-0.36417 0.26458-0.36417-0.26458c0-0.26458 0.36417-0.26458 0.36417-0.26458s0.36417 0 0.36417 0.26458z" fill="#d3d3d3"/>
+ <path d="m8.4667 12.452s-2e-7 -5.7669 7.9375-5.7669l-0.22507 0.69269-0.91853 1.1965-0.91853 0.13819-0.91853 1.1965-0.91853 0.13819-0.91853 1.1965-0.91853 0.13819-0.91853 1.1965-0.91853 0.13819z" fill="#bcbcbc"/>
+ <path d="m8.1025 12.716-0.91853-0.13819-0.91853-1.1965-0.91853-0.13819-0.91853-1.1965-0.91853-0.13819-0.91853-1.1965-0.91853-0.13819-0.91853-1.1965-0.22507-0.69269c7.9375 1e-7 7.9375 5.7669 7.9375 5.7669z" fill="#dedede"/>
<path d="m0.52917 6.6846 7.9375 5.7669 7.9375-5.7669-7.9375-5.7669z" fill="url(#linearGradient84726)"/>
</g>
<path d="m0.75424 7.3773-0.22507-0.69269 7.9375 5.7669 7.9375-5.7669-0.22507 0.69269-7.7124 5.6034z" fill-opacity="0"/>
diff --git a/launcher/tasks/SequentialTask.cpp b/launcher/tasks/SequentialTask.cpp
index a66b9d78..1573e476 100644
--- a/launcher/tasks/SequentialTask.cpp
+++ b/launcher/tasks/SequentialTask.cpp
@@ -1,7 +1,23 @@
#include "SequentialTask.h"
-SequentialTask::SequentialTask(QObject *parent) : Task(parent), m_currentIndex(-1)
+SequentialTask::SequentialTask(QObject* parent, const QString& task_name) : Task(parent), m_name(task_name), m_currentIndex(-1) {}
+
+SequentialTask::~SequentialTask()
+{
+ for(auto task : m_queue){
+ if(task)
+ task->deleteLater();
+ }
+}
+
+auto SequentialTask::getStepProgress() const -> qint64
+{
+ return m_stepProgress;
+}
+
+auto SequentialTask::getStepTotalProgress() const -> qint64
{
+ return m_stepTotalProgress;
}
void SequentialTask::addTask(Task::Ptr task)
@@ -15,16 +31,24 @@ void SequentialTask::executeTask()
startNext();
}
+bool SequentialTask::abort()
+{
+ bool succeeded = true;
+ for (auto& task : m_queue) {
+ if (!task->abort()) succeeded = false;
+ }
+
+ return succeeded;
+}
+
void SequentialTask::startNext()
{
- if (m_currentIndex != -1)
- {
+ if (m_currentIndex != -1) {
Task::Ptr previous = m_queue[m_currentIndex];
disconnect(previous.get(), 0, this, 0);
}
m_currentIndex++;
- if (m_queue.isEmpty() || m_currentIndex >= m_queue.size())
- {
+ if (m_queue.isEmpty() || m_currentIndex >= m_queue.size()) {
emitSucceeded();
return;
}
@@ -33,23 +57,27 @@ void SequentialTask::startNext()
connect(next.get(), SIGNAL(status(QString)), this, SLOT(subTaskStatus(QString)));
connect(next.get(), SIGNAL(progress(qint64, qint64)), this, SLOT(subTaskProgress(qint64, qint64)));
connect(next.get(), SIGNAL(succeeded()), this, SLOT(startNext()));
+
+ setStatus(tr("Executing task %1 out of %2").arg(m_currentIndex + 1).arg(m_queue.size()));
next->start();
}
-void SequentialTask::subTaskFailed(const QString &msg)
+void SequentialTask::subTaskFailed(const QString& msg)
{
emitFailed(msg);
}
-void SequentialTask::subTaskStatus(const QString &msg)
+void SequentialTask::subTaskStatus(const QString& msg)
{
- setStatus(msg);
+ setStepStatus(m_queue[m_currentIndex]->getStatus());
}
void SequentialTask::subTaskProgress(qint64 current, qint64 total)
{
- if(total == 0)
- {
+ if (total == 0) {
setProgress(0, 100);
return;
}
- setProgress(current, total);
+ setProgress(m_currentIndex, m_queue.count());
+
+ m_stepProgress = current;
+ m_stepTotalProgress = total;
}
diff --git a/launcher/tasks/SequentialTask.h b/launcher/tasks/SequentialTask.h
index 027744f3..5b3c0111 100644
--- a/launcher/tasks/SequentialTask.h
+++ b/launcher/tasks/SequentialTask.h
@@ -9,13 +9,21 @@ class SequentialTask : public Task
{
Q_OBJECT
public:
- explicit SequentialTask(QObject *parent = 0);
- virtual ~SequentialTask() {};
+ explicit SequentialTask(QObject *parent = nullptr, const QString& task_name = "");
+ virtual ~SequentialTask();
+
+ inline auto isMultiStep() const -> bool override { return m_queue.size() > 1; };
+ auto getStepProgress() const -> qint64 override;
+ auto getStepTotalProgress() const -> qint64 override;
+
+ inline auto getStepStatus() const -> QString override { return m_step_status; }
void addTask(Task::Ptr task);
-protected:
- void executeTask();
+protected slots:
+ void executeTask() override;
+public slots:
+ bool abort() override;
private
slots:
@@ -24,7 +32,19 @@ slots:
void subTaskStatus(const QString &msg);
void subTaskProgress(qint64 current, qint64 total);
+signals:
+ void stepStatus(QString status);
+
private:
+ void setStepStatus(QString status) { m_step_status = status; };
+
+private:
+ QString m_name;
+ QString m_step_status;
+
QQueue<Task::Ptr > m_queue;
int m_currentIndex;
+
+ qint64 m_stepProgress = 0;
+ qint64 m_stepTotalProgress = 100;
};
diff --git a/launcher/tasks/Task.h b/launcher/tasks/Task.h
index 9cf08dbd..344a024e 100644
--- a/launcher/tasks/Task.h
+++ b/launcher/tasks/Task.h
@@ -21,29 +21,27 @@
#include "QObjectPtr.h"
-class Task : public QObject
-{
+class Task : public QObject {
Q_OBJECT
-public:
+ public:
using Ptr = shared_qobject_ptr<Task>;
- enum class State
- {
- Inactive,
- Running,
- Succeeded,
- Failed,
- AbortedByUser
- };
+ enum class State { Inactive, Running, Succeeded, Failed, AbortedByUser };
-public:
- explicit Task(QObject *parent = 0);
- virtual ~Task() {};
+ public:
+ explicit Task(QObject* parent = 0);
+ virtual ~Task() = default;
bool isRunning() const;
bool isFinished() const;
bool wasSuccessful() const;
+ /*!
+ * MultiStep tasks are combinations of multiple tasks into a single logical task.
+ * The main usage of this is in SequencialTask.
+ */
+ virtual auto isMultiStep() const -> bool { return false; }
+
/*!
* Returns the string that was passed to emitFailed as the error message when the task failed.
* If the task hasn't failed, returns an empty string.
@@ -54,52 +52,45 @@ public:
virtual bool canAbort() const { return false; }
- QString getStatus()
- {
- return m_status;
- }
+ QString getStatus() { return m_status; }
+ virtual auto getStepStatus() const -> QString { return m_status; }
- qint64 getProgress()
- {
- return m_progress;
- }
+ qint64 getProgress() { return m_progress; }
+ qint64 getTotalProgress() { return m_progressTotal; }
+ virtual auto getStepProgress() const -> qint64 { return 0; }
+ virtual auto getStepTotalProgress() const -> qint64 { return 100; }
- qint64 getTotalProgress()
- {
- return m_progressTotal;
- }
+ protected:
+ void logWarning(const QString& line);
-protected:
- void logWarning(const QString & line);
-
-private:
+ private:
QString describe();
-signals:
+ signals:
void started();
- void progress(qint64 current, qint64 total);
+ virtual void progress(qint64 current, qint64 total);
void finished();
void succeeded();
void failed(QString reason);
void status(QString status);
-public slots:
+ public slots:
virtual void start();
virtual bool abort() { return false; };
-protected:
+ protected:
virtual void executeTask() = 0;
-protected slots:
+ protected slots:
virtual void emitSucceeded();
virtual void emitAborted();
virtual void emitFailed(QString reason);
-public slots:
- void setStatus(const QString &status);
+ public slots:
+ void setStatus(const QString& status);
void setProgress(qint64 current, qint64 total);
-private:
+ private:
State m_state = State::Inactive;
QStringList m_Warnings;
QString m_failReason = "";
@@ -107,4 +98,3 @@ private:
int m_progress = 0;
int m_progressTotal = 100;
};
-
diff --git a/launcher/tasks/Task_test.cpp b/launcher/tasks/Task_test.cpp
new file mode 100644
index 00000000..9b6cc2e5
--- /dev/null
+++ b/launcher/tasks/Task_test.cpp
@@ -0,0 +1,68 @@
+#include <QTest>
+#include "TestUtil.h"
+
+#include "Task.h"
+
+/* Does nothing. Only used for testing. */
+class BasicTask : public Task {
+ Q_OBJECT
+
+ friend class TaskTest;
+
+ private:
+ void executeTask() override {};
+};
+
+/* Does nothing. Only used for testing. */
+class BasicTask_MultiStep : public Task {
+ Q_OBJECT
+
+ friend class TaskTest;
+
+ private:
+ auto isMultiStep() const -> bool override { return true; }
+
+ void executeTask() override {};
+};
+
+class TaskTest : public QObject {
+ Q_OBJECT
+
+ private slots:
+ void test_SetStatus_NoMultiStep(){
+ BasicTask t;
+ QString status {"test status"};
+
+ t.setStatus(status);
+
+ QCOMPARE(t.getStatus(), status);
+ QCOMPARE(t.getStepStatus(), status);
+ }
+
+ void test_SetStatus_MultiStep(){
+ BasicTask_MultiStep t;
+ QString status {"test status"};
+
+ t.setStatus(status);
+
+ QCOMPARE(t.getStatus(), status);
+ // Even though it is multi step, it does not override the getStepStatus method,
+ // so it should remain the same.
+ QCOMPARE(t.getStepStatus(), status);
+ }
+
+ void test_SetProgress(){
+ BasicTask t;
+ int current = 42;
+ int total = 207;
+
+ t.setProgress(current, total);
+
+ QCOMPARE(t.getProgress(), current);
+ QCOMPARE(t.getTotalProgress(), total);
+ }
+};
+
+QTEST_GUILESS_MAIN(TaskTest)
+
+#include "Task_test.moc"
diff --git a/launcher/ui/dialogs/AboutDialog.cpp b/launcher/ui/dialogs/AboutDialog.cpp
index ef96cc23..8dadb755 100644
--- a/launcher/ui/dialogs/AboutDialog.cpp
+++ b/launcher/ui/dialogs/AboutDialog.cpp
@@ -1,29 +1,63 @@
-/* Copyright 2013-2021 MultiMC Contributors
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * 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
+ * the Free Software Foundation, version 3.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2013-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
#include "AboutDialog.h"
+#include "BuildConfig.h"
#include "ui_AboutDialog.h"
#include <QIcon>
#include "Application.h"
#include "BuildConfig.h"
#include <net/NetJob.h>
+#include <qobject.h>
#include "HoeDown.h"
namespace {
+QString getLink(QString link, QString name) {
+ return QString("&lt;<a href='%1'>%2</a>&gt;").arg(link).arg(name);
+}
+
+QString getWebsite(QString link) {
+ return getLink(link, QObject::tr("Website"));
+}
+
+QString getGitHub(QString username) {
+ return getLink("https://github.com/" + username, "GitHub");
+}
+
// Credits
// This is a hack, but I can't think of a better way to do this easily without screwing with QTextDocument...
QString getCreditsHtml()
@@ -33,15 +67,29 @@ QString getCreditsHtml()
stream.setCodec(QTextCodec::codecForName("UTF-8"));
stream << "<center>\n";
- stream << "<h3>" << QObject::tr("PolyMC Developers", "About Credits") << "</h3>\n";
- stream << "<p>swirl &lt;<a href='mailto:swurl@swurl.xyz'>swurl@swurl.xyz </a>&gt;</p>\n";
- stream << "<p>LennyMcLennington &lt;<a href='mailto:lenny@sneed.church'>lenny@sneed.church</a>&gt;</p>\n";
+ //: %1 is the name of the launcher, determined at build time, e.g. "PolyMC Developers"
+ stream << "<h3>" << QObject::tr("%1 Developers", "About Credits").arg(BuildConfig.LAUNCHER_NAME) << "</h3>\n";
+ stream << QString("<p>LennyMcLennington %1</p>\n") .arg(getGitHub("LennyMcLennington"));
+ stream << QString("<p>Sefa Eyeoglu (Scrumplex) %1</p>\n") .arg(getWebsite("https://scrumplex.net"));
+ stream << QString("<p>dada513 %1</p>\n") .arg(getGitHub("dada513"));
+ stream << QString("<p>txtsd %1</p>\n") .arg(getGitHub("txtsd"));
+ stream << QString("<p>timoreo %1</p>\n") .arg(getGitHub("timoreo22"));
+ stream << QString("<p>Ezekiel Smith (ZekeSmith) %1</p>\n") .arg(getGitHub("ZekeSmith"));
+ stream << QString("<p>cozyGalvinism %1</p>\n") .arg(getGitHub("cozyGalvinism"));
+ stream << "<br />\n";
+
+ //: %1 is the name of the launcher, determined at build time, e.g. "PolyMC Contributors"
+ stream << "<h3>" << QObject::tr("%1 Contributors", "About Credits").arg(BuildConfig.LAUNCHER_NAME) << "</h3>\n";
+ stream << QString("<p>DioEgizio %1</p>\n") .arg(getGitHub("DioEgizio"));
+ stream << QString("<p>flowln %1</p>\n") .arg(getGitHub("flowln"));
+ stream << QString("<p>swirl %1</p>\n") .arg(getWebsite("https://swurl.xyz/"));
stream << "<br />\n";
// TODO: possibly retrieve from git history at build time?
- stream << "<h3>" << QObject::tr("MultiMC Developers", "About Credits") << "</h3>\n";
+ //: %1 is the name of the launcher, determined at build time, e.g. "PolyMC Developers"
+ stream << "<h3>" << QObject::tr("%1 Developers", "About Credits").arg("MultiMC") << "</h3>\n";
stream << "<p>Andrew Okin &lt;<a href='mailto:forkk@forkk.net'>forkk@forkk.net</a>&gt;</p>\n";
- stream << "<p>Petr Mrázek &lt;<a href='mailto:peterix@gmail.com'>peterix@gmail.com</a>&gt;</p>\n";
+ stream << QString("<p>Petr Mrázek &lt;<a href='mailto:peterix@gmail.com'>peterix@gmail.com</a>&gt;</p>\n");
stream << "<p>Sky Welch &lt;<a href='mailto:multimc@bunnies.io'>multimc@bunnies.io</a>&gt;</p>\n";
stream << "<p>Jan (02JanDal) &lt;<a href='mailto:02jandal@gmail.com'>02jandal@gmail.com</a>&gt;</p>\n";
stream << "<p>RoboSky &lt;<a href='https://twitter.com/RoboSky_'>@RoboSky_</a>&gt;</p>\n";
diff --git a/launcher/ui/dialogs/AboutDialog.ui b/launcher/ui/dialogs/AboutDialog.ui
index 58275c66..70c5009d 100644
--- a/launcher/ui/dialogs/AboutDialog.ui
+++ b/launcher/ui/dialogs/AboutDialog.ui
@@ -80,14 +80,14 @@
</font>
</property>
<property name="text">
- <string notr="true">PolyMC</string>
+ <string notr="true">Launcher</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
- <item>
+ <item>
<widget class="QLabel" name="versionLabel">
<property name="alignment">
<set>Qt::AlignCenter</set>
@@ -209,13 +209,10 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
- <widget class="QTextEdit" name="creditsText">
- <property name="readOnly">
+ <widget class="QTextBrowser" name="creditsText">
+ <property name="openExternalLinks">
<bool>true</bool>
</property>
- <property name="textInteractionFlags">
- <set>Qt::TextBrowserInteraction</set>
- </property>
</widget>
</item>
</layout>
diff --git a/launcher/ui/dialogs/ProgressDialog.cpp b/launcher/ui/dialogs/ProgressDialog.cpp
index 4b092859..648bd88b 100644
--- a/launcher/ui/dialogs/ProgressDialog.cpp
+++ b/launcher/ui/dialogs/ProgressDialog.cpp
@@ -81,6 +81,12 @@ int ProgressDialog::execWithTask(Task *task)
connect(task, SIGNAL(status(QString)), SLOT(changeStatus(const QString &)));
connect(task, SIGNAL(progress(qint64, qint64)), SLOT(changeProgress(qint64, qint64)));
+ m_is_multi_step = task->isMultiStep();
+ if(!m_is_multi_step){
+ ui->globalStatusLabel->setHidden(true);
+ ui->globalProgressBar->setHidden(true);
+ }
+
// if this didn't connect to an already running task, invoke start
if(!task->isRunning())
{
@@ -152,14 +158,24 @@ void ProgressDialog::onTaskSucceeded()
void ProgressDialog::changeStatus(const QString &status)
{
- ui->statusLabel->setText(status);
+ ui->statusLabel->setText(task->getStepStatus());
+ ui->globalStatusLabel->setText(status);
updateSize();
}
void ProgressDialog::changeProgress(qint64 current, qint64 total)
{
- ui->taskProgressBar->setMaximum(total);
- ui->taskProgressBar->setValue(current);
+ ui->globalProgressBar->setMaximum(total);
+ ui->globalProgressBar->setValue(current);
+
+ if(!m_is_multi_step){
+ ui->taskProgressBar->setMaximum(total);
+ ui->taskProgressBar->setValue(current);
+ }
+ else{
+ ui->taskProgressBar->setMaximum(task->getStepProgress());
+ ui->taskProgressBar->setValue(task->getStepTotalProgress());
+ }
}
void ProgressDialog::keyPressEvent(QKeyEvent *e)
diff --git a/launcher/ui/dialogs/ProgressDialog.h b/launcher/ui/dialogs/ProgressDialog.h
index b28ad4fa..0b4b78a4 100644
--- a/launcher/ui/dialogs/ProgressDialog.h
+++ b/launcher/ui/dialogs/ProgressDialog.h
@@ -19,6 +19,7 @@
#include <memory>
class Task;
+class SequentialTask;
namespace Ui
{
@@ -35,7 +36,7 @@ public:
void updateSize();
- int execWithTask(Task *task);
+ int execWithTask(Task* task);
int execWithTask(std::unique_ptr<Task> &&task);
int execWithTask(std::unique_ptr<Task> &task);
@@ -68,4 +69,6 @@ private:
Ui::ProgressDialog *ui;
Task *task;
+
+ bool m_is_multi_step = false;
};
diff --git a/launcher/ui/dialogs/ProgressDialog.ui b/launcher/ui/dialogs/ProgressDialog.ui
index 04b8fef3..bf119a78 100644
--- a/launcher/ui/dialogs/ProgressDialog.ui
+++ b/launcher/ui/dialogs/ProgressDialog.ui
@@ -2,14 +2,6 @@
<ui version="4.0">
<class>ProgressDialog</class>
<widget class="QDialog" name="ProgressDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>400</width>
- <height>100</height>
- </rect>
- </property>
<property name="minimumSize">
<size>
<width>400</width>
@@ -26,7 +18,27 @@
<string>Please wait...</string>
</property>
<layout class="QGridLayout" name="gridLayout">
+ <item row="4" column="0">
+ <widget class="QPushButton" name="skipButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Skip</string>
+ </property>
+ </widget>
+ </item>
<item row="0" column="0">
+ <widget class="QLabel" name="globalStatusLabel">
+ <property name="text">
+ <string>Global Task Status...</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
<widget class="QLabel" name="statusLabel">
<property name="text">
<string>Task Status...</string>
@@ -36,7 +48,7 @@
</property>
</widget>
</item>
- <item row="1" column="0">
+ <item row="3" column="0">
<widget class="QProgressBar" name="taskProgressBar">
<property name="value">
<number>24</number>
@@ -46,16 +58,13 @@
</property>
</widget>
</item>
- <item row="2" column="0">
- <widget class="QPushButton" name="skipButton">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
+ <item row="1" column="0">
+ <widget class="QProgressBar" name="globalProgressBar">
+ <property name="enabled">
+ <bool>true</bool>
</property>
- <property name="text">
- <string>Skip</string>
+ <property name="value">
+ <number>24</number>
</property>
</widget>
</item>
diff --git a/launcher/ui/dialogs/UpdateDialog.ui b/launcher/ui/dialogs/UpdateDialog.ui
index bd94a554..5eb9d88a 100644
--- a/launcher/ui/dialogs/UpdateDialog.ui
+++ b/launcher/ui/dialogs/UpdateDialog.ui
@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
- <string>PolyMC Update</string>
+ <string>Launcher Update</string>
</property>
<property name="windowIcon">
<iconset>
diff --git a/launcher/ui/pages/global/AccountListPage.cpp b/launcher/ui/pages/global/AccountListPage.cpp
index 1edba499..6e1e2183 100644
--- a/launcher/ui/pages/global/AccountListPage.cpp
+++ b/launcher/ui/pages/global/AccountListPage.cpp
@@ -161,10 +161,11 @@ void AccountListPage::on_actionAddMicrosoft_triggered()
CustomMessageBox::selectable(
this,
tr("Microsoft Accounts not available"),
+ //: %1 refers to the launcher itself
tr(
- "Microsoft accounts are only usable on macOS 10.13 or newer, with fully updated PolyMC.\n\n"
- "Please update both your operating system and PolyMC."
- ),
+ "Microsoft accounts are only usable on macOS 10.13 or newer, with fully updated %1.\n\n"
+ "Please update both your operating system and %1."
+ ).arg(BuildConfig.LAUNCHER_NAME),
QMessageBox::Warning
)->exec();
return;
diff --git a/launcher/ui/pages/global/JavaPage.cpp b/launcher/ui/pages/global/JavaPage.cpp
index 3eb4bd59..f0616db1 100644
--- a/launcher/ui/pages/global/JavaPage.cpp
+++ b/launcher/ui/pages/global/JavaPage.cpp
@@ -2,6 +2,7 @@
/*
* PolyMC - Minecraft Launcher
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
+ * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
* 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
@@ -95,6 +96,7 @@ void JavaPage::applySettings()
// Java Settings
s->set("JavaPath", ui->javaPathTextBox->text());
s->set("JvmArgs", ui->jvmArgsTextBox->text());
+ s->set("IgnoreJavaCompatibility", ui->skipCompatibilityCheckbox->isChecked());
JavaCommon::checkJVMArgs(s->get("JvmArgs").toString(), this->parentWidget());
}
void JavaPage::loadSettings()
@@ -118,6 +120,7 @@ void JavaPage::loadSettings()
// Java Settings
ui->javaPathTextBox->setText(s->get("JavaPath").toString());
ui->jvmArgsTextBox->setText(s->get("JvmArgs").toString());
+ ui->skipCompatibilityCheckbox->setChecked(s->get("IgnoreJavaCompatibility").toBool());
}
void JavaPage::on_javaDetectBtn_clicked()
diff --git a/launcher/ui/pages/global/JavaPage.ui b/launcher/ui/pages/global/JavaPage.ui
index b67e9994..d27b200f 100644
--- a/launcher/ui/pages/global/JavaPage.ui
+++ b/launcher/ui/pages/global/JavaPage.ui
@@ -222,6 +222,22 @@
</property>
</widget>
</item>
+ <item row="4" column="1">
+ <widget class="QCheckBox" name="skipCompatibilityCheckbox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>If enabled, the launcher will not check if an instance is compatible with the selected Java version.</string>
+ </property>
+ <property name="text">
+ <string>Skip Java compatibility checks</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
diff --git a/launcher/ui/pages/global/LauncherPage.cpp b/launcher/ui/pages/global/LauncherPage.cpp
index 6f7e1cc7..42ad5ae3 100644
--- a/launcher/ui/pages/global/LauncherPage.cpp
+++ b/launcher/ui/pages/global/LauncherPage.cpp
@@ -2,6 +2,7 @@
/*
* PolyMC - Minecraft Launcher
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
+ * Copyright (c) 2022 dada513 <dada513@protonmail.com>
*
* 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
@@ -134,13 +135,31 @@ void LauncherPage::on_instDirBrowseBtn_clicked()
warning.setInformativeText(
tr("Do you really want to use this path? "
"Selecting \"No\" will close this and not alter your instance path."));
- warning.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
+ warning.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
int result = warning.exec();
- if (result == QMessageBox::Yes)
+ if (result == QMessageBox::Ok)
{
ui->instDirTextBox->setText(cooked_dir);
}
}
+ else if(APPLICATION->isFlatpak() && raw_dir.startsWith("/run/user"))
+ {
+ QMessageBox warning;
+ warning.setText(tr("You're trying to specify an instance folder "
+ "which was granted temporaily via Flatpak.\n"
+ "This is known to cause problems. "
+ "After a restart the launcher might break, "
+ "because it will no longer have access to that directory.\n\n"
+ "Granting PolyMC access to it via Flatseal is recommended."));
+ warning.setInformativeText(
+ tr("Do you want to proceed anyway?"));
+ warning.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
+ int result = warning.exec();
+ if (result == QMessageBox::Ok)
+ {
+ ui->instDirTextBox->setText(cooked_dir);
+ }
+ }
else
{
ui->instDirTextBox->setText(cooked_dir);
diff --git a/launcher/ui/pages/global/MinecraftPage.cpp b/launcher/ui/pages/global/MinecraftPage.cpp
index 9abae425..f49f5a92 100644
--- a/launcher/ui/pages/global/MinecraftPage.cpp
+++ b/launcher/ui/pages/global/MinecraftPage.cpp
@@ -94,6 +94,7 @@ void MinecraftPage::applySettings()
// Miscellaneous
s->set("CloseAfterLaunch", ui->closeAfterLaunchCheck->isChecked());
+ s->set("QuitAfterGameStop", ui->quitAfterGameStopCheck->isChecked());
}
void MinecraftPage::loadSettings()
@@ -113,6 +114,7 @@ void MinecraftPage::loadSettings()
ui->recordGameTime->setChecked(s->get("RecordGameTime").toBool());
ui->closeAfterLaunchCheck->setChecked(s->get("CloseAfterLaunch").toBool());
+ ui->quitAfterGameStopCheck->setChecked(s->get("QuitAfterGameStop").toBool());
}
void MinecraftPage::retranslate()
diff --git a/launcher/ui/pages/global/MinecraftPage.ui b/launcher/ui/pages/global/MinecraftPage.ui
index a28b1f59..c18ab34b 100644
--- a/launcher/ui/pages/global/MinecraftPage.ui
+++ b/launcher/ui/pages/global/MinecraftPage.ui
@@ -173,13 +173,23 @@
<item>
<widget class="QCheckBox" name="closeAfterLaunchCheck">
<property name="toolTip">
- <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;PolyMC will automatically reopen when the game crashes or exits.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The launcher will automatically reopen when the game crashes or exits.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
- <string>Close PolyMC after game window opens</string>
+ <string>Close the launcher after game window opens</string>
</property>
</widget>
</item>
+ <item>
+ <widget class="QCheckBox" name="quitAfterGameStopCheck">
+ <property name="toolTip">
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The launcher will automatically quit after the game exits or crashes.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="text">
+ <string>Quit the launcher after game window closes</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.cpp b/launcher/ui/pages/instance/InstanceSettingsPage.cpp
index e68a7124..a48c4d69 100644
--- a/launcher/ui/pages/instance/InstanceSettingsPage.cpp
+++ b/launcher/ui/pages/instance/InstanceSettingsPage.cpp
@@ -165,10 +165,12 @@ void InstanceSettingsPage::applySettings()
if (javaInstall)
{
m_settings->set("JavaPath", ui->javaPathTextBox->text());
+ m_settings->set("IgnoreJavaCompatibility", ui->skipCompatibilityCheckbox->isChecked());
}
else
{
m_settings->reset("JavaPath");
+ m_settings->reset("IgnoreJavaCompatibility");
}
// Java arguments
@@ -177,7 +179,6 @@ void InstanceSettingsPage::applySettings()
if(javaArgs)
{
m_settings->set("JvmArgs", ui->jvmArgsTextBox->toPlainText().replace("\n", " "));
- JavaCommon::checkJVMArgs(m_settings->get("JvmArgs").toString(), this->parentWidget());
}
else
{
@@ -286,6 +287,7 @@ void InstanceSettingsPage::loadSettings()
ui->javaSettingsGroupBox->setChecked(overrideLocation);
ui->javaPathTextBox->setText(m_settings->get("JavaPath").toString());
+ ui->skipCompatibilityCheckbox->setChecked(m_settings->get("IgnoreJavaCompatibility").toBool());
ui->javaArgumentsGroupBox->setChecked(overrideArgs);
ui->jvmArgsTextBox->setPlainText(m_settings->get("JvmArgs").toString());
diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.ui b/launcher/ui/pages/instance/InstanceSettingsPage.ui
index 729f8e2a..5db2d147 100644
--- a/launcher/ui/pages/instance/InstanceSettingsPage.ui
+++ b/launcher/ui/pages/instance/InstanceSettingsPage.ui
@@ -85,6 +85,16 @@
</property>
</widget>
</item>
+ <item row="2" column="0">
+ <widget class="QCheckBox" name="skipCompatibilityCheckbox">
+ <property name="toolTip">
+ <string>If enabled, the launcher will not check if an instance is compatible with the selected Java version.</string>
+ </property>
+ <property name="text">
+ <string>Skip Java compatibility checks</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp
index 599f0e11..8113fe85 100644
--- a/launcher/ui/pages/instance/ModFolderPage.cpp
+++ b/launcher/ui/pages/instance/ModFolderPage.cpp
@@ -56,8 +56,11 @@
#include "minecraft/VersionFilterData.h"
#include "minecraft/PackProfile.h"
+#include "modplatform/ModAPI.h"
+
#include "Version.h"
#include "ui/dialogs/ProgressDialog.h"
+#include "tasks/SequentialTask.h"
namespace {
// FIXME: wasteful
@@ -387,32 +390,31 @@ void ModFolderPage::on_actionInstall_mods_triggered()
if(m_inst->typeName() != "Minecraft"){
return; //this is a null instance or a legacy instance
}
- bool hasFabric = !((MinecraftInstance *)m_inst)->getPackProfile()->getComponentVersion("net.fabricmc.fabric-loader").isEmpty();
- bool hasForge = !((MinecraftInstance *)m_inst)->getPackProfile()->getComponentVersion("net.minecraftforge").isEmpty();
- if (!hasFabric && !hasForge) {
+ auto profile = ((MinecraftInstance *)m_inst)->getPackProfile();
+ if (profile->getModLoader() == ModAPI::Unspecified) {
QMessageBox::critical(this,tr("Error"),tr("Please install a mod loader first!"));
return;
}
ModDownloadDialog mdownload(m_mods, this, m_inst);
- if(mdownload.exec()) {
- for(auto task : mdownload.getTasks()){
- connect(task, &Task::failed, [this, task](QString reason) {
- task->deleteLater();
- CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
- });
- connect(task, &Task::succeeded, [this, task]() {
- QStringList warnings = task->warnings();
- if (warnings.count()) {
- CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'),
- QMessageBox::Warning)->show();
- }
- task->deleteLater();
- });
- ProgressDialog loadDialog(this);
- loadDialog.setSkipButton(true, tr("Abort"));
- loadDialog.execWithTask(task);
- m_mods->update();
+ if (mdownload.exec()) {
+ SequentialTask* tasks = new SequentialTask(this);
+ connect(tasks, &Task::failed, [this, tasks](QString reason) {
+ CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show();
+ tasks->deleteLater();
+ });
+ connect(tasks, &Task::succeeded, [this, tasks]() {
+ QStringList warnings = tasks->warnings();
+ if (warnings.count()) { CustomMessageBox::selectable(this, tr("Warnings"), warnings.join('\n'), QMessageBox::Warning)->show(); }
+ tasks->deleteLater();
+ });
+
+ for (auto task : mdownload.getTasks()) {
+ tasks->addTask(task);
}
+ ProgressDialog loadDialog(this);
+ loadDialog.setSkipButton(true, tr("Abort"));
+ loadDialog.execWithTask(tasks);
+ m_mods->update();
}
}
diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp
index 97c6fe8f..23e2367b 100644
--- a/launcher/ui/pages/instance/VersionPage.cpp
+++ b/launcher/ui/pages/instance/VersionPage.cpp
@@ -2,6 +2,7 @@
/*
* PolyMC - Minecraft Launcher
* Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
+ * Copyright (c) 2022 Sefa Eyeoglu <contact@scrumplex.net>
*
* 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
@@ -242,6 +243,9 @@ void VersionPage::updateVersionControls()
bool supportsFabric = minecraftVersion >= Version("1.14");
ui->actionInstall_Fabric->setEnabled(controlsEnabled && supportsFabric);
+ bool supportsQuilt = minecraftVersion >= Version("1.14");
+ ui->actionInstall_Quilt->setEnabled(controlsEnabled && supportsQuilt);
+
bool supportsLiteLoader = minecraftVersion <= Version("1.12.2");
ui->actionInstall_LiteLoader->setEnabled(controlsEnabled && supportsLiteLoader);
@@ -391,7 +395,7 @@ void VersionPage::on_actionChange_version_triggered()
return;
}
VersionSelectDialog vselect(list.get(), tr("Change %1 version").arg(name), this);
- if (uid == "net.fabricmc.intermediary")
+ if (uid == "net.fabricmc.intermediary" || uid == "org.quiltmc.hashed")
{
vselect.setEmptyString(tr("No intermediary mappings versions are currently available."));
vselect.setEmptyErrorString(tr("Couldn't load or download the intermediary mappings version lists!"));
@@ -422,7 +426,7 @@ void VersionPage::on_actionDownload_All_triggered()
{
CustomMessageBox::selectable(
this, tr("Error"),
- tr("PolyMC cannot download Minecraft or update instances unless you have at least "
+ tr("Cannot download Minecraft or update instances unless you have at least "
"one account added.\nPlease add your Mojang or Minecraft account."),
QMessageBox::Warning)->show();
return;
@@ -497,6 +501,33 @@ void VersionPage::on_actionInstall_Fabric_triggered()
}
}
+void VersionPage::on_actionInstall_Quilt_triggered()
+{
+ auto vlist = APPLICATION->metadataIndex()->get("org.quiltmc.quilt-loader");
+ if(!vlist)
+ {
+ return;
+ }
+ VersionSelectDialog vselect(vlist.get(), tr("Select Quilt Loader version"), this);
+ vselect.setEmptyString(tr("No Quilt Loader versions are currently available."));
+ vselect.setEmptyErrorString(tr("Couldn't load or download the Quilt Loader version lists!"));
+
+ auto currentVersion = m_profile->getComponentVersion("org.quiltmc.quilt-loader");
+ if(!currentVersion.isEmpty())
+ {
+ vselect.setCurrentVersion(currentVersion);
+ }
+
+ if (vselect.exec() && vselect.selectedVersion())
+ {
+ auto vsn = vselect.selectedVersion();
+ m_profile->setComponentVersion("org.quiltmc.quilt-loader", vsn->descriptor());
+ m_profile->resolve(Net::Mode::Online);
+ preselect(m_profile->rowCount(QModelIndex())-1);
+ m_container->refreshContainer();
+ }
+}
+
void VersionPage::on_actionAdd_Empty_triggered()
{
NewComponentDialog compdialog(QString(), QString(), this);
diff --git a/launcher/ui/pages/instance/VersionPage.h b/launcher/ui/pages/instance/VersionPage.h
index 2d37af43..979311fc 100644
--- a/launcher/ui/pages/instance/VersionPage.h
+++ b/launcher/ui/pages/instance/VersionPage.h
@@ -73,6 +73,7 @@ private slots:
void on_actionChange_version_triggered();
void on_actionInstall_Forge_triggered();
void on_actionInstall_Fabric_triggered();
+ void on_actionInstall_Quilt_triggered();
void on_actionAdd_Empty_triggered();
void on_actionInstall_LiteLoader_triggered();
void on_actionReload_triggered();
diff --git a/launcher/ui/pages/instance/VersionPage.ui b/launcher/ui/pages/instance/VersionPage.ui
index a4990ff3..489f7218 100644
--- a/launcher/ui/pages/instance/VersionPage.ui
+++ b/launcher/ui/pages/instance/VersionPage.ui
@@ -107,6 +107,7 @@
<addaction name="separator"/>
<addaction name="actionInstall_Forge"/>
<addaction name="actionInstall_Fabric"/>
+ <addaction name="actionInstall_Quilt"/>
<addaction name="actionInstall_LiteLoader"/>
<addaction name="actionInstall_mods"/>
<addaction name="separator"/>
@@ -192,6 +193,14 @@
<string>Install the Fabric Loader package.</string>
</property>
</action>
+ <action name="actionInstall_Quilt">
+ <property name="text">
+ <string>Install Quilt</string>
+ </property>
+ <property name="toolTip">
+ <string>Install the Quilt Loader package.</string>
+ </property>
+ </action>
<action name="actionInstall_LiteLoader">
<property name="text">
<string>Install LiteLoader</string>
diff --git a/launcher/ui/pages/modplatform/ModModel.cpp b/launcher/ui/pages/modplatform/ModModel.cpp
new file mode 100644
index 00000000..f75d2847
--- /dev/null
+++ b/launcher/ui/pages/modplatform/ModModel.cpp
@@ -0,0 +1,231 @@
+#include "ModModel.h"
+
+#include "BuildConfig.h"
+#include "Json.h"
+#include "minecraft/MinecraftInstance.h"
+#include "minecraft/PackProfile.h"
+#include "ui/dialogs/ModDownloadDialog.h"
+
+#include <QMessageBox>
+
+namespace ModPlatform {
+
+ListModel::ListModel(ModPage* parent) : QAbstractListModel(parent), m_parent(parent) {}
+
+auto ListModel::debugName() const -> QString
+{
+ return m_parent->debugName();
+}
+
+/******** Make data requests ********/
+
+void ListModel::fetchMore(const QModelIndex& parent)
+{
+ if (parent.isValid()) return;
+ if (nextSearchOffset == 0) {
+ qWarning() << "fetchMore with 0 offset is wrong...";
+ return;
+ }
+ performPaginatedSearch();
+}
+
+auto ListModel::data(const QModelIndex& index, int role) const -> QVariant
+{
+ int pos = index.row();
+ if (pos >= modpacks.size() || pos < 0 || !index.isValid()) { return QString("INVALID INDEX %1").arg(pos); }
+
+ ModPlatform::IndexedPack pack = modpacks.at(pos);
+ if (role == Qt::DisplayRole) {
+ return pack.name;
+ } else if (role == Qt::ToolTipRole) {
+ if (pack.description.length() > 100) {
+ // some magic to prevent to long tooltips and replace html linebreaks
+ QString edit = pack.description.left(97);
+ edit = edit.left(edit.lastIndexOf("<br>")).left(edit.lastIndexOf(" ")).append("...");
+ return edit;
+ }
+ return pack.description;
+ } else if (role == Qt::DecorationRole) {
+ if (m_logoMap.contains(pack.logoName)) { return (m_logoMap.value(pack.logoName)); }
+ QIcon icon = APPLICATION->getThemedIcon("screenshot-placeholder");
+ ((ListModel*)this)->requestLogo(pack.logoName, pack.logoUrl);
+ return icon;
+ } else if (role == Qt::UserRole) {
+ QVariant v;
+ v.setValue(pack);
+ return v;
+ }
+
+ return {};
+}
+
+void ListModel::requestModVersions(ModPlatform::IndexedPack const& current)
+{
+ auto profile = (dynamic_cast<MinecraftInstance*>((dynamic_cast<ModPage*>(parent()))->m_instance))->getPackProfile();
+
+ m_parent->apiProvider()->getVersions(this,
+ { current.addonId.toString(), getMineVersions(), profile->getModLoader() });
+}
+
+void ListModel::performPaginatedSearch()
+{
+ auto profile = (dynamic_cast<MinecraftInstance*>((dynamic_cast<ModPage*>(parent()))->m_instance))->getPackProfile();
+
+ m_parent->apiProvider()->searchMods(this,
+ { nextSearchOffset, currentSearchTerm, getSorts()[currentSort], profile->getModLoader(), getMineVersions().at(0) });
+}
+
+void ListModel::searchWithTerm(const QString& term, const int sort)
+{
+ if (currentSearchTerm == term && currentSearchTerm.isNull() == term.isNull() && currentSort == sort) { return; }
+ currentSearchTerm = term;
+ currentSort = sort;
+ if (jobPtr) {
+ jobPtr->abort();
+ searchState = ResetRequested;
+ return;
+ } else {
+ beginResetModel();
+ modpacks.clear();
+ endResetModel();
+ searchState = None;
+ }
+ nextSearchOffset = 0;
+ performPaginatedSearch();
+}
+
+void ListModel::getLogo(const QString& logo, const QString& logoUrl, LogoCallback callback)
+{
+ if (m_logoMap.contains(logo)) {
+ callback(APPLICATION->metacache()
+ ->resolveEntry(m_parent->metaEntryBase(), QString("logos/%1").arg(logo.section(".", 0, 0)))
+ ->getFullPath());
+ } else {
+ requestLogo(logo, logoUrl);
+ }
+}
+
+void ListModel::requestLogo(QString logo, QString url)
+{
+ if (m_loadingLogos.contains(logo) || m_failedLogos.contains(logo)) { return; }
+
+ MetaEntryPtr entry =
+ APPLICATION->metacache()->resolveEntry(m_parent->metaEntryBase(), QString("logos/%1").arg(logo.section(".", 0, 0)));
+ auto job = new NetJob(QString("%1 Icon Download %2").arg(m_parent->debugName()).arg(logo), APPLICATION->network());
+ job->addNetAction(Net::Download::makeCached(QUrl(url), entry));
+
+ auto fullPath = entry->getFullPath();
+ QObject::connect(job, &NetJob::succeeded, this, [this, logo, fullPath, job] {
+ job->deleteLater();
+ emit logoLoaded(logo, QIcon(fullPath));
+ if (waitingCallbacks.contains(logo)) { waitingCallbacks.value(logo)(fullPath); }
+ });
+
+ QObject::connect(job, &NetJob::failed, this, [this, logo, job] {
+ job->deleteLater();
+ emit logoFailed(logo);
+ });
+
+ job->start();
+ m_loadingLogos.append(logo);
+}
+
+/******** Request callbacks ********/
+
+void ListModel::logoLoaded(QString logo, QIcon out)
+{
+ m_loadingLogos.removeAll(logo);
+ m_logoMap.insert(logo, out);
+ for (int i = 0; i < modpacks.size(); i++) {
+ if (modpacks[i].logoName == logo) { emit dataChanged(createIndex(i, 0), createIndex(i, 0), { Qt::DecorationRole }); }
+ }
+}
+
+void ListModel::logoFailed(QString logo)
+{
+ m_failedLogos.append(logo);
+ m_loadingLogos.removeAll(logo);
+}
+
+void ListModel::searchRequestFinished(QJsonDocument& doc)
+{
+ jobPtr.reset();
+
+ QList<ModPlatform::IndexedPack> newList;
+ auto packs = documentToArray(doc);
+
+ for (auto packRaw : packs) {
+ auto packObj = packRaw.toObject();
+
+ ModPlatform::IndexedPack pack;
+ try {
+ loadIndexedPack(pack, packObj);
+ newList.append(pack);
+ } catch (const JSONValidationError& e) {
+ qWarning() << "Error while loading mod from " << m_parent->debugName() << ": " << e.cause();
+ continue;
+ }
+ }
+
+ if (packs.size() < 25) {
+ searchState = Finished;
+ } else {
+ nextSearchOffset += 25;
+ searchState = CanPossiblyFetchMore;
+ }
+
+ beginInsertRows(QModelIndex(), modpacks.size(), modpacks.size() + newList.size() - 1);
+ modpacks.append(newList);
+ endInsertRows();
+}
+
+void ListModel::searchRequestFailed(QString reason)
+{
+ if (jobPtr->first()->m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 409) {
+ // 409 Gone, notify user to update
+ QMessageBox::critical(nullptr, tr("Error"),
+ //: %1 refers to the launcher itself
+ QString("%1 %2").arg(m_parent->displayName()).arg(tr("API version too old!\nPlease update %1!").arg(BuildConfig.LAUNCHER_NAME)));
+ // self-destruct
+ (dynamic_cast<ModDownloadDialog*>((dynamic_cast<ModPage*>(parent()))->parentWidget()))->reject();
+ }
+ jobPtr.reset();
+
+ if (searchState == ResetRequested) {
+ beginResetModel();
+ modpacks.clear();
+ endResetModel();
+
+ nextSearchOffset = 0;
+ performPaginatedSearch();
+ } else {
+ searchState = Finished;
+ }
+}
+
+void ListModel::versionRequestSucceeded(QJsonDocument doc, QString addonId)
+{
+ auto& current = m_parent->getCurrent();
+ if (addonId != current.addonId) { return; }
+
+ QJsonArray arr = doc.array();
+ try {
+ loadIndexedPackVersions(current, arr);
+ } catch (const JSONValidationError& e) {
+ qDebug() << doc;
+ qWarning() << "Error while reading " << debugName() << " mod version: " << e.cause();
+ }
+
+ m_parent->updateModVersions();
+}
+
+} // namespace ModPlatform
+
+/******** Helpers ********/
+
+auto ModPlatform::ListModel::getMineVersions() const -> QList<QString>
+{
+ return { (dynamic_cast<MinecraftInstance*>((dynamic_cast<ModPage*>(parent()))->m_instance))
+ ->getPackProfile()
+ ->getComponentVersion("net.minecraft") };
+}
diff --git a/launcher/ui/pages/modplatform/ModModel.h b/launcher/ui/pages/modplatform/ModModel.h
new file mode 100644
index 00000000..dbadbeee
--- /dev/null
+++ b/launcher/ui/pages/modplatform/ModModel.h
@@ -0,0 +1,84 @@
+#pragma once
+
+#include <QAbstractListModel>
+
+#include "modplatform/ModAPI.h"
+#include "modplatform/ModIndex.h"
+#include "net/NetJob.h"
+
+class ModPage;
+
+namespace ModPlatform {
+
+using LogoMap = QMap<QString, QIcon>;
+using LogoCallback = std::function<void (QString)>;
+
+class ListModel : public QAbstractListModel {
+ Q_OBJECT
+
+ public:
+ ListModel(ModPage* parent);
+ ~ListModel() override = default;
+
+ inline auto rowCount(const QModelIndex& parent) const -> int override { return modpacks.size(); };
+ inline auto columnCount(const QModelIndex& parent) const -> int override { return 1; };
+ inline auto flags(const QModelIndex& index) const -> Qt::ItemFlags override { return QAbstractListModel::flags(index); };
+
+ auto debugName() const -> QString;
+
+ /* Retrieve information from the model at a given index with the given role */
+ auto data(const QModelIndex& index, int role) const -> QVariant override;
+
+ inline void setActiveJob(NetJob::Ptr ptr) { jobPtr = ptr; }
+
+ /* Ask the API for more information */
+ void fetchMore(const QModelIndex& parent) override;
+ void searchWithTerm(const QString& term, const int sort);
+ void requestModVersions(const ModPlatform::IndexedPack& current);
+
+ virtual void loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj) = 0;
+ virtual void loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonArray& arr) = 0;
+
+ void getLogo(const QString& logo, const QString& logoUrl, LogoCallback callback);
+
+ inline auto canFetchMore(const QModelIndex& parent) const -> bool override { return searchState == CanPossiblyFetchMore; };
+
+ public slots:
+ void searchRequestFinished(QJsonDocument& doc);
+ void searchRequestFailed(QString reason);
+
+ void versionRequestSucceeded(QJsonDocument doc, QString addonId);
+
+ protected slots:
+
+ void logoFailed(QString logo);
+ void logoLoaded(QString logo, QIcon out);
+
+ void performPaginatedSearch();
+
+ protected:
+ virtual auto documentToArray(QJsonDocument& obj) const -> QJsonArray = 0;
+ virtual auto getSorts() const -> const char** = 0;
+
+ void requestLogo(QString file, QString url);
+
+ inline auto getMineVersions() const -> QList<QString>;
+
+ protected:
+ ModPage* m_parent;
+
+ QList<ModPlatform::IndexedPack> modpacks;
+
+ LogoMap m_logoMap;
+ QMap<QString, LogoCallback> waitingCallbacks;
+ QStringList m_failedLogos;
+ QStringList m_loadingLogos;
+
+ QString currentSearchTerm;
+ int currentSort = 0;
+ int nextSearchOffset = 0;
+ enum SearchState { None, CanPossiblyFetchMore, ResetRequested, Finished } searchState = None;
+
+ NetJob::Ptr jobPtr;
+};
+} // namespace ModPlatform
diff --git a/launcher/ui/pages/modplatform/ModPage.cpp b/launcher/ui/pages/modplatform/ModPage.cpp
new file mode 100644
index 00000000..eabd8379
--- /dev/null
+++ b/launcher/ui/pages/modplatform/ModPage.cpp
@@ -0,0 +1,171 @@
+#include "ModPage.h"
+#include "ui_ModPage.h"
+
+#include <QKeyEvent>
+
+#include "minecraft/MinecraftInstance.h"
+#include "minecraft/PackProfile.h"
+#include "ui/dialogs/ModDownloadDialog.h"
+
+ModPage::ModPage(ModDownloadDialog* dialog, BaseInstance* instance, ModAPI* api)
+ : QWidget(dialog), m_instance(instance), ui(new Ui::ModPage), dialog(dialog), api(api)
+{
+ ui->setupUi(this);
+ connect(ui->searchButton, &QPushButton::clicked, this, &ModPage::triggerSearch);
+ ui->searchEdit->installEventFilter(this);
+
+ ui->versionSelectionBox->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ ui->versionSelectionBox->view()->parentWidget()->setMaximumHeight(300);
+
+}
+
+ModPage::~ModPage()
+{
+ delete ui;
+}
+
+
+/******** Qt things ********/
+
+void ModPage::openedImpl()
+{
+ updateSelectionButton();
+ triggerSearch();
+}
+
+auto ModPage::eventFilter(QObject* watched, QEvent* event) -> bool
+{
+ if (watched == ui->searchEdit && event->type() == QEvent::KeyPress) {
+ auto* keyEvent = dynamic_cast<QKeyEvent*>(event);
+ if (keyEvent->key() == Qt::Key_Return) {
+ triggerSearch();
+ keyEvent->accept();
+ return true;
+ }
+ }
+ return QWidget::eventFilter(watched, event);
+}
+
+
+/******** Callbacks to events in the UI (set up in the derived classes) ********/
+
+void ModPage::triggerSearch()
+{
+ listModel->searchWithTerm(ui->searchEdit->text(), ui->sortByBox->currentIndex());
+}
+
+void ModPage::onSelectionChanged(QModelIndex first, QModelIndex second)
+{
+ ui->versionSelectionBox->clear();
+
+ if (!first.isValid()) { return; }
+
+ current = listModel->data(first, Qt::UserRole).value<ModPlatform::IndexedPack>();
+ QString text = "";
+ QString name = current.name;
+
+ if (current.websiteUrl.isEmpty())
+ text = name;
+ else
+ text = "<a href=\"" + current.websiteUrl + "\">" + name + "</a>";
+
+ if (!current.authors.empty()) {
+ auto authorToStr = [](ModPlatform::ModpackAuthor& author) -> QString {
+ if (author.url.isEmpty()) { return author.name; }
+ return QString("<a href=\"%1\">%2</a>").arg(author.url, author.name);
+ };
+ QStringList authorStrs;
+ for (auto& author : current.authors) {
+ authorStrs.push_back(authorToStr(author));
+ }
+ text += "<br>" + tr(" by ") + authorStrs.join(", ");
+ }
+ text += "<br><br>";
+
+ ui->packDescription->setHtml(text + current.description);
+
+ if (!current.versionsLoaded) {
+ qDebug() << QString("Loading %1 mod versions").arg(debugName());
+
+ ui->modSelectionButton->setText(tr("Loading versions..."));
+ ui->modSelectionButton->setEnabled(false);
+
+ listModel->requestModVersions(current);
+ } else {
+ for (int i = 0; i < current.versions.size(); i++) {
+ ui->versionSelectionBox->addItem(current.versions[i].version, QVariant(i));
+ }
+ if (ui->versionSelectionBox->count() == 0) { ui->versionSelectionBox->addItem(tr("No valid version found."), QVariant(-1)); }
+
+ updateSelectionButton();
+ }
+}
+
+void ModPage::onVersionSelectionChanged(QString data)
+{
+ if (data.isNull() || data.isEmpty()) {
+ selectedVersion = -1;
+ return;
+ }
+ selectedVersion = ui->versionSelectionBox->currentData().toInt();
+ updateSelectionButton();
+}
+
+void ModPage::onModSelected()
+{
+ auto& version = current.versions[selectedVersion];
+ if (dialog->isModSelected(current.name, version.fileName)) {
+ dialog->removeSelectedMod(current.name);
+ } else {
+ dialog->addSelectedMod(current.name, new ModDownloadTask(version.downloadUrl, version.fileName, dialog->mods));
+ }
+
+ updateSelectionButton();
+}
+
+
+/******** Make changes to the UI ********/
+
+void ModPage::retranslate()
+{
+ ui->retranslateUi(this);
+}
+
+void ModPage::updateModVersions()
+{
+ auto packProfile = (dynamic_cast<MinecraftInstance*>(m_instance))->getPackProfile();
+
+ QString mcVersion = packProfile->getComponentVersion("net.minecraft");
+
+ QString loaderString = ModAPI::getModLoaderString(packProfile->getModLoader());
+
+ for (int i = 0; i < current.versions.size(); i++) {
+ auto version = current.versions[i];
+ //NOTE: Flame doesn't care about loaderString, so passing it changes nothing.
+ if (!validateVersion(version, mcVersion, loaderString)) {
+ continue;
+ }
+ ui->versionSelectionBox->addItem(version.version, QVariant(i));
+ }
+ if (ui->versionSelectionBox->count() == 0) { ui->versionSelectionBox->addItem(tr("No valid version found!"), QVariant(-1)); }
+
+ ui->modSelectionButton->setText(tr("Cannot select invalid version :("));
+ updateSelectionButton();
+}
+
+
+void ModPage::updateSelectionButton()
+{
+ if (!isOpened || selectedVersion < 0) {
+ ui->modSelectionButton->setEnabled(false);
+ return;
+ }
+
+ ui->modSelectionButton->setEnabled(true);
+ auto& version = current.versions[selectedVersion];
+ if (!dialog->isModSelected(current.name, version.fileName)) {
+ ui->modSelectionButton->setText(tr("Select mod for download"));
+ } else {
+ ui->modSelectionButton->setText(tr("Deselect mod for download"));
+ }
+}
diff --git a/launcher/ui/pages/modplatform/ModPage.h b/launcher/ui/pages/modplatform/ModPage.h
new file mode 100644
index 00000000..0cd13f37
--- /dev/null
+++ b/launcher/ui/pages/modplatform/ModPage.h
@@ -0,0 +1,69 @@
+#pragma once
+
+#include <QWidget>
+
+#include "Application.h"
+#include "modplatform/ModAPI.h"
+#include "modplatform/ModIndex.h"
+#include "ui/pages/BasePage.h"
+#include "ui/pages/modplatform/ModModel.h"
+
+class ModDownloadDialog;
+
+namespace Ui {
+class ModPage;
+}
+
+/* This page handles most logic related to browsing and selecting mods to download. */
+class ModPage : public QWidget, public BasePage {
+ Q_OBJECT
+
+ public:
+ explicit ModPage(ModDownloadDialog* dialog, BaseInstance* instance, ModAPI* api);
+ ~ModPage() override;
+
+ /* Affects what the user sees */
+ auto displayName() const -> QString override = 0;
+ auto icon() const -> QIcon override = 0;
+ auto id() const -> QString override = 0;
+ auto helpPage() const -> QString override = 0;
+
+ /* Used internally */
+ virtual auto metaEntryBase() const -> QString = 0;
+ virtual auto debugName() const -> QString = 0;
+
+
+ void retranslate() override;
+
+ auto shouldDisplay() const -> bool override = 0;
+ virtual auto validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, QString loaderVer = "") const -> bool = 0;
+
+ auto apiProvider() const -> const ModAPI* { return api.get(); };
+
+ auto getCurrent() -> ModPlatform::IndexedPack& { return current; }
+ void updateModVersions();
+
+ void openedImpl() override;
+ auto eventFilter(QObject* watched, QEvent* event) -> bool override;
+
+ BaseInstance* m_instance;
+
+ protected:
+ void updateSelectionButton();
+
+ protected slots:
+ void triggerSearch();
+ void onSelectionChanged(QModelIndex first, QModelIndex second);
+ void onVersionSelectionChanged(QString data);
+ void onModSelected();
+
+ protected:
+ Ui::ModPage* ui = nullptr;
+ ModDownloadDialog* dialog = nullptr;
+ ModPlatform::ListModel* listModel = nullptr;
+ ModPlatform::IndexedPack current;
+
+ std::unique_ptr<ModAPI> api;
+
+ int selectedVersion = -1;
+};
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.ui b/launcher/ui/pages/modplatform/ModPage.ui
index 6c709825..508f1bac 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.ui
+++ b/launcher/ui/pages/modplatform/ModPage.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>ModrinthPage</class>
- <widget class="QWidget" name="ModrinthPage">
+ <class>ModPage</class>
+ <widget class="QWidget" name="ModPage">
<property name="geometry">
<rect>
<x>0</x>
diff --git a/launcher/ui/pages/modplatform/flame/FlameModModel.cpp b/launcher/ui/pages/modplatform/flame/FlameModModel.cpp
index e8afba5a..905fb2dd 100644
--- a/launcher/ui/pages/modplatform/flame/FlameModModel.cpp
+++ b/launcher/ui/pages/modplatform/flame/FlameModModel.cpp
@@ -1,273 +1,25 @@
#include "FlameModModel.h"
-#include "Application.h"
-#include "minecraft/MinecraftInstance.h"
-#include "minecraft/PackProfile.h"
-#include "FlameModPage.h"
-#include <Json.h>
-
-#include <MMCStrings.h>
-#include <Version.h>
-
-#include <QtMath>
+#include "modplatform/flame/FlameModIndex.h"
namespace FlameMod {
-ListModel::ListModel(FlameModPage *parent) : QAbstractListModel(parent)
-{
-}
-
-ListModel::~ListModel()
-{
-}
+// NOLINTNEXTLINE(modernize-avoid-c-arrays)
+const char* ListModel::sorts[6]{ "Featured", "Popularity", "LastUpdated", "Name", "Author", "TotalDownloads" };
-int ListModel::rowCount(const QModelIndex &parent) const
+void ListModel::loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj)
{
- return modpacks.size();
-}
-
-int ListModel::columnCount(const QModelIndex &parent) const
-{
- return 1;
-}
-
-QVariant ListModel::data(const QModelIndex &index, int role) const
-{
- int pos = index.row();
- if(pos >= modpacks.size() || pos < 0 || !index.isValid())
- {
- return QString("INVALID INDEX %1").arg(pos);
- }
-
- IndexedPack pack = modpacks.at(pos);
- if(role == Qt::DisplayRole)
- {
- return pack.name;
- }
- else if (role == Qt::ToolTipRole)
- {
- if(pack.description.length() > 100)
- {
- //some magic to prevent to long tooltips and replace html linebreaks
- QString edit = pack.description.left(97);
- edit = edit.left(edit.lastIndexOf("<br>")).left(edit.lastIndexOf(" ")).append("...");
- return edit;
-
- }
- return pack.description;
- }
- else if(role == Qt::DecorationRole)
- {
- if(m_logoMap.contains(pack.logoName))
- {
- return (m_logoMap.value(pack.logoName));
- }
- QIcon icon = APPLICATION->getThemedIcon("screenshot-placeholder");
- ((ListModel *)this)->requestLogo(pack.logoName, pack.logoUrl);
- return icon;
- }
- else if(role == Qt::UserRole)
- {
- QVariant v;
- v.setValue(pack);
- return v;
- }
-
- return QVariant();
-}
-
-void ListModel::logoLoaded(QString logo, QIcon out)
-{
- m_loadingLogos.removeAll(logo);
- m_logoMap.insert(logo, out);
- for(int i = 0; i < modpacks.size(); i++) {
- if(modpacks[i].logoName == logo) {
- emit dataChanged(createIndex(i, 0), createIndex(i, 0), {Qt::DecorationRole});
- }
- }
-}
-
-void ListModel::logoFailed(QString logo)
-{
- m_failedLogos.append(logo);
- m_loadingLogos.removeAll(logo);
-}
-
-void ListModel::requestLogo(QString logo, QString url)
-{
- if(m_loadingLogos.contains(logo) || m_failedLogos.contains(logo))
- {
- return;
- }
-
- MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("FlameMods", QString("logos/%1").arg(logo.section(".", 0, 0)));
- auto job = new NetJob(QString("Flame Icon Download %1").arg(logo), APPLICATION->network());
- job->addNetAction(Net::Download::makeCached(QUrl(url), entry));
-
- auto fullPath = entry->getFullPath();
- QObject::connect(job, &NetJob::succeeded, this, [this, logo, fullPath, job]
- {
- job->deleteLater();
- emit logoLoaded(logo, QIcon(fullPath));
- if(waitingCallbacks.contains(logo))
- {
- waitingCallbacks.value(logo)(fullPath);
- }
- });
-
- QObject::connect(job, &NetJob::failed, this, [this, logo, job]
- {
- job->deleteLater();
- emit logoFailed(logo);
- });
-
- job->start();
- m_loadingLogos.append(logo);
+ FlameMod::loadIndexedPack(m, obj);
}
-void ListModel::getLogo(const QString &logo, const QString &logoUrl, LogoCallback callback)
+void ListModel::loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonArray& arr)
{
- if(m_logoMap.contains(logo))
- {
- callback(APPLICATION->metacache()->resolveEntry("FlameMods", QString("logos/%1").arg(logo.section(".", 0, 0)))->getFullPath());
- }
- else
- {
- requestLogo(logo, logoUrl);
- }
+ FlameMod::loadIndexedPackVersions(m, arr, APPLICATION->network(), m_parent->m_instance);
}
-Qt::ItemFlags ListModel::flags(const QModelIndex &index) const
+auto ListModel::documentToArray(QJsonDocument& obj) const -> QJsonArray
{
- return QAbstractListModel::flags(index);
-}
-
-bool ListModel::canFetchMore(const QModelIndex& parent) const
-{
- return searchState == CanPossiblyFetchMore;
-}
-
-void ListModel::fetchMore(const QModelIndex& parent)
-{
- if (parent.isValid())
- return;
- if(nextSearchOffset == 0) {
- qWarning() << "fetchMore with 0 offset is wrong...";
- return;
- }
- performPaginatedSearch();
-}
-const char* sorts[6]{"Featured","Popularity","LastUpdated","Name","Author","TotalDownloads"};
-
-void ListModel::performPaginatedSearch()
-{
-
- QString mcVersion = ((MinecraftInstance *)((FlameModPage *)parent())->m_instance)->getPackProfile()->getComponentVersion("net.minecraft");
- bool hasFabric = !((MinecraftInstance *)((FlameModPage *)parent())->m_instance)->getPackProfile()->getComponentVersion("net.fabricmc.fabric-loader").isEmpty();
- auto netJob = new NetJob("Flame::Search", APPLICATION->network());
- auto searchUrl = QString(
- "https://addons-ecs.forgesvc.net/api/v2/addon/search?"
- "gameId=432&"
- "categoryId=0&"
- "sectionId=6&"
-
- "index=%1&"
- "pageSize=25&"
- "searchFilter=%2&"
- "sort=%3&"
- "modLoaderType=%4&"
- "gameVersion=%5"
- )
- .arg(nextSearchOffset)
- .arg(currentSearchTerm)
- .arg(sorts[currentSort])
- .arg(hasFabric ? 4 : 1) // Enum: https://docs.curseforge.com/?http#tocS_ModLoaderType
- .arg(mcVersion);
-
- netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));
- jobPtr = netJob;
- jobPtr->start();
- QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::searchRequestFinished);
- QObject::connect(netJob, &NetJob::failed, this, &ListModel::searchRequestFailed);
-}
-
-void ListModel::searchWithTerm(const QString &term, const int sort)
-{
- if(currentSearchTerm == term && currentSearchTerm.isNull() == term.isNull() && currentSort == sort) {
- return;
- }
- currentSearchTerm = term;
- currentSort = sort;
- if(jobPtr) {
- jobPtr->abort();
- searchState = ResetRequested;
- return;
- }
- else {
- beginResetModel();
- modpacks.clear();
- endResetModel();
- searchState = None;
- }
- nextSearchOffset = 0;
- performPaginatedSearch();
-}
-
-void ListModel::searchRequestFinished()
-{
- jobPtr.reset();
-
- QJsonParseError parse_error;
- QJsonDocument doc = QJsonDocument::fromJson(response, &parse_error);
- if(parse_error.error != QJsonParseError::NoError) {
- qWarning() << "Error while parsing JSON response from Flame at " << parse_error.offset << " reason: " << parse_error.errorString();
- qWarning() << response;
- return;
- }
-
- QList<FlameMod::IndexedPack> newList;
- auto packs = doc.array();
- for(auto packRaw : packs) {
- auto packObj = packRaw.toObject();
-
- FlameMod::IndexedPack pack;
- try
- {
- FlameMod::loadIndexedPack(pack, packObj);
- newList.append(pack);
- }
- catch(const JSONValidationError &e)
- {
- qWarning() << "Error while loading mod from Flame: " << e.cause();
- continue;
- }
- }
- if(packs.size() < 25) {
- searchState = Finished;
- } else {
- nextSearchOffset += 25;
- searchState = CanPossiblyFetchMore;
- }
- beginInsertRows(QModelIndex(), modpacks.size(), modpacks.size() + newList.size() - 1);
- modpacks.append(newList);
- endInsertRows();
-}
-
-void ListModel::searchRequestFailed(QString reason)
-{
- jobPtr.reset();
-
- if(searchState == ResetRequested) {
- beginResetModel();
- modpacks.clear();
- endResetModel();
-
- nextSearchOffset = 0;
- performPaginatedSearch();
- } else {
- searchState = Finished;
- }
-}
-
+ return obj.array();
}
+} // namespace FlameMod
diff --git a/launcher/ui/pages/modplatform/flame/FlameModModel.h b/launcher/ui/pages/modplatform/flame/FlameModModel.h
index 0c1cb95e..707c1bb1 100644
--- a/launcher/ui/pages/modplatform/flame/FlameModModel.h
+++ b/launcher/ui/pages/modplatform/flame/FlameModModel.h
@@ -1,79 +1,25 @@
#pragma once
-#include <RWStorage.h>
-
-#include <QAbstractListModel>
-#include <QSortFilterProxyModel>
-#include <QThreadPool>
-#include <QIcon>
-#include <QStyledItemDelegate>
-#include <QList>
-#include <QString>
-#include <QStringList>
-#include <QMetaType>
-
-#include <functional>
-#include <net/NetJob.h>
-
-#include <modplatform/flame/FlamePackIndex.h>
-#include "modplatform/flame/FlameModIndex.h"
-#include "BaseInstance.h"
#include "FlameModPage.h"
namespace FlameMod {
-
-typedef QMap<QString, QIcon> LogoMap;
-typedef std::function<void(QString)> LogoCallback;
-
-class ListModel : public QAbstractListModel
-{
+class ListModel : public ModPlatform::ListModel {
Q_OBJECT
-public:
- ListModel(FlameModPage *parent);
- virtual ~ListModel();
-
- int rowCount(const QModelIndex &parent) const override;
- int columnCount(const QModelIndex &parent) const override;
- QVariant data(const QModelIndex &index, int role) const override;
- Qt::ItemFlags flags(const QModelIndex &index) const override;
- bool canFetchMore(const QModelIndex & parent) const override;
- void fetchMore(const QModelIndex & parent) override;
-
- void getLogo(const QString &logo, const QString &logoUrl, LogoCallback callback);
- void searchWithTerm(const QString &term, const int sort);
-
-private slots:
- void performPaginatedSearch();
-
- void logoFailed(QString logo);
- void logoLoaded(QString logo, QIcon out);
-
- void searchRequestFinished();
- void searchRequestFailed(QString reason);
+ public:
+ ListModel(FlameModPage* parent) : ModPlatform::ListModel(parent) {}
+ ~ListModel() override = default;
-private:
- void requestLogo(QString file, QString url);
+ private:
+ void loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj) override;
+ void loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonArray& arr) override;
-private:
- QList<IndexedPack> modpacks;
- QStringList m_failedLogos;
- QStringList m_loadingLogos;
- LogoMap m_logoMap;
- QMap<QString, LogoCallback> waitingCallbacks;
+ auto documentToArray(QJsonDocument& obj) const -> QJsonArray override;
- QString currentSearchTerm;
- int currentSort = 0;
- int nextSearchOffset = 0;
- enum SearchState {
- None,
- CanPossiblyFetchMore,
- ResetRequested,
- Finished
- } searchState = None;
- NetJob::Ptr jobPtr;
- QByteArray response;
+ // NOLINTNEXTLINE(modernize-avoid-c-arrays)
+ static const char* sorts[6];
+ inline auto getSorts() const -> const char** override { return sorts; };
};
-}
+} // namespace FlameMod
diff --git a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp
index d1641729..864ae8e6 100644
--- a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp
+++ b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp
@@ -34,224 +34,40 @@
*/
#include "FlameModPage.h"
-#include "ui_FlameModPage.h"
+#include "ui_ModPage.h"
-#include <QKeyEvent>
-
-#include "Application.h"
#include "FlameModModel.h"
-#include "InstanceImportTask.h"
-#include "Json.h"
-#include "ModDownloadTask.h"
-#include "minecraft/MinecraftInstance.h"
-#include "minecraft/PackProfile.h"
#include "ui/dialogs/ModDownloadDialog.h"
-FlameModPage::FlameModPage(ModDownloadDialog *dialog, BaseInstance *instance)
- : QWidget(dialog), m_instance(instance), ui(new Ui::FlameModPage),
- dialog(dialog) {
- ui->setupUi(this);
- connect(ui->searchButton, &QPushButton::clicked, this,
- &FlameModPage::triggerSearch);
- ui->searchEdit->installEventFilter(this);
- listModel = new FlameMod::ListModel(this);
- ui->packView->setModel(listModel);
-
- ui->versionSelectionBox->view()->setVerticalScrollBarPolicy(
- Qt::ScrollBarAsNeeded);
- ui->versionSelectionBox->view()->parentWidget()->setMaximumHeight(300);
-
- // index is used to set the sorting with the flame api
- ui->sortByBox->addItem(tr("Sort by Featured"));
- ui->sortByBox->addItem(tr("Sort by Popularity"));
- ui->sortByBox->addItem(tr("Sort by last updated"));
- ui->sortByBox->addItem(tr("Sort by Name"));
- ui->sortByBox->addItem(tr("Sort by Author"));
- ui->sortByBox->addItem(tr("Sort by Downloads"));
-
- connect(ui->sortByBox, SIGNAL(currentIndexChanged(int)), this,
- SLOT(triggerSearch()));
- connect(ui->packView->selectionModel(), &QItemSelectionModel::currentChanged,
- this, &FlameModPage::onSelectionChanged);
- connect(ui->versionSelectionBox, &QComboBox::currentTextChanged, this,
- &FlameModPage::onVersionSelectionChanged);
- connect(ui->modSelectionButton, &QPushButton::clicked, this,
- &FlameModPage::onModSelected);
-}
-
-FlameModPage::~FlameModPage() { delete ui; }
-
-bool FlameModPage::eventFilter(QObject *watched, QEvent *event) {
- if (watched == ui->searchEdit && event->type() == QEvent::KeyPress) {
- QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
- if (keyEvent->key() == Qt::Key_Return) {
- triggerSearch();
- keyEvent->accept();
- return true;
- }
- }
- return QWidget::eventFilter(watched, event);
-}
-
-bool FlameModPage::shouldDisplay() const { return true; }
-
-void FlameModPage::retranslate()
+FlameModPage::FlameModPage(ModDownloadDialog* dialog, BaseInstance* instance)
+ : ModPage(dialog, instance, new FlameAPI())
{
- ui->retranslateUi(this);
-}
-
-void FlameModPage::openedImpl() {
- updateSelectionButton();
- triggerSearch();
-}
-
-void FlameModPage::triggerSearch() {
- listModel->searchWithTerm(ui->searchEdit->text(),
- ui->sortByBox->currentIndex());
-}
-
-void FlameModPage::onSelectionChanged(QModelIndex first, QModelIndex second) {
- ui->versionSelectionBox->clear();
-
- if (!first.isValid()) {
- return;
- }
-
- current = listModel->data(first, Qt::UserRole).value<FlameMod::IndexedPack>();
- QString text = "";
- QString name = current.name;
-
- if (current.websiteUrl.isEmpty())
- text = name;
- else
- text = "<a href=\"" + current.websiteUrl + "\">" + name + "</a>";
- if (!current.authors.empty()) {
- auto authorToStr = [](FlameMod::ModpackAuthor &author) {
- if (author.url.isEmpty()) {
- return author.name;
- }
- return QString("<a href=\"%1\">%2</a>").arg(author.url, author.name);
- };
- QStringList authorStrs;
- for (auto &author : current.authors) {
- authorStrs.push_back(authorToStr(author));
- }
- text += "<br>" + tr(" by ") + authorStrs.join(", ");
- }
- text += "<br><br>";
-
- ui->packDescription->setHtml(text + current.description);
-
- if (!current.versionsLoaded) {
- qDebug() << "Loading flame mod versions";
-
- ui->modSelectionButton->setText(tr("Loading versions..."));
- ui->modSelectionButton->setEnabled(false);
-
- auto netJob =
- new NetJob(QString("Flame::ModVersions(%1)").arg(current.name),
- APPLICATION->network());
- auto response = new QByteArray();
- int addonId = current.addonId;
- netJob->addNetAction(Net::Download::makeByteArray(
- QString("https://addons-ecs.forgesvc.net/api/v2/addon/%1/files")
- .arg(addonId),
- response));
-
- QObject::connect(netJob, &NetJob::succeeded, this, [this, response, addonId] {
- if(addonId != current.addonId){
- return; //wrong request
- }
- QJsonParseError parse_error;
- QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error);
- if (parse_error.error != QJsonParseError::NoError) {
- qWarning() << "Error while parsing JSON response from Flame at "
- << parse_error.offset
- << " reason: " << parse_error.errorString();
- qWarning() << *response;
- return;
- }
- QJsonArray arr = doc.array();
- try {
- FlameMod::loadIndexedPackVersions(current, arr, APPLICATION->network(),
- m_instance);
- } catch (const JSONValidationError &e) {
- qDebug() << *response;
- qWarning() << "Error while reading Flame mod version: " << e.cause();
- }
- auto packProfile = ((MinecraftInstance *)m_instance)->getPackProfile();
- QString mcVersion = packProfile->getComponentVersion("net.minecraft");
- QString loaderString =
- (packProfile->getComponentVersion("net.minecraftforge").isEmpty())
- ? "fabric"
- : "forge";
- for (int i = 0; i < current.versions.size(); i++) {
- auto version = current.versions[i];
- if (!version.mcVersion.contains(mcVersion)) {
- continue;
- }
- ui->versionSelectionBox->addItem(version.version, QVariant(i));
- }
- if (ui->versionSelectionBox->count() == 0) {
- ui->versionSelectionBox->addItem(tr("No valid version found."),
- QVariant(-1));
- }
-
- ui->modSelectionButton->setText(tr("Cannot select invalid version :("));
- updateSelectionButton();
- });
- QObject::connect(netJob, &NetJob::finished, this, [response, netJob] {
- netJob->deleteLater();
- delete response;
- });
- netJob->start();
- } else {
- for (int i = 0; i < current.versions.size(); i++) {
- ui->versionSelectionBox->addItem(current.versions[i].version,
- QVariant(i));
- }
- if (ui->versionSelectionBox->count() == 0) {
- ui->versionSelectionBox->addItem(tr("No valid version found."),
- QVariant(-1));
- }
-
- updateSelectionButton();
- }
-}
-
-void FlameModPage::updateSelectionButton() {
- if (!isOpened || selectedVersion < 0) {
- ui->modSelectionButton->setEnabled(false);
- return;
- }
-
- ui->modSelectionButton->setEnabled(true);
- auto &version = current.versions[selectedVersion];
- if (!dialog->isModSelected(current.name, version.fileName)) {
- ui->modSelectionButton->setText(tr("Select mod for download"));
- } else {
- ui->modSelectionButton->setText(tr("Deselect mod for download"));
- }
+ listModel = new FlameMod::ListModel(this);
+ ui->packView->setModel(listModel);
+
+ // index is used to set the sorting with the flame api
+ ui->sortByBox->addItem(tr("Sort by Featured"));
+ ui->sortByBox->addItem(tr("Sort by Popularity"));
+ ui->sortByBox->addItem(tr("Sort by last updated"));
+ ui->sortByBox->addItem(tr("Sort by Name"));
+ ui->sortByBox->addItem(tr("Sort by Author"));
+ ui->sortByBox->addItem(tr("Sort by Downloads"));
+
+ // sometimes Qt just ignores virtual slots and doesn't work as intended it seems,
+ // so it's best not to connect them in the parent's contructor...
+ connect(ui->sortByBox, SIGNAL(currentIndexChanged(int)), this, SLOT(triggerSearch()));
+ connect(ui->packView->selectionModel(), &QItemSelectionModel::currentChanged, this, &FlameModPage::onSelectionChanged);
+ connect(ui->versionSelectionBox, &QComboBox::currentTextChanged, this, &FlameModPage::onVersionSelectionChanged);
+ connect(ui->modSelectionButton, &QPushButton::clicked, this, &FlameModPage::onModSelected);
}
-void FlameModPage::onVersionSelectionChanged(QString data) {
- if (data.isNull() || data.isEmpty()) {
- selectedVersion = -1;
- return;
- }
- selectedVersion = ui->versionSelectionBox->currentData().toInt();
- updateSelectionButton();
+auto FlameModPage::validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, QString loaderVer) const -> bool
+{
+ (void) loaderVer;
+ return ver.mcVersion.contains(mineVer);
}
-void FlameModPage::onModSelected() {
- auto &version = current.versions[selectedVersion];
- if (dialog->isModSelected(current.name, version.fileName)) {
- dialog->removeSelectedMod(current.name);
- } else {
- dialog->addSelectedMod(current.name,
- new ModDownloadTask(version.downloadUrl,
- version.fileName, dialog->mods));
- }
-
- updateSelectionButton();
-}
+// I don't know why, but doing this on the parent class makes it so that
+// other mod providers start loading before being selected, at least with
+// my Qt, so we need to implement this in every derived class...
+auto FlameModPage::shouldDisplay() const -> bool { return true; }
diff --git a/launcher/ui/pages/modplatform/flame/FlameModPage.h b/launcher/ui/pages/modplatform/flame/FlameModPage.h
index 2a6ade85..dc58fd7f 100644
--- a/launcher/ui/pages/modplatform/flame/FlameModPage.h
+++ b/launcher/ui/pages/modplatform/flame/FlameModPage.h
@@ -35,70 +35,26 @@
#pragma once
-#include <QWidget>
+#include "ui/pages/modplatform/ModPage.h"
-#include "ui/pages/BasePage.h"
-#include <Application.h>
-#include "tasks/Task.h"
-#include "modplatform/flame/FlameModIndex.h"
+#include "modplatform/flame/FlameAPI.h"
-namespace Ui
-{
-class FlameModPage;
-}
-
-class ModDownloadDialog;
-
-namespace FlameMod {
- class ListModel;
-}
-
-class FlameModPage : public QWidget, public BasePage
-{
+class FlameModPage : public ModPage {
Q_OBJECT
-public:
- explicit FlameModPage(ModDownloadDialog *dialog, BaseInstance *instance);
- virtual ~FlameModPage();
- virtual QString displayName() const override
- {
- return "CurseForge";
- }
- virtual QIcon icon() const override
- {
- return APPLICATION->getThemedIcon("flame");
- }
- virtual QString id() const override
- {
- return "curseforge";
- }
- virtual QString helpPage() const override
- {
- return "Flame-platform";
- }
- virtual bool shouldDisplay() const override;
- void retranslate() override;
-
- void openedImpl() override;
-
- bool eventFilter(QObject * watched, QEvent * event) override;
-
- BaseInstance *m_instance;
+ public:
+ explicit FlameModPage(ModDownloadDialog* dialog, BaseInstance* instance);
+ ~FlameModPage() override = default;
-private:
- void updateSelectionButton();
+ inline auto displayName() const -> QString override { return "CurseForge"; }
+ inline auto icon() const -> QIcon override { return APPLICATION->getThemedIcon("flame"); }
+ inline auto id() const -> QString override { return "curseforge"; }
+ inline auto helpPage() const -> QString override { return "Flame-platform"; }
-private slots:
- void triggerSearch();
- void onSelectionChanged(QModelIndex first, QModelIndex second);
- void onVersionSelectionChanged(QString data);
- void onModSelected();
+ inline auto debugName() const -> QString override { return "Flame"; }
+ inline auto metaEntryBase() const -> QString override { return "FlameMods"; };
-private:
- Ui::FlameModPage *ui = nullptr;
- ModDownloadDialog* dialog = nullptr;
- FlameMod::ListModel* listModel = nullptr;
- FlameMod::IndexedPack current;
+ auto validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, QString loaderVer = "") const -> bool override;
- int selectedVersion = -1;
+ auto shouldDisplay() const -> bool override;
};
diff --git a/launcher/ui/pages/modplatform/flame/FlameModPage.ui b/launcher/ui/pages/modplatform/flame/FlameModPage.ui
deleted file mode 100644
index 25cb2571..00000000
--- a/launcher/ui/pages/modplatform/flame/FlameModPage.ui
+++ /dev/null
@@ -1,97 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>FlameModPage</class>
- <widget class="QWidget" name="FlameModPage">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>837</width>
- <height>685</height>
- </rect>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="2" column="0" colspan="2">
- <layout class="QGridLayout" name="gridLayout_4" columnstretch="0,0,0" rowminimumheight="0,0,0" columnminimumwidth="0,0,0">
- <item row="1" column="2">
- <widget class="QComboBox" name="versionSelectionBox"/>
- </item>
- <item row="1" column="0">
- <widget class="QComboBox" name="sortByBox"/>
- </item>
- <item row="1" column="1">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Version selected:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
- <item row="2" column="2">
- <widget class="QPushButton" name="modSelectionButton">
- <property name="text">
- <string>Select mod for download</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="0" column="0">
- <widget class="QLineEdit" name="searchEdit">
- <property name="placeholderText">
- <string>Search and filter...</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0" colspan="2">
- <layout class="QGridLayout" name="gridLayout_3">
- <item row="1" column="0">
- <widget class="QListView" name="packView">
- <property name="horizontalScrollBarPolicy">
- <enum>Qt::ScrollBarAlwaysOff</enum>
- </property>
- <property name="alternatingRowColors">
- <bool>true</bool>
- </property>
- <property name="iconSize">
- <size>
- <width>48</width>
- <height>48</height>
- </size>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QTextBrowser" name="packDescription">
- <property name="openExternalLinks">
- <bool>true</bool>
- </property>
- <property name="openLinks">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="0" column="1">
- <widget class="QPushButton" name="searchButton">
- <property name="text">
- <string>Search</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <tabstops>
- <tabstop>searchEdit</tabstop>
- <tabstop>searchButton</tabstop>
- <tabstop>packView</tabstop>
- <tabstop>packDescription</tabstop>
- <tabstop>sortByBox</tabstop>
- <tabstop>versionSelectionBox</tabstop>
- </tabstops>
- <resources/>
- <connections/>
-</ui>
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp
index 5a18830a..b788860a 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.cpp
@@ -1,276 +1,43 @@
-#include "ModrinthModel.h"
-#include "Application.h"
-#include "minecraft/MinecraftInstance.h"
-#include "minecraft/PackProfile.h"
-#include "ModrinthPage.h"
-#include "ui/dialogs/ModDownloadDialog.h"
-#include <Json.h>
-
-#include <MMCStrings.h>
-#include <Version.h>
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
+ *
+ * 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
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
-#include <QtMath>
-#include <QMessageBox>
+#include "ModrinthModel.h"
+#include "modplatform/modrinth/ModrinthPackIndex.h"
namespace Modrinth {
-ListModel::ListModel(ModrinthPage *parent) : QAbstractListModel(parent)
-{
-}
-
-ListModel::~ListModel()
-{
-}
+// NOLINTNEXTLINE(modernize-avoid-c-arrays)
+const char* ListModel::sorts[5]{ "relevance", "downloads", "follows", "updated", "newest" };
-int ListModel::rowCount(const QModelIndex &parent) const
+void ListModel::loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj)
{
- return modpacks.size();
+ Modrinth::loadIndexedPack(m, obj);
}
-int ListModel::columnCount(const QModelIndex &parent) const
+void ListModel::loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonArray& arr)
{
- return 1;
+ Modrinth::loadIndexedPackVersions(m, arr, APPLICATION->network(), m_parent->m_instance);
}
-QVariant ListModel::data(const QModelIndex &index, int role) const
+auto ListModel::documentToArray(QJsonDocument& obj) const -> QJsonArray
{
- int pos = index.row();
- if(pos >= modpacks.size() || pos < 0 || !index.isValid())
- {
- return QString("INVALID INDEX %1").arg(pos);
- }
-
- IndexedPack pack = modpacks.at(pos);
- if(role == Qt::DisplayRole)
- {
- return pack.name;
- }
- else if (role == Qt::ToolTipRole)
- {
- if(pack.description.length() > 100)
- {
- //some magic to prevent to long tooltips and replace html linebreaks
- QString edit = pack.description.left(97);
- edit = edit.left(edit.lastIndexOf("<br>")).left(edit.lastIndexOf(" ")).append("...");
- return edit;
-
- }
- return pack.description;
- }
- else if(role == Qt::DecorationRole)
- {
- if(m_logoMap.contains(pack.logoName))
- {
- return (m_logoMap.value(pack.logoName));
- }
- QIcon icon = APPLICATION->getThemedIcon("screenshot-placeholder");
- ((ListModel *)this)->requestLogo(pack.logoName, pack.logoUrl);
- return icon;
- }
- else if(role == Qt::UserRole)
- {
- QVariant v;
- v.setValue(pack);
- return v;
- }
-
- return QVariant();
-}
-
-void ListModel::logoLoaded(QString logo, QIcon out)
-{
- m_loadingLogos.removeAll(logo);
- m_logoMap.insert(logo, out);
- for(int i = 0; i < modpacks.size(); i++) {
- if(modpacks[i].logoName == logo) {
- emit dataChanged(createIndex(i, 0), createIndex(i, 0), {Qt::DecorationRole});
- }
- }
-}
-
-void ListModel::logoFailed(QString logo)
-{
- m_failedLogos.append(logo);
- m_loadingLogos.removeAll(logo);
-}
-
-void ListModel::requestLogo(QString logo, QString url)
-{
- if(m_loadingLogos.contains(logo) || m_failedLogos.contains(logo))
- {
- return;
- }
-
- MetaEntryPtr entry = APPLICATION->metacache()->resolveEntry("ModrinthPacks", QString("logos/%1").arg(logo.section(".", 0, 0)));
- auto job = new NetJob(QString("Modrinth Icon Download %1").arg(logo), APPLICATION->network());
- job->addNetAction(Net::Download::makeCached(QUrl(url), entry));
-
- auto fullPath = entry->getFullPath();
- QObject::connect(job, &NetJob::succeeded, this, [this, logo, fullPath, job]
- {
- job->deleteLater();
- emit logoLoaded(logo, QIcon(fullPath));
- if(waitingCallbacks.contains(logo))
- {
- waitingCallbacks.value(logo)(fullPath);
- }
- });
-
- QObject::connect(job, &NetJob::failed, this, [this, logo, job]
- {
- job->deleteLater();
- emit logoFailed(logo);
- });
-
- job->start();
- m_loadingLogos.append(logo);
-}
-
-void ListModel::getLogo(const QString &logo, const QString &logoUrl, LogoCallback callback)
-{
- if(m_logoMap.contains(logo))
- {
- callback(APPLICATION->metacache()->resolveEntry("ModrinthPacks", QString("logos/%1").arg(logo.section(".", 0, 0)))->getFullPath());
- }
- else
- {
- requestLogo(logo, logoUrl);
- }
-}
-
-Qt::ItemFlags ListModel::flags(const QModelIndex &index) const
-{
- return QAbstractListModel::flags(index);
-}
-
-bool ListModel::canFetchMore(const QModelIndex& parent) const
-{
- return searchState == CanPossiblyFetchMore;
-}
-
-void ListModel::fetchMore(const QModelIndex& parent)
-{
- if (parent.isValid())
- return;
- if(nextSearchOffset == 0) {
- qWarning() << "fetchMore with 0 offset is wrong...";
- return;
- }
- performPaginatedSearch();
-}
-const char* sorts[5]{"relevance","downloads","follows","updated","newest"};
-
-void ListModel::performPaginatedSearch()
-{
-
- QString mcVersion = ((MinecraftInstance *)((ModrinthPage *)parent())->m_instance)->getPackProfile()->getComponentVersion("net.minecraft");
- bool hasFabric = !((MinecraftInstance *)((ModrinthPage *)parent())->m_instance)->getPackProfile()->getComponentVersion("net.fabricmc.fabric-loader").isEmpty();
- auto netJob = new NetJob("Modrinth::Search", APPLICATION->network());
- auto searchUrl = QString(
- "https://api.modrinth.com/v2/search?"
- "offset=%1&"
- "limit=25&"
- "query=%2&"
- "index=%3&"
- "facets=[[\"categories:%4\"],[\"versions:%5\"],[\"project_type:mod\"]]"
- )
- .arg(nextSearchOffset)
- .arg(currentSearchTerm)
- .arg(sorts[currentSort])
- .arg(hasFabric ? "fabric" : "forge")
- .arg(mcVersion);
-
- netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));
- jobPtr = netJob;
- jobPtr->start();
- QObject::connect(netJob, &NetJob::succeeded, this, &ListModel::searchRequestFinished);
- QObject::connect(netJob, &NetJob::failed, this, &ListModel::searchRequestFailed);
-}
-
-void ListModel::searchWithTerm(const QString &term, const int sort)
-{
- if(currentSearchTerm == term && currentSearchTerm.isNull() == term.isNull() && currentSort == sort) {
- return;
- }
- currentSearchTerm = term;
- currentSort = sort;
- if(jobPtr) {
- jobPtr->abort();
- searchState = ResetRequested;
- return;
- }
- else {
- beginResetModel();
- modpacks.clear();
- endResetModel();
- searchState = None;
- }
- nextSearchOffset = 0;
- performPaginatedSearch();
-}
-
-void Modrinth::ListModel::searchRequestFinished()
-{
- jobPtr.reset();
-
- QJsonParseError parse_error;
- QJsonDocument doc = QJsonDocument::fromJson(response, &parse_error);
- if(parse_error.error != QJsonParseError::NoError) {
- qWarning() << "Error while parsing JSON response from Modrinth at " << parse_error.offset << " reason: " << parse_error.errorString();
- qWarning() << response;
- return;
- }
-
- QList<Modrinth::IndexedPack> newList;
- auto packs = doc.object().value("hits").toArray();
- for(auto packRaw : packs) {
- auto packObj = packRaw.toObject();
-
- Modrinth::IndexedPack pack;
- try
- {
- Modrinth::loadIndexedPack(pack, packObj);
- newList.append(pack);
- }
- catch(const JSONValidationError &e)
- {
- qWarning() << "Error while loading mod from Modrinth: " << e.cause();
- continue;
- }
- }
- if(packs.size() < 25) {
- searchState = Finished;
- } else {
- nextSearchOffset += 25;
- searchState = CanPossiblyFetchMore;
- }
- beginInsertRows(QModelIndex(), modpacks.size(), modpacks.size() + newList.size() - 1);
- modpacks.append(newList);
- endInsertRows();
-}
-
-void Modrinth::ListModel::searchRequestFailed(QString reason)
-{
- if(jobPtr->first()->m_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 409){
- //409 Gone, notify user to update
- QMessageBox::critical(nullptr, tr("Error"), tr("Modrinth API version too old!\nPlease update PolyMC!"));
- //self-destruct
- ((ModDownloadDialog *)((ModrinthPage *)parent())->parentWidget())->reject();
- }
- jobPtr.reset();
-
- if(searchState == ResetRequested) {
- beginResetModel();
- modpacks.clear();
- endResetModel();
-
- nextSearchOffset = 0;
- performPaginatedSearch();
- } else {
- searchState = Finished;
- }
-}
-
+ return obj.object().value("hits").toArray();
}
+} // namespace Modrinth
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.h b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.h
index 53f1f134..45a6090a 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthModel.h
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthModel.h
@@ -1,79 +1,25 @@
#pragma once
-#include <RWStorage.h>
-
-#include <QAbstractListModel>
-#include <QSortFilterProxyModel>
-#include <QThreadPool>
-#include <QIcon>
-#include <QStyledItemDelegate>
-#include <QList>
-#include <QString>
-#include <QStringList>
-#include <QMetaType>
-
-#include <functional>
-#include <net/NetJob.h>
-
-#include <modplatform/flame/FlamePackIndex.h>
-#include "modplatform/modrinth/ModrinthPackIndex.h"
-#include "BaseInstance.h"
#include "ModrinthPage.h"
namespace Modrinth {
-
-typedef QMap<QString, QIcon> LogoMap;
-typedef std::function<void(QString)> LogoCallback;
-
-class ListModel : public QAbstractListModel
-{
+class ListModel : public ModPlatform::ListModel {
Q_OBJECT
-public:
- ListModel(ModrinthPage *parent);
- virtual ~ListModel();
-
- int rowCount(const QModelIndex &parent) const override;
- int columnCount(const QModelIndex &parent) const override;
- QVariant data(const QModelIndex &index, int role) const override;
- Qt::ItemFlags flags(const QModelIndex &index) const override;
- bool canFetchMore(const QModelIndex & parent) const override;
- void fetchMore(const QModelIndex & parent) override;
-
- void getLogo(const QString &logo, const QString &logoUrl, LogoCallback callback);
- void searchWithTerm(const QString &term, const int sort);
-
-private slots:
- void performPaginatedSearch();
-
- void logoFailed(QString logo);
- void logoLoaded(QString logo, QIcon out);
-
- void searchRequestFinished();
- void searchRequestFailed(QString reason);
-
-private:
- void requestLogo(QString file, QString url);
+ public:
+ ListModel(ModrinthPage* parent) : ModPlatform::ListModel(parent){};
+ ~ListModel() override = default;
-private:
- QList<IndexedPack> modpacks;
- QStringList m_failedLogos;
- QStringList m_loadingLogos;
- LogoMap m_logoMap;
- QMap<QString, LogoCallback> waitingCallbacks;
+ private:
+ void loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj) override;
+ void loadIndexedPackVersions(ModPlatform::IndexedPack& m, QJsonArray& arr) override;
+
+ auto documentToArray(QJsonDocument& obj) const -> QJsonArray override;
- QString currentSearchTerm;
- int currentSort = 0;
- int nextSearchOffset = 0;
- enum SearchState {
- None,
- CanPossiblyFetchMore,
- ResetRequested,
- Finished
- } searchState = None;
- NetJob::Ptr jobPtr;
- QByteArray response;
+ // NOLINTNEXTLINE(modernize-avoid-c-arrays)
+ static const char* sorts[5];
+ inline auto getSorts() const -> const char** override { return sorts; };
};
-}
+} // namespace Modrinth
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp
index 82340448..ddaf96e2 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.cpp
@@ -34,211 +34,38 @@
*/
#include "ModrinthPage.h"
-#include "ui_ModrinthPage.h"
+#include "ui_ModPage.h"
-#include <QKeyEvent>
-
-#include "Application.h"
-#include "InstanceImportTask.h"
-#include "Json.h"
-#include "ModDownloadTask.h"
#include "ModrinthModel.h"
-#include "minecraft/MinecraftInstance.h"
-#include "minecraft/PackProfile.h"
#include "ui/dialogs/ModDownloadDialog.h"
-ModrinthPage::ModrinthPage(ModDownloadDialog *dialog, BaseInstance *instance)
- : QWidget(dialog), m_instance(instance), ui(new Ui::ModrinthPage),
- dialog(dialog) {
- ui->setupUi(this);
- connect(ui->searchButton, &QPushButton::clicked, this,
- &ModrinthPage::triggerSearch);
- ui->searchEdit->installEventFilter(this);
- listModel = new Modrinth::ListModel(this);
- ui->packView->setModel(listModel);
-
- ui->versionSelectionBox->view()->setVerticalScrollBarPolicy(
- Qt::ScrollBarAsNeeded);
- ui->versionSelectionBox->view()->parentWidget()->setMaximumHeight(300);
-
- // index is used to set the sorting with the modrinth api
- ui->sortByBox->addItem(tr("Sort by Relevance"));
- ui->sortByBox->addItem(tr("Sort by Downloads"));
- ui->sortByBox->addItem(tr("Sort by Follows"));
- ui->sortByBox->addItem(tr("Sort by last updated"));
- ui->sortByBox->addItem(tr("Sort by newest"));
-
- connect(ui->sortByBox, SIGNAL(currentIndexChanged(int)), this,
- SLOT(triggerSearch()));
- connect(ui->packView->selectionModel(), &QItemSelectionModel::currentChanged,
- this, &ModrinthPage::onSelectionChanged);
- connect(ui->versionSelectionBox, &QComboBox::currentTextChanged, this,
- &ModrinthPage::onVersionSelectionChanged);
- connect(ui->modSelectionButton, &QPushButton::clicked, this,
- &ModrinthPage::onModSelected);
-}
-
-ModrinthPage::~ModrinthPage() { delete ui; }
-
-bool ModrinthPage::eventFilter(QObject *watched, QEvent *event) {
- if (watched == ui->searchEdit && event->type() == QEvent::KeyPress) {
- QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
- if (keyEvent->key() == Qt::Key_Return) {
- triggerSearch();
- keyEvent->accept();
- return true;
- }
- }
- return QWidget::eventFilter(watched, event);
-}
-
-bool ModrinthPage::shouldDisplay() const { return true; }
-
-void ModrinthPage::retranslate() {
- ui->retranslateUi(this);
-}
-
-void ModrinthPage::openedImpl() {
- updateSelectionButton();
- triggerSearch();
-}
-
-void ModrinthPage::triggerSearch() {
- listModel->searchWithTerm(ui->searchEdit->text(),
- ui->sortByBox->currentIndex());
-}
-
-void ModrinthPage::onSelectionChanged(QModelIndex first, QModelIndex second) {
- ui->versionSelectionBox->clear();
-
- if (!first.isValid()) {
- return;
- }
-
- current = listModel->data(first, Qt::UserRole).value<Modrinth::IndexedPack>();
- QString text = "";
- QString name = current.name;
-
- if (current.websiteUrl.isEmpty())
- text = name;
- else
- text = "<a href=\"" + current.websiteUrl + "\">" + name + "</a>";
- text += "<br>" + tr(" by ") + "<a href=\"" + current.author.url + "\">" +
- current.author.name + "</a><br><br>";
- ui->packDescription->setHtml(text + current.description);
-
- if (!current.versionsLoaded) {
- qDebug() << "Loading Modrinth mod versions";
-
- ui->modSelectionButton->setText(tr("Loading versions..."));
- ui->modSelectionButton->setEnabled(false);
-
- auto netJob =
- new NetJob(QString("Modrinth::ModVersions(%1)").arg(current.name),
- APPLICATION->network());
- auto response = new QByteArray();
- QString addonId = current.addonId;
- netJob->addNetAction(Net::Download::makeByteArray(
- QString("https://api.modrinth.com/v2/project/%1/version").arg(addonId),
- response));
-
- QObject::connect(netJob, &NetJob::succeeded, this, [this, response, addonId] {
- if(addonId != current.addonId){
- return;
- }
- QJsonParseError parse_error;
- QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error);
- if (parse_error.error != QJsonParseError::NoError) {
- qWarning() << "Error while parsing JSON response from Modrinth at "
- << parse_error.offset
- << " reason: " << parse_error.errorString();
- qWarning() << *response;
- return;
- }
- QJsonArray arr = doc.array();
- try {
- Modrinth::loadIndexedPackVersions(current, arr, APPLICATION->network(),
- m_instance);
- } catch (const JSONValidationError &e) {
- qDebug() << *response;
- qWarning() << "Error while reading Modrinth mod version: " << e.cause();
- }
- auto packProfile = ((MinecraftInstance *)m_instance)->getPackProfile();
- QString mcVersion = packProfile->getComponentVersion("net.minecraft");
- QString loaderString =
- (packProfile->getComponentVersion("net.minecraftforge").isEmpty())
- ? "fabric"
- : "forge";
- for (int i = 0; i < current.versions.size(); i++) {
- auto version = current.versions[i];
- if (!version.mcVersion.contains(mcVersion) ||
- !version.loaders.contains(loaderString)) {
- continue;
- }
- ui->versionSelectionBox->addItem(version.version, QVariant(i));
- }
- if (ui->versionSelectionBox->count() == 0) {
- ui->versionSelectionBox->addItem(tr("No valid version found."),
- QVariant(-1));
- }
-
- ui->modSelectionButton->setText(tr("Cannot select invalid version :("));
- updateSelectionButton();
- });
-
- QObject::connect(netJob, &NetJob::finished, this, [response, netJob] {
- netJob->deleteLater();
- delete response;
- });
-
- netJob->start();
- } else {
- for (int i = 0; i < current.versions.size(); i++) {
- ui->versionSelectionBox->addItem(current.versions[i].version,
- QVariant(i));
- }
- if (ui->versionSelectionBox->count() == 0) {
- ui->versionSelectionBox->addItem(tr("No valid version found."),
- QVariant(-1));
- }
-
- updateSelectionButton();
- }
-}
-
-void ModrinthPage::updateSelectionButton() {
- if (!isOpened || selectedVersion < 0) {
- ui->modSelectionButton->setEnabled(false);
- return;
- }
-
- ui->modSelectionButton->setEnabled(true);
- auto &version = current.versions[selectedVersion];
- if (!dialog->isModSelected(current.name, version.fileName)) {
- ui->modSelectionButton->setText(tr("Select mod for download"));
- } else {
- ui->modSelectionButton->setText(tr("Deselect mod for download"));
- }
+ModrinthPage::ModrinthPage(ModDownloadDialog* dialog, BaseInstance* instance)
+ : ModPage(dialog, instance, new ModrinthAPI())
+{
+ listModel = new Modrinth::ListModel(this);
+ ui->packView->setModel(listModel);
+
+ // index is used to set the sorting with the modrinth api
+ ui->sortByBox->addItem(tr("Sort by Relevence"));
+ ui->sortByBox->addItem(tr("Sort by Downloads"));
+ ui->sortByBox->addItem(tr("Sort by Follows"));
+ ui->sortByBox->addItem(tr("Sort by last updated"));
+ ui->sortByBox->addItem(tr("Sort by newest"));
+
+ // sometimes Qt just ignores virtual slots and doesn't work as intended it seems,
+ // so it's best not to connect them in the parent's contructor...
+ connect(ui->sortByBox, SIGNAL(currentIndexChanged(int)), this, SLOT(triggerSearch()));
+ connect(ui->packView->selectionModel(), &QItemSelectionModel::currentChanged, this, &ModrinthPage::onSelectionChanged);
+ connect(ui->versionSelectionBox, &QComboBox::currentTextChanged, this, &ModrinthPage::onVersionSelectionChanged);
+ connect(ui->modSelectionButton, &QPushButton::clicked, this, &ModrinthPage::onModSelected);
}
-void ModrinthPage::onVersionSelectionChanged(QString data) {
- if (data.isNull() || data.isEmpty()) {
- selectedVersion = -1;
- return;
- }
- selectedVersion = ui->versionSelectionBox->currentData().toInt();
- updateSelectionButton();
+auto ModrinthPage::validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, QString loaderVer) const -> bool
+{
+ return ver.mcVersion.contains(mineVer) && ver.loaders.contains(loaderVer);
}
-void ModrinthPage::onModSelected() {
- auto &version = current.versions[selectedVersion];
- if (dialog->isModSelected(current.name, version.fileName)) {
- dialog->removeSelectedMod(current.name);
- } else {
- dialog->addSelectedMod(current.name,
- new ModDownloadTask(version.downloadUrl,
- version.fileName, dialog->mods));
- }
-
- updateSelectionButton();
-}
+// I don't know why, but doing this on the parent class makes it so that
+// other mod providers start loading before being selected, at least with
+// my Qt, so we need to implement this in every derived class...
+auto ModrinthPage::shouldDisplay() const -> bool { return true; }
diff --git a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h
index 92955d62..aa5ed793 100644
--- a/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h
+++ b/launcher/ui/pages/modplatform/modrinth/ModrinthPage.h
@@ -35,70 +35,26 @@
#pragma once
-#include <QWidget>
+#include "ui/pages/modplatform/ModPage.h"
-#include "ui/pages/BasePage.h"
-#include <Application.h>
-#include "tasks/Task.h"
-#include "modplatform/modrinth/ModrinthPackIndex.h"
+#include "modplatform/modrinth/ModrinthAPI.h"
-namespace Ui
-{
-class ModrinthPage;
-}
-
-class ModDownloadDialog;
-
-namespace Modrinth {
- class ListModel;
-}
-
-class ModrinthPage : public QWidget, public BasePage
-{
+class ModrinthPage : public ModPage {
Q_OBJECT
-public:
- explicit ModrinthPage(ModDownloadDialog *dialog, BaseInstance *instance);
- virtual ~ModrinthPage();
- virtual QString displayName() const override
- {
- return "Modrinth";
- }
- virtual QIcon icon() const override
- {
- return APPLICATION->getThemedIcon("modrinth");
- }
- virtual QString id() const override
- {
- return "modrinth";
- }
- virtual QString helpPage() const override
- {
- return "Modrinth-platform";
- }
- virtual bool shouldDisplay() const override;
- void retranslate() override;
-
- void openedImpl() override;
-
- bool eventFilter(QObject * watched, QEvent * event) override;
-
- BaseInstance *m_instance;
+ public:
+ explicit ModrinthPage(ModDownloadDialog* dialog, BaseInstance* instance);
+ ~ModrinthPage() override = default;
-private:
- void updateSelectionButton();
+ inline auto displayName() const -> QString override { return "Modrinth"; }
+ inline auto icon() const -> QIcon override { return APPLICATION->getThemedIcon("modrinth"); }
+ inline auto id() const -> QString override { return "modrinth"; }
+ inline auto helpPage() const -> QString override { return "Modrinth-platform"; }
-private slots:
- void triggerSearch();
- void onSelectionChanged(QModelIndex first, QModelIndex second);
- void onVersionSelectionChanged(QString data);
- void onModSelected();
+ inline auto debugName() const -> QString override { return "Modrinth"; }
+ inline auto metaEntryBase() const -> QString override { return "ModrinthPacks"; };
-private:
- Ui::ModrinthPage *ui = nullptr;
- ModDownloadDialog* dialog = nullptr;
- Modrinth::ListModel* listModel = nullptr;
- Modrinth::IndexedPack current;
+ auto validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, QString loaderVer = "") const -> bool override;
- int selectedVersion = -1;
+ auto shouldDisplay() const -> bool override;
};
diff --git a/launcher/ui/pages/modplatform/technic/TechnicData.h b/launcher/ui/pages/modplatform/technic/TechnicData.h
index 50fd75e8..cd2ea8e1 100644
--- a/launcher/ui/pages/modplatform/technic/TechnicData.h
+++ b/launcher/ui/pages/modplatform/technic/TechnicData.h
@@ -1,22 +1,43 @@
-/* Copyright 2020-2021 MultiMC Contributors
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (c) 2021-2022 Jamie Mansfield <jmansfield@cadixdev.org>
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * 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
+ * the Free Software Foundation, version 3.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2020-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
#pragma once
#include <QList>
#include <QString>
+#include <QVector>
namespace Technic {
struct Modpack {
@@ -36,6 +57,11 @@ struct Modpack {
QString websiteUrl;
QString author;
QString description;
+ QString currentVersion;
+
+ bool versionsLoaded = false;
+ QString recommended;
+ QVector<QString> versions;
};
}
diff --git a/launcher/ui/pages/modplatform/technic/TechnicModel.cpp b/launcher/ui/pages/modplatform/technic/TechnicModel.cpp
index 0167f746..9c9d1e75 100644
--- a/launcher/ui/pages/modplatform/technic/TechnicModel.cpp
+++ b/launcher/ui/pages/modplatform/technic/TechnicModel.cpp
@@ -1,20 +1,41 @@
-/* Copyright 2020-2021 MultiMC Contributors
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (c) 2021 Jamie Mansfield <jmansfield@cadixdev.org>
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * 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
+ * the Free Software Foundation, version 3.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2020-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
#include "TechnicModel.h"
#include "Application.h"
+#include "BuildConfig.h"
#include "Json.h"
#include <QIcon>
@@ -94,13 +115,24 @@ void Technic::ListModel::performSearch()
NetJob *netJob = new NetJob("Technic::Search", APPLICATION->network());
QString searchUrl = "";
if (currentSearchTerm.isEmpty()) {
- searchUrl = "https://api.technicpack.net/trending?build=multimc";
+ searchUrl = QString("%1trending?build=%2")
+ .arg(BuildConfig.TECHNIC_API_BASE_URL, BuildConfig.TECHNIC_API_BUILD);
+ searchMode = List;
}
- else
- {
+ else if (currentSearchTerm.startsWith("http://api.technicpack.net/modpack/")) {
+ searchUrl = QString("https://%1?build=%2")
+ .arg(currentSearchTerm.mid(7), BuildConfig.TECHNIC_API_BUILD);
+ searchMode = Single;
+ }
+ else if (currentSearchTerm.startsWith("https://api.technicpack.net/modpack/")) {
+ searchUrl = QString("%1?build=%2").arg(currentSearchTerm, BuildConfig.TECHNIC_API_BUILD);
+ searchMode = Single;
+ }
+ else {
searchUrl = QString(
- "https://api.technicpack.net/search?build=multimc&q=%1"
- ).arg(currentSearchTerm);
+ "%1search?build=%2&q=%3"
+ ).arg(BuildConfig.TECHNIC_API_BASE_URL, BuildConfig.TECHNIC_API_BUILD, currentSearchTerm);
+ searchMode = List;
}
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));
jobPtr = netJob;
@@ -125,26 +157,58 @@ void Technic::ListModel::searchRequestFinished()
QList<Modpack> newList;
try {
auto root = Json::requireObject(doc);
- auto objs = Json::requireArray(root, "modpacks");
- for (auto technicPack: objs) {
- Modpack pack;
- auto technicPackObject = Json::requireObject(technicPack);
- pack.name = Json::requireString(technicPackObject, "name");
- pack.slug = Json::requireString(technicPackObject, "slug");
- if (pack.slug == "vanilla")
- continue;
-
- auto rawURL = Json::ensureString(technicPackObject, "iconUrl", "null");
- if(rawURL == "null") {
- pack.logoUrl = "null";
- pack.logoName = "null";
+
+ switch (searchMode) {
+ case List: {
+ auto objs = Json::requireArray(root, "modpacks");
+ for (auto technicPack: objs) {
+ Modpack pack;
+ auto technicPackObject = Json::requireObject(technicPack);
+ pack.name = Json::requireString(technicPackObject, "name");
+ pack.slug = Json::requireString(technicPackObject, "slug");
+ if (pack.slug == "vanilla")
+ continue;
+
+ auto rawURL = Json::ensureString(technicPackObject, "iconUrl", "null");
+ if(rawURL == "null") {
+ pack.logoUrl = "null";
+ pack.logoName = "null";
+ }
+ else {
+ pack.logoUrl = rawURL;
+ pack.logoName = rawURL.section(QLatin1Char('/'), -1).section(QLatin1Char('.'), 0, 0);
+ }
+ pack.broken = false;
+ newList.append(pack);
+ }
+ break;
}
- else {
- pack.logoUrl = rawURL;
- pack.logoName = rawURL.section(QLatin1Char('/'), -1).section(QLatin1Char('.'), 0, 0);
+ case Single: {
+ if (root.contains("error")) {
+ // Invalid API url
+ break;
+ }
+
+ Modpack pack;
+ pack.name = Json::requireString(root, "displayName");
+ pack.slug = Json::requireString(root, "name");
+
+ if (root.contains("icon")) {
+ auto iconObj = Json::requireObject(root, "icon");
+ auto iconUrl = Json::requireString(iconObj, "url");
+
+ pack.logoUrl = iconUrl;
+ pack.logoName = iconUrl.section(QLatin1Char('/'), -1).section(QLatin1Char('.'), 0, 0);
+ }
+ else {
+ pack.logoUrl = "null";
+ pack.logoName = "null";
+ }
+
+ pack.broken = false;
+ newList.append(pack);
+ break;
}
- pack.broken = false;
- newList.append(pack);
}
}
catch (const JSONValidationError &err)
diff --git a/launcher/ui/pages/modplatform/technic/TechnicModel.h b/launcher/ui/pages/modplatform/technic/TechnicModel.h
index e80e6e7c..5eea124c 100644
--- a/launcher/ui/pages/modplatform/technic/TechnicModel.h
+++ b/launcher/ui/pages/modplatform/technic/TechnicModel.h
@@ -1,16 +1,36 @@
-/* Copyright 2020-2021 MultiMC Contributors
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (c) 2021 Jamie Mansfield <jmansfield@cadixdev.org>
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * 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
+ * the Free Software Foundation, version 3.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * This file incorporates work covered by the following copyright and
+ * permission notice:
+ *
+ * Copyright 2020-2021 MultiMC Contributors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
#pragma once
@@ -63,6 +83,10 @@ private:
ResetRequested,
Finished
} searchState = None;
+ enum SearchMode {
+ List,
+ Single,
+ } searchMode = List;
NetJob::Ptr jobPtr;
QByteArray response;
};
diff --git a/launcher/ui/pages/modplatform/technic/TechnicPage.cpp b/launcher/ui/pages/modplatform/technic/TechnicPage.cpp
index c3807269..b8c1e00a 100644
--- a/launcher/ui/pages/modplatform/technic/TechnicPage.cpp
+++ b/launcher/ui/pages/modplatform/technic/TechnicPage.cpp
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* PolyMC - Minecraft Launcher
- * Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
+ * Copyright (c) 2021-2022 Jamie Mansfield <jmansfield@cadixdev.org>
*
* 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
@@ -40,12 +40,14 @@
#include "ui/dialogs/NewInstanceDialog.h"
+#include "BuildConfig.h"
#include "TechnicModel.h"
#include "modplatform/technic/SingleZipPackInstallTask.h"
#include "modplatform/technic/SolderPackInstallTask.h"
#include "Json.h"
#include "Application.h"
+#include "modplatform/technic/SolderPackManifest.h"
TechnicPage::TechnicPage(NewInstanceDialog* dialog, QWidget *parent)
: QWidget(parent), ui(new Ui::TechnicPage), dialog(dialog)
@@ -55,7 +57,9 @@ TechnicPage::TechnicPage(NewInstanceDialog* dialog, QWidget *parent)
ui->searchEdit->installEventFilter(this);
model = new Technic::ListModel(this);
ui->packView->setModel(model);
+
connect(ui->packView->selectionModel(), &QItemSelectionModel::currentChanged, this, &TechnicPage::onSelectionChanged);
+ connect(ui->versionSelectionBox, &QComboBox::currentTextChanged, this, &TechnicPage::onVersionSelectionChanged);
}
bool TechnicPage::eventFilter(QObject* watched, QEvent* event)
@@ -98,13 +102,14 @@ void TechnicPage::triggerSearch() {
void TechnicPage::onSelectionChanged(QModelIndex first, QModelIndex second)
{
+ ui->versionSelectionBox->clear();
+
if(!first.isValid())
{
if(isOpened)
{
dialog->setSuggestedPack();
}
- //ui->frame->clear();
return;
}
@@ -137,17 +142,19 @@ void TechnicPage::suggestCurrent()
}
NetJob *netJob = new NetJob(QString("Technic::PackMeta(%1)").arg(current.name), APPLICATION->network());
- std::shared_ptr<QByteArray> response = std::make_shared<QByteArray>();
QString slug = current.slug;
- netJob->addNetAction(Net::Download::makeByteArray(QString("https://api.technicpack.net/modpack/%1?build=multimc").arg(slug), response.get()));
- QObject::connect(netJob, &NetJob::succeeded, this, [this, response, slug]
+ netJob->addNetAction(Net::Download::makeByteArray(QString("%1modpack/%2?build=%3").arg(BuildConfig.TECHNIC_API_BASE_URL, slug, BuildConfig.TECHNIC_API_BUILD), &response));
+ QObject::connect(netJob, &NetJob::succeeded, this, [this, slug]
{
+ jobPtr.reset();
+
if (current.slug != slug)
{
return;
}
- QJsonParseError parse_error;
- QJsonDocument doc = QJsonDocument::fromJson(*response, &parse_error);
+
+ QJsonParseError parse_error {};
+ QJsonDocument doc = QJsonDocument::fromJson(response, &parse_error);
QJsonObject obj = doc.object();
if(parse_error.error != QJsonParseError::NoError)
{
@@ -189,10 +196,14 @@ void TechnicPage::suggestCurrent()
current.websiteUrl = Json::ensureString(obj, "platformUrl", QString(), "__placeholder__");
current.author = Json::ensureString(obj, "user", QString(), "__placeholder__");
current.description = Json::ensureString(obj, "description", QString(), "__placeholder__");
+ current.currentVersion = Json::ensureString(obj, "version", QString(), "__placeholder__");
current.metadataLoaded = true;
+
metadataLoaded();
});
- netJob->start();
+
+ jobPtr = netJob;
+ jobPtr->start();
}
// expects current.metadataLoaded to be true
@@ -202,25 +213,119 @@ void TechnicPage::metadataLoaded()
QString name = current.name;
if (current.websiteUrl.isEmpty())
- // This allows injecting HTML here.
- text = name;
+ text = name.toHtmlEscaped();
else
- // URL not properly escaped for inclusion in HTML. The name allows for injecting HTML.
- text = "<a href=\"" + current.websiteUrl + "\">" + name + "</a>";
+ text = "<a href=\"" + current.websiteUrl.toHtmlEscaped() + "\">" + name.toHtmlEscaped() + "</a>";
+
if (!current.author.isEmpty()) {
- // This allows injecting HTML here
- text += tr(" by ") + current.author;
+ text += "<br>" + tr(" by ") + current.author.toHtmlEscaped();
+ }
+
+ text += "<br><br>";
+
+ ui->packDescription->setHtml(text + current.description);
+
+ // Strip trailing forward-slashes from Solder URL's
+ if (current.isSolder) {
+ while (current.url.endsWith('/')) current.url.chop(1);
+ }
+
+ // Display versions from Solder
+ if (!current.isSolder) {
+ // If the pack isn't a Solder pack, it only has the single version
+ ui->versionSelectionBox->addItem(current.currentVersion);
+ }
+ else if (current.versionsLoaded) {
+ // reverse foreach, so that the newest versions are first
+ for (auto i = current.versions.size(); i--;) {
+ ui->versionSelectionBox->addItem(current.versions.at(i));
+ }
+ ui->versionSelectionBox->setCurrentText(current.recommended);
+ }
+ else {
+ // For now, until the versions are pulled from the Solder instance, display the current
+ // version so we can display something quicker
+ ui->versionSelectionBox->addItem(current.currentVersion);
+
+ auto* netJob = new NetJob(QString("Technic::SolderMeta(%1)").arg(current.name), APPLICATION->network());
+ auto url = QString("%1/modpack/%2").arg(current.url, current.slug);
+ netJob->addNetAction(Net::Download::makeByteArray(QUrl(url), &response));
+
+ QObject::connect(netJob, &NetJob::succeeded, this, &TechnicPage::onSolderLoaded);
+
+ jobPtr = netJob;
+ jobPtr->start();
+ }
+
+ selectVersion();
+}
+
+void TechnicPage::selectVersion() {
+ if (!isOpened) {
+ return;
+ }
+ if (current.broken) {
+ dialog->setSuggestedPack();
+ return;
}
- ui->frame->setModText(text);
- ui->frame->setModDescription(current.description);
if (!current.isSolder)
{
- dialog->setSuggestedPack(current.name, new Technic::SingleZipPackInstallTask(current.url, current.minecraftVersion));
+ dialog->setSuggestedPack(current.name + " " + selectedVersion, new Technic::SingleZipPackInstallTask(current.url, current.minecraftVersion));
}
else
{
- while (current.url.endsWith('/')) current.url.chop(1);
- dialog->setSuggestedPack(current.name, new Technic::SolderPackInstallTask(APPLICATION->network(), current.url + "/modpack/" + current.slug, current.minecraftVersion));
+ dialog->setSuggestedPack(current.name + " " + selectedVersion, new Technic::SolderPackInstallTask(APPLICATION->network(), current.url, current.slug, selectedVersion, current.minecraftVersion));
+ }
+}
+
+void TechnicPage::onSolderLoaded() {
+ jobPtr.reset();
+
+ auto fallback = [this]() {
+ current.versionsLoaded = true;
+
+ current.versions.clear();
+ current.versions.append(current.currentVersion);
+ };
+
+ current.versions.clear();
+
+ QJsonParseError parse_error {};
+ auto doc = QJsonDocument::fromJson(response, &parse_error);
+ if (parse_error.error != QJsonParseError::NoError) {
+ qWarning() << "Error while parsing JSON response from Solder at " << parse_error.offset << " reason: " << parse_error.errorString();
+ qWarning() << response;
+ fallback();
+ return;
+ }
+ auto obj = doc.object();
+
+ TechnicSolder::Pack pack;
+ try {
+ TechnicSolder::loadPack(pack, obj);
+ }
+ catch (const JSONValidationError& err) {
+ qCritical() << "Couldn't parse Solder pack metadata:" << err.cause();
+ fallback();
+ return;
+ }
+
+ current.versionsLoaded = true;
+ current.recommended = pack.recommended;
+ current.versions.append(pack.builds);
+
+ // Finally, let's reload :)
+ ui->versionSelectionBox->clear();
+ metadataLoaded();
+}
+
+void TechnicPage::onVersionSelectionChanged(QString data) {
+ if (data.isNull() || data.isEmpty()) {
+ selectedVersion = "";
+ return;
}
+
+ selectedVersion = data;
+ selectVersion();
}
diff --git a/launcher/ui/pages/modplatform/technic/TechnicPage.h b/launcher/ui/pages/modplatform/technic/TechnicPage.h
index bf4baa58..f4a3b61d 100644
--- a/launcher/ui/pages/modplatform/technic/TechnicPage.h
+++ b/launcher/ui/pages/modplatform/technic/TechnicPage.h
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
* PolyMC - Minecraft Launcher
- * Copyright (c) 2022 Jamie Mansfield <jmansfield@cadixdev.org>
+ * Copyright (c) 2021-2022 Jamie Mansfield <jmansfield@cadixdev.org>
*
* 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
@@ -39,6 +39,7 @@
#include "ui/pages/BasePage.h"
#include <Application.h>
+#include "net/NetJob.h"
#include "tasks/Task.h"
#include "TechnicData.h"
@@ -86,14 +87,22 @@ public:
private:
void suggestCurrent();
void metadataLoaded();
+ void selectVersion();
private slots:
void triggerSearch();
void onSelectionChanged(QModelIndex first, QModelIndex second);
+ void onSolderLoaded();
+ void onVersionSelectionChanged(QString data);
private:
Ui::TechnicPage *ui = nullptr;
NewInstanceDialog* dialog = nullptr;
Technic::ListModel* model = nullptr;
+
Technic::Modpack current;
+ QString selectedVersion;
+
+ NetJob::Ptr jobPtr;
+ QByteArray response;
};
diff --git a/launcher/ui/pages/modplatform/technic/TechnicPage.ui b/launcher/ui/pages/modplatform/technic/TechnicPage.ui
index 62ab6154..ca6a9b7e 100644
--- a/launcher/ui/pages/modplatform/technic/TechnicPage.ui
+++ b/launcher/ui/pages/modplatform/technic/TechnicPage.ui
@@ -10,86 +10,76 @@
<height>405</height>
</rect>
</property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QWidget" name="widget" native="true">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <widget class="QLineEdit" name="searchEdit">
- <property name="placeholderText">
- <string>Search and filter...</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="searchButton">
- <property name="text">
- <string>Search</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="3" column="0" colspan="2">
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="2">
+ <widget class="QComboBox" name="versionSelectionBox"/>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Version selected:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Preferred</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>1</width>
+ <height>1</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
</item>
- <item>
- <widget class="QListView" name="packView">
- <property name="horizontalScrollBarPolicy">
- <enum>Qt::ScrollBarAlwaysOff</enum>
- </property>
- <property name="alternatingRowColors">
- <bool>true</bool>
- </property>
- <property name="iconSize">
- <size>
- <width>48</width>
- <height>48</height>
- </size>
+ <item row="2" column="0" colspan="2">
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <widget class="QListView" name="packView">
+ <property name="alternatingRowColors">
+ <bool>true</bool>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>48</width>
+ <height>48</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QTextBrowser" name="packDescription"/>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLineEdit" name="searchEdit">
+ <property name="placeholderText">
+ <string>Search and filter...</string>
</property>
</widget>
</item>
- <item>
- <widget class="MCModInfoFrame" name="frame">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="frameShape">
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Raised</enum>
+ <item row="1" column="1">
+ <widget class="QPushButton" name="searchButton">
+ <property name="text">
+ <string>Search</string>
</property>
</widget>
</item>
</layout>
</widget>
- <customwidgets>
- <customwidget>
- <class>MCModInfoFrame</class>
- <extends>QFrame</extends>
- <header>ui/widgets/MCModInfoFrame.h</header>
- <container>1</container>
- </customwidget>
- </customwidgets>
- <tabstops>
- <tabstop>searchEdit</tabstop>
- <tabstop>searchButton</tabstop>
- <tabstop>packView</tabstop>
- </tabstops>
<resources/>
<connections/>
</ui>
diff --git a/launcher/ui/widgets/CustomCommands.ui b/launcher/ui/widgets/CustomCommands.ui
index dbd54431..650a9cc1 100644
--- a/launcher/ui/widgets/CustomCommands.ui
+++ b/launcher/ui/widgets/CustomCommands.ui
@@ -74,7 +74,7 @@
<item>
<widget class="QLabel" name="labelCustomCmdsDescription">
<property name="text">
- <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Pre-launch command runs before the instance launches and post-exit command runs after it exits.&lt;/p&gt;&lt;p&gt;Both will be run in the launcher's working folder with extra environment variables:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;$INST_NAME - Name of the instance&lt;/li&gt;&lt;li&gt;$INST_ID - ID of the instance (its folder name)&lt;/li&gt;&lt;li&gt;$INST_DIR - absolute path of the instance&lt;/li&gt;&lt;li&gt;$INST_MC_DIR - absolute path of Minecraft&lt;/li&gt;&lt;li&gt;$INST_JAVA - Java binary used for launch&lt;/li&gt;&lt;li&gt;$INST_JAVA_ARGS - command-line parameters used for launch&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Wrapper command allows launching using an extra wrapper program (like 'optirun' on Linux)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Pre-launch command runs before the instance launches and post-exit command runs after it exits.&lt;/p&gt;&lt;p&gt;Both will be run in the launcher's working folder with extra environment variables:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;$INST_NAME - Name of the instance&lt;/li&gt;&lt;li&gt;$INST_ID - ID of the instance (its folder name)&lt;/li&gt;&lt;li&gt;$INST_DIR - absolute path of the instance&lt;/li&gt;&lt;li&gt;$INST_MC_DIR - absolute path of Minecraft&lt;/li&gt;&lt;li&gt;$INST_JAVA - Java binary used for launch&lt;/li&gt;&lt;li&gt;$INST_JAVA_ARGS - command-line parameters used for launch (warning: will not work correctly if arguments contain spaces)&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Wrapper command allows launching using an extra wrapper program (like 'optirun' on Linux)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
diff --git a/packages/nix/polymc/default.nix b/packages/nix/polymc/default.nix
index 63fc6b7e..e352209a 100644
--- a/packages/nix/polymc/default.nix
+++ b/packages/nix/polymc/default.nix
@@ -14,10 +14,11 @@
, libGL
, msaClientID ? ""
-# flake
+ # flake
, self
-, submoduleNbt
-, submoduleQuazip
+, version
+, libnbtplusplus
+, quazip
}:
let
@@ -30,7 +31,7 @@ let
libXxf86vm
libpulseaudio
libGL
- ];
+ ];
# This variable will be passed to Minecraft by PolyMC
gameLibraryPath = libpath + ":/run/opengl-driver/lib";
@@ -38,12 +39,12 @@ in
mkDerivation rec {
pname = "polymc";
- version = "nightly";
+ inherit version;
src = lib.cleanSource self;
nativeBuildInputs = [ cmake ninja file makeWrapper ];
- buildInputs = [ qtbase jdk8 zlib ];
+ buildInputs = [ qtbase jdk zlib ];
dontWrapQtApps = true;
@@ -57,8 +58,8 @@ mkDerivation rec {
# Copy submodules inputs
rm -rf source/libraries/{libnbtplusplus,quazip}
mkdir source/libraries/{libnbtplusplus,quazip}
- cp -a ${submoduleNbt}/* source/libraries/libnbtplusplus
- cp -a ${submoduleQuazip}/* source/libraries/quazip
+ cp -a ${libnbtplusplus}/* source/libraries/libnbtplusplus
+ cp -a ${quazip}/* source/libraries/quazip
chmod a+r+w source/libraries/{libnbtplusplus,quazip}/*
'';
diff --git a/program_info/CMakeLists.txt b/program_info/CMakeLists.txt
index f9d7621d..9c243826 100644
--- a/program_info/CMakeLists.txt
+++ b/program_info/CMakeLists.txt
@@ -11,6 +11,7 @@ set(Launcher_DesktopFileName "org.polymc.PolyMC.desktop" PARENT_SCOPE)
set(Launcher_Desktop "program_info/org.polymc.PolyMC.desktop" PARENT_SCOPE)
set(Launcher_MetaInfo "program_info/org.polymc.PolyMC.metainfo.xml" PARENT_SCOPE)
+set(Launcher_ManPage "program_info/polymc.6.txt" PARENT_SCOPE)
set(Launcher_SVG "program_info/org.polymc.PolyMC.svg" PARENT_SCOPE)
set(Launcher_Branding_ICNS "program_info/polymc.icns" PARENT_SCOPE)
set(Launcher_Branding_WindowsRC "program_info/polymc.rc" PARENT_SCOPE)
diff --git a/program_info/LICENSE b/program_info/LICENSE
index 40cc6059..c68207dc 100644
--- a/program_info/LICENSE
+++ b/program_info/LICENSE
@@ -1,4 +1,4 @@
-Attribution-NonCommercial-ShareAlike 4.0 International
+Attribution-ShareAlike 4.0 International
This license only applies to the logos and branding in this folder.
@@ -56,18 +56,18 @@ exhaustive, and do not form part of our licenses.
=======================================================================
-Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
-Public License
+Creative Commons Attribution-ShareAlike 4.0 International Public
+License
By exercising the Licensed Rights (defined below), You accept and agree
to be bound by the terms and conditions of this Creative Commons
-Attribution-NonCommercial-ShareAlike 4.0 International Public License
-("Public License"). To the extent this Public License may be
-interpreted as a contract, You are granted the Licensed Rights in
-consideration of Your acceptance of these terms and conditions, and the
-Licensor grants You such rights in consideration of benefits the
-Licensor receives from making the Licensed Material available under
-these terms and conditions.
+Attribution-ShareAlike 4.0 International Public License ("Public
+License"). To the extent this Public License may be interpreted as a
+contract, You are granted the Licensed Rights in consideration of Your
+acceptance of these terms and conditions, and the Licensor grants You
+such rights in consideration of benefits the Licensor receives from
+making the Licensed Material available under these terms and
+conditions.
Section 1 -- Definitions.
@@ -86,7 +86,7 @@ Section 1 -- Definitions.
and Similar Rights in Your contributions to Adapted Material in
accordance with the terms and conditions of this Public License.
- c. BY-NC-SA Compatible License means a license listed at
+ c. BY-SA Compatible License means a license listed at
creativecommons.org/compatiblelicenses, approved by Creative
Commons as essentially the equivalent of this Public License.
@@ -110,7 +110,7 @@ Section 1 -- Definitions.
g. License Elements means the license attributes listed in the name
of a Creative Commons Public License. The License Elements of this
- Public License are Attribution, NonCommercial, and ShareAlike.
+ Public License are Attribution and ShareAlike.
h. Licensed Material means the artistic or literary work, database,
or other material to which the Licensor applied this Public
@@ -124,15 +124,7 @@ Section 1 -- Definitions.
j. Licensor means the individual(s) or entity(ies) granting rights
under this Public License.
- k. NonCommercial means not primarily intended for or directed towards
- commercial advantage or monetary compensation. For purposes of
- this Public License, the exchange of the Licensed Material for
- other material subject to Copyright and Similar Rights by digital
- file-sharing or similar means is NonCommercial provided there is
- no payment of monetary compensation in connection with the
- exchange.
-
- l. Share means to provide material to the public by any means or
+ k. Share means to provide material to the public by any means or
process that requires permission under the Licensed Rights, such
as reproduction, public display, public performance, distribution,
dissemination, communication, or importation, and to make material
@@ -140,13 +132,13 @@ Section 1 -- Definitions.
public may access the material from a place and at a time
individually chosen by them.
- m. Sui Generis Database Rights means rights other than copyright
+ l. Sui Generis Database Rights means rights other than copyright
resulting from Directive 96/9/EC of the European Parliament and of
the Council of 11 March 1996 on the legal protection of databases,
as amended and/or succeeded, as well as other essentially
equivalent rights anywhere in the world.
- n. You means the individual or entity exercising the Licensed Rights
+ m. You means the individual or entity exercising the Licensed Rights
under this Public License. Your has a corresponding meaning.
@@ -160,10 +152,9 @@ Section 2 -- Scope.
exercise the Licensed Rights in the Licensed Material to:
a. reproduce and Share the Licensed Material, in whole or
- in part, for NonCommercial purposes only; and
+ in part; and
- b. produce, reproduce, and Share Adapted Material for
- NonCommercial purposes only.
+ b. produce, reproduce, and Share Adapted Material.
2. Exceptions and Limitations. For the avoidance of doubt, where
Exceptions and Limitations apply to Your use, this Public
@@ -231,9 +222,7 @@ Section 2 -- Scope.
Rights, whether directly or through a collecting society
under any voluntary or waivable statutory or compulsory
licensing scheme. In all other cases the Licensor expressly
- reserves any right to collect such royalties, including when
- the Licensed Material is used other than for NonCommercial
- purposes.
+ reserves any right to collect such royalties.
Section 3 -- License Conditions.
@@ -278,6 +267,7 @@ following conditions.
reasonable to satisfy the conditions by providing a URI or
hyperlink to a resource that includes the required
information.
+
3. If requested by the Licensor, You must remove any of the
information required by Section 3(a)(1)(A) to the extent
reasonably practicable.
@@ -289,7 +279,7 @@ following conditions.
1. The Adapter's License You apply must be a Creative Commons
license with the same License Elements, this version or
- later, or a BY-NC-SA Compatible License.
+ later, or a BY-SA Compatible License.
2. You must include the text of, or the URI or hyperlink to, the
Adapter's License You apply. You may satisfy this condition
@@ -309,15 +299,14 @@ apply to Your use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
to extract, reuse, reproduce, and Share all or a substantial
- portion of the contents of the database for NonCommercial purposes
- only;
+ portion of the contents of the database;
b. if You include all or a substantial portion of the database
contents in a database in which You have Sui Generis Database
Rights, then the database in which You have Sui Generis Database
Rights (but not its individual contents) is Adapted Material,
- including for purposes of Section 3(b); and
+ including for purposes of Section 3(b); and
c. You must comply with the conditions in Section 3(a) if You Share
all or a substantial portion of the contents of the database.
@@ -417,6 +406,7 @@ Section 8 -- Interpretation.
that apply to the Licensor or You, including from the legal
processes of any jurisdiction or authority.
+
=======================================================================
Creative Commons is not a party to its public
@@ -437,3 +427,4 @@ the avoidance of doubt, this paragraph does not form part of the
public licenses.
Creative Commons may be contacted at creativecommons.org.
+
diff --git a/doc/polymc.1.txt b/program_info/polymc.6.txt
index 9ba34662..8f126cce 100644
--- a/doc/polymc.1.txt
+++ b/program_info/polymc.6.txt
@@ -59,8 +59,6 @@ Main website: <https://polymc.org>
AUTHORS
-------
-peterix <peterix@gmail.com>
-
-swurl <swurl@swurl.xyz>
+PolyMC Contributors
// vim: syntax=asciidoc