diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml
new file mode 100644
index 00000000..70acfdfd
--- /dev/null
+++ b/.github/codeql/codeql-config.yml
@@ -0,0 +1,3 @@
+query-filters:
+ - exclude:
+ id: cpp/fixme-comment
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 286d9de2..cc0d5311 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -39,12 +39,21 @@ jobs:
qt_ver: 6
- os: macos-12
+ name: macOS
macosx_deployment_target: 10.15
qt_ver: 6
qt_host: mac
qt_version: '6.3.0'
qt_modules: 'qt5compat qtimageformats'
+ - os: macos-12
+ name: macOS-Legacy
+ macosx_deployment_target: 10.13
+ qt_ver: 5
+ qt_host: mac
+ qt_version: '5.15.2'
+ qt_modules: ''
+
runs-on: ${{ matrix.os }}
env:
@@ -64,6 +73,14 @@ jobs:
with:
submodules: 'true'
+ - name: Initialize CodeQL
+ if: runner.os == 'Linux' && matrix.qt_ver == 6
+ uses: github/codeql-action/init@v2
+ with:
+ config-file: ./.github/codeql/codeql-config.yml
+ queries: security-and-quality
+ languages: cpp, java
+
- name: 'Setup MSYS2'
if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2
@@ -140,7 +157,7 @@ jobs:
sudo apt-get -y install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libqt5core5a libqt5network5 libqt5gui5
- name: Install Qt (macOS and AppImage)
- if: matrix.qt_ver == 6 && runner.os != 'Windows'
+ if: runner.os == 'Linux' && matrix.qt_ver == 6 || runner.os == 'macOS'
uses: jurplel/install-qt-action@v3
with:
version: ${{ matrix.qt_version }}
@@ -164,9 +181,14 @@ jobs:
##
- name: Configure CMake (macOS)
- if: runner.os == 'macOS'
+ if: runner.os == 'macOS' && matrix.qt_ver == 6
run: |
- cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -DLauncher_BUILD_PLATFORM=macOS -DCMAKE_C_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -DCMAKE_CXX_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -DLauncher_QT_VERSION_MAJOR=${{ matrix.qt_ver }} -G Ninja
+ cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_BUILD_PLATFORM=${{ matrix.name }} -DCMAKE_C_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -DCMAKE_CXX_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -DLauncher_QT_VERSION_MAJOR=${{ matrix.qt_ver }} -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -G Ninja
+
+ - name: Configure CMake (macOS-Legacy)
+ if: runner.os == 'macOS' && matrix.qt_ver == 5
+ run: |
+ cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_BUILD_PLATFORM=${{ matrix.name }} -DCMAKE_C_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -DCMAKE_CXX_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -DLauncher_QT_VERSION_MAJOR=${{ matrix.qt_ver }} -DMACOSX_SPARKLE_UPDATE_PUBLIC_KEY="" -DMACOSX_SPARKLE_UPDATE_FEED_URL="" -G Ninja
- name: Configure CMake (Windows)
if: runner.os == 'Windows'
@@ -209,6 +231,14 @@ jobs:
run: |
ctest --test-dir build --output-on-failure
+ ##
+ # CODE SCAN
+ ##
+
+ - name: Perform CodeQL Analysis
+ if: runner.os == 'Linux' && matrix.qt_ver == 6
+ uses: github/codeql-action/analyze@v2
+
##
# PACKAGE BUILDS
##
@@ -224,7 +254,7 @@ jobs:
tar -czf ../PollyMC.tar.gz *
- name: Make Sparkle signature (macOS)
- if: runner.os == 'macOS'
+ if: matrix.name == 'macOS'
run: |
if [ '${{ secrets.SPARKLE_ED25519_KEY }}' != '' ]; then
brew install openssl@3
@@ -323,7 +353,7 @@ jobs:
if: runner.os == 'macOS'
uses: actions/upload-artifact@v3
with:
- name: PollyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}
+ name: PollyMC-${{ matrix.name }}-${{ env.VERSION }}-${{ inputs.build_type }}
path: PollyMC.tar.gz
- name: Upload binary zip (Windows)
diff --git a/.github/workflows/trigger_release.yml b/.github/workflows/trigger_release.yml
index af5c2137..38b3bbba 100644
--- a/.github/workflows/trigger_release.yml
+++ b/.github/workflows/trigger_release.yml
@@ -40,6 +40,7 @@ jobs:
mv PollyMC-Linux-Portable*/PollyMC-portable.tar.gz PollyMC-Linux-Portable-${{ env.VERSION }}.tar.gz
mv PollyMC-Linux*/PollyMC.tar.gz PollyMC-Linux-${{ env.VERSION }}.tar.gz
mv PollyMC-*.AppImage/PollyMC-*.AppImage PollyMC-Linux-${{ env.VERSION }}-x86_64.AppImage
+ mv PollyMC-macOS-Legacy*/PollyMC.tar.gz PollyMC-macOS-Legacy-${{ env.VERSION }}.tar.gz
mv PollyMC-macOS*/PollyMC.tar.gz PollyMC-macOS-${{ env.VERSION }}.tar.gz
tar -czf PollyMC-${{ env.VERSION }}.tar.gz PollyMC-${{ env.VERSION }}
@@ -80,4 +81,5 @@ jobs:
PollyMC-Windows-Portable-${{ env.VERSION }}.zip
PollyMC-Windows-Setup-${{ env.VERSION }}.exe
PollyMC-macOS-${{ env.VERSION }}.tar.gz
+ PollyMC-macOS-Legacy-${{ env.VERSION }}.tar.gz
PollyMC-${{ env.VERSION }}.tar.gz
diff --git a/.github/workflows/winget.yml b/.github/workflows/winget.yml
index 98981e80..5c34040f 100644
--- a/.github/workflows/winget.yml
+++ b/.github/workflows/winget.yml
@@ -7,8 +7,9 @@ jobs:
publish:
runs-on: windows-latest
steps:
- - uses: vedantmgoyal2009/winget-releaser@latest
+ - uses: vedantmgoyal2009/winget-releaser@v1
with:
- identifier: PolyMC.PolyMC
- installers-regex: 'PolyMC-Windows-Setup-.+\.exe$'
+ identifier: PrismLauncher.PrismLauncher
+ version: ${{ github.event.release.tag_name }}
+ installers-regex: 'PrismLauncher-Windows-Setup-.+\.exe$'
token: ${{ secrets.WINGET_TOKEN }}
diff --git a/.gitmodules b/.gitmodules
index 08b94c96..8d034354 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,8 +1,12 @@
-[submodule "depends/libnbtplusplus"]
- path = libraries/libnbtplusplus
- url = https://github.com/PolyMC/libnbtplusplus.git
- pushurl = git@github.com:PolyMC/libnbtplusplus.git
-
[submodule "libraries/quazip"]
path = libraries/quazip
url = https://github.com/stachenov/quazip.git
+[submodule "libraries/tomlplusplus"]
+ path = libraries/tomlplusplus
+ url = https://github.com/marzer/tomlplusplus.git
+[submodule "libraries/filesystem"]
+ path = libraries/filesystem
+ url = https://github.com/gulrak/filesystem
+[submodule "libraries/libnbtplusplus"]
+ path = libraries/libnbtplusplus
+ url = https://github.com/PrismLauncher/libnbtplusplus.git
diff --git a/BUILD.md b/BUILD.md
index 8a76b68b..2443ac56 100644
--- a/BUILD.md
+++ b/BUILD.md
@@ -1,5 +1,53 @@
# Build Instructions
-Build instructions are available on [the website](https://polymc.org/wiki/development/build-instructions/).
+Full build instructions will be available on [the website](https://prismlauncher.org/wiki/development/build-instructions/).
+
+If you would like to contribute or fix an issue with the Build instructions you will be able to do so [here](https://github.com/PrismLauncher/website/blob/master/src/wiki/development/build-instructions.md).
+
+## Getting the source
+
+Clone the source code using git, and grab all the submodules. This is generic for all platforms you want to build on.
+```
+git clone --recursive https://github.com/PrismLauncher/PrismLauncher
+cd PrismLauncher
+```
+
+## Linux
+
+This guide will mostly mention dependant packages by their Debian naming and commands are done by a user in the sudoers file.
+### Dependencies
+
+- A C++ compiler capable of building C++17 code (can be found in the package `build-essential`).
+- Qt Development tools 5.12 or newer (on Debian 11 or Debian-based distributions, `qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libqt5core5a libqt5network5 libqt5gui5`).
+- `cmake` 3.15 or newer.
+- `extra-cmake-modules`.
+- zlib (`zlib1g-dev` on Debian 11 or Debian-based distributions).
+- Java Development Kit (Java JDK) (`openjdk-17-jdk` on Debian 11 or Debian-based distributions).
+- Mesa GL headers (`libgl1-mesa-dev` on Debian 11 or Debian-based distributions).
+- (Optional) `scdoc` to generate man pages.
+
+In conclusion, to check if all you need is installed (including optional):
+
+```
+sudo apt install build-essential qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libqt5core5a libqt5network5 libqt5gui5 cmake extra-cmake-modules zlib1g-dev openjdk-17-jdk libgl1-mesa-dev scdoc
+```
+
+### Compiling
+#### Building and installing on the system
+This is usually the suggested way to build the client.
+
+```
+cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="/usr" -DENABLE_LTO=ON
+cmake --build build -j$(nproc)
+sudo cmake --install build
+```
+
+#### Building a portable binary
+
+```
+cmake -S . -B build -DCMAKE_INSTALL_PREFIX=install
+cmake --build build -j$(nproc)
+cmake --install build
+cmake --install build --component portable
+```
-If you would like to contribute or fix an issue with the Build instructions you can do so [here](https://github.com/PolyMC/polymc.github.io/blob/master/src/wiki/development/build-instructions.md).
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e9f838a9..9679a00c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,9 +33,6 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 11)
include(GenerateExportHeader)
set(CMAKE_CXX_FLAGS "-Wall -pedantic -fstack-protector-strong --param=ssp-buffer-size=4 ${CMAKE_CXX_FLAGS}")
-if(UNIX AND APPLE)
- set(CMAKE_CXX_FLAGS "-stdlib=libc++ ${CMAKE_CXX_FLAGS}")
-endif()
# Fix build with Qt 5.13
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_NO_DEPRECATED_WARNINGS=Y")
@@ -74,9 +71,9 @@ endif()
##################################### Set Application options #####################################
######## Set URLs ########
-set(Launcher_NEWS_RSS_URL "https://polymc.org/feed/feed.xml" CACHE STRING "URL to fetch PolyMC's news RSS feed from.")
-set(Launcher_NEWS_OPEN_URL "https://polymc.org/news" CACHE STRING "URL that gets opened when the user clicks 'More News'")
-set(Launcher_HELP_URL "https://polymc.org/wiki/help-pages/%1" CACHE STRING "URL (with arg %1 to be substituted with page-id) that gets opened when the user requests help")
+set(Launcher_NEWS_RSS_URL "https://prismlauncher.org/feed/feed.xml" CACHE STRING "URL to fetch PrismLauncher's news RSS feed from.")
+set(Launcher_NEWS_OPEN_URL "https://prismlauncher.org/news" CACHE STRING "URL that gets opened when the user clicks 'More News'")
+set(Launcher_HELP_URL "https://prismlauncher.org/wiki/help-pages/%1" CACHE STRING "URL (with arg %1 to be substituted with page-id) that gets opened when the user requests help")
######## Set version numbers ########
set(Launcher_VERSION_MAJOR 5)
@@ -93,7 +90,7 @@ set(Launcher_BUILD_PLATFORM "" CACHE STRING "A short string identifying the plat
set(Launcher_UPDATER_BASE "" CACHE STRING "Base URL for the updater.")
# The metadata server
-set(Launcher_META_URL "https://meta.polymc.org/v1/" CACHE STRING "URL to fetch Launcher's meta files from.")
+set(Launcher_META_URL "https://meta.prismlauncher.org/v1/" CACHE STRING "URL to fetch Launcher's meta files from.")
# Imgur API Client ID
set(Launcher_IMGUR_CLIENT_ID "5b97b0713fba4a3" CACHE STRING "Client ID you can get from Imgur when you register an application")
@@ -102,7 +99,7 @@ set(Launcher_IMGUR_CLIENT_ID "5b97b0713fba4a3" CACHE STRING "Client ID you can g
set(Launcher_BUG_TRACKER_URL "https://github.com/fn2006/PollyMC/issues" CACHE STRING "URL for the bug tracker.")
# Translations Platform URL
-set(Launcher_TRANSLATIONS_URL "https://hosted.weblate.org/projects/polymc/polymc/" CACHE STRING "URL for the translations platform.")
+set(Launcher_TRANSLATIONS_URL "https://hosted.weblate.org/projects/prismlauncher/launcher/" CACHE STRING "URL for the translations platform.")
# Matrix Space
set(Launcher_MATRIX_URL "" CACHE STRING "URL to the Matrix Space")
@@ -192,6 +189,14 @@ if (Qt5_POSITION_INDEPENDENT_CODE)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
+if(NOT Launcher_FORCE_BUNDLED_LIBS)
+ # Find toml++
+ find_package(tomlplusplus 3.2.0 QUIET)
+
+ # Find ghc_filesystem
+ find_package(ghc_filesystem QUIET)
+endif()
+
####################################### Program Info #######################################
set(Launcher_APP_BINARY_NAME "pollymc" CACHE STRING "Name of the Launcher binary")
@@ -218,14 +223,14 @@ if(UNIX AND APPLE)
# Mac bundle settings
set(MACOSX_BUNDLE_BUNDLE_NAME "${Launcher_Name}")
set(MACOSX_BUNDLE_INFO_STRING "${Launcher_Name}: A custom launcher for Minecraft that allows you to easily manage multiple installations of Minecraft at once.")
- set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.polymc.${Launcher_Name}")
+ set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.prismlauncher.${Launcher_Name}")
set(MACOSX_BUNDLE_BUNDLE_VERSION "${Launcher_VERSION_NAME}")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${Launcher_VERSION_NAME}")
set(MACOSX_BUNDLE_LONG_VERSION_STRING "${Launcher_VERSION_NAME}")
set(MACOSX_BUNDLE_ICON_FILE ${Launcher_Name}.icns)
set(MACOSX_BUNDLE_COPYRIGHT "Copyright 2021-2022 ${Launcher_Copyright}")
- set(MACOSX_SPARKLE_UPDATE_PUBLIC_KEY "idALcUIazingvKSSsEa9U7coDVxZVx/ORpOEE/QtJfg=")
- set(MACOSX_SPARKLE_UPDATE_FEED_URL "https://polymc.org/feed/appcast.xml")
+ set(MACOSX_SPARKLE_UPDATE_PUBLIC_KEY "v55ZWWD6QlPoXGV6VLzOTZxZUggWeE51X8cRQyQh6vA=")
+ set(MACOSX_SPARKLE_UPDATE_FEED_URL "https://prismlauncher.org/feed/appcast.xml")
set(MACOSX_SPARKLE_DOWNLOAD_URL "https://github.com/sparkle-project/Sparkle/releases/download/2.1.0/Sparkle-2.1.0.tar.xz" CACHE STRING "URL to Sparkle release archive")
set(MACOSX_SPARKLE_SHA256 "bf6ac1caa9f8d321d5784859c88da874f28412f37fb327bc21b7b14c5d61ef94" CACHE STRING "SHA256 checksum for Sparkle release archive")
@@ -300,7 +305,6 @@ add_subdirectory(libraries/systeminfo) # system information library
add_subdirectory(libraries/hoedown) # markdown parser
add_subdirectory(libraries/launcher) # java based launcher part for Minecraft
add_subdirectory(libraries/javacheck) # java compatibility checker
-add_subdirectory(libraries/xz-embedded) # xz compression
if (FORCE_BUNDLED_QUAZIP)
message(STATUS "Using bundled QuaZip")
set(BUILD_SHARED_LIBS 0) # link statically to avoid conflicts.
@@ -311,11 +315,23 @@ else()
endif()
add_subdirectory(libraries/rainbow) # Qt extension for colors
add_subdirectory(libraries/LocalPeer) # fork of a library from Qt solutions
-add_subdirectory(libraries/classparser) # class parser library
-add_subdirectory(libraries/tomlc99) # toml parser
+if(NOT tomlplusplus_FOUND)
+ message(STATUS "Using bundled tomlplusplus")
+ add_subdirectory(libraries/tomlplusplus) # toml parser
+else()
+ message(STATUS "Using system tomlplusplus")
+endif()
add_subdirectory(libraries/katabasis) # An OAuth2 library that tried to do too much
add_subdirectory(libraries/gamemode)
add_subdirectory(libraries/murmur2) # Hash for usage with the CurseForge API
+if (NOT ghc_filesystem_FOUND)
+ message(STATUS "Using bundled ghc_filesystem")
+ set(GHC_FILESYSTEM_WITH_INSTALL OFF) # Workaround ghc::filesystem bug
+ add_subdirectory(libraries/filesystem) # Implementation of std::filesystem for old C++, for usage in old macOS
+ add_library(ghcFilesystem::ghc_filesystem ALIAS ghc_filesystem)
+else()
+ message(STATUS "Using system ghc_filesystem")
+endif()
############################### Built Artifacts ###############################
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
index 7bbd01da..defa2170 100644
--- a/CODE_OF_CONDUCT.md
+++ b/CODE_OF_CONDUCT.md
@@ -63,7 +63,7 @@ representative at an online or offline event.
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement via email at
-[polymc-enforcement@scrumplex.net](mailto:polymc-enforcement@scrumplex.net) (Email
+[coc@scrumplex.net](mailto:coc@scrumplex.net) (Email
address subject to change).
All complaints will be reviewed and investigated promptly and fairly.
diff --git a/COPYING.md b/COPYING.md
index c94c51c3..3e35c579 100644
--- a/COPYING.md
+++ b/COPYING.md
@@ -1,3 +1,37 @@
+## Prism Launcher
+
+ Prism Launcher - Minecraft Launcher
+ Copyright (C) 2022 Prism Launcher Contributors
+
+ 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 .
+
+ 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.
+
## PolyMC
PolyMC - Minecraft Launcher
@@ -191,52 +225,6 @@
See COPYING file for the full LGPL text.
-## xz-minidec
-
- XZ decompressor
-
- Authors: Lasse Collin
- Igor Pavlov
-
- This file has been put into the public domain.
- You can do whatever you want with this file.
-
-## ColumnResizer
-
- Copyright (c) 2011-2016 Aurélien Gâteau and contributors.
-
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted (subject to the limitations in the
- disclaimer below) provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the
- distribution.
-
- * The name of the contributors may not be used to endorse or
- promote products derived from this software without specific prior
- written permission.
-
- NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
- GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
- HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
## launcher (`libraries/launcher`)
PolyMC - Minecraft Launcher
@@ -315,30 +303,24 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-## tomlc99
+## tomlplusplus
MIT License
- Copyright (c) 2017 CK Tan
- https://github.com/cktan/tomlc99
+ Copyright (c) Mark Gillard
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
+ documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in all
- copies or substantial portions of the Software.
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
+ Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- SOFTWARE.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
## O2 (Katabasis fork)
@@ -394,3 +376,25 @@
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
+
+## gulrak/filesystem
+
+ Copyright (c) 2018, Steffen Schümann
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
diff --git a/README.md b/README.md
index 5a6aa810..21ce2eb5 100644
--- a/README.md
+++ b/README.md
@@ -1,17 +1,14 @@
-# One of PolyMC's developers has gone rouge and kicked out all of the other developers
-### For the time being use I would use `https://meta.prismlauncher.org/v1/` as your metaserver
-### If you trust him then you can continue using the default metaserver but I take no responsibility for anything that happens while using it
-
-PollyMC is a **fork** of PolyMC and is not endorsed by or affiliated with the PolyMC project.
-If you have any problems open an issue here, do not bug the PolyMC maintainers.
+PollyMC is a **fork** of Prism Launcher that adds support for Ely.by accounts and allows you to play offline mode without an account
+PollyMC is not endorsed by or affiliated with the Prism Launcher project.
+If you have any problems open an issue here, do not bug the Prism Launcher maintainers.
Binaries can be found in releases.
Workaround for downloading from CurseForge and FTB not working [here](https://github.com/fn2006/PollyMC/wiki/CurseForge-Workaround).
-To build this yourself, follow the instructions on the PolyMC website but clone this repo instead.
+To build this yourself, follow the instructions on the Prism Launcher website but clone this repo instead.
diff --git a/buildconfig/BuildConfig.h b/buildconfig/BuildConfig.h
index de66cec4..ef384ed2 100644
--- a/buildconfig/BuildConfig.h
+++ b/buildconfig/BuildConfig.h
@@ -140,8 +140,8 @@ class Config {
QString LIBRARY_BASE = "https://libraries.minecraft.net/";
QString AUTH_BASE = "https://authserver.mojang.com/";
QString IMGUR_BASE_URL = "https://api.imgur.com/3/";
- QString FMLLIBS_BASE_URL = "https://files.polymc.org/fmllibs/";
- QString TRANSLATIONS_BASE_URL = "https://i18n.polymc.org/";
+ QString FMLLIBS_BASE_URL = "https://files.prismlauncher.org/fmllibs/"; // FIXME: move into CMakeLists
+ QString TRANSLATIONS_BASE_URL = "https://i18n.prismlauncher.org/"; // FIXME: move into CMakeLists
QString MODPACKSCH_API_BASE_URL = "https://api.modpacks.ch/";
diff --git a/flake.lock b/flake.lock
index bfc9ac6d..7c0bb2f8 100644
--- a/flake.lock
+++ b/flake.lock
@@ -21,24 +21,24 @@
"locked": {
"lastModified": 1650031308,
"narHash": "sha256-TvVOjkUobYJD9itQYueELJX3wmecvEdCbJ0FinW2mL4=",
- "owner": "PolyMC",
+ "owner": "PrismLauncher",
"repo": "libnbtplusplus",
"rev": "2203af7eeb48c45398139b583615134efd8d407f",
"type": "github"
},
"original": {
- "owner": "PolyMC",
+ "owner": "PrismLauncher",
"repo": "libnbtplusplus",
"type": "github"
}
},
"nixpkgs": {
"locked": {
- "lastModified": 1658119717,
- "narHash": "sha256-4upOZIQQ7Bc4CprqnHsKnqYfw+arJeAuU+QcpjYBXW0=",
+ "lastModified": 1666057921,
+ "narHash": "sha256-VpQqtXdj6G7cH//SvoprjR7XT3KS7p+tCVebGK1N6tE=",
"owner": "nixos",
"repo": "nixpkgs",
- "rev": "9eb60f25aff0d2218c848dd4574a0ab5e296cabe",
+ "rev": "88eab1e431cabd0ed621428d8b40d425a07af39f",
"type": "github"
},
"original": {
@@ -52,7 +52,24 @@
"inputs": {
"flake-compat": "flake-compat",
"libnbtplusplus": "libnbtplusplus",
- "nixpkgs": "nixpkgs"
+ "nixpkgs": "nixpkgs",
+ "tomlplusplus": "tomlplusplus"
+ }
+ },
+ "tomlplusplus": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1666091090,
+ "narHash": "sha256-djpMCFPvkJcfynV8WnsYdtwLq+J7jpV1iM4C6TojiyM=",
+ "owner": "marzer",
+ "repo": "tomlplusplus",
+ "rev": "1e4a3833d013aee08f58c5b31c69f709afc69f73",
+ "type": "github"
+ },
+ "original": {
+ "owner": "marzer",
+ "repo": "tomlplusplus",
+ "type": "github"
}
}
},
diff --git a/flake.nix b/flake.nix
index 51bc1fda..d4a25338 100644
--- a/flake.nix
+++ b/flake.nix
@@ -4,10 +4,11 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
- libnbtplusplus = { url = "github:PolyMC/libnbtplusplus"; flake = false; };
+ libnbtplusplus = { url = "github:PrismLauncher/libnbtplusplus"; flake = false; };
+ tomlplusplus = { url = "github:marzer/tomlplusplus"; flake = false; };
};
- outputs = { self, nixpkgs, libnbtplusplus, ... }:
+ outputs = { self, nixpkgs, libnbtplusplus, tomlplusplus, ... }:
let
# User-friendly version number.
version = builtins.substring 0 8 self.lastModifiedDate;
@@ -22,14 +23,14 @@
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
packagesFn = pkgs: rec {
- polymc = pkgs.libsForQt5.callPackage ./nix { inherit version self libnbtplusplus; };
- polymc-qt6 = pkgs.qt6Packages.callPackage ./nix { inherit version self libnbtplusplus; };
+ prismlauncher = pkgs.libsForQt5.callPackage ./nix { inherit version self libnbtplusplus tomlplusplus; };
+ prismlauncher-qt6 = pkgs.qt6Packages.callPackage ./nix { inherit version self libnbtplusplus tomlplusplus; };
};
in
{
packages = forAllSystems (system:
let packages = packagesFn pkgs.${system}; in
- packages // { default = packages.polymc; }
+ packages // { default = packages.prismlauncher; }
);
overlay = final: packagesFn;
diff --git a/launcher/Application.cpp b/launcher/Application.cpp
index 6e177f14..a9274260 100644
--- a/launcher/Application.cpp
+++ b/launcher/Application.cpp
@@ -78,6 +78,7 @@
#include
#include
+#include
#include
#include
#include
@@ -110,7 +111,6 @@
#include "translations/TranslationsModel.h"
#include "meta/Index.h"
-#include
#include
#include
#include
@@ -136,12 +136,6 @@
static const QLatin1String liveCheckFile("live.check");
-using namespace Commandline;
-
-#define MACOS_HINT "If you are on macOS Sierra, you might have to move the app to your /Applications or ~/Applications folder. "\
- "This usually fixes the problem and you can move the application elsewhere afterwards.\n"\
- "\n"
-
namespace {
void appDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
@@ -242,80 +236,27 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
this->setQuitOnLastWindowClosed(false);
// Commandline parsing
- QHash args;
- {
- Parser parser(FlagStyle::GNU, ArgumentStyle::SpaceAndEquals);
+ QCommandLineParser parser;
+ parser.setApplicationDescription(BuildConfig.LAUNCHER_DISPLAYNAME);
- // --help
- parser.addSwitch("help");
- parser.addShortOpt("help", 'h');
- parser.addDocumentation("help", "Display this help and exit.");
- // --version
- parser.addSwitch("version");
- parser.addShortOpt("version", 'V');
- parser.addDocumentation("version", "Display program version and exit.");
- // --dir
- parser.addOption("dir");
- parser.addShortOpt("dir", 'd');
- parser.addDocumentation("dir", "Use the supplied folder as application root instead of the binary location (use '.' for current)");
- // --launch
- parser.addOption("launch");
- parser.addShortOpt("launch", 'l');
- parser.addDocumentation("launch", "Launch the specified instance (by instance ID)");
- // --server
- parser.addOption("server");
- parser.addShortOpt("server", 's');
- parser.addDocumentation("server", "Join the specified server on launch (only valid in combination with --launch)");
- // --profile
- parser.addOption("profile");
- parser.addShortOpt("profile", 'a');
- parser.addDocumentation("profile", "Use the account specified by its profile name (only valid in combination with --launch)");
- // --alive
- parser.addSwitch("alive");
- parser.addDocumentation("alive", "Write a small '" + liveCheckFile + "' file after the launcher starts");
- // --import
- parser.addOption("import");
- parser.addShortOpt("import", 'I');
- parser.addDocumentation("import", "Import instance from specified zip (local path or URL)");
+ parser.addOptions({
+ {{"d", "dir"}, "Use a custom path as application root (use '.' for current directory)", "directory"},
+ {{"l", "launch"}, "Launch the specified instance (by instance ID)", "instance"},
+ {{"s", "server"}, "Join the specified server on launch (only valid in combination with --launch)", "address"},
+ {{"a", "profile"}, "Use the account specified by its profile name (only valid in combination with --launch)", "profile"},
+ {"alive", "Write a small '" + liveCheckFile + "' file after the launcher starts"},
+ {{"I", "import"}, "Import instance from specified zip (local path or URL)", "file"}
+ });
+ parser.addHelpOption();
+ parser.addVersionOption();
- // parse the arguments
- try
- {
- args = parser.parse(arguments());
- }
- catch (const ParsingError &e)
- {
- std::cerr << "CommandLineError: " << e.what() << std::endl;
- if(argc > 0)
- std::cerr << "Try '" << argv[0] << " -h' to get help on command line parameters."
- << std::endl;
- m_status = Application::Failed;
- return;
- }
+ parser.process(arguments());
- // display help and exit
- if (args["help"].toBool())
- {
- std::cout << qPrintable(parser.compileHelp(arguments()[0]));
- m_status = Application::Succeeded;
- return;
- }
-
- // display version and exit
- if (args["version"].toBool())
- {
- std::cout << "Version " << BuildConfig.printableVersionString().toStdString() << std::endl;
- std::cout << "Git " << BuildConfig.GIT_COMMIT.toStdString() << std::endl;
- m_status = Application::Succeeded;
- return;
- }
- }
-
- m_instanceIdToLaunch = args["launch"].toString();
- m_serverToJoin = args["server"].toString();
- m_profileToUse = args["profile"].toString();
- m_liveCheck = args["alive"].toBool();
- m_zipToImport = args["import"].toUrl();
+ m_instanceIdToLaunch = parser.value("launch");
+ m_serverToJoin = parser.value("server");
+ m_profileToUse = parser.value("profile");
+ m_liveCheck = parser.isSet("alive");
+ m_zipToImport = parser.value("import");
// error if --launch is missing with --server or --profile
if((!m_serverToJoin.isEmpty() || !m_profileToUse.isEmpty()) && m_instanceIdToLaunch.isEmpty())
@@ -346,7 +287,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
QString adjustedBy;
QString dataPath;
// change folder
- QString dirParam = args["dir"].toString();
+ QString dirParam = parser.value("dir");
if (!dirParam.isEmpty())
{
// the dir param. it makes multimc data path point to whatever the user specified
@@ -360,6 +301,12 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
dataPath = foo.absolutePath();
adjustedBy = "Persistent data path";
+ QDir polymcData(FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation), "PolyMC"));
+ if (polymcData.exists()) {
+ dataPath = polymcData.absolutePath();
+ adjustedBy = "PolyMC data path";
+ }
+
#ifdef Q_OS_LINUX
// TODO: this should be removed in a future version
// TODO: provide a migration path similar to macOS migration
@@ -385,9 +332,6 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
QString(
"The launcher data folder could not be created.\n"
"\n"
-#if defined(Q_OS_MAC)
- MACOS_HINT
-#endif
"Make sure you have the right permissions to the launcher data folder and any folder needed to access it.\n"
"(%1)\n"
"\n"
@@ -403,9 +347,6 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
QString(
"The launcher data folder could not be opened.\n"
"\n"
-#if defined(Q_OS_MAC)
- MACOS_HINT
-#endif
"Make sure you have the right permissions to the launcher data folder.\n"
"(%1)\n"
"\n"
@@ -486,9 +427,6 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
QString(
"The launcher couldn't create a log file - the data folder is not writable.\n"
"\n"
- #if defined(Q_OS_MAC)
- MACOS_HINT
- #endif
"Make sure you have write permissions to the data folder.\n"
"(%1)\n"
"\n"
@@ -550,7 +488,8 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
// Initialize application settings
{
- m_settings.reset(new INISettingsObject(BuildConfig.LAUNCHER_CONFIGFILE, this));
+ // Provide a fallback for migration from PolyMC
+ m_settings.reset(new INISettingsObject({ BuildConfig.LAUNCHER_CONFIGFILE, "polymc.cfg", "multimc.cfg" }, this));
// Updates
// Multiple channels are separated by spaces
m_settings->registerSetting("UpdateChannel", BuildConfig.VERSION_CHANNEL);
@@ -877,6 +816,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
m_metacache->addBase("FlamePacks", QDir("cache/FlamePacks").absolutePath());
m_metacache->addBase("FlameMods", QDir("cache/FlameMods").absolutePath());
m_metacache->addBase("ModrinthPacks", QDir("cache/ModrinthPacks").absolutePath());
+ m_metacache->addBase("ModrinthModpacks", QDir("cache/ModrinthModpacks").absolutePath());
m_metacache->addBase("root", QDir::currentPath());
m_metacache->addBase("translations", QDir("translations").absolutePath());
m_metacache->addBase("icons", QDir("cache/icons").absolutePath());
@@ -928,12 +868,13 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
qDebug() << "<> Application theme set.";
}
+ updateCapabilities();
+
if(createSetupWizard())
{
return;
}
- updateCapabilities();
performMainStartupAction();
}
diff --git a/launcher/BaseInstance.cpp b/launcher/BaseInstance.cpp
index 2995df6f..8680361c 100644
--- a/launcher/BaseInstance.cpp
+++ b/launcher/BaseInstance.cpp
@@ -355,7 +355,7 @@ QString BaseInstance::name() const
QString BaseInstance::windowTitle() const
{
- return BuildConfig.LAUNCHER_NAME + ": " + name().replace(QRegularExpression("\\s+"), " ");
+ return BuildConfig.LAUNCHER_DISPLAYNAME + ": " + name().replace(QRegularExpression("\\s+"), " ");
}
// FIXME: why is this here? move it to MinecraftInstance!!!
@@ -368,3 +368,8 @@ shared_qobject_ptr BaseInstance::getLaunchTask()
{
return m_launchProcess;
}
+
+void BaseInstance::updateRuntimeContext()
+{
+ // NOOP
+}
diff --git a/launcher/BaseInstance.h b/launcher/BaseInstance.h
index 21cc3413..307240e0 100644
--- a/launcher/BaseInstance.h
+++ b/launcher/BaseInstance.h
@@ -54,6 +54,7 @@
#include "net/Mode.h"
#include "minecraft/launch/MinecraftServerTarget.h"
+#include "RuntimeContext.h"
class QDir;
class Task;
@@ -220,6 +221,12 @@ public:
virtual QString typeName() const = 0;
+ void updateRuntimeContext();
+ RuntimeContext runtimeContext() const
+ {
+ return m_runtimeContext;
+ }
+
bool hasVersionBroken() const
{
return m_hasBrokenVersion;
@@ -305,6 +312,7 @@ protected: /* data */
bool m_isRunning = false;
shared_qobject_ptr m_launchProcess;
QDateTime m_timeStarted;
+ RuntimeContext m_runtimeContext;
private: /* data */
Status m_status = Status::Present;
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt
index 6515edb3..eed41cec 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -26,6 +26,7 @@ set(CORE_SOURCES
MMCZip.cpp
MMCStrings.h
MMCStrings.cpp
+ RuntimeContext.h
# Basic instance manipulation tasks (derived from InstanceTask)
InstanceCreationTask.h
@@ -296,8 +297,6 @@ set(MINECRAFT_SOURCES
minecraft/Rule.h
minecraft/OneSixVersionFormat.cpp
minecraft/OneSixVersionFormat.h
- minecraft/OpSys.cpp
- minecraft/OpSys.h
minecraft/ParseUtils.cpp
minecraft/ParseUtils.h
minecraft/ProfileUtils.cpp
@@ -865,6 +864,10 @@ SET(LAUNCHER_SOURCES
ui/widgets/PageContainer.cpp
ui/widgets/PageContainer.h
ui/widgets/PageContainer_p.h
+ ui/widgets/ProjectDescriptionPage.h
+ ui/widgets/ProjectDescriptionPage.cpp
+ ui/widgets/VariableSizedImageObject.h
+ ui/widgets/VariableSizedImageObject.cpp
ui/widgets/ProjectItem.h
ui/widgets/ProjectItem.cpp
ui/widgets/VersionListView.cpp
@@ -980,14 +983,14 @@ add_library(Launcher_logic STATIC ${LOGIC_SOURCES} ${LAUNCHER_SOURCES} ${LAUNCHE
target_include_directories(Launcher_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(Launcher_logic
systeminfo
- Launcher_classparser
Launcher_murmur2
nbt++
${ZLIB_LIBRARIES}
- tomlc99
+ tomlplusplus::tomlplusplus
BuildConfig
Katabasis
Qt${QT_VERSION_MAJOR}::Widgets
+ ghcFilesystem::ghc_filesystem
)
if (UNIX AND NOT CYGWIN AND NOT APPLE)
diff --git a/launcher/Commandline.cpp b/launcher/Commandline.cpp
index 8e7356bb..6d97918d 100644
--- a/launcher/Commandline.cpp
+++ b/launcher/Commandline.cpp
@@ -92,412 +92,4 @@ QStringList splitArgs(QString args)
argv << current;
return argv;
}
-
-Parser::Parser(FlagStyle::Enum flagStyle, ArgumentStyle::Enum argStyle)
-{
- m_flagStyle = flagStyle;
- m_argStyle = argStyle;
-}
-
-// styles setter/getter
-void Parser::setArgumentStyle(ArgumentStyle::Enum style)
-{
- m_argStyle = style;
-}
-ArgumentStyle::Enum Parser::argumentStyle()
-{
- return m_argStyle;
-}
-
-void Parser::setFlagStyle(FlagStyle::Enum style)
-{
- m_flagStyle = style;
-}
-FlagStyle::Enum Parser::flagStyle()
-{
- return m_flagStyle;
-}
-
-// setup methods
-void Parser::addSwitch(QString name, bool def)
-{
- if (m_params.contains(name))
- throw "Name not unique";
-
- OptionDef *param = new OptionDef;
- param->type = otSwitch;
- param->name = name;
- param->metavar = QString("<%1>").arg(name);
- param->def = def;
-
- m_options[name] = param;
- m_params[name] = (CommonDef *)param;
- m_optionList.append(param);
-}
-
-void Parser::addOption(QString name, QVariant def)
-{
- if (m_params.contains(name))
- throw "Name not unique";
-
- OptionDef *param = new OptionDef;
- param->type = otOption;
- param->name = name;
- param->metavar = QString("<%1>").arg(name);
- param->def = def;
-
- m_options[name] = param;
- m_params[name] = (CommonDef *)param;
- m_optionList.append(param);
-}
-
-void Parser::addArgument(QString name, bool required, QVariant def)
-{
- if (m_params.contains(name))
- throw "Name not unique";
-
- PositionalDef *param = new PositionalDef;
- param->name = name;
- param->def = def;
- param->required = required;
- param->metavar = name;
-
- m_positionals.append(param);
- m_params[name] = (CommonDef *)param;
-}
-
-void Parser::addDocumentation(QString name, QString doc, QString metavar)
-{
- if (!m_params.contains(name))
- throw "Name does not exist";
-
- CommonDef *param = m_params[name];
- param->doc = doc;
- if (!metavar.isNull())
- param->metavar = metavar;
-}
-
-void Parser::addShortOpt(QString name, QChar flag)
-{
- if (!m_params.contains(name))
- throw "Name does not exist";
- if (!m_options.contains(name))
- throw "Name is not an Option or Swtich";
-
- OptionDef *param = m_options[name];
- m_flags[flag] = param;
- param->flag = flag;
-}
-
-// help methods
-QString Parser::compileHelp(QString progName, int helpIndent, bool useFlags)
-{
- QStringList help;
- help << compileUsage(progName, useFlags) << "\r\n";
-
- // positionals
- if (!m_positionals.isEmpty())
- {
- help << "\r\n";
- help << "Positional arguments:\r\n";
- QListIterator it2(m_positionals);
- while (it2.hasNext())
- {
- PositionalDef *param = it2.next();
- help << " " << param->metavar;
- help << " " << QString(helpIndent - param->metavar.length() - 1, ' ');
- help << param->doc << "\r\n";
- }
- }
-
- // Options
- if (!m_optionList.isEmpty())
- {
- help << "\r\n";
- QString optPrefix, flagPrefix;
- getPrefix(optPrefix, flagPrefix);
-
- help << "Options & Switches:\r\n";
- QListIterator it(m_optionList);
- while (it.hasNext())
- {
- OptionDef *option = it.next();
- help << " ";
- int nameLength = optPrefix.length() + option->name.length();
- if (!option->flag.isNull())
- {
- nameLength += 3 + flagPrefix.length();
- help << flagPrefix << option->flag << ", ";
- }
- help << optPrefix << option->name;
- if (option->type == otOption)
- {
- QString arg = QString("%1%2").arg(
- ((m_argStyle == ArgumentStyle::Equals) ? "=" : " "), option->metavar);
- nameLength += arg.length();
- help << arg;
- }
- help << " " << QString(helpIndent - nameLength - 1, ' ');
- help << option->doc << "\r\n";
- }
- }
-
- return help.join("");
-}
-
-QString Parser::compileUsage(QString progName, bool useFlags)
-{
- QStringList usage;
- usage << "Usage: " << progName;
-
- QString optPrefix, flagPrefix;
- getPrefix(optPrefix, flagPrefix);
-
- // options
- QListIterator it(m_optionList);
- while (it.hasNext())
- {
- OptionDef *option = it.next();
- usage << " [";
- if (!option->flag.isNull() && useFlags)
- usage << flagPrefix << option->flag;
- else
- usage << optPrefix << option->name;
- if (option->type == otOption)
- usage << ((m_argStyle == ArgumentStyle::Equals) ? "=" : " ") << option->metavar;
- usage << "]";
- }
-
- // arguments
- QListIterator it2(m_positionals);
- while (it2.hasNext())
- {
- PositionalDef *param = it2.next();
- usage << " " << (param->required ? "<" : "[");
- usage << param->metavar;
- usage << (param->required ? ">" : "]");
- }
-
- return usage.join("");
-}
-
-// parsing
-QHash Parser::parse(QStringList argv)
-{
- QHash map;
-
- QStringListIterator it(argv);
- QString programName = it.next();
-
- QString optionPrefix;
- QString flagPrefix;
- QListIterator positionals(m_positionals);
- QStringList expecting;
-
- getPrefix(optionPrefix, flagPrefix);
-
- while (it.hasNext())
- {
- QString arg = it.next();
-
- if (!expecting.isEmpty())
- // we were expecting an argument
- {
- QString name = expecting.first();
-/*
- if (map.contains(name))
- throw ParsingError(
- QString("Option %2%1 was given multiple times").arg(name, optionPrefix));
-*/
- map[name] = QVariant(arg);
-
- expecting.removeFirst();
- continue;
- }
-
- if (arg.startsWith(optionPrefix))
- // we have an option
- {
- // qDebug("Found option %s", qPrintable(arg));
-
- QString name = arg.mid(optionPrefix.length());
- QString equals;
-
- if ((m_argStyle == ArgumentStyle::Equals ||
- m_argStyle == ArgumentStyle::SpaceAndEquals) &&
- name.contains("="))
- {
- int i = name.indexOf("=");
- equals = name.mid(i + 1);
- name = name.left(i);
- }
-
- if (m_options.contains(name))
- {
- /*
- if (map.contains(name))
- throw ParsingError(QString("Option %2%1 was given multiple times")
- .arg(name, optionPrefix));
-*/
- OptionDef *option = m_options[name];
- if (option->type == otSwitch)
- map[name] = true;
- else // if (option->type == otOption)
- {
- if (m_argStyle == ArgumentStyle::Space)
- expecting.append(name);
- else if (!equals.isNull())
- map[name] = equals;
- else if (m_argStyle == ArgumentStyle::SpaceAndEquals)
- expecting.append(name);
- else
- throw ParsingError(QString("Option %2%1 reqires an argument.")
- .arg(name, optionPrefix));
- }
-
- continue;
- }
-
- throw ParsingError(QString("Unknown Option %2%1").arg(name, optionPrefix));
- }
-
- if (arg.startsWith(flagPrefix))
- // we have (a) flag(s)
- {
- // qDebug("Found flags %s", qPrintable(arg));
-
- QString flags = arg.mid(flagPrefix.length());
- QString equals;
-
- if ((m_argStyle == ArgumentStyle::Equals ||
- m_argStyle == ArgumentStyle::SpaceAndEquals) &&
- flags.contains("="))
- {
- int i = flags.indexOf("=");
- equals = flags.mid(i + 1);
- flags = flags.left(i);
- }
-
- for (int i = 0; i < flags.length(); i++)
- {
- QChar flag = flags.at(i);
-
- if (!m_flags.contains(flag))
- throw ParsingError(QString("Unknown flag %2%1").arg(flag, flagPrefix));
-
- OptionDef *option = m_flags[flag];
-/*
- if (map.contains(option->name))
- throw ParsingError(QString("Option %2%1 was given multiple times")
- .arg(option->name, optionPrefix));
-*/
- if (option->type == otSwitch)
- map[option->name] = true;
- else // if (option->type == otOption)
- {
- if (m_argStyle == ArgumentStyle::Space)
- expecting.append(option->name);
- else if (!equals.isNull())
- if (i == flags.length() - 1)
- map[option->name] = equals;
- else
- throw ParsingError(QString("Flag %4%2 of Argument-requiring Option "
- "%1 not last flag in %4%3")
- .arg(option->name, flag, flags, flagPrefix));
- else if (m_argStyle == ArgumentStyle::SpaceAndEquals)
- expecting.append(option->name);
- else
- throw ParsingError(QString("Option %1 reqires an argument. (flag %3%2)")
- .arg(option->name, flag, flagPrefix));
- }
- }
-
- continue;
- }
-
- // must be a positional argument
- if (!positionals.hasNext())
- throw ParsingError(QString("Don't know what to do with '%1'").arg(arg));
-
- PositionalDef *param = positionals.next();
-
- map[param->name] = arg;
- }
-
- // check if we're missing something
- if (!expecting.isEmpty())
- throw ParsingError(QString("Was still expecting arguments for %2%1").arg(
- expecting.join(QString(", ") + optionPrefix), optionPrefix));
-
- while (positionals.hasNext())
- {
- PositionalDef *param = positionals.next();
- if (param->required)
- throw ParsingError(
- QString("Missing required positional argument '%1'").arg(param->name));
- else
- map[param->name] = param->def;
- }
-
- // fill out gaps
- QListIterator iter(m_optionList);
- while (iter.hasNext())
- {
- OptionDef *option = iter.next();
- if (!map.contains(option->name))
- map[option->name] = option->def;
- }
-
- return map;
-}
-
-// clear defs
-void Parser::clear()
-{
- m_flags.clear();
- m_params.clear();
- m_options.clear();
-
- QMutableListIterator it(m_optionList);
- while (it.hasNext())
- {
- OptionDef *option = it.next();
- it.remove();
- delete option;
- }
-
- QMutableListIterator it2(m_positionals);
- while (it2.hasNext())
- {
- PositionalDef *arg = it2.next();
- it2.remove();
- delete arg;
- }
-}
-
-// Destructor
-Parser::~Parser()
-{
- clear();
-}
-
-// getPrefix
-void Parser::getPrefix(QString &opt, QString &flag)
-{
- if (m_flagStyle == FlagStyle::Windows)
- opt = flag = "/";
- else if (m_flagStyle == FlagStyle::Unix)
- opt = flag = "-";
- // else if (m_flagStyle == FlagStyle::GNU)
- else
- {
- opt = "--";
- flag = "-";
- }
-}
-
-// ParsingError
-ParsingError::ParsingError(const QString &what) : std::runtime_error(what.toStdString())
-{
-}
}
diff --git a/launcher/Commandline.h b/launcher/Commandline.h
index a4e7aa61..8bd79180 100644
--- a/launcher/Commandline.h
+++ b/launcher/Commandline.h
@@ -17,12 +17,7 @@
#pragma once
-#include
-#include
-
#include
-#include
-#include
#include
/**
@@ -39,212 +34,4 @@ namespace Commandline
* @return a QStringList containing all arguments
*/
QStringList splitArgs(QString args);
-
-/**
- * @brief The FlagStyle enum
- * Specifies how flags are decorated
- */
-
-namespace FlagStyle
-{
-enum Enum
-{
- GNU, /**< --option and -o (GNU Style) */
- Unix, /**< -option and -o (Unix Style) */
- Windows, /**< /option and /o (Windows Style) */
-#ifdef Q_OS_WIN32
- Default = Windows
-#else
- Default = GNU
-#endif
-};
-}
-
-/**
- * @brief The ArgumentStyle enum
- */
-namespace ArgumentStyle
-{
-enum Enum
-{
- Space, /**< --option value */
- Equals, /**< --option=value */
- SpaceAndEquals, /**< --option[= ]value */
-#ifdef Q_OS_WIN32
- Default = Equals
-#else
- Default = SpaceAndEquals
-#endif
-};
-}
-
-/**
- * @brief The ParsingError class
- */
-class ParsingError : public std::runtime_error
-{
-public:
- ParsingError(const QString &what);
-};
-
-/**
- * @brief The Parser class
- */
-class Parser
-{
-public:
- /**
- * @brief Parser constructor
- * @param flagStyle the FlagStyle to use in this Parser
- * @param argStyle the ArgumentStyle to use in this Parser
- */
- Parser(FlagStyle::Enum flagStyle = FlagStyle::Default,
- ArgumentStyle::Enum argStyle = ArgumentStyle::Default);
-
- /**
- * @brief set the flag style
- * @param style
- */
- void setFlagStyle(FlagStyle::Enum style);
-
- /**
- * @brief get the flag style
- * @return
- */
- FlagStyle::Enum flagStyle();
-
- /**
- * @brief set the argument style
- * @param style
- */
- void setArgumentStyle(ArgumentStyle::Enum style);
-
- /**
- * @brief get the argument style
- * @return
- */
- ArgumentStyle::Enum argumentStyle();
-
- /**
- * @brief define a boolean switch
- * @param name the parameter name
- * @param def the default value
- */
- void addSwitch(QString name, bool def = false);
-
- /**
- * @brief define an option that takes an additional argument
- * @param name the parameter name
- * @param def the default value
- */
- void addOption(QString name, QVariant def = QVariant());
-
- /**
- * @brief define a positional argument
- * @param name the parameter name
- * @param required wether this argument is required
- * @param def the default value
- */
- void addArgument(QString name, bool required = true, QVariant def = QVariant());
-
- /**
- * @brief adds a flag to an existing parameter
- * @param name the (existing) parameter name
- * @param flag the flag character
- * @see addSwitch addArgument addOption
- * Note: any one parameter can only have one flag
- */
- void addShortOpt(QString name, QChar flag);
-
- /**
- * @brief adds documentation to a Parameter
- * @param name the parameter name
- * @param metavar a string to be displayed as placeholder for the value
- * @param doc a QString containing the documentation
- * Note: on positional arguments, metavar replaces the name as displayed.
- * on options , metavar replaces the value placeholder
- */
- void addDocumentation(QString name, QString doc, QString metavar = QString());
-
- /**
- * @brief generate a help message
- * @param progName the program name to use in the help message
- * @param helpIndent how much the parameter documentation should be indented
- * @param flagsInUsage whether we should use flags instead of options in the usage
- * @return a help message
- */
- QString compileHelp(QString progName, int helpIndent = 22, bool flagsInUsage = true);
-
- /**
- * @brief generate a short usage message
- * @param progName the program name to use in the usage message
- * @param useFlags whether we should use flags instead of options
- * @return a usage message
- */
- QString compileUsage(QString progName, bool useFlags = true);
-
- /**
- * @brief parse
- * @param argv a QStringList containing the program ARGV
- * @return a QHash mapping argument names to their values
- */
- QHash parse(QStringList argv);
-
- /**
- * @brief clear all definitions
- */
- void clear();
-
- ~Parser();
-
-private:
- FlagStyle::Enum m_flagStyle;
- ArgumentStyle::Enum m_argStyle;
-
- enum OptionType
- {
- otSwitch,
- otOption
- };
-
- // Important: the common part MUST BE COMMON ON ALL THREE structs
- struct CommonDef
- {
- QString name;
- QString doc;
- QString metavar;
- QVariant def;
- };
-
- struct OptionDef
- {
- // common
- QString name;
- QString doc;
- QString metavar;
- QVariant def;
- // option
- OptionType type;
- QChar flag;
- };
-
- struct PositionalDef
- {
- // common
- QString name;
- QString doc;
- QString metavar;
- QVariant def;
- // positional
- bool required;
- };
-
- QHash m_options;
- QHash m_flags;
- QHash m_params;
- QList m_positionals;
- QList m_optionList;
-
- void getPrefix(QString &opt, QString &flag);
-};
}
diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp
index 5d179641..39e68c20 100644
--- a/launcher/FileSystem.cpp
+++ b/launcher/FileSystem.cpp
@@ -59,7 +59,24 @@
#include
#endif
+// Snippet from https://github.com/gulrak/filesystem#using-it-as-single-file-header
+
+#ifdef __APPLE__
+#include // for deployment target to support pre-catalina targets without std::fs
+#endif // __APPLE__
+
+#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || (defined(__cplusplus) && __cplusplus >= 201703L)) && defined(__has_include)
+#if __has_include() && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500)
+#define GHC_USE_STD_FS
#include
+namespace fs = std::filesystem;
+#endif // MacOS min version check
+#endif // Other OSes version check
+
+#ifndef GHC_USE_STD_FS
+#include
+namespace fs = ghc::filesystem;
+#endif
#if defined Q_OS_WIN32
@@ -147,7 +164,7 @@ bool ensureFolderPathExists(QString foldernamepath)
bool copy::operator()(const QString& offset)
{
- using copy_opts = std::filesystem::copy_options;
+ using copy_opts = fs::copy_options;
// NOTE always deep copy on windows. the alternatives are too messy.
#if defined Q_OS_WIN32
@@ -159,7 +176,7 @@ bool copy::operator()(const QString& offset)
std::error_code err;
- std::filesystem::copy_options opt = copy_opts::none;
+ fs::copy_options opt = copy_opts::none;
// The default behavior is to follow symlinks
if (!m_followSymlinks)
@@ -170,7 +187,7 @@ bool copy::operator()(const QString& offset)
// blacklisted paths, so we iterate over the source directory, and if there's no blacklist
// match, we copy the file.
QDir src_dir(src);
- QDirIterator source_it(src, QDir::Filter::Files, QDirIterator::Subdirectories);
+ QDirIterator source_it(src, QDir::Filter::Files | QDir::Filter::Hidden, QDirIterator::Subdirectories);
while (source_it.hasNext()) {
auto src_path = source_it.next();
@@ -182,7 +199,7 @@ bool copy::operator()(const QString& offset)
auto dst_path = PathCombine(dst, relative_path);
ensureFilePathExists(dst_path);
- std::filesystem::copy(toStdString(src_path), toStdString(dst_path), opt, err);
+ fs::copy(toStdString(src_path), toStdString(dst_path), opt, err);
if (err) {
qWarning() << "Failed to copy files:" << QString::fromStdString(err.message());
qDebug() << "Source file:" << src_path;
@@ -197,7 +214,7 @@ bool deletePath(QString path)
{
std::error_code err;
- std::filesystem::remove_all(toStdString(path), err);
+ fs::remove_all(toStdString(path), err);
if (err) {
qWarning() << "Failed to remove files:" << QString::fromStdString(err.message());
@@ -376,15 +393,15 @@ bool createShortCut(QString location, QString dest, QStringList args, QString na
bool overrideFolder(QString overwritten_path, QString override_path)
{
- using copy_opts = std::filesystem::copy_options;
+ using copy_opts = fs::copy_options;
if (!FS::ensureFolderPathExists(overwritten_path))
return false;
std::error_code err;
- std::filesystem::copy_options opt = copy_opts::recursive | copy_opts::overwrite_existing;
+ fs::copy_options opt = copy_opts::recursive | copy_opts::overwrite_existing;
- std::filesystem::copy(toStdString(override_path), toStdString(overwritten_path), opt, err);
+ fs::copy(toStdString(override_path), toStdString(overwritten_path), opt, err);
if (err) {
qCritical() << QString("Failed to apply override from %1 to %2").arg(override_path, overwritten_path);
diff --git a/launcher/LaunchController.cpp b/launcher/LaunchController.cpp
index 830fcf82..11e3de15 100644
--- a/launcher/LaunchController.cpp
+++ b/launcher/LaunchController.cpp
@@ -93,8 +93,8 @@ void LaunchController::decideAccount()
auto reply = CustomMessageBox::selectable(
m_parentWidget,
tr("No Accounts"),
- tr("In order to play Minecraft, you must have at least one Mojang or Microsoft "
- "account logged in. "
+ tr("In order to play Minecraft, you must have at least one Microsoft or Mojang "
+ "account logged in. Mojang accounts can only be used offline. "
"Would you like to open the account manager to add an account now?"),
QMessageBox::Information,
QMessageBox::Yes | QMessageBox::No
@@ -382,7 +382,7 @@ void LaunchController::launchInstance()
m_launcher->prependStep(new TextPrint(m_launcher.get(), "Launched instance in " + online_mode + " mode\n", MessageLevel::Launcher));
// Prepend Version
- m_launcher->prependStep(new TextPrint(m_launcher.get(), BuildConfig.LAUNCHER_NAME + " version: " + BuildConfig.printableVersionString() + "\n\n", MessageLevel::Launcher));
+ m_launcher->prependStep(new TextPrint(m_launcher.get(), BuildConfig.LAUNCHER_DISPLAYNAME + " version: " + BuildConfig.printableVersionString() + "\n\n", MessageLevel::Launcher));
m_launcher->start();
}
diff --git a/launcher/NullInstance.h b/launcher/NullInstance.h
index 53e64a05..53edfa0b 100644
--- a/launcher/NullInstance.h
+++ b/launcher/NullInstance.h
@@ -1,3 +1,38 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 Sefa Eyeoglu
+ *
+ * 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 .
+ *
+ * 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 "BaseInstance.h"
#include "launch/LaunchTask.h"
@@ -84,4 +119,8 @@ public:
QString modsRoot() const override {
return QString();
}
+ void updateRuntimeContext()
+ {
+ // NOOP
+ }
};
diff --git a/launcher/RuntimeContext.h b/launcher/RuntimeContext.h
new file mode 100644
index 00000000..70e7d0d1
--- /dev/null
+++ b/launcher/RuntimeContext.h
@@ -0,0 +1,88 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 Sefa Eyeoglu
+ *
+ * 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 .
+ */
+
+#pragma once
+
+#include
+#include
+#include "settings/SettingsObject.h"
+
+struct RuntimeContext {
+ QString javaArchitecture;
+ QString javaRealArchitecture;
+ QString javaPath;
+ QString system;
+
+ QString mappedJavaRealArchitecture() const
+ {
+ if (javaRealArchitecture == "amd64")
+ return "x86_64";
+ if (javaRealArchitecture == "i386" || javaRealArchitecture == "i686")
+ return "x86";
+ if (javaRealArchitecture == "aarch64")
+ return "arm64";
+ if (javaRealArchitecture == "arm" || javaRealArchitecture == "armhf")
+ return "arm32";
+ return javaRealArchitecture;
+ }
+
+ void updateFromInstanceSettings(SettingsObjectPtr instanceSettings)
+ {
+ javaArchitecture = instanceSettings->get("JavaArchitecture").toString();
+ javaRealArchitecture = instanceSettings->get("JavaRealArchitecture").toString();
+ javaPath = instanceSettings->get("JavaPath").toString();
+ system = currentSystem();
+ }
+
+ QString getClassifier() const { return system + "-" + mappedJavaRealArchitecture(); }
+
+ // "Legacy" refers to the fact that Mojang assumed that these are the only two architectures
+ bool isLegacyArch() const
+ {
+ const QString mapped = mappedJavaRealArchitecture();
+ return mapped == "x86_64" || mapped == "x86";
+ }
+
+ bool classifierMatches(QString target) const
+ {
+ // try to match precise classifier "[os]-[arch]"
+ bool x = target == getClassifier();
+ // try to match imprecise classifier on legacy architectures "[os]"
+ if (!x && isLegacyArch())
+ x = target == system;
+
+ return x;
+ }
+
+ static QString currentSystem()
+ {
+#if defined(Q_OS_LINUX)
+ return "linux";
+#elif defined(Q_OS_MACOS)
+ return "osx";
+#elif defined(Q_OS_WINDOWS)
+ return "windows";
+#elif defined(Q_OS_FREEBSD)
+ return "freebsd";
+#elif defined(Q_OS_OPENBSD)
+ return "openbsd";
+#else
+ return "unknown";
+#endif
+ }
+};
diff --git a/launcher/UpdateController.cpp b/launcher/UpdateController.cpp
index 646f8e57..9ff44854 100644
--- a/launcher/UpdateController.cpp
+++ b/launcher/UpdateController.cpp
@@ -358,7 +358,7 @@ void UpdateController::fail()
msg = QObject::tr(
"Couldn't replace file %1. Changes will be reverted.\n"
"See the %2 log file for details."
- ).arg(m_failedFile, BuildConfig.LAUNCHER_NAME);
+ ).arg(m_failedFile, BuildConfig.LAUNCHER_DISPLAYNAME);
doRollback = true;
QMessageBox::critical(m_parent, failTitle, msg);
break;
@@ -368,7 +368,7 @@ void UpdateController::fail()
msg = QObject::tr(
"Couldn't remove file %1. Changes will be reverted.\n"
"See the %2 log file for details."
- ).arg(m_failedFile, BuildConfig.LAUNCHER_NAME);
+ ).arg(m_failedFile, BuildConfig.LAUNCHER_DISPLAYNAME);
doRollback = true;
QMessageBox::critical(m_parent, failTitle, msg);
break;
@@ -399,7 +399,7 @@ void UpdateController::fail()
{
msg = QObject::tr("The rollback failed too.\n"
"You will have to repair %1 manually.\n"
- "Please let us know why and how this happened.").arg(BuildConfig.LAUNCHER_NAME);
+ "Please let us know why and how this happened.").arg(BuildConfig.LAUNCHER_DISPLAYNAME);
QMessageBox::critical(m_parent, rollFailTitle, msg);
qApp->quit();
}
diff --git a/launcher/java/JavaUtils.cpp b/launcher/java/JavaUtils.cpp
index 2f91605b..040fe821 100644
--- a/launcher/java/JavaUtils.cpp
+++ b/launcher/java/JavaUtils.cpp
@@ -174,7 +174,7 @@ JavaInstallPtr JavaUtils::GetDefaultJava()
QStringList addJavasFromEnv(QList javas)
{
- auto env = qEnvironmentVariable("POLYMC_JAVA_PATHS");
+ auto env = qEnvironmentVariable("PRISMLAUNCHER_JAVA_PATHS"); // FIXME: use launcher name from buildconfig
#if defined(Q_OS_WIN32)
QList javaPaths = env.replace("\\", "/").split(QLatin1String(";"));
@@ -441,7 +441,7 @@ QList JavaUtils::FindJavaPaths()
scanJavaDir("/usr/lib/jvm");
scanJavaDir("/usr/lib64/jvm");
scanJavaDir("/usr/lib32/jvm");
- // javas stored in PolyMC's folder
+ // javas stored in Prism Launcher's folder
scanJavaDir("java");
// manually installed JDKs in /opt
scanJavaDir("/opt/jdk");
diff --git a/launcher/launch/steps/CheckJava.cpp b/launcher/launch/steps/CheckJava.cpp
index db56b652..7aeb61bf 100644
--- a/launcher/launch/steps/CheckJava.cpp
+++ b/launcher/launch/steps/CheckJava.cpp
@@ -121,7 +121,6 @@ void CheckJava::checkJavaFinished(JavaCheckResult result)
emit logLine(QString("Could not start java:"), MessageLevel::Error);
emit logLines(result.errorLog.split('\n'), MessageLevel::Error);
emit logLine(QString("\nCheck your Java settings."), MessageLevel::Launcher);
- printSystemInfo(false, false);
emitFailed(QString("Could not start java!"));
return;
}
@@ -130,7 +129,6 @@ void CheckJava::checkJavaFinished(JavaCheckResult result)
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);
emitSucceeded();
return;
}
@@ -138,7 +136,6 @@ void CheckJava::checkJavaFinished(JavaCheckResult result)
{
auto instance = m_parent->instance();
printJavaInfo(result.javaVersion.toString(), result.mojangPlatform, 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("JavaRealArchitecture", result.realPlatform);
@@ -155,20 +152,3 @@ void CheckJava::printJavaInfo(const QString& version, const QString& architectur
emit logLine(QString("Java is version %1, using %2 (%3) architecture, from %4.\n\n")
.arg(version, architecture, realArchitecture, vendor), MessageLevel::Launcher);
}
-
-void CheckJava::printSystemInfo(bool javaIsKnown, bool javaIs64bit)
-{
- auto cpu64 = Sys::isCPU64bit();
- auto system64 = Sys::isSystem64bit();
- if(cpu64 != system64)
- {
- emit logLine(QString("Your CPU architecture is not matching your system architecture. You might want to install a 64bit Operating System.\n\n"), MessageLevel::Error);
- }
- if(javaIsKnown)
- {
- if(javaIs64bit != system64)
- {
- emit logLine(QString("Your Java architecture is not matching your system architecture. You might want to install a 64bit Java version.\n\n"), MessageLevel::Error);
- }
- }
-}
diff --git a/launcher/main.cpp b/launcher/main.cpp
index 85fe1260..c6a7614c 100644
--- a/launcher/main.cpp
+++ b/launcher/main.cpp
@@ -75,7 +75,7 @@ int main(int argc, char *argv[])
Q_INIT_RESOURCE(multimc);
Q_INIT_RESOURCE(backgrounds);
Q_INIT_RESOURCE(documents);
- Q_INIT_RESOURCE(polymc);
+ Q_INIT_RESOURCE(prismlauncher);
Q_INIT_RESOURCE(pe_dark);
Q_INIT_RESOURCE(pe_light);
diff --git a/launcher/minecraft/Component.cpp b/launcher/minecraft/Component.cpp
index c7dd5e36..7e5b6058 100644
--- a/launcher/minecraft/Component.cpp
+++ b/launcher/minecraft/Component.cpp
@@ -1,3 +1,38 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 Sefa Eyeoglu
+ *
+ * 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 .
+ *
+ * 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
#include
#include "Component.h"
@@ -60,7 +95,7 @@ void Component::applyTo(LaunchProfile* profile)
auto vfile = getVersionFile();
if(vfile)
{
- vfile->applyTo(profile);
+ vfile->applyTo(profile, m_parent->runtimeContext());
}
else
{
diff --git a/launcher/minecraft/LaunchProfile.cpp b/launcher/minecraft/LaunchProfile.cpp
index 39a342ca..9a6cea11 100644
--- a/launcher/minecraft/LaunchProfile.cpp
+++ b/launcher/minecraft/LaunchProfile.cpp
@@ -173,9 +173,9 @@ void LaunchProfile::applyCompatibleJavaMajors(QList& javaMajor)
m_compatibleJavaMajors.append(javaMajor);
}
-void LaunchProfile::applyLibrary(LibraryPtr library)
+void LaunchProfile::applyLibrary(LibraryPtr library, const RuntimeContext & runtimeContext)
{
- if(!library->isActive())
+ if(!library->isActive(runtimeContext))
{
return;
}
@@ -205,9 +205,9 @@ void LaunchProfile::applyLibrary(LibraryPtr library)
}
}
-void LaunchProfile::applyMavenFile(LibraryPtr mavenFile)
+void LaunchProfile::applyMavenFile(LibraryPtr mavenFile, const RuntimeContext & runtimeContext)
{
- if(!mavenFile->isActive())
+ if(!mavenFile->isActive(runtimeContext))
{
return;
}
@@ -221,10 +221,10 @@ void LaunchProfile::applyMavenFile(LibraryPtr mavenFile)
m_mavenFiles.append(Library::limitedCopy(mavenFile));
}
-void LaunchProfile::applyAgent(AgentPtr agent)
+void LaunchProfile::applyAgent(AgentPtr agent, const RuntimeContext & runtimeContext)
{
auto lib = agent->library();
- if(!lib->isActive())
+ if(!lib->isActive(runtimeContext))
{
return;
}
@@ -354,7 +354,7 @@ const QList & LaunchProfile::getCompatibleJavaMajors() const
}
void LaunchProfile::getLibraryFiles(
- const QString& architecture,
+ const RuntimeContext & runtimeContext,
QStringList& jars,
QStringList& nativeJars,
const QString& overridePath,
@@ -366,7 +366,7 @@ void LaunchProfile::getLibraryFiles(
nativeJars.clear();
for (auto lib : getLibraries())
{
- lib->getApplicableFiles(currentSystem, jars, nativeJars, native32, native64, overridePath);
+ lib->getApplicableFiles(runtimeContext, jars, nativeJars, native32, native64, overridePath);
}
// NOTE: order is important here, add main jar last to the lists
if(m_mainJar)
@@ -379,18 +379,18 @@ void LaunchProfile::getLibraryFiles(
}
else
{
- m_mainJar->getApplicableFiles(currentSystem, jars, nativeJars, native32, native64, overridePath);
+ m_mainJar->getApplicableFiles(runtimeContext, jars, nativeJars, native32, native64, overridePath);
}
}
for (auto lib : getNativeLibraries())
{
- lib->getApplicableFiles(currentSystem, jars, nativeJars, native32, native64, overridePath);
+ lib->getApplicableFiles(runtimeContext, jars, nativeJars, native32, native64, overridePath);
}
- if(architecture == "32")
+ if(runtimeContext.javaArchitecture == "32")
{
nativeJars.append(native32);
}
- else if(architecture == "64")
+ else if(runtimeContext.javaArchitecture == "64")
{
nativeJars.append(native64);
}
diff --git a/launcher/minecraft/LaunchProfile.h b/launcher/minecraft/LaunchProfile.h
index b55cf661..49c1217d 100644
--- a/launcher/minecraft/LaunchProfile.h
+++ b/launcher/minecraft/LaunchProfile.h
@@ -56,9 +56,9 @@ public: /* application of profile variables from patches */
void applyTweakers(const QStringList &tweakers);
void applyJarMods(const QList &jarMods);
void applyMods(const QList &jarMods);
- void applyLibrary(LibraryPtr library);
- void applyMavenFile(LibraryPtr library);
- void applyAgent(AgentPtr agent);
+ void applyLibrary(LibraryPtr library, const RuntimeContext & runtimeContext);
+ void applyMavenFile(LibraryPtr library, const RuntimeContext & runtimeContext);
+ void applyAgent(AgentPtr agent, const RuntimeContext & runtimeContext);
void applyCompatibleJavaMajors(QList& javaMajor);
void applyMainJar(LibraryPtr jar);
void applyProblemSeverity(ProblemSeverity severity);
@@ -83,7 +83,7 @@ public: /* getters for profile variables */
const QList & getCompatibleJavaMajors() const;
const LibraryPtr getMainJar() const;
void getLibraryFiles(
- const QString & architecture,
+ const RuntimeContext & runtimeContext,
QStringList & jars,
QStringList & nativeJars,
const QString & overridePath,
diff --git a/launcher/minecraft/Library.cpp b/launcher/minecraft/Library.cpp
index ba7aed4b..cb2b5254 100644
--- a/launcher/minecraft/Library.cpp
+++ b/launcher/minecraft/Library.cpp
@@ -1,3 +1,38 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 Sefa Eyeoglu
+ *
+ * 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 .
+ *
+ * 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 "Library.h"
#include "MinecraftInstance.h"
@@ -7,7 +42,7 @@
#include
-void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& native, QStringList& native32,
+void Library::getApplicableFiles(const RuntimeContext & runtimeContext, QStringList& jar, QStringList& native, QStringList& native32,
QStringList& native64, const QString &overridePath) const
{
bool local = isLocal();
@@ -21,7 +56,7 @@ void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& na
}
return out.absoluteFilePath();
};
- QString raw_storage = storageSuffix(system);
+ QString raw_storage = storageSuffix(runtimeContext);
if(isNative())
{
if (raw_storage.contains("${arch}"))
@@ -45,7 +80,7 @@ void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& na
}
QList Library::getDownloads(
- OpSys system,
+ const RuntimeContext & runtimeContext,
class HttpMetaCache* cache,
QStringList& failedLocalFiles,
const QString & overridePath
@@ -107,14 +142,14 @@ QList Library::getDownloads(
return true;
};
- QString raw_storage = storageSuffix(system);
+ QString raw_storage = storageSuffix(runtimeContext);
if(m_mojangDownloads)
{
if(isNative())
{
- if(m_nativeClassifiers.contains(system))
+ auto nativeClassifier = getCompatibleNative(runtimeContext);
+ if(!nativeClassifier.isNull())
{
- auto nativeClassifier = m_nativeClassifiers[system];
if(nativeClassifier.contains("${arch}"))
{
auto nat32Classifier = nativeClassifier;
@@ -203,7 +238,7 @@ QList Library::getDownloads(
return out;
}
-bool Library::isActive() const
+bool Library::isActive(const RuntimeContext & runtimeContext) const
{
bool result = true;
if (m_rules.empty())
@@ -215,7 +250,7 @@ bool Library::isActive() const
RuleAction ruleResult = Disallow;
for (auto rule : m_rules)
{
- RuleAction temp = rule->apply(this);
+ RuleAction temp = rule->apply(this, runtimeContext);
if (temp != Defer)
ruleResult = temp;
}
@@ -223,7 +258,7 @@ bool Library::isActive() const
}
if (isNative())
{
- result = result && m_nativeClassifiers.contains(currentSystem);
+ result = result && !getCompatibleNative(runtimeContext).isNull();
}
return result;
}
@@ -238,6 +273,19 @@ bool Library::isAlwaysStale() const
return m_hint == "always-stale";
}
+QString Library::getCompatibleNative(const RuntimeContext & runtimeContext) const {
+ // try to match precise classifier "[os]-[arch]"
+ auto entry = m_nativeClassifiers.constFind(runtimeContext.getClassifier());
+ // try to match imprecise classifier on legacy architectures "[os]"
+ if (entry == m_nativeClassifiers.constEnd() && runtimeContext.isLegacyArch())
+ entry = m_nativeClassifiers.constFind(runtimeContext.system);
+
+ if (entry == m_nativeClassifiers.constEnd())
+ return QString();
+
+ return entry.value();
+}
+
void Library::setStoragePrefix(QString prefix)
{
m_storagePrefix = prefix;
@@ -257,7 +305,7 @@ QString Library::storagePrefix() const
return m_storagePrefix;
}
-QString Library::filename(OpSys system) const
+QString Library::filename(const RuntimeContext & runtimeContext) const
{
if(!m_filename.isEmpty())
{
@@ -271,9 +319,10 @@ QString Library::filename(OpSys system) const
// otherwise native, override classifiers. Mojang HACK!
GradleSpecifier nativeSpec = m_name;
- if (m_nativeClassifiers.contains(system))
+ QString nativeClassifier = getCompatibleNative(runtimeContext);
+ if (!nativeClassifier.isNull())
{
- nativeSpec.setClassifier(m_nativeClassifiers[system]);
+ nativeSpec.setClassifier(nativeClassifier);
}
else
{
@@ -282,14 +331,14 @@ QString Library::filename(OpSys system) const
return nativeSpec.getFileName();
}
-QString Library::displayName(OpSys system) const
+QString Library::displayName(const RuntimeContext & runtimeContext) const
{
if(!m_displayname.isEmpty())
return m_displayname;
- return filename(system);
+ return filename(runtimeContext);
}
-QString Library::storageSuffix(OpSys system) const
+QString Library::storageSuffix(const RuntimeContext & runtimeContext) const
{
// non-native? use only the gradle specifier
if (!isNative())
@@ -299,9 +348,10 @@ QString Library::storageSuffix(OpSys system) const
// otherwise native, override classifiers. Mojang HACK!
GradleSpecifier nativeSpec = m_name;
- if (m_nativeClassifiers.contains(system))
+ QString nativeClassifier = getCompatibleNative(runtimeContext);
+ if (!nativeClassifier.isNull())
{
- nativeSpec.setClassifier(m_nativeClassifiers[system]);
+ nativeSpec.setClassifier(nativeClassifier);
}
else
{
diff --git a/launcher/minecraft/Library.h b/launcher/minecraft/Library.h
index 0740a7ca..26dbf962 100644
--- a/launcher/minecraft/Library.h
+++ b/launcher/minecraft/Library.h
@@ -1,8 +1,44 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 Sefa Eyeoglu
+ *
+ * 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 .
+ *
+ * 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
#include
#include
#include
+#include
#include
#include
#include
@@ -10,9 +46,9 @@
#include
#include "Rule.h"
-#include "minecraft/OpSys.h"
#include "GradleSpecifier.h"
#include "MojangDownloadInfo.h"
+#include "RuntimeContext.h"
class Library;
class MinecraftInstance;
@@ -98,7 +134,7 @@ public: /* methods */
m_repositoryURL = base_url;
}
- void getApplicableFiles(OpSys system, QStringList & jar, QStringList & native,
+ void getApplicableFiles(const RuntimeContext & runtimeContext, QStringList & jar, QStringList & native,
QStringList & native32, QStringList & native64, const QString & overridePath) const;
void setAbsoluteUrl(const QString &absolute_url)
@@ -112,7 +148,7 @@ public: /* methods */
}
/// Get the file name of the library
- QString filename(OpSys system) const;
+ QString filename(const RuntimeContext & runtimeContext) const;
// DEPRECATED: set a display name, used by jar mods only
void setDisplayName(const QString & displayName)
@@ -121,7 +157,7 @@ public: /* methods */
}
/// Get the file name of the library
- QString displayName(OpSys system) const;
+ QString displayName(const RuntimeContext & runtimeContext) const;
void setMojangDownloadInfo(MojangLibraryDownloadInfo::Ptr info)
{
@@ -140,7 +176,7 @@ public: /* methods */
}
/// Returns true if the library should be loaded (or extracted, in case of natives)
- bool isActive() const;
+ bool isActive(const RuntimeContext & runtimeContext) const;
/// Returns true if the library is contained in an instance and false if it is shared
bool isLocal() const;
@@ -152,18 +188,20 @@ public: /* methods */
bool isForge() const;
// Get a list of downloads for this library
- QList getDownloads(OpSys system, class HttpMetaCache * cache,
+ QList getDownloads(const RuntimeContext & runtimeContext, class HttpMetaCache * cache,
QStringList & failedLocalFiles, const QString & overridePath) const;
+ QString getCompatibleNative(const RuntimeContext & runtimeContext) const;
+
private: /* methods */
- /// the default storage prefix used by PolyMC
+ /// the default storage prefix used by Prism Launcher
static QString defaultStoragePrefix();
/// Get the prefix - root of the storage to be used
QString storagePrefix() const;
/// Get the relative file path where the library should be saved
- QString storageSuffix(OpSys system) const;
+ QString storageSuffix(const RuntimeContext & runtimeContext) const;
QString hint() const
{
@@ -177,23 +215,23 @@ protected: /* data */
/// DEPRECATED URL prefix of the maven repo where the file can be downloaded
QString m_repositoryURL;
- /// DEPRECATED: PolyMC-specific absolute URL. takes precedence over the implicit maven repo URL, if defined
+ /// DEPRECATED: Prism Launcher-specific absolute URL. takes precedence over the implicit maven repo URL, if defined
QString m_absoluteURL;
- /// PolyMC extension - filename override
+ /// Prism Launcher extension - filename override
QString m_filename;
- /// DEPRECATED PolyMC extension - display name
+ /// DEPRECATED Prism Launcher extension - display name
QString m_displayname;
/**
- * PolyMC-specific type hint - modifies how the library is treated
+ * Prism Launcher-specific type hint - modifies how the library is treated
*/
QString m_hint;
/**
- * storage - by default the local libraries folder in polymc, but could be elsewhere
- * PolyMC specific, because of FTB.
+ * storage - by default the local libraries folder in Prism Launcher, but could be elsewhere
+ * Prism Launcher specific, because of FTB.
*/
QString m_storagePrefix;
@@ -204,7 +242,7 @@ protected: /* data */
QStringList m_extractExcludes;
/// native suffixes per OS
- QMap m_nativeClassifiers;
+ QMap m_nativeClassifiers;
/// true if the library had a rules section (even empty)
bool applyRules = false;
diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp
index bbbd4f79..3b29d929 100644
--- a/launcher/minecraft/MinecraftInstance.cpp
+++ b/launcher/minecraft/MinecraftInstance.cpp
@@ -147,6 +147,7 @@ void MinecraftInstance::loadSpecificSettings()
m_settings->registerPassthrough(global_settings->getSetting("JavaTimestamp"), javaOrLocation);
m_settings->registerPassthrough(global_settings->getSetting("JavaVersion"), javaOrLocation);
m_settings->registerPassthrough(global_settings->getSetting("JavaArchitecture"), javaOrLocation);
+ m_settings->registerPassthrough(global_settings->getSetting("JavaRealArchitecture"), javaOrLocation);
// Window Size
auto windowSetting = m_settings->registerSetting("OverrideWindow", false);
@@ -190,6 +191,13 @@ void MinecraftInstance::loadSpecificSettings()
qDebug() << "Instance-type specific settings were loaded!";
setSpecificSettingsLoaded(true);
+
+ updateRuntimeContext();
+}
+
+void MinecraftInstance::updateRuntimeContext()
+{
+ m_runtimeContext.updateFromInstanceSettings(m_settings);
}
QString MinecraftInstance::typeName() const
@@ -327,9 +335,8 @@ QDir MinecraftInstance::versionsPath() const
QStringList MinecraftInstance::getClassPath()
{
QStringList jars, nativeJars;
- auto javaArchitecture = settings()->get("JavaArchitecture").toString();
auto profile = m_components->getProfile();
- profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot());
+ profile->getLibraryFiles(runtimeContext(), jars, nativeJars, getLocalLibraryPath(), binRoot());
return jars;
}
@@ -342,9 +349,8 @@ QString MinecraftInstance::getMainClass() const
QStringList MinecraftInstance::getNativeJars()
{
QStringList jars, nativeJars;
- auto javaArchitecture = settings()->get("JavaArchitecture").toString();
auto profile = m_components->getProfile();
- profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot());
+ profile->getLibraryFiles(runtimeContext(), jars, nativeJars, getLocalLibraryPath(), binRoot());
return nativeJars;
}
@@ -369,7 +375,7 @@ QStringList MinecraftInstance::extraArguments()
for (auto agent : agents)
{
QStringList jar, temp1, temp2, temp3;
- agent->library()->getApplicableFiles(currentSystem, jar, temp1, temp2, temp3, getLocalLibraryPath());
+ agent->library()->getApplicableFiles(runtimeContext(), jar, temp1, temp2, temp3, getLocalLibraryPath());
list.append("-javaagent:"+jar[0]+(agent->argument().isEmpty() ? "" : "="+agent->argument()));
}
@@ -633,8 +639,7 @@ QString MinecraftInstance::createLaunchScript(AuthSessionPtr session, MinecraftS
// libraries and class path.
{
QStringList jars, nativeJars;
- auto javaArchitecture = settings()->get("JavaArchitecture").toString();
- profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot());
+ profile->getLibraryFiles(runtimeContext(), jars, nativeJars, getLocalLibraryPath(), binRoot());
for(auto file: jars)
{
launchScript += "cp " + file + "\n";
@@ -690,8 +695,7 @@ QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session, Minecr
{
out << "Libraries:";
QStringList jars, nativeJars;
- auto javaArchitecture = settings->get("JavaArchitecture").toString();
- profile->getLibraryFiles(javaArchitecture, jars, nativeJars, getLocalLibraryPath(), binRoot());
+ profile->getLibraryFiles(runtimeContext(), jars, nativeJars, getLocalLibraryPath(), binRoot());
auto printLibFile = [&](const QString & path)
{
QFileInfo info(path);
@@ -756,8 +760,8 @@ QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session, Minecr
out << "Jar Mods:";
for(auto & jarmod: jarMods)
{
- auto displayname = jarmod->displayName(currentSystem);
- auto realname = jarmod->filename(currentSystem);
+ auto displayname = jarmod->displayName(runtimeContext());
+ auto realname = jarmod->filename(runtimeContext());
if(displayname != realname)
{
out << " " + displayname + " (" + realname + ")";
@@ -919,6 +923,7 @@ QString MinecraftInstance::getStatusbarDescription()
Task::Ptr MinecraftInstance::createUpdateTask(Net::Mode mode)
{
+ updateRuntimeContext();
switch (mode)
{
case Net::Mode::Offline:
@@ -935,6 +940,7 @@ Task::Ptr MinecraftInstance::createUpdateTask(Net::Mode mode)
shared_qobject_ptr MinecraftInstance::createLaunchTask(AuthSessionPtr session, MinecraftServerTargetPtr serverToJoin)
{
+ updateRuntimeContext();
// FIXME: get rid of shared_from_this ...
auto process = LaunchTask::create(std::dynamic_pointer_cast(shared_from_this()));
auto pptr = process.get();
@@ -1172,7 +1178,7 @@ QList MinecraftInstance::getJarMods() const
for (auto jarmod : profile->getJarMods())
{
QStringList jar, temp1, temp2, temp3;
- jarmod->getApplicableFiles(currentSystem, jar, temp1, temp2, temp3, jarmodsPath().absolutePath());
+ jarmod->getApplicableFiles(runtimeContext(), jar, temp1, temp2, temp3, jarmodsPath().absolutePath());
// QString filePath = jarmodsPath().absoluteFilePath(jarmod->filename(currentSystem));
mods.push_back(new Mod(QFileInfo(jar[0])));
}
diff --git a/launcher/minecraft/MinecraftInstance.h b/launcher/minecraft/MinecraftInstance.h
index 6f303ef6..e4f68508 100644
--- a/launcher/minecraft/MinecraftInstance.h
+++ b/launcher/minecraft/MinecraftInstance.h
@@ -1,3 +1,38 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 Sefa Eyeoglu
+ *
+ * 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 .
+ *
+ * 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 "BaseInstance.h"
#include
@@ -73,6 +108,8 @@ public:
/** Returns whether the instance, with its version, has support for demo mode. */
[[nodiscard]] bool supportsDemo() const;
+ void updateRuntimeContext();
+
////// Profile management //////
std::shared_ptr getPackProfile() const;
diff --git a/launcher/minecraft/MojangVersionFormat.cpp b/launcher/minecraft/MojangVersionFormat.cpp
index 94c58676..9bbb4ada 100644
--- a/launcher/minecraft/MojangVersionFormat.cpp
+++ b/launcher/minecraft/MojangVersionFormat.cpp
@@ -214,7 +214,7 @@ void MojangVersionFormat::readVersionProperties(const QJsonObject &in, VersionFi
QObject::tr("The 'minimumLauncherVersion' value of this version (%1) is higher than supported by %3 (%2). It might not work properly!")
.arg(out->minimumLauncherVersion)
.arg(CURRENT_MINIMUM_LAUNCHER_VERSION)
- .arg(BuildConfig.LAUNCHER_NAME)
+ .arg(BuildConfig.LAUNCHER_DISPLAYNAME)
);
}
}
@@ -362,11 +362,8 @@ LibraryPtr MojangVersionFormat::libraryFromJson(ProblemContainer & problems, con
{
qWarning() << filename << "contains an invalid native (skipping)";
}
- OpSys opSys = OpSys_fromString(it.key());
- if (opSys != Os_Other)
- {
- out->m_nativeClassifiers[opSys] = it.value().toString();
- }
+ // FIXME: Skip unknown platforms
+ out->m_nativeClassifiers[it.key()] = it.value().toString();
}
}
if (libObj.contains("rules"))
@@ -395,7 +392,7 @@ QJsonObject MojangVersionFormat::libraryToJson(Library *library)
auto iter = library->m_nativeClassifiers.begin();
while (iter != library->m_nativeClassifiers.end())
{
- nativeList.insert(OpSys_toString(iter.key()), iter.value());
+ nativeList.insert(iter.key(), iter.value());
iter++;
}
libRoot.insert("natives", nativeList);
diff --git a/launcher/minecraft/OpSys.cpp b/launcher/minecraft/OpSys.cpp
deleted file mode 100644
index 093ec419..00000000
--- a/launcher/minecraft/OpSys.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/* 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 "OpSys.h"
-
-OpSys OpSys_fromString(QString name)
-{
- if (name == "freebsd")
- return Os_FreeBSD;
- if (name == "linux")
- return Os_Linux;
- if (name == "windows")
- return Os_Windows;
- if (name == "osx")
- return Os_OSX;
- return Os_Other;
-}
-
-QString OpSys_toString(OpSys name)
-{
- switch (name)
- {
- case Os_FreeBSD:
- return "freebsd";
- case Os_Linux:
- return "linux";
- case Os_OSX:
- return "osx";
- case Os_Windows:
- return "windows";
- default:
- return "other";
- }
-}
\ No newline at end of file
diff --git a/launcher/minecraft/OpSys.h b/launcher/minecraft/OpSys.h
deleted file mode 100644
index 0936f817..00000000
--- a/launcher/minecraft/OpSys.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* 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
-enum OpSys
-{
- Os_Windows,
- Os_FreeBSD,
- Os_Linux,
- Os_OSX,
- Os_Other
-};
-
-OpSys OpSys_fromString(QString);
-QString OpSys_toString(OpSys);
-
-#ifdef Q_OS_WIN32
- #define currentSystem Os_Windows
-#elif defined Q_OS_MAC
- #define currentSystem Os_OSX
-#elif defined Q_OS_FREEBSD
- #define currentSystem Os_FreeBSD
-#else
- #define currentSystem Os_Linux
-#endif
diff --git a/launcher/minecraft/PackProfile.cpp b/launcher/minecraft/PackProfile.cpp
index 5e76b892..1618458f 100644
--- a/launcher/minecraft/PackProfile.cpp
+++ b/launcher/minecraft/PackProfile.cpp
@@ -273,6 +273,11 @@ void PackProfile::scheduleSave()
d->m_saveTimer.start();
}
+RuntimeContext PackProfile::runtimeContext()
+{
+ return d->m_instance->runtimeContext();
+}
+
QString PackProfile::componentsFilePath() const
{
return FS::PathCombine(d->m_instance->instanceRoot(), "mmc-pack.json");
@@ -784,7 +789,7 @@ bool PackProfile::removeComponent_internal(ComponentPtr patch)
return true;
}
QStringList jar, temp1, temp2, temp3;
- jarMod->getApplicableFiles(currentSystem, jar, temp1, temp2, temp3, d->m_instance->jarmodsPath().absolutePath());
+ jarMod->getApplicableFiles(d->m_instance->runtimeContext(), jar, temp1, temp2, temp3, d->m_instance->jarmodsPath().absolutePath());
QFileInfo finfo (jar[0]);
if(finfo.exists())
{
diff --git a/launcher/minecraft/PackProfile.h b/launcher/minecraft/PackProfile.h
index 918e7f7a..807511a2 100644
--- a/launcher/minecraft/PackProfile.h
+++ b/launcher/minecraft/PackProfile.h
@@ -1,16 +1,36 @@
-/* Copyright 2013-2021 MultiMC Contributors
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 Sefa Eyeoglu
*
- * 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 .
+ *
+ * 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
@@ -104,6 +124,9 @@ public:
/// if there is a save scheduled, do it now.
void saveNow();
+ /// helper method, returns RuntimeContext of instance
+ RuntimeContext runtimeContext();
+
signals:
void minecraftChanged();
diff --git a/launcher/minecraft/Rule.cpp b/launcher/minecraft/Rule.cpp
index af2861e3..ff3d75f2 100644
--- a/launcher/minecraft/Rule.cpp
+++ b/launcher/minecraft/Rule.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
*
- * 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 .
+ *
+ * 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
@@ -60,10 +80,10 @@ QList> rulesFromJsonV4(const QJsonObject &objectWithRules)
auto osNameVal = osObj.value("name");
if (!osNameVal.isString())
continue;
- OpSys requiredOs = OpSys_fromString(osNameVal.toString());
+ QString osName = osNameVal.toString();
QString versionRegex = osObj.value("version").toString();
// add a new OS rule
- rules.append(OsRule::create(action, requiredOs, versionRegex));
+ rules.append(OsRule::create(action, osName, versionRegex));
}
return rules;
}
@@ -81,7 +101,7 @@ QJsonObject OsRule::toJson()
ruleObj.insert("action", m_result == Allow ? QString("allow") : QString("disallow"));
QJsonObject osObj;
{
- osObj.insert("name", OpSys_toString(m_system));
+ osObj.insert("name", m_system);
if(!m_version_regexp.isEmpty())
{
osObj.insert("version", m_version_regexp);
diff --git a/launcher/minecraft/Rule.h b/launcher/minecraft/Rule.h
index 7aa34d96..236f9a87 100644
--- a/launcher/minecraft/Rule.h
+++ b/launcher/minecraft/Rule.h
@@ -1,16 +1,36 @@
-/* Copyright 2013-2021 MultiMC Contributors
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 Sefa Eyeoglu
*
- * 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 .
+ *
+ * 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
@@ -19,7 +39,7 @@
#include
#include
#include
-#include "OpSys.h"
+#include "RuntimeContext.h"
class Library;
class Rule;
@@ -37,7 +57,7 @@ class Rule
{
protected:
RuleAction m_result;
- virtual bool applies(const Library *parent) = 0;
+ virtual bool applies(const Library *parent, const RuntimeContext & runtimeContext) = 0;
public:
Rule(RuleAction result) : m_result(result)
@@ -45,9 +65,9 @@ public:
}
virtual ~Rule() {};
virtual QJsonObject toJson() = 0;
- RuleAction apply(const Library *parent)
+ RuleAction apply(const Library *parent, const RuntimeContext & runtimeContext)
{
- if (applies(parent))
+ if (applies(parent, runtimeContext))
return m_result;
else
return Defer;
@@ -58,23 +78,23 @@ class OsRule : public Rule
{
private:
// the OS
- OpSys m_system;
+ QString m_system;
// the OS version regexp
QString m_version_regexp;
protected:
- virtual bool applies(const Library *)
+ virtual bool applies(const Library *, const RuntimeContext & runtimeContext)
{
- return (m_system == currentSystem);
+ return runtimeContext.classifierMatches(m_system);
}
- OsRule(RuleAction result, OpSys system, QString version_regexp)
+ OsRule(RuleAction result, QString system, QString version_regexp)
: Rule(result), m_system(system), m_version_regexp(version_regexp)
{
}
public:
virtual QJsonObject toJson();
- static std::shared_ptr create(RuleAction result, OpSys system,
+ static std::shared_ptr create(RuleAction result, QString system,
QString version_regexp)
{
return std::shared_ptr(new OsRule(result, system, version_regexp));
@@ -84,7 +104,7 @@ public:
class ImplicitRule : public Rule
{
protected:
- virtual bool applies(const Library *)
+ virtual bool applies(const Library *, const RuntimeContext & runtimeContext)
{
return true;
}
diff --git a/launcher/minecraft/VersionFile.cpp b/launcher/minecraft/VersionFile.cpp
index a9a0f7f4..76f41600 100644
--- a/launcher/minecraft/VersionFile.cpp
+++ b/launcher/minecraft/VersionFile.cpp
@@ -51,7 +51,7 @@ static bool isMinecraftVersion(const QString &uid)
return uid == "net.minecraft";
}
-void VersionFile::applyTo(LaunchProfile *profile)
+void VersionFile::applyTo(LaunchProfile *profile, const RuntimeContext & runtimeContext)
{
// Only real Minecraft can set those. Don't let anything override them.
if (isMinecraftVersion(uid))
@@ -77,15 +77,15 @@ void VersionFile::applyTo(LaunchProfile *profile)
for (auto library : libraries)
{
- profile->applyLibrary(library);
+ profile->applyLibrary(library, runtimeContext);
}
for (auto mavenFile : mavenFiles)
{
- profile->applyMavenFile(mavenFile);
+ profile->applyMavenFile(mavenFile, runtimeContext);
}
for (auto agent : agents)
{
- profile->applyAgent(agent);
+ profile->applyAgent(agent, runtimeContext);
}
profile->applyProblemSeverity(getProblemSeverity());
}
diff --git a/launcher/minecraft/VersionFile.h b/launcher/minecraft/VersionFile.h
index d4b29719..11c5a3af 100644
--- a/launcher/minecraft/VersionFile.h
+++ b/launcher/minecraft/VersionFile.h
@@ -41,7 +41,6 @@
#include
#include
-#include "minecraft/OpSys.h"
#include "minecraft/Rule.h"
#include "ProblemProvider.h"
#include "Library.h"
@@ -60,22 +59,22 @@ class VersionFile : public ProblemContainer
friend class MojangVersionFormat;
friend class OneSixVersionFormat;
public: /* methods */
- void applyTo(LaunchProfile* profile);
+ void applyTo(LaunchProfile* profile, const RuntimeContext & runtimeContext);
public: /* data */
- /// PolyMC: order hint for this version file if no explicit order is set
+ /// Prism Launcher: order hint for this version file if no explicit order is set
int order = 0;
- /// PolyMC: human readable name of this package
+ /// Prism Launcher: human readable name of this package
QString name;
- /// PolyMC: package ID of this package
+ /// Prism Launcher: package ID of this package
QString uid;
- /// PolyMC: version of this package
+ /// Prism Launcher: version of this package
QString version;
- /// PolyMC: DEPRECATED dependency on a Minecraft version
+ /// Prism Launcher: DEPRECATED dependency on a Minecraft version
QString dependsOnMinecraftVersion;
/// Mojang: DEPRECATED used to version the Mojang version format
@@ -87,13 +86,13 @@ public: /* data */
/// Mojang: class to launch Minecraft with
QString mainClass;
- /// PolyMC: class to launch legacy Minecraft with (embed in a custom window)
+ /// Prism Launcher: class to launch legacy Minecraft with (embed in a custom window)
QString appletClass;
/// Mojang: Minecraft launch arguments (may contain placeholders for variable substitution)
QString minecraftArguments;
- /// PolyMC: Additional JVM launch arguments
+ /// Prism Launcher: Additional JVM launch arguments
QStringList addnJvmArguments;
/// Mojang: list of compatible java majors
@@ -111,38 +110,38 @@ public: /* data */
/// Mojang: DEPRECATED asset group to be used with Minecraft
QString assets;
- /// PolyMC: list of tweaker mod arguments for launchwrapper
+ /// Prism Launcher: list of tweaker mod arguments for launchwrapper
QStringList addTweakers;
/// Mojang: list of libraries to add to the version
QList libraries;
- /// PolyMC: list of maven files to put in the libraries folder, but not in classpath
+ /// Prism Launcher: list of maven files to put in the libraries folder, but not in classpath
QList mavenFiles;
- /// PolyMC: list of agents to add to JVM arguments
+ /// Prism Launcher: list of agents to add to JVM arguments
QList agents;
/// The main jar (Minecraft version library, normally)
LibraryPtr mainJar;
- /// PolyMC: list of attached traits of this version file - used to enable features
+ /// Prism Launcher: list of attached traits of this version file - used to enable features
QSet traits;
- /// PolyMC: list of jar mods added to this version
+ /// Prism Launcher: list of jar mods added to this version
QList jarMods;
- /// PolyMC: list of mods added to this version
+ /// Prism Launcher: list of mods added to this version
QList mods;
/**
- * PolyMC: set of packages this depends on
+ * Prism Launcher: set of packages this depends on
* NOTE: this is shared with the meta format!!!
*/
Meta::RequireSet requires;
/**
- * PolyMC: set of packages this conflicts with
+ * Prism Launcher: set of packages this conflicts with
* NOTE: this is shared with the meta format!!!
*/
Meta::RequireSet conflicts;
diff --git a/launcher/minecraft/auth/AccountList.h b/launcher/minecraft/auth/AccountList.h
index 8136a92e..a8c3529a 100644
--- a/launcher/minecraft/auth/AccountList.h
+++ b/launcher/minecraft/auth/AccountList.h
@@ -44,7 +44,7 @@
/*!
* List of available Mojang accounts.
- * This should be loaded in the background by PolyMC on startup.
+ * This should be loaded in the background by Prism Launcher on startup.
*/
class AccountList : public QAbstractListModel
{
diff --git a/launcher/minecraft/auth/MinecraftAccount.h b/launcher/minecraft/auth/MinecraftAccount.h
index 923df0f5..4985ab97 100644
--- a/launcher/minecraft/auth/MinecraftAccount.h
+++ b/launcher/minecraft/auth/MinecraftAccount.h
@@ -61,7 +61,7 @@ Q_DECLARE_METATYPE(MinecraftAccountPtr)
* A profile within someone's Mojang account.
*
* Currently, the profile system has not been implemented by Mojang yet,
- * but we might as well add some things for it in PolyMC right now so
+ * but we might as well add some things for it in Prism Launcher right now so
* we don't have to rip the code to pieces to add it later.
*/
struct AccountProfile
diff --git a/launcher/minecraft/launch/LauncherPartLaunch.cpp b/launcher/minecraft/launch/LauncherPartLaunch.cpp
index ce477ad7..1d8d7083 100644
--- a/launcher/minecraft/launch/LauncherPartLaunch.cpp
+++ b/launcher/minecraft/launch/LauncherPartLaunch.cpp
@@ -154,7 +154,7 @@ void LauncherPartLaunch::executeTask()
#else
args << classPath.join(':');
#endif
- args << "org.polymc.EntryPoint";
+ args << "org.prismlauncher.EntryPoint";
qDebug() << args.join(' ');
diff --git a/launcher/minecraft/launch/MinecraftServerTarget.cpp b/launcher/minecraft/launch/MinecraftServerTarget.cpp
index 78a33359..a3383ec0 100644
--- a/launcher/minecraft/launch/MinecraftServerTarget.cpp
+++ b/launcher/minecraft/launch/MinecraftServerTarget.cpp
@@ -23,7 +23,7 @@ MinecraftServerTarget MinecraftServerTarget::parse(const QString &fullAddress) {
// The logic below replicates the exact logic minecraft uses for parsing server addresses.
// While the conversion is not lossless and eats errors, it ensures the same behavior
- // within Minecraft and PolyMC when entering server addresses.
+ // within Minecraft and Prism Launcher when entering server addresses.
if (fullAddress.startsWith("["))
{
int bracket = fullAddress.indexOf("]");
diff --git a/launcher/minecraft/launch/ModMinecraftJar.cpp b/launcher/minecraft/launch/ModMinecraftJar.cpp
index 93de9d59..1d6eecf2 100644
--- a/launcher/minecraft/launch/ModMinecraftJar.cpp
+++ b/launcher/minecraft/launch/ModMinecraftJar.cpp
@@ -1,22 +1,41 @@
-/* Copyright 2013-2021 MultiMC Contributors
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 Sefa Eyeoglu
*
- * 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 .
+ *
+ * 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 "ModMinecraftJar.h"
#include "launch/LaunchTask.h"
#include "MMCZip.h"
-#include "minecraft/OpSys.h"
#include "FileSystem.h"
#include "minecraft/MinecraftInstance.h"
#include "minecraft/PackProfile.h"
@@ -50,7 +69,7 @@ void ModMinecraftJar::executeTask()
{
auto mainJar = profile->getMainJar();
QStringList jars, temp1, temp2, temp3, temp4;
- mainJar->getApplicableFiles(currentSystem, jars, temp1, temp2, temp3, m_inst->getLocalLibraryPath());
+ mainJar->getApplicableFiles(m_inst->runtimeContext(), jars, temp1, temp2, temp3, m_inst->getLocalLibraryPath());
auto sourceJarPath = jars[0];
if(!MMCZip::createModdedJar(sourceJarPath, finalJarPath, jarMods))
{
diff --git a/launcher/minecraft/launch/ScanModFolders.cpp b/launcher/minecraft/launch/ScanModFolders.cpp
index 2a0e21b3..bdffeadd 100644
--- a/launcher/minecraft/launch/ScanModFolders.cpp
+++ b/launcher/minecraft/launch/ScanModFolders.cpp
@@ -1,22 +1,41 @@
-/* Copyright 2013-2021 MultiMC Contributors
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 Sefa Eyeoglu
*
- * 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 .
+ *
+ * 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 "ScanModFolders.h"
#include "launch/LaunchTask.h"
#include "MMCZip.h"
-#include "minecraft/OpSys.h"
#include "FileSystem.h"
#include "minecraft/MinecraftInstance.h"
#include "minecraft/mod/ModFolderModel.h"
diff --git a/launcher/minecraft/mod/tasks/LocalModParseTask.cpp b/launcher/minecraft/mod/tasks/LocalModParseTask.cpp
index 8a6e54d8..a694e7b2 100644
--- a/launcher/minecraft/mod/tasks/LocalModParseTask.cpp
+++ b/launcher/minecraft/mod/tasks/LocalModParseTask.cpp
@@ -1,17 +1,17 @@
#include "LocalModParseTask.h"
-#include
-#include
-#include
-#include
-#include
#include
#include
-#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "FileSystem.h"
#include "Json.h"
#include "settings/INIFile.h"
-#include "FileSystem.h"
namespace {
@@ -22,8 +22,7 @@ namespace {
// https://github.com/MinecraftForge/FML/wiki/FML-mod-information-file/5bf6a2d05145ec79387acc0d45c958642fb049fc
ModDetails ReadMCModInfo(QByteArray contents)
{
- auto getInfoFromArray = [&](QJsonArray arr) -> ModDetails
- {
+ auto getInfoFromArray = [&](QJsonArray arr) -> ModDetails {
if (!arr.at(0).isObject()) {
return {};
}
@@ -32,16 +31,14 @@ ModDetails ReadMCModInfo(QByteArray contents)
details.mod_id = firstObj.value("modid").toString();
auto name = firstObj.value("name").toString();
// NOTE: ignore stupid example mods copies where the author didn't even bother to change the name
- if(name != "Example Mod") {
+ if (name != "Example Mod") {
details.name = name;
}
details.version = firstObj.value("version").toString();
auto homeurl = firstObj.value("url").toString().trimmed();
- if(!homeurl.isEmpty())
- {
+ if (!homeurl.isEmpty()) {
// fix up url.
- if (!homeurl.startsWith("http://") && !homeurl.startsWith("https://") && !homeurl.startsWith("ftp://"))
- {
+ if (!homeurl.startsWith("http://") && !homeurl.startsWith("https://") && !homeurl.startsWith("ftp://")) {
homeurl.prepend("http://");
}
}
@@ -53,8 +50,7 @@ ModDetails ReadMCModInfo(QByteArray contents)
authors = firstObj.value("authors").toArray();
}
- for (auto author: authors)
- {
+ for (auto author : authors) {
details.authors.append(author.toString());
}
return details;
@@ -62,14 +58,11 @@ ModDetails ReadMCModInfo(QByteArray contents)
QJsonParseError jsonError;
QJsonDocument jsonDoc = QJsonDocument::fromJson(contents, &jsonError);
// this is the very old format that had just the array
- if (jsonDoc.isArray())
- {
+ if (jsonDoc.isArray()) {
return getInfoFromArray(jsonDoc.array());
- }
- else if (jsonDoc.isObject())
- {
+ } else if (jsonDoc.isObject()) {
auto val = jsonDoc.object().value("modinfoversion");
- if(val.isUndefined()) {
+ if (val.isUndefined()) {
val = jsonDoc.object().value("modListVersion");
}
@@ -79,18 +72,16 @@ ModDetails ReadMCModInfo(QByteArray contents)
if (version < 0)
version = Json::ensureString(val, "").toInt();
- if (version != 2)
- {
+ if (version != 2) {
qCritical() << "BAD stuff happened to mod json:";
qCritical() << contents;
return {};
}
auto arrVal = jsonDoc.object().value("modlist");
- if(arrVal.isUndefined()) {
+ if (arrVal.isUndefined()) {
arrVal = jsonDoc.object().value("modList");
}
- if (arrVal.isArray())
- {
+ if (arrVal.isArray()) {
return getInfoFromArray(arrVal.toArray());
}
}
@@ -102,109 +93,76 @@ ModDetails ReadMCModTOML(QByteArray contents)
{
ModDetails details;
- char errbuf[200];
- // top-level table
- toml_table_t* tomlData = toml_parse(contents.data(), errbuf, sizeof(errbuf));
-
- if(!tomlData)
- {
+ toml::table tomlData;
+#if TOML_EXCEPTIONS
+ try {
+ tomlData = toml::parse(contents.toStdString());
+ } catch (const toml::parse_error& err) {
return {};
}
+#else
+ tomlData = toml::parse(contents.toStdString());
+ if (!tomlData) {
+ return {};
+ }
+#endif
// array defined by [[mods]]
- toml_array_t* tomlModsArr = toml_array_in(tomlData, "mods");
- if(!tomlModsArr)
- {
+ auto tomlModsArr = tomlData["mods"].as_array();
+ if (!tomlModsArr) {
qWarning() << "Corrupted mods.toml? Couldn't find [[mods]] array!";
return {};
}
// we only really care about the first element, since multiple mods in one file is not supported by us at the moment
- toml_table_t* tomlModsTable0 = toml_table_at(tomlModsArr, 0);
- if(!tomlModsTable0)
- {
+ auto tomlModsTable0 = tomlModsArr->get(0);
+ if (!tomlModsTable0) {
qWarning() << "Corrupted mods.toml? [[mods]] didn't have an element at index 0!";
return {};
}
+ auto modsTable = tomlModsTable0->as_table();
+ if (!tomlModsTable0) {
+ qWarning() << "Corrupted mods.toml? [[mods]] was not a table!";
+ return {};
+ }
// mandatory properties - always in [[mods]]
- toml_datum_t modIdDatum = toml_string_in(tomlModsTable0, "modId");
- if(modIdDatum.ok)
- {
- details.mod_id = modIdDatum.u.s;
- // library says this is required for strings
- free(modIdDatum.u.s);
+ if (auto modIdDatum = (*modsTable)["modId"].as_string()) {
+ details.mod_id = QString::fromStdString(modIdDatum->get());
}
- toml_datum_t versionDatum = toml_string_in(tomlModsTable0, "version");
- if(versionDatum.ok)
- {
- details.version = versionDatum.u.s;
- free(versionDatum.u.s);
+ if (auto versionDatum = (*modsTable)["version"].as_string()) {
+ details.version = QString::fromStdString(versionDatum->get());
}
- toml_datum_t displayNameDatum = toml_string_in(tomlModsTable0, "displayName");
- if(displayNameDatum.ok)
- {
- details.name = displayNameDatum.u.s;
- free(displayNameDatum.u.s);
+ if (auto displayNameDatum = (*modsTable)["displayName"].as_string()) {
+ details.name = QString::fromStdString(displayNameDatum->get());
}
- toml_datum_t descriptionDatum = toml_string_in(tomlModsTable0, "description");
- if(descriptionDatum.ok)
- {
- details.description = descriptionDatum.u.s;
- free(descriptionDatum.u.s);
+ if (auto descriptionDatum = (*modsTable)["description"].as_string()) {
+ details.description = QString::fromStdString(descriptionDatum->get());
}
// optional properties - can be in the root table or [[mods]]
- toml_datum_t authorsDatum = toml_string_in(tomlData, "authors");
QString authors = "";
- if(authorsDatum.ok)
- {
- authors = authorsDatum.u.s;
- free(authorsDatum.u.s);
+ if (auto authorsDatum = tomlData["authors"].as_string()) {
+ authors = QString::fromStdString(authorsDatum->get());
+ } else if (auto authorsDatum = (*modsTable)["authors"].as_string()) {
+ authors = QString::fromStdString(authorsDatum->get());
}
- else
- {
- authorsDatum = toml_string_in(tomlModsTable0, "authors");
- if(authorsDatum.ok)
- {
- authors = authorsDatum.u.s;
- free(authorsDatum.u.s);
- }
- }
- if(!authors.isEmpty())
- {
+ if (!authors.isEmpty()) {
details.authors.append(authors);
}
- toml_datum_t homeurlDatum = toml_string_in(tomlData, "displayURL");
QString homeurl = "";
- if(homeurlDatum.ok)
- {
- homeurl = homeurlDatum.u.s;
- free(homeurlDatum.u.s);
+ if (auto homeurlDatum = tomlData["displayURL"].as_string()) {
+ homeurl = QString::fromStdString(homeurlDatum->get());
+ } else if (auto homeurlDatum = (*modsTable)["displayURL"].as_string()) {
+ homeurl = QString::fromStdString(homeurlDatum->get());
}
- else
- {
- homeurlDatum = toml_string_in(tomlModsTable0, "displayURL");
- if(homeurlDatum.ok)
- {
- homeurl = homeurlDatum.u.s;
- free(homeurlDatum.u.s);
- }
- }
- if(!homeurl.isEmpty())
- {
- // fix up url.
- if (!homeurl.startsWith("http://") && !homeurl.startsWith("https://") && !homeurl.startsWith("ftp://"))
- {
- homeurl.prepend("http://");
- }
+ // fix up url.
+ if (!homeurl.isEmpty() && !homeurl.startsWith("http://") && !homeurl.startsWith("https://") && !homeurl.startsWith("ftp://")) {
+ homeurl.prepend("http://");
}
details.homeurl = homeurl;
- // this seems to be recursive, so it should free everything
- toml_free(tomlData);
-
return details;
}
@@ -224,25 +182,20 @@ ModDetails ReadFabricModInfo(QByteArray contents)
details.name = object.contains("name") ? object.value("name").toString() : details.mod_id;
details.description = object.value("description").toString();
- if (schemaVersion >= 1)
- {
+ if (schemaVersion >= 1) {
QJsonArray authors = object.value("authors").toArray();
- for (auto author: authors)
- {
- if(author.isObject()) {
+ for (auto author : authors) {
+ if (author.isObject()) {
details.authors.append(author.toObject().value("name").toString());
- }
- else {
+ } else {
details.authors.append(author.toString());
}
}
- if (object.contains("contact"))
- {
+ if (object.contains("contact")) {
QJsonObject contact = object.value("contact").toObject();
- if (contact.contains("homepage"))
- {
+ if (contact.contains("homepage")) {
details.homeurl = contact.value("homepage").toString();
}
}
@@ -261,8 +214,7 @@ ModDetails ReadQuiltModInfo(QByteArray contents)
ModDetails details;
// https://github.com/QuiltMC/rfcs/blob/be6ba280d785395fefa90a43db48e5bfc1d15eb4/specification/0002-quilt.mod.json.md
- if (schemaVersion == 1)
- {
+ if (schemaVersion == 1) {
auto modInfo = Json::requireObject(object.value("quilt_loader"), "Quilt mod info");
details.mod_id = Json::requireString(modInfo.value("id"), "Mod ID");
@@ -280,8 +232,7 @@ ModDetails ReadQuiltModInfo(QByteArray contents)
auto modContact = Json::ensureObject(modMetadata.value("contact"));
- if (modContact.contains("homepage"))
- {
+ if (modContact.contains("homepage")) {
details.homeurl = Json::requireString(modContact.value("homepage"));
}
}
@@ -314,21 +265,17 @@ ModDetails ReadLiteModInfo(QByteArray contents)
QJsonParseError jsonError;
QJsonDocument jsonDoc = QJsonDocument::fromJson(contents, &jsonError);
auto object = jsonDoc.object();
- if (object.contains("name"))
- {
+ if (object.contains("name")) {
details.mod_id = details.name = object.value("name").toString();
}
- if (object.contains("version"))
- {
+ if (object.contains("version")) {
details.version = object.value("version").toString("");
- }
- else
- {
+ } else {
details.version = object.value("revision").toString("");
}
details.mcversion = object.value("mcversion").toString();
auto author = object.value("author").toString();
- if(!author.isEmpty()) {
+ if (!author.isEmpty()) {
details.authors.append(author);
}
details.description = object.value("description").toString();
@@ -336,14 +283,10 @@ ModDetails ReadLiteModInfo(QByteArray contents)
return details;
}
-}
+} // namespace
-LocalModParseTask::LocalModParseTask(int token, ResourceType type, const QFileInfo& modFile):
- Task(nullptr, false),
- m_token(token),
- m_type(type),
- m_modFile(modFile),
- m_result(new Result())
+LocalModParseTask::LocalModParseTask(int token, ResourceType type, const QFileInfo& modFile)
+ : Task(nullptr, false), m_token(token), m_type(type), m_modFile(modFile), m_result(new Result())
{}
void LocalModParseTask::processAsZip()
@@ -354,10 +297,8 @@ void LocalModParseTask::processAsZip()
QuaZipFile file(&zip);
- if (zip.setCurrentFile("META-INF/mods.toml"))
- {
- if (!file.open(QIODevice::ReadOnly))
- {
+ if (zip.setCurrentFile("META-INF/mods.toml")) {
+ if (!file.open(QIODevice::ReadOnly)) {
zip.close();
return;
}
@@ -366,12 +307,9 @@ void LocalModParseTask::processAsZip()
file.close();
// to replace ${file.jarVersion} with the actual version, as needed
- if (m_result->details.version == "${file.jarVersion}")
- {
- if (zip.setCurrentFile("META-INF/MANIFEST.MF"))
- {
- if (!file.open(QIODevice::ReadOnly))
- {
+ if (m_result->details.version == "${file.jarVersion}") {
+ if (zip.setCurrentFile("META-INF/MANIFEST.MF")) {
+ if (!file.open(QIODevice::ReadOnly)) {
zip.close();
return;
}
@@ -379,10 +317,8 @@ void LocalModParseTask::processAsZip()
// quick and dirty line-by-line parser
auto manifestLines = file.readAll().split('\n');
QString manifestVersion = "";
- for (auto &line : manifestLines)
- {
- if (QString(line).startsWith("Implementation-Version: "))
- {
+ for (auto& line : manifestLines) {
+ if (QString(line).startsWith("Implementation-Version: ")) {
manifestVersion = QString(line).remove("Implementation-Version: ");
break;
}
@@ -390,8 +326,7 @@ void LocalModParseTask::processAsZip()
// some mods use ${projectversion} in their build.gradle, causing this mess to show up in MANIFEST.MF
// also keep with forge's behavior of setting the version to "NONE" if none is found
- if (manifestVersion.contains("task ':jar' property 'archiveVersion'") || manifestVersion == "")
- {
+ if (manifestVersion.contains("task ':jar' property 'archiveVersion'") || manifestVersion == "") {
manifestVersion = "NONE";
}
@@ -403,11 +338,8 @@ void LocalModParseTask::processAsZip()
zip.close();
return;
- }
- else if (zip.setCurrentFile("mcmod.info"))
- {
- if (!file.open(QIODevice::ReadOnly))
- {
+ } else if (zip.setCurrentFile("mcmod.info")) {
+ if (!file.open(QIODevice::ReadOnly)) {
zip.close();
return;
}
@@ -416,11 +348,8 @@ void LocalModParseTask::processAsZip()
file.close();
zip.close();
return;
- }
- else if (zip.setCurrentFile("quilt.mod.json"))
- {
- if (!file.open(QIODevice::ReadOnly))
- {
+ } else if (zip.setCurrentFile("quilt.mod.json")) {
+ if (!file.open(QIODevice::ReadOnly)) {
zip.close();
return;
}
@@ -429,11 +358,8 @@ void LocalModParseTask::processAsZip()
file.close();
zip.close();
return;
- }
- else if (zip.setCurrentFile("fabric.mod.json"))
- {
- if (!file.open(QIODevice::ReadOnly))
- {
+ } else if (zip.setCurrentFile("fabric.mod.json")) {
+ if (!file.open(QIODevice::ReadOnly)) {
zip.close();
return;
}
@@ -442,11 +368,8 @@ void LocalModParseTask::processAsZip()
file.close();
zip.close();
return;
- }
- else if (zip.setCurrentFile("forgeversion.properties"))
- {
- if (!file.open(QIODevice::ReadOnly))
- {
+ } else if (zip.setCurrentFile("forgeversion.properties")) {
+ if (!file.open(QIODevice::ReadOnly)) {
zip.close();
return;
}
@@ -463,8 +386,7 @@ void LocalModParseTask::processAsZip()
void LocalModParseTask::processAsFolder()
{
QFileInfo mcmod_info(FS::PathCombine(m_modFile.filePath(), "mcmod.info"));
- if (mcmod_info.isFile())
- {
+ if (mcmod_info.isFile()) {
QFile mcmod(mcmod_info.filePath());
if (!mcmod.open(QIODevice::ReadOnly))
return;
@@ -483,10 +405,8 @@ void LocalModParseTask::processAsLitemod()
QuaZipFile file(&zip);
- if (zip.setCurrentFile("litemod.json"))
- {
- if (!file.open(QIODevice::ReadOnly))
- {
+ if (zip.setCurrentFile("litemod.json")) {
+ if (!file.open(QIODevice::ReadOnly)) {
zip.close();
return;
}
@@ -505,8 +425,7 @@ bool LocalModParseTask::abort()
void LocalModParseTask::executeTask()
{
- switch(m_type)
- {
+ switch (m_type) {
case ResourceType::ZIPFILE:
processAsZip();
break;
diff --git a/launcher/minecraft/update/FoldersTask.cpp b/launcher/minecraft/update/FoldersTask.cpp
index 22768bd9..b9ee9d98 100644
--- a/launcher/minecraft/update/FoldersTask.cpp
+++ b/launcher/minecraft/update/FoldersTask.cpp
@@ -1,3 +1,38 @@
+// SPDX-License-Identifier: GPL-3.0-only
+/*
+ * PolyMC - Minecraft Launcher
+ * Copyright (C) 2022 Sefa Eyeoglu
+ *
+ * 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 .
+ *
+ * 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 "FoldersTask.h"
#include "minecraft/MinecraftInstance.h"
#include
diff --git a/launcher/minecraft/update/LibrariesTask.cpp b/launcher/minecraft/update/LibrariesTask.cpp
index aa2bf407..3b129fe1 100644
--- a/launcher/minecraft/update/LibrariesTask.cpp
+++ b/launcher/minecraft/update/LibrariesTask.cpp
@@ -34,7 +34,7 @@ void LibrariesTask::executeTask()
emitFailed(tr("Null jar is specified in the metadata, aborting."));
return false;
}
- auto dls = lib->getDownloads(currentSystem, metacache.get(), errors, localPath);
+ auto dls = lib->getDownloads(inst->runtimeContext(), metacache.get(), errors, localPath);
for(auto dl : dls)
{
downloadJob->addNetAction(dl);
diff --git a/launcher/modplatform/flame/FileResolvingTask.cpp b/launcher/modplatform/flame/FileResolvingTask.cpp
index 058d2471..1e7f5559 100644
--- a/launcher/modplatform/flame/FileResolvingTask.cpp
+++ b/launcher/modplatform/flame/FileResolvingTask.cpp
@@ -9,9 +9,10 @@ Flame::FileResolvingTask::FileResolvingTask(const shared_qobject_ptrabort();
- return true;
+ aborted &= m_dljob->abort();
+ return aborted ? Task::abort() : false;
}
void Flame::FileResolvingTask::executeTask()
diff --git a/launcher/modplatform/legacy_ftb/PackInstallTask.cpp b/launcher/modplatform/legacy_ftb/PackInstallTask.cpp
index 209ad884..06b3788b 100644
--- a/launcher/modplatform/legacy_ftb/PackInstallTask.cpp
+++ b/launcher/modplatform/legacy_ftb/PackInstallTask.cpp
@@ -65,48 +65,42 @@ void PackInstallTask::executeTask()
void PackInstallTask::downloadPack()
{
setStatus(tr("Downloading zip for %1").arg(m_pack.name));
+ setAbortable(false);
+
+ archivePath = QString("%1/%2/%3").arg(m_pack.dir, m_version.replace(".", "_"), m_pack.file);
- auto packoffset = QString("%1/%2/%3").arg(m_pack.dir, m_version.replace(".", "_"), m_pack.file);
- auto entry = APPLICATION->metacache()->resolveEntry("FTBPacks", packoffset);
netJobContainer = new NetJob("Download FTB Pack", m_network);
-
- entry->setStale(true);
QString url;
- if(m_pack.type == PackType::Private)
- {
- url = QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "privatepacks/%1").arg(packoffset);
+ if (m_pack.type == PackType::Private) {
+ url = QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "privatepacks/%1").arg(archivePath);
+ } else {
+ url = QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "modpacks/%1").arg(archivePath);
}
- else
- {
- url = QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "modpacks/%1").arg(packoffset);
- }
- netJobContainer->addNetAction(Net::Download::makeCached(url, entry));
- archivePath = entry->getFullPath();
+ netJobContainer->addNetAction(Net::Download::makeFile(url, archivePath));
connect(netJobContainer.get(), &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded);
connect(netJobContainer.get(), &NetJob::failed, this, &PackInstallTask::onDownloadFailed);
connect(netJobContainer.get(), &NetJob::progress, this, &PackInstallTask::onDownloadProgress);
connect(netJobContainer.get(), &NetJob::aborted, this, &PackInstallTask::onDownloadAborted);
+
netJobContainer->start();
+ setAbortable(true);
progress(1, 4);
}
void PackInstallTask::onDownloadSucceeded()
{
- abortable = false;
unzip();
}
void PackInstallTask::onDownloadFailed(QString reason)
{
- abortable = false;
emitFailed(reason);
}
void PackInstallTask::onDownloadProgress(qint64 current, qint64 total)
{
- abortable = true;
progress(current, total * 4);
setStatus(tr("Downloading zip for %1 (%2%)").arg(m_pack.name).arg(current / 10));
}
@@ -118,8 +112,10 @@ void PackInstallTask::onDownloadAborted()
void PackInstallTask::unzip()
{
- progress(2, 4);
setStatus(tr("Extracting modpack"));
+ setAbortable(false);
+ progress(2, 4);
+
QDir extractDir(m_stagingPath);
m_packZip.reset(new QuaZip(archivePath));
@@ -151,8 +147,8 @@ void PackInstallTask::onUnzipCanceled()
void PackInstallTask::install()
{
- progress(3, 4);
setStatus(tr("Installing modpack"));
+ progress(3, 4);
QDir unzipMcDir(m_stagingPath + "/unzip/minecraft");
if(unzipMcDir.exists())
{
@@ -247,11 +243,12 @@ void PackInstallTask::install()
bool PackInstallTask::abort()
{
- if(abortable)
- {
- return netJobContainer->abort();
+ if (!canAbort()) {
+ return false;
}
- return false;
+
+ netJobContainer->abort();
+ return InstanceTask::abort();
}
}
diff --git a/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp b/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp
index 97ce1dc6..7b112d8f 100644
--- a/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp
+++ b/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp
@@ -58,6 +58,9 @@ PackInstallTask::PackInstallTask(Modpack pack, QString version, QWidget* parent)
bool PackInstallTask::abort()
{
+ if (!canAbort())
+ return false;
+
bool aborted = true;
if (m_net_job)
@@ -65,15 +68,13 @@ bool PackInstallTask::abort()
if (m_mod_id_resolver_task)
aborted &= m_mod_id_resolver_task->abort();
- if (aborted)
- emitAborted();
-
- return aborted;
+ return aborted ? InstanceTask::abort() : false;
}
void PackInstallTask::executeTask()
{
setStatus(tr("Getting the manifest..."));
+ setAbortable(false);
// Find pack version
auto version_it = std::find_if(m_pack.versions.constBegin(), m_pack.versions.constEnd(),
@@ -93,10 +94,12 @@ void PackInstallTask::executeTask()
QObject::connect(netJob, &NetJob::succeeded, this, &PackInstallTask::onManifestDownloadSucceeded);
QObject::connect(netJob, &NetJob::failed, this, &PackInstallTask::onManifestDownloadFailed);
+ QObject::connect(netJob, &NetJob::aborted, this, &PackInstallTask::abort);
QObject::connect(netJob, &NetJob::progress, this, &PackInstallTask::setProgress);
m_net_job = netJob;
+ setAbortable(true);
netJob->start();
}
@@ -130,6 +133,7 @@ void PackInstallTask::onManifestDownloadSucceeded()
void PackInstallTask::resolveMods()
{
setStatus(tr("Resolving mods..."));
+ setAbortable(false);
setProgress(0, 100);
m_file_id_map.clear();
@@ -162,15 +166,16 @@ void PackInstallTask::resolveMods()
connect(m_mod_id_resolver_task.get(), &Flame::FileResolvingTask::succeeded, this, &PackInstallTask::onResolveModsSucceeded);
connect(m_mod_id_resolver_task.get(), &Flame::FileResolvingTask::failed, this, &PackInstallTask::onResolveModsFailed);
+ connect(m_mod_id_resolver_task.get(), &Flame::FileResolvingTask::aborted, this, &PackInstallTask::abort);
connect(m_mod_id_resolver_task.get(), &Flame::FileResolvingTask::progress, this, &PackInstallTask::setProgress);
+ setAbortable(true);
+
m_mod_id_resolver_task->start();
}
void PackInstallTask::onResolveModsSucceeded()
{
- m_abortable = false;
-
QString text;
QList urls;
auto anyBlocked = false;
@@ -209,94 +214,23 @@ void PackInstallTask::onResolveModsSucceeded()
urls);
if (message_dialog->exec() == QDialog::Accepted)
- downloadPack();
+ createInstance();
else
abort();
} else {
- downloadPack();
+ createInstance();
}
}
-void PackInstallTask::downloadPack()
+void PackInstallTask::createInstance()
{
- setStatus(tr("Downloading mods..."));
+ setAbortable(false);
- auto* jobPtr = new NetJob(tr("Mod download"), APPLICATION->network());
- for (auto const& file : m_version.files) {
- if (file.serverOnly || file.url.isEmpty())
- continue;
-
- QFileInfo file_info(file.name);
- auto cacheName = file_info.completeBaseName() + "-" + file.sha1 + "." + file_info.suffix();
-
- auto entry = APPLICATION->metacache()->resolveEntry("ModpacksCHPacks", cacheName);
- entry->setStale(true);
-
- auto relpath = FS::PathCombine("minecraft", file.path, file.name);
- auto path = FS::PathCombine(m_stagingPath, relpath);
-
- if (m_files_to_copy.contains(path)) {
- qWarning() << "Ignoring" << file.url << "as a file of that path is already downloading.";
- continue;
- }
-
- qDebug() << "Will download" << file.url << "to" << path;
- m_files_to_copy[path] = entry->getFullPath();
-
- auto dl = Net::Download::makeCached(file.url, entry);
- if (!file.sha1.isEmpty()) {
- auto rawSha1 = QByteArray::fromHex(file.sha1.toLatin1());
- dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawSha1));
- }
-
- jobPtr->addNetAction(dl);
- }
-
- connect(jobPtr, &NetJob::succeeded, this, &PackInstallTask::onModDownloadSucceeded);
- connect(jobPtr, &NetJob::failed, this, &PackInstallTask::onModDownloadFailed);
- connect(jobPtr, &NetJob::progress, this, &PackInstallTask::setProgress);
-
- m_net_job = jobPtr;
- jobPtr->start();
-
- m_abortable = true;
-}
-
-void PackInstallTask::onModDownloadSucceeded()
-{
- m_net_job.reset();
- install();
-}
-
-void PackInstallTask::install()
-{
- setStatus(tr("Copying modpack files..."));
- setProgress(0, m_files_to_copy.size());
- QCoreApplication::processEvents();
-
- m_abortable = false;
-
- int i = 0;
- for (auto iter = m_files_to_copy.constBegin(); iter != m_files_to_copy.constEnd(); iter++) {
- auto& to = iter.key();
- auto& from = iter.value();
- FS::copy fileCopyOperation(from, to);
- if (!fileCopyOperation()) {
- qWarning() << "Failed to copy" << from << "to" << to;
- emitFailed(tr("Failed to copy files"));
- return;
- }
-
- setProgress(i++, m_files_to_copy.size());
- QCoreApplication::processEvents();
- }
-
- setStatus(tr("Installing modpack..."));
+ setStatus(tr("Creating the instance..."));
QCoreApplication::processEvents();
auto instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg");
auto instanceSettings = std::make_shared(instanceConfigPath);
- instanceSettings->suspendSave();
MinecraftInstance instance(m_globalSettings, instanceSettings, m_stagingPath);
auto components = instance.getPackProfile();
@@ -337,8 +271,55 @@ void PackInstallTask::install()
instance.setName(name());
instance.setIconKey(m_instIcon);
instance.setManagedPack("modpacksch", QString::number(m_pack.id), m_pack.name, QString::number(m_version.id), m_version.name);
- instanceSettings->resumeSave();
+ instance.saveNow();
+
+ onCreateInstanceSucceeded();
+}
+
+void PackInstallTask::onCreateInstanceSucceeded()
+{
+ downloadPack();
+}
+
+void PackInstallTask::downloadPack()
+{
+ setStatus(tr("Downloading mods..."));
+ setAbortable(false);
+
+ auto* jobPtr = new NetJob(tr("Mod download"), APPLICATION->network());
+ for (auto const& file : m_version.files) {
+ if (file.serverOnly || file.url.isEmpty())
+ continue;
+
+ auto path = FS::PathCombine(m_stagingPath, ".minecraft", file.path, file.name);
+ qDebug() << "Will try to download" << file.url << "to" << path;
+
+ QFileInfo file_info(file.name);
+
+ auto dl = Net::Download::makeFile(file.url, path);
+ if (!file.sha1.isEmpty()) {
+ auto rawSha1 = QByteArray::fromHex(file.sha1.toLatin1());
+ dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawSha1));
+ }
+
+ jobPtr->addNetAction(dl);
+ }
+
+ connect(jobPtr, &NetJob::succeeded, this, &PackInstallTask::onModDownloadSucceeded);
+ connect(jobPtr, &NetJob::failed, this, &PackInstallTask::onModDownloadFailed);
+ connect(jobPtr, &NetJob::aborted, this, &PackInstallTask::abort);
+ connect(jobPtr, &NetJob::progress, this, &PackInstallTask::setProgress);
+
+ m_net_job = jobPtr;
+
+ setAbortable(true);
+ jobPtr->start();
+}
+
+void PackInstallTask::onModDownloadSucceeded()
+{
+ m_net_job.reset();
emitSucceeded();
}
@@ -352,6 +333,10 @@ void PackInstallTask::onResolveModsFailed(QString reason)
m_net_job.reset();
emitFailed(reason);
}
+void PackInstallTask::onCreateInstanceFailed(QString reason)
+{
+ emitFailed(reason);
+}
void PackInstallTask::onModDownloadFailed(QString reason)
{
m_net_job.reset();
diff --git a/launcher/modplatform/modpacksch/FTBPackInstallTask.h b/launcher/modplatform/modpacksch/FTBPackInstallTask.h
index e63ca0df..7c6fbeb9 100644
--- a/launcher/modplatform/modpacksch/FTBPackInstallTask.h
+++ b/launcher/modplatform/modpacksch/FTBPackInstallTask.h
@@ -56,7 +56,6 @@ public:
explicit PackInstallTask(Modpack pack, QString version, QWidget* parent = nullptr);
~PackInstallTask() override = default;
- bool canAbort() const override { return m_abortable; }
bool abort() override;
protected:
@@ -65,20 +64,20 @@ protected:
private slots:
void onManifestDownloadSucceeded();
void onResolveModsSucceeded();
+ void onCreateInstanceSucceeded();
void onModDownloadSucceeded();
void onManifestDownloadFailed(QString reason);
void onResolveModsFailed(QString reason);
+ void onCreateInstanceFailed(QString reason);
void onModDownloadFailed(QString reason);
private:
void resolveMods();
+ void createInstance();
void downloadPack();
- void install();
private:
- bool m_abortable = true;
-
NetJob::Ptr m_net_job = nullptr;
shared_qobject_ptr m_mod_id_resolver_task = nullptr;
diff --git a/launcher/modplatform/packwiz/Packwiz.cpp b/launcher/modplatform/packwiz/Packwiz.cpp
index c3561093..b1fe963e 100644
--- a/launcher/modplatform/packwiz/Packwiz.cpp
+++ b/launcher/modplatform/packwiz/Packwiz.cpp
@@ -1,20 +1,20 @@
// SPDX-License-Identifier: GPL-3.0-only
/*
-* PolyMC - Minecraft Launcher
-* Copyright (c) 2022 flowln
-*
-* 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 .
-*/
+ * PolyMC - Minecraft Launcher
+ * Copyright (c) 2022 flowln
+ *
+ * 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 .
+ */
#include "Packwiz.h"
@@ -22,9 +22,7 @@
#include
#include
-#include "toml.h"
-#include "FileSystem.h"
-
+#include
#include "minecraft/mod/Mod.h"
#include "modplatform/ModIndex.h"
@@ -44,7 +42,7 @@ auto getRealIndexName(QDir& index_dir, QString normalized_fname, bool should_fin
}
}
- if(should_find_match && !QString::compare(normalized_fname, real_fname, Qt::CaseSensitive)){
+ if (should_find_match && !QString::compare(normalized_fname, real_fname, Qt::CaseSensitive)) {
qCritical() << "Could not find a match for a valid metadata file!";
qCritical() << "File: " << normalized_fname;
return {};
@@ -57,7 +55,7 @@ auto getRealIndexName(QDir& index_dir, QString normalized_fname, bool should_fin
// Helpers
static inline auto indexFileName(QString const& mod_slug) -> QString
{
- if(mod_slug.endsWith(".pw.toml"))
+ if (mod_slug.endsWith(".pw.toml"))
return mod_slug;
return QString("%1.pw.toml").arg(mod_slug);
}
@@ -65,32 +63,28 @@ static inline auto indexFileName(QString const& mod_slug) -> QString
static ModPlatform::ProviderCapabilities ProviderCaps;
// Helper functions for extracting data from the TOML file
-auto stringEntry(toml_table_t* parent, const char* entry_name) -> QString
+auto stringEntry(toml::table table, const std::string entry_name) -> QString
{
- toml_datum_t var = toml_string_in(parent, entry_name);
- if (!var.ok) {
- qCritical() << QString("Failed to read str property '%1' in mod metadata.").arg(entry_name);
+ auto node = table[entry_name];
+ if (!node) {
+ qCritical() << QString::fromStdString("Failed to read str property '" + entry_name + "' in mod metadata.");
return {};
}
- QString tmp = var.u.s;
- free(var.u.s);
-
- return tmp;
+ return QString::fromStdString(node.value_or(""));
}
-auto intEntry(toml_table_t* parent, const char* entry_name) -> int
+auto intEntry(toml::table table, const std::string entry_name) -> int
{
- toml_datum_t var = toml_int_in(parent, entry_name);
- if (!var.ok) {
- qCritical() << QString("Failed to read int property '%1' in mod metadata.").arg(entry_name);
+ auto node = table[entry_name];
+ if (!node) {
+ qCritical() << QString::fromStdString("Failed to read int property '" + entry_name + "' in mod metadata.");
return {};
}
- return var.u.i;
+ return node.value_or(0);
}
-
auto V1::createModFormat(QDir& index_dir, ModPlatform::IndexedPack& mod_pack, ModPlatform::IndexedVersion& mod_version) -> Mod
{
Mod mod;
@@ -99,10 +93,9 @@ auto V1::createModFormat(QDir& index_dir, ModPlatform::IndexedPack& mod_pack, Mo
mod.name = mod_pack.name;
mod.filename = mod_version.fileName;
- if(mod_pack.provider == ModPlatform::Provider::FLAME){
+ if (mod_pack.provider == ModPlatform::Provider::FLAME) {
mod.mode = "metadata:curseforge";
- }
- else {
+ } else {
mod.mode = "url";
mod.url = mod_version.downloadUrl;
}
@@ -120,8 +113,8 @@ auto V1::createModFormat(QDir& index_dir, ModPlatform::IndexedPack& mod_pack, Mo
auto V1::createModFormat(QDir& index_dir, ::Mod& internal_mod, QString slug) -> Mod
{
// Try getting metadata if it exists
- Mod mod { getIndexForMod(index_dir, slug) };
- if(mod.isValid())
+ Mod mod{ getIndexForMod(index_dir, slug) };
+ if (mod.isValid())
return mod;
qWarning() << QString("Tried to create mod metadata with a Mod without metadata!");
@@ -131,7 +124,7 @@ auto V1::createModFormat(QDir& index_dir, ::Mod& internal_mod, QString slug) ->
void V1::updateModIndex(QDir& index_dir, Mod& mod)
{
- if(!mod.isValid()){
+ if (!mod.isValid()) {
qCritical() << QString("Tried to update metadata of an invalid mod!");
return;
}
@@ -150,7 +143,9 @@ void V1::updateModIndex(QDir& index_dir, Mod& mod)
// TODO: We should do more stuff here, as the user is likely trying to
// override a file. In this case, check versions and ask the user what
// they want to do!
- if (index_file.exists()) { index_file.remove(); }
+ if (index_file.exists()) {
+ index_file.remove();
+ }
if (!index_file.open(QIODevice::ReadWrite)) {
qCritical() << QString("Could not open file %1!").arg(indexFileName(mod.name));
@@ -174,15 +169,15 @@ void V1::updateModIndex(QDir& index_dir, Mod& mod)
in_stream << QString("\n[update]\n");
in_stream << QString("[update.%1]\n").arg(ProviderCaps.name(mod.provider));
- switch(mod.provider){
- case(ModPlatform::Provider::FLAME):
- in_stream << QString("file-id = %1\n").arg(mod.file_id.toString());
- in_stream << QString("project-id = %1\n").arg(mod.project_id.toString());
- break;
- case(ModPlatform::Provider::MODRINTH):
- addToStream("mod-id", mod.mod_id().toString());
- addToStream("version", mod.version().toString());
- break;
+ switch (mod.provider) {
+ case (ModPlatform::Provider::FLAME):
+ in_stream << QString("file-id = %1\n").arg(mod.file_id.toString());
+ in_stream << QString("project-id = %1\n").arg(mod.project_id.toString());
+ break;
+ case (ModPlatform::Provider::MODRINTH):
+ addToStream("mod-id", mod.mod_id().toString());
+ addToStream("version", mod.version().toString());
+ break;
}
}
@@ -230,27 +225,25 @@ auto V1::getIndexForMod(QDir& index_dir, QString slug) -> Mod
if (real_fname.isEmpty())
return {};
- QFile index_file(index_dir.absoluteFilePath(real_fname));
-
- if (!index_file.open(QIODevice::ReadOnly)) {
- qWarning() << QString("Failed to open mod metadata for %1").arg(slug);
+ toml::table table;
+#if TOML_EXCEPTIONS
+ try {
+ table = toml::parse_file(index_dir.absoluteFilePath(real_fname).toStdString());
+ } catch (const toml::parse_error& err) {
+ qWarning() << QString("Could not open file %1!").arg(normalized_fname);
+ qWarning() << "Reason: " << QString(err.what());
return {};
}
-
- toml_table_t* table = nullptr;
-
- // NOLINTNEXTLINE(modernize-avoid-c-arrays)
- char errbuf[200];
- auto file_bytearray = index_file.readAll();
- table = toml_parse(file_bytearray.data(), errbuf, sizeof(errbuf));
-
- index_file.close();
-
+#else
+ table = toml::parse_file(index_dir.absoluteFilePath(real_fname).toStdString());
if (!table) {
qWarning() << QString("Could not open file %1!").arg(normalized_fname);
- qWarning() << "Reason: " << QString(errbuf);
+ qWarning() << "Reason: " << QString(table.error().what());
return {};
}
+#endif
+
+ // index_file.close();
mod.slug = slug;
@@ -261,45 +254,42 @@ auto V1::getIndexForMod(QDir& index_dir, QString slug) -> Mod
}
{ // [download] info
- toml_table_t* download_table = toml_table_in(table, "download");
+ auto download_table = table["download"].as_table();
if (!download_table) {
qCritical() << QString("No [download] section found on mod metadata!");
return {};
}
- mod.mode = stringEntry(download_table, "mode");
- mod.url = stringEntry(download_table, "url");
- mod.hash_format = stringEntry(download_table, "hash-format");
- mod.hash = stringEntry(download_table, "hash");
+ mod.mode = stringEntry(*download_table, "mode");
+ mod.url = stringEntry(*download_table, "url");
+ mod.hash_format = stringEntry(*download_table, "hash-format");
+ mod.hash = stringEntry(*download_table, "hash");
}
- { // [update] info
+ { // [update] info
using Provider = ModPlatform::Provider;
- toml_table_t* update_table = toml_table_in(table, "update");
- if (!update_table) {
+ auto update_table = table["update"];
+ if (!update_table || !update_table.is_table()) {
qCritical() << QString("No [update] section found on mod metadata!");
return {};
}
- toml_table_t* mod_provider_table = nullptr;
- if ((mod_provider_table = toml_table_in(update_table, ProviderCaps.name(Provider::FLAME)))) {
+ toml::table* mod_provider_table = nullptr;
+ if ((mod_provider_table = update_table[ProviderCaps.name(Provider::FLAME)].as_table())) {
mod.provider = Provider::FLAME;
- mod.file_id = intEntry(mod_provider_table, "file-id");
- mod.project_id = intEntry(mod_provider_table, "project-id");
- } else if ((mod_provider_table = toml_table_in(update_table, ProviderCaps.name(Provider::MODRINTH)))) {
+ mod.file_id = intEntry(*mod_provider_table, "file-id");
+ mod.project_id = intEntry(*mod_provider_table, "project-id");
+ } else if ((mod_provider_table = update_table[ProviderCaps.name(Provider::MODRINTH)].as_table())) {
mod.provider = Provider::MODRINTH;
- mod.mod_id() = stringEntry(mod_provider_table, "mod-id");
- mod.version() = stringEntry(mod_provider_table, "version");
+ mod.mod_id() = stringEntry(*mod_provider_table, "mod-id");
+ mod.version() = stringEntry(*mod_provider_table, "version");
} else {
qCritical() << QString("No mod provider on mod metadata!");
return {};
}
-
}
- toml_free(table);
-
return mod;
}
diff --git a/launcher/net/HttpMetaCache.cpp b/launcher/net/HttpMetaCache.cpp
index 9606ddb6..42198b71 100644
--- a/launcher/net/HttpMetaCache.cpp
+++ b/launcher/net/HttpMetaCache.cpp
@@ -162,6 +162,18 @@ auto HttpMetaCache::evictEntry(MetaEntryPtr entry) -> bool
return true;
}
+void HttpMetaCache::evictAll()
+{
+ for (QString& base : m_entries.keys()) {
+ EntryMap& map = m_entries[base];
+ qDebug() << "Evicting base" << base;
+ for (MetaEntryPtr entry : map.entry_list) {
+ if (!evictEntry(entry))
+ qWarning() << "Unexpected missing cache entry" << entry->basePath;
+ }
+ }
+}
+
auto HttpMetaCache::staleEntry(QString base, QString resource_path) -> MetaEntryPtr
{
auto foo = new MetaEntry();
diff --git a/launcher/net/HttpMetaCache.h b/launcher/net/HttpMetaCache.h
index c0b12318..2a07d65a 100644
--- a/launcher/net/HttpMetaCache.h
+++ b/launcher/net/HttpMetaCache.h
@@ -113,6 +113,7 @@ class HttpMetaCache : public QObject {
// evict selected entry from cache
auto evictEntry(MetaEntryPtr entry) -> bool;
+ void evictAll();
void addBase(QString base, QString base_root);
diff --git a/launcher/resources/multimc/multimc.qrc b/launcher/resources/multimc/multimc.qrc
index 2337acd6..3f3d22fc 100644
--- a/launcher/resources/multimc/multimc.qrc
+++ b/launcher/resources/multimc/multimc.qrc
@@ -311,6 +311,6 @@
scalable/instances/fox.svgscalable/instances/bee.svg
- scalable/instances/polymc.svg
+ scalable/instances/prismlauncher.svg
diff --git a/launcher/resources/multimc/scalable/instances/polymc.svg b/launcher/resources/multimc/scalable/instances/polymc.svg
deleted file mode 100644
index c192d503..00000000
--- a/launcher/resources/multimc/scalable/instances/polymc.svg
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
diff --git a/launcher/resources/multimc/scalable/instances/prismlauncher.svg b/launcher/resources/multimc/scalable/instances/prismlauncher.svg
new file mode 100644
index 00000000..93493aab
--- /dev/null
+++ b/launcher/resources/multimc/scalable/instances/prismlauncher.svg
@@ -0,0 +1,18 @@
+
+
+
diff --git a/launcher/settings/INISettingsObject.cpp b/launcher/settings/INISettingsObject.cpp
index 12513403..da962ee9 100644
--- a/launcher/settings/INISettingsObject.cpp
+++ b/launcher/settings/INISettingsObject.cpp
@@ -16,7 +16,30 @@
#include "INISettingsObject.h"
#include "Setting.h"
-INISettingsObject::INISettingsObject(const QString &path, QObject *parent)
+#include
+#include
+
+INISettingsObject::INISettingsObject(QStringList paths, QObject *parent)
+ : SettingsObject(parent)
+{
+ auto first_path = paths.constFirst();
+ for (auto path : paths) {
+ if (!QFile::exists(path))
+ continue;
+
+ if (path != first_path && QFile::exists(path)) {
+ // Copy the fallback to the preferred path.
+ QFile::copy(path, first_path);
+ qDebug() << "Copied settings from" << path << "to" << first_path;
+ break;
+ }
+ }
+
+ m_filePath = first_path;
+ m_ini.loadFile(first_path);
+}
+
+INISettingsObject::INISettingsObject(QString path, QObject* parent)
: SettingsObject(parent)
{
m_filePath = path;
diff --git a/launcher/settings/INISettingsObject.h b/launcher/settings/INISettingsObject.h
index 26cc32e5..d2f448a9 100644
--- a/launcher/settings/INISettingsObject.h
+++ b/launcher/settings/INISettingsObject.h
@@ -28,7 +28,10 @@ class INISettingsObject : public SettingsObject
{
Q_OBJECT
public:
- explicit INISettingsObject(const QString &path, QObject *parent = 0);
+ /** 'paths' is a list of INI files to try, in order, for fallback support. */
+ explicit INISettingsObject(QStringList paths, QObject* parent = nullptr);
+
+ explicit INISettingsObject(QString path, QObject* parent = nullptr);
/*!
* \brief Gets the path to the INI file.
diff --git a/launcher/settings/Setting.h b/launcher/settings/Setting.h
index 9a5b8210..86007c13 100644
--- a/launcher/settings/Setting.h
+++ b/launcher/settings/Setting.h
@@ -33,7 +33,7 @@ public:
* Construct a Setting
*
* Synonyms are all the possible names used in the settings object, in order of preference.
- * First synonym is the ID, which identifies the setting in PolyMC.
+ * First synonym is the ID, which identifies the setting in Prism Launcher.
*
* defVal is the default value that will be returned when the settings object
* doesn't have any value for this setting.
diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp
index f570c4e5..5af10ae4 100644
--- a/launcher/ui/MainWindow.cpp
+++ b/launcher/ui/MainWindow.cpp
@@ -161,7 +161,7 @@ public:
QString result;
result = QApplication::translate("MainWindow", m_text);
if(result.contains("%1")) {
- result = result.arg(BuildConfig.LAUNCHER_NAME);
+ result = result.arg(BuildConfig.LAUNCHER_DISPLAYNAME);
}
m_contained->setText(result);
}
@@ -170,7 +170,7 @@ public:
QString result;
result = QApplication::translate("MainWindow", m_tooltip);
if(result.contains("%1")) {
- result = result.arg(BuildConfig.LAUNCHER_NAME);
+ result = result.arg(BuildConfig.LAUNCHER_DISPLAYNAME);
}
m_contained->setToolTip(result);
}
@@ -229,19 +229,13 @@ public:
TranslatedAction actionRenameInstance;
TranslatedAction actionChangeInstGroup;
TranslatedAction actionChangeInstIcon;
- TranslatedAction actionEditInstNotes;
TranslatedAction actionEditInstance;
- TranslatedAction actionWorlds;
- TranslatedAction actionMods;
TranslatedAction actionViewSelectedInstFolder;
- TranslatedAction actionViewSelectedMCFolder;
TranslatedAction actionDeleteInstance;
- TranslatedAction actionConfig_Folder;
TranslatedAction actionCAT;
TranslatedAction actionCopyInstance;
TranslatedAction actionLaunchInstanceOffline;
TranslatedAction actionLaunchInstanceDemo;
- TranslatedAction actionScreenshots;
TranslatedAction actionExportInstance;
QVector all_actions;
@@ -258,6 +252,7 @@ public:
QMenu * helpMenu = nullptr;
TranslatedToolButton helpMenuButton;
+ TranslatedAction actionClearMetadata;
TranslatedAction actionReportBug;
TranslatedAction actionDISCORD;
TranslatedAction actionMATRIX;
@@ -347,6 +342,13 @@ public:
actionUndoTrashInstance->setShortcut(QKeySequence("Ctrl+Z"));
all_actions.append(&actionUndoTrashInstance);
+ actionClearMetadata = TranslatedAction(MainWindow);
+ actionClearMetadata->setObjectName(QStringLiteral("actionClearMetadata"));
+ actionClearMetadata->setIcon(APPLICATION->getThemedIcon("refresh"));
+ actionClearMetadata.setTextId(QT_TRANSLATE_NOOP("MainWindow", "&Clear Metadata Cache"));
+ actionClearMetadata.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Clear cached metadata"));
+ all_actions.append(&actionClearMetadata);
+
if (!BuildConfig.BUG_TRACKER_URL.isEmpty()) {
actionReportBug = TranslatedAction(MainWindow);
actionReportBug->setObjectName(QStringLiteral("actionReportBug"));
@@ -445,6 +447,8 @@ public:
helpMenu = new QMenu(MainWindow);
helpMenu->setToolTipsVisible(true);
+ helpMenu->addAction(actionClearMetadata);
+
if (!BuildConfig.BUG_TRACKER_URL.isEmpty()) {
helpMenu->addAction(actionReportBug);
}
@@ -505,16 +509,8 @@ public:
fileMenu->addAction(actionCloseWindow);
fileMenu->addSeparator();
fileMenu->addAction(actionEditInstance);
- fileMenu->addAction(actionEditInstNotes);
- fileMenu->addAction(actionMods);
- fileMenu->addAction(actionWorlds);
- fileMenu->addAction(actionScreenshots);
fileMenu->addAction(actionChangeInstGroup);
- fileMenu->addSeparator();
- fileMenu->addAction(actionViewSelectedMCFolder);
- fileMenu->addAction(actionConfig_Folder);
fileMenu->addAction(actionViewSelectedInstFolder);
- fileMenu->addSeparator();
fileMenu->addAction(actionExportInstance);
fileMenu->addAction(actionDeleteInstance);
fileMenu->addAction(actionCopyInstance);
@@ -537,6 +533,8 @@ public:
helpMenu = menuBar->addMenu(tr("&Help"));
helpMenu->setSeparatorsCollapsible(false);
+ helpMenu->addAction(actionClearMetadata);
+ helpMenu->addSeparator();
helpMenu->addAction(actionAbout);
helpMenu->addAction(actionOpenWiki);
helpMenu->addAction(actionNewsMenuBar);
@@ -586,13 +584,7 @@ public:
void setInstanceActionsEnabled(bool enabled)
{
actionEditInstance->setEnabled(enabled);
- actionEditInstNotes->setEnabled(enabled);
- actionMods->setEnabled(enabled);
- actionWorlds->setEnabled(enabled);
- actionScreenshots->setEnabled(enabled);
actionChangeInstGroup->setEnabled(enabled);
- actionViewSelectedMCFolder->setEnabled(enabled);
- actionConfig_Folder->setEnabled(enabled);
actionViewSelectedInstFolder->setEnabled(enabled);
actionExportInstance->setEnabled(enabled);
actionDeleteInstance->setEnabled(enabled);
@@ -687,35 +679,11 @@ public:
actionEditInstance = TranslatedAction(MainWindow);
actionEditInstance->setObjectName(QStringLiteral("actionEditInstance"));
- actionEditInstance.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Edit Inst&ance..."));
+ actionEditInstance.setTextId(QT_TRANSLATE_NOOP("MainWindow", "&Edit..."));
actionEditInstance.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Change the instance settings, mods and versions."));
actionEditInstance->setShortcut(QKeySequence(tr("Ctrl+I")));
all_actions.append(&actionEditInstance);
- actionEditInstNotes = TranslatedAction(MainWindow);
- actionEditInstNotes->setObjectName(QStringLiteral("actionEditInstNotes"));
- actionEditInstNotes.setTextId(QT_TRANSLATE_NOOP("MainWindow", "E&dit Notes..."));
- actionEditInstNotes.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Edit the notes for the selected instance."));
- all_actions.append(&actionEditInstNotes);
-
- actionMods = TranslatedAction(MainWindow);
- actionMods->setObjectName(QStringLiteral("actionMods"));
- actionMods.setTextId(QT_TRANSLATE_NOOP("MainWindow", "View &Mods"));
- actionMods.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "View the mods of this instance."));
- all_actions.append(&actionMods);
-
- actionWorlds = TranslatedAction(MainWindow);
- actionWorlds->setObjectName(QStringLiteral("actionWorlds"));
- actionWorlds.setTextId(QT_TRANSLATE_NOOP("MainWindow", "&View Worlds"));
- actionWorlds.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "View the worlds of this instance."));
- all_actions.append(&actionWorlds);
-
- actionScreenshots = TranslatedAction(MainWindow);
- actionScreenshots->setObjectName(QStringLiteral("actionScreenshots"));
- actionScreenshots.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Manage &Screenshots"));
- actionScreenshots.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "View and upload screenshots for this instance."));
- all_actions.append(&actionScreenshots);
-
actionChangeInstGroup = TranslatedAction(MainWindow);
actionChangeInstGroup->setObjectName(QStringLiteral("actionChangeInstGroup"));
actionChangeInstGroup.setTextId(QT_TRANSLATE_NOOP("MainWindow", "&Change Group..."));
@@ -723,38 +691,22 @@ public:
actionChangeInstGroup->setShortcut(QKeySequence(tr("Ctrl+G")));
all_actions.append(&actionChangeInstGroup);
- actionViewSelectedMCFolder = TranslatedAction(MainWindow);
- actionViewSelectedMCFolder->setObjectName(QStringLiteral("actionViewSelectedMCFolder"));
- actionViewSelectedMCFolder.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Minec&raft Folder"));
- actionViewSelectedMCFolder.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open the selected instance's Minecraft folder in a file browser."));
- actionViewSelectedMCFolder->setShortcut(QKeySequence(tr("Ctrl+M")));
- all_actions.append(&actionViewSelectedMCFolder);
-
- actionConfig_Folder = TranslatedAction(MainWindow);
- actionConfig_Folder->setObjectName(QStringLiteral("actionConfig_Folder"));
- actionConfig_Folder.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Confi&g Folder"));
- actionConfig_Folder.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open the instance's config folder."));
- // Qt on macOS is "smart" and will eat up this action when added to the menu bar because it starts with the word "config"...
- // Docs: https://doc.qt.io/qt-5/qmenubar.html#qmenubar-as-a-global-menu-bar
- actionConfig_Folder->setMenuRole(QAction::NoRole);
- all_actions.append(&actionConfig_Folder);
-
actionViewSelectedInstFolder = TranslatedAction(MainWindow);
actionViewSelectedInstFolder->setObjectName(QStringLiteral("actionViewSelectedInstFolder"));
- actionViewSelectedInstFolder.setTextId(QT_TRANSLATE_NOOP("MainWindow", "&Instance Folder"));
+ actionViewSelectedInstFolder.setTextId(QT_TRANSLATE_NOOP("MainWindow", "&Folder"));
actionViewSelectedInstFolder.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Open the selected instance's root folder in a file browser."));
all_actions.append(&actionViewSelectedInstFolder);
actionExportInstance = TranslatedAction(MainWindow);
actionExportInstance->setObjectName(QStringLiteral("actionExportInstance"));
- actionExportInstance.setTextId(QT_TRANSLATE_NOOP("MainWindow", "E&xport Instance..."));
+ actionExportInstance.setTextId(QT_TRANSLATE_NOOP("MainWindow", "E&xport..."));
actionExportInstance.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Export the selected instance as a zip file."));
actionExportInstance->setShortcut(QKeySequence(tr("Ctrl+E")));
all_actions.append(&actionExportInstance);
actionDeleteInstance = TranslatedAction(MainWindow);
actionDeleteInstance->setObjectName(QStringLiteral("actionDeleteInstance"));
- actionDeleteInstance.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Dele&te Instance"));
+ actionDeleteInstance.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Dele&te"));
actionDeleteInstance.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Delete the selected instance."));
actionDeleteInstance->setShortcuts({QKeySequence(tr("Backspace")), QKeySequence::Delete});
actionDeleteInstance->setAutoRepeat(false);
@@ -763,7 +715,7 @@ public:
actionCopyInstance = TranslatedAction(MainWindow);
actionCopyInstance->setObjectName(QStringLiteral("actionCopyInstance"));
actionCopyInstance->setIcon(APPLICATION->getThemedIcon("copy"));
- actionCopyInstance.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Cop&y Instance..."));
+ actionCopyInstance.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Cop&y..."));
actionCopyInstance.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Copy the selected instance."));
actionCopyInstance->setShortcut(QKeySequence(tr("Ctrl+D")));
all_actions.append(&actionCopyInstance);
@@ -792,26 +744,15 @@ public:
instanceToolBar->addSeparator();
instanceToolBar->addAction(actionLaunchInstance);
- instanceToolBar->addAction(actionLaunchInstanceOffline);
instanceToolBar->addAction(actionKillInstance);
instanceToolBar->addSeparator();
instanceToolBar->addAction(actionEditInstance);
- instanceToolBar->addAction(actionEditInstNotes);
- instanceToolBar->addAction(actionMods);
- instanceToolBar->addAction(actionWorlds);
- instanceToolBar->addAction(actionScreenshots);
instanceToolBar->addAction(actionChangeInstGroup);
- instanceToolBar->addSeparator();
-
- instanceToolBar->addAction(actionViewSelectedMCFolder);
- instanceToolBar->addAction(actionConfig_Folder);
instanceToolBar->addAction(actionViewSelectedInstFolder);
- instanceToolBar->addSeparator();
-
instanceToolBar->addAction(actionExportInstance);
instanceToolBar->addAction(actionDeleteInstance);
instanceToolBar->addAction(actionCopyInstance);
@@ -830,7 +771,7 @@ public:
MainWindow->setWindowIcon(APPLICATION->getThemedIcon("logo"));
MainWindow->setWindowTitle(APPLICATION->applicationDisplayName());
#ifndef QT_NO_ACCESSIBILITY
- MainWindow->setAccessibleName(BuildConfig.LAUNCHER_NAME);
+ MainWindow->setAccessibleName(BuildConfig.LAUNCHER_DISPLAYNAME);
#endif
createMainToolbarActions(MainWindow);
@@ -1147,7 +1088,7 @@ void MainWindow::showInstanceContextMenu(const QPoint &pos)
{
auto group = view->groupNameAt(pos);
- QAction *actionVoid = new QAction(BuildConfig.LAUNCHER_NAME, this);
+ QAction *actionVoid = new QAction(BuildConfig.LAUNCHER_DISPLAYNAME, this);
actionVoid->setEnabled(false);
QAction *actionCreateInstance = new QAction(tr("Create instance"), this);
@@ -1197,7 +1138,6 @@ void MainWindow::updateMainToolBar()
void MainWindow::updateToolsMenu()
{
QToolButton *launchButton = dynamic_cast(ui->instanceToolBar->widgetForAction(ui->actionLaunchInstance));
- QToolButton *launchOfflineButton = dynamic_cast(ui->instanceToolBar->widgetForAction(ui->actionLaunchInstanceOffline));
bool currentInstanceRunning = m_selectedInstance && m_selectedInstance->isRunning();
@@ -1206,9 +1146,7 @@ void MainWindow::updateToolsMenu()
ui->actionLaunchInstanceDemo->setDisabled(!m_selectedInstance || currentInstanceRunning);
QMenu *launchMenu = ui->actionLaunchInstance->menu();
- QMenu *launchOfflineMenu = ui->actionLaunchInstanceOffline->menu();
launchButton->setPopupMode(QToolButton::MenuButtonPopup);
- launchOfflineButton->setPopupMode(QToolButton::MenuButtonPopup);
if (launchMenu)
{
launchMenu->clear();
@@ -1217,19 +1155,12 @@ void MainWindow::updateToolsMenu()
{
launchMenu = new QMenu(this);
}
- if (launchOfflineMenu) {
- launchOfflineMenu->clear();
- }
- else
- {
- launchOfflineMenu = new QMenu(this);
- }
QAction *normalLaunch = launchMenu->addAction(tr("Launch"));
normalLaunch->setShortcut(QKeySequence::Open);
- QAction *normalLaunchOffline = launchOfflineMenu->addAction(tr("Launch Offline"));
+ QAction *normalLaunchOffline = launchMenu->addAction(tr("Launch Offline"));
normalLaunchOffline->setShortcut(QKeySequence(tr("Ctrl+Shift+O")));
- QAction *normalLaunchDemo = launchOfflineMenu->addAction(tr("Launch Demo"));
+ QAction *normalLaunchDemo = launchMenu->addAction(tr("Launch Demo"));
normalLaunchDemo->setShortcut(QKeySequence(tr("Ctrl+Alt+O")));
if (m_selectedInstance)
{
@@ -1262,11 +1193,10 @@ void MainWindow::updateToolsMenu()
QString profilersTitle = tr("Profilers");
launchMenu->addSeparator()->setText(profilersTitle);
- launchOfflineMenu->addSeparator()->setText(profilersTitle);
for (auto profiler : APPLICATION->profilers().values())
{
QAction *profilerAction = launchMenu->addAction(profiler->name());
- QAction *profilerOfflineAction = launchOfflineMenu->addAction(profiler->name());
+ QAction *profilerOfflineAction = launchMenu->addAction(tr("%1 Offline").arg(profiler->name()));
QString error;
if (!profiler->check(&error))
{
@@ -1297,7 +1227,6 @@ void MainWindow::updateToolsMenu()
}
}
ui->actionLaunchInstance->setMenu(launchMenu);
- ui->actionLaunchInstanceOffline->setMenu(launchOfflineMenu);
}
void MainWindow::repopulateAccountsMenu()
@@ -1903,15 +1832,6 @@ void MainWindow::on_actionViewCentralModsFolder_triggered()
DesktopServices::openDirectory(APPLICATION->settings()->get("CentralModsDir").toString(), true);
}
-void MainWindow::on_actionConfig_Folder_triggered()
-{
- if (m_selectedInstance)
- {
- QString str = m_selectedInstance->instanceConfigFolder();
- DesktopServices::openDirectory(QDir(str).absolutePath());
- }
-}
-
void MainWindow::checkForUpdates()
{
if(BuildConfig.UPDATER_ENABLED)
@@ -1940,36 +1860,16 @@ void MainWindow::globalSettingsClosed()
updateToolsMenu();
updateStatusCenter();
// This needs to be done to prevent UI elements disappearing in the event the config is changed
- // but PolyMC exits abnormally, causing the window state to never be saved:
+ // but Prism Launcher exits abnormally, causing the window state to never be saved:
APPLICATION->settings()->set("MainWindowState", saveState().toBase64());
update();
}
-void MainWindow::on_actionEditInstNotes_triggered()
-{
- APPLICATION->showInstanceWindow(m_selectedInstance, "notes");
-}
-
-void MainWindow::on_actionWorlds_triggered()
-{
- APPLICATION->showInstanceWindow(m_selectedInstance, "worlds");
-}
-
-void MainWindow::on_actionMods_triggered()
-{
- APPLICATION->showInstanceWindow(m_selectedInstance, "mods");
-}
-
void MainWindow::on_actionEditInstance_triggered()
{
APPLICATION->showInstanceWindow(m_selectedInstance);
}
-void MainWindow::on_actionScreenshots_triggered()
-{
- APPLICATION->showInstanceWindow(m_selectedInstance, "screenshots");
-}
-
void MainWindow::on_actionManageAccounts_triggered()
{
APPLICATION->ShowGlobalSettings(this, "accounts");
@@ -1980,6 +1880,11 @@ void MainWindow::on_actionReportBug_triggered()
DesktopServices::openUrl(QUrl(BuildConfig.BUG_TRACKER_URL));
}
+void MainWindow::on_actionClearMetadata_triggered()
+{
+ APPLICATION->metacache()->evictAll();
+}
+
void MainWindow::on_actionOpenWiki_triggered()
{
DesktopServices::openUrl(QUrl(BuildConfig.HELP_URL.arg("")));
@@ -2058,20 +1963,6 @@ void MainWindow::on_actionViewSelectedInstFolder_triggered()
}
}
-void MainWindow::on_actionViewSelectedMCFolder_triggered()
-{
- if (m_selectedInstance)
- {
- QString str = m_selectedInstance->gameRoot();
- if (!FS::ensureFilePathExists(str))
- {
- // TODO: report error
- return;
- }
- DesktopServices::openDirectory(QDir(str).absolutePath());
- }
-}
-
void MainWindow::closeEvent(QCloseEvent *event)
{
// Save the window state and geometry.
@@ -2252,7 +2143,7 @@ void MainWindow::checkInstancePathForProblems()
"You have now two options: "
" - change the instance folder in the settings "
" - move this installation of %1 to a different folder"
- ).arg(BuildConfig.LAUNCHER_NAME)
+ ).arg(BuildConfig.LAUNCHER_DISPLAYNAME)
);
warning.setDefaultButton(QMessageBox::Ok);
warning.exec();
diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h
index 8b41bf94..cb8cb4aa 100644
--- a/launcher/ui/MainWindow.h
+++ b/launcher/ui/MainWindow.h
@@ -112,12 +112,8 @@ private slots:
void on_actionViewInstanceFolder_triggered();
- void on_actionConfig_Folder_triggered();
-
void on_actionViewSelectedInstFolder_triggered();
- void on_actionViewSelectedMCFolder_triggered();
-
void refreshInstances();
void on_actionViewCentralModsFolder_triggered();
@@ -130,6 +126,8 @@ private slots:
void on_actionReportBug_triggered();
+ void on_actionClearMetadata_triggered();
+
void on_actionOpenWiki_triggered();
void on_actionMoreNews_triggered();
@@ -159,14 +157,6 @@ private slots:
void on_actionEditInstance_triggered();
- void on_actionEditInstNotes_triggered();
-
- void on_actionMods_triggered();
-
- void on_actionWorlds_triggered();
-
- void on_actionScreenshots_triggered();
-
void taskEnd();
/**
diff --git a/launcher/ui/dialogs/AboutDialog.cpp b/launcher/ui/dialogs/AboutDialog.cpp
index 36689e10..4ced38a5 100644
--- a/launcher/ui/dialogs/AboutDialog.cpp
+++ b/launcher/ui/dialogs/AboutDialog.cpp
@@ -69,20 +69,19 @@ QString getCreditsHtml()
#endif
stream << "
\n";
- //: %1 is the name of the launcher, determined at build time, e.g. "PolyMC Developers"
- stream << "
\n") .arg(getGitHub("fn2006"));
stream << " \n";
- //: %1 is the name of the launcher, determined at build time, e.g. "PolyMC Contributors"
- stream << "
\n") .arg(getWebsite("https://tebibyte.media/"));
stream << " \n";
- //: %1 is the name of the launcher, determined at build time, e.g. "PolyMC Developers"
- stream << "
\n") .arg(getGitHub("LennyMcLennington"));
+ //: %1 is the name of the launcher, determined at build time, e.g. "Prism Launcher Developers"
+ stream << "
\n") .arg(getGitHub("cozyGalvinism"));
stream << " \n";
- //: %1 is the name of the launcher, determined at build time, e.g. "PolyMC Contributors"
- stream << "
\n") .arg(getWebsite("https://swurl.xyz/"));
stream << " \n";
// TODO: possibly retrieve from git history at build time?
- //: %1 is the name of the launcher, determined at build time, e.g. "PolyMC Developers"
+ //: %1 is the name of the launcher, determined at build time, e.g. "Prism Launcher Developers"
stream << "