Merge remote-tracking branch 'upstream/develop' into develop
Signed-off-by: sneedium <sneed@sneedmc.org>
This commit is contained in:
commit
ba1d07fee1
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@ -27,7 +27,7 @@ body:
|
|||||||
attributes:
|
attributes:
|
||||||
label: Version of PolyMC
|
label: Version of PolyMC
|
||||||
description: The version of PolyMC used in the bug report.
|
description: The version of PolyMC used in the bug report.
|
||||||
placeholder: PolyMC 1.2.2
|
placeholder: PolyMC 1.3.2
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: textarea
|
- type: textarea
|
||||||
|
2
.github/dco.yml
vendored
Normal file
2
.github/dco.yml
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
allowRemediationCommits:
|
||||||
|
individual: true
|
19
.github/workflows/backport.yml
vendored
19
.github/workflows/backport.yml
vendored
@ -1,19 +0,0 @@
|
|||||||
name: Backport PR to stable
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches: [ develop ]
|
|
||||||
types: [ closed ]
|
|
||||||
jobs:
|
|
||||||
release_pull_request:
|
|
||||||
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'backport')
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
- name: Backport PR by cherry-pick-ing
|
|
||||||
uses: Nathanmalnoury/gh-backport-action@master
|
|
||||||
with:
|
|
||||||
pr_branch: 'stable'
|
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
162
.github/workflows/build.yml
vendored
162
.github/workflows/build.yml
vendored
@ -7,6 +7,10 @@ on:
|
|||||||
description: Type of build (Debug, Release, RelWithDebInfo, MinSizeRel)
|
description: Type of build (Debug, Release, RelWithDebInfo, MinSizeRel)
|
||||||
type: string
|
type: string
|
||||||
default: Debug
|
default: Debug
|
||||||
|
secrets:
|
||||||
|
SPARKLE_ED25519_KEY:
|
||||||
|
description: Private key for signing Sparkle updates
|
||||||
|
required: false
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@ -16,20 +20,32 @@ jobs:
|
|||||||
include:
|
include:
|
||||||
|
|
||||||
- os: ubuntu-20.04
|
- os: ubuntu-20.04
|
||||||
|
qt_ver: 5
|
||||||
|
|
||||||
- os: ubuntu-20.04
|
- os: ubuntu-20.04
|
||||||
appimage: true
|
qt_ver: 6
|
||||||
|
qt_host: linux
|
||||||
|
qt_version: '6.2.4'
|
||||||
|
qt_modules: 'qt5compat qtimageformats'
|
||||||
|
qt_path: /home/runner/work/PolyMC/Qt
|
||||||
|
|
||||||
- os: windows-2022
|
- os: windows-2022
|
||||||
name: "Windows-i686"
|
name: "Windows-Legacy"
|
||||||
msystem: mingw32
|
msystem: mingw32
|
||||||
|
qt_ver: 5
|
||||||
|
|
||||||
- os: windows-2022
|
- os: windows-2022
|
||||||
name: "Windows-x86_64"
|
name: "Windows"
|
||||||
msystem: mingw64
|
msystem: mingw32
|
||||||
|
qt_ver: 6
|
||||||
|
|
||||||
- os: macos-12
|
- os: macos-12
|
||||||
macosx_deployment_target: 10.13
|
macosx_deployment_target: 10.14
|
||||||
|
qt_ver: 6
|
||||||
|
qt_host: mac
|
||||||
|
qt_version: '6.3.1'
|
||||||
|
qt_modules: 'qt5compat qtimageformats'
|
||||||
|
qt_path: /Users/runner/work/PolyMC/Qt
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
@ -61,16 +77,21 @@ jobs:
|
|||||||
pacboy: >-
|
pacboy: >-
|
||||||
toolchain:p
|
toolchain:p
|
||||||
cmake:p
|
cmake:p
|
||||||
|
extra-cmake-modules:p
|
||||||
ninja:p
|
ninja:p
|
||||||
qt5:p
|
qt${{ matrix.qt_ver }}-base:p
|
||||||
|
qt${{ matrix.qt_ver }}-svg:p
|
||||||
|
qt${{ matrix.qt_ver }}-imageformats:p
|
||||||
|
quazip-qt${{ matrix.qt_ver }}:p
|
||||||
ccache:p
|
ccache:p
|
||||||
nsis:p
|
nsis:p
|
||||||
|
${{ matrix.qt_ver == 6 && 'qt6-5compat:p' || '' }}
|
||||||
|
|
||||||
- name: Setup ccache
|
- name: Setup ccache
|
||||||
if: runner.os != 'Windows' && inputs.build_type == 'Debug'
|
if: runner.os != 'Windows' && inputs.build_type == 'Debug'
|
||||||
uses: hendrikmuhs/ccache-action@v1.2.1
|
uses: hendrikmuhs/ccache-action@v1.2.1
|
||||||
with:
|
with:
|
||||||
key: ${{ matrix.os }}-${{ matrix.appimage }}
|
key: ${{ matrix.os }}-qt${{ matrix.qt_ver }}
|
||||||
|
|
||||||
- name: Setup ccache (Windows)
|
- name: Setup ccache (Windows)
|
||||||
if: runner.os == 'Windows' && inputs.build_type == 'Debug'
|
if: runner.os == 'Windows' && inputs.build_type == 'Debug'
|
||||||
@ -93,9 +114,9 @@ jobs:
|
|||||||
uses: actions/cache@v3.0.2
|
uses: actions/cache@v3.0.2
|
||||||
with:
|
with:
|
||||||
path: '${{ github.workspace }}\.ccache'
|
path: '${{ github.workspace }}\.ccache'
|
||||||
key: ${{ matrix.os }}-${{ matrix.msystem }}
|
key: ${{ matrix.os }}-qt${{ matrix.qt_ver }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ matrix.os }}-${{ matrix.msystem }}
|
${{ matrix.os }}-qt${{ matrix.qt_ver }}
|
||||||
|
|
||||||
- name: Set short version
|
- name: Set short version
|
||||||
shell: bash
|
shell: bash
|
||||||
@ -103,28 +124,44 @@ jobs:
|
|||||||
ver_short=`git rev-parse --short HEAD`
|
ver_short=`git rev-parse --short HEAD`
|
||||||
echo "VERSION=$ver_short" >> $GITHUB_ENV
|
echo "VERSION=$ver_short" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Install Qt (macOS)
|
- name: Install Dependencies (Linux)
|
||||||
if: runner.os == 'macOS'
|
|
||||||
run: |
|
|
||||||
brew update
|
|
||||||
brew install qt@5 ninja
|
|
||||||
|
|
||||||
- name: Update Qt (AppImage)
|
|
||||||
if: runner.os == 'Linux' && matrix.appimage == true
|
|
||||||
run: |
|
|
||||||
sudo add-apt-repository ppa:savoury1/qt-5-15
|
|
||||||
sudo add-apt-repository ppa:savoury1/kde-5-80
|
|
||||||
sudo add-apt-repository ppa:savoury1/gpg
|
|
||||||
sudo add-apt-repository ppa:savoury1/ffmpeg4
|
|
||||||
|
|
||||||
- name: Install Qt (Linux)
|
|
||||||
if: runner.os == 'Linux'
|
if: runner.os == 'Linux'
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get -y update
|
sudo apt-get -y update
|
||||||
sudo apt-get -y install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libqt5core5a libqt5network5 libqt5gui5 ninja-build qt5-image-formats-plugins
|
sudo apt-get -y install ninja-build extra-cmake-modules scdoc
|
||||||
|
|
||||||
|
- name: Install Dependencies (macOS)
|
||||||
|
if: runner.os == 'macOS'
|
||||||
|
run: |
|
||||||
|
brew update
|
||||||
|
brew install ninja extra-cmake-modules
|
||||||
|
|
||||||
|
- name: Install Qt (Linux)
|
||||||
|
if: runner.os == 'Linux' && matrix.qt_ver != 6
|
||||||
|
run: |
|
||||||
|
sudo apt-get -y install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libqt5core5a libqt5network5 libqt5gui5
|
||||||
|
|
||||||
|
- name: Cache Qt (macOS and AppImage)
|
||||||
|
id: cache-qt
|
||||||
|
if: matrix.qt_ver == 6 && runner.os != 'Windows'
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: '${{ matrix.qt_path }}/${{ matrix.qt_version }}'
|
||||||
|
key: ${{ matrix.qt_host }}-${{ matrix.qt_version }}-"${{ matrix.qt_modules }}"-qt_cache
|
||||||
|
|
||||||
|
- name: Install Qt (macOS and AppImage)
|
||||||
|
if: matrix.qt_ver == 6 && runner.os != 'Windows'
|
||||||
|
uses: jurplel/install-qt-action@v2
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.qt_version }}
|
||||||
|
host: ${{ matrix.qt_host }}
|
||||||
|
target: 'desktop'
|
||||||
|
modules: ${{ matrix.qt_modules }}
|
||||||
|
cached: ${{ steps.cache-qt.outputs.cache-hit }}
|
||||||
|
aqtversion: ==2.1.*
|
||||||
|
|
||||||
- name: Prepare AppImage (Linux)
|
- name: Prepare AppImage (Linux)
|
||||||
if: runner.os == 'Linux' && matrix.appimage == true
|
if: runner.os == 'Linux' && matrix.qt_ver != 5
|
||||||
run: |
|
run: |
|
||||||
wget "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage"
|
wget "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage"
|
||||||
wget "https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/continuous/linuxdeploy-plugin-appimage-x86_64.AppImage"
|
wget "https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/continuous/linuxdeploy-plugin-appimage-x86_64.AppImage"
|
||||||
@ -139,18 +176,18 @@ jobs:
|
|||||||
- name: Configure CMake (macOS)
|
- name: Configure CMake (macOS)
|
||||||
if: runner.os == 'macOS'
|
if: runner.os == 'macOS'
|
||||||
run: |
|
run: |
|
||||||
cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DQt5_DIR=/usr/local/opt/qt@5 -DCMAKE_PREFIX_PATH=/usr/local/opt/qt@5 -DLauncher_BUILD_PLATFORM=macOS -DCMAKE_C_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -DCMAKE_CXX_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -G Ninja
|
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
|
||||||
|
|
||||||
- name: Configure CMake (Windows)
|
- name: Configure CMake (Windows)
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows'
|
||||||
shell: msys2 {0}
|
shell: msys2 {0}
|
||||||
run: |
|
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 }} -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 }} -G Ninja
|
||||||
|
|
||||||
- name: Configure CMake (Linux)
|
- name: Configure CMake (Linux)
|
||||||
if: runner.os == 'Linux'
|
if: runner.os == 'Linux'
|
||||||
run: |
|
run: |
|
||||||
cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_BUILD_PLATFORM=Linux -DCMAKE_C_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -DCMAKE_CXX_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -G Ninja
|
cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_BUILD_PLATFORM=Linux -DCMAKE_C_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -DCMAKE_CXX_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -DLauncher_QT_VERSION_MAJOR=${{ matrix.qt_ver }} -G Ninja
|
||||||
|
|
||||||
##
|
##
|
||||||
# BUILD
|
# BUILD
|
||||||
@ -167,6 +204,21 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cmake --build ${{ env.BUILD_DIR }}
|
cmake --build ${{ env.BUILD_DIR }}
|
||||||
|
|
||||||
|
##
|
||||||
|
# TEST
|
||||||
|
##
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
if: runner.os != 'Windows'
|
||||||
|
run: |
|
||||||
|
ctest --test-dir build --output-on-failure
|
||||||
|
|
||||||
|
- name: Test (Windows)
|
||||||
|
if: runner.os == 'Windows'
|
||||||
|
shell: msys2 {0}
|
||||||
|
run: |
|
||||||
|
ctest --test-dir build --output-on-failure
|
||||||
|
|
||||||
##
|
##
|
||||||
# PACKAGE BUILDS
|
# PACKAGE BUILDS
|
||||||
##
|
##
|
||||||
@ -181,6 +233,25 @@ jobs:
|
|||||||
sudo codesign --sign - --deep --force --entitlements "../program_info/App.entitlements" --options runtime "PolyMC.app/Contents/MacOS/polymc"
|
sudo codesign --sign - --deep --force --entitlements "../program_info/App.entitlements" --options runtime "PolyMC.app/Contents/MacOS/polymc"
|
||||||
tar -czf ../PolyMC.tar.gz *
|
tar -czf ../PolyMC.tar.gz *
|
||||||
|
|
||||||
|
- name: Make Sparkle signature (macOS)
|
||||||
|
if: runner.os == 'macOS'
|
||||||
|
run: |
|
||||||
|
if [ '${{ secrets.SPARKLE_ED25519_KEY }}' != '' ]; then
|
||||||
|
brew install openssl@3
|
||||||
|
echo '${{ secrets.SPARKLE_ED25519_KEY }}' > ed25519-priv.pem
|
||||||
|
signature=$(/usr/local/opt/openssl@3/bin/openssl pkeyutl -sign -rawin -in ${{ github.workspace }}/PolyMC.tar.gz -inkey ed25519-priv.pem | openssl base64 | tr -d \\n)
|
||||||
|
rm ed25519-priv.pem
|
||||||
|
cat >> $GITHUB_STEP_SUMMARY << EOF
|
||||||
|
### Artifact Information :information_source:
|
||||||
|
- :memo: Sparkle Signature (ed25519): \`$signature\`
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
cat >> $GITHUB_STEP_SUMMARY << EOF
|
||||||
|
### Artifact Information :information_source:
|
||||||
|
- :warning: Sparkle Signature (ed25519): No private key available (likely a pull request or fork)
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Package (Windows)
|
- name: Package (Windows)
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows'
|
||||||
shell: msys2 {0}
|
shell: msys2 {0}
|
||||||
@ -209,7 +280,7 @@ jobs:
|
|||||||
makensis -NOCD "${{ github.workspace }}/${{ env.BUILD_DIR }}/program_info/win_install.nsi"
|
makensis -NOCD "${{ github.workspace }}/${{ env.BUILD_DIR }}/program_info/win_install.nsi"
|
||||||
|
|
||||||
- name: Package (Linux)
|
- name: Package (Linux)
|
||||||
if: runner.os == 'Linux' && matrix.appimage != true
|
if: runner.os == 'Linux'
|
||||||
run: |
|
run: |
|
||||||
cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_DIR }}
|
cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_DIR }}
|
||||||
|
|
||||||
@ -217,7 +288,7 @@ jobs:
|
|||||||
tar --owner root --group root -czf ../PolyMC.tar.gz *
|
tar --owner root --group root -czf ../PolyMC.tar.gz *
|
||||||
|
|
||||||
- name: Package (Linux, portable)
|
- name: Package (Linux, portable)
|
||||||
if: runner.os == 'Linux' && matrix.appimage != true
|
if: runner.os == 'Linux'
|
||||||
run: |
|
run: |
|
||||||
cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_PORTABLE_DIR }}
|
cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_PORTABLE_DIR }}
|
||||||
cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_PORTABLE_DIR }} --component portable
|
cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_PORTABLE_DIR }} --component portable
|
||||||
@ -226,7 +297,7 @@ jobs:
|
|||||||
tar -czf ../PolyMC-portable.tar.gz *
|
tar -czf ../PolyMC-portable.tar.gz *
|
||||||
|
|
||||||
- name: Package AppImage (Linux)
|
- name: Package AppImage (Linux)
|
||||||
if: runner.os == 'Linux' && matrix.appimage == true
|
if: runner.os == 'Linux' && matrix.qt_ver != 5
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_APPIMAGE_DIR }}/usr
|
cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_APPIMAGE_DIR }}/usr
|
||||||
@ -236,11 +307,14 @@ jobs:
|
|||||||
chmod +x linuxdeploy-*.AppImage
|
chmod +x linuxdeploy-*.AppImage
|
||||||
|
|
||||||
mkdir -p ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-{8,17}-openjdk
|
mkdir -p ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-{8,17}-openjdk
|
||||||
|
mkdir -p ${{ env.INSTALL_APPIMAGE_DIR }}/usr/plugins/iconengines
|
||||||
|
|
||||||
cp -r ${{ github.workspace }}/JREs/jre8/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-8-openjdk
|
cp -r ${{ github.workspace }}/JREs/jre8/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-8-openjdk
|
||||||
|
|
||||||
cp -r ${{ github.workspace }}/JREs/jre17/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-17-openjdk
|
cp -r ${{ github.workspace }}/JREs/jre17/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-17-openjdk
|
||||||
|
|
||||||
|
cp -r /home/runner/work/PolyMC/Qt/${{ matrix.qt_version }}/gcc_64/plugins/iconengines/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/plugins/iconengines
|
||||||
|
|
||||||
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib"
|
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib"
|
||||||
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-8-openjdk/lib/amd64/server"
|
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-8-openjdk/lib/amd64/server"
|
||||||
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-8-openjdk/lib/amd64"
|
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-8-openjdk/lib/amd64"
|
||||||
@ -282,22 +356,36 @@ jobs:
|
|||||||
name: PolyMC-${{ matrix.name }}-Setup-${{ env.VERSION }}-${{ inputs.build_type }}
|
name: PolyMC-${{ matrix.name }}-Setup-${{ env.VERSION }}-${{ inputs.build_type }}
|
||||||
path: PolyMC-Setup.exe
|
path: PolyMC-Setup.exe
|
||||||
|
|
||||||
- name: Upload binary tarball (Linux)
|
- name: Upload binary tarball (Linux, Qt 5)
|
||||||
if: runner.os == 'Linux' && matrix.appimage != true
|
if: runner.os == 'Linux' && matrix.qt_ver != 6
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}
|
name: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}
|
||||||
path: PolyMC.tar.gz
|
path: PolyMC.tar.gz
|
||||||
|
|
||||||
- name: Upload binary tarball (Linux, portable)
|
- name: Upload binary tarball (Linux, portable, Qt 5)
|
||||||
if: runner.os == 'Linux' && matrix.appimage != true
|
if: runner.os == 'Linux' && matrix.qt_ver != 6
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: PolyMC-${{ runner.os }}-Portable-${{ env.VERSION }}-${{ inputs.build_type }}
|
name: PolyMC-${{ runner.os }}-Portable-${{ env.VERSION }}-${{ inputs.build_type }}
|
||||||
path: PolyMC-portable.tar.gz
|
path: PolyMC-portable.tar.gz
|
||||||
|
|
||||||
|
- name: Upload binary tarball (Linux, Qt 6)
|
||||||
|
if: runner.os == 'Linux' && matrix.qt_ver !=5
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: PolyMC-${{ runner.os }}-Qt6-${{ env.VERSION }}-${{ inputs.build_type }}
|
||||||
|
path: PolyMC.tar.gz
|
||||||
|
|
||||||
|
- name: Upload binary tarball (Linux, portable, Qt 6)
|
||||||
|
if: runner.os == 'Linux' && matrix.qt_ver != 5
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: PolyMC-${{ runner.os }}-Qt6-Portable-${{ env.VERSION }}-${{ inputs.build_type }}
|
||||||
|
path: PolyMC-portable.tar.gz
|
||||||
|
|
||||||
- name: Upload AppImage (Linux)
|
- name: Upload AppImage (Linux)
|
||||||
if: runner.os == 'Linux' && matrix.appimage == true
|
if: runner.os == 'Linux' && matrix.qt_ver != 5
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage
|
name: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage
|
||||||
|
61
.github/workflows/pr-comment.yml
vendored
61
.github/workflows/pr-comment.yml
vendored
@ -1,61 +0,0 @@
|
|||||||
name: Comment on pull request
|
|
||||||
on:
|
|
||||||
workflow_run:
|
|
||||||
workflows: ['Build Application']
|
|
||||||
types: [completed]
|
|
||||||
jobs:
|
|
||||||
pr_comment:
|
|
||||||
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/github-script@v5
|
|
||||||
with:
|
|
||||||
# This snippet is public-domain, taken from
|
|
||||||
# https://github.com/oprypin/nightly.link/blob/master/.github/workflows/pr-comment.yml
|
|
||||||
script: |
|
|
||||||
async function upsertComment(owner, repo, issue_number, purpose, body) {
|
|
||||||
const {data: comments} = await github.rest.issues.listComments(
|
|
||||||
{owner, repo, issue_number});
|
|
||||||
|
|
||||||
const marker = `<!-- bot: ${purpose} -->`;
|
|
||||||
body = marker + "\n" + body;
|
|
||||||
|
|
||||||
const existing = comments.filter((c) => c.body.includes(marker));
|
|
||||||
if (existing.length > 0) {
|
|
||||||
const last = existing[existing.length - 1];
|
|
||||||
core.info(`Updating comment ${last.id}`);
|
|
||||||
await github.rest.issues.updateComment({
|
|
||||||
owner, repo,
|
|
||||||
body,
|
|
||||||
comment_id: last.id,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
core.info(`Creating a comment in issue / PR #${issue_number}`);
|
|
||||||
await github.rest.issues.createComment({issue_number, body, owner, repo});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const {owner, repo} = context.repo;
|
|
||||||
const run_id = ${{github.event.workflow_run.id}};
|
|
||||||
|
|
||||||
const pull_requests = ${{ toJSON(github.event.workflow_run.pull_requests) }};
|
|
||||||
if (!pull_requests.length) {
|
|
||||||
return core.error("This workflow doesn't match any pull requests!");
|
|
||||||
}
|
|
||||||
|
|
||||||
const artifacts = await github.paginate(
|
|
||||||
github.rest.actions.listWorkflowRunArtifacts, {owner, repo, run_id});
|
|
||||||
if (!artifacts.length) {
|
|
||||||
return core.error(`No artifacts found`);
|
|
||||||
}
|
|
||||||
let body = `Download the artifacts for this pull request:\n`;
|
|
||||||
for (const art of artifacts) {
|
|
||||||
body += `\n* [${art.name}.zip](https://nightly.link/${owner}/${repo}/actions/artifacts/${art.id}.zip)`;
|
|
||||||
}
|
|
||||||
|
|
||||||
core.info("Review thread message body:", body);
|
|
||||||
|
|
||||||
for (const pr of pull_requests) {
|
|
||||||
await upsertComment(owner, repo, pr.number,
|
|
||||||
"nightly-link", body);
|
|
||||||
}
|
|
2
.github/workflows/trigger_builds.yml
vendored
2
.github/workflows/trigger_builds.yml
vendored
@ -28,3 +28,5 @@ jobs:
|
|||||||
uses: ./.github/workflows/build.yml
|
uses: ./.github/workflows/build.yml
|
||||||
with:
|
with:
|
||||||
build_type: Debug
|
build_type: Debug
|
||||||
|
secrets:
|
||||||
|
SPARKLE_ED25519_KEY: ${{ secrets.SPARKLE_ED25519_KEY }}
|
||||||
|
23
.github/workflows/trigger_release.yml
vendored
23
.github/workflows/trigger_release.yml
vendored
@ -12,6 +12,8 @@ jobs:
|
|||||||
uses: ./.github/workflows/build.yml
|
uses: ./.github/workflows/build.yml
|
||||||
with:
|
with:
|
||||||
build_type: Release
|
build_type: Release
|
||||||
|
secrets:
|
||||||
|
SPARKLE_ED25519_KEY: ${{ secrets.SPARKLE_ED25519_KEY }}
|
||||||
|
|
||||||
create_release:
|
create_release:
|
||||||
needs: build_release
|
needs: build_release
|
||||||
@ -33,6 +35,8 @@ jobs:
|
|||||||
- name: Package artifacts properly
|
- name: Package artifacts properly
|
||||||
run: |
|
run: |
|
||||||
mv ${{ github.workspace }}/PolyMC-source PolyMC-${{ env.VERSION }}
|
mv ${{ github.workspace }}/PolyMC-source PolyMC-${{ env.VERSION }}
|
||||||
|
mv PolyMC-Linux-Qt6-Portable*/PolyMC-portable.tar.gz PolyMC-Linux-Qt6-Portable-${{ env.VERSION }}.tar.gz
|
||||||
|
mv PolyMC-Linux-Qt6*/PolyMC.tar.gz PolyMC-Linux-Qt6-${{ env.VERSION }}.tar.gz
|
||||||
mv PolyMC-Linux-Portable*/PolyMC-portable.tar.gz PolyMC-Linux-Portable-${{ env.VERSION }}.tar.gz
|
mv PolyMC-Linux-Portable*/PolyMC-portable.tar.gz PolyMC-Linux-Portable-${{ env.VERSION }}.tar.gz
|
||||||
mv PolyMC-Linux*/PolyMC.tar.gz PolyMC-Linux-${{ env.VERSION }}.tar.gz
|
mv PolyMC-Linux*/PolyMC.tar.gz PolyMC-Linux-${{ env.VERSION }}.tar.gz
|
||||||
mv PolyMC-*.AppImage/PolyMC-*.AppImage PolyMC-Linux-${{ env.VERSION }}-x86_64.AppImage
|
mv PolyMC-*.AppImage/PolyMC-*.AppImage PolyMC-Linux-${{ env.VERSION }}-x86_64.AppImage
|
||||||
@ -42,10 +46,11 @@ jobs:
|
|||||||
|
|
||||||
for d in PolyMC-Windows-*; do
|
for d in PolyMC-Windows-*; do
|
||||||
cd "${d}" || continue
|
cd "${d}" || continue
|
||||||
ARCH="$(echo -n ${d} | cut -d '-' -f 3)"
|
LEGACY="$(echo -n ${d} | grep -o Legacy || true)"
|
||||||
INST="$(echo -n ${d} | grep -o Setup || true)"
|
INST="$(echo -n ${d} | grep -o Setup || true)"
|
||||||
PORT="$(echo -n ${d} | grep -o Portable || true)"
|
PORT="$(echo -n ${d} | grep -o Portable || true)"
|
||||||
NAME="PolyMC-Windows-${ARCH}"
|
NAME="PolyMC-Windows"
|
||||||
|
test -z "${LEGACY}" || NAME="${NAME}-Legacy"
|
||||||
test -z "${PORT}" || NAME="${NAME}-Portable"
|
test -z "${PORT}" || NAME="${NAME}-Portable"
|
||||||
test -z "${INST}" || mv PolyMC-*.exe ../${NAME}-Setup-${{ env.VERSION }}.exe
|
test -z "${INST}" || mv PolyMC-*.exe ../${NAME}-Setup-${{ env.VERSION }}.exe
|
||||||
test -n "${INST}" || zip -r -9 "../${NAME}-${{ env.VERSION }}.zip" *
|
test -n "${INST}" || zip -r -9 "../${NAME}-${{ env.VERSION }}.zip" *
|
||||||
@ -66,11 +71,13 @@ jobs:
|
|||||||
PolyMC-Linux-${{ env.VERSION }}.tar.gz
|
PolyMC-Linux-${{ env.VERSION }}.tar.gz
|
||||||
PolyMC-Linux-Portable-${{ env.VERSION }}.tar.gz
|
PolyMC-Linux-Portable-${{ env.VERSION }}.tar.gz
|
||||||
PolyMC-Linux-${{ env.VERSION }}-x86_64.AppImage
|
PolyMC-Linux-${{ env.VERSION }}-x86_64.AppImage
|
||||||
PolyMC-Windows-i686-${{ env.VERSION }}.zip
|
PolyMC-Windows-Legacy-${{ env.VERSION }}.zip
|
||||||
PolyMC-Windows-i686-Portable-${{ env.VERSION }}.zip
|
PolyMC-Linux-Qt6-${{ env.VERSION }}.tar.gz
|
||||||
PolyMC-Windows-i686-Setup-${{ env.VERSION }}.exe
|
PolyMC-Linux-Qt6-Portable-${{ env.VERSION }}.tar.gz
|
||||||
PolyMC-Windows-x86_64-${{ env.VERSION }}.zip
|
PolyMC-Windows-Legacy-Portable-${{ env.VERSION }}.zip
|
||||||
PolyMC-Windows-x86_64-Portable-${{ env.VERSION }}.zip
|
PolyMC-Windows-Legacy-Setup-${{ env.VERSION }}.exe
|
||||||
PolyMC-Windows-x86_64-Setup-${{ env.VERSION }}.exe
|
PolyMC-Windows-${{ env.VERSION }}.zip
|
||||||
|
PolyMC-Windows-Portable-${{ env.VERSION }}.zip
|
||||||
|
PolyMC-Windows-Setup-${{ env.VERSION }}.exe
|
||||||
PolyMC-macOS-${{ env.VERSION }}.tar.gz
|
PolyMC-macOS-${{ env.VERSION }}.tar.gz
|
||||||
PolyMC-${{ env.VERSION }}.tar.gz
|
PolyMC-${{ env.VERSION }}.tar.gz
|
||||||
|
14
.github/workflows/winget.yml
vendored
Normal file
14
.github/workflows/winget.yml
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
name: Publish to WinGet
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [released]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- uses: vedantmgoyal2009/winget-releaser@latest
|
||||||
|
with:
|
||||||
|
identifier: PolyMC.PolyMC
|
||||||
|
installers-regex: '\.exe$'
|
||||||
|
token: ${{ secrets.WINGET_TOKEN }}
|
@ -6,14 +6,12 @@ if(WIN32)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
project(Launcher)
|
project(Launcher)
|
||||||
include(CTest)
|
|
||||||
|
|
||||||
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BUILD_DIR}" IS_IN_SOURCE_BUILD)
|
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BUILD_DIR}" IS_IN_SOURCE_BUILD)
|
||||||
if(IS_IN_SOURCE_BUILD)
|
if(IS_IN_SOURCE_BUILD)
|
||||||
message(FATAL_ERROR "You are building the Launcher in-source. Please separate the build tree from the source tree.")
|
message(FATAL_ERROR "You are building the Launcher in-source. Please separate the build tree from the source tree.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
##################################### Set CMake options #####################################
|
##################################### Set CMake options #####################################
|
||||||
set(CMAKE_AUTOMOC ON)
|
set(CMAKE_AUTOMOC ON)
|
||||||
set(CMAKE_AUTORCC ON)
|
set(CMAKE_AUTORCC ON)
|
||||||
@ -34,7 +32,7 @@ set(CMAKE_C_STANDARD_REQUIRED true)
|
|||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
include(GenerateExportHeader)
|
include(GenerateExportHeader)
|
||||||
set(CMAKE_CXX_FLAGS "-Wall -pedantic -Werror -Wno-deprecated-declarations -D_GLIBCXX_USE_CXX11_ABI=0 -fstack-protector-strong --param=ssp-buffer-size=4 ${CMAKE_CXX_FLAGS}")
|
set(CMAKE_CXX_FLAGS "-Wall -pedantic -D_GLIBCXX_USE_CXX11_ABI=0 -fstack-protector-strong --param=ssp-buffer-size=4 ${CMAKE_CXX_FLAGS}")
|
||||||
if(UNIX AND APPLE)
|
if(UNIX AND APPLE)
|
||||||
set(CMAKE_CXX_FLAGS "-stdlib=libc++ ${CMAKE_CXX_FLAGS}")
|
set(CMAKE_CXX_FLAGS "-stdlib=libc++ ${CMAKE_CXX_FLAGS}")
|
||||||
endif()
|
endif()
|
||||||
@ -63,6 +61,16 @@ if(ENABLE_LTO)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
option(BUILD_TESTING "Build the testing tree." ON)
|
||||||
|
|
||||||
|
find_package(ECM REQUIRED NO_MODULE)
|
||||||
|
set(CMAKE_MODULE_PATH "${ECM_MODULE_PATH};${CMAKE_MODULE_PATH}")
|
||||||
|
include(CTest)
|
||||||
|
include(ECMAddTests)
|
||||||
|
if (BUILD_TESTING)
|
||||||
|
enable_testing()
|
||||||
|
endif()
|
||||||
|
|
||||||
##################################### Set Application options #####################################
|
##################################### Set Application options #####################################
|
||||||
|
|
||||||
######## Set URLs ########
|
######## Set URLs ########
|
||||||
@ -99,8 +107,6 @@ set(Launcher_MATRIX_URL "" CACHE STRING "URL to the Matrix Space")
|
|||||||
# Discord URL
|
# Discord URL
|
||||||
set(Launcher_DISCORD_URL "" CACHE STRING "URL for the Discord guild.")
|
set(Launcher_DISCORD_URL "" CACHE STRING "URL for the Discord guild.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Subreddit URL
|
# Subreddit URL
|
||||||
set(Launcher_SUBREDDIT_URL "https://www.reddit.com/r/PolyMCLauncher/" CACHE STRING "URL for the subreddit.")
|
set(Launcher_SUBREDDIT_URL "https://www.reddit.com/r/PolyMCLauncher/" CACHE STRING "URL for the subreddit.")
|
||||||
|
|
||||||
@ -119,9 +125,11 @@ execute_process(COMMAND ./cf.sh OUTPUT_VARIABLE Launcher_CURSEFORGE_API_KEY)
|
|||||||
|
|
||||||
#### Check the current Git commit and branch
|
#### Check the current Git commit and branch
|
||||||
include(GetGitRevisionDescription)
|
include(GetGitRevisionDescription)
|
||||||
|
git_get_exact_tag(Launcher_GIT_TAG)
|
||||||
get_git_head_revision(Launcher_GIT_REFSPEC Launcher_GIT_COMMIT)
|
get_git_head_revision(Launcher_GIT_REFSPEC Launcher_GIT_COMMIT)
|
||||||
|
|
||||||
message(STATUS "Git commit: ${Launcher_GIT_COMMIT}")
|
message(STATUS "Git commit: ${Launcher_GIT_COMMIT}")
|
||||||
|
message(STATUS "Git tag: ${Launcher_GIT_TAG}")
|
||||||
message(STATUS "Git refspec: ${Launcher_GIT_REFSPEC}")
|
message(STATUS "Git refspec: ${Launcher_GIT_REFSPEC}")
|
||||||
|
|
||||||
set(Launcher_RELEASE_VERSION_NAME "${Launcher_VERSION_MAJOR}.${Launcher_VERSION_MINOR}.${Launcher_VERSION_HOTFIX}")
|
set(Launcher_RELEASE_VERSION_NAME "${Launcher_VERSION_MAJOR}.${Launcher_VERSION_MINOR}.${Launcher_VERSION_HOTFIX}")
|
||||||
@ -137,6 +145,7 @@ add_custom_target(tcversion echo "\\#\\#teamcity[setParameter name=\\'env.LAUNCH
|
|||||||
################################ 3rd Party Libs ################################
|
################################ 3rd Party Libs ################################
|
||||||
|
|
||||||
# Find the required Qt parts
|
# Find the required Qt parts
|
||||||
|
include(QtVersionlessBackport)
|
||||||
if(Launcher_QT_VERSION_MAJOR EQUAL 5)
|
if(Launcher_QT_VERSION_MAJOR EQUAL 5)
|
||||||
set(QT_VERSION_MAJOR 5)
|
set(QT_VERSION_MAJOR 5)
|
||||||
find_package(Qt5 REQUIRED COMPONENTS Core Widgets Concurrent Network Test Xml)
|
find_package(Qt5 REQUIRED COMPONENTS Core Widgets Concurrent Network Test Xml)
|
||||||
@ -148,19 +157,33 @@ if(Launcher_QT_VERSION_MAJOR EQUAL 5)
|
|||||||
set(QUAZIP_QT_MAJOR_VERSION ${QT_VERSION_MAJOR} CACHE STRING "Qt version to use (4, 5 or 6), defaults to ${QT_VERSION_MAJOR}" FORCE)
|
set(QUAZIP_QT_MAJOR_VERSION ${QT_VERSION_MAJOR} CACHE STRING "Qt version to use (4, 5 or 6), defaults to ${QT_VERSION_MAJOR}" FORCE)
|
||||||
set(FORCE_BUNDLED_QUAZIP 1)
|
set(FORCE_BUNDLED_QUAZIP 1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Qt 6 sets these by default. Notably causes Windows APIs to use UNICODE strings.
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUNICODE -D_UNICODE")
|
||||||
|
elseif(Launcher_QT_VERSION_MAJOR EQUAL 6)
|
||||||
|
set(QT_VERSION_MAJOR 6)
|
||||||
|
find_package(Qt6 REQUIRED COMPONENTS Core Widgets Concurrent Network Test Xml Core5Compat)
|
||||||
|
list(APPEND Launcher_QT_LIBS Qt6::Core5Compat)
|
||||||
|
|
||||||
|
if(NOT Launcher_FORCE_BUNDLED_LIBS)
|
||||||
|
find_package(QuaZip-Qt6 1.3 QUIET)
|
||||||
|
endif()
|
||||||
|
if (NOT QuaZip-Qt6_FOUND)
|
||||||
|
set(QUAZIP_QT_MAJOR_VERSION ${QT_VERSION_MAJOR} CACHE STRING "Qt version to use (4, 5 or 6), defaults to ${QT_VERSION_MAJOR}" FORCE)
|
||||||
|
set(FORCE_BUNDLED_QUAZIP 1)
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Qt version ${Launcher_QT_VERSION_MAJOR} is not supported")
|
message(FATAL_ERROR "Qt version ${Launcher_QT_VERSION_MAJOR} is not supported")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# The Qt5 cmake files don't provide its install paths, so ask qmake.
|
include(ECMQueryQt)
|
||||||
include(QMakeQuery)
|
ecm_query_qt(QT_PLUGINS_DIR QT_INSTALL_PLUGINS)
|
||||||
query_qmake(QT_INSTALL_PLUGINS QT_PLUGINS_DIR)
|
ecm_query_qt(QT_LIBS_DIR QT_INSTALL_LIBS)
|
||||||
query_qmake(QT_INSTALL_IMPORTS QT_IMPORTS_DIR)
|
ecm_query_qt(QT_LIBEXECS_DIR QT_INSTALL_LIBEXECS)
|
||||||
query_qmake(QT_INSTALL_LIBS QT_LIBS_DIR)
|
ecm_query_qt(QT_DATA_DIR QT_HOST_DATA)
|
||||||
query_qmake(QT_INSTALL_LIBEXECS QT_LIBEXECS_DIR)
|
|
||||||
query_qmake(QT_HOST_DATA QT_DATA_DIR)
|
|
||||||
set(QT_MKSPECS_DIR ${QT_DATA_DIR}/mkspecs)
|
set(QT_MKSPECS_DIR ${QT_DATA_DIR}/mkspecs)
|
||||||
|
|
||||||
|
# NOTE: Qt 6 already sets this by default
|
||||||
if (Qt5_POSITION_INDEPENDENT_CODE)
|
if (Qt5_POSITION_INDEPENDENT_CODE)
|
||||||
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
endif()
|
endif()
|
||||||
@ -181,6 +204,7 @@ if(UNIX AND APPLE)
|
|||||||
set(BINARY_DEST_DIR "${Launcher_Name}.app/Contents/MacOS")
|
set(BINARY_DEST_DIR "${Launcher_Name}.app/Contents/MacOS")
|
||||||
set(LIBRARY_DEST_DIR "${Launcher_Name}.app/Contents/MacOS")
|
set(LIBRARY_DEST_DIR "${Launcher_Name}.app/Contents/MacOS")
|
||||||
set(PLUGIN_DEST_DIR "${Launcher_Name}.app/Contents/MacOS")
|
set(PLUGIN_DEST_DIR "${Launcher_Name}.app/Contents/MacOS")
|
||||||
|
set(FRAMEWORK_DEST_DIR "${Launcher_Name}.app/Contents/Frameworks")
|
||||||
set(RESOURCES_DEST_DIR "${Launcher_Name}.app/Contents/Resources")
|
set(RESOURCES_DEST_DIR "${Launcher_Name}.app/Contents/Resources")
|
||||||
set(JARS_DEST_DIR "${Launcher_Name}.app/Contents/MacOS/jars")
|
set(JARS_DEST_DIR "${Launcher_Name}.app/Contents/MacOS/jars")
|
||||||
|
|
||||||
@ -196,9 +220,15 @@ if(UNIX AND APPLE)
|
|||||||
set(MACOSX_BUNDLE_LONG_VERSION_STRING "${Launcher_VERSION_MAJOR}.${Launcher_VERSION_MINOR}.${Launcher_VERSION_HOTFIX}.${Launcher_VERSION_BUILD}")
|
set(MACOSX_BUNDLE_LONG_VERSION_STRING "${Launcher_VERSION_MAJOR}.${Launcher_VERSION_MINOR}.${Launcher_VERSION_HOTFIX}.${Launcher_VERSION_BUILD}")
|
||||||
set(MACOSX_BUNDLE_ICON_FILE ${Launcher_Name}.icns)
|
set(MACOSX_BUNDLE_ICON_FILE ${Launcher_Name}.icns)
|
||||||
set(MACOSX_BUNDLE_COPYRIGHT "Copyright 2021-2022 ${Launcher_Copyright}")
|
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_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")
|
||||||
|
set(MACOSX_SPARKLE_DIR "${CMAKE_BINARY_DIR}/frameworks/Sparkle")
|
||||||
|
|
||||||
# directories to look for dependencies
|
# directories to look for dependencies
|
||||||
set(DIRS ${QT_LIBS_DIR} ${QT_LIBEXECS_DIR} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
set(DIRS ${QT_LIBS_DIR} ${QT_LIBEXECS_DIR} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${MACOSX_SPARKLE_DIR})
|
||||||
|
|
||||||
# install as bundle
|
# install as bundle
|
||||||
set(INSTALL_BUNDLE "full")
|
set(INSTALL_BUNDLE "full")
|
||||||
@ -221,13 +251,13 @@ elseif(UNIX)
|
|||||||
# Set RPATH
|
# Set RPATH
|
||||||
SET(Launcher_BINARY_RPATH "$ORIGIN/")
|
SET(Launcher_BINARY_RPATH "$ORIGIN/")
|
||||||
|
|
||||||
# jars path is determined on runtime, relative to "Application root path", generally /usr or the root of the portable bundle
|
|
||||||
set(Launcher_APP_BINARY_DEFS "-DLAUNCHER_JARS_LOCATION=${JARS_DEST_DIR}")
|
|
||||||
|
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${Launcher_Desktop} DESTINATION ${LAUNCHER_DESKTOP_DEST_DIR})
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${Launcher_Desktop} DESTINATION ${LAUNCHER_DESKTOP_DEST_DIR})
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${Launcher_MetaInfo} DESTINATION ${LAUNCHER_METAINFO_DEST_DIR})
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${Launcher_MetaInfo} DESTINATION ${LAUNCHER_METAINFO_DEST_DIR})
|
||||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${Launcher_SVG} DESTINATION ${LAUNCHER_ICON_DEST_DIR})
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${Launcher_SVG} DESTINATION ${LAUNCHER_ICON_DEST_DIR})
|
||||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${Launcher_ManPage} DESTINATION ${LAUNCHER_MAN_DEST_DIR} RENAME "${Launcher_APP_BINARY_NAME}.6")
|
|
||||||
|
if(Launcher_ManPage)
|
||||||
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${Launcher_ManPage} DESTINATION ${LAUNCHER_MAN_DEST_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
# Install basic runner script if component "portable" is selected
|
# Install basic runner script if component "portable" is selected
|
||||||
configure_file(launcher/Launcher.in "${CMAKE_CURRENT_BINARY_DIR}/LauncherScript" @ONLY)
|
configure_file(launcher/Launcher.in "${CMAKE_CURRENT_BINARY_DIR}/LauncherScript" @ONLY)
|
||||||
@ -276,12 +306,13 @@ else()
|
|||||||
message(STATUS "Using system QuaZip")
|
message(STATUS "Using system QuaZip")
|
||||||
endif()
|
endif()
|
||||||
add_subdirectory(libraries/rainbow) # Qt extension for colors
|
add_subdirectory(libraries/rainbow) # Qt extension for colors
|
||||||
add_subdirectory(libraries/iconfix) # fork of Qt's QIcon loader
|
|
||||||
add_subdirectory(libraries/LocalPeer) # fork of a library from Qt solutions
|
add_subdirectory(libraries/LocalPeer) # fork of a library from Qt solutions
|
||||||
add_subdirectory(libraries/classparser) # class parser library
|
add_subdirectory(libraries/classparser) # class parser library
|
||||||
add_subdirectory(libraries/optional-bare)
|
add_subdirectory(libraries/optional-bare)
|
||||||
add_subdirectory(libraries/tomlc99) # toml parser
|
add_subdirectory(libraries/tomlc99) # toml parser
|
||||||
add_subdirectory(libraries/katabasis) # An OAuth2 library that tried to do too much
|
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
|
||||||
|
|
||||||
############################### Built Artifacts ###############################
|
############################### Built Artifacts ###############################
|
||||||
|
|
||||||
|
62
CONTRIBUTING.md
Normal file
62
CONTRIBUTING.md
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
# Contributions Guidelines
|
||||||
|
|
||||||
|
## Code formatting
|
||||||
|
|
||||||
|
Try to follow the existing formatting.
|
||||||
|
If there is no existing formatting, you may use `clang-format` with our included `.clang-format` configuration.
|
||||||
|
|
||||||
|
In general, in order of importance:
|
||||||
|
- Make sure your IDE is not messing up line endings or whitespace and avoid using linters.
|
||||||
|
- Prefer readability over dogma.
|
||||||
|
- Keep to the existing formatting.
|
||||||
|
- Indent with 4 space unless it's in a submodule.
|
||||||
|
- Keep lists (of arguments, parameters, initializers...) as lists, not paragraphs. It should either read from top to bottom, or left to right. Not both.
|
||||||
|
|
||||||
|
## Signing your work
|
||||||
|
|
||||||
|
In an effort to ensure that the code you contribute is actually compatible with the licenses in this codebase, we require you to sign-off all your contributions.
|
||||||
|
|
||||||
|
This can be done by appending `-s` to your `git commit` call, or by manually appending the following text to your commit message:
|
||||||
|
|
||||||
|
```
|
||||||
|
<commit message>
|
||||||
|
|
||||||
|
Signed-off-by: Author name <Author email>
|
||||||
|
```
|
||||||
|
|
||||||
|
By signing off your work, you agree to the terms below:
|
||||||
|
|
||||||
|
Developer's Certificate of Origin 1.1
|
||||||
|
|
||||||
|
By making a contribution to this project, I certify that:
|
||||||
|
|
||||||
|
(a) The contribution was created in whole or in part by me and I
|
||||||
|
have the right to submit it under the open source license
|
||||||
|
indicated in the file; or
|
||||||
|
|
||||||
|
(b) The contribution is based upon previous work that, to the best
|
||||||
|
of my knowledge, is covered under an appropriate open source
|
||||||
|
license and I have the right under that license to submit that
|
||||||
|
work with modifications, whether created in whole or in part
|
||||||
|
by me, under the same open source license (unless I am
|
||||||
|
permitted to submit under a different license), as indicated
|
||||||
|
in the file; or
|
||||||
|
|
||||||
|
(c) The contribution was provided directly to me by some other
|
||||||
|
person who certified (a), (b) or (c) and I have not modified
|
||||||
|
it.
|
||||||
|
|
||||||
|
(d) I understand and agree that this project and the contribution
|
||||||
|
are public and that a record of the contribution (including all
|
||||||
|
personal information I submit with it, including my sign-off) is
|
||||||
|
maintained indefinitely and may be redistributed consistent with
|
||||||
|
this project or the open source license(s) involved.
|
||||||
|
|
||||||
|
These terms will be enforced once you create a pull request, and you will be informed automatically if any of your commits aren't signed-off by you.
|
||||||
|
|
||||||
|
As a bonus, you can also [cryptographically sign your commits][gh-signing-commits] and enable [vigilant mode][gh-vigilant-mode] on GitHub.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[gh-signing-commits]: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits
|
||||||
|
[gh-vigilant-mode]: https://docs.github.com/en/authentication/managing-commit-signature-verification/displaying-verification-statuses-for-all-of-your-commits
|
137
COPYING.md
137
COPYING.md
@ -1,33 +1,36 @@
|
|||||||
# PolyMC
|
# PolyMC
|
||||||
|
|
||||||
Copyright (C) 2012-2021 MultiMC Contributors
|
PolyMC - Minecraft Launcher
|
||||||
Copyright (C) 2021-2022 PolyMC Contributors
|
Copyright (C) 2021-2022 PolyMC Contributors
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, version 3.
|
the Free Software Foundation, version 3.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
# Launcher (https://github.com/MultiMC/Launcher)
|
This file incorporates work covered by the following copyright and
|
||||||
Copyright 2012-2021 MultiMC Contributors
|
permission notice:
|
||||||
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
|
Copyright 2013-2021 MultiMC Contributors
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
you may not use this file except in compliance with the License.
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
You may obtain a copy of the License at
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
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.
|
||||||
|
|
||||||
# MinGW runtime (Windows)
|
# MinGW runtime (Windows)
|
||||||
|
|
||||||
@ -51,12 +54,12 @@
|
|||||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
DEALINGS IN THE SOFTWARE.
|
DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
# Qt 5
|
# Qt 5/6
|
||||||
|
|
||||||
Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
Copyright (C) 2022 The Qt Company Ltd and other contributors.
|
||||||
Contact: http://www.qt-project.org/legal
|
Contact: https://www.qt.io/licensing
|
||||||
|
|
||||||
Licensed under LGPL v2.1
|
Licensed under LGPL v3
|
||||||
|
|
||||||
# libnbt++
|
# libnbt++
|
||||||
|
|
||||||
@ -146,27 +149,28 @@
|
|||||||
|
|
||||||
# Quazip
|
# Quazip
|
||||||
|
|
||||||
Copyright (C) 2005-2011 Sergey A. Tachenov
|
Copyright (C) 2005-2021 Sergey A. Tachenov
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it
|
The QuaZip library is licensed under the GNU Lesser General Public
|
||||||
under the terms of the GNU Lesser General Public License as published by
|
License V2.1 plus a static linking exception.
|
||||||
the Free Software Foundation; either version 2 of the License, or (at
|
|
||||||
your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful, but
|
The original ZIP/UNZIP package (MiniZip) is copyrighted by Gilles
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
Vollant and contributors, see quazip/(un)zip.h files for details.
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
Basically it's the zlib license.
|
||||||
General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public License
|
STATIC LINKING EXCEPTION
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
|
||||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
The copyright holders give you permission to link this library with
|
||||||
|
independent modules to produce an executable, regardless of the license
|
||||||
|
terms of these independent modules, and to copy and distribute the
|
||||||
|
resulting executable under terms of your choice, provided that you also
|
||||||
|
meet, for each linked independent module, the terms and conditions of
|
||||||
|
the license of that module. An independent module is a module which is
|
||||||
|
not derived from or based on this library. If you modify this library,
|
||||||
|
you must extend this exception to your version of the library.
|
||||||
|
|
||||||
See COPYING file for the full LGPL text.
|
See COPYING file for the full LGPL text.
|
||||||
|
|
||||||
Original ZIP package is copyrighted by Gilles Vollant, see
|
|
||||||
quazip/(un)zip.h files for details, basically it's zlib license.
|
|
||||||
|
|
||||||
# xz-minidec
|
# xz-minidec
|
||||||
|
|
||||||
XZ decompressor
|
XZ decompressor
|
||||||
@ -213,6 +217,57 @@
|
|||||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
# launcher (`libraries/launcher`)
|
||||||
|
|
||||||
|
PolyMC - Minecraft Launcher
|
||||||
|
Copyright (C) 2021-2022 PolyMC 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.
|
||||||
|
|
||||||
|
Linking this library statically or dynamically with other modules is
|
||||||
|
making a combined work based on this library. Thus, the terms and
|
||||||
|
conditions of the GNU General Public License cover the whole
|
||||||
|
combination.
|
||||||
|
|
||||||
|
As a special exception, the copyright holders of this library give
|
||||||
|
you permission to link this library with independent modules to
|
||||||
|
produce an executable, regardless of the license terms of these
|
||||||
|
independent modules, and to copy and distribute the resulting
|
||||||
|
executable under terms of your choice, provided that you also meet,
|
||||||
|
for each linked independent module, the terms and conditions of the
|
||||||
|
license of that module. An independent module is a module which is
|
||||||
|
not derived from or based on this library. If you modify this
|
||||||
|
library, you may extend this exception to your version of the
|
||||||
|
library, but you are not obliged to do so. If you do not wish to do
|
||||||
|
so, delete this exception statement from your version.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
This file incorporates work covered by the following copyright and
|
||||||
|
permission notice:
|
||||||
|
|
||||||
|
Copyright 2013-2021 MultiMC Contributors
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
# lionshead
|
# lionshead
|
||||||
|
|
||||||
Code has been taken from https://github.com/natefoo/lionshead and loosely
|
Code has been taken from https://github.com/natefoo/lionshead and loosely
|
||||||
|
17
README.md
17
README.md
@ -1,7 +1,6 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="./program_info/org.sneederix.SneedMC.svg" alt="SneedMC logo"/>
|
<img src="./program_info/org.sneederix.SneedMC.svg" alt="SneedMC logo"/>
|
||||||
</p>
|
</p>
|
||||||
<br>
|
|
||||||
|
|
||||||
# SneedMC
|
# SneedMC
|
||||||
|
|
||||||
@ -162,25 +161,17 @@ If you want to contribute to SneedMC you might find it useful to join our Discor
|
|||||||
|
|
||||||
If you want to build SneedMC yourself, check [BUILD.md](BUILD.md) for build instructions.
|
If you want to build SneedMC yourself, check [BUILD.md](BUILD.md) for build instructions.
|
||||||
|
|
||||||
## Code formatting
|
|
||||||
|
|
||||||
Just follow the existing formatting.
|
|
||||||
|
|
||||||
In general, in order of importance:
|
|
||||||
|
|
||||||
- Make sure your IDE is not messing up line endings or whitespace and avoid using linters.
|
|
||||||
- Prefer readability over dogma.
|
|
||||||
- Keep to the existing formatting.
|
|
||||||
- Indent with 4 space unless it's in a submodule.
|
|
||||||
- Keep lists (of arguments, parameters, initializers...) as lists, not paragraphs. It should either read from top to bottom, or left to right. Not both.
|
|
||||||
|
|
||||||
## Translations
|
## Translations
|
||||||
|
|
||||||
The translation effort for SneedMC is hosted on [Weblate](https://hosted.weblate.org/projects/polymc/polymc/) and information about translating SneedMC is available at https://github.com/PolyMC/Translations
|
The translation effort for SneedMC is hosted on [Weblate](https://hosted.weblate.org/projects/polymc/polymc/) and information about translating SneedMC is available at https://github.com/PolyMC/Translations
|
||||||
|
|
||||||
## Download information
|
## Download information
|
||||||
|
|
||||||
To modify download information or change packaging information send a pull request or issue to the website [Here](https://github.com/PolyMC/polymc.github.io/blob/master/src/download.md)
|
To modify download information or change packaging information send a pull request or issue to the website [Here](https://github.com/PolyMC/polymc.github.io/blob/master/src/download.md)
|
||||||
|
|
||||||
## Forking/Redistributing/Custom builds policy
|
## Forking/Redistributing/Custom builds policy
|
||||||
|
|
||||||
SNEED
|
SNEED
|
||||||
|
|
||||||
|
## Sponsors
|
||||||
|
Money is not sneedful
|
||||||
|
@ -60,13 +60,27 @@ Config::Config()
|
|||||||
|
|
||||||
BUILD_PLATFORM = "@Launcher_BUILD_PLATFORM@";
|
BUILD_PLATFORM = "@Launcher_BUILD_PLATFORM@";
|
||||||
|
|
||||||
GIT_COMMIT = "@Launcher_GIT_COMMIT@";
|
MAC_SPARKLE_PUB_KEY = "@MACOSX_SPARKLE_UPDATE_PUBLIC_KEY@";
|
||||||
GIT_REFSPEC = "@Launcher_GIT_REFSPEC@";
|
MAC_SPARKLE_APPCAST_URL = "@MACOSX_SPARKLE_UPDATE_FEED_URL@";
|
||||||
if (GIT_REFSPEC == QStringLiteral("GITDIR-NOTFOUND"))
|
|
||||||
|
if (BUILD_PLATFORM == "macOS" && !MAC_SPARKLE_PUB_KEY.isEmpty() && !MAC_SPARKLE_APPCAST_URL.isEmpty())
|
||||||
{
|
{
|
||||||
VERSION_CHANNEL = QStringLiteral("stable");
|
UPDATER_ENABLED = true;
|
||||||
}
|
}
|
||||||
else if(GIT_REFSPEC.startsWith("refs/heads/"))
|
|
||||||
|
GIT_COMMIT = "@Launcher_GIT_COMMIT@";
|
||||||
|
GIT_TAG = "@Launcher_GIT_TAG@";
|
||||||
|
GIT_REFSPEC = "@Launcher_GIT_REFSPEC@";
|
||||||
|
|
||||||
|
// Assume that builds outside of Git repos are "stable"
|
||||||
|
if (GIT_REFSPEC == QStringLiteral("GITDIR-NOTFOUND")
|
||||||
|
|| GIT_TAG == QStringLiteral("GITDIR-NOTFOUND"))
|
||||||
|
{
|
||||||
|
GIT_REFSPEC = "refs/heads/stable";
|
||||||
|
GIT_TAG = versionString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GIT_REFSPEC.startsWith("refs/heads/"))
|
||||||
{
|
{
|
||||||
VERSION_CHANNEL = GIT_REFSPEC;
|
VERSION_CHANNEL = GIT_REFSPEC;
|
||||||
VERSION_CHANNEL.remove("refs/heads/");
|
VERSION_CHANNEL.remove("refs/heads/");
|
||||||
@ -77,7 +91,7 @@ Config::Config()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VERSION_CHANNEL = QObject::tr("unknown");
|
VERSION_CHANNEL = "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
VERSION_STR = "@Launcher_VERSION_STRING@";
|
VERSION_STR = "@Launcher_VERSION_STRING@";
|
||||||
@ -86,7 +100,7 @@ Config::Config()
|
|||||||
HELP_URL = "@Launcher_HELP_URL@";
|
HELP_URL = "@Launcher_HELP_URL@";
|
||||||
IMGUR_CLIENT_ID = "@Launcher_IMGUR_CLIENT_ID@";
|
IMGUR_CLIENT_ID = "@Launcher_IMGUR_CLIENT_ID@";
|
||||||
MSA_CLIENT_ID = "@Launcher_MSA_CLIENT_ID@";
|
MSA_CLIENT_ID = "@Launcher_MSA_CLIENT_ID@";
|
||||||
CURSEFORGE_API_KEY = "@Launcher_CURSEFORGE_API_KEY@";
|
FLAME_API_KEY = "@Launcher_CURSEFORGE_API_KEY@";
|
||||||
META_URL = "@Launcher_META_URL@";
|
META_URL = "@Launcher_META_URL@";
|
||||||
|
|
||||||
BUG_TRACKER_URL = "@Launcher_BUG_TRACKER_URL@";
|
BUG_TRACKER_URL = "@Launcher_BUG_TRACKER_URL@";
|
||||||
@ -96,12 +110,17 @@ Config::Config()
|
|||||||
SUBREDDIT_URL = "@Launcher_SUBREDDIT_URL@";
|
SUBREDDIT_URL = "@Launcher_SUBREDDIT_URL@";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Config::versionString() const
|
||||||
|
{
|
||||||
|
return QString("%1.%2.%3").arg(VERSION_MAJOR).arg(VERSION_MINOR).arg(VERSION_HOTFIX);
|
||||||
|
}
|
||||||
|
|
||||||
QString Config::printableVersionString() const
|
QString Config::printableVersionString() const
|
||||||
{
|
{
|
||||||
QString vstr = QString("%1.%2.%3").arg(QString::number(VERSION_MAJOR), QString::number(VERSION_MINOR), QString::number(VERSION_HOTFIX));
|
QString vstr = versionString();
|
||||||
|
|
||||||
// If the build is not a main release, append the channel
|
// If the build is not a main release, append the channel
|
||||||
if(VERSION_CHANNEL != "stable")
|
if(VERSION_CHANNEL != "stable" && GIT_TAG != vstr)
|
||||||
{
|
{
|
||||||
vstr += "-" + VERSION_CHANNEL;
|
vstr += "-" + VERSION_CHANNEL;
|
||||||
}
|
}
|
||||||
@ -109,7 +128,7 @@ QString Config::printableVersionString() const
|
|||||||
// if a build number is set, also add it to the end
|
// if a build number is set, also add it to the end
|
||||||
if(VERSION_BUILD >= 0)
|
if(VERSION_BUILD >= 0)
|
||||||
{
|
{
|
||||||
vstr += "-" + QString::number(VERSION_BUILD);
|
vstr += "+build." + QString::number(VERSION_BUILD);
|
||||||
}
|
}
|
||||||
return vstr;
|
return vstr;
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,9 @@ class Config {
|
|||||||
/// The git commit hash of this build
|
/// The git commit hash of this build
|
||||||
QString GIT_COMMIT;
|
QString GIT_COMMIT;
|
||||||
|
|
||||||
|
/// The git tag of this build
|
||||||
|
QString GIT_TAG;
|
||||||
|
|
||||||
/// The git refspec of this build
|
/// The git refspec of this build
|
||||||
QString GIT_REFSPEC;
|
QString GIT_REFSPEC;
|
||||||
|
|
||||||
@ -109,7 +112,7 @@ class Config {
|
|||||||
/**
|
/**
|
||||||
* Client API key for CurseForge
|
* Client API key for CurseForge
|
||||||
*/
|
*/
|
||||||
QString CURSEFORGE_API_KEY;
|
QString FLAME_API_KEY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Metadata repository URL prefix
|
* Metadata repository URL prefix
|
||||||
@ -145,6 +148,7 @@ class Config {
|
|||||||
QString MODRINTH_STAGING_URL = "https://staging-api.modrinth.com/v2";
|
QString MODRINTH_STAGING_URL = "https://staging-api.modrinth.com/v2";
|
||||||
QString MODRINTH_PROD_URL = "https://api.modrinth.com/v2";
|
QString MODRINTH_PROD_URL = "https://api.modrinth.com/v2";
|
||||||
|
|
||||||
|
QString versionString() const;
|
||||||
/**
|
/**
|
||||||
* \brief Converts the Version to a string.
|
* \brief Converts the Version to a string.
|
||||||
* \return The version number in string format (major.minor.revision.build).
|
* \return The version number in string format (major.minor.revision.build).
|
||||||
@ -153,3 +157,4 @@ class Config {
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern const Config BuildConfig;
|
extern const Config BuildConfig;
|
||||||
|
|
||||||
|
@ -7,5 +7,5 @@ add_library(BuildConfig STATIC
|
|||||||
${CMAKE_CURRENT_BINARY_DIR}/BuildConfig.cpp
|
${CMAKE_CURRENT_BINARY_DIR}/BuildConfig.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(BuildConfig Qt5::Core)
|
target_link_libraries(BuildConfig Qt${QT_VERSION_MAJOR}::Core)
|
||||||
target_include_directories(BuildConfig PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
target_include_directories(BuildConfig PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
100
cmake/ECMQueryQt.cmake
Normal file
100
cmake/ECMQueryQt.cmake
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2014 Rohan Garg <rohan16garg@gmail.com>
|
||||||
|
# SPDX-FileCopyrightText: 2014 Alex Merry <alex.merry@kde.org>
|
||||||
|
# SPDX-FileCopyrightText: 2014-2016 Aleix Pol <aleixpol@kde.org>
|
||||||
|
# SPDX-FileCopyrightText: 2017 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||||
|
# SPDX-FileCopyrightText: 2022 Ahmad Samir <a.samir78@gmail.com>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
#[=======================================================================[.rst:
|
||||||
|
ECMQueryQt
|
||||||
|
---------------
|
||||||
|
This module can be used to query the installation paths used by Qt.
|
||||||
|
|
||||||
|
For Qt5 this uses ``qmake``, and for Qt6 this used ``qtpaths`` (the latter has built-in
|
||||||
|
support to query the paths of a target platform when cross-compiling).
|
||||||
|
|
||||||
|
This module defines the following function:
|
||||||
|
::
|
||||||
|
|
||||||
|
ecm_query_qt(<result_variable> <qt_variable> [TRY])
|
||||||
|
|
||||||
|
Passing ``TRY`` will result in the method not making the build fail if the executable
|
||||||
|
used for querying has not been found, but instead simply print a warning message and
|
||||||
|
return an empty string.
|
||||||
|
|
||||||
|
Example usage:
|
||||||
|
|
||||||
|
.. code-block:: cmake
|
||||||
|
|
||||||
|
include(ECMQueryQt)
|
||||||
|
ecm_query_qt(bin_dir QT_INSTALL_BINS)
|
||||||
|
|
||||||
|
If the call succeeds ``${bin_dir}`` will be set to ``<prefix>/path/to/bin/dir`` (e.g.
|
||||||
|
``/usr/lib64/qt/bin/``).
|
||||||
|
|
||||||
|
Since: 5.93
|
||||||
|
#]=======================================================================]
|
||||||
|
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/QtVersionOption.cmake)
|
||||||
|
include(CheckLanguage)
|
||||||
|
check_language(CXX)
|
||||||
|
if (CMAKE_CXX_COMPILER)
|
||||||
|
# Enable the CXX language to let CMake look for config files in library dirs.
|
||||||
|
# See: https://gitlab.kitware.com/cmake/cmake/-/issues/23266
|
||||||
|
enable_language(CXX)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (QT_MAJOR_VERSION STREQUAL "5")
|
||||||
|
# QUIET to accommodate the TRY option
|
||||||
|
find_package(Qt${QT_MAJOR_VERSION}Core QUIET)
|
||||||
|
if(TARGET Qt5::qmake)
|
||||||
|
get_target_property(_qmake_executable_default Qt5::qmake LOCATION)
|
||||||
|
|
||||||
|
set(QUERY_EXECUTABLE ${_qmake_executable_default}
|
||||||
|
CACHE FILEPATH "Location of the Qt5 qmake executable")
|
||||||
|
set(_exec_name_text "Qt5 qmake")
|
||||||
|
set(_cli_option "-query")
|
||||||
|
endif()
|
||||||
|
elseif(QT_MAJOR_VERSION STREQUAL "6")
|
||||||
|
# QUIET to accommodate the TRY option
|
||||||
|
find_package(Qt6 COMPONENTS CoreTools QUIET CONFIG)
|
||||||
|
if (TARGET Qt6::qtpaths)
|
||||||
|
get_target_property(_qtpaths_executable Qt6::qtpaths LOCATION)
|
||||||
|
|
||||||
|
set(QUERY_EXECUTABLE ${_qtpaths_executable}
|
||||||
|
CACHE FILEPATH "Location of the Qt6 qtpaths executable")
|
||||||
|
set(_exec_name_text "Qt6 qtpaths")
|
||||||
|
set(_cli_option "--query")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
function(ecm_query_qt result_variable qt_variable)
|
||||||
|
set(options TRY)
|
||||||
|
set(oneValueArgs)
|
||||||
|
set(multiValueArgs)
|
||||||
|
|
||||||
|
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
|
if(NOT QUERY_EXECUTABLE)
|
||||||
|
if(ARGS_TRY)
|
||||||
|
set(${result_variable} "" PARENT_SCOPE)
|
||||||
|
message(STATUS "No ${_exec_name_text} executable found. Can't check ${qt_variable}")
|
||||||
|
return()
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "No ${_exec_name_text} executable found. Can't check ${qt_variable} as required")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${QUERY_EXECUTABLE} ${_cli_option} "${qt_variable}"
|
||||||
|
RESULT_VARIABLE return_code
|
||||||
|
OUTPUT_VARIABLE output
|
||||||
|
)
|
||||||
|
if(return_code EQUAL 0)
|
||||||
|
string(STRIP "${output}" output)
|
||||||
|
file(TO_CMAKE_PATH "${output}" output_path)
|
||||||
|
set(${result_variable} "${output_path}" PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
message(WARNING "Failed call: ${_command} \"${qt_variable}\"")
|
||||||
|
message(FATAL_ERROR "${_exec_name_text} call failed: ${return_code}")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
@ -3,7 +3,7 @@
|
|||||||
# These functions force a re-configure on each git commit so that you can
|
# These functions force a re-configure on each git commit so that you can
|
||||||
# trust the values of the variables in your build system.
|
# trust the values of the variables in your build system.
|
||||||
#
|
#
|
||||||
# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...])
|
# get_git_head_revision(<refspecvar> <hashvar> [ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR])
|
||||||
#
|
#
|
||||||
# Returns the refspec and sha hash of the current head revision
|
# Returns the refspec and sha hash of the current head revision
|
||||||
#
|
#
|
||||||
@ -12,20 +12,33 @@
|
|||||||
# Returns the results of git describe on the source tree, and adjusting
|
# Returns the results of git describe on the source tree, and adjusting
|
||||||
# the output so that it tests false if an error occurs.
|
# the output so that it tests false if an error occurs.
|
||||||
#
|
#
|
||||||
|
# git_describe_working_tree(<var> [<additional arguments to git describe> ...])
|
||||||
|
#
|
||||||
|
# Returns the results of git describe on the working tree (--dirty option),
|
||||||
|
# and adjusting the output so that it tests false if an error occurs.
|
||||||
|
#
|
||||||
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
|
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
|
||||||
#
|
#
|
||||||
# Returns the results of git describe --exact-match on the source tree,
|
# Returns the results of git describe --exact-match on the source tree,
|
||||||
# and adjusting the output so that it tests false if there was no exact
|
# and adjusting the output so that it tests false if there was no exact
|
||||||
# matching tag.
|
# matching tag.
|
||||||
#
|
#
|
||||||
|
# git_local_changes(<var>)
|
||||||
|
#
|
||||||
|
# Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes.
|
||||||
|
# Uses the return code of "git diff-index --quiet HEAD --".
|
||||||
|
# Does not regard untracked files.
|
||||||
|
#
|
||||||
# Requires CMake 2.6 or newer (uses the 'function' command)
|
# Requires CMake 2.6 or newer (uses the 'function' command)
|
||||||
#
|
#
|
||||||
# Original Author:
|
# Original Author:
|
||||||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
# 2009-2020 Ryan Pavlik <ryan.pavlik@gmail.com> <abiryan@ryand.net>
|
||||||
# http://academic.cleardefinition.com
|
# http://academic.cleardefinition.com
|
||||||
# Iowa State University HCI Graduate Program/VRAC
|
|
||||||
#
|
#
|
||||||
# Copyright Iowa State University 2009-2010.
|
# Copyright 2009-2013, Iowa State University.
|
||||||
|
# Copyright 2013-2020, Ryan Pavlik
|
||||||
|
# Copyright 2013-2020, Contributors
|
||||||
|
# SPDX-License-Identifier: BSL-1.0
|
||||||
# Distributed under the Boost Software License, Version 1.0.
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
# http://www.boost.org/LICENSE_1_0.txt)
|
# http://www.boost.org/LICENSE_1_0.txt)
|
||||||
@ -39,45 +52,124 @@ set(__get_git_revision_description YES)
|
|||||||
# to find the path to this module rather than the path to a calling list file
|
# to find the path to this module rather than the path to a calling list file
|
||||||
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
|
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||||
|
|
||||||
function(get_git_head_revision _refspecvar _hashvar)
|
# Function _git_find_closest_git_dir finds the next closest .git directory
|
||||||
set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
# that is part of any directory in the path defined by _start_dir.
|
||||||
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
|
# The result is returned in the parent scope variable whose name is passed
|
||||||
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
|
# as variable _git_dir_var. If no .git directory can be found, the
|
||||||
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
|
# function returns an empty string via _git_dir_var.
|
||||||
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
|
#
|
||||||
if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
|
# Example: Given a path C:/bla/foo/bar and assuming C:/bla/.git exists and
|
||||||
|
# neither foo nor bar contain a file/directory .git. This wil return
|
||||||
|
# C:/bla/.git
|
||||||
|
#
|
||||||
|
function(_git_find_closest_git_dir _start_dir _git_dir_var)
|
||||||
|
set(cur_dir "${_start_dir}")
|
||||||
|
set(git_dir "${_start_dir}/.git")
|
||||||
|
while(NOT EXISTS "${git_dir}")
|
||||||
|
# .git dir not found, search parent directories
|
||||||
|
set(git_previous_parent "${cur_dir}")
|
||||||
|
get_filename_component(cur_dir "${cur_dir}" DIRECTORY)
|
||||||
|
if(cur_dir STREQUAL git_previous_parent)
|
||||||
# We have reached the root directory, we are not in git
|
# We have reached the root directory, we are not in git
|
||||||
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
|
set(${_git_dir_var}
|
||||||
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
|
""
|
||||||
|
PARENT_SCOPE)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
|
set(git_dir "${cur_dir}/.git")
|
||||||
endwhile()
|
endwhile()
|
||||||
# check if this is a submodule
|
set(${_git_dir_var}
|
||||||
|
"${git_dir}"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(get_git_head_revision _refspecvar _hashvar)
|
||||||
|
_git_find_closest_git_dir("${CMAKE_CURRENT_SOURCE_DIR}" GIT_DIR)
|
||||||
|
|
||||||
|
if("${ARGN}" STREQUAL "ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR")
|
||||||
|
set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR TRUE)
|
||||||
|
else()
|
||||||
|
set(ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR FALSE)
|
||||||
|
endif()
|
||||||
|
if(NOT "${GIT_DIR}" STREQUAL "")
|
||||||
|
file(RELATIVE_PATH _relative_to_source_dir "${CMAKE_SOURCE_DIR}"
|
||||||
|
"${GIT_DIR}")
|
||||||
|
if("${_relative_to_source_dir}" MATCHES "[.][.]" AND NOT ALLOW_LOOKING_ABOVE_CMAKE_SOURCE_DIR)
|
||||||
|
# We've gone above the CMake root dir.
|
||||||
|
set(GIT_DIR "")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
if("${GIT_DIR}" STREQUAL "")
|
||||||
|
set(${_refspecvar}
|
||||||
|
"GITDIR-NOTFOUND"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
set(${_hashvar}
|
||||||
|
"GITDIR-NOTFOUND"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Check if the current source dir is a git submodule or a worktree.
|
||||||
|
# In both cases .git is a file instead of a directory.
|
||||||
|
#
|
||||||
if(NOT IS_DIRECTORY ${GIT_DIR})
|
if(NOT IS_DIRECTORY ${GIT_DIR})
|
||||||
file(READ ${GIT_DIR} submodule)
|
# The following git command will return a non empty string that
|
||||||
string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule})
|
# points to the super project working tree if the current
|
||||||
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
|
# source dir is inside a git submodule.
|
||||||
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
|
# Otherwise the command will return an empty string.
|
||||||
|
#
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${GIT_EXECUTABLE}" rev-parse
|
||||||
|
--show-superproject-working-tree
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
OUTPUT_VARIABLE out
|
||||||
|
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
if(NOT "${out}" STREQUAL "")
|
||||||
|
# If out is empty, GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a submodule
|
||||||
|
file(READ ${GIT_DIR} submodule)
|
||||||
|
string(REGEX REPLACE "gitdir: (.*)$" "\\1" GIT_DIR_RELATIVE
|
||||||
|
${submodule})
|
||||||
|
string(STRIP ${GIT_DIR_RELATIVE} GIT_DIR_RELATIVE)
|
||||||
|
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
|
||||||
|
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE}
|
||||||
|
ABSOLUTE)
|
||||||
|
set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD")
|
||||||
|
else()
|
||||||
|
# GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a worktree
|
||||||
|
file(READ ${GIT_DIR} worktree_ref)
|
||||||
|
# The .git directory contains a path to the worktree information directory
|
||||||
|
# inside the parent git repo of the worktree.
|
||||||
|
#
|
||||||
|
string(REGEX REPLACE "gitdir: (.*)$" "\\1" git_worktree_dir
|
||||||
|
${worktree_ref})
|
||||||
|
string(STRIP ${git_worktree_dir} git_worktree_dir)
|
||||||
|
_git_find_closest_git_dir("${git_worktree_dir}" GIT_DIR)
|
||||||
|
set(HEAD_SOURCE_FILE "${git_worktree_dir}/HEAD")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(HEAD_SOURCE_FILE "${GIT_DIR}/HEAD")
|
||||||
endif()
|
endif()
|
||||||
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
|
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
|
||||||
if(NOT EXISTS "${GIT_DATA}")
|
if(NOT EXISTS "${GIT_DATA}")
|
||||||
file(MAKE_DIRECTORY "${GIT_DATA}")
|
file(MAKE_DIRECTORY "${GIT_DATA}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT EXISTS "${GIT_DIR}/HEAD")
|
if(NOT EXISTS "${HEAD_SOURCE_FILE}")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
set(HEAD_FILE "${GIT_DATA}/HEAD")
|
set(HEAD_FILE "${GIT_DATA}/HEAD")
|
||||||
configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
|
configure_file("${HEAD_SOURCE_FILE}" "${HEAD_FILE}" COPYONLY)
|
||||||
|
|
||||||
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
|
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
|
||||||
"${GIT_DATA}/grabRef.cmake"
|
"${GIT_DATA}/grabRef.cmake" @ONLY)
|
||||||
@ONLY)
|
|
||||||
include("${GIT_DATA}/grabRef.cmake")
|
include("${GIT_DATA}/grabRef.cmake")
|
||||||
|
|
||||||
set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
|
set(${_refspecvar}
|
||||||
set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE)
|
"${HEAD_REF}"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
set(${_hashvar}
|
||||||
|
"${HEAD_HASH}"
|
||||||
|
PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(git_describe _var)
|
function(git_describe _var)
|
||||||
@ -86,45 +178,107 @@ function(git_describe _var)
|
|||||||
endif()
|
endif()
|
||||||
get_git_head_revision(refspec hash)
|
get_git_head_revision(refspec hash)
|
||||||
if(NOT GIT_FOUND)
|
if(NOT GIT_FOUND)
|
||||||
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
|
set(${_var}
|
||||||
|
"GIT-NOTFOUND"
|
||||||
|
PARENT_SCOPE)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
if(NOT hash)
|
if(NOT hash)
|
||||||
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
|
set(${_var}
|
||||||
|
"HEAD-HASH-NOTFOUND"
|
||||||
|
PARENT_SCOPE)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# TODO sanitize
|
# TODO sanitize
|
||||||
#if((${ARGN}" MATCHES "&&") OR
|
#if((${ARGN}" MATCHES "&&") OR
|
||||||
# (ARGN MATCHES "||") OR
|
# (ARGN MATCHES "||") OR
|
||||||
# (ARGN MATCHES "\\;"))
|
# (ARGN MATCHES "\\;"))
|
||||||
# message("Please report the following error to the project!")
|
# message("Please report the following error to the project!")
|
||||||
# message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
|
# message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
|
||||||
#endif()
|
#endif()
|
||||||
|
|
||||||
#message(STATUS "Arguments to execute_process: ${ARGN}")
|
#message(STATUS "Arguments to execute_process: ${ARGN}")
|
||||||
|
|
||||||
execute_process(COMMAND
|
execute_process(
|
||||||
"${GIT_EXECUTABLE}"
|
COMMAND "${GIT_EXECUTABLE}" describe --tags --always ${hash} ${ARGN}
|
||||||
describe
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
${hash}
|
RESULT_VARIABLE res
|
||||||
${ARGN}
|
OUTPUT_VARIABLE out
|
||||||
WORKING_DIRECTORY
|
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
|
||||||
RESULT_VARIABLE
|
|
||||||
res
|
|
||||||
OUTPUT_VARIABLE
|
|
||||||
out
|
|
||||||
ERROR_QUIET
|
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
||||||
if(NOT res EQUAL 0)
|
if(NOT res EQUAL 0)
|
||||||
set(out "${out}-${res}-NOTFOUND")
|
set(out "${out}-${res}-NOTFOUND")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(${_var} "${out}" PARENT_SCOPE)
|
set(${_var}
|
||||||
|
"${out}"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(git_describe_working_tree _var)
|
||||||
|
if(NOT GIT_FOUND)
|
||||||
|
find_package(Git QUIET)
|
||||||
|
endif()
|
||||||
|
if(NOT GIT_FOUND)
|
||||||
|
set(${_var}
|
||||||
|
"GIT-NOTFOUND"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${GIT_EXECUTABLE}" describe --dirty ${ARGN}
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
RESULT_VARIABLE res
|
||||||
|
OUTPUT_VARIABLE out
|
||||||
|
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
if(NOT res EQUAL 0)
|
||||||
|
set(out "${out}-${res}-NOTFOUND")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(${_var}
|
||||||
|
"${out}"
|
||||||
|
PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(git_get_exact_tag _var)
|
function(git_get_exact_tag _var)
|
||||||
git_describe(out --exact-match ${ARGN})
|
git_describe(out --exact-match ${ARGN})
|
||||||
set(${_var} "${out}" PARENT_SCOPE)
|
set(${_var}
|
||||||
|
"${out}"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(git_local_changes _var)
|
||||||
|
if(NOT GIT_FOUND)
|
||||||
|
find_package(Git QUIET)
|
||||||
|
endif()
|
||||||
|
get_git_head_revision(refspec hash)
|
||||||
|
if(NOT GIT_FOUND)
|
||||||
|
set(${_var}
|
||||||
|
"GIT-NOTFOUND"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
if(NOT hash)
|
||||||
|
set(${_var}
|
||||||
|
"HEAD-HASH-NOTFOUND"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${GIT_EXECUTABLE}" diff-index --quiet HEAD --
|
||||||
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
|
RESULT_VARIABLE res
|
||||||
|
OUTPUT_VARIABLE out
|
||||||
|
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
if(res EQUAL 0)
|
||||||
|
set(${_var}
|
||||||
|
"CLEAN"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
set(${_var}
|
||||||
|
"DIRTY"
|
||||||
|
PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
@ -8,10 +8,12 @@
|
|||||||
# http://academic.cleardefinition.com
|
# http://academic.cleardefinition.com
|
||||||
# Iowa State University HCI Graduate Program/VRAC
|
# Iowa State University HCI Graduate Program/VRAC
|
||||||
#
|
#
|
||||||
# Copyright Iowa State University 2009-2010.
|
# Copyright 2009-2012, Iowa State University
|
||||||
|
# Copyright 2011-2015, Contributors
|
||||||
# Distributed under the Boost Software License, Version 1.0.
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
# http://www.boost.org/LICENSE_1_0.txt)
|
# http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
# SPDX-License-Identifier: BSL-1.0
|
||||||
|
|
||||||
set(HEAD_HASH)
|
set(HEAD_HASH)
|
||||||
|
|
||||||
@ -19,23 +21,23 @@ file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
|
|||||||
|
|
||||||
string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
|
string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
|
||||||
if(HEAD_CONTENTS MATCHES "ref")
|
if(HEAD_CONTENTS MATCHES "ref")
|
||||||
# named branch
|
# named branch
|
||||||
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
|
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
|
||||||
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
|
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
|
||||||
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
|
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
|
||||||
else()
|
else()
|
||||||
configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
|
configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
|
||||||
file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
|
file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
|
||||||
if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
|
if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
|
||||||
set(HEAD_HASH "${CMAKE_MATCH_1}")
|
set(HEAD_HASH "${CMAKE_MATCH_1}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
# detached HEAD
|
# detached HEAD
|
||||||
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
|
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT HEAD_HASH)
|
if(NOT HEAD_HASH)
|
||||||
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
|
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
|
||||||
string(STRIP "${HEAD_HASH}" HEAD_HASH)
|
string(STRIP "${HEAD_HASH}" HEAD_HASH)
|
||||||
endif()
|
endif()
|
||||||
|
@ -40,5 +40,9 @@
|
|||||||
<true/>
|
<true/>
|
||||||
<key>NSHumanReadableCopyright</key>
|
<key>NSHumanReadableCopyright</key>
|
||||||
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
|
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
|
||||||
|
<key>SUPublicEDKey</key>
|
||||||
|
<string>${MACOSX_SPARKLE_UPDATE_PUBLIC_KEY}</string>
|
||||||
|
<key>SUFeedURL</key>
|
||||||
|
<string>${MACOSX_SPARKLE_UPDATE_FEED_URL}</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
if(__QMAKEQUERY_CMAKE__)
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
set(__QMAKEQUERY_CMAKE__ TRUE)
|
|
||||||
|
|
||||||
get_target_property(QMAKE_EXECUTABLE Qt5::qmake LOCATION)
|
|
||||||
|
|
||||||
function(QUERY_QMAKE VAR RESULT)
|
|
||||||
exec_program(${QMAKE_EXECUTABLE} ARGS "-query ${VAR}" RETURN_VALUE return_code OUTPUT_VARIABLE output )
|
|
||||||
if(NOT return_code)
|
|
||||||
file(TO_CMAKE_PATH "${output}" output)
|
|
||||||
set(${RESULT} ${output} PARENT_SCOPE)
|
|
||||||
endif(NOT return_code)
|
|
||||||
endfunction(QUERY_QMAKE)
|
|
38
cmake/QtVersionOption.cmake
Normal file
38
cmake/QtVersionOption.cmake
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#.rst:
|
||||||
|
# QtVersionOption
|
||||||
|
# ---------------
|
||||||
|
#
|
||||||
|
# Adds a build option to select the major Qt version if necessary,
|
||||||
|
# that is, if the major Qt version has not yet been determined otherwise
|
||||||
|
# (e.g. by a corresponding find_package() call).
|
||||||
|
#
|
||||||
|
# This module is typically included by other modules requiring knowledge
|
||||||
|
# about the major Qt version.
|
||||||
|
#
|
||||||
|
# ``QT_MAJOR_VERSION`` is defined to either be "5" or "6".
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Since 5.82.0.
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
if (DEFINED QT_MAJOR_VERSION)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (TARGET Qt5::Core)
|
||||||
|
set(QT_MAJOR_VERSION 5)
|
||||||
|
elseif (TARGET Qt6::Core)
|
||||||
|
set(QT_MAJOR_VERSION 6)
|
||||||
|
else()
|
||||||
|
option(BUILD_WITH_QT6 "Build against Qt 6" OFF)
|
||||||
|
|
||||||
|
if (BUILD_WITH_QT6)
|
||||||
|
set(QT_MAJOR_VERSION 6)
|
||||||
|
else()
|
||||||
|
set(QT_MAJOR_VERSION 5)
|
||||||
|
endif()
|
||||||
|
endif()
|
97
cmake/QtVersionlessBackport.cmake
Normal file
97
cmake/QtVersionlessBackport.cmake
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
#=============================================================================
|
||||||
|
# Copyright 2005-2011 Kitware, Inc.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this 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.
|
||||||
|
#
|
||||||
|
# * Neither the name of Kitware, Inc. nor the names of its
|
||||||
|
# contributors may be used to endorse or promote products derived
|
||||||
|
# from this software without specific prior written permission.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
# HOLDER 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.
|
||||||
|
#=============================================================================
|
||||||
|
|
||||||
|
# From Qt5CoreMacros.cmake
|
||||||
|
|
||||||
|
function(qt_generate_moc)
|
||||||
|
if(QT_VERSION_MAJOR EQUAL 5)
|
||||||
|
qt5_generate_moc(${ARGV})
|
||||||
|
elseif(QT_VERSION_MAJOR EQUAL 6)
|
||||||
|
qt6_generate_moc(${ARGV})
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(qt_wrap_cpp outfiles)
|
||||||
|
if(QT_VERSION_MAJOR EQUAL 5)
|
||||||
|
qt5_wrap_cpp("${outfiles}" ${ARGN})
|
||||||
|
elseif(QT_VERSION_MAJOR EQUAL 6)
|
||||||
|
qt6_wrap_cpp("${outfiles}" ${ARGN})
|
||||||
|
endif()
|
||||||
|
set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(qt_add_binary_resources)
|
||||||
|
if(QT_VERSION_MAJOR EQUAL 5)
|
||||||
|
qt5_add_binary_resources(${ARGV})
|
||||||
|
elseif(QT_VERSION_MAJOR EQUAL 6)
|
||||||
|
qt6_add_binary_resources(${ARGV})
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(qt_add_resources outfiles)
|
||||||
|
if(QT_VERSION_MAJOR EQUAL 5)
|
||||||
|
qt5_add_resources("${outfiles}" ${ARGN})
|
||||||
|
elseif(QT_VERSION_MAJOR EQUAL 6)
|
||||||
|
qt6_add_resources("${outfiles}" ${ARGN})
|
||||||
|
endif()
|
||||||
|
set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(qt_add_big_resources outfiles)
|
||||||
|
if(QT_VERSION_MAJOR EQUAL 5)
|
||||||
|
qt5_add_big_resources(${outfiles} ${ARGN})
|
||||||
|
elseif(QT_VERSION_MAJOR EQUAL 6)
|
||||||
|
qt6_add_big_resources(${outfiles} ${ARGN})
|
||||||
|
endif()
|
||||||
|
set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(qt_import_plugins)
|
||||||
|
if(QT_VERSION_MAJOR EQUAL 5)
|
||||||
|
qt5_import_plugins(${ARGV})
|
||||||
|
elseif(QT_VERSION_MAJOR EQUAL 6)
|
||||||
|
qt6_import_plugins(${ARGV})
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
# From Qt5WidgetsMacros.cmake
|
||||||
|
|
||||||
|
function(qt_wrap_ui outfiles)
|
||||||
|
if(QT_VERSION_MAJOR EQUAL 5)
|
||||||
|
qt5_wrap_ui("${outfiles}" ${ARGN})
|
||||||
|
elseif(QT_VERSION_MAJOR EQUAL 6)
|
||||||
|
qt6_wrap_ui("${outfiles}" ${ARGN})
|
||||||
|
endif()
|
||||||
|
set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
@ -1,50 +0,0 @@
|
|||||||
find_package(Qt5Test REQUIRED)
|
|
||||||
|
|
||||||
set(TEST_RESOURCE_PATH ${CMAKE_CURRENT_LIST_DIR})
|
|
||||||
|
|
||||||
message(${TEST_RESOURCE_PATH})
|
|
||||||
|
|
||||||
function(add_unit_test name)
|
|
||||||
if(BUILD_TESTING)
|
|
||||||
set(options "")
|
|
||||||
set(oneValueArgs DATA)
|
|
||||||
set(multiValueArgs SOURCES LIBS)
|
|
||||||
|
|
||||||
cmake_parse_arguments(OPT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
add_executable(${name}_test ${OPT_SOURCES} ${TEST_RESOURCE_PATH}/UnitTest/test.rc)
|
|
||||||
else()
|
|
||||||
add_executable(${name}_test ${OPT_SOURCES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT "${OPT_DATA}" STREQUAL "")
|
|
||||||
set(TEST_DATA_PATH "${CMAKE_CURRENT_BINARY_DIR}/data")
|
|
||||||
set(TEST_DATA_PATH_SRC "${CMAKE_CURRENT_SOURCE_DIR}/${OPT_DATA}")
|
|
||||||
message("From ${TEST_DATA_PATH_SRC} to ${TEST_DATA_PATH}")
|
|
||||||
string(REGEX REPLACE "[/\\:]" "_" DATA_TARGET_NAME "${TEST_DATA_PATH_SRC}")
|
|
||||||
if(UNIX)
|
|
||||||
# on unix we get the third / from the filename
|
|
||||||
set(TEST_DATA_URL "file://${TEST_DATA_PATH}")
|
|
||||||
else()
|
|
||||||
# we don't on windows, so we have to add it ourselves
|
|
||||||
set(TEST_DATA_URL "file:///${TEST_DATA_PATH}")
|
|
||||||
endif()
|
|
||||||
if(NOT TARGET "${DATA_TARGET_NAME}")
|
|
||||||
add_custom_target(${DATA_TARGET_NAME})
|
|
||||||
add_dependencies(${name}_test ${DATA_TARGET_NAME})
|
|
||||||
add_custom_command(
|
|
||||||
TARGET ${DATA_TARGET_NAME}
|
|
||||||
COMMAND ${CMAKE_COMMAND} "-DTEST_DATA_URL=${TEST_DATA_URL}" -DSOURCE=${TEST_DATA_PATH_SRC} -DDESTINATION=${TEST_DATA_PATH} -P ${TEST_RESOURCE_PATH}/UnitTest/generate_test_data.cmake
|
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(${name}_test Qt5::Test ${OPT_LIBS})
|
|
||||||
|
|
||||||
target_include_directories(${name}_test PRIVATE "${TEST_RESOURCE_PATH}/UnitTest/")
|
|
||||||
|
|
||||||
add_test(NAME ${name} COMMAND ${name}_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
@ -1,28 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QFile>
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QTest>
|
|
||||||
#include <QDir>
|
|
||||||
|
|
||||||
#define expandstr(s) expandstr2(s)
|
|
||||||
#define expandstr2(s) #s
|
|
||||||
|
|
||||||
class TestsInternal
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static QByteArray readFile(const QString &fileName)
|
|
||||||
{
|
|
||||||
QFile f(fileName);
|
|
||||||
f.open(QFile::ReadOnly);
|
|
||||||
return f.readAll();
|
|
||||||
}
|
|
||||||
static QString readFileUtf8(const QString &fileName)
|
|
||||||
{
|
|
||||||
return QString::fromUtf8(readFile(fileName));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#define GET_TEST_FILE(file) TestsInternal::readFile(QFINDTESTDATA(file))
|
|
||||||
#define GET_TEST_FILE_UTF8(file) TestsInternal::readFileUtf8(QFINDTESTDATA(file))
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
|||||||
# Copy files from source directory to destination directory, substituting any
|
|
||||||
# variables. Create destination directory if it does not exist.
|
|
||||||
|
|
||||||
function(configure_files srcDir destDir)
|
|
||||||
make_directory(${destDir})
|
|
||||||
|
|
||||||
file(GLOB templateFiles RELATIVE ${srcDir} ${srcDir}/*)
|
|
||||||
foreach(templateFile ${templateFiles})
|
|
||||||
set(srcTemplatePath ${srcDir}/${templateFile})
|
|
||||||
if(NOT IS_DIRECTORY ${srcTemplatePath})
|
|
||||||
configure_file(
|
|
||||||
${srcTemplatePath}
|
|
||||||
${destDir}/${templateFile}
|
|
||||||
@ONLY
|
|
||||||
NEWLINE_STYLE LF
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
configure_files("${srcTemplatePath}" "${destDir}/${templateFile}")
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
configure_files(${SOURCE} ${DESTINATION})
|
|
@ -1,27 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
||||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
|
|
||||||
<assemblyIdentity name="Launcher.Test.0" type="win32" version="5.0.0.0" />
|
|
||||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
|
||||||
<security>
|
|
||||||
<requestedPrivileges>
|
|
||||||
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
|
|
||||||
</requestedPrivileges>
|
|
||||||
</security>
|
|
||||||
</trustInfo>
|
|
||||||
<dependency>
|
|
||||||
<dependentAssembly>
|
|
||||||
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*"/>
|
|
||||||
</dependentAssembly>
|
|
||||||
</dependency>
|
|
||||||
<description>Custom Minecraft launcher for managing multiple installs.</description>
|
|
||||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
|
||||||
<application>
|
|
||||||
<!--The ID below indicates app support for Windows Vista -->
|
|
||||||
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
|
|
||||||
<!--The ID below indicates app support for Windows 7 -->
|
|
||||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
|
|
||||||
<!--The ID below indicates app support for Windows Developer Preview / Windows 8 -->
|
|
||||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
|
|
||||||
</application>
|
|
||||||
</compatibility>
|
|
||||||
</assembly>
|
|
@ -1,28 +0,0 @@
|
|||||||
#ifndef WIN32_LEAN_AND_MEAN
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#endif
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
1 RT_MANIFEST "test.manifest"
|
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
|
||||||
FILEVERSION 1,0,0,0
|
|
||||||
FILEOS VOS_NT_WINDOWS32
|
|
||||||
FILETYPE VFT_APP
|
|
||||||
BEGIN
|
|
||||||
BLOCK "StringFileInfo"
|
|
||||||
BEGIN
|
|
||||||
BLOCK "000004b0"
|
|
||||||
BEGIN
|
|
||||||
VALUE "CompanyName", "MultiMC & PolyMC Contributors"
|
|
||||||
VALUE "FileDescription", "Testcase"
|
|
||||||
VALUE "FileVersion", "1.0.0.0"
|
|
||||||
VALUE "ProductName", "Launcher Testcase"
|
|
||||||
VALUE "ProductVersion", "5"
|
|
||||||
END
|
|
||||||
END
|
|
||||||
BLOCK "VarFileInfo"
|
|
||||||
BEGIN
|
|
||||||
VALUE "Translation", 0x0000, 0x04b0 // Unicode
|
|
||||||
END
|
|
||||||
END
|
|
16
flake.lock
16
flake.lock
@ -19,26 +19,26 @@
|
|||||||
"libnbtplusplus": {
|
"libnbtplusplus": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1591558203,
|
"lastModified": 1650031308,
|
||||||
"narHash": "sha256-QgvNvaoFflCXEPCCFBCeZvYTpuiwScBG7EosUgFwFNQ=",
|
"narHash": "sha256-TvVOjkUobYJD9itQYueELJX3wmecvEdCbJ0FinW2mL4=",
|
||||||
"owner": "multimc",
|
"owner": "PolyMC",
|
||||||
"repo": "libnbtplusplus",
|
"repo": "libnbtplusplus",
|
||||||
"rev": "dc72a20b7efd304d12af2025223fad07b4b78464",
|
"rev": "2203af7eeb48c45398139b583615134efd8d407f",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "multimc",
|
"owner": "PolyMC",
|
||||||
"repo": "libnbtplusplus",
|
"repo": "libnbtplusplus",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1654665288,
|
"lastModified": 1658119717,
|
||||||
"narHash": "sha256-7blJpfoZEu7GKb84uh3io/5eSJNdaagXD9d15P9iQMs=",
|
"narHash": "sha256-4upOZIQQ7Bc4CprqnHsKnqYfw+arJeAuU+QcpjYBXW0=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "43ecbe7840d155fa933ee8a500fb00dbbc651fc8",
|
"rev": "9eb60f25aff0d2218c848dd4574a0ab5e296cabe",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
15
flake.nix
15
flake.nix
@ -4,28 +4,33 @@
|
|||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
||||||
flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
|
flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
|
||||||
libnbtplusplus = { url = "github:multimc/libnbtplusplus"; flake = false; };
|
libnbtplusplus = { url = "github:PolyMC/libnbtplusplus"; flake = false; };
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, libnbtplusplus, ... }:
|
outputs = { self, nixpkgs, libnbtplusplus, ... }:
|
||||||
let
|
let
|
||||||
# Generate a user-friendly version number.
|
# User-friendly version number.
|
||||||
version = builtins.substring 0 8 self.lastModifiedDate;
|
version = builtins.substring 0 8 self.lastModifiedDate;
|
||||||
|
|
||||||
# System types to support (qtbase is currently broken for "aarch64-darwin")
|
# Supported systems (qtbase is currently broken for "aarch64-darwin")
|
||||||
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" ];
|
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" ];
|
||||||
|
|
||||||
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
|
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
|
||||||
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
||||||
|
|
||||||
# Nixpkgs instantiated for supported system types.
|
# Nixpkgs instantiated for supported systems.
|
||||||
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
|
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; };
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages = forAllSystems (system: rec {
|
packages = forAllSystems (system: rec {
|
||||||
sneedmc = pkgs.${system}.libsForQt5.callPackage ./nix { inherit version self libnbtplusplus; };
|
sneedmc = pkgs.${system}.libsForQt5.callPackage ./nix { inherit version self libnbtplusplus; };
|
||||||
sneedmc-qt6 = pkgs.${system}.qt6Packages.callPackage ./nix { inherit version self libnbtplusplus; };
|
sneedmc-qt6 = pkgs.${system}.qt6Packages.callPackage ./nix { inherit version self libnbtplusplus; };
|
||||||
|
|
||||||
default = sneedmc;
|
default = sneedmc;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -84,6 +84,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStyleFactory>
|
#include <QStyleFactory>
|
||||||
#include <QWindow>
|
#include <QWindow>
|
||||||
|
#include <QIcon>
|
||||||
|
|
||||||
#include "InstanceList.h"
|
#include "InstanceList.h"
|
||||||
|
|
||||||
@ -97,7 +98,6 @@
|
|||||||
#include "tools/JVisualVM.h"
|
#include "tools/JVisualVM.h"
|
||||||
#include "tools/MCEditTool.h"
|
#include "tools/MCEditTool.h"
|
||||||
|
|
||||||
#include <xdgicon.h>
|
|
||||||
#include "settings/INISettingsObject.h"
|
#include "settings/INISettingsObject.h"
|
||||||
#include "settings/Setting.h"
|
#include "settings/Setting.h"
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
setOrganizationName(BuildConfig.LAUNCHER_NAME);
|
setOrganizationName(BuildConfig.LAUNCHER_NAME);
|
||||||
setOrganizationDomain(BuildConfig.LAUNCHER_DOMAIN);
|
setOrganizationDomain(BuildConfig.LAUNCHER_DOMAIN);
|
||||||
setApplicationName(BuildConfig.LAUNCHER_NAME);
|
setApplicationName(BuildConfig.LAUNCHER_NAME);
|
||||||
setApplicationDisplayName(BuildConfig.LAUNCHER_DISPLAYNAME);
|
setApplicationDisplayName(QString("%1 %2").arg(BuildConfig.LAUNCHER_DISPLAYNAME, BuildConfig.printableVersionString()));
|
||||||
setApplicationVersion(BuildConfig.printableVersionString());
|
setApplicationVersion(BuildConfig.printableVersionString());
|
||||||
setDesktopFileName(BuildConfig.LAUNCHER_DESKTOPFILENAME);
|
setDesktopFileName(BuildConfig.LAUNCHER_DESKTOPFILENAME);
|
||||||
startTime = QDateTime::currentDateTime();
|
startTime = QDateTime::currentDateTime();
|
||||||
@ -291,10 +291,6 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
// on macOS, touch the root to force Finder to reload the .app metadata (and fix any icon change issues)
|
// on macOS, touch the root to force Finder to reload the .app metadata (and fix any icon change issues)
|
||||||
FS::updateTimestamp(m_rootPath);
|
FS::updateTimestamp(m_rootPath);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LAUNCHER_JARS_LOCATION
|
|
||||||
m_jarsPath = TOSTRING(LAUNCHER_JARS_LOCATION);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString adjustedBy;
|
QString adjustedBy;
|
||||||
@ -513,6 +509,13 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
// Initialize application settings
|
// Initialize application settings
|
||||||
{
|
{
|
||||||
m_settings.reset(new INISettingsObject(BuildConfig.LAUNCHER_CONFIGFILE, this));
|
m_settings.reset(new INISettingsObject(BuildConfig.LAUNCHER_CONFIGFILE, this));
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
// Updates
|
||||||
|
// Multiple channels are separated by spaces
|
||||||
|
m_settings->registerSetting("UpdateChannel", BuildConfig.VERSION_CHANNEL);
|
||||||
|
m_settings->registerSetting("AutoUpdate", true);
|
||||||
|
>>>>>>> upstream/develop
|
||||||
|
|
||||||
// Theming
|
// Theming
|
||||||
m_settings->registerSetting("IconTheme", QString("pe_colored"));
|
m_settings->registerSetting("IconTheme", QString("pe_colored"));
|
||||||
@ -588,6 +591,7 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
m_settings->registerSetting("JavaPath", "");
|
m_settings->registerSetting("JavaPath", "");
|
||||||
m_settings->registerSetting("JavaTimestamp", 0);
|
m_settings->registerSetting("JavaTimestamp", 0);
|
||||||
m_settings->registerSetting("JavaArchitecture", "");
|
m_settings->registerSetting("JavaArchitecture", "");
|
||||||
|
m_settings->registerSetting("JavaRealArchitecture", "");
|
||||||
m_settings->registerSetting("JavaVersion", "");
|
m_settings->registerSetting("JavaVersion", "");
|
||||||
m_settings->registerSetting("JavaVendor", "");
|
m_settings->registerSetting("JavaVendor", "");
|
||||||
m_settings->registerSetting("LastHostname", "");
|
m_settings->registerSetting("LastHostname", "");
|
||||||
@ -599,6 +603,11 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
m_settings->registerSetting("UseNativeOpenAL", false);
|
m_settings->registerSetting("UseNativeOpenAL", false);
|
||||||
m_settings->registerSetting("UseNativeGLFW", false);
|
m_settings->registerSetting("UseNativeGLFW", false);
|
||||||
|
|
||||||
|
// Peformance related options
|
||||||
|
m_settings->registerSetting("EnableFeralGamemode", false);
|
||||||
|
m_settings->registerSetting("EnableMangoHud", false);
|
||||||
|
m_settings->registerSetting("UseDiscreteGpu", false);
|
||||||
|
|
||||||
// Game time
|
// Game time
|
||||||
m_settings->registerSetting("ShowGameTime", true);
|
m_settings->registerSetting("ShowGameTime", true);
|
||||||
m_settings->registerSetting("ShowGlobalGameTime", true);
|
m_settings->registerSetting("ShowGlobalGameTime", true);
|
||||||
@ -672,9 +681,20 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
m_settings->registerSetting("CloseAfterLaunch", false);
|
m_settings->registerSetting("CloseAfterLaunch", false);
|
||||||
m_settings->registerSetting("QuitAfterGameStop", false);
|
m_settings->registerSetting("QuitAfterGameStop", false);
|
||||||
|
|
||||||
// Custom MSA credentials
|
// Custom Microsoft Authentication Client ID
|
||||||
m_settings->registerSetting("MSAClientIDOverride", "");
|
m_settings->registerSetting("MSAClientIDOverride", "");
|
||||||
m_settings->registerSetting("CFKeyOverride", "");
|
|
||||||
|
// Custom Flame API Key
|
||||||
|
{
|
||||||
|
m_settings->registerSetting("CFKeyOverride", "");
|
||||||
|
m_settings->registerSetting("FlameKeyOverride", "");
|
||||||
|
|
||||||
|
QString flameKey = m_settings->get("CFKeyOverride").toString();
|
||||||
|
|
||||||
|
if (!flameKey.isEmpty())
|
||||||
|
m_settings->set("FlameKeyOverride", flameKey);
|
||||||
|
m_settings->reset("CFKeyOverride");
|
||||||
|
}
|
||||||
m_settings->registerSetting("UserAgentOverride", "");
|
m_settings->registerSetting("UserAgentOverride", "");
|
||||||
|
|
||||||
// Init page provider
|
// Init page provider
|
||||||
@ -718,6 +738,19 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
qDebug() << "<> Translations loaded.";
|
qDebug() << "<> Translations loaded.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
// initialize the updater
|
||||||
|
if(BuildConfig.UPDATER_ENABLED)
|
||||||
|
{
|
||||||
|
auto platform = getIdealPlatform(BuildConfig.BUILD_PLATFORM);
|
||||||
|
auto channelUrl = BuildConfig.UPDATER_BASE + platform + "/channels.json";
|
||||||
|
qDebug() << "Initializing updater with platform: " << platform << " -- " << channelUrl;
|
||||||
|
m_updateChecker.reset(new UpdateChecker(m_network, channelUrl, BuildConfig.VERSION_CHANNEL, BuildConfig.VERSION_BUILD));
|
||||||
|
qDebug() << "<> Updater started.";
|
||||||
|
}
|
||||||
|
|
||||||
|
>>>>>>> upstream/develop
|
||||||
// Instance icons
|
// Instance icons
|
||||||
{
|
{
|
||||||
auto setting = APPLICATION->settings()->getSetting("IconsDir");
|
auto setting = APPLICATION->settings()->getSetting("IconsDir");
|
||||||
@ -1134,7 +1167,7 @@ void Application::setApplicationTheme(const QString& name, bool initial)
|
|||||||
|
|
||||||
void Application::setIconTheme(const QString& name)
|
void Application::setIconTheme(const QString& name)
|
||||||
{
|
{
|
||||||
XdgIcon::setThemeName(name);
|
QIcon::setThemeName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon Application::getThemedIcon(const QString& name)
|
QIcon Application::getThemedIcon(const QString& name)
|
||||||
@ -1142,7 +1175,7 @@ QIcon Application::getThemedIcon(const QString& name)
|
|||||||
if(name == "logo") {
|
if(name == "logo") {
|
||||||
return QIcon(":/org.sneederix.SneedMC.svg");
|
return QIcon(":/org.sneederix.SneedMC.svg");
|
||||||
}
|
}
|
||||||
return XdgIcon::fromTheme(name);
|
return QIcon::fromTheme(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::openJsonEditor(const QString &filename)
|
bool Application::openJsonEditor(const QString &filename)
|
||||||
@ -1339,6 +1372,10 @@ MainWindow* Application::showMainWindow(bool minimized)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_mainWindow->checkInstancePathForProblems();
|
m_mainWindow->checkInstancePathForProblems();
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
connect(this, &Application::updateAllowedChanged, m_mainWindow, &MainWindow::updatesAllowedChanged);
|
||||||
|
>>>>>>> upstream/develop
|
||||||
connect(m_mainWindow, &MainWindow::isClosing, this, &Application::on_windowClose);
|
connect(m_mainWindow, &MainWindow::isClosing, this, &Application::on_windowClose);
|
||||||
m_openWindows++;
|
m_openWindows++;
|
||||||
}
|
}
|
||||||
@ -1480,13 +1517,32 @@ shared_qobject_ptr<Meta::Index> Application::metadataIndex()
|
|||||||
return m_metadataIndex;
|
return m_metadataIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Application::getJarsPath()
|
Application::Capabilities Application::currentCapabilities()
|
||||||
{
|
{
|
||||||
if(m_jarsPath.isEmpty())
|
Capabilities c;
|
||||||
|
if (!getMSAClientID().isEmpty())
|
||||||
|
c |= SupportsMSA;
|
||||||
|
if (!getFlameAPIKey().isEmpty())
|
||||||
|
c |= SupportsFlame;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Application::getJarPath(QString jarFile)
|
||||||
|
{
|
||||||
|
QStringList potentialPaths = {
|
||||||
|
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
|
||||||
|
FS::PathCombine(m_rootPath, "share/jars"),
|
||||||
|
#endif
|
||||||
|
FS::PathCombine(m_rootPath, "jars"),
|
||||||
|
FS::PathCombine(applicationDirPath(), "jars")
|
||||||
|
};
|
||||||
|
for(QString p : potentialPaths)
|
||||||
{
|
{
|
||||||
return FS::PathCombine(QCoreApplication::applicationDirPath(), "jars");
|
QString jarPath = FS::PathCombine(p, jarFile);
|
||||||
|
if (QFileInfo(jarPath).isFile())
|
||||||
|
return jarPath;
|
||||||
}
|
}
|
||||||
return FS::PathCombine(m_rootPath, m_jarsPath);
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Application::getMSAClientID()
|
QString Application::getMSAClientID()
|
||||||
@ -1499,14 +1555,14 @@ QString Application::getMSAClientID()
|
|||||||
return BuildConfig.MSA_CLIENT_ID;
|
return BuildConfig.MSA_CLIENT_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Application::getCurseKey()
|
QString Application::getFlameAPIKey()
|
||||||
{
|
{
|
||||||
QString keyOverride = m_settings->get("CFKeyOverride").toString();
|
QString keyOverride = m_settings->get("FlameKeyOverride").toString();
|
||||||
if (!keyOverride.isEmpty()) {
|
if (!keyOverride.isEmpty()) {
|
||||||
return keyOverride;
|
return keyOverride;
|
||||||
}
|
}
|
||||||
|
|
||||||
return BuildConfig.CURSEFORGE_API_KEY;
|
return BuildConfig.FLAME_API_KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Application::getUserAgent()
|
QString Application::getUserAgent()
|
||||||
|
@ -88,6 +88,14 @@ public:
|
|||||||
Initialized
|
Initialized
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum Capability {
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
SupportsMSA = 1 << 0,
|
||||||
|
SupportsFlame = 1 << 1,
|
||||||
|
};
|
||||||
|
Q_DECLARE_FLAGS(Capabilities, Capability)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Application(int &argc, char **argv);
|
Application(int &argc, char **argv);
|
||||||
virtual ~Application();
|
virtual ~Application();
|
||||||
@ -148,10 +156,16 @@ public:
|
|||||||
|
|
||||||
shared_qobject_ptr<Meta::Index> metadataIndex();
|
shared_qobject_ptr<Meta::Index> metadataIndex();
|
||||||
|
|
||||||
QString getJarsPath();
|
Capabilities currentCapabilities();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Finds and returns the full path to a jar file.
|
||||||
|
* Returns a null-string if it could not be found.
|
||||||
|
*/
|
||||||
|
QString getJarPath(QString jarFile);
|
||||||
|
|
||||||
QString getMSAClientID();
|
QString getMSAClientID();
|
||||||
QString getCurseKey();
|
QString getFlameAPIKey();
|
||||||
QString getUserAgent();
|
QString getUserAgent();
|
||||||
QString getUserAgentUncached();
|
QString getUserAgentUncached();
|
||||||
|
|
||||||
@ -227,7 +241,6 @@ private:
|
|||||||
std::shared_ptr<GenericPageProvider> m_globalSettingsProvider;
|
std::shared_ptr<GenericPageProvider> m_globalSettingsProvider;
|
||||||
std::map<QString, std::unique_ptr<ITheme>> m_themes;
|
std::map<QString, std::unique_ptr<ITheme>> m_themes;
|
||||||
std::unique_ptr<MCEditTool> m_mcedit;
|
std::unique_ptr<MCEditTool> m_mcedit;
|
||||||
QString m_jarsPath;
|
|
||||||
QSet<QString> m_features;
|
QSet<QString> m_features;
|
||||||
|
|
||||||
QMap<QString, std::shared_ptr<BaseProfilerFactory>> m_profilers;
|
QMap<QString, std::shared_ptr<BaseProfilerFactory>> m_profilers;
|
||||||
|
@ -1,11 +1,47 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This file incorporates work covered by the following copyright and
|
||||||
|
* permission notice:
|
||||||
|
*
|
||||||
|
* Copyright 2013-2021 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "ApplicationMessage.h"
|
#include "ApplicationMessage.h"
|
||||||
|
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
#include "Json.h"
|
||||||
|
|
||||||
void ApplicationMessage::parse(const QByteArray & input) {
|
void ApplicationMessage::parse(const QByteArray & input) {
|
||||||
auto doc = QJsonDocument::fromBinaryData(input);
|
auto doc = Json::requireDocument(input, "ApplicationMessage");
|
||||||
auto root = doc.object();
|
auto root = Json::requireObject(doc, "ApplicationMessage");
|
||||||
|
|
||||||
command = root.value("command").toString();
|
command = root.value("command").toString();
|
||||||
args.clear();
|
args.clear();
|
||||||
@ -25,7 +61,5 @@ QByteArray ApplicationMessage::serialize() {
|
|||||||
}
|
}
|
||||||
root.insert("args", outArgs);
|
root.insert("args", outArgs);
|
||||||
|
|
||||||
QJsonDocument out;
|
return Json::toText(root);
|
||||||
out.setObject(root);
|
|
||||||
return out.toBinaryData();
|
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
#include "settings/INISettingsObject.h"
|
#include "settings/INISettingsObject.h"
|
||||||
#include "settings/Setting.h"
|
#include "settings/Setting.h"
|
||||||
@ -335,7 +336,7 @@ QString BaseInstance::name() const
|
|||||||
|
|
||||||
QString BaseInstance::windowTitle() const
|
QString BaseInstance::windowTitle() const
|
||||||
{
|
{
|
||||||
return BuildConfig.LAUNCHER_NAME + ": " + name().replace(QRegExp("[ \n\r\t]+"), " ");
|
return BuildConfig.LAUNCHER_NAME + ": " + name().replace(QRegularExpression("\\s+"), " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: why is this here? move it to MinecraftInstance!!!
|
// FIXME: why is this here? move it to MinecraftInstance!!!
|
||||||
|
@ -188,6 +188,7 @@ public:
|
|||||||
* Create envrironment variables for running the instance
|
* Create envrironment variables for running the instance
|
||||||
*/
|
*/
|
||||||
virtual QProcessEnvironment createEnvironment() = 0;
|
virtual QProcessEnvironment createEnvironment() = 0;
|
||||||
|
virtual QProcessEnvironment createLaunchEnvironment() = 0;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns a matcher that can maps relative paths within the instance to whether they are 'log files'
|
* Returns a matcher that can maps relative paths within the instance to whether they are 'log files'
|
||||||
|
@ -1,16 +1,36 @@
|
|||||||
/* Copyright 2013-2021 MultiMC Contributors
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* you may not use this file except in compliance with the License.
|
* it under the terms of the GNU General Public License as published by
|
||||||
* You may obtain a copy of the License at
|
* 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
|
* You should have received a copy of the GNU General Public License
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
*
|
||||||
* See the License for the specific language governing permissions and
|
* This file incorporates work covered by the following copyright and
|
||||||
* limitations under the License.
|
* 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 "BaseVersionList.h"
|
#include "BaseVersionList.h"
|
||||||
@ -51,7 +71,7 @@ QVariant BaseVersionList::data(const QModelIndex &index, int role) const
|
|||||||
switch (role)
|
switch (role)
|
||||||
{
|
{
|
||||||
case VersionPointerRole:
|
case VersionPointerRole:
|
||||||
return qVariantFromValue(version);
|
return QVariant::fromValue(version);
|
||||||
|
|
||||||
case VersionRole:
|
case VersionRole:
|
||||||
return version->name();
|
return version->name();
|
||||||
|
@ -4,8 +4,6 @@ project(application)
|
|||||||
|
|
||||||
######## Sources and headers ########
|
######## Sources and headers ########
|
||||||
|
|
||||||
include (UnitTest)
|
|
||||||
|
|
||||||
set(CORE_SOURCES
|
set(CORE_SOURCES
|
||||||
# LOGIC - Base classes and infrastructure
|
# LOGIC - Base classes and infrastructure
|
||||||
BaseInstaller.h
|
BaseInstaller.h
|
||||||
@ -90,16 +88,11 @@ set(CORE_SOURCES
|
|||||||
MMCTime.cpp
|
MMCTime.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_unit_test(FileSystem
|
ecm_add_test(FileSystem_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test
|
||||||
SOURCES FileSystem_test.cpp
|
TEST_NAME FileSystem) # TODO: needs testdata
|
||||||
LIBS Launcher_logic
|
|
||||||
DATA testdata
|
|
||||||
)
|
|
||||||
|
|
||||||
add_unit_test(GZip
|
ecm_add_test(GZip_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test
|
||||||
SOURCES GZip_test.cpp
|
TEST_NAME GZip)
|
||||||
LIBS Launcher_logic
|
|
||||||
)
|
|
||||||
|
|
||||||
set(PATHMATCHER_SOURCES
|
set(PATHMATCHER_SOURCES
|
||||||
# Path matchers
|
# Path matchers
|
||||||
@ -124,6 +117,7 @@ set(NET_SOURCES
|
|||||||
net/NetAction.h
|
net/NetAction.h
|
||||||
net/NetJob.cpp
|
net/NetJob.cpp
|
||||||
net/NetJob.h
|
net/NetJob.h
|
||||||
|
net/NetUtils.h
|
||||||
net/PasteUpload.cpp
|
net/PasteUpload.cpp
|
||||||
net/PasteUpload.h
|
net/PasteUpload.h
|
||||||
net/Sink.h
|
net/Sink.h
|
||||||
@ -335,10 +329,8 @@ set(MINECRAFT_SOURCES
|
|||||||
mojang/PackageManifest.cpp
|
mojang/PackageManifest.cpp
|
||||||
minecraft/Agent.h)
|
minecraft/Agent.h)
|
||||||
|
|
||||||
add_unit_test(GradleSpecifier
|
ecm_add_test(minecraft/GradleSpecifier_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test
|
||||||
SOURCES minecraft/GradleSpecifier_test.cpp
|
TEST_NAME GradleSpecifier)
|
||||||
LIBS Launcher_logic
|
|
||||||
)
|
|
||||||
|
|
||||||
if(BUILD_TESTING)
|
if(BUILD_TESTING)
|
||||||
add_executable(PackageManifest
|
add_executable(PackageManifest
|
||||||
@ -346,7 +338,7 @@ if(BUILD_TESTING)
|
|||||||
)
|
)
|
||||||
target_link_libraries(PackageManifest
|
target_link_libraries(PackageManifest
|
||||||
Launcher_logic
|
Launcher_logic
|
||||||
Qt5::Test
|
Qt${QT_VERSION_MAJOR}::Test
|
||||||
)
|
)
|
||||||
target_include_directories(PackageManifest
|
target_include_directories(PackageManifest
|
||||||
PRIVATE ../cmake/UnitTest/
|
PRIVATE ../cmake/UnitTest/
|
||||||
@ -358,28 +350,20 @@ if(BUILD_TESTING)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_unit_test(MojangVersionFormat
|
# TODO: needs minecraft/testdata
|
||||||
SOURCES minecraft/MojangVersionFormat_test.cpp
|
ecm_add_test(minecraft/MojangVersionFormat_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test
|
||||||
LIBS Launcher_logic
|
TEST_NAME MojangVersionFormat)
|
||||||
DATA minecraft/testdata
|
|
||||||
)
|
|
||||||
|
|
||||||
add_unit_test(Library
|
ecm_add_test(minecraft/Library_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test
|
||||||
SOURCES minecraft/Library_test.cpp
|
TEST_NAME Library)
|
||||||
LIBS Launcher_logic
|
|
||||||
)
|
|
||||||
|
|
||||||
# FIXME: shares data with FileSystem test
|
# FIXME: shares data with FileSystem test
|
||||||
add_unit_test(ModFolderModel
|
# TODO: needs testdata
|
||||||
SOURCES minecraft/mod/ModFolderModel_test.cpp
|
ecm_add_test(minecraft/mod/ModFolderModel_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test
|
||||||
DATA testdata
|
TEST_NAME ModFolderModel)
|
||||||
LIBS Launcher_logic
|
|
||||||
)
|
|
||||||
|
|
||||||
add_unit_test(ParseUtils
|
ecm_add_test(minecraft/ParseUtils_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test
|
||||||
SOURCES minecraft/ParseUtils_test.cpp
|
TEST_NAME ParseUtils)
|
||||||
LIBS Launcher_logic
|
|
||||||
)
|
|
||||||
|
|
||||||
# the screenshots feature
|
# the screenshots feature
|
||||||
set(SCREENSHOTS_SOURCES
|
set(SCREENSHOTS_SOURCES
|
||||||
@ -394,14 +378,16 @@ set(TASKS_SOURCES
|
|||||||
# Tasks
|
# Tasks
|
||||||
tasks/Task.h
|
tasks/Task.h
|
||||||
tasks/Task.cpp
|
tasks/Task.cpp
|
||||||
|
tasks/ConcurrentTask.h
|
||||||
|
tasks/ConcurrentTask.cpp
|
||||||
tasks/SequentialTask.h
|
tasks/SequentialTask.h
|
||||||
tasks/SequentialTask.cpp
|
tasks/SequentialTask.cpp
|
||||||
|
tasks/MultipleOptionsTask.h
|
||||||
|
tasks/MultipleOptionsTask.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_unit_test(Task
|
ecm_add_test(tasks/Task_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test
|
||||||
SOURCES tasks/Task_test.cpp
|
TEST_NAME Task)
|
||||||
LIBS Launcher_logic
|
|
||||||
)
|
|
||||||
|
|
||||||
set(SETTINGS_SOURCES
|
set(SETTINGS_SOURCES
|
||||||
# Settings
|
# Settings
|
||||||
@ -419,10 +405,8 @@ set(SETTINGS_SOURCES
|
|||||||
settings/SettingsObject.h
|
settings/SettingsObject.h
|
||||||
)
|
)
|
||||||
|
|
||||||
add_unit_test(INIFile
|
ecm_add_test(settings/INIFile_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test
|
||||||
SOURCES settings/INIFile_test.cpp
|
TEST_NAME INIFile)
|
||||||
LIBS Launcher_logic
|
|
||||||
)
|
|
||||||
|
|
||||||
set(JAVA_SOURCES
|
set(JAVA_SOURCES
|
||||||
java/JavaChecker.h
|
java/JavaChecker.h
|
||||||
@ -439,10 +423,8 @@ set(JAVA_SOURCES
|
|||||||
java/JavaVersion.cpp
|
java/JavaVersion.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_unit_test(JavaVersion
|
ecm_add_test(java/JavaVersion_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test
|
||||||
SOURCES java/JavaVersion_test.cpp
|
TEST_NAME JavaVersion)
|
||||||
LIBS Launcher_logic
|
|
||||||
)
|
|
||||||
|
|
||||||
set(TRANSLATIONS_SOURCES
|
set(TRANSLATIONS_SOURCES
|
||||||
translations/TranslationsModel.h
|
translations/TranslationsModel.h
|
||||||
@ -485,9 +467,15 @@ set(API_SOURCES
|
|||||||
|
|
||||||
modplatform/ModAPI.h
|
modplatform/ModAPI.h
|
||||||
|
|
||||||
|
modplatform/EnsureMetadataTask.h
|
||||||
|
modplatform/EnsureMetadataTask.cpp
|
||||||
|
|
||||||
|
modplatform/CheckUpdateTask.h
|
||||||
|
|
||||||
modplatform/flame/FlameAPI.h
|
modplatform/flame/FlameAPI.h
|
||||||
|
modplatform/flame/FlameAPI.cpp
|
||||||
modplatform/modrinth/ModrinthAPI.h
|
modplatform/modrinth/ModrinthAPI.h
|
||||||
|
modplatform/modrinth/ModrinthAPI.cpp
|
||||||
modplatform/helpers/NetworkModAPI.h
|
modplatform/helpers/NetworkModAPI.h
|
||||||
modplatform/helpers/NetworkModAPI.cpp
|
modplatform/helpers/NetworkModAPI.cpp
|
||||||
)
|
)
|
||||||
@ -513,6 +501,8 @@ set(FLAME_SOURCES
|
|||||||
modplatform/flame/PackManifest.cpp
|
modplatform/flame/PackManifest.cpp
|
||||||
modplatform/flame/FileResolvingTask.h
|
modplatform/flame/FileResolvingTask.h
|
||||||
modplatform/flame/FileResolvingTask.cpp
|
modplatform/flame/FileResolvingTask.cpp
|
||||||
|
modplatform/flame/FlameCheckUpdate.cpp
|
||||||
|
modplatform/flame/FlameCheckUpdate.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(MODRINTH_SOURCES
|
set(MODRINTH_SOURCES
|
||||||
@ -520,6 +510,8 @@ set(MODRINTH_SOURCES
|
|||||||
modplatform/modrinth/ModrinthPackIndex.h
|
modplatform/modrinth/ModrinthPackIndex.h
|
||||||
modplatform/modrinth/ModrinthPackManifest.cpp
|
modplatform/modrinth/ModrinthPackManifest.cpp
|
||||||
modplatform/modrinth/ModrinthPackManifest.h
|
modplatform/modrinth/ModrinthPackManifest.h
|
||||||
|
modplatform/modrinth/ModrinthCheckUpdate.cpp
|
||||||
|
modplatform/modrinth/ModrinthCheckUpdate.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(MODPACKSCH_SOURCES
|
set(MODPACKSCH_SOURCES
|
||||||
@ -534,11 +526,9 @@ set(PACKWIZ_SOURCES
|
|||||||
modplatform/packwiz/Packwiz.cpp
|
modplatform/packwiz/Packwiz.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_unit_test(Packwiz
|
# TODO: needs modplatform/packwiz/testdata
|
||||||
SOURCES modplatform/packwiz/Packwiz_test.cpp
|
ecm_add_test(modplatform/packwiz/Packwiz_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test
|
||||||
DATA modplatform/packwiz/testdata
|
TEST_NAME Packwiz)
|
||||||
LIBS Launcher_logic
|
|
||||||
)
|
|
||||||
|
|
||||||
set(TECHNIC_SOURCES
|
set(TECHNIC_SOURCES
|
||||||
modplatform/technic/SingleZipPackInstallTask.h
|
modplatform/technic/SingleZipPackInstallTask.h
|
||||||
@ -562,10 +552,8 @@ set(ATLAUNCHER_SOURCES
|
|||||||
modplatform/atlauncher/ATLShareCode.h
|
modplatform/atlauncher/ATLShareCode.h
|
||||||
)
|
)
|
||||||
|
|
||||||
add_unit_test(Index
|
ecm_add_test(meta/Index_test.cpp LINK_LIBRARIES Launcher_logic Qt${QT_VERSION_MAJOR}::Test
|
||||||
SOURCES meta/Index_test.cpp
|
TEST_NAME Index)
|
||||||
LIBS Launcher_logic
|
|
||||||
)
|
|
||||||
|
|
||||||
################################ COMPILE ################################
|
################################ COMPILE ################################
|
||||||
|
|
||||||
@ -597,6 +585,10 @@ set(LOGIC_SOURCES
|
|||||||
${ATLAUNCHER_SOURCES}
|
${ATLAUNCHER_SOURCES}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
set (LOGIC_SOURCES ${LOGIC_SOURCES} ${MAC_UPDATE_SOURCES})
|
||||||
|
endif()
|
||||||
|
|
||||||
SET(LAUNCHER_SOURCES
|
SET(LAUNCHER_SOURCES
|
||||||
# Application base
|
# Application base
|
||||||
Application.h
|
Application.h
|
||||||
@ -690,6 +682,8 @@ SET(LAUNCHER_SOURCES
|
|||||||
ui/pages/BasePageProvider.h
|
ui/pages/BasePageProvider.h
|
||||||
|
|
||||||
# GUI - instance pages
|
# GUI - instance pages
|
||||||
|
ui/pages/instance/ExternalResourcesPage.cpp
|
||||||
|
ui/pages/instance/ExternalResourcesPage.h
|
||||||
ui/pages/instance/GameOptionsPage.cpp
|
ui/pages/instance/GameOptionsPage.cpp
|
||||||
ui/pages/instance/GameOptionsPage.h
|
ui/pages/instance/GameOptionsPage.h
|
||||||
ui/pages/instance/VersionPage.cpp
|
ui/pages/instance/VersionPage.cpp
|
||||||
@ -818,6 +812,8 @@ SET(LAUNCHER_SOURCES
|
|||||||
ui/dialogs/NewComponentDialog.h
|
ui/dialogs/NewComponentDialog.h
|
||||||
ui/dialogs/NewInstanceDialog.cpp
|
ui/dialogs/NewInstanceDialog.cpp
|
||||||
ui/dialogs/NewInstanceDialog.h
|
ui/dialogs/NewInstanceDialog.h
|
||||||
|
ui/dialogs/NewsDialog.cpp
|
||||||
|
ui/dialogs/NewsDialog.h
|
||||||
ui/pagedialog/PageDialog.cpp
|
ui/pagedialog/PageDialog.cpp
|
||||||
ui/pagedialog/PageDialog.h
|
ui/pagedialog/PageDialog.h
|
||||||
ui/dialogs/ProgressDialog.cpp
|
ui/dialogs/ProgressDialog.cpp
|
||||||
@ -832,6 +828,10 @@ SET(LAUNCHER_SOURCES
|
|||||||
ui/dialogs/ModDownloadDialog.h
|
ui/dialogs/ModDownloadDialog.h
|
||||||
ui/dialogs/ScrollMessageBox.cpp
|
ui/dialogs/ScrollMessageBox.cpp
|
||||||
ui/dialogs/ScrollMessageBox.h
|
ui/dialogs/ScrollMessageBox.h
|
||||||
|
ui/dialogs/ChooseProviderDialog.h
|
||||||
|
ui/dialogs/ChooseProviderDialog.cpp
|
||||||
|
ui/dialogs/ModUpdateDialog.cpp
|
||||||
|
ui/dialogs/ModUpdateDialog.h
|
||||||
|
|
||||||
# GUI - widgets
|
# GUI - widgets
|
||||||
ui/widgets/Common.cpp
|
ui/widgets/Common.cpp
|
||||||
@ -886,7 +886,7 @@ SET(LAUNCHER_SOURCES
|
|||||||
ui/instanceview/VisualGroup.h
|
ui/instanceview/VisualGroup.h
|
||||||
)
|
)
|
||||||
|
|
||||||
qt5_wrap_ui(LAUNCHER_UI
|
qt_wrap_ui(LAUNCHER_UI
|
||||||
ui/setupwizard/PasteWizardPage.ui
|
ui/setupwizard/PasteWizardPage.ui
|
||||||
ui/pages/global/AccountListPage.ui
|
ui/pages/global/AccountListPage.ui
|
||||||
ui/pages/global/JavaPage.ui
|
ui/pages/global/JavaPage.ui
|
||||||
@ -895,7 +895,7 @@ qt5_wrap_ui(LAUNCHER_UI
|
|||||||
ui/pages/global/ProxyPage.ui
|
ui/pages/global/ProxyPage.ui
|
||||||
ui/pages/global/MinecraftPage.ui
|
ui/pages/global/MinecraftPage.ui
|
||||||
ui/pages/global/ExternalToolsPage.ui
|
ui/pages/global/ExternalToolsPage.ui
|
||||||
ui/pages/instance/ModFolderPage.ui
|
ui/pages/instance/ExternalResourcesPage.ui
|
||||||
ui/pages/instance/NotesPage.ui
|
ui/pages/instance/NotesPage.ui
|
||||||
ui/pages/instance/LogPage.ui
|
ui/pages/instance/LogPage.ui
|
||||||
ui/pages/instance/ServersPage.ui
|
ui/pages/instance/ServersPage.ui
|
||||||
@ -924,6 +924,7 @@ qt5_wrap_ui(LAUNCHER_UI
|
|||||||
ui/dialogs/ProgressDialog.ui
|
ui/dialogs/ProgressDialog.ui
|
||||||
ui/dialogs/NewInstanceDialog.ui
|
ui/dialogs/NewInstanceDialog.ui
|
||||||
ui/dialogs/NewComponentDialog.ui
|
ui/dialogs/NewComponentDialog.ui
|
||||||
|
ui/dialogs/NewsDialog.ui
|
||||||
ui/dialogs/ProfileSelectDialog.ui
|
ui/dialogs/ProfileSelectDialog.ui
|
||||||
ui/dialogs/SkinUploadDialog.ui
|
ui/dialogs/SkinUploadDialog.ui
|
||||||
ui/dialogs/ExportInstanceDialog.ui
|
ui/dialogs/ExportInstanceDialog.ui
|
||||||
@ -935,9 +936,10 @@ qt5_wrap_ui(LAUNCHER_UI
|
|||||||
ui/dialogs/EditAccountDialog.ui
|
ui/dialogs/EditAccountDialog.ui
|
||||||
ui/dialogs/ReviewMessageBox.ui
|
ui/dialogs/ReviewMessageBox.ui
|
||||||
ui/dialogs/ScrollMessageBox.ui
|
ui/dialogs/ScrollMessageBox.ui
|
||||||
|
ui/dialogs/ChooseProviderDialog.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
qt5_add_resources(LAUNCHER_RESOURCES
|
qt_add_resources(LAUNCHER_RESOURCES
|
||||||
resources/backgrounds/backgrounds.qrc
|
resources/backgrounds/backgrounds.qrc
|
||||||
resources/multimc/multimc.qrc
|
resources/multimc/multimc.qrc
|
||||||
resources/pe_dark/pe_dark.qrc
|
resources/pe_dark/pe_dark.qrc
|
||||||
@ -961,27 +963,53 @@ add_library(Launcher_logic STATIC ${LOGIC_SOURCES} ${LAUNCHER_SOURCES} ${LAUNCHE
|
|||||||
target_link_libraries(Launcher_logic
|
target_link_libraries(Launcher_logic
|
||||||
systeminfo
|
systeminfo
|
||||||
Launcher_classparser
|
Launcher_classparser
|
||||||
|
Launcher_murmur2
|
||||||
nbt++
|
nbt++
|
||||||
${ZLIB_LIBRARIES}
|
${ZLIB_LIBRARIES}
|
||||||
optional-bare
|
optional-bare
|
||||||
tomlc99
|
tomlc99
|
||||||
BuildConfig
|
BuildConfig
|
||||||
Katabasis
|
Katabasis
|
||||||
|
Qt${QT_VERSION_MAJOR}::Widgets
|
||||||
|
)
|
||||||
|
|
||||||
|
if (UNIX AND NOT CYGWIN AND NOT APPLE)
|
||||||
|
target_link_libraries(Launcher_logic
|
||||||
|
gamemode
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_link_libraries(Launcher_logic
|
||||||
|
Qt${QT_VERSION_MAJOR}::Core
|
||||||
|
Qt${QT_VERSION_MAJOR}::Xml
|
||||||
|
Qt${QT_VERSION_MAJOR}::Network
|
||||||
|
Qt${QT_VERSION_MAJOR}::Concurrent
|
||||||
|
Qt${QT_VERSION_MAJOR}::Gui
|
||||||
|
Qt${QT_VERSION_MAJOR}::Widgets
|
||||||
|
${Launcher_QT_LIBS}
|
||||||
)
|
)
|
||||||
target_link_libraries(Launcher_logic
|
target_link_libraries(Launcher_logic
|
||||||
Qt5::Core
|
|
||||||
Qt5::Xml
|
|
||||||
Qt5::Network
|
|
||||||
Qt5::Concurrent
|
|
||||||
Qt5::Gui
|
|
||||||
)
|
|
||||||
target_link_libraries(Launcher_logic
|
|
||||||
Launcher_iconfix
|
|
||||||
QuaZip::QuaZip
|
QuaZip::QuaZip
|
||||||
hoedown
|
hoedown
|
||||||
LocalPeer
|
LocalPeer
|
||||||
Launcher_rainbow
|
Launcher_rainbow
|
||||||
)
|
)
|
||||||
|
if(APPLE)
|
||||||
|
set(CMAKE_MACOSX_RPATH 1)
|
||||||
|
set(CMAKE_INSTALL_RPATH "@loader_path/../Frameworks/")
|
||||||
|
|
||||||
|
file(DOWNLOAD ${MACOSX_SPARKLE_DOWNLOAD_URL} ${CMAKE_BINARY_DIR}/Sparkle.tar.xz EXPECTED_HASH SHA256=${MACOSX_SPARKLE_SHA256})
|
||||||
|
file(ARCHIVE_EXTRACT INPUT ${CMAKE_BINARY_DIR}/Sparkle.tar.xz DESTINATION ${CMAKE_BINARY_DIR}/frameworks/Sparkle)
|
||||||
|
|
||||||
|
find_library(SPARKLE_FRAMEWORK Sparkle "${CMAKE_BINARY_DIR}/frameworks/Sparkle")
|
||||||
|
target_link_libraries(Launcher_logic
|
||||||
|
"-framework AppKit"
|
||||||
|
"-framework Carbon"
|
||||||
|
"-framework Foundation"
|
||||||
|
"-framework ApplicationServices"
|
||||||
|
)
|
||||||
|
target_link_libraries(Launcher_logic ${SPARKLE_FRAMEWORK})
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries(Launcher_logic)
|
target_link_libraries(Launcher_logic)
|
||||||
|
|
||||||
@ -1004,8 +1032,16 @@ install(TARGETS ${Launcher_Name}
|
|||||||
BUNDLE DESTINATION "." COMPONENT Runtime
|
BUNDLE DESTINATION "." COMPONENT Runtime
|
||||||
LIBRARY DESTINATION ${LIBRARY_DEST_DIR} COMPONENT Runtime
|
LIBRARY DESTINATION ${LIBRARY_DEST_DIR} COMPONENT Runtime
|
||||||
RUNTIME DESTINATION ${BINARY_DEST_DIR} COMPONENT Runtime
|
RUNTIME DESTINATION ${BINARY_DEST_DIR} COMPONENT Runtime
|
||||||
|
FRAMEWORK DESTINATION ${FRAMEWORK_DEST_DIR} COMPONENT Runtime
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (UNIX AND APPLE)
|
||||||
|
# Add Sparkle updater
|
||||||
|
# It has to be copied here instead of just allowing fixup_bundle to install it, otherwise essential parts of
|
||||||
|
# the framework aren't installed
|
||||||
|
install(DIRECTORY ${MACOSX_SPARKLE_DIR}/Sparkle.framework DESTINATION ${FRAMEWORK_DEST_DIR} USE_SOURCE_PERMISSIONS)
|
||||||
|
endif()
|
||||||
|
|
||||||
#### The bundle mess! ####
|
#### The bundle mess! ####
|
||||||
# Bundle utilities are used to complete the portable packages - they add all the libraries that would otherwise be missing on the target system.
|
# Bundle utilities are used to complete the portable packages - they add all the libraries that would otherwise be missing on the target system.
|
||||||
# NOTE: it seems that this absolutely has to be here, and nowhere else.
|
# NOTE: it seems that this absolutely has to be here, and nowhere else.
|
||||||
@ -1046,6 +1082,14 @@ if(INSTALL_BUNDLE STREQUAL "full")
|
|||||||
COMPONENT Runtime
|
COMPONENT Runtime
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
# TLS plugins (Qt 6 only)
|
||||||
|
if(EXISTS "${QT_PLUGINS_DIR}/tls")
|
||||||
|
install(
|
||||||
|
DIRECTORY "${QT_PLUGINS_DIR}/tls"
|
||||||
|
DESTINATION ${PLUGIN_DEST_DIR}
|
||||||
|
COMPONENT Runtime
|
||||||
|
)
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
# Image formats
|
# Image formats
|
||||||
install(
|
install(
|
||||||
@ -1088,6 +1132,16 @@ if(INSTALL_BUNDLE STREQUAL "full")
|
|||||||
REGEX "\\.dSYM" EXCLUDE
|
REGEX "\\.dSYM" EXCLUDE
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
# TLS plugins (Qt 6 only)
|
||||||
|
if(EXISTS "${QT_PLUGINS_DIR}/tls")
|
||||||
|
install(
|
||||||
|
DIRECTORY "${QT_PLUGINS_DIR}/tls"
|
||||||
|
DESTINATION ${PLUGIN_DEST_DIR}
|
||||||
|
COMPONENT Runtime
|
||||||
|
REGEX "_debug\\." EXCLUDE
|
||||||
|
REGEX "\\.dSYM" EXCLUDE
|
||||||
|
)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
configure_file(
|
configure_file(
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/install_prereqs.cmake.in"
|
"${CMAKE_CURRENT_SOURCE_DIR}/install_prereqs.cmake.in"
|
||||||
|
@ -1,18 +1,38 @@
|
|||||||
/* Copyright 2013-2021 MultiMC Contributors
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
*
|
*
|
||||||
* Authors: Orochimarufan <orochimarufan.x3@gmail.com>
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* This program is distributed in the hope that it will be useful,
|
||||||
* you may not use this file except in compliance with the License.
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* You may obtain a copy of the License at
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* This file incorporates work covered by the following copyright and
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* permission notice:
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
*
|
||||||
* See the License for the specific language governing permissions and
|
* Copyright 2013-2021 MultiMC Contributors
|
||||||
* limitations under the License.
|
*
|
||||||
|
* Authors: Orochimarufan <orochimarufan.x3@gmail.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Commandline.h"
|
#include "Commandline.h"
|
||||||
@ -47,7 +67,7 @@ QStringList splitArgs(QString args)
|
|||||||
if (cchar == '\\')
|
if (cchar == '\\')
|
||||||
escape = true;
|
escape = true;
|
||||||
else if (cchar == inquotes)
|
else if (cchar == inquotes)
|
||||||
inquotes = 0;
|
inquotes = QChar::Null;
|
||||||
else
|
else
|
||||||
current += cchar;
|
current += cchar;
|
||||||
// otherwise
|
// otherwise
|
||||||
@ -480,4 +500,4 @@ void Parser::getPrefix(QString &opt, QString &flag)
|
|||||||
ParsingError::ParsingError(const QString &what) : std::runtime_error(what.toStdString())
|
ParsingError::ParsingError(const QString &what) : std::runtime_error(what.toStdString())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,37 @@
|
|||||||
// Licensed under the Apache-2.0 license. See README.md for details.
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This file incorporates work covered by the following copyright and
|
||||||
|
* permission notice:
|
||||||
|
*
|
||||||
|
* Copyright 2013-2021 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
|
|
||||||
@ -346,7 +379,7 @@ bool checkProblemticPathJava(QDir folder)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Win32 crap
|
// Win32 crap
|
||||||
#if defined Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
|
||||||
bool called_coinit = false;
|
bool called_coinit = false;
|
||||||
|
|
||||||
@ -366,7 +399,7 @@ HRESULT CreateLink(LPCSTR linkPath, LPCSTR targetPath, LPCSTR args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IShellLink *link;
|
IShellLinkA *link;
|
||||||
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink,
|
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink,
|
||||||
(LPVOID *)&link);
|
(LPVOID *)&link);
|
||||||
|
|
||||||
|
@ -1,4 +1,37 @@
|
|||||||
// Licensed under the Apache-2.0 license. See README.md for details.
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This file incorporates work covered by the following copyright and
|
||||||
|
* permission notice:
|
||||||
|
*
|
||||||
|
* Copyright 2013-2021 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@ -49,8 +82,8 @@ class copy
|
|||||||
public:
|
public:
|
||||||
copy(const QString & src, const QString & dst)
|
copy(const QString & src, const QString & dst)
|
||||||
{
|
{
|
||||||
m_src = src;
|
m_src.setPath(src);
|
||||||
m_dst = dst;
|
m_dst.setPath(dst);
|
||||||
}
|
}
|
||||||
copy & followSymlinks(const bool follow)
|
copy & followSymlinks(const bool follow)
|
||||||
{
|
{
|
||||||
@ -120,11 +153,6 @@ bool checkProblemticPathJava(QDir folder);
|
|||||||
// Get the Directory representing the User's Desktop
|
// Get the Directory representing the User's Desktop
|
||||||
QString getDesktopDir();
|
QString getDesktopDir();
|
||||||
|
|
||||||
// Create a shortcut at *location*, pointing to *dest* called with the arguments *args*
|
|
||||||
// call it *name* and assign it the icon *icon*
|
|
||||||
// return true if operation succeeded
|
|
||||||
bool createShortCut(QString location, QString dest, QStringList args, QString name, QString iconLocation);
|
|
||||||
|
|
||||||
// Overrides one folder with the contents of another, preserving items exclusive to the first folder
|
// Overrides one folder with the contents of another, preserving items exclusive to the first folder
|
||||||
// Equivalent to doing QDir::rename, but allowing for overrides
|
// Equivalent to doing QDir::rename, but allowing for overrides
|
||||||
bool overrideFolder(QString overwritten_path, QString override_path);
|
bool overrideFolder(QString overwritten_path, QString override_path);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include <QTest>
|
#include <QTest>
|
||||||
#include <QTemporaryDir>
|
#include <QTemporaryDir>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include "TestUtil.h"
|
|
||||||
|
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
|
|
||||||
@ -81,7 +80,7 @@ slots:
|
|||||||
|
|
||||||
void test_copy()
|
void test_copy()
|
||||||
{
|
{
|
||||||
QString folder = QFINDTESTDATA("data/test_folder");
|
QString folder = QFINDTESTDATA("testdata/test_folder");
|
||||||
auto f = [&folder]()
|
auto f = [&folder]()
|
||||||
{
|
{
|
||||||
QTemporaryDir tempDir;
|
QTemporaryDir tempDir;
|
||||||
@ -116,47 +115,6 @@ slots:
|
|||||||
{
|
{
|
||||||
QCOMPARE(FS::getDesktopDir(), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
|
QCOMPARE(FS::getDesktopDir(), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is only valid on linux
|
|
||||||
// FIXME: implement on windows, OSX, then test.
|
|
||||||
#if defined(Q_OS_LINUX)
|
|
||||||
void test_createShortcut_data()
|
|
||||||
{
|
|
||||||
QTest::addColumn<QString>("location");
|
|
||||||
QTest::addColumn<QString>("dest");
|
|
||||||
QTest::addColumn<QStringList>("args");
|
|
||||||
QTest::addColumn<QString>("name");
|
|
||||||
QTest::addColumn<QString>("iconLocation");
|
|
||||||
QTest::addColumn<QByteArray>("result");
|
|
||||||
|
|
||||||
QTest::newRow("unix") << QDir::currentPath()
|
|
||||||
<< "asdfDest"
|
|
||||||
<< (QStringList() << "arg1" << "arg2")
|
|
||||||
<< "asdf"
|
|
||||||
<< QString()
|
|
||||||
#if defined(Q_OS_LINUX)
|
|
||||||
<< GET_TEST_FILE("data/FileSystem-test_createShortcut-unix")
|
|
||||||
#elif defined(Q_OS_WIN)
|
|
||||||
<< QByteArray()
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_createShortcut()
|
|
||||||
{
|
|
||||||
QFETCH(QString, location);
|
|
||||||
QFETCH(QString, dest);
|
|
||||||
QFETCH(QStringList, args);
|
|
||||||
QFETCH(QString, name);
|
|
||||||
QFETCH(QString, iconLocation);
|
|
||||||
QFETCH(QByteArray, result);
|
|
||||||
|
|
||||||
QVERIFY(FS::createShortCut(location, dest, args, name, iconLocation));
|
|
||||||
QCOMPARE(QString::fromLocal8Bit(TestsInternal::readFile(location + QDir::separator() + name + ".desktop")), QString::fromLocal8Bit(result));
|
|
||||||
|
|
||||||
//QDir().remove(location);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QTEST_GUILESS_MAIN(FileSystemTest)
|
QTEST_GUILESS_MAIN(FileSystemTest)
|
||||||
|
@ -1,3 +1,38 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This file incorporates work covered by the following copyright and
|
||||||
|
* permission notice:
|
||||||
|
*
|
||||||
|
* Copyright 2013-2021 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "GZip.h"
|
#include "GZip.h"
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
@ -67,7 +102,7 @@ bool GZip::zip(const QByteArray &uncompressedBytes, QByteArray &compressedBytes)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned compLength = std::min(uncompressedBytes.size(), 16);
|
unsigned compLength = qMin(uncompressedBytes.size(), 16);
|
||||||
compressedBytes.clear();
|
compressedBytes.clear();
|
||||||
compressedBytes.resize(compLength);
|
compressedBytes.resize(compLength);
|
||||||
|
|
||||||
@ -112,4 +147,4 @@ bool GZip::zip(const QByteArray &uncompressedBytes, QByteArray &compressedBytes)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include <QTest>
|
#include <QTest>
|
||||||
#include "TestUtil.h"
|
|
||||||
|
|
||||||
#include "GZip.h"
|
#include "GZip.h"
|
||||||
#include <random>
|
#include <random>
|
||||||
|
@ -325,7 +325,7 @@ void InstanceImportTask::processFlame()
|
|||||||
// Hack to correct some 'special sauce'...
|
// Hack to correct some 'special sauce'...
|
||||||
if(mcVersion.endsWith('.'))
|
if(mcVersion.endsWith('.'))
|
||||||
{
|
{
|
||||||
mcVersion.remove(QRegExp("[.]+$"));
|
mcVersion.remove(QRegularExpression("[.]+$"));
|
||||||
logWarning(tr("Mysterious trailing dots removed from Minecraft version while importing pack."));
|
logWarning(tr("Mysterious trailing dots removed from Minecraft version while importing pack."));
|
||||||
}
|
}
|
||||||
auto components = instance.getPackProfile();
|
auto components = instance.getPackProfile();
|
||||||
@ -412,12 +412,8 @@ void InstanceImportTask::processFlame()
|
|||||||
"You will need to manually download them and add them to the modpack"),
|
"You will need to manually download them and add them to the modpack"),
|
||||||
text);
|
text);
|
||||||
message_dialog->setModal(true);
|
message_dialog->setModal(true);
|
||||||
message_dialog->show();
|
|
||||||
connect(message_dialog, &QDialog::rejected, [&]() {
|
if (message_dialog->exec()) {
|
||||||
m_modIdResolver.reset();
|
|
||||||
emitFailed("Canceled");
|
|
||||||
});
|
|
||||||
connect(message_dialog, &QDialog::accepted, [&]() {
|
|
||||||
m_filesNetJob = new NetJob(tr("Mod download"), APPLICATION->network());
|
m_filesNetJob = new NetJob(tr("Mod download"), APPLICATION->network());
|
||||||
for (const auto &result: m_modIdResolver->getResults().files) {
|
for (const auto &result: m_modIdResolver->getResults().files) {
|
||||||
QString filename = result.fileName;
|
QString filename = result.fileName;
|
||||||
@ -469,8 +465,11 @@ void InstanceImportTask::processFlame()
|
|||||||
});
|
});
|
||||||
setStatus(tr("Downloading mods..."));
|
setStatus(tr("Downloading mods..."));
|
||||||
m_filesNetJob->start();
|
m_filesNetJob->start();
|
||||||
});
|
} else {
|
||||||
}else{
|
m_modIdResolver.reset();
|
||||||
|
emitFailed("Canceled");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
//TODO extract to function ?
|
//TODO extract to function ?
|
||||||
m_filesNetJob = new NetJob(tr("Mod download"), APPLICATION->network());
|
m_filesNetJob = new NetJob(tr("Mod download"), APPLICATION->network());
|
||||||
for (const auto &result: m_modIdResolver->getResults().files) {
|
for (const auto &result: m_modIdResolver->getResults().files) {
|
||||||
@ -723,11 +722,11 @@ void InstanceImportTask::processModrinth()
|
|||||||
components->buildingFromScratch();
|
components->buildingFromScratch();
|
||||||
components->setComponentVersion("net.minecraft", minecraftVersion, true);
|
components->setComponentVersion("net.minecraft", minecraftVersion, true);
|
||||||
if (!fabricVersion.isEmpty())
|
if (!fabricVersion.isEmpty())
|
||||||
components->setComponentVersion("net.fabricmc.fabric-loader", fabricVersion, true);
|
components->setComponentVersion("net.fabricmc.fabric-loader", fabricVersion);
|
||||||
if (!quiltVersion.isEmpty())
|
if (!quiltVersion.isEmpty())
|
||||||
components->setComponentVersion("org.quiltmc.quilt-loader", quiltVersion, true);
|
components->setComponentVersion("org.quiltmc.quilt-loader", quiltVersion);
|
||||||
if (!forgeVersion.isEmpty())
|
if (!forgeVersion.isEmpty())
|
||||||
components->setComponentVersion("net.minecraftforge", forgeVersion, true);
|
components->setComponentVersion("net.minecraftforge", forgeVersion);
|
||||||
if (m_instIcon != "default")
|
if (m_instIcon != "default")
|
||||||
{
|
{
|
||||||
instance.setIconKey(m_instIcon);
|
instance.setIconKey(m_instIcon);
|
||||||
|
@ -1,16 +1,36 @@
|
|||||||
/* Copyright 2013-2021 MultiMC Contributors
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* you may not use this file except in compliance with the License.
|
* it under the terms of the GNU General Public License as published by
|
||||||
* You may obtain a copy of the License at
|
* 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
|
* You should have received a copy of the GNU General Public License
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
*
|
||||||
* See the License for the specific language governing permissions and
|
* This file incorporates work covered by the following copyright and
|
||||||
* limitations under the License.
|
* 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 <QDir>
|
#include <QDir>
|
||||||
@ -136,7 +156,7 @@ QVariant InstanceList::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
case InstancePointerRole:
|
case InstancePointerRole:
|
||||||
{
|
{
|
||||||
QVariant v = qVariantFromValue((void *)pdata);
|
QVariant v = QVariant::fromValue((void *)pdata);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
case InstanceIDRole:
|
case InstanceIDRole:
|
||||||
@ -252,7 +272,7 @@ void InstanceList::setInstanceGroup(const InstanceId& id, const GroupId& name)
|
|||||||
|
|
||||||
QStringList InstanceList::getGroups()
|
QStringList InstanceList::getGroups()
|
||||||
{
|
{
|
||||||
return m_groupNameCache.toList();
|
return m_groupNameCache.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceList::deleteGroup(const QString& name)
|
void InstanceList::deleteGroup(const QString& name)
|
||||||
@ -353,7 +373,11 @@ QList< InstanceId > InstanceList::discoverInstances()
|
|||||||
out.append(id);
|
out.append(id);
|
||||||
qDebug() << "Found instance ID" << id;
|
qDebug() << "Found instance ID" << id;
|
||||||
}
|
}
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||||
|
instanceSet = QSet<QString>(out.begin(), out.end());
|
||||||
|
#else
|
||||||
instanceSet = out.toSet();
|
instanceSet = out.toSet();
|
||||||
|
#endif
|
||||||
m_instancesProbed = true;
|
m_instancesProbed = true;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@ -33,10 +33,10 @@ public:
|
|||||||
values.append(new LogPage(inst));
|
values.append(new LogPage(inst));
|
||||||
std::shared_ptr<MinecraftInstance> onesix = std::dynamic_pointer_cast<MinecraftInstance>(inst);
|
std::shared_ptr<MinecraftInstance> onesix = std::dynamic_pointer_cast<MinecraftInstance>(inst);
|
||||||
values.append(new VersionPage(onesix.get()));
|
values.append(new VersionPage(onesix.get()));
|
||||||
auto modsPage = new ModFolderPage(onesix.get(), onesix->loaderModList(), "mods", "loadermods", tr("Mods"), "Loader-mods");
|
auto modsPage = new ModFolderPage(onesix.get(), onesix->loaderModList());
|
||||||
modsPage->setFilter("%1 (*.zip *.jar *.litemod)");
|
modsPage->setFilter("%1 (*.zip *.jar *.litemod)");
|
||||||
values.append(modsPage);
|
values.append(modsPage);
|
||||||
values.append(new CoreModFolderPage(onesix.get(), onesix->coreModList(), "coremods", "coremods", tr("Core mods"), "Core-mods"));
|
values.append(new CoreModFolderPage(onesix.get(), onesix->coreModList()));
|
||||||
values.append(new ResourcePackPage(onesix.get()));
|
values.append(new ResourcePackPage(onesix.get()));
|
||||||
values.append(new TexturePackPage(onesix.get()));
|
values.append(new TexturePackPage(onesix.get()));
|
||||||
values.append(new ShaderPackPage(onesix.get()));
|
values.append(new ShaderPackPage(onesix.get()));
|
||||||
|
@ -1,10 +1,47 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This file incorporates work covered by the following copyright and
|
||||||
|
* permission notice:
|
||||||
|
*
|
||||||
|
* Copyright 2013-2021 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "JavaCommon.h"
|
#include "JavaCommon.h"
|
||||||
|
#include "java/JavaUtils.h"
|
||||||
#include "ui/dialogs/CustomMessageBox.h"
|
#include "ui/dialogs/CustomMessageBox.h"
|
||||||
#include <MMCStrings.h>
|
#include <MMCStrings.h>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
bool JavaCommon::checkJVMArgs(QString jvmargs, QWidget *parent)
|
bool JavaCommon::checkJVMArgs(QString jvmargs, QWidget *parent)
|
||||||
{
|
{
|
||||||
if (jvmargs.contains("-XX:PermSize=") || jvmargs.contains(QRegExp("-Xm[sx]"))
|
if (jvmargs.contains("-XX:PermSize=") || jvmargs.contains(QRegularExpression("-Xm[sx]"))
|
||||||
|| jvmargs.contains("-XX-MaxHeapSize") || jvmargs.contains("-XX:InitialHeapSize"))
|
|| jvmargs.contains("-XX-MaxHeapSize") || jvmargs.contains("-XX:InitialHeapSize"))
|
||||||
{
|
{
|
||||||
auto warnStr = QObject::tr(
|
auto warnStr = QObject::tr(
|
||||||
@ -18,7 +55,7 @@ bool JavaCommon::checkJVMArgs(QString jvmargs, QWidget *parent)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// block lunacy with passing required version to the JVM
|
// block lunacy with passing required version to the JVM
|
||||||
if (jvmargs.contains(QRegExp("-version:.*"))) {
|
if (jvmargs.contains(QRegularExpression("-version:.*"))) {
|
||||||
auto warnStr = QObject::tr(
|
auto warnStr = QObject::tr(
|
||||||
"You tried to pass required Java version argument to the JVM (using \"-version:xxx\"). This is not safe and will not be allowed.\n"
|
"You tried to pass required Java version argument to the JVM (using \"-version:xxx\"). This is not safe and will not be allowed.\n"
|
||||||
"This message will be displayed until you remove this from the JVM arguments.");
|
"This message will be displayed until you remove this from the JVM arguments.");
|
||||||
@ -65,6 +102,13 @@ void JavaCommon::javaBinaryWasBad(QWidget *parent, JavaCheckResult result)
|
|||||||
CustomMessageBox::selectable(parent, QObject::tr("Java test failure"), text, QMessageBox::Warning)->show();
|
CustomMessageBox::selectable(parent, QObject::tr("Java test failure"), text, QMessageBox::Warning)->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JavaCommon::javaCheckNotFound(QWidget *parent)
|
||||||
|
{
|
||||||
|
QString text;
|
||||||
|
text += QObject::tr("Java checker library could not be found. Please check your installation.");
|
||||||
|
CustomMessageBox::selectable(parent, QObject::tr("Java test failure"), text, QMessageBox::Warning)->show();
|
||||||
|
}
|
||||||
|
|
||||||
void JavaCommon::TestCheck::run()
|
void JavaCommon::TestCheck::run()
|
||||||
{
|
{
|
||||||
if (!JavaCommon::checkJVMArgs(m_args, m_parent))
|
if (!JavaCommon::checkJVMArgs(m_args, m_parent))
|
||||||
@ -72,6 +116,11 @@ void JavaCommon::TestCheck::run()
|
|||||||
emit finished();
|
emit finished();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (JavaUtils::getJavaCheckPath().isEmpty()) {
|
||||||
|
javaCheckNotFound(m_parent);
|
||||||
|
emit finished();
|
||||||
|
return;
|
||||||
|
}
|
||||||
checker.reset(new JavaChecker());
|
checker.reset(new JavaChecker());
|
||||||
connect(checker.get(), SIGNAL(checkFinished(JavaCheckResult)), this,
|
connect(checker.get(), SIGNAL(checkFinished(JavaCheckResult)), this,
|
||||||
SLOT(checkFinished(JavaCheckResult)));
|
SLOT(checkFinished(JavaCheckResult)));
|
||||||
|
@ -10,12 +10,14 @@ namespace JavaCommon
|
|||||||
{
|
{
|
||||||
bool checkJVMArgs(QString args, QWidget *parent);
|
bool checkJVMArgs(QString args, QWidget *parent);
|
||||||
|
|
||||||
// Show a dialog saying that the Java binary was not usable
|
|
||||||
void javaBinaryWasBad(QWidget *parent, JavaCheckResult result);
|
|
||||||
// Show a dialog saying that the Java binary was not usable because of bad options
|
|
||||||
void javaArgsWereBad(QWidget *parent, JavaCheckResult result);
|
|
||||||
// Show a dialog saying that the Java binary was usable
|
// Show a dialog saying that the Java binary was usable
|
||||||
void javaWasOk(QWidget *parent, JavaCheckResult result);
|
void javaWasOk(QWidget *parent, JavaCheckResult result);
|
||||||
|
// Show a dialog saying that the Java binary was not usable because of bad options
|
||||||
|
void javaArgsWereBad(QWidget *parent, JavaCheckResult result);
|
||||||
|
// Show a dialog saying that the Java binary was not usable
|
||||||
|
void javaBinaryWasBad(QWidget *parent, JavaCheckResult result);
|
||||||
|
// Show a dialog if we couldn't find Java Checker
|
||||||
|
void javaCheckNotFound(QWidget *parent);
|
||||||
|
|
||||||
class TestCheck : public QObject
|
class TestCheck : public QObject
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,37 @@
|
|||||||
// Licensed under the Apache-2.0 license. See README.md for details.
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This file incorporates work covered by the following copyright and
|
||||||
|
* permission notice:
|
||||||
|
*
|
||||||
|
* Copyright 2013-2021 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "Json.h"
|
#include "Json.h"
|
||||||
|
|
||||||
@ -22,14 +55,6 @@ void write(const QJsonArray &array, const QString &filename)
|
|||||||
write(QJsonDocument(array), filename);
|
write(QJsonDocument(array), filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray toBinary(const QJsonObject &obj)
|
|
||||||
{
|
|
||||||
return QJsonDocument(obj).toBinaryData();
|
|
||||||
}
|
|
||||||
QByteArray toBinary(const QJsonArray &array)
|
|
||||||
{
|
|
||||||
return QJsonDocument(array).toBinaryData();
|
|
||||||
}
|
|
||||||
QByteArray toText(const QJsonObject &obj)
|
QByteArray toText(const QJsonObject &obj)
|
||||||
{
|
{
|
||||||
return QJsonDocument(obj).toJson(QJsonDocument::Compact);
|
return QJsonDocument(obj).toJson(QJsonDocument::Compact);
|
||||||
@ -48,12 +73,8 @@ QJsonDocument requireDocument(const QByteArray &data, const QString &what)
|
|||||||
{
|
{
|
||||||
if (isBinaryJson(data))
|
if (isBinaryJson(data))
|
||||||
{
|
{
|
||||||
QJsonDocument doc = QJsonDocument::fromBinaryData(data);
|
// FIXME: Is this needed?
|
||||||
if (doc.isNull())
|
throw JsonException(what + ": Invalid JSON. Binary JSON unsupported");
|
||||||
{
|
|
||||||
throw JsonException(what + ": Invalid JSON (binary JSON detected)");
|
|
||||||
}
|
|
||||||
return doc;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,37 @@
|
|||||||
// Licensed under the Apache-2.0 license. See README.md for details.
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This file incorporates work covered by the following copyright and
|
||||||
|
* permission notice:
|
||||||
|
*
|
||||||
|
* Copyright 2013-2021 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@ -29,8 +62,6 @@ void write(const QJsonObject &object, const QString &filename);
|
|||||||
/// @throw FileSystemException
|
/// @throw FileSystemException
|
||||||
void write(const QJsonArray &array, const QString &filename);
|
void write(const QJsonArray &array, const QString &filename);
|
||||||
|
|
||||||
QByteArray toBinary(const QJsonObject &obj);
|
|
||||||
QByteArray toBinary(const QJsonArray &array);
|
|
||||||
QByteArray toText(const QJsonObject &obj);
|
QByteArray toText(const QJsonObject &obj);
|
||||||
QByteArray toText(const QJsonArray &array);
|
QByteArray toText(const QJsonArray &array);
|
||||||
|
|
||||||
|
@ -18,13 +18,17 @@ LAUNCHER_NAME=@Launcher_APP_BINARY_NAME@
|
|||||||
LAUNCHER_DIR="$(dirname "$(readlink -f "$0")")"
|
LAUNCHER_DIR="$(dirname "$(readlink -f "$0")")"
|
||||||
echo "Launcher Dir: ${LAUNCHER_DIR}"
|
echo "Launcher Dir: ${LAUNCHER_DIR}"
|
||||||
|
|
||||||
# Set up env - filter out input LD_ variables but pass them in under different names
|
# Set up env.
|
||||||
export GAME_LIBRARY_PATH=${GAME_LIBRARY_PATH-${LD_LIBRARY_PATH}}
|
# Pass our custom variables separately so that the launcher can remove them for child processes
|
||||||
export GAME_PRELOAD=${GAME_PRELOAD-${LD_PRELOAD}}
|
export LAUNCHER_LD_LIBRARY_PATH="${LAUNCHER_DIR}/lib@LIB_SUFFIX@"
|
||||||
export LD_LIBRARY_PATH="${LAUNCHER_DIR}/lib@LIB_SUFFIX@":$LAUNCHER_LIBRARY_PATH
|
export LAUNCHER_LD_PRELOAD=""
|
||||||
export LD_PRELOAD=$LAUNCHER_PRELOAD
|
export LAUNCHER_QT_PLUGIN_PATH="${LAUNCHER_DIR}/plugins"
|
||||||
export QT_PLUGIN_PATH="${LAUNCHER_DIR}/plugins"
|
export LAUNCHER_QT_FONTPATH="${LAUNCHER_DIR}/fonts"
|
||||||
export QT_FONTPATH="${LAUNCHER_DIR}/fonts"
|
|
||||||
|
export LD_LIBRARY_PATH="$LAUNCHER_LD_LIBRARY_PATH:$LD_LIBRARY_PATH"
|
||||||
|
export LD_PRELOAD="$LAUNCHER_LD_PRELOAD:$LD_PRELOAD"
|
||||||
|
export QT_PLUGIN_PATH="$LAUNCHER_QT_PLUGIN_PATH:$QT_PLUGIN_PATH"
|
||||||
|
export QT_FONTPATH="$LAUNCHER_QT_FONTPATH:$QT_FONTPATH"
|
||||||
|
|
||||||
# Detect missing dependencies...
|
# Detect missing dependencies...
|
||||||
DEPS_LIST=`ldd "${LAUNCHER_DIR}"/plugins/*/*.so 2>/dev/null | grep "not found" | sort -u | awk -vORS=", " '{ print $1 }'`
|
DEPS_LIST=`ldd "${LAUNCHER_DIR}"/plugins/*/*.so 2>/dev/null | grep "not found" | sort -u | awk -vORS=", " '{ print $1 }'`
|
||||||
|
@ -1,3 +1,38 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This file incorporates work covered by the following copyright and
|
||||||
|
* permission notice:
|
||||||
|
*
|
||||||
|
* Copyright 2013-2021 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "LoggedProcess.h"
|
#include "LoggedProcess.h"
|
||||||
#include "MessageLevel.h"
|
#include "MessageLevel.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@ -8,7 +43,11 @@ LoggedProcess::LoggedProcess(QObject *parent) : QProcess(parent)
|
|||||||
connect(this, &QProcess::readyReadStandardOutput, this, &LoggedProcess::on_stdOut);
|
connect(this, &QProcess::readyReadStandardOutput, this, &LoggedProcess::on_stdOut);
|
||||||
connect(this, &QProcess::readyReadStandardError, this, &LoggedProcess::on_stdErr);
|
connect(this, &QProcess::readyReadStandardError, this, &LoggedProcess::on_stdErr);
|
||||||
connect(this, SIGNAL(finished(int,QProcess::ExitStatus)), SLOT(on_exit(int,QProcess::ExitStatus)));
|
connect(this, SIGNAL(finished(int,QProcess::ExitStatus)), SLOT(on_exit(int,QProcess::ExitStatus)));
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
connect(this, SIGNAL(errorOccurred(QProcess::ProcessError)), this, SLOT(on_error(QProcess::ProcessError)));
|
||||||
|
#else
|
||||||
connect(this, SIGNAL(error(QProcess::ProcessError)), this, SLOT(on_error(QProcess::ProcessError)));
|
connect(this, SIGNAL(error(QProcess::ProcessError)), this, SLOT(on_error(QProcess::ProcessError)));
|
||||||
|
#endif
|
||||||
connect(this, &QProcess::stateChanged, this, &LoggedProcess::on_stateChange);
|
connect(this, &QProcess::stateChanged, this, &LoggedProcess::on_stateChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,19 +196,6 @@ void LoggedProcess::on_stateChange(QProcess::ProcessState state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined Q_OS_WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
qint64 LoggedProcess::processId() const
|
|
||||||
{
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
return pid() ? pid()->dwProcessId : 0;
|
|
||||||
#else
|
|
||||||
return pid();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoggedProcess::setDetachable(bool detachable)
|
void LoggedProcess::setDetachable(bool detachable)
|
||||||
{
|
{
|
||||||
m_is_detachable = detachable;
|
m_is_detachable = detachable;
|
||||||
|
@ -1,16 +1,36 @@
|
|||||||
/* Copyright 2013-2021 MultiMC Contributors
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* you may not use this file except in compliance with the License.
|
* it under the terms of the GNU General Public License as published by
|
||||||
* You may obtain a copy of the License at
|
* 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
|
* You should have received a copy of the GNU General Public License
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
*
|
||||||
* See the License for the specific language governing permissions and
|
* This file incorporates work covered by the following copyright and
|
||||||
* limitations under the License.
|
* 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
|
#pragma once
|
||||||
@ -43,7 +63,6 @@ public:
|
|||||||
|
|
||||||
State state() const;
|
State state() const;
|
||||||
int exitCode() const;
|
int exitCode() const;
|
||||||
qint64 processId() const;
|
|
||||||
|
|
||||||
void setDetachable(bool detachable);
|
void setDetachable(bool detachable);
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ bool MMCZip::compressDirFiles(QString fileCompressed, QString dir, QFileInfoList
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ours
|
// ours
|
||||||
bool MMCZip::createModdedJar(QString sourceJarPath, QString targetJarPath, const QList<Mod>& mods)
|
bool MMCZip::createModdedJar(QString sourceJarPath, QString targetJarPath, const QList<Mod*>& mods)
|
||||||
{
|
{
|
||||||
QuaZip zipOut(targetJarPath);
|
QuaZip zipOut(targetJarPath);
|
||||||
if (!zipOut.open(QuaZip::mdCreate))
|
if (!zipOut.open(QuaZip::mdCreate))
|
||||||
@ -141,42 +141,40 @@ bool MMCZip::createModdedJar(QString sourceJarPath, QString targetJarPath, const
|
|||||||
QSet<QString> addedFiles;
|
QSet<QString> addedFiles;
|
||||||
|
|
||||||
// Modify the jar
|
// Modify the jar
|
||||||
QListIterator<Mod> i(mods);
|
for (auto i = mods.constEnd(); i != mods.constBegin(); --i)
|
||||||
i.toBack();
|
|
||||||
while (i.hasPrevious())
|
|
||||||
{
|
{
|
||||||
const Mod &mod = i.previous();
|
const Mod* mod = *i;
|
||||||
// do not merge disabled mods.
|
// do not merge disabled mods.
|
||||||
if (!mod.enabled())
|
if (!mod->enabled())
|
||||||
continue;
|
continue;
|
||||||
if (mod.type() == Mod::MOD_ZIPFILE)
|
if (mod->type() == Mod::MOD_ZIPFILE)
|
||||||
{
|
{
|
||||||
if (!mergeZipFiles(&zipOut, mod.fileinfo(), addedFiles))
|
if (!mergeZipFiles(&zipOut, mod->fileinfo(), addedFiles))
|
||||||
{
|
{
|
||||||
zipOut.close();
|
zipOut.close();
|
||||||
QFile::remove(targetJarPath);
|
QFile::remove(targetJarPath);
|
||||||
qCritical() << "Failed to add" << mod.fileinfo().fileName() << "to the jar.";
|
qCritical() << "Failed to add" << mod->fileinfo().fileName() << "to the jar.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mod.type() == Mod::MOD_SINGLEFILE)
|
else if (mod->type() == Mod::MOD_SINGLEFILE)
|
||||||
{
|
{
|
||||||
// FIXME: buggy - does not work with addedFiles
|
// FIXME: buggy - does not work with addedFiles
|
||||||
auto filename = mod.fileinfo();
|
auto filename = mod->fileinfo();
|
||||||
if (!JlCompress::compressFile(&zipOut, filename.absoluteFilePath(), filename.fileName()))
|
if (!JlCompress::compressFile(&zipOut, filename.absoluteFilePath(), filename.fileName()))
|
||||||
{
|
{
|
||||||
zipOut.close();
|
zipOut.close();
|
||||||
QFile::remove(targetJarPath);
|
QFile::remove(targetJarPath);
|
||||||
qCritical() << "Failed to add" << mod.fileinfo().fileName() << "to the jar.";
|
qCritical() << "Failed to add" << mod->fileinfo().fileName() << "to the jar.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
addedFiles.insert(filename.fileName());
|
addedFiles.insert(filename.fileName());
|
||||||
}
|
}
|
||||||
else if (mod.type() == Mod::MOD_FOLDER)
|
else if (mod->type() == Mod::MOD_FOLDER)
|
||||||
{
|
{
|
||||||
// untested, but seems to be unused / not possible to reach
|
// untested, but seems to be unused / not possible to reach
|
||||||
// FIXME: buggy - does not work with addedFiles
|
// FIXME: buggy - does not work with addedFiles
|
||||||
auto filename = mod.fileinfo();
|
auto filename = mod->fileinfo();
|
||||||
QString what_to_zip = filename.absoluteFilePath();
|
QString what_to_zip = filename.absoluteFilePath();
|
||||||
QDir dir(what_to_zip);
|
QDir dir(what_to_zip);
|
||||||
dir.cdUp();
|
dir.cdUp();
|
||||||
@ -193,7 +191,7 @@ bool MMCZip::createModdedJar(QString sourceJarPath, QString targetJarPath, const
|
|||||||
{
|
{
|
||||||
zipOut.close();
|
zipOut.close();
|
||||||
QFile::remove(targetJarPath);
|
QFile::remove(targetJarPath);
|
||||||
qCritical() << "Failed to add" << mod.fileinfo().fileName() << "to the jar.";
|
qCritical() << "Failed to add" << mod->fileinfo().fileName() << "to the jar.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
qDebug() << "Adding folder " << filename.fileName() << " from "
|
qDebug() << "Adding folder " << filename.fileName() << " from "
|
||||||
@ -204,7 +202,7 @@ bool MMCZip::createModdedJar(QString sourceJarPath, QString targetJarPath, const
|
|||||||
// Make sure we do not continue launching when something is missing or undefined...
|
// Make sure we do not continue launching when something is missing or undefined...
|
||||||
zipOut.close();
|
zipOut.close();
|
||||||
QFile::remove(targetJarPath);
|
QFile::remove(targetJarPath);
|
||||||
qCritical() << "Failed to add unknown mod type" << mod.fileinfo().fileName() << "to the jar.";
|
qCritical() << "Failed to add unknown mod type" << mod->fileinfo().fileName() << "to the jar.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -305,7 +303,7 @@ nonstd::optional<QStringList> MMCZip::extractSubDir(QuaZip *zip, const QString &
|
|||||||
QString path;
|
QString path;
|
||||||
if(name.contains('/') && !name.endsWith('/')){
|
if(name.contains('/') && !name.endsWith('/')){
|
||||||
path = name.section('/', 0, -2) + "/";
|
path = name.section('/', 0, -2) + "/";
|
||||||
FS::ensureFolderPathExists(path);
|
FS::ensureFolderPathExists(FS::PathCombine(target, path));
|
||||||
|
|
||||||
name = name.split('/').last();
|
name = name.split('/').last();
|
||||||
}
|
}
|
||||||
@ -421,7 +419,7 @@ bool MMCZip::collectFileListRecursively(const QString& rootDir, const QString& s
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
files->append(e.filePath()); // we want the original paths for MMCZip::compressDirFiles
|
files->append(e); // we want the original paths for MMCZip::compressDirFiles
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ namespace MMCZip
|
|||||||
/**
|
/**
|
||||||
* take a source jar, add mods to it, resulting in target jar
|
* take a source jar, add mods to it, resulting in target jar
|
||||||
*/
|
*/
|
||||||
bool createModdedJar(QString sourceJarPath, QString targetJarPath, const QList<Mod>& mods);
|
bool createModdedJar(QString sourceJarPath, QString targetJarPath, const QList<Mod*>& mods);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a single file in archive by file name (not path)
|
* Find a single file in archive by file name (not path)
|
||||||
|
@ -27,6 +27,7 @@ ModDownloadTask::ModDownloadTask(ModPlatform::IndexedPack mod, ModPlatform::Inde
|
|||||||
{
|
{
|
||||||
if (is_indexed) {
|
if (is_indexed) {
|
||||||
m_update_task.reset(new LocalModUpdateTask(mods->indexDir(), m_mod, m_mod_version));
|
m_update_task.reset(new LocalModUpdateTask(mods->indexDir(), m_mod, m_mod_version));
|
||||||
|
connect(m_update_task.get(), &LocalModUpdateTask::hasOldMod, this, &ModDownloadTask::hasOldMod);
|
||||||
|
|
||||||
addTask(m_update_task);
|
addTask(m_update_task);
|
||||||
}
|
}
|
||||||
@ -40,12 +41,16 @@ ModDownloadTask::ModDownloadTask(ModPlatform::IndexedPack mod, ModPlatform::Inde
|
|||||||
connect(m_filesNetJob.get(), &NetJob::failed, this, &ModDownloadTask::downloadFailed);
|
connect(m_filesNetJob.get(), &NetJob::failed, this, &ModDownloadTask::downloadFailed);
|
||||||
|
|
||||||
addTask(m_filesNetJob);
|
addTask(m_filesNetJob);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModDownloadTask::downloadSucceeded()
|
void ModDownloadTask::downloadSucceeded()
|
||||||
{
|
{
|
||||||
m_filesNetJob.reset();
|
m_filesNetJob.reset();
|
||||||
|
auto name = std::get<0>(to_delete);
|
||||||
|
auto filename = std::get<1>(to_delete);
|
||||||
|
if (!name.isEmpty() && filename != m_mod_version.fileName) {
|
||||||
|
mods->uninstallMod(filename, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModDownloadTask::downloadFailed(QString reason)
|
void ModDownloadTask::downloadFailed(QString reason)
|
||||||
@ -58,3 +63,10 @@ void ModDownloadTask::downloadProgressChanged(qint64 current, qint64 total)
|
|||||||
{
|
{
|
||||||
emit progress(current, total);
|
emit progress(current, total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This indirection is done so that we don't delete a mod before being sure it was
|
||||||
|
// downloaded successfully!
|
||||||
|
void ModDownloadTask::hasOldMod(QString name, QString filename)
|
||||||
|
{
|
||||||
|
to_delete = {name, filename};
|
||||||
|
}
|
||||||
|
@ -30,7 +30,7 @@ class ModFolderModel;
|
|||||||
class ModDownloadTask : public SequentialTask {
|
class ModDownloadTask : public SequentialTask {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ModDownloadTask(ModPlatform::IndexedPack mod, ModPlatform::IndexedVersion version, const std::shared_ptr<ModFolderModel> mods, bool is_indexed);
|
explicit ModDownloadTask(ModPlatform::IndexedPack mod, ModPlatform::IndexedVersion version, const std::shared_ptr<ModFolderModel> mods, bool is_indexed = true);
|
||||||
const QString& getFilename() const { return m_mod_version.fileName; }
|
const QString& getFilename() const { return m_mod_version.fileName; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -46,6 +46,11 @@ private:
|
|||||||
void downloadFailed(QString reason);
|
void downloadFailed(QString reason);
|
||||||
|
|
||||||
void downloadSucceeded();
|
void downloadSucceeded();
|
||||||
|
|
||||||
|
std::tuple<QString, QString> to_delete {"", ""};
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void hasOldMod(QString name, QString filename);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,6 +39,10 @@ public:
|
|||||||
{
|
{
|
||||||
return QProcessEnvironment();
|
return QProcessEnvironment();
|
||||||
}
|
}
|
||||||
|
QProcessEnvironment createLaunchEnvironment() override
|
||||||
|
{
|
||||||
|
return QProcessEnvironment();
|
||||||
|
}
|
||||||
QMap<QString, QString> getVariables() const override
|
QMap<QString, QString> getVariables() const override
|
||||||
{
|
{
|
||||||
return QMap<QString, QString>();
|
return QMap<QString, QString>();
|
||||||
|
@ -1,6 +1,42 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This file incorporates work covered by the following copyright and
|
||||||
|
* permission notice:
|
||||||
|
*
|
||||||
|
* Copyright 2013-2021 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QStringView>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
class QUrl;
|
class QUrl;
|
||||||
@ -39,13 +75,21 @@ private:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
auto numPart = QStringView{m_fullString}.left(cutoff);
|
||||||
|
#else
|
||||||
auto numPart = m_fullString.leftRef(cutoff);
|
auto numPart = m_fullString.leftRef(cutoff);
|
||||||
|
#endif
|
||||||
if(numPart.size())
|
if(numPart.size())
|
||||||
{
|
{
|
||||||
numValid = true;
|
numValid = true;
|
||||||
m_numPart = numPart.toInt();
|
m_numPart = numPart.toInt();
|
||||||
}
|
}
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
auto stringPart = QStringView{m_fullString}.mid(cutoff);
|
||||||
|
#else
|
||||||
auto stringPart = m_fullString.midRef(cutoff);
|
auto stringPart = m_fullString.midRef(cutoff);
|
||||||
|
#endif
|
||||||
if(stringPart.size())
|
if(stringPart.size())
|
||||||
{
|
{
|
||||||
m_stringPart = stringPart.toString();
|
m_stringPart = stringPart.toString();
|
||||||
|
@ -1,3 +1,38 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This file incorporates work covered by the following copyright and
|
||||||
|
* permission notice:
|
||||||
|
*
|
||||||
|
* Copyright 2013-2021 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "VersionProxyModel.h"
|
#include "VersionProxyModel.h"
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
@ -208,7 +243,8 @@ QVariant VersionProxyModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
return APPLICATION->getThemedIcon("bug");
|
return APPLICATION->getThemedIcon("bug");
|
||||||
}
|
}
|
||||||
auto pixmap = QPixmapCache::find("placeholder");
|
QPixmap pixmap;
|
||||||
|
QPixmapCache::find("placeholder", &pixmap);
|
||||||
if(!pixmap)
|
if(!pixmap)
|
||||||
{
|
{
|
||||||
QPixmap px(16,16);
|
QPixmap px(16,16);
|
||||||
@ -216,7 +252,7 @@ QVariant VersionProxyModel::data(const QModelIndex &index, int role) const
|
|||||||
QPixmapCache::insert("placeholder", px);
|
QPixmapCache::insert("placeholder", px);
|
||||||
return px;
|
return px;
|
||||||
}
|
}
|
||||||
return *pixmap;
|
return pixmap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -1,16 +1,36 @@
|
|||||||
/* Copyright 2013-2021 MultiMC Contributors
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* you may not use this file except in compliance with the License.
|
* it under the terms of the GNU General Public License as published by
|
||||||
* You may obtain a copy of the License at
|
* 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
|
* You should have received a copy of the GNU General Public License
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
*
|
||||||
* See the License for the specific language governing permissions and
|
* This file incorporates work covered by the following copyright and
|
||||||
* limitations under the License.
|
* 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 "IconList.h"
|
#include "IconList.h"
|
||||||
@ -86,7 +106,11 @@ void IconList::directoryChanged(const QString &path)
|
|||||||
QString &foo = (*it);
|
QString &foo = (*it);
|
||||||
foo = m_dir.filePath(foo);
|
foo = m_dir.filePath(foo);
|
||||||
}
|
}
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||||
|
QSet<QString> new_set(new_list.begin(), new_list.end());
|
||||||
|
#else
|
||||||
auto new_set = new_list.toSet();
|
auto new_set = new_list.toSet();
|
||||||
|
#endif
|
||||||
QList<QString> current_list;
|
QList<QString> current_list;
|
||||||
for (auto &it : icons)
|
for (auto &it : icons)
|
||||||
{
|
{
|
||||||
@ -94,7 +118,11 @@ void IconList::directoryChanged(const QString &path)
|
|||||||
continue;
|
continue;
|
||||||
current_list.push_back(it.m_images[IconType::FileBased].filename);
|
current_list.push_back(it.m_images[IconType::FileBased].filename);
|
||||||
}
|
}
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||||
|
QSet<QString> current_set(current_list.begin(), current_list.end());
|
||||||
|
#else
|
||||||
QSet<QString> current_set = current_list.toSet();
|
QSet<QString> current_set = current_list.toSet();
|
||||||
|
#endif
|
||||||
|
|
||||||
QSet<QString> to_remove = current_set;
|
QSet<QString> to_remove = current_set;
|
||||||
to_remove -= new_set;
|
to_remove -= new_set;
|
||||||
|
@ -1,21 +1,41 @@
|
|||||||
/* Copyright 2013-2021 MultiMC Contributors
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* you may not use this file except in compliance with the License.
|
* it under the terms of the GNU General Public License as published by
|
||||||
* You may obtain a copy of the License at
|
* 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
|
* You should have received a copy of the GNU General Public License
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
*
|
||||||
* See the License for the specific language governing permissions and
|
* This file incorporates work covered by the following copyright and
|
||||||
* limitations under the License.
|
* 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 "MMCIcon.h"
|
#include "MMCIcon.h"
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <xdgicon.h>
|
#include <QIcon>
|
||||||
|
|
||||||
IconType operator--(IconType &t, int)
|
IconType operator--(IconType &t, int)
|
||||||
{
|
{
|
||||||
@ -63,7 +83,7 @@ QIcon MMCIcon::icon() const
|
|||||||
if(!icon.isNull())
|
if(!icon.isNull())
|
||||||
return icon;
|
return icon;
|
||||||
// FIXME: inject this.
|
// FIXME: inject this.
|
||||||
return XdgIcon::fromTheme(m_images[m_current_type].key);
|
return QIcon::fromTheme(m_images[m_current_type].key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MMCIcon::remove(IconType rm_type)
|
void MMCIcon::remove(IconType rm_type)
|
||||||
|
@ -1,3 +1,38 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This file incorporates work covered by the following copyright and
|
||||||
|
* permission notice:
|
||||||
|
*
|
||||||
|
* Copyright 2013-2021 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "JavaChecker.h"
|
#include "JavaChecker.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
@ -16,7 +51,13 @@ JavaChecker::JavaChecker(QObject *parent) : QObject(parent)
|
|||||||
|
|
||||||
void JavaChecker::performCheck()
|
void JavaChecker::performCheck()
|
||||||
{
|
{
|
||||||
QString checkerJar = FS::PathCombine(APPLICATION->getJarsPath(), "JavaCheck.jar");
|
QString checkerJar = JavaUtils::getJavaCheckPath();
|
||||||
|
|
||||||
|
if (checkerJar.isEmpty())
|
||||||
|
{
|
||||||
|
qDebug() << "Java checker library could not be found. Please check your installation.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QStringList args;
|
QStringList args;
|
||||||
|
|
||||||
@ -47,7 +88,11 @@ void JavaChecker::performCheck()
|
|||||||
qDebug() << "Running java checker: " + m_path + args.join(" ");;
|
qDebug() << "Running java checker: " + m_path + args.join(" ");;
|
||||||
|
|
||||||
connect(process.get(), SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(finished(int, QProcess::ExitStatus)));
|
connect(process.get(), SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(finished(int, QProcess::ExitStatus)));
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
connect(process.get(), SIGNAL(errorOccurred(QProcess::ProcessError)), this, SLOT(error(QProcess::ProcessError)));
|
||||||
|
#else
|
||||||
connect(process.get(), SIGNAL(error(QProcess::ProcessError)), this, SLOT(error(QProcess::ProcessError)));
|
connect(process.get(), SIGNAL(error(QProcess::ProcessError)), this, SLOT(error(QProcess::ProcessError)));
|
||||||
|
#endif
|
||||||
connect(process.get(), SIGNAL(readyReadStandardOutput()), this, SLOT(stdoutReady()));
|
connect(process.get(), SIGNAL(readyReadStandardOutput()), this, SLOT(stdoutReady()));
|
||||||
connect(process.get(), SIGNAL(readyReadStandardError()), this, SLOT(stderrReady()));
|
connect(process.get(), SIGNAL(readyReadStandardError()), this, SLOT(stderrReady()));
|
||||||
connect(&killTimer, SIGNAL(timeout()), SLOT(timeout()));
|
connect(&killTimer, SIGNAL(timeout()), SLOT(timeout()));
|
||||||
@ -99,7 +144,12 @@ void JavaChecker::finished(int exitcode, QProcess::ExitStatus status)
|
|||||||
bool success = true;
|
bool success = true;
|
||||||
|
|
||||||
QMap<QString, QString> results;
|
QMap<QString, QString> results;
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||||
|
QStringList lines = m_stdout.split("\n", Qt::SkipEmptyParts);
|
||||||
|
#else
|
||||||
QStringList lines = m_stdout.split("\n", QString::SkipEmptyParts);
|
QStringList lines = m_stdout.split("\n", QString::SkipEmptyParts);
|
||||||
|
#endif
|
||||||
for(QString line : lines)
|
for(QString line : lines)
|
||||||
{
|
{
|
||||||
line = line.trimmed();
|
line = line.trimmed();
|
||||||
@ -108,7 +158,11 @@ void JavaChecker::finished(int exitcode, QProcess::ExitStatus status)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||||
|
auto parts = line.split('=', Qt::SkipEmptyParts);
|
||||||
|
#else
|
||||||
auto parts = line.split('=', QString::SkipEmptyParts);
|
auto parts = line.split('=', QString::SkipEmptyParts);
|
||||||
|
#endif
|
||||||
if(parts.size() != 2 || parts[0].isEmpty() || parts[1].isEmpty())
|
if(parts.size() != 2 || parts[0].isEmpty() || parts[1].isEmpty())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -1,21 +1,40 @@
|
|||||||
/* Copyright 2013-2021 MultiMC Contributors
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* you may not use this file except in compliance with the License.
|
* it under the terms of the GNU General Public License as published by
|
||||||
* You may obtain a copy of the License at
|
* 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
|
* You should have received a copy of the GNU General Public License
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
*
|
||||||
* See the License for the specific language governing permissions and
|
* This file incorporates work covered by the following copyright and
|
||||||
* limitations under the License.
|
* 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 <QtNetwork>
|
#include <QtNetwork>
|
||||||
#include <QtXml>
|
#include <QtXml>
|
||||||
#include <QRegExp>
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
@ -81,7 +100,7 @@ QVariant JavaInstallList::data(const QModelIndex &index, int role) const
|
|||||||
switch (role)
|
switch (role)
|
||||||
{
|
{
|
||||||
case VersionPointerRole:
|
case VersionPointerRole:
|
||||||
return qVariantFromValue(m_vlist[index.row()]);
|
return QVariant::fromValue(m_vlist[index.row()]);
|
||||||
case VersionIdRole:
|
case VersionIdRole:
|
||||||
return version->descriptor();
|
return version->descriptor();
|
||||||
case VersionRole:
|
case VersionRole:
|
||||||
|
@ -1,16 +1,36 @@
|
|||||||
/* Copyright 2013-2021 MultiMC Contributors
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* you may not use this file except in compliance with the License.
|
* it under the terms of the GNU General Public License as published by
|
||||||
* You may obtain a copy of the License at
|
* 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
|
* You should have received a copy of the GNU General Public License
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
*
|
||||||
* See the License for the specific language governing permissions and
|
* This file incorporates work covered by the following copyright and
|
||||||
* limitations under the License.
|
* 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 <QStringList>
|
#include <QStringList>
|
||||||
@ -24,6 +44,7 @@
|
|||||||
#include "java/JavaUtils.h"
|
#include "java/JavaUtils.h"
|
||||||
#include "java/JavaInstallList.h"
|
#include "java/JavaInstallList.h"
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
|
#include "Application.h"
|
||||||
|
|
||||||
#define IBUS "@im=ibus"
|
#define IBUS "@im=ibus"
|
||||||
|
|
||||||
@ -31,26 +52,25 @@ JavaUtils::JavaUtils()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
|
QString stripVariableEntries(QString name, QString target, QString remove)
|
||||||
static QString processLD_LIBRARY_PATH(const QString & LD_LIBRARY_PATH)
|
|
||||||
{
|
{
|
||||||
QDir mmcBin(QCoreApplication::applicationDirPath());
|
char delimiter = ':';
|
||||||
auto items = LD_LIBRARY_PATH.split(':');
|
#ifdef Q_OS_WIN32
|
||||||
QStringList final;
|
delimiter = ';';
|
||||||
for(auto & item: items)
|
|
||||||
{
|
|
||||||
QDir test(item);
|
|
||||||
if(test == mmcBin)
|
|
||||||
{
|
|
||||||
qDebug() << "Env:LD_LIBRARY_PATH ignoring path" << item;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
final.append(item);
|
|
||||||
}
|
|
||||||
return final.join(':');
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
auto targetItems = target.split(delimiter);
|
||||||
|
auto toRemove = remove.split(delimiter);
|
||||||
|
|
||||||
|
for (QString item : toRemove) {
|
||||||
|
bool removed = targetItems.removeOne(item);
|
||||||
|
if (!removed)
|
||||||
|
qWarning() << "Entry" << item
|
||||||
|
<< "could not be stripped from variable" << name;
|
||||||
|
}
|
||||||
|
return targetItems.join(delimiter);
|
||||||
|
}
|
||||||
|
|
||||||
QProcessEnvironment CleanEnviroment()
|
QProcessEnvironment CleanEnviroment()
|
||||||
{
|
{
|
||||||
// prepare the process environment
|
// prepare the process environment
|
||||||
@ -68,6 +88,16 @@ QProcessEnvironment CleanEnviroment()
|
|||||||
"JAVA_OPTIONS",
|
"JAVA_OPTIONS",
|
||||||
"JAVA_TOOL_OPTIONS"
|
"JAVA_TOOL_OPTIONS"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QStringList stripped =
|
||||||
|
{
|
||||||
|
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
|
||||||
|
"LD_LIBRARY_PATH",
|
||||||
|
"LD_PRELOAD",
|
||||||
|
#endif
|
||||||
|
"QT_PLUGIN_PATH",
|
||||||
|
"QT_FONTPATH"
|
||||||
|
};
|
||||||
for(auto key: rawenv.keys())
|
for(auto key: rawenv.keys())
|
||||||
{
|
{
|
||||||
auto value = rawenv.value(key);
|
auto value = rawenv.value(key);
|
||||||
@ -87,9 +117,11 @@ QProcessEnvironment CleanEnviroment()
|
|||||||
// Do not pass LD_* variables to java. They were intended for SneedMC
|
// Do not pass LD_* variables to java. They were intended for SneedMC
|
||||||
if(key.startsWith("LD_"))
|
if(key.startsWith("LD_"))
|
||||||
{
|
{
|
||||||
qDebug() << "Env: ignoring" << key << value;
|
QString newValue = stripVariableEntries(key, value, rawenv.value("LAUNCHER_" + key));
|
||||||
continue;
|
|
||||||
|
qDebug() << "Env: stripped" << key << value << "to" << newValue;
|
||||||
}
|
}
|
||||||
|
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
|
||||||
// Strip IBus
|
// Strip IBus
|
||||||
// IBus is a Linux IME framework. For some reason, it breaks MC?
|
// IBus is a Linux IME framework. For some reason, it breaks MC?
|
||||||
if (key == "XMODIFIERS" && value.contains(IBUS))
|
if (key == "XMODIFIERS" && value.contains(IBUS))
|
||||||
@ -98,22 +130,12 @@ QProcessEnvironment CleanEnviroment()
|
|||||||
value.replace(IBUS, "");
|
value.replace(IBUS, "");
|
||||||
qDebug() << "Env: stripped" << IBUS << "from" << save << ":" << value;
|
qDebug() << "Env: stripped" << IBUS << "from" << save << ":" << value;
|
||||||
}
|
}
|
||||||
if(key == "GAME_PRELOAD")
|
|
||||||
{
|
|
||||||
env.insert("LD_PRELOAD", value);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(key == "GAME_LIBRARY_PATH")
|
|
||||||
{
|
|
||||||
env.insert("LD_LIBRARY_PATH", processLD_LIBRARY_PATH(value));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
// qDebug() << "Env: " << key << value;
|
// qDebug() << "Env: " << key << value;
|
||||||
env.insert(key, value);
|
env.insert(key, value);
|
||||||
}
|
}
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
// HACK: Workaround for QTBUG42500
|
// HACK: Workaround for QTBUG-42500
|
||||||
if(!env.contains("LD_LIBRARY_PATH"))
|
if(!env.contains("LD_LIBRARY_PATH"))
|
||||||
{
|
{
|
||||||
env.insert("LD_LIBRARY_PATH", "");
|
env.insert("LD_LIBRARY_PATH", "");
|
||||||
@ -176,25 +198,17 @@ QList<JavaInstallPtr> JavaUtils::FindJavaFromRegistryKey(DWORD keyType, QString
|
|||||||
archType = "32";
|
archType = "32";
|
||||||
|
|
||||||
HKEY jreKey;
|
HKEY jreKey;
|
||||||
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, keyName.toStdString().c_str(), 0,
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, keyName.toStdWString().c_str(), 0,
|
||||||
KEY_READ | keyType | KEY_ENUMERATE_SUB_KEYS, &jreKey) == ERROR_SUCCESS)
|
KEY_READ | keyType | KEY_ENUMERATE_SUB_KEYS, &jreKey) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
// Read the current type version from the registry.
|
// Read the current type version from the registry.
|
||||||
// This will be used to find any key that contains the JavaHome value.
|
// This will be used to find any key that contains the JavaHome value.
|
||||||
char *value = new char[0];
|
|
||||||
DWORD valueSz = 0;
|
|
||||||
if (RegQueryValueExA(jreKey, "CurrentVersion", NULL, NULL, (BYTE *)value, &valueSz) ==
|
|
||||||
ERROR_MORE_DATA)
|
|
||||||
{
|
|
||||||
value = new char[valueSz];
|
|
||||||
RegQueryValueExA(jreKey, "CurrentVersion", NULL, NULL, (BYTE *)value, &valueSz);
|
|
||||||
}
|
|
||||||
|
|
||||||
TCHAR subKeyName[255];
|
WCHAR subKeyName[255];
|
||||||
DWORD subKeyNameSize, numSubKeys, retCode;
|
DWORD subKeyNameSize, numSubKeys, retCode;
|
||||||
|
|
||||||
// Get the number of subkeys
|
// Get the number of subkeys
|
||||||
RegQueryInfoKey(jreKey, NULL, NULL, NULL, &numSubKeys, NULL, NULL, NULL, NULL, NULL,
|
RegQueryInfoKeyW(jreKey, NULL, NULL, NULL, &numSubKeys, NULL, NULL, NULL, NULL, NULL,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
// Iterate until RegEnumKeyEx fails
|
// Iterate until RegEnumKeyEx fails
|
||||||
@ -203,34 +217,37 @@ QList<JavaInstallPtr> JavaUtils::FindJavaFromRegistryKey(DWORD keyType, QString
|
|||||||
for (DWORD i = 0; i < numSubKeys; i++)
|
for (DWORD i = 0; i < numSubKeys; i++)
|
||||||
{
|
{
|
||||||
subKeyNameSize = 255;
|
subKeyNameSize = 255;
|
||||||
retCode = RegEnumKeyEx(jreKey, i, subKeyName, &subKeyNameSize, NULL, NULL, NULL,
|
retCode = RegEnumKeyExW(jreKey, i, subKeyName, &subKeyNameSize, NULL, NULL, NULL,
|
||||||
NULL);
|
NULL);
|
||||||
|
QString newSubkeyName = QString::fromWCharArray(subKeyName);
|
||||||
if (retCode == ERROR_SUCCESS)
|
if (retCode == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
// Now open the registry key for the version that we just got.
|
// Now open the registry key for the version that we just got.
|
||||||
QString newKeyName = keyName + "\\" + subKeyName + subkeySuffix;
|
QString newKeyName = keyName + "\\" + newSubkeyName + subkeySuffix;
|
||||||
|
|
||||||
HKEY newKey;
|
HKEY newKey;
|
||||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, newKeyName.toStdString().c_str(), 0,
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, newKeyName.toStdWString().c_str(), 0,
|
||||||
KEY_READ | KEY_WOW64_64KEY, &newKey) == ERROR_SUCCESS)
|
KEY_READ | KEY_WOW64_64KEY, &newKey) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
// Read the JavaHome value to find where Java is installed.
|
// Read the JavaHome value to find where Java is installed.
|
||||||
value = new char[0];
|
DWORD valueSz = 0;
|
||||||
valueSz = 0;
|
if (RegQueryValueExW(newKey, keyJavaDir.toStdWString().c_str(), NULL, NULL, NULL,
|
||||||
if (RegQueryValueEx(newKey, keyJavaDir.toStdString().c_str(), NULL, NULL, (BYTE *)value,
|
&valueSz) == ERROR_SUCCESS)
|
||||||
&valueSz) == ERROR_MORE_DATA)
|
|
||||||
{
|
{
|
||||||
value = new char[valueSz];
|
WCHAR *value = new WCHAR[valueSz];
|
||||||
RegQueryValueEx(newKey, keyJavaDir.toStdString().c_str(), NULL, NULL, (BYTE *)value,
|
RegQueryValueExW(newKey, keyJavaDir.toStdWString().c_str(), NULL, NULL, (BYTE *)value,
|
||||||
&valueSz);
|
&valueSz);
|
||||||
|
|
||||||
|
QString newValue = QString::fromWCharArray(value);
|
||||||
|
delete [] value;
|
||||||
|
|
||||||
// Now, we construct the version object and add it to the list.
|
// Now, we construct the version object and add it to the list.
|
||||||
JavaInstallPtr javaVersion(new JavaInstall());
|
JavaInstallPtr javaVersion(new JavaInstall());
|
||||||
|
|
||||||
javaVersion->id = subKeyName;
|
javaVersion->id = newSubkeyName;
|
||||||
javaVersion->arch = archType;
|
javaVersion->arch = archType;
|
||||||
javaVersion->path =
|
javaVersion->path =
|
||||||
QDir(FS::PathCombine(value, "bin")).absoluteFilePath("javaw.exe");
|
QDir(FS::PathCombine(newValue, "bin")).absoluteFilePath("javaw.exe");
|
||||||
javas.append(javaVersion);
|
javas.append(javaVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -437,3 +454,8 @@ QList<QString> JavaUtils::FindJavaPaths()
|
|||||||
return addJavasFromEnv(javas);
|
return addJavasFromEnv(javas);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
QString JavaUtils::getJavaCheckPath()
|
||||||
|
{
|
||||||
|
return APPLICATION->getJarPath("JavaCheck.jar");
|
||||||
|
}
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
QString stripVariableEntries(QString name, QString target, QString remove);
|
||||||
QProcessEnvironment CleanEnviroment();
|
QProcessEnvironment CleanEnviroment();
|
||||||
|
|
||||||
class JavaUtils : public QObject
|
class JavaUtils : public QObject
|
||||||
@ -39,4 +40,6 @@ public:
|
|||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
QList<JavaInstallPtr> FindJavaFromRegistryKey(DWORD keyType, QString keyName, QString keyJavaDir, QString subkeySuffix = "");
|
QList<JavaInstallPtr> FindJavaFromRegistryKey(DWORD keyType, QString keyName, QString keyJavaDir, QString subkeySuffix = "");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static QString getJavaCheckPath();
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include <QTest>
|
#include <QTest>
|
||||||
#include "TestUtil.h"
|
|
||||||
|
|
||||||
#include "java/JavaVersion.h"
|
#include "java/JavaVersion.h"
|
||||||
|
|
||||||
|
@ -282,18 +282,22 @@ void LaunchTask::emitFailed(QString reason)
|
|||||||
Task::emitFailed(reason);
|
Task::emitFailed(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString LaunchTask::substituteVariables(const QString &cmd) const
|
void LaunchTask::substituteVariables(QStringList &args) const
|
||||||
{
|
{
|
||||||
QString out = cmd;
|
auto env = m_instance->createEnvironment();
|
||||||
auto variables = m_instance->getVariables();
|
|
||||||
for (auto it = variables.begin(); it != variables.end(); ++it)
|
for (auto key : env.keys())
|
||||||
{
|
{
|
||||||
out.replace("$" + it.key(), it.value());
|
args.replaceInStrings("$" + key, env.value(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LaunchTask::substituteVariables(QString &cmd) const
|
||||||
|
{
|
||||||
|
auto env = m_instance->createEnvironment();
|
||||||
|
|
||||||
|
for (auto key : env.keys())
|
||||||
|
{
|
||||||
|
cmd.replace("$" + key, env.value(key));
|
||||||
}
|
}
|
||||||
auto env = QProcessEnvironment::systemEnvironment();
|
|
||||||
for (auto var : env.keys())
|
|
||||||
{
|
|
||||||
out.replace("$" + var, env.value(var));
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,38 @@
|
|||||||
/* Copyright 2013-2021 MultiMC Contributors
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
*
|
*
|
||||||
* Authors: Orochimarufan <orochimarufan.x3@gmail.com>
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* This program is distributed in the hope that it will be useful,
|
||||||
* you may not use this file except in compliance with the License.
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* You may obtain a copy of the License at
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* This file incorporates work covered by the following copyright and
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* permission notice:
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
*
|
||||||
* See the License for the specific language governing permissions and
|
* Copyright 2013-2021 MultiMC Contributors
|
||||||
* limitations under the License.
|
*
|
||||||
|
* Authors: Orochimarufan <orochimarufan.x3@gmail.com>
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@ -85,7 +105,8 @@ public: /* methods */
|
|||||||
shared_qobject_ptr<LogModel> getLogModel();
|
shared_qobject_ptr<LogModel> getLogModel();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString substituteVariables(const QString &cmd) const;
|
void substituteVariables(QStringList &args) const;
|
||||||
|
void substituteVariables(QString &cmd) const;
|
||||||
QString censorPrivateInfo(QString in);
|
QString censorPrivateInfo(QString in);
|
||||||
|
|
||||||
protected: /* methods */
|
protected: /* methods */
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "CheckJava.h"
|
#include "CheckJava.h"
|
||||||
|
#include "java/JavaUtils.h"
|
||||||
#include <launch/LaunchTask.h>
|
#include <launch/LaunchTask.h>
|
||||||
#include <FileSystem.h>
|
#include <FileSystem.h>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
@ -71,15 +72,26 @@ void CheckJava::executeTask()
|
|||||||
emit logLine("Java path is:\n" + m_javaPath + "\n\n", MessageLevel::Launcher);
|
emit logLine("Java path is:\n" + m_javaPath + "\n\n", MessageLevel::Launcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (JavaUtils::getJavaCheckPath().isEmpty())
|
||||||
|
{
|
||||||
|
const char *reason = QT_TR_NOOP("Java checker library could not be found. Please check your installation.");
|
||||||
|
emit logLine(tr(reason), MessageLevel::Fatal);
|
||||||
|
emitFailed(tr(reason));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QFileInfo javaInfo(realJavaPath);
|
QFileInfo javaInfo(realJavaPath);
|
||||||
qlonglong javaUnixTime = javaInfo.lastModified().toMSecsSinceEpoch();
|
qlonglong javaUnixTime = javaInfo.lastModified().toMSecsSinceEpoch();
|
||||||
auto storedUnixTime = settings->get("JavaTimestamp").toLongLong();
|
auto storedUnixTime = settings->get("JavaTimestamp").toLongLong();
|
||||||
auto storedArchitecture = settings->get("JavaArchitecture").toString();
|
auto storedArchitecture = settings->get("JavaArchitecture").toString();
|
||||||
|
auto storedRealArchitecture = settings->get("JavaRealArchitecture").toString();
|
||||||
auto storedVersion = settings->get("JavaVersion").toString();
|
auto storedVersion = settings->get("JavaVersion").toString();
|
||||||
auto storedVendor = settings->get("JavaVendor").toString();
|
auto storedVendor = settings->get("JavaVendor").toString();
|
||||||
m_javaUnixTime = javaUnixTime;
|
m_javaUnixTime = javaUnixTime;
|
||||||
// if timestamps are not the same, or something is missing, check!
|
// if timestamps are not the same, or something is missing, check!
|
||||||
if (javaUnixTime != storedUnixTime || storedVersion.size() == 0 || storedArchitecture.size() == 0 || storedVendor.size() == 0)
|
if (javaUnixTime != storedUnixTime || storedVersion.size() == 0
|
||||||
|
|| storedArchitecture.size() == 0 || storedRealArchitecture.size() == 0
|
||||||
|
|| storedVendor.size() == 0)
|
||||||
{
|
{
|
||||||
m_JavaChecker = new JavaChecker();
|
m_JavaChecker = new JavaChecker();
|
||||||
emit logLine(QString("Checking Java version..."), MessageLevel::Launcher);
|
emit logLine(QString("Checking Java version..."), MessageLevel::Launcher);
|
||||||
@ -92,8 +104,9 @@ void CheckJava::executeTask()
|
|||||||
{
|
{
|
||||||
auto verString = instance->settings()->get("JavaVersion").toString();
|
auto verString = instance->settings()->get("JavaVersion").toString();
|
||||||
auto archString = instance->settings()->get("JavaArchitecture").toString();
|
auto archString = instance->settings()->get("JavaArchitecture").toString();
|
||||||
|
auto realArchString = settings->get("JavaRealArchitecture").toString();
|
||||||
auto vendorString = instance->settings()->get("JavaVendor").toString();
|
auto vendorString = instance->settings()->get("JavaVendor").toString();
|
||||||
printJavaInfo(verString, archString, vendorString);
|
printJavaInfo(verString, archString, realArchString, vendorString);
|
||||||
}
|
}
|
||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
}
|
}
|
||||||
@ -124,10 +137,11 @@ void CheckJava::checkJavaFinished(JavaCheckResult result)
|
|||||||
case JavaCheckResult::Validity::Valid:
|
case JavaCheckResult::Validity::Valid:
|
||||||
{
|
{
|
||||||
auto instance = m_parent->instance();
|
auto instance = m_parent->instance();
|
||||||
printJavaInfo(result.javaVersion.toString(), result.realPlatform, result.javaVendor);
|
printJavaInfo(result.javaVersion.toString(), result.mojangPlatform, result.realPlatform, result.javaVendor);
|
||||||
printSystemInfo(true, result.is_64bit);
|
printSystemInfo(true, result.is_64bit);
|
||||||
instance->settings()->set("JavaVersion", result.javaVersion.toString());
|
instance->settings()->set("JavaVersion", result.javaVersion.toString());
|
||||||
instance->settings()->set("JavaArchitecture", result.mojangPlatform);
|
instance->settings()->set("JavaArchitecture", result.mojangPlatform);
|
||||||
|
instance->settings()->set("JavaRealArchitecture", result.realPlatform);
|
||||||
instance->settings()->set("JavaVendor", result.javaVendor);
|
instance->settings()->set("JavaVendor", result.javaVendor);
|
||||||
instance->settings()->set("JavaTimestamp", m_javaUnixTime);
|
instance->settings()->set("JavaTimestamp", m_javaUnixTime);
|
||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
@ -136,9 +150,10 @@ void CheckJava::checkJavaFinished(JavaCheckResult result)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckJava::printJavaInfo(const QString& version, const QString& architecture, const QString & vendor)
|
void CheckJava::printJavaInfo(const QString& version, const QString& architecture, const QString& realArchitecture, const QString & vendor)
|
||||||
{
|
{
|
||||||
emit logLine(QString("Java is version %1, using %2 architecture, from %3.\n\n").arg(version, architecture, vendor), MessageLevel::Launcher);
|
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)
|
void CheckJava::printSystemInfo(bool javaIsKnown, bool javaIs64bit)
|
||||||
|
@ -35,7 +35,7 @@ private slots:
|
|||||||
void checkJavaFinished(JavaCheckResult result);
|
void checkJavaFinished(JavaCheckResult result);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void printJavaInfo(const QString & version, const QString & architecture, const QString & vendor);
|
void printJavaInfo(const QString & version, const QString & architecture, const QString & realArchitecture, const QString & vendor);
|
||||||
void printSystemInfo(bool javaIsKnown, bool javaIs64bit);
|
void printSystemInfo(bool javaIsKnown, bool javaIs64bit);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -1,16 +1,36 @@
|
|||||||
/* Copyright 2013-2021 MultiMC Contributors
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* you may not use this file except in compliance with the License.
|
* it under the terms of the GNU General Public License as published by
|
||||||
* You may obtain a copy of the License at
|
* 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
|
* You should have received a copy of the GNU General Public License
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
*
|
||||||
* See the License for the specific language governing permissions and
|
* This file incorporates work covered by the following copyright and
|
||||||
* limitations under the License.
|
* 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 "PostLaunchCommand.h"
|
#include "PostLaunchCommand.h"
|
||||||
@ -27,9 +47,20 @@ PostLaunchCommand::PostLaunchCommand(LaunchTask *parent) : LaunchStep(parent)
|
|||||||
|
|
||||||
void PostLaunchCommand::executeTask()
|
void PostLaunchCommand::executeTask()
|
||||||
{
|
{
|
||||||
QString postlaunch_cmd = m_parent->substituteVariables(m_command);
|
//FIXME: where to put this?
|
||||||
emit logLine(tr("Running Post-Launch command: %1").arg(postlaunch_cmd), MessageLevel::Launcher);
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||||
m_process.start(postlaunch_cmd);
|
auto args = QProcess::splitCommand(m_command);
|
||||||
|
m_parent->substituteVariables(args);
|
||||||
|
|
||||||
|
emit logLine(tr("Running Post-Launch command: %1").arg(args.join(' ')), MessageLevel::Launcher);
|
||||||
|
const QString program = args.takeFirst();
|
||||||
|
m_process.start(program, args);
|
||||||
|
#else
|
||||||
|
m_parent->substituteVariables(m_command);
|
||||||
|
|
||||||
|
emit logLine(tr("Running Post-Launch command: %1").arg(m_command), MessageLevel::Launcher);
|
||||||
|
m_process.start(m_command);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostLaunchCommand::on_state(LoggedProcess::State state)
|
void PostLaunchCommand::on_state(LoggedProcess::State state)
|
||||||
|
@ -1,16 +1,36 @@
|
|||||||
/* Copyright 2013-2021 MultiMC Contributors
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* you may not use this file except in compliance with the License.
|
* it under the terms of the GNU General Public License as published by
|
||||||
* You may obtain a copy of the License at
|
* 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
|
* You should have received a copy of the GNU General Public License
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
*
|
||||||
* See the License for the specific language governing permissions and
|
* This file incorporates work covered by the following copyright and
|
||||||
* limitations under the License.
|
* 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 "PreLaunchCommand.h"
|
#include "PreLaunchCommand.h"
|
||||||
@ -28,9 +48,19 @@ PreLaunchCommand::PreLaunchCommand(LaunchTask *parent) : LaunchStep(parent)
|
|||||||
void PreLaunchCommand::executeTask()
|
void PreLaunchCommand::executeTask()
|
||||||
{
|
{
|
||||||
//FIXME: where to put this?
|
//FIXME: where to put this?
|
||||||
QString prelaunch_cmd = m_parent->substituteVariables(m_command);
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||||
emit logLine(tr("Running Pre-Launch command: %1").arg(prelaunch_cmd), MessageLevel::Launcher);
|
auto args = QProcess::splitCommand(m_command);
|
||||||
m_process.start(prelaunch_cmd);
|
m_parent->substituteVariables(args);
|
||||||
|
|
||||||
|
emit logLine(tr("Running Pre-Launch command: %1").arg(args.join(' ')), MessageLevel::Launcher);
|
||||||
|
const QString program = args.takeFirst();
|
||||||
|
m_process.start(program, args);
|
||||||
|
#else
|
||||||
|
m_parent->substituteVariables(m_command);
|
||||||
|
|
||||||
|
emit logLine(tr("Running Pre-Launch command: %1").arg(m_command), MessageLevel::Launcher);
|
||||||
|
m_process.start(m_command);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreLaunchCommand::on_state(LoggedProcess::State state)
|
void PreLaunchCommand::on_state(LoggedProcess::State state)
|
||||||
|
@ -1,3 +1,38 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This file incorporates work covered by the following copyright and
|
||||||
|
* permission notice:
|
||||||
|
*
|
||||||
|
* Copyright 2013-2021 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
|
||||||
// #define BREAK_INFINITE_LOOP
|
// #define BREAK_INFINITE_LOOP
|
||||||
@ -24,8 +59,10 @@ int main(int argc, char *argv[])
|
|||||||
return 42;
|
return 42;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if QT_VERSION <= QT_VERSION_CHECK(6, 0, 0)
|
||||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
|
#endif
|
||||||
|
|
||||||
// initialize Qt
|
// initialize Qt
|
||||||
Application app(argc, argv);
|
Application app(argc, argv);
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include <QTest>
|
#include <QTest>
|
||||||
#include "TestUtil.h"
|
|
||||||
|
|
||||||
#include "meta/Index.h"
|
#include "meta/Index.h"
|
||||||
#include "meta/VersionList.h"
|
#include "meta/VersionList.h"
|
||||||
|
@ -197,6 +197,10 @@ void ComponentUpdateTask::loadComponents()
|
|||||||
{
|
{
|
||||||
remoteLoadFailed(taskIndex, error);
|
remoteLoadFailed(taskIndex, error);
|
||||||
});
|
});
|
||||||
|
connect(indexLoadTask.get(), &Task::aborted, [=]()
|
||||||
|
{
|
||||||
|
remoteLoadFailed(taskIndex, tr("Aborted"));
|
||||||
|
});
|
||||||
taskIndex++;
|
taskIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -243,6 +247,10 @@ void ComponentUpdateTask::loadComponents()
|
|||||||
{
|
{
|
||||||
remoteLoadFailed(taskIndex, error);
|
remoteLoadFailed(taskIndex, error);
|
||||||
});
|
});
|
||||||
|
connect(loadTask.get(), &Task::aborted, [=]()
|
||||||
|
{
|
||||||
|
remoteLoadFailed(taskIndex, tr("Aborted"));
|
||||||
|
});
|
||||||
RemoteLoadStatus status;
|
RemoteLoadStatus status;
|
||||||
status.type = loadType;
|
status.type = loadType;
|
||||||
status.PackProfileIndex = componentIndex;
|
status.PackProfileIndex = componentIndex;
|
||||||
|
@ -1,7 +1,43 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This file incorporates work covered by the following copyright and
|
||||||
|
* permission notice:
|
||||||
|
*
|
||||||
|
* Copyright 2013-2021 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QRegularExpression>
|
||||||
#include "DefaultVariable.h"
|
#include "DefaultVariable.h"
|
||||||
|
|
||||||
struct GradleSpecifier
|
struct GradleSpecifier
|
||||||
@ -25,20 +61,21 @@ struct GradleSpecifier
|
|||||||
4 "jdk15"
|
4 "jdk15"
|
||||||
5 "jar"
|
5 "jar"
|
||||||
*/
|
*/
|
||||||
QRegExp matcher("([^:@]+):([^:@]+):([^:@]+)" "(?::([^:@]+))?" "(?:@([^:@]+))?");
|
QRegularExpression matcher(QRegularExpression::anchoredPattern("([^:@]+):([^:@]+):([^:@]+)" "(?::([^:@]+))?" "(?:@([^:@]+))?"));
|
||||||
m_valid = matcher.exactMatch(value);
|
QRegularExpressionMatch match = matcher.match(value);
|
||||||
|
m_valid = match.hasMatch();
|
||||||
if(!m_valid) {
|
if(!m_valid) {
|
||||||
m_invalidValue = value;
|
m_invalidValue = value;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
auto elements = matcher.capturedTexts();
|
auto elements = match.captured();
|
||||||
m_groupId = elements[1];
|
m_groupId = match.captured(1);
|
||||||
m_artifactId = elements[2];
|
m_artifactId = match.captured(2);
|
||||||
m_version = elements[3];
|
m_version = match.captured(3);
|
||||||
m_classifier = elements[4];
|
m_classifier = match.captured(4);
|
||||||
if(!elements[5].isEmpty())
|
if(match.lastCapturedIndex() >= 5)
|
||||||
{
|
{
|
||||||
m_extension = elements[5];
|
m_extension = match.captured(5);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include <QTest>
|
#include <QTest>
|
||||||
#include "TestUtil.h"
|
|
||||||
|
|
||||||
#include "minecraft/GradleSpecifier.h"
|
#include "minecraft/GradleSpecifier.h"
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include <QTest>
|
#include <QTest>
|
||||||
#include "TestUtil.h"
|
|
||||||
|
|
||||||
#include "minecraft/MojangVersionFormat.h"
|
#include "minecraft/MojangVersionFormat.h"
|
||||||
#include "minecraft/OneSixVersionFormat.h"
|
#include "minecraft/OneSixVersionFormat.h"
|
||||||
@ -11,15 +10,14 @@ class LibraryTest : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
LibraryPtr readMojangJson(const char *file)
|
LibraryPtr readMojangJson(const QString path)
|
||||||
{
|
{
|
||||||
auto path = QFINDTESTDATA(file);
|
|
||||||
QFile jsonFile(path);
|
QFile jsonFile(path);
|
||||||
jsonFile.open(QIODevice::ReadOnly);
|
jsonFile.open(QIODevice::ReadOnly);
|
||||||
auto data = jsonFile.readAll();
|
auto data = jsonFile.readAll();
|
||||||
jsonFile.close();
|
jsonFile.close();
|
||||||
ProblemContainer problems;
|
ProblemContainer problems;
|
||||||
return MojangVersionFormat::libraryFromJson(problems, QJsonDocument::fromJson(data).object(), file);
|
return MojangVersionFormat::libraryFromJson(problems, QJsonDocument::fromJson(data).object(), path);
|
||||||
}
|
}
|
||||||
// get absolute path to expected storage, assuming default cache prefix
|
// get absolute path to expected storage, assuming default cache prefix
|
||||||
QStringList getStorage(QString relative)
|
QStringList getStorage(QString relative)
|
||||||
@ -32,7 +30,7 @@ slots:
|
|||||||
{
|
{
|
||||||
cache.reset(new HttpMetaCache());
|
cache.reset(new HttpMetaCache());
|
||||||
cache->addBase("libraries", QDir("libraries").absolutePath());
|
cache->addBase("libraries", QDir("libraries").absolutePath());
|
||||||
dataDir = QDir("data").absolutePath();
|
dataDir = QDir(QFINDTESTDATA("testdata")).absolutePath();
|
||||||
}
|
}
|
||||||
void test_legacy()
|
void test_legacy()
|
||||||
{
|
{
|
||||||
@ -74,14 +72,14 @@ slots:
|
|||||||
QCOMPARE(test.isNative(), false);
|
QCOMPARE(test.isNative(), false);
|
||||||
QStringList failedFiles;
|
QStringList failedFiles;
|
||||||
test.setHint("local");
|
test.setHint("local");
|
||||||
auto downloads = test.getDownloads(currentSystem, cache.get(), failedFiles, QString("data"));
|
auto downloads = test.getDownloads(currentSystem, cache.get(), failedFiles, QFINDTESTDATA("testdata"));
|
||||||
QCOMPARE(downloads.size(), 0);
|
QCOMPARE(downloads.size(), 0);
|
||||||
qDebug() << failedFiles;
|
qDebug() << failedFiles;
|
||||||
QCOMPARE(failedFiles.size(), 0);
|
QCOMPARE(failedFiles.size(), 0);
|
||||||
|
|
||||||
QStringList jar, native, native32, native64;
|
QStringList jar, native, native32, native64;
|
||||||
test.getApplicableFiles(currentSystem, jar, native, native32, native64, QString("data"));
|
test.getApplicableFiles(currentSystem, jar, native, native32, native64, QFINDTESTDATA("testdata"));
|
||||||
QCOMPARE(jar, {QFileInfo("data/codecwav-20101023.jar").absoluteFilePath()});
|
QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/codecwav-20101023.jar")).absoluteFilePath()});
|
||||||
QCOMPARE(native, {});
|
QCOMPARE(native, {});
|
||||||
QCOMPARE(native32, {});
|
QCOMPARE(native32, {});
|
||||||
QCOMPARE(native64, {});
|
QCOMPARE(native64, {});
|
||||||
@ -167,20 +165,20 @@ slots:
|
|||||||
test.setRepositoryURL("file://foo/bar");
|
test.setRepositoryURL("file://foo/bar");
|
||||||
{
|
{
|
||||||
QStringList jar, native, native32, native64;
|
QStringList jar, native, native32, native64;
|
||||||
test.getApplicableFiles(Os_Linux, jar, native, native32, native64, QString("data"));
|
test.getApplicableFiles(Os_Linux, jar, native, native32, native64, QFINDTESTDATA("testdata"));
|
||||||
QCOMPARE(jar, {});
|
QCOMPARE(jar, {});
|
||||||
QCOMPARE(native, {});
|
QCOMPARE(native, {});
|
||||||
QCOMPARE(native32, {QFileInfo("data/testname-testversion-linux-32.jar").absoluteFilePath()});
|
QCOMPARE(native32, {QFileInfo(QFINDTESTDATA("testdata/testname-testversion-linux-32.jar")).absoluteFilePath()});
|
||||||
QCOMPARE(native64, {QFileInfo("data/testname-testversion-linux-64.jar").absoluteFilePath()});
|
QCOMPARE(native64, {QFileInfo(QFINDTESTDATA("testdata") + "/testname-testversion-linux-64.jar").absoluteFilePath()});
|
||||||
QStringList failedFiles;
|
QStringList failedFiles;
|
||||||
auto dls = test.getDownloads(Os_Linux, cache.get(), failedFiles, QString("data"));
|
auto dls = test.getDownloads(Os_Linux, cache.get(), failedFiles, QFINDTESTDATA("testdata"));
|
||||||
QCOMPARE(dls.size(), 0);
|
QCOMPARE(dls.size(), 0);
|
||||||
QCOMPARE(failedFiles, {"data/testname-testversion-linux-64.jar"});
|
QCOMPARE(failedFiles, {QFileInfo(QFINDTESTDATA("testdata") + "/testname-testversion-linux-64.jar").absoluteFilePath()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void test_onenine()
|
void test_onenine()
|
||||||
{
|
{
|
||||||
auto test = readMojangJson("data/lib-simple.json");
|
auto test = readMojangJson(QFINDTESTDATA("testdata/lib-simple.json"));
|
||||||
{
|
{
|
||||||
QStringList jar, native, native32, native64;
|
QStringList jar, native, native32, native64;
|
||||||
test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QString());
|
test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QString());
|
||||||
@ -199,41 +197,41 @@ slots:
|
|||||||
test->setHint("local");
|
test->setHint("local");
|
||||||
{
|
{
|
||||||
QStringList jar, native, native32, native64;
|
QStringList jar, native, native32, native64;
|
||||||
test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QString("data"));
|
test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QFINDTESTDATA("testdata"));
|
||||||
QCOMPARE(jar, {QFileInfo("data/codecwav-20101023.jar").absoluteFilePath()});
|
QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/codecwav-20101023.jar")).absoluteFilePath()});
|
||||||
QCOMPARE(native, {});
|
QCOMPARE(native, {});
|
||||||
QCOMPARE(native32, {});
|
QCOMPARE(native32, {});
|
||||||
QCOMPARE(native64, {});
|
QCOMPARE(native64, {});
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
QStringList failedFiles;
|
QStringList failedFiles;
|
||||||
auto dls = test->getDownloads(Os_Linux, cache.get(), failedFiles, QString("data"));
|
auto dls = test->getDownloads(Os_Linux, cache.get(), failedFiles, QFINDTESTDATA("testdata"));
|
||||||
QCOMPARE(dls.size(), 0);
|
QCOMPARE(dls.size(), 0);
|
||||||
QCOMPARE(failedFiles, {});
|
QCOMPARE(failedFiles, {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void test_onenine_local_override()
|
void test_onenine_local_override()
|
||||||
{
|
{
|
||||||
auto test = readMojangJson("data/lib-simple.json");
|
auto test = readMojangJson(QFINDTESTDATA("testdata/lib-simple.json"));
|
||||||
test->setHint("local");
|
test->setHint("local");
|
||||||
{
|
{
|
||||||
QStringList jar, native, native32, native64;
|
QStringList jar, native, native32, native64;
|
||||||
test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QString("data"));
|
test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QFINDTESTDATA("testdata"));
|
||||||
QCOMPARE(jar, {QFileInfo("data/codecwav-20101023.jar").absoluteFilePath()});
|
QCOMPARE(jar, {QFileInfo(QFINDTESTDATA("testdata/codecwav-20101023.jar")).absoluteFilePath()});
|
||||||
QCOMPARE(native, {});
|
QCOMPARE(native, {});
|
||||||
QCOMPARE(native32, {});
|
QCOMPARE(native32, {});
|
||||||
QCOMPARE(native64, {});
|
QCOMPARE(native64, {});
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
QStringList failedFiles;
|
QStringList failedFiles;
|
||||||
auto dls = test->getDownloads(Os_Linux, cache.get(), failedFiles, QString("data"));
|
auto dls = test->getDownloads(Os_Linux, cache.get(), failedFiles, QFINDTESTDATA("testdata"));
|
||||||
QCOMPARE(dls.size(), 0);
|
QCOMPARE(dls.size(), 0);
|
||||||
QCOMPARE(failedFiles, {});
|
QCOMPARE(failedFiles, {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void test_onenine_native()
|
void test_onenine_native()
|
||||||
{
|
{
|
||||||
auto test = readMojangJson("data/lib-native.json");
|
auto test = readMojangJson(QFINDTESTDATA("testdata/lib-native.json"));
|
||||||
QStringList jar, native, native32, native64;
|
QStringList jar, native, native32, native64;
|
||||||
test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QString());
|
test->getApplicableFiles(Os_OSX, jar, native, native32, native64, QString());
|
||||||
QCOMPARE(jar, QStringList());
|
QCOMPARE(jar, QStringList());
|
||||||
@ -248,7 +246,7 @@ slots:
|
|||||||
}
|
}
|
||||||
void test_onenine_native_arch()
|
void test_onenine_native_arch()
|
||||||
{
|
{
|
||||||
auto test = readMojangJson("data/lib-native-arch.json");
|
auto test = readMojangJson(QFINDTESTDATA("testdata/lib-native-arch.json"));
|
||||||
QStringList jar, native, native32, native64;
|
QStringList jar, native, native32, native64;
|
||||||
test->getApplicableFiles(Os_Windows, jar, native, native32, native64, QString());
|
test->getApplicableFiles(Os_Windows, jar, native, native32, native64, QString());
|
||||||
QCOMPARE(jar, {});
|
QCOMPARE(jar, {});
|
||||||
|
@ -154,6 +154,12 @@ MinecraftInstance::MinecraftInstance(SettingsObjectPtr globalSettings, SettingsO
|
|||||||
m_settings->registerOverride(globalSettings->getSetting("UseNativeOpenAL"), nativeLibraryWorkaroundsOverride);
|
m_settings->registerOverride(globalSettings->getSetting("UseNativeOpenAL"), nativeLibraryWorkaroundsOverride);
|
||||||
m_settings->registerOverride(globalSettings->getSetting("UseNativeGLFW"), nativeLibraryWorkaroundsOverride);
|
m_settings->registerOverride(globalSettings->getSetting("UseNativeGLFW"), nativeLibraryWorkaroundsOverride);
|
||||||
|
|
||||||
|
// Peformance related options
|
||||||
|
auto performanceOverride = m_settings->registerSetting("OverridePerformance", false);
|
||||||
|
m_settings->registerOverride(globalSettings->getSetting("EnableFeralGamemode"), performanceOverride);
|
||||||
|
m_settings->registerOverride(globalSettings->getSetting("EnableMangoHud"), performanceOverride);
|
||||||
|
m_settings->registerOverride(globalSettings->getSetting("UseDiscreteGpu"), performanceOverride);
|
||||||
|
|
||||||
// Game time
|
// Game time
|
||||||
auto gameTimeOverride = m_settings->registerSetting("OverrideGameTime", false);
|
auto gameTimeOverride = m_settings->registerSetting("OverrideGameTime", false);
|
||||||
m_settings->registerOverride(globalSettings->getSetting("ShowGameTime"), gameTimeOverride);
|
m_settings->registerOverride(globalSettings->getSetting("ShowGameTime"), gameTimeOverride);
|
||||||
@ -435,27 +441,57 @@ QProcessEnvironment MinecraftInstance::createEnvironment()
|
|||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QProcessEnvironment MinecraftInstance::createLaunchEnvironment()
|
||||||
|
{
|
||||||
|
// prepare the process environment
|
||||||
|
QProcessEnvironment env = createEnvironment();
|
||||||
|
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
if (settings()->get("EnableMangoHud").toBool())
|
||||||
|
{
|
||||||
|
auto preload = env.value("LD_PRELOAD", "") + ":libMangoHud_dlsym.so:libMangoHud.so";
|
||||||
|
auto lib_path = env.value("LD_LIBRARY_PATH", "") + ":/usr/local/$LIB/mangohud/:/usr/$LIB/mangohud/";
|
||||||
|
|
||||||
|
env.insert("LD_PRELOAD", preload);
|
||||||
|
env.insert("LD_LIBRARY_PATH", lib_path);
|
||||||
|
env.insert("MANGOHUD", "1");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings()->get("UseDiscreteGpu").toBool())
|
||||||
|
{
|
||||||
|
// Open Source Drivers
|
||||||
|
env.insert("DRI_PRIME", "1");
|
||||||
|
// Proprietary Nvidia Drivers
|
||||||
|
env.insert("__NV_PRIME_RENDER_OFFLOAD", "1");
|
||||||
|
env.insert("__VK_LAYER_NV_optimus", "NVIDIA_only");
|
||||||
|
env.insert("__GLX_VENDOR_LIBRARY_NAME", "nvidia");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return env;
|
||||||
|
}
|
||||||
|
|
||||||
static QString replaceTokensIn(QString text, QMap<QString, QString> with)
|
static QString replaceTokensIn(QString text, QMap<QString, QString> with)
|
||||||
{
|
{
|
||||||
|
// TODO: does this still work??
|
||||||
QString result;
|
QString result;
|
||||||
QRegExp token_regexp("\\$\\{(.+)\\}");
|
QRegularExpression token_regexp("\\$\\{(.+)\\}", QRegularExpression::InvertedGreedinessOption);
|
||||||
token_regexp.setMinimal(true);
|
|
||||||
QStringList list;
|
QStringList list;
|
||||||
int tail = 0;
|
QRegularExpressionMatchIterator i = token_regexp.globalMatch(text);
|
||||||
int head = 0;
|
int lastCapturedEnd = 0;
|
||||||
while ((head = token_regexp.indexIn(text, head)) != -1)
|
while (i.hasNext())
|
||||||
{
|
{
|
||||||
result.append(text.mid(tail, head - tail));
|
QRegularExpressionMatch match = i.next();
|
||||||
QString key = token_regexp.cap(1);
|
result.append(text.mid(lastCapturedEnd, match.capturedStart()));
|
||||||
|
QString key = match.captured(1);
|
||||||
auto iter = with.find(key);
|
auto iter = with.find(key);
|
||||||
if (iter != with.end())
|
if (iter != with.end())
|
||||||
{
|
{
|
||||||
result.append(*iter);
|
result.append(*iter);
|
||||||
}
|
}
|
||||||
head += token_regexp.matchedLength();
|
lastCapturedEnd = match.capturedEnd();
|
||||||
tail = head;
|
|
||||||
}
|
}
|
||||||
result.append(text.mid(tail));
|
result.append(text.mid(lastCapturedEnd));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -505,7 +541,11 @@ QStringList MinecraftInstance::processMinecraftArgs(
|
|||||||
token_mapping["assets_root"] = absAssetsDir;
|
token_mapping["assets_root"] = absAssetsDir;
|
||||||
token_mapping["assets_index_name"] = assets->id;
|
token_mapping["assets_index_name"] = assets->id;
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||||
|
QStringList parts = args_pattern.split(' ', Qt::SkipEmptyParts);
|
||||||
|
#else
|
||||||
QStringList parts = args_pattern.split(' ', QString::SkipEmptyParts);
|
QStringList parts = args_pattern.split(' ', QString::SkipEmptyParts);
|
||||||
|
#endif
|
||||||
for (int i = 0; i < parts.length(); i++)
|
for (int i = 0; i < parts.length(); i++)
|
||||||
{
|
{
|
||||||
parts[i] = replaceTokensIn(parts[i], token_mapping);
|
parts[i] = replaceTokensIn(parts[i], token_mapping);
|
||||||
@ -661,24 +701,24 @@ QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session, Minecr
|
|||||||
{
|
{
|
||||||
out << QString("%1:").arg(label);
|
out << QString("%1:").arg(label);
|
||||||
auto modList = model.allMods();
|
auto modList = model.allMods();
|
||||||
std::sort(modList.begin(), modList.end(), [](Mod &a, Mod &b) {
|
std::sort(modList.begin(), modList.end(), [](Mod::Ptr a, Mod::Ptr b) {
|
||||||
auto aName = a.fileinfo().completeBaseName();
|
auto aName = a->fileinfo().completeBaseName();
|
||||||
auto bName = b.fileinfo().completeBaseName();
|
auto bName = b->fileinfo().completeBaseName();
|
||||||
return aName.localeAwareCompare(bName) < 0;
|
return aName.localeAwareCompare(bName) < 0;
|
||||||
});
|
});
|
||||||
for(auto & mod: modList)
|
for(auto mod: modList)
|
||||||
{
|
{
|
||||||
if(mod.type() == Mod::MOD_FOLDER)
|
if(mod->type() == Mod::MOD_FOLDER)
|
||||||
{
|
{
|
||||||
out << u8" [📁] " + mod.fileinfo().completeBaseName() + " (folder)";
|
out << u8" [🖿] " + mod->fileinfo().completeBaseName() + " (folder)";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mod.enabled()) {
|
if(mod->enabled()) {
|
||||||
out << u8" [✔️] " + mod.fileinfo().completeBaseName();
|
out << u8" [✔] " + mod->fileinfo().completeBaseName();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
out << u8" [❌] " + mod.fileinfo().completeBaseName() + " (disabled)";
|
out << u8" [✘] " + mod->fileinfo().completeBaseName() + " (disabled)";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -748,7 +788,9 @@ QMap<QString, QString> MinecraftInstance::createCensorFilterFromSession(AuthSess
|
|||||||
{
|
{
|
||||||
addToFilter(sessionRef.session, tr("<SESSION ID>"));
|
addToFilter(sessionRef.session, tr("<SESSION ID>"));
|
||||||
}
|
}
|
||||||
addToFilter(sessionRef.access_token, tr("<ACCESS TOKEN>"));
|
if (sessionRef.access_token != "offline") {
|
||||||
|
addToFilter(sessionRef.access_token, tr("<ACCESS TOKEN>"));
|
||||||
|
}
|
||||||
if(sessionRef.client_token.size()) {
|
if(sessionRef.client_token.size()) {
|
||||||
addToFilter(sessionRef.client_token, tr("<CLIENT TOKEN>"));
|
addToFilter(sessionRef.client_token, tr("<CLIENT TOKEN>"));
|
||||||
}
|
}
|
||||||
@ -827,8 +869,16 @@ QString MinecraftInstance::getStatusbarDescription()
|
|||||||
traits.append(tr("broken"));
|
traits.append(tr("broken"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString mcVersion = m_components->getComponentVersion("net.minecraft");
|
||||||
|
if (mcVersion.isEmpty())
|
||||||
|
{
|
||||||
|
// Load component info if needed
|
||||||
|
m_components->reload(Net::Mode::Offline);
|
||||||
|
mcVersion = m_components->getComponentVersion("net.minecraft");
|
||||||
|
}
|
||||||
|
|
||||||
QString description;
|
QString description;
|
||||||
description.append(tr("Minecraft %1 (%2)").arg(m_components->getComponentVersion("net.minecraft")).arg(typeName()));
|
description.append(tr("Minecraft %1").arg(mcVersion));
|
||||||
if(m_settings->get("ShowGameTime").toBool())
|
if(m_settings->get("ShowGameTime").toBool())
|
||||||
{
|
{
|
||||||
if (lastTimePlayed() > 0) {
|
if (lastTimePlayed() > 0) {
|
||||||
@ -1087,16 +1137,16 @@ std::shared_ptr<GameOptions> MinecraftInstance::gameOptionsModel() const
|
|||||||
return m_game_options;
|
return m_game_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList< Mod > MinecraftInstance::getJarMods() const
|
QList<Mod*> MinecraftInstance::getJarMods() const
|
||||||
{
|
{
|
||||||
auto profile = m_components->getProfile();
|
auto profile = m_components->getProfile();
|
||||||
QList<Mod> mods;
|
QList<Mod*> mods;
|
||||||
for (auto jarmod : profile->getJarMods())
|
for (auto jarmod : profile->getJarMods())
|
||||||
{
|
{
|
||||||
QStringList jar, temp1, temp2, temp3;
|
QStringList jar, temp1, temp2, temp3;
|
||||||
jarmod->getApplicableFiles(currentSystem, jar, temp1, temp2, temp3, jarmodsPath().absolutePath());
|
jarmod->getApplicableFiles(currentSystem, jar, temp1, temp2, temp3, jarmodsPath().absolutePath());
|
||||||
// QString filePath = jarmodsPath().absoluteFilePath(jarmod->filename(currentSystem));
|
// QString filePath = jarmodsPath().absoluteFilePath(jarmod->filename(currentSystem));
|
||||||
mods.push_back(Mod(QFileInfo(jar[0])));
|
mods.push_back(new Mod(QFileInfo(jar[0])));
|
||||||
}
|
}
|
||||||
return mods;
|
return mods;
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ public:
|
|||||||
shared_qobject_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account, MinecraftServerTargetPtr serverToJoin) override;
|
shared_qobject_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account, MinecraftServerTargetPtr serverToJoin) override;
|
||||||
QStringList extraArguments() const override;
|
QStringList extraArguments() const override;
|
||||||
QStringList verboseDescription(AuthSessionPtr session, MinecraftServerTargetPtr serverToJoin) override;
|
QStringList verboseDescription(AuthSessionPtr session, MinecraftServerTargetPtr serverToJoin) override;
|
||||||
QList<Mod> getJarMods() const;
|
QList<Mod*> getJarMods() const;
|
||||||
QString createLaunchScript(AuthSessionPtr session, MinecraftServerTargetPtr serverToJoin);
|
QString createLaunchScript(AuthSessionPtr session, MinecraftServerTargetPtr serverToJoin);
|
||||||
/// get arguments passed to java
|
/// get arguments passed to java
|
||||||
QStringList javaArguments() const;
|
QStringList javaArguments() const;
|
||||||
@ -91,6 +91,7 @@ public:
|
|||||||
|
|
||||||
/// create an environment for launching processes
|
/// create an environment for launching processes
|
||||||
QProcessEnvironment createEnvironment() override;
|
QProcessEnvironment createEnvironment() override;
|
||||||
|
QProcessEnvironment createLaunchEnvironment() override;
|
||||||
|
|
||||||
/// guess log level from a line of minecraft log
|
/// guess log level from a line of minecraft log
|
||||||
MessageLevel::Enum guessLevel(const QString &line, MessageLevel::Enum level) override;
|
MessageLevel::Enum guessLevel(const QString &line, MessageLevel::Enum level) override;
|
||||||
|
@ -20,6 +20,7 @@ void MinecraftLoadAndCheck::executeTask()
|
|||||||
}
|
}
|
||||||
connect(m_task.get(), &Task::succeeded, this, &MinecraftLoadAndCheck::subtaskSucceeded);
|
connect(m_task.get(), &Task::succeeded, this, &MinecraftLoadAndCheck::subtaskSucceeded);
|
||||||
connect(m_task.get(), &Task::failed, this, &MinecraftLoadAndCheck::subtaskFailed);
|
connect(m_task.get(), &Task::failed, this, &MinecraftLoadAndCheck::subtaskFailed);
|
||||||
|
connect(m_task.get(), &Task::aborted, this, [this]{ subtaskFailed(tr("Aborted")); });
|
||||||
connect(m_task.get(), &Task::progress, this, &MinecraftLoadAndCheck::progress);
|
connect(m_task.get(), &Task::progress, this, &MinecraftLoadAndCheck::progress);
|
||||||
connect(m_task.get(), &Task::status, this, &MinecraftLoadAndCheck::setStatus);
|
connect(m_task.get(), &Task::status, this, &MinecraftLoadAndCheck::setStatus);
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,7 @@ void MinecraftUpdate::next()
|
|||||||
auto task = m_tasks[m_currentTask - 1];
|
auto task = m_tasks[m_currentTask - 1];
|
||||||
disconnect(task.get(), &Task::succeeded, this, &MinecraftUpdate::subtaskSucceeded);
|
disconnect(task.get(), &Task::succeeded, this, &MinecraftUpdate::subtaskSucceeded);
|
||||||
disconnect(task.get(), &Task::failed, this, &MinecraftUpdate::subtaskFailed);
|
disconnect(task.get(), &Task::failed, this, &MinecraftUpdate::subtaskFailed);
|
||||||
|
disconnect(task.get(), &Task::aborted, this, &Task::abort);
|
||||||
disconnect(task.get(), &Task::progress, this, &MinecraftUpdate::progress);
|
disconnect(task.get(), &Task::progress, this, &MinecraftUpdate::progress);
|
||||||
disconnect(task.get(), &Task::status, this, &MinecraftUpdate::setStatus);
|
disconnect(task.get(), &Task::status, this, &MinecraftUpdate::setStatus);
|
||||||
}
|
}
|
||||||
@ -115,6 +116,7 @@ void MinecraftUpdate::next()
|
|||||||
}
|
}
|
||||||
connect(task.get(), &Task::succeeded, this, &MinecraftUpdate::subtaskSucceeded);
|
connect(task.get(), &Task::succeeded, this, &MinecraftUpdate::subtaskSucceeded);
|
||||||
connect(task.get(), &Task::failed, this, &MinecraftUpdate::subtaskFailed);
|
connect(task.get(), &Task::failed, this, &MinecraftUpdate::subtaskFailed);
|
||||||
|
connect(task.get(), &Task::aborted, this, &Task::abort);
|
||||||
connect(task.get(), &Task::progress, this, &MinecraftUpdate::progress);
|
connect(task.get(), &Task::progress, this, &MinecraftUpdate::progress);
|
||||||
connect(task.get(), &Task::status, this, &MinecraftUpdate::setStatus);
|
connect(task.get(), &Task::status, this, &MinecraftUpdate::setStatus);
|
||||||
// if the task is already running, do not start it again
|
// if the task is already running, do not start it again
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
class MinecraftVersion;
|
class MinecraftVersion;
|
||||||
class MinecraftInstance;
|
class MinecraftInstance;
|
||||||
|
|
||||||
|
// FIXME: This looks very similar to a SequentialTask. Maybe we can reduce code duplications? :^)
|
||||||
|
|
||||||
class MinecraftUpdate : public Task
|
class MinecraftUpdate : public Task
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -65,7 +65,7 @@ struct MojangAssetIndexInfo : public MojangDownloadInfo
|
|||||||
// https://www.theregister.co.uk/2017/02/28/aws_is_awol_as_s3_goes_haywire/
|
// https://www.theregister.co.uk/2017/02/28/aws_is_awol_as_s3_goes_haywire/
|
||||||
if(id == "legacy")
|
if(id == "legacy")
|
||||||
{
|
{
|
||||||
url = "https://launchermeta.mojang.com/mc/assets/legacy/c0fd82e8ce9fbc93119e40d96d5a4e62cfa3f729/legacy.json";
|
url = "https://piston-meta.mojang.com/mc/assets/legacy/c0fd82e8ce9fbc93119e40d96d5a4e62cfa3f729/legacy.json";
|
||||||
}
|
}
|
||||||
// HACK
|
// HACK
|
||||||
else
|
else
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include <QTest>
|
#include <QTest>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "TestUtil.h"
|
|
||||||
|
|
||||||
#include "minecraft/MojangVersionFormat.h"
|
#include "minecraft/MojangVersionFormat.h"
|
||||||
|
|
||||||
@ -8,9 +7,8 @@ class MojangVersionFormatTest : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
static QJsonDocument readJson(const char *file)
|
static QJsonDocument readJson(const QString path)
|
||||||
{
|
{
|
||||||
auto path = QFINDTESTDATA(file);
|
|
||||||
QFile jsonFile(path);
|
QFile jsonFile(path);
|
||||||
jsonFile.open(QIODevice::ReadOnly);
|
jsonFile.open(QIODevice::ReadOnly);
|
||||||
auto data = jsonFile.readAll();
|
auto data = jsonFile.readAll();
|
||||||
@ -31,7 +29,7 @@ private
|
|||||||
slots:
|
slots:
|
||||||
void test_Through_Simple()
|
void test_Through_Simple()
|
||||||
{
|
{
|
||||||
QJsonDocument doc = readJson("data/1.9-simple.json");
|
QJsonDocument doc = readJson(QFINDTESTDATA("testdata/1.9-simple.json"));
|
||||||
auto vfile = MojangVersionFormat::versionFileFromJson(doc, "1.9-simple.json");
|
auto vfile = MojangVersionFormat::versionFileFromJson(doc, "1.9-simple.json");
|
||||||
auto doc2 = MojangVersionFormat::versionFileToJson(vfile);
|
auto doc2 = MojangVersionFormat::versionFileToJson(vfile);
|
||||||
writeJson("1.9-simple-passthorugh.json", doc2);
|
writeJson("1.9-simple-passthorugh.json", doc2);
|
||||||
@ -41,7 +39,7 @@ slots:
|
|||||||
|
|
||||||
void test_Through()
|
void test_Through()
|
||||||
{
|
{
|
||||||
QJsonDocument doc = readJson("data/1.9.json");
|
QJsonDocument doc = readJson(QFINDTESTDATA("testdata/1.9.json"));
|
||||||
auto vfile = MojangVersionFormat::versionFileFromJson(doc, "1.9.json");
|
auto vfile = MojangVersionFormat::versionFileFromJson(doc, "1.9.json");
|
||||||
auto doc2 = MojangVersionFormat::versionFileToJson(vfile);
|
auto doc2 = MojangVersionFormat::versionFileToJson(vfile);
|
||||||
writeJson("1.9-passthorugh.json", doc2);
|
writeJson("1.9-passthorugh.json", doc2);
|
||||||
|
@ -1,3 +1,38 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This file incorporates work covered by the following copyright and
|
||||||
|
* permission notice:
|
||||||
|
*
|
||||||
|
* Copyright 2013-2021 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "OneSixVersionFormat.h"
|
#include "OneSixVersionFormat.h"
|
||||||
#include <Json.h>
|
#include <Json.h>
|
||||||
#include "minecraft/Agent.h"
|
#include "minecraft/Agent.h"
|
||||||
@ -296,7 +331,7 @@ QJsonDocument OneSixVersionFormat::versionFileToJson(const VersionFilePtr &patch
|
|||||||
}
|
}
|
||||||
writeString(root, "appletClass", patch->appletClass);
|
writeString(root, "appletClass", patch->appletClass);
|
||||||
writeStringList(root, "+tweakers", patch->addTweakers);
|
writeStringList(root, "+tweakers", patch->addTweakers);
|
||||||
writeStringList(root, "+traits", patch->traits.toList());
|
writeStringList(root, "+traits", patch->traits.values());
|
||||||
if (!patch->libraries.isEmpty())
|
if (!patch->libraries.isEmpty())
|
||||||
{
|
{
|
||||||
QJsonArray array;
|
QJsonArray array;
|
||||||
|
@ -1,16 +1,36 @@
|
|||||||
/* Copyright 2013-2021 MultiMC Contributors
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* you may not use this file except in compliance with the License.
|
* it under the terms of the GNU General Public License as published by
|
||||||
* You may obtain a copy of the License at
|
* 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
|
* You should have received a copy of the GNU General Public License
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
*
|
||||||
* See the License for the specific language governing permissions and
|
* This file incorporates work covered by the following copyright and
|
||||||
* limitations under the License.
|
* 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 <QFile>
|
#include <QFile>
|
||||||
@ -346,6 +366,7 @@ void PackProfile::resolve(Net::Mode netmode)
|
|||||||
d->m_updateTask.reset(updateTask);
|
d->m_updateTask.reset(updateTask);
|
||||||
connect(updateTask, &ComponentUpdateTask::succeeded, this, &PackProfile::updateSucceeded);
|
connect(updateTask, &ComponentUpdateTask::succeeded, this, &PackProfile::updateSucceeded);
|
||||||
connect(updateTask, &ComponentUpdateTask::failed, this, &PackProfile::updateFailed);
|
connect(updateTask, &ComponentUpdateTask::failed, this, &PackProfile::updateFailed);
|
||||||
|
connect(updateTask, &ComponentUpdateTask::aborted, this, [this]{ updateFailed(tr("Aborted")); });
|
||||||
d->m_updateTask->start();
|
d->m_updateTask->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -687,7 +708,11 @@ void PackProfile::move(const int index, const MoveDirection direction)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
beginMoveRows(QModelIndex(), index, index, QModelIndex(), togap);
|
beginMoveRows(QModelIndex(), index, index, QModelIndex(), togap);
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
|
||||||
|
d->components.swapItemsAt(index, theirIndex);
|
||||||
|
#else
|
||||||
d->components.swap(index, theirIndex);
|
d->components.swap(index, theirIndex);
|
||||||
|
#endif
|
||||||
endMoveRows();
|
endMoveRows();
|
||||||
invalidateLaunchProfile();
|
invalidateLaunchProfile();
|
||||||
scheduleSave();
|
scheduleSave();
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include <QTest>
|
#include <QTest>
|
||||||
#include "TestUtil.h"
|
|
||||||
|
|
||||||
#include "minecraft/ParseUtils.h"
|
#include "minecraft/ParseUtils.h"
|
||||||
|
|
||||||
@ -42,4 +41,3 @@ slots:
|
|||||||
QTEST_GUILESS_MAIN(ParseUtilsTest)
|
QTEST_GUILESS_MAIN(ParseUtilsTest)
|
||||||
|
|
||||||
#include "ParseUtils_test.moc"
|
#include "ParseUtils_test.moc"
|
||||||
|
|
||||||
|
@ -1,3 +1,38 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This file incorporates work covered by the following copyright and
|
||||||
|
* permission notice:
|
||||||
|
*
|
||||||
|
* Copyright 2013-2021 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "ProfileUtils.h"
|
#include "ProfileUtils.h"
|
||||||
#include "minecraft/VersionFilterData.h"
|
#include "minecraft/VersionFilterData.h"
|
||||||
#include "minecraft/OneSixVersionFormat.h"
|
#include "minecraft/OneSixVersionFormat.h"
|
||||||
@ -141,24 +176,6 @@ bool saveJsonFile(const QJsonDocument doc, const QString & filename)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
VersionFilePtr parseBinaryJsonFile(const QFileInfo &fileInfo)
|
|
||||||
{
|
|
||||||
QFile file(fileInfo.absoluteFilePath());
|
|
||||||
if (!file.open(QFile::ReadOnly))
|
|
||||||
{
|
|
||||||
auto errorStr = QObject::tr("Unable to open the version file %1: %2.").arg(fileInfo.fileName(), file.errorString());
|
|
||||||
return createErrorVersionFile(fileInfo.completeBaseName(), fileInfo.absoluteFilePath(), errorStr);
|
|
||||||
}
|
|
||||||
QJsonDocument doc = QJsonDocument::fromBinaryData(file.readAll());
|
|
||||||
file.close();
|
|
||||||
if (doc.isNull())
|
|
||||||
{
|
|
||||||
file.remove();
|
|
||||||
throw JSONValidationError(QObject::tr("Unable to process the version file %1.").arg(fileInfo.fileName()));
|
|
||||||
}
|
|
||||||
return guardedParseJson(doc, fileInfo.completeBaseName(), fileInfo.absoluteFilePath(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void removeLwjglFromPatch(VersionFilePtr patch)
|
void removeLwjglFromPatch(VersionFilePtr patch)
|
||||||
{
|
{
|
||||||
auto filter = [](QList<LibraryPtr>& libs)
|
auto filter = [](QList<LibraryPtr>& libs)
|
||||||
|
@ -1,3 +1,38 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This file incorporates work covered by the following copyright and
|
||||||
|
* permission notice:
|
||||||
|
*
|
||||||
|
* Copyright 2013-2021 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "Library.h"
|
#include "Library.h"
|
||||||
#include "VersionFile.h"
|
#include "VersionFile.h"
|
||||||
@ -19,9 +54,6 @@ VersionFilePtr parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder)
|
|||||||
/// Save a JSON file (in any format)
|
/// Save a JSON file (in any format)
|
||||||
bool saveJsonFile(const QJsonDocument doc, const QString & filename);
|
bool saveJsonFile(const QJsonDocument doc, const QString & filename);
|
||||||
|
|
||||||
/// Parse a version file in binary JSON format
|
|
||||||
VersionFilePtr parseBinaryJsonFile(const QFileInfo &fileInfo);
|
|
||||||
|
|
||||||
/// Remove LWJGL from a patch file. This is applied to all Mojang-like profile files.
|
/// Remove LWJGL from a patch file. This is applied to all Mojang-like profile files.
|
||||||
void removeLwjglFromPatch(VersionFilePtr patch);
|
void removeLwjglFromPatch(VersionFilePtr patch);
|
||||||
|
|
||||||
|
@ -89,14 +89,3 @@ void VersionFile::applyTo(LaunchProfile *profile)
|
|||||||
}
|
}
|
||||||
profile->applyProblemSeverity(getProblemSeverity());
|
profile->applyProblemSeverity(getProblemSeverity());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
auto theirVersion = profile->getMinecraftVersion();
|
|
||||||
if (!theirVersion.isNull() && !dependsOnMinecraftVersion.isNull())
|
|
||||||
{
|
|
||||||
if (QRegExp(dependsOnMinecraftVersion, Qt::CaseInsensitive, QRegExp::Wildcard).indexIn(theirVersion) == -1)
|
|
||||||
{
|
|
||||||
throw MinecraftVersionMismatch(uid, dependsOnMinecraftVersion, theirVersion);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
@ -1,16 +1,36 @@
|
|||||||
/* Copyright 2015-2021 MultiMC Contributors
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* you may not use this file except in compliance with the License.
|
* it under the terms of the GNU General Public License as published by
|
||||||
* You may obtain a copy of the License at
|
* 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
|
* You should have received a copy of the GNU General Public License
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
*
|
||||||
* See the License for the specific language governing permissions and
|
* This file incorporates work covered by the following copyright and
|
||||||
* limitations under the License.
|
* 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 <QDir>
|
#include <QDir>
|
||||||
@ -321,7 +341,8 @@ bool World::install(const QString &to, const QString &name)
|
|||||||
|
|
||||||
if(ok && !name.isEmpty() && m_actualName != name)
|
if(ok && !name.isEmpty() && m_actualName != name)
|
||||||
{
|
{
|
||||||
World newWorld(finalPath);
|
QFileInfo finalPathInfo(finalPath);
|
||||||
|
World newWorld(finalPathInfo);
|
||||||
if(newWorld.isValid())
|
if(newWorld.isValid())
|
||||||
{
|
{
|
||||||
newWorld.rename(name);
|
newWorld.rename(name);
|
||||||
|
@ -1,16 +1,36 @@
|
|||||||
/* Copyright 2015-2021 MultiMC Contributors
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* you may not use this file except in compliance with the License.
|
* it under the terms of the GNU General Public License as published by
|
||||||
* You may obtain a copy of the License at
|
* 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
|
* You should have received a copy of the GNU General Public License
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
*
|
||||||
* See the License for the specific language governing permissions and
|
* This file incorporates work covered by the following copyright and
|
||||||
* limitations under the License.
|
* 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 "WorldList.h"
|
#include "WorldList.h"
|
||||||
@ -195,7 +215,7 @@ QVariant WorldList::data(const QModelIndex &index, int role) const
|
|||||||
switch (column)
|
switch (column)
|
||||||
{
|
{
|
||||||
case SizeColumn:
|
case SizeColumn:
|
||||||
return qVariantFromValue<qlonglong>(world.bytes());
|
return QVariant::fromValue<qlonglong>(world.bytes());
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return data(index, Qt::DisplayRole);
|
return data(index, Qt::DisplayRole);
|
||||||
@ -215,7 +235,7 @@ QVariant WorldList::data(const QModelIndex &index, int role) const
|
|||||||
}
|
}
|
||||||
case SeedRole:
|
case SeedRole:
|
||||||
{
|
{
|
||||||
return qVariantFromValue<qlonglong>(world.seed());
|
return QVariant::fromValue<qlonglong>(world.seed());
|
||||||
}
|
}
|
||||||
case NameRole:
|
case NameRole:
|
||||||
{
|
{
|
||||||
@ -227,7 +247,7 @@ QVariant WorldList::data(const QModelIndex &index, int role) const
|
|||||||
}
|
}
|
||||||
case SizeRole:
|
case SizeRole:
|
||||||
{
|
{
|
||||||
return qVariantFromValue<qlonglong>(world.bytes());
|
return QVariant::fromValue<qlonglong>(world.bytes());
|
||||||
}
|
}
|
||||||
case IconFileRole:
|
case IconFileRole:
|
||||||
{
|
{
|
||||||
@ -301,7 +321,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
QVariant retrieveData(const QString &mimetype, QMetaType type) const
|
||||||
|
#else
|
||||||
QVariant retrieveData(const QString &mimetype, QVariant::Type type) const
|
QVariant retrieveData(const QString &mimetype, QVariant::Type type) const
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
QList<QUrl> urls;
|
QList<QUrl> urls;
|
||||||
for(auto &world: m_worlds)
|
for(auto &world: m_worlds)
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void tokenToJSONV3(QJsonObject &parent, Katabasis::Token t, const char * tokenName) {
|
void tokenToJSONV3(QJsonObject &parent, Katabasis::Token t, const char * tokenName) {
|
||||||
@ -451,7 +452,7 @@ void AccountData::invalidateClientToken() {
|
|||||||
if(type != AccountType::Mojang) {
|
if(type != AccountType::Mojang) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
yggdrasilToken.extra["clientToken"] = QUuid::createUuid().toString().remove(QRegExp("[{-}]"));
|
yggdrasilToken.extra["clientToken"] = QUuid::createUuid().toString().remove(QRegularExpression("[{-}]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AccountData::profileId() const {
|
QString AccountData::profileId() const {
|
||||||
@ -473,7 +474,7 @@ QString AccountData::accountDisplayString() const {
|
|||||||
return userName();
|
return userName();
|
||||||
}
|
}
|
||||||
case AccountType::Offline: {
|
case AccountType::Offline: {
|
||||||
return userName();
|
return QObject::tr("<Offline>");
|
||||||
}
|
}
|
||||||
case AccountType::MSA: {
|
case AccountType::MSA: {
|
||||||
if(xboxApiToken.extra.contains("gtg")) {
|
if(xboxApiToken.extra.contains("gtg")) {
|
||||||
|
@ -282,6 +282,10 @@ QVariant AccountList::data(const QModelIndex &index, int role) const
|
|||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
switch (index.column())
|
switch (index.column())
|
||||||
{
|
{
|
||||||
|
case ProfileNameColumn: {
|
||||||
|
return account->profileName();
|
||||||
|
}
|
||||||
|
|
||||||
case NameColumn:
|
case NameColumn:
|
||||||
return account->accountDisplayString();
|
return account->accountDisplayString();
|
||||||
|
|
||||||
@ -300,7 +304,7 @@ QVariant AccountList::data(const QModelIndex &index, int role) const
|
|||||||
return tr("Offline", "Account status");
|
return tr("Offline", "Account status");
|
||||||
}
|
}
|
||||||
case AccountState::Online: {
|
case AccountState::Online: {
|
||||||
return tr("Online", "Account status");
|
return tr("Ready", "Account status");
|
||||||
}
|
}
|
||||||
case AccountState::Working: {
|
case AccountState::Working: {
|
||||||
return tr("Working", "Account status");
|
return tr("Working", "Account status");
|
||||||
@ -320,10 +324,6 @@ QVariant AccountList::data(const QModelIndex &index, int role) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case ProfileNameColumn: {
|
|
||||||
return account->profileName();
|
|
||||||
}
|
|
||||||
|
|
||||||
case MigrationColumn: {
|
case MigrationColumn: {
|
||||||
if(account->isMSA() || account->isOffline()) {
|
if(account->isMSA() || account->isOffline()) {
|
||||||
return tr("N/A", "Can Migrate?");
|
return tr("N/A", "Can Migrate?");
|
||||||
@ -349,7 +349,7 @@ QVariant AccountList::data(const QModelIndex &index, int role) const
|
|||||||
case Qt::CheckStateRole:
|
case Qt::CheckStateRole:
|
||||||
switch (index.column())
|
switch (index.column())
|
||||||
{
|
{
|
||||||
case NameColumn:
|
case ProfileNameColumn:
|
||||||
return account == m_defaultAccount ? Qt::Checked : Qt::Unchecked;
|
return account == m_defaultAccount ? Qt::Checked : Qt::Unchecked;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,6 +365,8 @@ QVariant AccountList::headerData(int section, Qt::Orientation orientation, int r
|
|||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
switch (section)
|
switch (section)
|
||||||
{
|
{
|
||||||
|
case ProfileNameColumn:
|
||||||
|
return tr("Username");
|
||||||
case NameColumn:
|
case NameColumn:
|
||||||
return tr("Account");
|
return tr("Account");
|
||||||
case TypeColumn:
|
case TypeColumn:
|
||||||
@ -373,8 +375,6 @@ QVariant AccountList::headerData(int section, Qt::Orientation orientation, int r
|
|||||||
return tr("Status");
|
return tr("Status");
|
||||||
case MigrationColumn:
|
case MigrationColumn:
|
||||||
return tr("Can Migrate?");
|
return tr("Can Migrate?");
|
||||||
case ProfileNameColumn:
|
|
||||||
return tr("Profile");
|
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
@ -382,6 +382,8 @@ QVariant AccountList::headerData(int section, Qt::Orientation orientation, int r
|
|||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
switch (section)
|
switch (section)
|
||||||
{
|
{
|
||||||
|
case ProfileNameColumn:
|
||||||
|
return tr("Minecraft username associated with the account.");
|
||||||
case NameColumn:
|
case NameColumn:
|
||||||
return tr("User name of the account.");
|
return tr("User name of the account.");
|
||||||
case TypeColumn:
|
case TypeColumn:
|
||||||
@ -389,9 +391,7 @@ QVariant AccountList::headerData(int section, Qt::Orientation orientation, int r
|
|||||||
case StatusColumn:
|
case StatusColumn:
|
||||||
return tr("Current status of the account.");
|
return tr("Current status of the account.");
|
||||||
case MigrationColumn:
|
case MigrationColumn:
|
||||||
return tr("Can this account migrate to Microsoft account?");
|
return tr("Can this account migrate to a Microsoft account?");
|
||||||
case ProfileNameColumn:
|
|
||||||
return tr("Name of the Minecraft profile associated with the account.");
|
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -58,8 +58,8 @@ public:
|
|||||||
enum VListColumns
|
enum VListColumns
|
||||||
{
|
{
|
||||||
// TODO: Add icon column.
|
// TODO: Add icon column.
|
||||||
NameColumn = 0,
|
ProfileNameColumn = 0,
|
||||||
ProfileNameColumn,
|
NameColumn,
|
||||||
MigrationColumn,
|
MigrationColumn,
|
||||||
TypeColumn,
|
TypeColumn,
|
||||||
StatusColumn,
|
StatusColumn,
|
||||||
|
@ -79,6 +79,8 @@ QString AccountTask::getStateMessage() const
|
|||||||
bool AccountTask::changeState(AccountTaskState newState, QString reason)
|
bool AccountTask::changeState(AccountTaskState newState, QString reason)
|
||||||
{
|
{
|
||||||
m_taskState = newState;
|
m_taskState = newState;
|
||||||
|
// FIXME: virtual method invoked in constructor.
|
||||||
|
// We want that behavior, but maybe make it less weird?
|
||||||
setStatus(getStateMessage());
|
setStatus(getStateMessage());
|
||||||
switch(newState) {
|
switch(newState) {
|
||||||
case AccountTaskState::STATE_CREATED: {
|
case AccountTaskState::STATE_CREATED: {
|
||||||
|
@ -1,3 +1,38 @@
|
|||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
/*
|
||||||
|
* PolyMC - Minecraft Launcher
|
||||||
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, version 3.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This file incorporates work covered by the following copyright and
|
||||||
|
* permission notice:
|
||||||
|
*
|
||||||
|
* Copyright 2013-2021 MultiMC Contributors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@ -20,7 +55,11 @@ void AuthRequest::get(const QNetworkRequest &req, int timeout/* = 60*1000*/) {
|
|||||||
reply_ = APPLICATION->network()->get(request_);
|
reply_ = APPLICATION->network()->get(request_);
|
||||||
status_ = Requesting;
|
status_ = Requesting;
|
||||||
timedReplies_.add(new Katabasis::Reply(reply_, timeout));
|
timedReplies_.add(new Katabasis::Reply(reply_, timeout));
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)));
|
||||||
|
#else
|
||||||
connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)));
|
connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)));
|
||||||
|
#endif
|
||||||
connect(reply_, SIGNAL(finished()), this, SLOT(onRequestFinished()));
|
connect(reply_, SIGNAL(finished()), this, SLOT(onRequestFinished()));
|
||||||
connect(reply_, &QNetworkReply::sslErrors, this, &AuthRequest::onSslErrors);
|
connect(reply_, &QNetworkReply::sslErrors, this, &AuthRequest::onSslErrors);
|
||||||
}
|
}
|
||||||
@ -31,7 +70,11 @@ void AuthRequest::post(const QNetworkRequest &req, const QByteArray &data, int t
|
|||||||
status_ = Requesting;
|
status_ = Requesting;
|
||||||
reply_ = APPLICATION->network()->post(request_, data_);
|
reply_ = APPLICATION->network()->post(request_, data_);
|
||||||
timedReplies_.add(new Katabasis::Reply(reply_, timeout));
|
timedReplies_.add(new Katabasis::Reply(reply_, timeout));
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
connect(reply_, SIGNAL(errorOccurred(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)));
|
||||||
|
#else
|
||||||
connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)));
|
connect(reply_, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(onRequestError(QNetworkReply::NetworkError)));
|
||||||
|
#endif
|
||||||
connect(reply_, SIGNAL(finished()), this, SLOT(onRequestFinished()));
|
connect(reply_, SIGNAL(finished()), this, SLOT(onRequestFinished()));
|
||||||
connect(reply_, &QNetworkReply::sslErrors, this, &AuthRequest::onSslErrors);
|
connect(reply_, &QNetworkReply::sslErrors, this, &AuthRequest::onSslErrors);
|
||||||
connect(reply_, SIGNAL(uploadProgress(qint64,qint64)), this, SLOT(onUploadProgress(qint64,qint64)));
|
connect(reply_, SIGNAL(uploadProgress(qint64,qint64)), this, SLOT(onUploadProgress(qint64,qint64)));
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
|
||||||
@ -53,7 +53,7 @@
|
|||||||
#include "flows/Offline.h"
|
#include "flows/Offline.h"
|
||||||
|
|
||||||
MinecraftAccount::MinecraftAccount(QObject* parent) : QObject(parent) {
|
MinecraftAccount::MinecraftAccount(QObject* parent) : QObject(parent) {
|
||||||
data.internalId = QUuid::createUuid().toString().remove(QRegExp("[{}-]"));
|
data.internalId = QUuid::createUuid().toString().remove(QRegularExpression("[{}-]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ MinecraftAccountPtr MinecraftAccount::createFromUsername(const QString &username
|
|||||||
MinecraftAccountPtr account = new MinecraftAccount();
|
MinecraftAccountPtr account = new MinecraftAccount();
|
||||||
account->data.type = AccountType::Mojang;
|
account->data.type = AccountType::Mojang;
|
||||||
account->data.yggdrasilToken.extra["userName"] = username;
|
account->data.yggdrasilToken.extra["userName"] = username;
|
||||||
account->data.yggdrasilToken.extra["clientToken"] = QUuid::createUuid().toString().remove(QRegExp("[{}-]"));
|
account->data.yggdrasilToken.extra["clientToken"] = QUuid::createUuid().toString().remove(QRegularExpression("[{}-]"));
|
||||||
return account;
|
return account;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,10 +97,10 @@ MinecraftAccountPtr MinecraftAccount::createOffline(const QString &username)
|
|||||||
account->data.yggdrasilToken.validity = Katabasis::Validity::Certain;
|
account->data.yggdrasilToken.validity = Katabasis::Validity::Certain;
|
||||||
account->data.yggdrasilToken.issueInstant = QDateTime::currentDateTimeUtc();
|
account->data.yggdrasilToken.issueInstant = QDateTime::currentDateTimeUtc();
|
||||||
account->data.yggdrasilToken.extra["userName"] = username;
|
account->data.yggdrasilToken.extra["userName"] = username;
|
||||||
account->data.yggdrasilToken.extra["clientToken"] = QUuid::createUuid().toString().remove(QRegExp("[{}-]"));
|
account->data.yggdrasilToken.extra["clientToken"] = QUuid::createUuid().toString().remove(QRegularExpression("[{}-]"));
|
||||||
account->data.minecraftEntitlement.ownsMinecraft = true;
|
account->data.minecraftEntitlement.ownsMinecraft = true;
|
||||||
account->data.minecraftEntitlement.canPlayMinecraft = true;
|
account->data.minecraftEntitlement.canPlayMinecraft = true;
|
||||||
account->data.minecraftProfile.id = QUuid::createUuid().toString().remove(QRegExp("[{}-]"));
|
account->data.minecraftProfile.id = QUuid::createUuid().toString().remove(QRegularExpression("[{}-]"));
|
||||||
account->data.minecraftProfile.name = username;
|
account->data.minecraftProfile.name = username;
|
||||||
account->data.minecraftProfile.validity = Katabasis::Validity::Certain;
|
account->data.minecraftProfile.validity = Katabasis::Validity::Certain;
|
||||||
return account;
|
return account;
|
||||||
@ -135,6 +135,7 @@ shared_qobject_ptr<AccountTask> MinecraftAccount::login(QString password) {
|
|||||||
m_currentTask.reset(new MojangLogin(&data, password));
|
m_currentTask.reset(new MojangLogin(&data, password));
|
||||||
connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded()));
|
connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded()));
|
||||||
connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString)));
|
connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString)));
|
||||||
|
connect(m_currentTask.get(), &Task::aborted, this, [this]{ authFailed(tr("Aborted")); });
|
||||||
emit activityChanged(true);
|
emit activityChanged(true);
|
||||||
return m_currentTask;
|
return m_currentTask;
|
||||||
}
|
}
|
||||||
@ -145,6 +146,7 @@ shared_qobject_ptr<AccountTask> MinecraftAccount::loginMSA() {
|
|||||||
m_currentTask.reset(new MSAInteractive(&data));
|
m_currentTask.reset(new MSAInteractive(&data));
|
||||||
connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded()));
|
connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded()));
|
||||||
connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString)));
|
connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString)));
|
||||||
|
connect(m_currentTask.get(), &Task::aborted, this, [this]{ authFailed(tr("Aborted")); });
|
||||||
emit activityChanged(true);
|
emit activityChanged(true);
|
||||||
return m_currentTask;
|
return m_currentTask;
|
||||||
}
|
}
|
||||||
@ -155,6 +157,7 @@ shared_qobject_ptr<AccountTask> MinecraftAccount::loginOffline() {
|
|||||||
m_currentTask.reset(new OfflineLogin(&data));
|
m_currentTask.reset(new OfflineLogin(&data));
|
||||||
connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded()));
|
connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded()));
|
||||||
connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString)));
|
connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString)));
|
||||||
|
connect(m_currentTask.get(), &Task::aborted, this, [this]{ authFailed(tr("Aborted")); });
|
||||||
emit activityChanged(true);
|
emit activityChanged(true);
|
||||||
return m_currentTask;
|
return m_currentTask;
|
||||||
}
|
}
|
||||||
@ -176,6 +179,7 @@ shared_qobject_ptr<AccountTask> MinecraftAccount::refresh() {
|
|||||||
|
|
||||||
connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded()));
|
connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded()));
|
||||||
connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString)));
|
connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString)));
|
||||||
|
connect(m_currentTask.get(), &Task::aborted, this, [this]{ authFailed(tr("Aborted")); });
|
||||||
emit activityChanged(true);
|
emit activityChanged(true);
|
||||||
return m_currentTask;
|
return m_currentTask;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "minecraft/auth/AuthRequest.h"
|
#include "minecraft/auth/AuthRequest.h"
|
||||||
#include "minecraft/auth/Parsers.h"
|
#include "minecraft/auth/Parsers.h"
|
||||||
#include "minecraft/auth/AccountTask.h"
|
#include "minecraft/auth/AccountTask.h"
|
||||||
|
#include "net/NetUtils.h"
|
||||||
|
|
||||||
LauncherLoginStep::LauncherLoginStep(AccountData* data) : AuthStep(data) {
|
LauncherLoginStep::LauncherLoginStep(AccountData* data) : AuthStep(data) {
|
||||||
|
|
||||||
@ -58,10 +59,18 @@ void LauncherLoginStep::onRequestDone(
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
qDebug() << data;
|
qDebug() << data;
|
||||||
#endif
|
#endif
|
||||||
emit finished(
|
if (Net::isApplicationError(error)) {
|
||||||
AccountTaskState::STATE_FAILED_SOFT,
|
emit finished(
|
||||||
tr("Failed to get Minecraft access token: %1").arg(requestor->errorString_)
|
AccountTaskState::STATE_FAILED_SOFT,
|
||||||
);
|
tr("Failed to get Minecraft access token: %1").arg(requestor->errorString_)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
emit finished(
|
||||||
|
AccountTaskState::STATE_OFFLINE,
|
||||||
|
tr("Failed to get Minecraft access token: %1").arg(requestor->errorString_)
|
||||||
|
);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user