mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-30 10:29:59 +03:00
Compare commits
86 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f0725e9edf | ||
|
|
dcb65e8a64 | ||
|
|
9ceee0a6e7 | ||
|
|
d33874f24e | ||
|
|
66f7fb909d | ||
|
|
928adcdb4e | ||
|
|
a4db3bfb88 | ||
|
|
73a68659f2 | ||
|
|
35a99bb5e6 | ||
|
|
5e628d9258 | ||
|
|
29f68ba1cf | ||
|
|
6762a1f448 | ||
|
|
c18128dd9f | ||
|
|
52a42d63ba | ||
|
|
a4e86f213f | ||
|
|
13427d77db | ||
|
|
a26954dafa | ||
|
|
94d18c44f3 | ||
|
|
66452b16f8 | ||
|
|
9c80e019cb | ||
|
|
317b8eea9b | ||
|
|
c968bafb0a | ||
|
|
9b7c83ef23 | ||
|
|
5ee0286635 | ||
|
|
10bee70c42 | ||
|
|
1e07305803 | ||
|
|
8d8e9d0390 | ||
|
|
2128e87d92 | ||
|
|
dbfae0599f | ||
|
|
b2d7211254 | ||
|
|
0631359ec4 | ||
|
|
e81ec9c39c | ||
|
|
b30677ef10 | ||
|
|
75215b0d31 | ||
|
|
bf0aa5f980 | ||
|
|
5520dc6aaf | ||
|
|
6d59334777 | ||
|
|
e90965adc1 | ||
|
|
a524d93ada | ||
|
|
7101f15a2c | ||
|
|
131dc0acf3 | ||
|
|
fd4436880a | ||
|
|
2582a90b90 | ||
|
|
31cf378171 | ||
|
|
4173faba7a | ||
|
|
0b3fb6c4ce | ||
|
|
302e10a7d9 | ||
|
|
947a8faa0d | ||
|
|
ad83592834 | ||
|
|
3f9b6ae452 | ||
|
|
f1e382b035 | ||
|
|
a0797d00e3 | ||
|
|
3d805dff29 | ||
|
|
8f314c982a | ||
|
|
9389b9d582 | ||
|
|
df172c0923 | ||
|
|
47be7ae502 | ||
|
|
e1941a5794 | ||
|
|
f85d399928 | ||
|
|
3fbbebe93b | ||
|
|
1274eb7e48 | ||
|
|
68010c6c49 | ||
|
|
49e9671c96 | ||
|
|
819b4e49c8 | ||
|
|
a74b1dd79d | ||
|
|
add5966c52 | ||
|
|
c89150a26e | ||
|
|
c8c6304a15 | ||
|
|
8bfb9b90c1 | ||
|
|
da62b63f52 | ||
|
|
881bb22d45 | ||
|
|
0776291e55 | ||
|
|
c2d324aff3 | ||
|
|
af83cd92c0 | ||
|
|
a639091a39 | ||
|
|
ab71c44ed6 | ||
|
|
9fef9c7bd8 | ||
|
|
811e3de29b | ||
|
|
1ebe081e03 | ||
|
|
79be92ca74 | ||
|
|
8fcfebb321 | ||
|
|
01bb8c81cf | ||
|
|
708222bb80 | ||
|
|
474be07724 | ||
|
|
6b952403c9 | ||
|
|
7711a9aa81 |
633 changed files with 8477 additions and 18951 deletions
|
|
@ -16,4 +16,3 @@ BraceWrapping:
|
||||||
BreakBeforeBraces: Custom
|
BreakBeforeBraces: Custom
|
||||||
BreakConstructorInitializers: BeforeComma
|
BreakConstructorInitializers: BeforeComma
|
||||||
Cpp11BracedListStyle: false
|
Cpp11BracedListStyle: false
|
||||||
QualifierAlignment: Left
|
|
||||||
|
|
|
||||||
49
.clang-tidy
49
.clang-tidy
|
|
@ -1,32 +1,23 @@
|
||||||
FormatStyle: file
|
|
||||||
|
|
||||||
Checks:
|
Checks:
|
||||||
"bugprone-*,clang-analyzer-*,cppcoreguidelines-*,hicpp-*,misc-*,modernize-*,performance-*,portability-*,readability-*,
|
- modernize-use-using
|
||||||
-*-magic-numbers,
|
- readability-avoid-const-params-in-decls
|
||||||
-*-non-private-member-variables-in-classes,
|
- misc-unused-parameters,
|
||||||
-*-special-member-functions,
|
- readability-identifier-naming
|
||||||
-bugprone-easily-swappable-parameters,
|
|
||||||
-cppcoreguidelines-owning-memory,
|
# ^ Without unused-parameters the readability-identifier-naming check doesn't cause any warnings.
|
||||||
-cppcoreguidelines-pro-type-static-cast-downcast,
|
|
||||||
-modernize-use-nodiscard,
|
|
||||||
-modernize-use-trailing-return-type,
|
|
||||||
-portability-avoid-pragma-once,
|
|
||||||
-readability-avoid-unconditional-preprocessor-if,
|
|
||||||
-readability-function-cognitive-complexity,
|
|
||||||
-readability-identifier-length,
|
|
||||||
-readability-redundant-access-specifiers"
|
|
||||||
|
|
||||||
CheckOptions:
|
CheckOptions:
|
||||||
misc-include-cleaner.MissingIncludes: false
|
- { key: readability-identifier-naming.ClassCase, value: PascalCase }
|
||||||
readability-identifier-naming.DefaultCase: "camelBack"
|
- { key: readability-identifier-naming.EnumCase, value: PascalCase }
|
||||||
readability-identifier-naming.NamespaceCase: "CamelCase"
|
- { key: readability-identifier-naming.FunctionCase, value: camelCase }
|
||||||
readability-identifier-naming.ClassCase: "CamelCase"
|
- { key: readability-identifier-naming.GlobalVariableCase, value: camelCase }
|
||||||
readability-identifier-naming.ClassConstantCase: "CamelCase"
|
- { key: readability-identifier-naming.GlobalFunctionCase, value: camelCase }
|
||||||
readability-identifier-naming.EnumCase: "CamelCase"
|
- { key: readability-identifier-naming.GlobalConstantCase, value: SCREAMING_SNAKE_CASE }
|
||||||
readability-identifier-naming.EnumConstantCase: "CamelCase"
|
- { key: readability-identifier-naming.MacroDefinitionCase, value: SCREAMING_SNAKE_CASE }
|
||||||
readability-identifier-naming.MacroDefinitionCase: "UPPER_CASE"
|
- { key: readability-identifier-naming.ClassMemberCase, value: camelCase }
|
||||||
readability-identifier-naming.ClassMemberPrefix: "m_"
|
- { key: readability-identifier-naming.PrivateMemberPrefix, value: m_ }
|
||||||
readability-identifier-naming.StaticConstantPrefix: "s_"
|
- { key: readability-identifier-naming.ProtectedMemberPrefix, value: m_ }
|
||||||
readability-identifier-naming.StaticVariablePrefix: "s_"
|
- { key: readability-identifier-naming.PrivateStaticMemberPrefix, value: s_ }
|
||||||
readability-identifier-naming.GlobalConstantPrefix: "g_"
|
- { key: readability-identifier-naming.ProtectedStaticMemberPrefix, value: s_ }
|
||||||
readability-implicit-bool-conversion.AllowPointerConditions: true
|
- { key: readability-identifier-naming.PublicStaticConstantCase, value: SCREAMING_SNAKE_CASE }
|
||||||
|
- { key: readability-identifier-naming.EnumConstantCase, value: SCREAMING_SNAKE_CASE }
|
||||||
6
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
6
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
|
|
@ -1,6 +1,6 @@
|
||||||
name: Bug Report
|
name: Bug Report
|
||||||
description: File a bug report
|
description: File a bug report
|
||||||
labels: ["bug: unconfirmed", "status: needs triage"]
|
labels: [bug]
|
||||||
body:
|
body:
|
||||||
- type: markdown
|
- type: markdown
|
||||||
attributes:
|
attributes:
|
||||||
|
|
@ -23,14 +23,14 @@ body:
|
||||||
- macOS
|
- macOS
|
||||||
- Linux
|
- Linux
|
||||||
- Other
|
- Other
|
||||||
- type: input
|
- type: textarea
|
||||||
attributes:
|
attributes:
|
||||||
label: Version of Prism Launcher
|
label: Version of Prism Launcher
|
||||||
description: The version of Prism Launcher used in the bug report.
|
description: The version of Prism Launcher used in the bug report.
|
||||||
placeholder: Prism Launcher 5.0
|
placeholder: Prism Launcher 5.0
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: input
|
- type: textarea
|
||||||
attributes:
|
attributes:
|
||||||
label: Version of Qt
|
label: Version of Qt
|
||||||
description: The version of Qt used in the bug report. You can find it in Help -> About Prism Launcher -> About Qt.
|
description: The version of Qt used in the bug report. You can find it in Help -> About Prism Launcher -> About Qt.
|
||||||
|
|
|
||||||
2
.github/ISSUE_TEMPLATE/rfc.yml
vendored
2
.github/ISSUE_TEMPLATE/rfc.yml
vendored
|
|
@ -1,7 +1,7 @@
|
||||||
# Template based on https://gitlab.archlinux.org/archlinux/rfcs/-/blob/0ba3b61e987e197f8d1901709409b8564958f78a/rfcs/0000-template.rst
|
# Template based on https://gitlab.archlinux.org/archlinux/rfcs/-/blob/0ba3b61e987e197f8d1901709409b8564958f78a/rfcs/0000-template.rst
|
||||||
name: Request for Comment (RFC)
|
name: Request for Comment (RFC)
|
||||||
description: Propose a larger change and start a discussion.
|
description: Propose a larger change and start a discussion.
|
||||||
labels: ["type: enhancement", "status: needs discussion", "status: needs triage"]
|
labels: [rfc]
|
||||||
body:
|
body:
|
||||||
- type: markdown
|
- type: markdown
|
||||||
attributes:
|
attributes:
|
||||||
|
|
|
||||||
2
.github/ISSUE_TEMPLATE/suggestion.yml
vendored
2
.github/ISSUE_TEMPLATE/suggestion.yml
vendored
|
|
@ -1,6 +1,6 @@
|
||||||
name: Suggestion
|
name: Suggestion
|
||||||
description: Make a suggestion
|
description: Make a suggestion
|
||||||
labels: ["type: enhancement", "status: needs triage"]
|
labels: [enhancement]
|
||||||
body:
|
body:
|
||||||
- type: markdown
|
- type: markdown
|
||||||
attributes:
|
attributes:
|
||||||
|
|
|
||||||
40
.github/actions/package/linux/action.yml
vendored
40
.github/actions/package/linux/action.yml
vendored
|
|
@ -27,18 +27,6 @@ runs:
|
||||||
using: composite
|
using: composite
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Cleanup Qt installation on Linux
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
rm -rf "$QT_PLUGIN_PATH"/printsupport
|
|
||||||
rm -rf "$QT_PLUGIN_PATH"/sqldrivers
|
|
||||||
rm -rf "$QT_PLUGIN_PATH"/help
|
|
||||||
rm -rf "$QT_PLUGIN_PATH"/designer
|
|
||||||
rm -rf "$QT_PLUGIN_PATH"/qmltooling
|
|
||||||
rm -rf "$QT_PLUGIN_PATH"/qmlls
|
|
||||||
rm -rf "$QT_PLUGIN_PATH"/qmllint
|
|
||||||
rm -rf "$QT_PLUGIN_PATH"/platformthemes/libqgtk3.so
|
|
||||||
|
|
||||||
- name: Setup build variables
|
- name: Setup build variables
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -64,7 +52,7 @@ runs:
|
||||||
- name: Package AppImage
|
- name: Package AppImage
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
VERSION: ${{ github.ref_type == 'tag' && github.ref_name || inputs.version }}
|
VERSION: ${{ inputs.version }}
|
||||||
BUILD_DIR: build
|
BUILD_DIR: build
|
||||||
INSTALL_APPIMAGE_DIR: install-appdir
|
INSTALL_APPIMAGE_DIR: install-appdir
|
||||||
|
|
||||||
|
|
@ -75,7 +63,7 @@ runs:
|
||||||
if [ '${{ inputs.gpg-private-key-id }}' != '' ]; then
|
if [ '${{ inputs.gpg-private-key-id }}' != '' ]; then
|
||||||
echo "$GPG_PRIVATE_KEY" > privkey.asc
|
echo "$GPG_PRIVATE_KEY" > privkey.asc
|
||||||
gpg --import privkey.asc
|
gpg --import privkey.asc
|
||||||
gpg --export --armor ${{ inputs.gpg-private-key-id }} > pubkey.asc
|
gpg --export --armor 9C7A2C9B62603299 > pubkey.asc
|
||||||
else
|
else
|
||||||
echo ":warning: Skipped code signing for Linux AppImage, as gpg key was not present." >> $GITHUB_STEP_SUMMARY
|
echo ":warning: Skipped code signing for Linux AppImage, as gpg key was not present." >> $GITHUB_STEP_SUMMARY
|
||||||
fi
|
fi
|
||||||
|
|
@ -90,26 +78,16 @@ runs:
|
||||||
# FIXME(@getchoo): gamemode doesn't seem to be very portable with DBus. Find a way to make it work!
|
# FIXME(@getchoo): gamemode doesn't seem to be very portable with DBus. Find a way to make it work!
|
||||||
find "$INSTALL_APPIMAGE_DIR" -name '*gamemode*' -exec rm {} +
|
find "$INSTALL_APPIMAGE_DIR" -name '*gamemode*' -exec rm {} +
|
||||||
|
|
||||||
#disable OpenGL and Vulkan launcher features until https://github.com/VHSgunzo/sharun/issues/35
|
|
||||||
echo "PRISMLAUNCHER_DISABLE_GLVULKAN=1" >> "$INSTALL_APPIMAGE_DIR"/.env
|
|
||||||
#makes the launcher use portals for file picking
|
|
||||||
echo "QT_QPA_PLATFORMTHEME=xdgdesktopportal" >> "$INSTALL_APPIMAGE_DIR"/.env
|
|
||||||
ln -s org.prismlauncher.PrismLauncher.metainfo.xml "$INSTALL_APPIMAGE_DIR"/share/metainfo/org.prismlauncher.PrismLauncher.appdata.xml
|
ln -s org.prismlauncher.PrismLauncher.metainfo.xml "$INSTALL_APPIMAGE_DIR"/share/metainfo/org.prismlauncher.PrismLauncher.appdata.xml
|
||||||
ln -s share/applications/org.prismlauncher.PrismLauncher.desktop "$INSTALL_APPIMAGE_DIR"
|
ln -s share/applications/org.prismlauncher.PrismLauncher.desktop "$INSTALL_APPIMAGE_DIR"
|
||||||
ln -s share/icons/hicolor/256x256/apps/org.prismlauncher.PrismLauncher.png "$INSTALL_APPIMAGE_DIR"
|
ln -s share/icons/hicolor/256x256/apps/org.prismlauncher.PrismLauncher.png "$INSTALL_APPIMAGE_DIR"
|
||||||
mv "$INSTALL_APPIMAGE_DIR"/{sharun,AppRun}
|
mv "$INSTALL_APPIMAGE_DIR"/{sharun,AppRun}
|
||||||
ls -la "$INSTALL_APPIMAGE_DIR"
|
ls -la "$INSTALL_APPIMAGE_DIR"
|
||||||
|
|
||||||
if [[ "${{ github.ref_type }}" == "tag" ]]; then
|
|
||||||
APPIMAGE_DEST="PrismLauncher-Linux-$APPIMAGE_ARCH.AppImage"
|
|
||||||
else
|
|
||||||
APPIMAGE_DEST="PrismLauncher-Linux-$VERSION-${{ inputs.build-type }}-$APPIMAGE_ARCH.AppImage"
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkappimage \
|
mkappimage \
|
||||||
--updateinformation "gh-releases-zsync|${{ github.repository_owner }}|${{ github.event.repository.name }}|latest|PrismLauncher-Linux-$APPIMAGE_ARCH.AppImage.zsync" \
|
--updateinformation "gh-releases-zsync|${{ github.repository_owner }}|${{ github.event.repository.name }}|latest|PrismLauncher-Linux-$APPIMAGE_ARCH.AppImage.zsync" \
|
||||||
"$INSTALL_APPIMAGE_DIR" \
|
"$INSTALL_APPIMAGE_DIR" \
|
||||||
"$APPIMAGE_DEST"
|
"PrismLauncher-Linux-$VERSION-${{ inputs.build-type }}-$APPIMAGE_ARCH.AppImage"
|
||||||
|
|
||||||
- name: Package portable tarball
|
- name: Package portable tarball
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
@ -130,24 +108,24 @@ runs:
|
||||||
# FIXME(@getchoo): gamemode doesn't seem to be very portable with DBus. Find a way to make it work!
|
# FIXME(@getchoo): gamemode doesn't seem to be very portable with DBus. Find a way to make it work!
|
||||||
find "$INSTALL_PORTABLE_DIR" -name '*gamemode*' -exec rm {} +
|
find "$INSTALL_PORTABLE_DIR" -name '*gamemode*' -exec rm {} +
|
||||||
|
|
||||||
for l in $(find ${{ env.INSTALL_PORTABLE_DIR }} -type f -o -type l); do l=${l#$(pwd)/}; l=${l#${{ env.INSTALL_PORTABLE_DIR }}/}; l=${l#./}; echo $l; done > ${{ env.INSTALL_PORTABLE_DIR }}/manifest.txt
|
for l in $(find ${{ env.INSTALL_PORTABLE_DIR }} -type f); do l=${l#$(pwd)/}; l=${l#${{ env.INSTALL_PORTABLE_DIR }}/}; l=${l#./}; echo $l; done > ${{ env.INSTALL_PORTABLE_DIR }}/manifest.txt
|
||||||
cd ${{ env.INSTALL_PORTABLE_DIR }}
|
cd ${{ env.INSTALL_PORTABLE_DIR }}
|
||||||
tar -czf ../PrismLauncher-portable.tar.gz *
|
tar -czf ../PrismLauncher-portable.tar.gz *
|
||||||
|
|
||||||
- name: Upload binary tarball
|
- name: Upload binary tarball
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: PrismLauncher-${{ inputs.artifact-name }}-Qt6-Portable-${{ inputs.version }}-${{ inputs.build-type }}
|
name: PrismLauncher-${{ inputs.artifact-name }}-Qt6-Portable-${{ inputs.version }}-${{ inputs.build-type }}
|
||||||
path: PrismLauncher-portable.tar.gz
|
path: PrismLauncher-portable.tar.gz
|
||||||
|
|
||||||
- name: Upload AppImage
|
- name: Upload AppImage
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: PrismLauncher-${{ runner.os }}-${{ inputs.version }}-${{ inputs.build-type }}-${{ env.APPIMAGE_ARCH }}.AppImage
|
name: PrismLauncher-${{ runner.os }}-${{ inputs.version }}-${{ inputs.build-type }}-${{ env.APPIMAGE_ARCH }}.AppImage
|
||||||
path: PrismLauncher-${{ runner.os }}-*${{ env.APPIMAGE_ARCH }}.AppImage
|
path: PrismLauncher-${{ runner.os }}-${{ inputs.version }}-${{ inputs.build-type }}-${{ env.APPIMAGE_ARCH }}.AppImage
|
||||||
|
|
||||||
- name: Upload AppImage Zsync
|
- name: Upload AppImage Zsync
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: PrismLauncher-${{ runner.os }}-${{ inputs.version }}-${{ inputs.build-type }}-${{ env.APPIMAGE_ARCH }}.AppImage.zsync
|
name: PrismLauncher-${{ runner.os }}-${{ inputs.version }}-${{ inputs.build-type }}-${{ env.APPIMAGE_ARCH }}.AppImage.zsync
|
||||||
path: PrismLauncher-${{ runner.os }}-*${{ env.APPIMAGE_ARCH }}.AppImage.zsync
|
path: PrismLauncher-${{ runner.os }}-${{ inputs.version }}-${{ inputs.build-type }}-${{ env.APPIMAGE_ARCH }}.AppImage.zsync
|
||||||
|
|
|
||||||
32
.github/actions/package/macos/action.yml
vendored
32
.github/actions/package/macos/action.yml
vendored
|
|
@ -96,36 +96,16 @@ runs:
|
||||||
fi
|
fi
|
||||||
ditto -c -k --sequesterRsrc --keepParent "Prism Launcher.app" ../PrismLauncher.zip
|
ditto -c -k --sequesterRsrc --keepParent "Prism Launcher.app" ../PrismLauncher.zip
|
||||||
|
|
||||||
- name: Create DMG
|
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
INSTALL_DIR: install
|
|
||||||
run: |
|
|
||||||
cd ${{ env.INSTALL_DIR }}
|
|
||||||
|
|
||||||
mkdir -p src
|
|
||||||
cp -R "Prism Launcher.app" src/
|
|
||||||
|
|
||||||
ln -s /Applications src/
|
|
||||||
|
|
||||||
hdiutil create \
|
|
||||||
-volname "Prism Launcher ${{ inputs.version }}" \
|
|
||||||
-srcfolder src \
|
|
||||||
-ov -format ULMO \
|
|
||||||
"../PrismLauncher.dmg"
|
|
||||||
|
|
||||||
- name: Make Sparkle signature
|
- name: Make Sparkle signature
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
if [ '${{ inputs.sparkle-ed25519-key }}' != '' ]; then
|
if [ '${{ inputs.sparkle-ed25519-key }}' != '' ]; then
|
||||||
echo '${{ inputs.sparkle-ed25519-key }}' > ed25519-priv.pem
|
echo '${{ inputs.sparkle-ed25519-key }}' > ed25519-priv.pem
|
||||||
signature_zip=$(/opt/homebrew/opt/openssl@3/bin/openssl pkeyutl -sign -rawin -in ${{ github.workspace }}/PrismLauncher.zip -inkey ed25519-priv.pem | openssl base64 | tr -d \\n)
|
signature=$(/opt/homebrew/opt/openssl@3/bin/openssl pkeyutl -sign -rawin -in ${{ github.workspace }}/PrismLauncher.zip -inkey ed25519-priv.pem | openssl base64 | tr -d \\n)
|
||||||
signature_dmg=$(/opt/homebrew/opt/openssl@3/bin/openssl pkeyutl -sign -rawin -in ${{ github.workspace }}/PrismLauncher.dmg -inkey ed25519-priv.pem | openssl base64 | tr -d \\n)
|
|
||||||
rm ed25519-priv.pem
|
rm ed25519-priv.pem
|
||||||
cat >> $GITHUB_STEP_SUMMARY << EOF
|
cat >> $GITHUB_STEP_SUMMARY << EOF
|
||||||
### Artifact Information :information_source:
|
### Artifact Information :information_source:
|
||||||
- :memo: Sparkle Signature (ed25519): \`$signature_zip\` (ZIP)
|
- :memo: Sparkle Signature (ed25519): \`$signature\`
|
||||||
- :memo: Sparkle Signature (ed25519): \`$signature_dmg\` (DMG)
|
|
||||||
EOF
|
EOF
|
||||||
else
|
else
|
||||||
cat >> $GITHUB_STEP_SUMMARY << EOF
|
cat >> $GITHUB_STEP_SUMMARY << EOF
|
||||||
|
|
@ -135,13 +115,7 @@ runs:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Upload binary tarball
|
- name: Upload binary tarball
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: PrismLauncher-${{ inputs.artifact-name }}-${{ inputs.version }}-${{ inputs.build-type }}
|
name: PrismLauncher-${{ inputs.artifact-name }}-${{ inputs.version }}-${{ inputs.build-type }}
|
||||||
path: PrismLauncher.zip
|
path: PrismLauncher.zip
|
||||||
|
|
||||||
- name: Upload disk image
|
|
||||||
uses: actions/upload-artifact@v7
|
|
||||||
with:
|
|
||||||
name: PrismLauncher-${{ inputs.artifact-name }}-${{ inputs.version }}-${{ inputs.build-type }}.dmg
|
|
||||||
path: PrismLauncher.dmg
|
|
||||||
|
|
|
||||||
28
.github/actions/package/windows/action.yml
vendored
28
.github/actions/package/windows/action.yml
vendored
|
|
@ -61,7 +61,7 @@ runs:
|
||||||
|
|
||||||
- name: Login to Azure
|
- name: Login to Azure
|
||||||
if: ${{ env.CI_HAS_ACCESS_TO_AZURE != '' && inputs.azure-client-id != '' }}
|
if: ${{ env.CI_HAS_ACCESS_TO_AZURE != '' && inputs.azure-client-id != '' }}
|
||||||
uses: azure/login@v3
|
uses: azure/login@v2
|
||||||
with:
|
with:
|
||||||
client-id: ${{ inputs.azure-client-id }}
|
client-id: ${{ inputs.azure-client-id }}
|
||||||
tenant-id: ${{ inputs.azure-tenant-id }}
|
tenant-id: ${{ inputs.azure-tenant-id }}
|
||||||
|
|
@ -69,18 +69,17 @@ runs:
|
||||||
|
|
||||||
- name: Sign executables
|
- name: Sign executables
|
||||||
if: ${{ env.CI_HAS_ACCESS_TO_AZURE != '' && inputs.azure-client-id != '' }}
|
if: ${{ env.CI_HAS_ACCESS_TO_AZURE != '' && inputs.azure-client-id != '' }}
|
||||||
uses: azure/artifact-signing-action@v2
|
uses: azure/trusted-signing-action@v0
|
||||||
with:
|
with:
|
||||||
endpoint: https://eus.codesigning.azure.net/
|
endpoint: https://eus.codesigning.azure.net/
|
||||||
trusted-signing-account-name: PrismLauncher
|
trusted-signing-account-name: PrismLauncher
|
||||||
certificate-profile-name: PrismLauncher
|
certificate-profile-name: PrismLauncher
|
||||||
files-folder: ${{ github.workspace }}\install\
|
|
||||||
files-folder-filter: dll,exe
|
files: |
|
||||||
files-folder-recurse: true
|
${{ github.workspace }}\install\prismlauncher.exe
|
||||||
files-folder-depth: 2
|
${{ github.workspace }}\install\prismlauncher_filelink.exe
|
||||||
# recommended in https://github.com/Azure/artifact-signing-action#timestamping-1
|
${{ github.workspace }}\install\prismlauncher_updater.exe
|
||||||
timestamp-rfc3161: 'http://timestamp.acs.microsoft.com'
|
|
||||||
timestamp-digest: 'SHA256'
|
|
||||||
# TODO(@getchoo): Is this all really needed???
|
# TODO(@getchoo): Is this all really needed???
|
||||||
# https://github.com/Azure/trusted-signing-action/blob/fc390cf8ed0f14e248a542af1d838388a47c7a7c/docs/OIDC.md
|
# https://github.com/Azure/trusted-signing-action/blob/fc390cf8ed0f14e248a542af1d838388a47c7a7c/docs/OIDC.md
|
||||||
exclude-environment-credential: true
|
exclude-environment-credential: true
|
||||||
|
|
@ -142,7 +141,7 @@ runs:
|
||||||
|
|
||||||
- name: Sign installer
|
- name: Sign installer
|
||||||
if: ${{ env.CI_HAS_ACCESS_TO_AZURE != '' && inputs.azure-client-id != '' }}
|
if: ${{ env.CI_HAS_ACCESS_TO_AZURE != '' && inputs.azure-client-id != '' }}
|
||||||
uses: azure/artifact-signing-action@v2
|
uses: azure/trusted-signing-action@v0
|
||||||
with:
|
with:
|
||||||
endpoint: https://eus.codesigning.azure.net/
|
endpoint: https://eus.codesigning.azure.net/
|
||||||
trusted-signing-account-name: PrismLauncher
|
trusted-signing-account-name: PrismLauncher
|
||||||
|
|
@ -151,9 +150,6 @@ runs:
|
||||||
files: |
|
files: |
|
||||||
${{ github.workspace }}\PrismLauncher-Setup.exe
|
${{ github.workspace }}\PrismLauncher-Setup.exe
|
||||||
|
|
||||||
# recommended in https://github.com/Azure/artifact-signing-action#timestamping-1
|
|
||||||
timestamp-rfc3161: 'http://timestamp.acs.microsoft.com'
|
|
||||||
timestamp-digest: 'SHA256'
|
|
||||||
# TODO(@getchoo): Is this all really needed???
|
# TODO(@getchoo): Is this all really needed???
|
||||||
# https://github.com/Azure/trusted-signing-action/blob/fc390cf8ed0f14e248a542af1d838388a47c7a7c/docs/OIDC.md
|
# https://github.com/Azure/trusted-signing-action/blob/fc390cf8ed0f14e248a542af1d838388a47c7a7c/docs/OIDC.md
|
||||||
exclude-environment-credential: true
|
exclude-environment-credential: true
|
||||||
|
|
@ -168,19 +164,19 @@ runs:
|
||||||
exclude-interactive-browser-credential: true
|
exclude-interactive-browser-credential: true
|
||||||
|
|
||||||
- name: Upload binary zip
|
- name: Upload binary zip
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: PrismLauncher-${{ inputs.artifact-name }}-${{ inputs.version }}-${{ inputs.build-type }}
|
name: PrismLauncher-${{ inputs.artifact-name }}-${{ inputs.version }}-${{ inputs.build-type }}
|
||||||
path: install/**
|
path: install/**
|
||||||
|
|
||||||
- name: Upload portable zip
|
- name: Upload portable zip
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: PrismLauncher-${{ inputs.artifact-name }}-Portable-${{ inputs.version }}-${{ inputs.build-type }}
|
name: PrismLauncher-${{ inputs.artifact-name }}-Portable-${{ inputs.version }}-${{ inputs.build-type }}
|
||||||
path: install-portable/**
|
path: install-portable/**
|
||||||
|
|
||||||
- name: Upload installer
|
- name: Upload installer
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: PrismLauncher-${{ inputs.artifact-name }}-Setup-${{ inputs.version }}-${{ inputs.build-type }}
|
name: PrismLauncher-${{ inputs.artifact-name }}-Setup-${{ inputs.version }}-${{ inputs.build-type }}
|
||||||
path: PrismLauncher-Setup.exe
|
path: PrismLauncher-Setup.exe
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ runs:
|
||||||
# TODO(@getchoo): Get this working on MSYS2!
|
# TODO(@getchoo): Get this working on MSYS2!
|
||||||
- name: Setup ccache
|
- name: Setup ccache
|
||||||
if: ${{ (runner.os != 'Windows' || inputs.msystem == '') && inputs.build-type == 'Debug' }}
|
if: ${{ (runner.os != 'Windows' || inputs.msystem == '') && inputs.build-type == 'Debug' }}
|
||||||
uses: hendrikmuhs/ccache-action@v1.2.23
|
uses: hendrikmuhs/ccache-action@v1.2.20
|
||||||
with:
|
with:
|
||||||
variant: sccache
|
variant: sccache
|
||||||
create-symlink: ${{ runner.os != 'Windows' }}
|
create-symlink: ${{ runner.os != 'Windows' }}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
name: Setup Linux dependencies
|
name: Setup Linux dependencies
|
||||||
description: Install and setup dependencies for building Prism Launcher
|
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
|
|
|
||||||
|
|
@ -44,4 +44,4 @@ runs:
|
||||||
- name: Setup vcpkg environment
|
- name: Setup vcpkg environment
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
echo "VCPKG_ROOT=$VCPKG_INSTALLATION_ROOT" >> "$GITHUB_ENV"
|
echo "CMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" >> "$GITHUB_ENV"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
name: Setup Windows Dependencies
|
name: Setup Windows Dependencies
|
||||||
description: Install and setup dependencies for building Prism Launcher
|
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
build-type:
|
build-type:
|
||||||
|
|
@ -58,7 +57,7 @@ runs:
|
||||||
if: ${{ inputs.msystem == '' }}
|
if: ${{ inputs.msystem == '' }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
echo "VCPKG_ROOT=$VCPKG_INSTALLATION_ROOT" >> "$GITHUB_ENV"
|
echo "CMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
- name: Setup MSYS2 (MinGW)
|
- name: Setup MSYS2 (MinGW)
|
||||||
if: ${{ inputs.msystem != '' }}
|
if: ${{ inputs.msystem != '' }}
|
||||||
|
|
@ -91,7 +90,7 @@ runs:
|
||||||
|
|
||||||
- name: Retrieve ccache cache (MinGW)
|
- name: Retrieve ccache cache (MinGW)
|
||||||
if: ${{ inputs.msystem != '' && inputs.build-type == 'Debug' }}
|
if: ${{ inputs.msystem != '' && inputs.build-type == 'Debug' }}
|
||||||
uses: actions/cache@v5.0.5
|
uses: actions/cache@v5.0.1
|
||||||
with:
|
with:
|
||||||
path: '${{ github.workspace }}\.ccache'
|
path: '${{ github.workspace }}\.ccache'
|
||||||
key: ${{ runner.os }}-mingw-w64-ccache-${{ github.run_id }}
|
key: ${{ runner.os }}-mingw-w64-ccache-${{ github.run_id }}
|
||||||
|
|
|
||||||
7
.github/workflows/backport.yml
vendored
7
.github/workflows/backport.yml
vendored
|
|
@ -8,7 +8,8 @@ on:
|
||||||
# the GitHub repository. This means that it should not evaluate user input in a
|
# the GitHub repository. This means that it should not evaluate user input in a
|
||||||
# way that allows code injection.
|
# way that allows code injection.
|
||||||
|
|
||||||
permissions: {}
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
backport:
|
backport:
|
||||||
|
|
@ -18,13 +19,13 @@ jobs:
|
||||||
actions: write # for korthout/backport-action to create PR with workflow changes
|
actions: write # for korthout/backport-action to create PR with workflow changes
|
||||||
name: Backport Pull Request
|
name: Backport Pull Request
|
||||||
if: github.repository_owner == 'PrismLauncher' && github.event.pull_request.merged == true && (github.event_name != 'labeled' || startsWith('backport', github.event.label.name))
|
if: github.repository_owner == 'PrismLauncher' && github.event.pull_request.merged == true && (github.event_name != 'labeled' || startsWith('backport', github.event.label.name))
|
||||||
runs-on: ubuntu-slim
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
- name: Create backport PRs
|
- name: Create backport PRs
|
||||||
uses: korthout/backport-action@v4.5
|
uses: korthout/backport-action@v4.0.0
|
||||||
with:
|
with:
|
||||||
# Config README: https://github.com/korthout/backport-action#backport-action
|
# Config README: https://github.com/korthout/backport-action#backport-action
|
||||||
pull_description: |-
|
pull_description: |-
|
||||||
|
|
|
||||||
18
.github/workflows/blocked-prs.yml
vendored
18
.github/workflows/blocked-prs.yml
vendored
|
|
@ -14,17 +14,15 @@ on:
|
||||||
required: true
|
required: true
|
||||||
type: number
|
type: number
|
||||||
|
|
||||||
permissions: {}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
blocked_status:
|
blocked_status:
|
||||||
name: Check Blocked Status
|
name: Check Blocked Status
|
||||||
runs-on: ubuntu-slim
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Generate token
|
- name: Generate token
|
||||||
id: generate-token
|
id: generate-token
|
||||||
uses: actions/create-github-app-token@v3
|
uses: actions/create-github-app-token@v2
|
||||||
with:
|
with:
|
||||||
app-id: ${{ vars.PULL_REQUEST_APP_ID }}
|
app-id: ${{ vars.PULL_REQUEST_APP_ID }}
|
||||||
private-key: ${{ secrets.PULL_REQUEST_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.PULL_REQUEST_APP_PRIVATE_KEY }}
|
||||||
|
|
@ -82,7 +80,7 @@ jobs:
|
||||||
| (
|
| (
|
||||||
$body |
|
$body |
|
||||||
reduce (
|
reduce (
|
||||||
. | scan("[Bb]locked (?:[Bb]y|[Oo]n):? #([0-9]+)")
|
. | scan("blocked (?:by|on):? #([0-9]+)")
|
||||||
| map({
|
| map({
|
||||||
"type": "Blocked on",
|
"type": "Blocked on",
|
||||||
"number": ( . | tonumber )
|
"number": ( . | tonumber )
|
||||||
|
|
@ -92,7 +90,7 @@ jobs:
|
||||||
| (
|
| (
|
||||||
$body |
|
$body |
|
||||||
reduce (
|
reduce (
|
||||||
. | scan("[Ss]tacked [Oo]n:? #([0-9]+)")
|
. | scan("stacked on:? #([0-9]+)")
|
||||||
| map({
|
| map({
|
||||||
"type": "Stacked on",
|
"type": "Stacked on",
|
||||||
"number": ( . | tonumber )
|
"number": ( . | tonumber )
|
||||||
|
|
@ -152,12 +150,12 @@ jobs:
|
||||||
|
|
||||||
- name: Add 'blocked' Label if Missing
|
- name: Add 'blocked' Label if Missing
|
||||||
id: label_blocked
|
id: label_blocked
|
||||||
if: "(fromJSON(steps.pr_ids.outputs.prs).numBlocking > 0) && !contains(fromJSON(env.JOB_DATA).prLabels, 'status: blocked') && !fromJSON(steps.blocking_data.outputs.all_merged)"
|
if: (fromJSON(steps.pr_ids.outputs.prs).numBlocking > 0) && !contains(fromJSON(env.JOB_DATA).prLabels, 'blocked') && !fromJSON(steps.blocking_data.outputs.all_merged)
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
||||||
run: |
|
run: |
|
||||||
gh -R ${{ github.repository }} issue edit --add-label 'status: blocked' "$PR_NUMBER"
|
gh -R ${{ github.repository }} issue edit --add-label 'blocked' "$PR_NUMBER"
|
||||||
|
|
||||||
- name: Remove 'blocked' Label if All Dependencies Are Merged
|
- name: Remove 'blocked' Label if All Dependencies Are Merged
|
||||||
id: unlabel_blocked
|
id: unlabel_blocked
|
||||||
|
|
@ -166,7 +164,7 @@ jobs:
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
||||||
run: |
|
run: |
|
||||||
gh -R ${{ github.repository }} issue edit --remove-label 'status: blocked' "$PR_NUMBER"
|
gh -R ${{ github.repository }} issue edit --remove-label 'blocked' "$PR_NUMBER"
|
||||||
|
|
||||||
- name: Apply 'blocking' Label to Unmerged Dependencies
|
- name: Apply 'blocking' Label to Unmerged Dependencies
|
||||||
id: label_blocking
|
id: label_blocking
|
||||||
|
|
@ -177,7 +175,7 @@ jobs:
|
||||||
BLOCKING_ISSUES: ${{ steps.blocking_data.outputs.current_blocking }}
|
BLOCKING_ISSUES: ${{ steps.blocking_data.outputs.current_blocking }}
|
||||||
run: |
|
run: |
|
||||||
while read -r pr ; do
|
while read -r pr ; do
|
||||||
gh -R ${{ github.repository }} issue edit --add-label 'status: blocking' "$pr" || true
|
gh -R ${{ github.repository }} issue edit --add-label 'blocking' "$pr" || true
|
||||||
done < <(jq -c '.[]' <<< "$BLOCKING_ISSUES")
|
done < <(jq -c '.[]' <<< "$BLOCKING_ISSUES")
|
||||||
|
|
||||||
- name: Apply Blocking PR Status Check
|
- name: Apply Blocking PR Status Check
|
||||||
|
|
|
||||||
63
.github/workflows/build.yml
vendored
63
.github/workflows/build.yml
vendored
|
|
@ -5,9 +5,57 @@ concurrency:
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
on:
|
on:
|
||||||
merge_group:
|
push:
|
||||||
types: [checks_requested]
|
branches:
|
||||||
|
- "develop"
|
||||||
|
- "release-*"
|
||||||
|
paths:
|
||||||
|
# File types
|
||||||
|
- "**.cpp"
|
||||||
|
- "**.h"
|
||||||
|
- "**.java"
|
||||||
|
- "**.ui"
|
||||||
|
|
||||||
|
# Directories
|
||||||
|
- "buildconfig/**"
|
||||||
|
- "cmake/**"
|
||||||
|
- "launcher/**"
|
||||||
|
- "libraries/**"
|
||||||
|
- "program_info/**"
|
||||||
|
- "tests/**"
|
||||||
|
|
||||||
|
# Files
|
||||||
|
- "CMakeLists.txt"
|
||||||
|
- "COPYING.md"
|
||||||
|
|
||||||
|
# Workflows
|
||||||
|
- ".github/workflows/build.yml"
|
||||||
|
- ".github/actions/package/**"
|
||||||
|
- ".github/actions/setup-dependencies/**"
|
||||||
pull_request:
|
pull_request:
|
||||||
|
paths:
|
||||||
|
# File types
|
||||||
|
- "**.cpp"
|
||||||
|
- "**.h"
|
||||||
|
- "**.java"
|
||||||
|
- "**.ui"
|
||||||
|
|
||||||
|
# Directories
|
||||||
|
- "buildconfig/**"
|
||||||
|
- "cmake/**"
|
||||||
|
- "launcher/**"
|
||||||
|
- "libraries/**"
|
||||||
|
- "program_info/**"
|
||||||
|
- "tests/**"
|
||||||
|
|
||||||
|
# Files
|
||||||
|
- "CMakeLists.txt"
|
||||||
|
- "COPYING.md"
|
||||||
|
|
||||||
|
# Workflows
|
||||||
|
- ".github/workflows/build.yml"
|
||||||
|
- ".github/actions/package/**"
|
||||||
|
- ".github/actions/setup-dependencies/**"
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
build-type:
|
build-type:
|
||||||
|
|
@ -24,8 +72,6 @@ on:
|
||||||
type: string
|
type: string
|
||||||
default: Debug
|
default: Debug
|
||||||
|
|
||||||
permissions: {}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build (${{ matrix.artifact-name }})
|
name: Build (${{ matrix.artifact-name }})
|
||||||
|
|
@ -33,7 +79,6 @@ jobs:
|
||||||
environment: ${{ inputs.environment || '' }}
|
environment: ${{ inputs.environment || '' }}
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
|
||||||
# Required for Azure Trusted Signing
|
# Required for Azure Trusted Signing
|
||||||
id-token: write
|
id-token: write
|
||||||
# Required for vcpkg binary cache
|
# Required for vcpkg binary cache
|
||||||
|
|
@ -46,12 +91,12 @@ jobs:
|
||||||
- os: ubuntu-24.04
|
- os: ubuntu-24.04
|
||||||
artifact-name: Linux
|
artifact-name: Linux
|
||||||
cmake-preset: linux
|
cmake-preset: linux
|
||||||
qt-version: 6.10.2
|
qt-version: 6.10.1
|
||||||
|
|
||||||
- os: ubuntu-24.04-arm
|
- os: ubuntu-24.04-arm
|
||||||
artifact-name: Linux-aarch64
|
artifact-name: Linux-aarch64
|
||||||
cmake-preset: linux
|
cmake-preset: linux
|
||||||
qt-version: 6.10.2
|
qt-version: 6.10.1
|
||||||
|
|
||||||
- os: windows-2022
|
- os: windows-2022
|
||||||
artifact-name: Windows-MinGW-w64
|
artifact-name: Windows-MinGW-w64
|
||||||
|
|
@ -70,13 +115,13 @@ jobs:
|
||||||
cmake-preset: windows_msvc
|
cmake-preset: windows_msvc
|
||||||
# TODO(@getchoo): This is the default in setup-dependencies/windows. Why isn't it working?!?!
|
# TODO(@getchoo): This is the default in setup-dependencies/windows. Why isn't it working?!?!
|
||||||
vcvars-arch: amd64
|
vcvars-arch: amd64
|
||||||
qt-version: 6.10.2
|
qt-version: 6.10.1
|
||||||
|
|
||||||
- os: windows-11-arm
|
- os: windows-11-arm
|
||||||
artifact-name: Windows-MSVC-arm64
|
artifact-name: Windows-MSVC-arm64
|
||||||
cmake-preset: windows_msvc
|
cmake-preset: windows_msvc
|
||||||
vcvars-arch: arm64
|
vcvars-arch: arm64
|
||||||
qt-version: 6.10.2
|
qt-version: 6.10.1
|
||||||
|
|
||||||
- os: macos-26
|
- os: macos-26
|
||||||
artifact-name: macOS
|
artifact-name: macOS
|
||||||
|
|
|
||||||
48
.github/workflows/clang-tidy.yml
vendored
48
.github/workflows/clang-tidy.yml
vendored
|
|
@ -1,48 +0,0 @@
|
||||||
name: Clang-Tidy Code Scanning
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
on:
|
|
||||||
merge_group:
|
|
||||||
types: [checks_requested]
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
permissions: {}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
clang-tidy:
|
|
||||||
name: Run Clang-Tidy
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
security-events: write
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v6
|
|
||||||
with:
|
|
||||||
fetch-depth: 0 # Required for diffing later on
|
|
||||||
submodules: "true"
|
|
||||||
|
|
||||||
- name: Install Nix
|
|
||||||
uses: cachix/install-nix-action@v31
|
|
||||||
|
|
||||||
- name: Run source generators
|
|
||||||
# TODO(@getchoo): Figure out how to make this work with PCH
|
|
||||||
run: |
|
|
||||||
nix develop --command bash -c '
|
|
||||||
cmake -B build -D Launcher_USE_PCH=OFF && cmake --build build --target autogen autorcc
|
|
||||||
'
|
|
||||||
|
|
||||||
# TODO: Use SARIF after https://github.com/psastras/sarif-rs/issues/638 is fixed
|
|
||||||
- name: Run clang-tidy-diff
|
|
||||||
env:
|
|
||||||
BASE_REF: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }}
|
|
||||||
run: |
|
|
||||||
nix develop --command bash -c '
|
|
||||||
clang-tidy -verify-config && git diff -U0 --no-color "$BASE_REF" | clang-tidy-diff.py -p1 -quiet -only-check-in-db
|
|
||||||
'
|
|
||||||
68
.github/workflows/codeql.yml
vendored
68
.github/workflows/codeql.yml
vendored
|
|
@ -5,21 +5,63 @@ concurrency:
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
on:
|
on:
|
||||||
merge_group:
|
push:
|
||||||
types: [checks_requested]
|
branches:
|
||||||
pull_request:
|
- "develop"
|
||||||
workflow_dispatch:
|
- "release-*"
|
||||||
|
paths:
|
||||||
|
# File types
|
||||||
|
- "**.cpp"
|
||||||
|
- "**.h"
|
||||||
|
- "**.java"
|
||||||
|
- "**.ui"
|
||||||
|
|
||||||
permissions: {}
|
# Directories
|
||||||
|
- "buildconfig/**"
|
||||||
|
- "cmake/**"
|
||||||
|
- "launcher/**"
|
||||||
|
- "libraries/**"
|
||||||
|
- "program_info/**"
|
||||||
|
- "tests/**"
|
||||||
|
|
||||||
|
# Files
|
||||||
|
- "CMakeLists.txt"
|
||||||
|
- "COPYING.md"
|
||||||
|
|
||||||
|
# Workflows
|
||||||
|
- ".github/codeql/**"
|
||||||
|
- ".github/workflows/codeql.yml"
|
||||||
|
- ".github/actions/setup-dependencies/**"
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
# File types
|
||||||
|
- "**.cpp"
|
||||||
|
- "**.h"
|
||||||
|
- "**.java"
|
||||||
|
- "**.ui"
|
||||||
|
|
||||||
|
# Directories
|
||||||
|
- "buildconfig/**"
|
||||||
|
- "cmake/**"
|
||||||
|
- "launcher/**"
|
||||||
|
- "libraries/**"
|
||||||
|
- "program_info/**"
|
||||||
|
- "tests/**"
|
||||||
|
|
||||||
|
# Files
|
||||||
|
- "CMakeLists.txt"
|
||||||
|
- "COPYING.md"
|
||||||
|
|
||||||
|
# Workflows
|
||||||
|
- ".github/codeql/**"
|
||||||
|
- ".github/workflows/codeql.yml"
|
||||||
|
- ".github/actions/setup-dependencies/**"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
CodeQL:
|
CodeQL:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
security-events: write
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
|
|
@ -37,16 +79,12 @@ jobs:
|
||||||
uses: ./.github/actions/setup-dependencies
|
uses: ./.github/actions/setup-dependencies
|
||||||
with:
|
with:
|
||||||
build-type: Debug
|
build-type: Debug
|
||||||
qt-version: 6.4.3
|
qt-version: 6.10.1
|
||||||
|
|
||||||
- name: Configure and Build
|
- name: Configure and Build
|
||||||
run: |
|
run: |
|
||||||
cmake --preset linux -DLauncher_USE_PCH=OFF
|
cmake --preset linux
|
||||||
cmake --build --preset linux --config Debug
|
cmake --build --preset linux --config Debug
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
run: |
|
|
||||||
ctest --preset linux --build-config Debug --extra-verbose --output-on-failure
|
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v4
|
uses: github/codeql-action/analyze@v4
|
||||||
|
|
|
||||||
174
.github/workflows/container.yml
vendored
174
.github/workflows/container.yml
vendored
|
|
@ -1,174 +0,0 @@
|
||||||
name: Development Container
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
on:
|
|
||||||
merge_group:
|
|
||||||
types: [checks_requested]
|
|
||||||
pull_request:
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
permissions: {}
|
|
||||||
|
|
||||||
env:
|
|
||||||
REGISTRY: ghcr.io
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
name: Build (${{ matrix.arch }})
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
packages: write
|
|
||||||
|
|
||||||
outputs:
|
|
||||||
image-name: ${{ steps.image-name.outputs.image-name }}
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- arch: arm64
|
|
||||||
os: ubuntu-24.04-arm
|
|
||||||
- arch: amd64
|
|
||||||
os: ubuntu-24.04
|
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Set image name
|
|
||||||
id: image-name
|
|
||||||
run: |
|
|
||||||
echo "image-name=${REGISTRY}/${GITHUB_REPOSITORY_OWNER,,}/devcontainer" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Install Podman
|
|
||||||
uses: redhat-actions/podman-install@main
|
|
||||||
# TODO(@getchoo): Always use this when the action properly supports ARM
|
|
||||||
if: ${{ runner.arch == 'X64' || runner.arch == 'X86' }}
|
|
||||||
with:
|
|
||||||
github-token: ${{ github.token }}
|
|
||||||
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v6
|
|
||||||
|
|
||||||
- name: Determine metadata for image
|
|
||||||
id: image-metadata
|
|
||||||
uses: docker/metadata-action@v6
|
|
||||||
with:
|
|
||||||
images: |
|
|
||||||
${{ steps.image-name.outputs.image-name }}
|
|
||||||
flavor: |
|
|
||||||
latest=false
|
|
||||||
tags: |
|
|
||||||
type=raw,value=latest,enable=${{ github.event.merge_group.base_ref == 'refs/heads/develop' }}
|
|
||||||
|
|
||||||
type=sha
|
|
||||||
type=sha,format=long
|
|
||||||
type=ref,event=branch
|
|
||||||
type=ref,event=tag
|
|
||||||
|
|
||||||
- name: Build image
|
|
||||||
id: build-image
|
|
||||||
uses: redhat-actions/buildah-build@v2
|
|
||||||
with:
|
|
||||||
containerfiles: |
|
|
||||||
./Containerfile
|
|
||||||
tags: ${{ steps.image-metadata.outputs.tags }}
|
|
||||||
labels: ${{ steps.image-metadata.outputs.labels }}
|
|
||||||
|
|
||||||
- name: Push image
|
|
||||||
id: push-image
|
|
||||||
if: ${{ github.event_name != 'pull_request' }}
|
|
||||||
uses: redhat-actions/push-to-registry@v2
|
|
||||||
with:
|
|
||||||
tags: ${{ steps.build-image.outputs.tags }}
|
|
||||||
username: ${{ github.repository_owner }}
|
|
||||||
password: ${{ github.token }}
|
|
||||||
tls-verify: true
|
|
||||||
|
|
||||||
- name: Export image digest
|
|
||||||
if: ${{ github.event_name != 'pull_request' }}
|
|
||||||
env:
|
|
||||||
DIGEST: ${{ steps.push-image.outputs.digest }}
|
|
||||||
run: |
|
|
||||||
mkdir -p "$RUNNER_TEMP"/digests
|
|
||||||
touch "$RUNNER_TEMP"/digests/"${DIGEST#sha256:}"
|
|
||||||
|
|
||||||
- name: Upload digest artifact
|
|
||||||
if: ${{ github.event_name != 'pull_request' }}
|
|
||||||
uses: actions/upload-artifact@v7
|
|
||||||
with:
|
|
||||||
name: digests-${{ matrix.arch }}
|
|
||||||
path: ${{ runner.temp }}/digests/*
|
|
||||||
if-no-files-found: error
|
|
||||||
retention-days: 1
|
|
||||||
|
|
||||||
manifest:
|
|
||||||
name: Create manifest
|
|
||||||
|
|
||||||
needs: [ build ]
|
|
||||||
if: ${{ github.event_name != 'pull_request' }}
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
packages: write
|
|
||||||
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Download digests
|
|
||||||
uses: actions/download-artifact@v8
|
|
||||||
with:
|
|
||||||
path: ${{ runner.temp }}/digests
|
|
||||||
pattern: digests-*
|
|
||||||
merge-multiple: true
|
|
||||||
|
|
||||||
- name: Install Podman
|
|
||||||
# TODO(@getchoo): Always use this when the action properly supports ARM
|
|
||||||
if: ${{ runner.arch == 'X64' || runner.arch == 'X86' }}
|
|
||||||
uses: redhat-actions/podman-install@main
|
|
||||||
with:
|
|
||||||
github-token: ${{ github.token }}
|
|
||||||
|
|
||||||
- name: Login to registry
|
|
||||||
uses: redhat-actions/podman-login@v1
|
|
||||||
with:
|
|
||||||
registry: ${{ env.REGISTRY }}
|
|
||||||
username: ${{ github.repository_owner }}
|
|
||||||
password: ${{ github.token }}
|
|
||||||
|
|
||||||
- name: Determine metadata for manifest
|
|
||||||
id: manifest-metadata
|
|
||||||
uses: docker/metadata-action@v6
|
|
||||||
with:
|
|
||||||
images: |
|
|
||||||
${{ needs.build.outputs.image-name }}
|
|
||||||
flavor: |
|
|
||||||
latest=false
|
|
||||||
tags: |
|
|
||||||
type=raw,value=latest,enable=${{ github.event.merge_group.base_ref == 'refs/heads/develop' }}
|
|
||||||
|
|
||||||
type=sha
|
|
||||||
type=sha,format=long
|
|
||||||
type=ref,event=branch
|
|
||||||
type=ref,event=tag
|
|
||||||
|
|
||||||
- name: Create manifest list
|
|
||||||
working-directory: ${{ runner.temp }}/digests
|
|
||||||
env:
|
|
||||||
IMAGE_NAME: ${{ needs.build.outputs.image-name }}
|
|
||||||
run: |
|
|
||||||
while read -r tag; do
|
|
||||||
podman manifest create "$tag" \
|
|
||||||
$(printf "$IMAGE_NAME@sha256:%s " *)
|
|
||||||
done <<< "$DOCKER_METADATA_OUTPUT_TAGS"
|
|
||||||
|
|
||||||
- name: Push manifest
|
|
||||||
uses: redhat-actions/push-to-registry@v2
|
|
||||||
with:
|
|
||||||
tags: ${{ steps.manifest-metadata.outputs.tags }}
|
|
||||||
username: ${{ github.repository_owner }}
|
|
||||||
password: ${{ github.token }}
|
|
||||||
tls-verify: true
|
|
||||||
102
.github/workflows/flatpak.yml
vendored
Normal file
102
.github/workflows/flatpak.yml
vendored
Normal file
|
|
@ -0,0 +1,102 @@
|
||||||
|
name: Flatpak
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "develop"
|
||||||
|
- "release-*"
|
||||||
|
# We don't do anything with these artifacts on releases. They go to Flathub
|
||||||
|
tags-ignore:
|
||||||
|
- "*"
|
||||||
|
paths:
|
||||||
|
# File types
|
||||||
|
- "**.cpp"
|
||||||
|
- "**.h"
|
||||||
|
- "**.java"
|
||||||
|
- "**.ui"
|
||||||
|
|
||||||
|
# Build files
|
||||||
|
- "flatpak/**"
|
||||||
|
|
||||||
|
# Directories
|
||||||
|
- "buildconfig/**"
|
||||||
|
- "cmake/**"
|
||||||
|
- "launcher/**"
|
||||||
|
- "libraries/**"
|
||||||
|
- "program_info/**"
|
||||||
|
- "tests/**"
|
||||||
|
|
||||||
|
# Files
|
||||||
|
- "CMakeLists.txt"
|
||||||
|
- "COPYING.md"
|
||||||
|
|
||||||
|
# Workflows
|
||||||
|
- ".github/workflows/flatpak.yml"
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
# File types
|
||||||
|
- "**.cpp"
|
||||||
|
- "**.h"
|
||||||
|
- "**.java"
|
||||||
|
- "**.ui"
|
||||||
|
|
||||||
|
# Build files
|
||||||
|
- "flatpak/**"
|
||||||
|
|
||||||
|
# Directories
|
||||||
|
- "buildconfig/**"
|
||||||
|
- "cmake/**"
|
||||||
|
- "launcher/**"
|
||||||
|
- "libraries/**"
|
||||||
|
- "program_info/**"
|
||||||
|
- "tests/**"
|
||||||
|
|
||||||
|
# Files
|
||||||
|
- "CMakeLists.txt"
|
||||||
|
- "COPYING.md"
|
||||||
|
|
||||||
|
# Workflows
|
||||||
|
- ".github/workflows/flatpak.yml"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build (${{ matrix.arch }})
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-22.04
|
||||||
|
arch: x86_64
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
container:
|
||||||
|
image: ghcr.io/flathub-infra/flatpak-github-actions:kde-6.10
|
||||||
|
options: --privileged
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
|
||||||
|
- name: Set short version
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "VERSION=${GITHUB_SHA::7}" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
|
- name: Build Flatpak
|
||||||
|
uses: flatpak/flatpak-github-actions/flatpak-builder@v6
|
||||||
|
with:
|
||||||
|
bundle: PrismLauncher-${{ runner.os }}-${{ env.VERSION }}-Flatpak.flatpak
|
||||||
|
manifest-path: flatpak/org.prismlauncher.PrismLauncher.yml
|
||||||
|
arch: ${{ matrix.arch }}
|
||||||
10
.github/workflows/merge-blocking-pr.yml
vendored
10
.github/workflows/merge-blocking-pr.yml
vendored
|
|
@ -11,21 +11,19 @@ on:
|
||||||
required: true
|
required: true
|
||||||
type: number
|
type: number
|
||||||
|
|
||||||
permissions: {}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update-blocked-status:
|
update-blocked-status:
|
||||||
name: Update Blocked Status
|
name: Update Blocked Status
|
||||||
runs-on: ubuntu-slim
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
# a pr that was a `blocking:<id>` label was merged.
|
# a pr that was a `blocking:<id>` label was merged.
|
||||||
# find the open pr's it was blocked by and trigger a refresh of their state
|
# find the open pr's it was blocked by and trigger a refresh of their state
|
||||||
if: "${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'status: blocking') }}"
|
if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'blocking') }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Generate token
|
- name: Generate token
|
||||||
id: generate-token
|
id: generate-token
|
||||||
uses: actions/create-github-app-token@v3
|
uses: actions/create-github-app-token@v2
|
||||||
with:
|
with:
|
||||||
app-id: ${{ vars.PULL_REQUEST_APP_ID }}
|
app-id: ${{ vars.PULL_REQUEST_APP_ID }}
|
||||||
private-key: ${{ secrets.PULL_REQUEST_APP_PRIVATE_KEY }}
|
private-key: ${{ secrets.PULL_REQUEST_APP_PRIVATE_KEY }}
|
||||||
|
|
@ -37,7 +35,7 @@ jobs:
|
||||||
PR_NUMBER: ${{ inputs.pr_id || github.event.pull_request.number }}
|
PR_NUMBER: ${{ inputs.pr_id || github.event.pull_request.number }}
|
||||||
run: |
|
run: |
|
||||||
blocked_prs=$(
|
blocked_prs=$(
|
||||||
gh -R ${{ github.repository }} pr list --label 'status: blocked' --json 'number,body' \
|
gh -R ${{ github.repository }} pr list --label 'blocked' --json 'number,body' \
|
||||||
| jq -c --argjson pr "$PR_NUMBER" '
|
| jq -c --argjson pr "$PR_NUMBER" '
|
||||||
reduce ( .[] | select(
|
reduce ( .[] | select(
|
||||||
.body |
|
.body |
|
||||||
|
|
|
||||||
16
.github/workflows/nix.yml
vendored
16
.github/workflows/nix.yml
vendored
|
|
@ -17,7 +17,6 @@ on:
|
||||||
- "**.h"
|
- "**.h"
|
||||||
- "**.java"
|
- "**.java"
|
||||||
- "**.ui"
|
- "**.ui"
|
||||||
- "**.md"
|
|
||||||
|
|
||||||
# Build files
|
# Build files
|
||||||
- "**.nix"
|
- "**.nix"
|
||||||
|
|
@ -34,6 +33,7 @@ on:
|
||||||
|
|
||||||
# Files
|
# Files
|
||||||
- "CMakeLists.txt"
|
- "CMakeLists.txt"
|
||||||
|
- "COPYING.md"
|
||||||
|
|
||||||
# Workflows
|
# Workflows
|
||||||
- ".github/workflows/nix.yml"
|
- ".github/workflows/nix.yml"
|
||||||
|
|
@ -44,7 +44,6 @@ on:
|
||||||
- "**.h"
|
- "**.h"
|
||||||
- "**.java"
|
- "**.java"
|
||||||
- "**.ui"
|
- "**.ui"
|
||||||
- "**.md"
|
|
||||||
|
|
||||||
# Build files
|
# Build files
|
||||||
- "**.nix"
|
- "**.nix"
|
||||||
|
|
@ -61,12 +60,14 @@ on:
|
||||||
|
|
||||||
# Files
|
# Files
|
||||||
- "CMakeLists.txt"
|
- "CMakeLists.txt"
|
||||||
|
- "COPYING.md"
|
||||||
|
|
||||||
# Workflows
|
# Workflows
|
||||||
- ".github/workflows/nix.yml"
|
- ".github/workflows/nix.yml"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions: {}
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
env:
|
env:
|
||||||
DEBUG: ${{ github.ref_type != 'tag' }}
|
DEBUG: ${{ github.ref_type != 'tag' }}
|
||||||
|
|
@ -75,9 +76,6 @@ jobs:
|
||||||
build:
|
build:
|
||||||
name: Build (${{ matrix.system }})
|
name: Build (${{ matrix.system }})
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
|
|
@ -88,7 +86,7 @@ jobs:
|
||||||
- os: ubuntu-22.04-arm
|
- os: ubuntu-22.04-arm
|
||||||
system: aarch64-linux
|
system: aarch64-linux
|
||||||
|
|
||||||
- os: macos-26
|
- os: macos-14
|
||||||
system: aarch64-darwin
|
system: aarch64-darwin
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
@ -103,7 +101,7 @@ jobs:
|
||||||
# For PRs
|
# For PRs
|
||||||
- name: Setup Nix Magic Cache
|
- name: Setup Nix Magic Cache
|
||||||
if: ${{ github.event_name == 'pull_request' }}
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
uses: DeterminateSystems/magic-nix-cache-action@v14
|
uses: DeterminateSystems/magic-nix-cache-action@v13
|
||||||
with:
|
with:
|
||||||
diagnostic-endpoint: ""
|
diagnostic-endpoint: ""
|
||||||
use-flakehub: false
|
use-flakehub: false
|
||||||
|
|
@ -111,7 +109,7 @@ jobs:
|
||||||
# For in-tree builds
|
# For in-tree builds
|
||||||
- name: Setup Cachix
|
- name: Setup Cachix
|
||||||
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
|
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
|
||||||
uses: cachix/cachix-action@v17
|
uses: cachix/cachix-action@v16
|
||||||
with:
|
with:
|
||||||
name: prismlauncher
|
name: prismlauncher
|
||||||
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
|
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
|
||||||
|
|
|
||||||
8
.github/workflows/publish.yml
vendored
8
.github/workflows/publish.yml
vendored
|
|
@ -4,16 +4,14 @@ on:
|
||||||
release:
|
release:
|
||||||
types: [ released ]
|
types: [ released ]
|
||||||
|
|
||||||
permissions: {}
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
winget:
|
winget:
|
||||||
name: Winget
|
name: Winget
|
||||||
|
|
||||||
permissions:
|
runs-on: windows-latest
|
||||||
contents: read
|
|
||||||
|
|
||||||
runs-on: ubuntu-slim
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Publish on Winget
|
- name: Publish on Winget
|
||||||
|
|
|
||||||
18
.github/workflows/release.yml
vendored
18
.github/workflows/release.yml
vendored
|
|
@ -5,18 +5,10 @@ on:
|
||||||
tags:
|
tags:
|
||||||
- "*"
|
- "*"
|
||||||
|
|
||||||
permissions: {}
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build_release:
|
build_release:
|
||||||
name: Build Release
|
name: Build Release
|
||||||
uses: ./.github/workflows/build.yml
|
uses: ./.github/workflows/build.yml
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
# Required for Azure Trusted Signing
|
|
||||||
id-token: write
|
|
||||||
# Required for vcpkg binary cache
|
|
||||||
packages: write
|
|
||||||
with:
|
with:
|
||||||
build-type: Release
|
build-type: Release
|
||||||
environment: Release
|
environment: Release
|
||||||
|
|
@ -24,9 +16,7 @@ jobs:
|
||||||
|
|
||||||
create_release:
|
create_release:
|
||||||
needs: build_release
|
needs: build_release
|
||||||
permissions:
|
runs-on: ubuntu-latest
|
||||||
contents: write
|
|
||||||
runs-on: ubuntu-slim
|
|
||||||
outputs:
|
outputs:
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
steps:
|
steps:
|
||||||
|
|
@ -36,7 +26,7 @@ jobs:
|
||||||
submodules: "true"
|
submodules: "true"
|
||||||
path: "PrismLauncher-source"
|
path: "PrismLauncher-source"
|
||||||
- name: Download artifacts
|
- name: Download artifacts
|
||||||
uses: actions/download-artifact@v8
|
uses: actions/download-artifact@v7
|
||||||
- name: Grab and store version
|
- name: Grab and store version
|
||||||
run: |
|
run: |
|
||||||
tag_name=$(echo ${{ github.ref }} | grep -oE "[^/]+$")
|
tag_name=$(echo ${{ github.ref }} | grep -oE "[^/]+$")
|
||||||
|
|
@ -51,7 +41,6 @@ jobs:
|
||||||
mv PrismLauncher-*.AppImage/PrismLauncher-*-aarch64.AppImage PrismLauncher-Linux-aarch64.AppImage
|
mv PrismLauncher-*.AppImage/PrismLauncher-*-aarch64.AppImage PrismLauncher-Linux-aarch64.AppImage
|
||||||
mv PrismLauncher-*.AppImage.zsync/PrismLauncher-*-aarch64.AppImage.zsync PrismLauncher-Linux-aarch64.AppImage.zsync
|
mv PrismLauncher-*.AppImage.zsync/PrismLauncher-*-aarch64.AppImage.zsync PrismLauncher-Linux-aarch64.AppImage.zsync
|
||||||
mv PrismLauncher-macOS*/PrismLauncher.zip PrismLauncher-macOS-${{ env.VERSION }}.zip
|
mv PrismLauncher-macOS*/PrismLauncher.zip PrismLauncher-macOS-${{ env.VERSION }}.zip
|
||||||
mv PrismLauncher-macOS*/PrismLauncher.dmg PrismLauncher-macOS-${{ env.VERSION }}.dmg
|
|
||||||
|
|
||||||
tar --exclude='.git' -czf PrismLauncher-${{ env.VERSION }}.tar.gz PrismLauncher-${{ env.VERSION }}
|
tar --exclude='.git' -czf PrismLauncher-${{ env.VERSION }}.tar.gz PrismLauncher-${{ env.VERSION }}
|
||||||
|
|
||||||
|
|
@ -94,7 +83,7 @@ jobs:
|
||||||
|
|
||||||
- name: Create release
|
- name: Create release
|
||||||
id: create_release
|
id: create_release
|
||||||
uses: softprops/action-gh-release@v3
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
tag_name: ${{ github.ref }}
|
tag_name: ${{ github.ref }}
|
||||||
|
|
@ -122,5 +111,4 @@ jobs:
|
||||||
PrismLauncher-Windows-MSVC-Portable-${{ env.VERSION }}.zip
|
PrismLauncher-Windows-MSVC-Portable-${{ env.VERSION }}.zip
|
||||||
PrismLauncher-Windows-MSVC-Setup-${{ env.VERSION }}.exe
|
PrismLauncher-Windows-MSVC-Setup-${{ env.VERSION }}.exe
|
||||||
PrismLauncher-macOS-${{ env.VERSION }}.zip
|
PrismLauncher-macOS-${{ env.VERSION }}.zip
|
||||||
PrismLauncher-macOS-${{ env.VERSION }}.dmg
|
|
||||||
PrismLauncher-${{ env.VERSION }}.tar.gz
|
PrismLauncher-${{ env.VERSION }}.tar.gz
|
||||||
|
|
|
||||||
29
.github/workflows/stale.yml
vendored
Normal file
29
.github/workflows/stale.yml
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
name: Stale
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
# run weekly on sunday
|
||||||
|
- cron: "0 0 * * 0"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
label:
|
||||||
|
name: Label issues and PRs
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
issues: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/stale@v10
|
||||||
|
with:
|
||||||
|
days-before-stale: 60
|
||||||
|
days-before-close: -1 # Don't close anything
|
||||||
|
exempt-issue-labels: rfc,nostale,help wanted
|
||||||
|
exempt-all-milestones: true
|
||||||
|
exempt-all-assignees: true
|
||||||
|
operations-per-run: 1000
|
||||||
|
stale-issue-label: inactive
|
||||||
|
stale-pr-label: inactive
|
||||||
21
.github/workflows/update-flake.yml
vendored
21
.github/workflows/update-flake.yml
vendored
|
|
@ -6,30 +6,25 @@ on:
|
||||||
- cron: "0 0 * * 0"
|
- cron: "0 0 * * 0"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions: {}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
update-flake:
|
|
||||||
if: github.repository == 'PrismLauncher/PrismLauncher'
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
|
||||||
runs-on: ubuntu-slim
|
jobs:
|
||||||
|
update-flake:
|
||||||
|
if: github.repository == 'PrismLauncher/PrismLauncher'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- uses: cachix/install-nix-action@8aa03977d8d733052d78f4e008a241fd1dbf36b3 # v31
|
- uses: cachix/install-nix-action@4e002c8ec80594ecd40e759629461e26c8abed15 # v31
|
||||||
|
|
||||||
- uses: DeterminateSystems/update-flake-lock@v28
|
- uses: DeterminateSystems/update-flake-lock@v28
|
||||||
with:
|
with:
|
||||||
commit-msg: "chore(nix): update lockfile"
|
commit-msg: "chore(nix): update lockfile"
|
||||||
pr-title: "chore(nix): update lockfile"
|
pr-title: "chore(nix): update lockfile"
|
||||||
pr-labels: |
|
pr-labels: |
|
||||||
platform: Linux
|
Linux
|
||||||
area: packaging
|
packaging
|
||||||
complexity: low
|
simple change
|
||||||
priority: low
|
|
||||||
type: robot
|
|
||||||
changelog:omit
|
changelog:omit
|
||||||
|
|
|
||||||
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -1,3 +1,6 @@
|
||||||
[submodule "libraries/libnbtplusplus"]
|
[submodule "libraries/libnbtplusplus"]
|
||||||
path = libraries/libnbtplusplus
|
path = libraries/libnbtplusplus
|
||||||
url = https://github.com/PrismLauncher/libnbtplusplus.git
|
url = https://github.com/PrismLauncher/libnbtplusplus.git
|
||||||
|
[submodule "flatpak/shared-modules"]
|
||||||
|
path = flatpak/shared-modules
|
||||||
|
url = https://github.com/flathub/shared-modules.git
|
||||||
|
|
|
||||||
116
CMakeLists.txt
116
CMakeLists.txt
|
|
@ -1,4 +1,4 @@
|
||||||
cmake_minimum_required(VERSION 3.25) # Required for features like `CMAKE_MSVC_DEBUG_INFORMATION_FORMAT`
|
cmake_minimum_required(VERSION 3.22) # minimum version required by Qt
|
||||||
|
|
||||||
project(Launcher LANGUAGES C CXX)
|
project(Launcher LANGUAGES C CXX)
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
|
|
@ -13,10 +13,6 @@ endif()
|
||||||
##################################### Set CMake options #####################################
|
##################################### Set CMake options #####################################
|
||||||
set(CMAKE_AUTOMOC ON)
|
set(CMAKE_AUTOMOC ON)
|
||||||
set(CMAKE_AUTORCC ON)
|
set(CMAKE_AUTORCC ON)
|
||||||
set(CMAKE_AUTOUIC ON)
|
|
||||||
set(CMAKE_AUTOGEN_ORIGIN_DEPENDS OFF)
|
|
||||||
set(CMAKE_GLOBAL_AUTOGEN_TARGET ON)
|
|
||||||
set(CMAKE_GLOBAL_AUTORCC_TARGET ON)
|
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
|
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")
|
||||||
|
|
@ -34,82 +30,79 @@ set(CMAKE_C_STANDARD_REQUIRED true)
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
include(GenerateExportHeader)
|
include(GenerateExportHeader)
|
||||||
|
if(MSVC)
|
||||||
|
# /GS Adds buffer security checks, default on but incuded anyway to mirror gcc's fstack-protector flag
|
||||||
|
# /permissive- specify standards-conforming compiler behavior, also enabled by Qt6, default on with std:c++20
|
||||||
|
# Use /W4 as /Wall includes unnesserey warnings such as added padding to structs
|
||||||
|
set(CMAKE_CXX_FLAGS "/GS /permissive- /W4 ${CMAKE_CXX_FLAGS}")
|
||||||
|
|
||||||
add_compile_definitions($<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>)
|
# /EHs Enables stack unwind semantics for standard C++ exceptions to ensure stackframes are unwound
|
||||||
add_compile_definitions(QT_WARN_DEPRECATED_UP_TO=0x060400)
|
# and object deconstructors are called when an exception is caught.
|
||||||
add_compile_definitions(QT_DISABLE_DEPRECATED_UP_TO=0x060400)
|
# without it memory leaks and a warning is printed
|
||||||
|
# /EHc tells the compiler to assume that functions declared as extern "C" never throw a C++ exception
|
||||||
|
# This appears to not always be a defualt compiler option in CMAKE
|
||||||
|
set(CMAKE_CXX_FLAGS "/EHsc ${CMAKE_CXX_FLAGS}")
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
|
# LINK accepts /SUBSYSTEM whics sets if we are a WINDOWS (gui) or a CONSOLE programs
|
||||||
add_compile_options(
|
# This implicitly selects an entrypoint specific to the subsystem selected
|
||||||
# /GS Adds buffer security checks, default on but included anyway to mirror gcc's fstack-protector flag
|
# qtmain/QtEntryPointLib provides the correct entrypoint (wWinMain) for gui programs
|
||||||
"$<$<COMPILE_LANGUAGE:C,CXX>:/GS>"
|
# Additinaly LINK autodetects we use a GUI so we can omit /SUBSYSTEM
|
||||||
|
# This allows tests to still use have console without using seperate linker flags
|
||||||
# /Gw helps reduce binary size
|
|
||||||
# /Gy allows the compiler to package individual functions
|
|
||||||
# /guard:cf enables control flow guard
|
|
||||||
"$<$<AND:$<CONFIG:Release,RelWithDebInfo>,$<COMPILE_LANGUAGE:C,CXX>>:/Gw;/Gy;/guard:cf>"
|
|
||||||
)
|
|
||||||
|
|
||||||
add_link_options(
|
|
||||||
# /LTCG allows for linking wholy optimizated programs
|
# /LTCG allows for linking wholy optimizated programs
|
||||||
# /MANIFEST:NO disables generating a manifest file, we instead provide our own
|
# /MANIFEST:NO disables generating a manifest file, we instead provide our own
|
||||||
# /STACK sets the stack reserve size, ATL's pack list needs 3-4 MiB as of November 2022, provide 8 MiB
|
# /STACK sets the stack reserve size, ATL's pack list needs 3-4 MiB as of November 2022, provide 8 MiB
|
||||||
"$<$<COMPILE_LANGUAGE:C,CXX>:/LTCG;/MANIFEST:NO;/STACK:8388608>"
|
set(CMAKE_EXE_LINKER_FLAGS "/LTCG /MANIFEST:NO /STACK:8388608 ${CMAKE_EXE_LINKER_FLAGS}")
|
||||||
)
|
|
||||||
|
|
||||||
# /GL enables whole program optimizations
|
# /GL enables whole program optimizations
|
||||||
# NOTE: With Clang, this is implemented as regular LTO and only used during linking
|
# /Gw helps reduce binary size
|
||||||
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
# /Gy allows the compiler to package individual functions
|
||||||
add_compile_options("$<$<AND:$<CONFIG:Release,RelWithDebInfo>,$<COMPILE_LANGUAGE:C,CXX>>:/GL>")
|
# /guard:cf enables control flow guard
|
||||||
endif()
|
foreach(lang C CXX)
|
||||||
|
set("CMAKE_${lang}_FLAGS_RELEASE" "/GL /Gw /Gy /guard:cf")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
# See https://github.com/ccache/ccache/issues/1040
|
# See https://github.com/ccache/ccache/issues/1040
|
||||||
# TODO(@getchoo): Is sccache affected by this? Would be nice to use `ProgramDatabase`....
|
# Note, CMake 3.25 replaces this with CMAKE_MSVC_DEBUG_INFORMATION_FORMAT
|
||||||
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>")
|
# See https://cmake.org/cmake/help/v3.25/variable/CMAKE_MSVC_DEBUG_INFORMATION_FORMAT.html
|
||||||
|
foreach(config DEBUG RELWITHDEBINFO)
|
||||||
|
foreach(lang C CXX)
|
||||||
|
set(flags_var "CMAKE_${lang}_FLAGS_${config}")
|
||||||
|
string(REGEX REPLACE "/Z[Ii]" "/Z7" ${flags_var} "${${flags_var}}")
|
||||||
|
endforeach()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
if(CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL "MultiThreadedDLL")
|
if(CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL "MultiThreadedDLL")
|
||||||
set(CMAKE_MAP_IMPORTED_CONFIG_DEBUG Release "")
|
set(CMAKE_MAP_IMPORTED_CONFIG_DEBUG Release "")
|
||||||
set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release "")
|
set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO Release "")
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
add_compile_options("$<$<COMPILE_LANGUAGE:C,CXX>:-fstack-protector-strong;--param=ssp-buffer-size=4>")
|
set(CMAKE_CXX_FLAGS "-Wall -pedantic -fstack-protector-strong --param=ssp-buffer-size=4 ${CMAKE_CXX_FLAGS}")
|
||||||
|
|
||||||
# Avoid re-defining _FORTIFY_SOURCE, as it can cause redefinition errors in setups that use it by default (i.e., package builds)
|
|
||||||
if(NOT (CMAKE_C_FLAGS MATCHES "-D_FORTIFY_SOURCE" OR CMAKE_CXX_FLAGS MATCHES "-D_FORTIFY_SOURCE"))
|
|
||||||
# NOTE: _FORTIFY_SOURCE requires optimizations in most newer versions of glibc
|
|
||||||
add_compile_options("$<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:Release,RelWithDebInfo>>:-D_FORTIFY_SOURCE=2>")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# ATL's pack list needs more than the default 1 Mib stack on windows
|
# ATL's pack list needs more than the default 1 Mib stack on windows
|
||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
if(WIN32)
|
||||||
add_link_options("$<$<COMPILE_LANGUAGE:C,CXX>:-Wl,--stack,8388608>")
|
set(CMAKE_EXE_LINKER_FLAGS "-Wl,--stack,8388608 ${CMAKE_EXE_LINKER_FLAGS}")
|
||||||
|
|
||||||
# -ffunction-sections and -fdata-sections help reduce binary size
|
# -ffunction-sections and -fdata-sections help reduce binary size
|
||||||
# -mguard=cf enables Control Flow Guard
|
# -mguard=cf enables Control Flow Guard
|
||||||
# TODO: Look into -gc-sections to further reduce binary size
|
# TODO: Look into -gc-sections to further reduce binary size
|
||||||
add_compile_options("$<$<AND:$<CONFIG:Release,RelWithDebInfo>,$<COMPILE_LANGUAGE:C,CXX>>:-ffunction-sections;-fdata-sections;-mguard=cf>")
|
foreach(lang C CXX)
|
||||||
|
set("CMAKE_${lang}_FLAGS_RELEASE" "-ffunction-sections -fdata-sections -mguard=cf")
|
||||||
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_WARN_DEPRECATED_UP_TO=0x060200")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_DISABLE_DEPRECATED_UP_TO=0x060000")
|
||||||
|
|
||||||
|
# set CXXFLAGS for build targets
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -D_FORTIFY_SOURCE=2 ${CMAKE_CXX_FLAGS_RELEASE}")
|
||||||
|
|
||||||
# Export compile commands for debug builds if we can (useful in LSPs like clangd)
|
# Export compile commands for debug builds if we can (useful in LSPs like clangd)
|
||||||
# https://cmake.org/cmake/help/v3.31/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html
|
# https://cmake.org/cmake/help/v3.31/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html
|
||||||
if(CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR MATCHES "^Ninja")
|
if(CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR MATCHES "^Ninja")
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(USE_CLANG_TIDY "Enable the use of clang-tidy during compilation" OFF)
|
|
||||||
|
|
||||||
if(USE_CLANG_TIDY)
|
|
||||||
find_program(CLANG_TIDY clang-tidy OPTIONAL)
|
|
||||||
if(CLANG_TIDY)
|
|
||||||
message(STATUS "Using clang-tidy during compilation")
|
|
||||||
set(CLANG_TIDY_COMMAND "${CLANG_TIDY}" "--config-file=${CMAKE_SOURCE_DIR}/.clang-tidy")
|
|
||||||
set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_COMMAND})
|
|
||||||
else()
|
|
||||||
message(WARNING "Unable to find `clang-tidy`. Not using during compilation")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
option(DEBUG_ADDRESS_SANITIZER "Enable Address Sanitizer in Debug builds" OFF)
|
option(DEBUG_ADDRESS_SANITIZER "Enable Address Sanitizer in Debug builds" OFF)
|
||||||
|
|
||||||
# If this is a Debug build turn on address sanitiser
|
# If this is a Debug build turn on address sanitiser
|
||||||
|
|
@ -146,9 +139,8 @@ if(ENABLE_LTO)
|
||||||
if(ipo_supported)
|
if(ipo_supported)
|
||||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
|
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
|
||||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL TRUE)
|
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL TRUE)
|
||||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO TRUE)
|
|
||||||
if(CMAKE_BUILD_TYPE)
|
if(CMAKE_BUILD_TYPE)
|
||||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
|
||||||
message(STATUS "IPO / LTO enabled")
|
message(STATUS "IPO / LTO enabled")
|
||||||
else()
|
else()
|
||||||
message(STATUS "Not enabling IPO / LTO on debug builds")
|
message(STATUS "Not enabling IPO / LTO on debug builds")
|
||||||
|
|
@ -177,13 +169,12 @@ endif()
|
||||||
######## Set URLs ########
|
######## Set URLs ########
|
||||||
set(Launcher_NEWS_RSS_URL "https://prismlauncher.org/feed/feed.xml" CACHE STRING "URL to fetch Prism Launcher's news RSS feed from.")
|
set(Launcher_NEWS_RSS_URL "https://prismlauncher.org/feed/feed.xml" CACHE STRING "URL to fetch Prism Launcher's news RSS feed from.")
|
||||||
set(Launcher_NEWS_OPEN_URL "https://prismlauncher.org/news" CACHE STRING "URL that gets opened when the user clicks 'More News'")
|
set(Launcher_NEWS_OPEN_URL "https://prismlauncher.org/news" CACHE STRING "URL that gets opened when the user clicks 'More News'")
|
||||||
set(Launcher_WIKI_URL "https://prismlauncher.org/wiki/" CACHE STRING "URL that gets opened when the user clicks 'Launcher Help'")
|
set(Launcher_HELP_URL "https://prismlauncher.org/wiki/help-pages/%1" CACHE STRING "URL (with arg %1 to be substituted with page-id) that gets opened when the user requests help")
|
||||||
set(Launcher_HELP_URL "https://prismlauncher.org/wiki/help-pages/%1" CACHE STRING "URL (with arg %1 to be substituted with page-id) that gets opened when the user requests help in a dialog window")
|
|
||||||
set(Launcher_LOGIN_CALLBACK_URL "https://prismlauncher.org/successful-login" CACHE STRING "URL that gets opened when the user successfully logins.")
|
set(Launcher_LOGIN_CALLBACK_URL "https://prismlauncher.org/successful-login" CACHE STRING "URL that gets opened when the user successfully logins.")
|
||||||
set(Launcher_LEGACY_FMLLIBS_BASE_URL "https://files.prismlauncher.org/fmllibs/" CACHE STRING "URL for legacy (<=1.5.2) FML Libraries.")
|
set(Launcher_FMLLIBS_BASE_URL "https://files.prismlauncher.org/fmllibs/" CACHE STRING "URL for FML Libraries.")
|
||||||
|
|
||||||
######## Set version numbers ########
|
######## Set version numbers ########
|
||||||
set(Launcher_VERSION_MAJOR 12)
|
set(Launcher_VERSION_MAJOR 10)
|
||||||
set(Launcher_VERSION_MINOR 0)
|
set(Launcher_VERSION_MINOR 0)
|
||||||
set(Launcher_VERSION_PATCH 0)
|
set(Launcher_VERSION_PATCH 0)
|
||||||
|
|
||||||
|
|
@ -225,8 +216,6 @@ set(Launcher_SUBREDDIT_URL "https://prismlauncher.org/reddit" CACHE STRING "URL
|
||||||
# Builds
|
# Builds
|
||||||
set(Launcher_QT_VERSION_MAJOR "6" CACHE STRING "Major Qt version to build against")
|
set(Launcher_QT_VERSION_MAJOR "6" CACHE STRING "Major Qt version to build against")
|
||||||
|
|
||||||
option(Launcher_USE_PCH "Use precompiled headers where possible" ON)
|
|
||||||
|
|
||||||
# Java downloader
|
# Java downloader
|
||||||
set(Launcher_ENABLE_JAVA_DOWNLOADER_DEFAULT ON)
|
set(Launcher_ENABLE_JAVA_DOWNLOADER_DEFAULT ON)
|
||||||
|
|
||||||
|
|
@ -292,7 +281,7 @@ set(Launcher_BUILD_TIMESTAMP "${TODAY}")
|
||||||
# Find the required Qt parts
|
# Find the required Qt parts
|
||||||
if(Launcher_QT_VERSION_MAJOR EQUAL 6)
|
if(Launcher_QT_VERSION_MAJOR EQUAL 6)
|
||||||
set(QT_VERSION_MAJOR 6)
|
set(QT_VERSION_MAJOR 6)
|
||||||
find_package(Qt6 6.4 REQUIRED COMPONENTS Core CoreTools Widgets Concurrent Network Test Xml NetworkAuth OpenGL)
|
find_package(Qt6 REQUIRED COMPONENTS Core CoreTools Widgets Concurrent Network Test Xml NetworkAuth OpenGL)
|
||||||
find_package(Qt6 COMPONENTS DBus)
|
find_package(Qt6 COMPONENTS DBus)
|
||||||
list(APPEND Launcher_QT_DBUS Qt6::DBus)
|
list(APPEND Launcher_QT_DBUS Qt6::DBus)
|
||||||
else()
|
else()
|
||||||
|
|
@ -374,7 +363,7 @@ if(UNIX AND APPLE)
|
||||||
# Mac bundle settings
|
# Mac bundle settings
|
||||||
set(MACOSX_BUNDLE_BUNDLE_NAME "${Launcher_DisplayName}")
|
set(MACOSX_BUNDLE_BUNDLE_NAME "${Launcher_DisplayName}")
|
||||||
set(MACOSX_BUNDLE_INFO_STRING "${Launcher_DisplayName}: A custom launcher for Minecraft that allows you to easily manage multiple installations of Minecraft at once.")
|
set(MACOSX_BUNDLE_INFO_STRING "${Launcher_DisplayName}: A custom launcher for Minecraft that allows you to easily manage multiple installations of Minecraft at once.")
|
||||||
set(MACOSX_BUNDLE_GUI_IDENTIFIER "${Launcher_AppID}")
|
set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.prismlauncher.${Launcher_Name}")
|
||||||
set(MACOSX_BUNDLE_BUNDLE_VERSION "${Launcher_VERSION_NAME}")
|
set(MACOSX_BUNDLE_BUNDLE_VERSION "${Launcher_VERSION_NAME}")
|
||||||
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${Launcher_VERSION_NAME}")
|
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${Launcher_VERSION_NAME}")
|
||||||
set(MACOSX_BUNDLE_LONG_VERSION_STRING "${Launcher_VERSION_NAME}")
|
set(MACOSX_BUNDLE_LONG_VERSION_STRING "${Launcher_VERSION_NAME}")
|
||||||
|
|
@ -419,7 +408,7 @@ if(UNIX AND APPLE)
|
||||||
COMMAND ${ACTOOL_EXE} "${ICON_SOURCE}"
|
COMMAND ${ACTOOL_EXE} "${ICON_SOURCE}"
|
||||||
--compile "${ASSETS_OUT_DIR}"
|
--compile "${ASSETS_OUT_DIR}"
|
||||||
--output-partial-info-plist /dev/null
|
--output-partial-info-plist /dev/null
|
||||||
--app-icon ${Launcher_Name}
|
--app-icon PrismLauncher
|
||||||
--enable-on-demand-resources NO
|
--enable-on-demand-resources NO
|
||||||
--target-device mac
|
--target-device mac
|
||||||
--minimum-deployment-target ${CMAKE_OSX_DEPLOYMENT_TARGET}
|
--minimum-deployment-target ${CMAKE_OSX_DEPLOYMENT_TARGET}
|
||||||
|
|
@ -454,7 +443,7 @@ elseif(UNIX)
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${Launcher_MetaInfo} DESTINATION ${KDE_INSTALL_METAINFODIR})
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${Launcher_MetaInfo} DESTINATION ${KDE_INSTALL_METAINFODIR})
|
||||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${Launcher_SVG} DESTINATION "${KDE_INSTALL_ICONDIR}/hicolor/scalable/apps")
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${Launcher_SVG} DESTINATION "${KDE_INSTALL_ICONDIR}/hicolor/scalable/apps")
|
||||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${Launcher_PNG_256} DESTINATION "${KDE_INSTALL_ICONDIR}/hicolor/256x256/apps" RENAME "${Launcher_AppID}.png")
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${Launcher_PNG_256} DESTINATION "${KDE_INSTALL_ICONDIR}/hicolor/256x256/apps" RENAME "${Launcher_AppID}.png")
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${Launcher_MIMEInfo} DESTINATION ${KDE_INSTALL_MIMEDIR})
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${Launcher_mrpack_MIMEInfo} DESTINATION ${KDE_INSTALL_MIMEDIR})
|
||||||
|
|
||||||
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/launcher/qtlogging.ini" DESTINATION "share/${Launcher_Name}")
|
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/launcher/qtlogging.ini" DESTINATION "share/${Launcher_Name}")
|
||||||
|
|
||||||
|
|
@ -492,6 +481,7 @@ option(NBT_USE_ZLIB "Build NBT library with zlib support" OFF)
|
||||||
option(NBT_BUILD_TESTS "Build NBT library tests" OFF) #FIXME: fix unit tests.
|
option(NBT_BUILD_TESTS "Build NBT library tests" OFF) #FIXME: fix unit tests.
|
||||||
add_subdirectory(libraries/libnbtplusplus)
|
add_subdirectory(libraries/libnbtplusplus)
|
||||||
|
|
||||||
|
add_subdirectory(libraries/systeminfo) # system information library
|
||||||
add_subdirectory(libraries/launcher) # java based launcher part for Minecraft
|
add_subdirectory(libraries/launcher) # java based launcher part for Minecraft
|
||||||
add_subdirectory(libraries/javacheck) # java compatibility checker
|
add_subdirectory(libraries/javacheck) # java compatibility checker
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,6 @@
|
||||||
"type": "equals",
|
"type": "equals",
|
||||||
"lhs": "${hostSystemName}",
|
"lhs": "${hostSystemName}",
|
||||||
"rhs": "Darwin"
|
"rhs": "Darwin"
|
||||||
},
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "$penv{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -53,7 +50,6 @@
|
||||||
"macos"
|
"macos"
|
||||||
],
|
],
|
||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"CMAKE_TOOLCHAIN_FILE": "$penv{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
|
|
||||||
"CMAKE_OSX_ARCHITECTURES": "x86_64;arm64",
|
"CMAKE_OSX_ARCHITECTURES": "x86_64;arm64",
|
||||||
"VCPKG_TARGET_TRIPLET": "universal-osx"
|
"VCPKG_TARGET_TRIPLET": "universal-osx"
|
||||||
}
|
}
|
||||||
|
|
@ -80,9 +76,6 @@
|
||||||
"type": "equals",
|
"type": "equals",
|
||||||
"lhs": "${hostSystemName}",
|
"lhs": "${hostSystemName}",
|
||||||
"rhs": "Windows"
|
"rhs": "Windows"
|
||||||
},
|
|
||||||
"cacheVariables": {
|
|
||||||
"CMAKE_TOOLCHAIN_FILE": "$penv{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
@ -141,8 +134,7 @@
|
||||||
"name": "base",
|
"name": "base",
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
"output": {
|
"output": {
|
||||||
"outputOnFailure": true,
|
"outputOnFailure": true
|
||||||
"verbosity": "extra"
|
|
||||||
},
|
},
|
||||||
"execution": {
|
"execution": {
|
||||||
"noTestsAction": "error"
|
"noTestsAction": "error"
|
||||||
|
|
|
||||||
|
|
@ -1,52 +1,5 @@
|
||||||
# Contributions Guidelines
|
# Contributions Guidelines
|
||||||
|
|
||||||
## Restrictions on Generative AI Usage (AI Policy)
|
|
||||||
|
|
||||||
> [!NOTE]
|
|
||||||
> The following is adapted from [matplotlib's contributing guide](https://matplotlib.org/devdocs/devel/contribute.html#generative-ai) and the [Linux Kernel policy guide](https://www.kernel.org/doc./html/next/process/coding-assistants.html)
|
|
||||||
|
|
||||||
We expect authentic engagement in our community.
|
|
||||||
|
|
||||||
- Do not post output from Large Language Models or similar generative AI as comments on GitHub or our discord server, as such comments tend to be formulaic and low-quality content.
|
|
||||||
- If you use generative AI tools as an aid in developing code or documentation changes, ensure that you fully understand the proposed changes and can explain why they are the correct approach.
|
|
||||||
|
|
||||||
Make sure you have added value based on your personal competency to your contributions.
|
|
||||||
Just taking some input, feeding it to an AI and posting the result is not of value to the project.
|
|
||||||
To preserve precious core developer capacity, we reserve the right to rigorously reject seemingly AI generated low-value contributions.
|
|
||||||
|
|
||||||
### Signed-off-by and Developer Certificate of Origin
|
|
||||||
|
|
||||||
AI agents MUST NOT add Signed-off-by tags. Only humans can legally certify the Developer Certificate of Origin (DCO). The human submitter is responsible for:
|
|
||||||
|
|
||||||
- Reviewing all AI-generated code
|
|
||||||
- Ensuring compliance with licensing requirements
|
|
||||||
- Adding their own Signed-off-by tag to certify the DCO
|
|
||||||
- Taking full responsibility for the contribution
|
|
||||||
|
|
||||||
See [Signing your work](#signing-your-work) for more information.
|
|
||||||
|
|
||||||
### Attribution
|
|
||||||
|
|
||||||
When AI tools contribute to development, proper attribution helps track the evolving role of AI in the development process. Contributions should include an Assisted-by tag in the commit message with the following format:
|
|
||||||
|
|
||||||
```text
|
|
||||||
Assisted-by: AGENT_NAME:MODEL_VERSION [TOOL1] [TOOL2]
|
|
||||||
```
|
|
||||||
|
|
||||||
Where:
|
|
||||||
|
|
||||||
- `AGENT_NAME` is the name of the AI tool or framework
|
|
||||||
- `MODEL_VERSION` is the specific model version used
|
|
||||||
- `[TOOL1] [TOOL2]` are optional specialized analysis tools used (e.g., coccinelle, sparse, smatch, clang-tidy)
|
|
||||||
|
|
||||||
Basic development tools (git, gcc, make, editors) should not be listed.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
```text
|
|
||||||
Assisted-by: Claude:claude-3-opus coccinelle sparse
|
|
||||||
```
|
|
||||||
|
|
||||||
## Code style
|
## Code style
|
||||||
|
|
||||||
All files are formatted with `clang-format` using the configuration in `.clang-format`. Ensure it is run on changed files before committing!
|
All files are formatted with `clang-format` using the configuration in `.clang-format`. Ensure it is run on changed files before committing!
|
||||||
|
|
@ -60,8 +13,7 @@ Please also follow the project's conventions for C++:
|
||||||
- Public, private or protected `static const` class data members should be formatted as `SCREAMING_SNAKE_CASE`: `MAX_VALUE`.
|
- Public, private or protected `static const` class data members should be formatted as `SCREAMING_SNAKE_CASE`: `MAX_VALUE`.
|
||||||
- Class function members should be formatted as `camelCase` without a prefix: `incrementCounter`.
|
- Class function members should be formatted as `camelCase` without a prefix: `incrementCounter`.
|
||||||
- Global functions and non-`const` global variables should be formatted as `camelCase` without a prefix: `globalData`.
|
- Global functions and non-`const` global variables should be formatted as `camelCase` without a prefix: `globalData`.
|
||||||
- `const` global variables and macros should be formatted as `SCREAMING_SNAKE_CASE`: `LIGHT_GRAY`.
|
- `const` global variables, macros, and enum constants should be formatted as `SCREAMING_SNAKE_CASE`: `LIGHT_GRAY`.
|
||||||
- enum constants should be formatted as `PascalCase`: `CamelusBactrianus`
|
|
||||||
- Avoid inventing acronyms or abbreviations especially for a name of multiple words - like `tp` for `texturePack`.
|
- Avoid inventing acronyms or abbreviations especially for a name of multiple words - like `tp` for `texturePack`.
|
||||||
- Avoid using `[[nodiscard]]` unless ignoring the return value is likely to cause a bug in cases such as:
|
- Avoid using `[[nodiscard]]` unless ignoring the return value is likely to cause a bug in cases such as:
|
||||||
- A function allocates memory or another resource and the caller needs to clean it up.
|
- A function allocates memory or another resource and the caller needs to clean it up.
|
||||||
|
|
@ -78,7 +30,7 @@ Here is what these conventions with the formatting configuration look like:
|
||||||
|
|
||||||
constexpr double PI = 3.14159;
|
constexpr double PI = 3.14159;
|
||||||
|
|
||||||
enum class PizzaToppings { HamAndPineapple, OreoAndKetchup };
|
enum class PizzaToppings { HAM_AND_PINEAPPLE, OREO_AND_KETCHUP };
|
||||||
|
|
||||||
struct Person {
|
struct Person {
|
||||||
QString name;
|
QString name;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
## Prism Launcher
|
## Prism Launcher
|
||||||
|
|
||||||
Prism Launcher - Minecraft Launcher
|
Prism Launcher - Minecraft Launcher
|
||||||
Copyright (C) 2022-2026 Prism Launcher Contributors
|
Copyright (C) 2022-2025 Prism Launcher 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
|
||||||
|
|
|
||||||
|
|
@ -1,74 +0,0 @@
|
||||||
ARG DEBIAN_VERSION=stable-slim
|
|
||||||
|
|
||||||
FROM docker.io/library/debian:${DEBIAN_VERSION}
|
|
||||||
|
|
||||||
ARG QT_ABI=gcc_64
|
|
||||||
ARG QT_ARCH=
|
|
||||||
ARG QT_HOST=linux
|
|
||||||
ARG QT_TARGET=desktop
|
|
||||||
ARG QT_VERSION=6.10.2
|
|
||||||
|
|
||||||
ARG DEBIAN_FRONTEND=noninteractive
|
|
||||||
|
|
||||||
RUN apt-get update \
|
|
||||||
&& apt-get --assume-yes upgrade \
|
|
||||||
&& apt-get --assume-yes autopurge
|
|
||||||
|
|
||||||
# Use Adoptium for Java 17
|
|
||||||
RUN apt-get --assume-yes --no-install-recommends install \
|
|
||||||
apt-transport-https ca-certificates curl gpg
|
|
||||||
RUN curl -L https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor | tee /etc/apt/trusted.gpg.d/adoptium.gpg
|
|
||||||
RUN echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list
|
|
||||||
RUN apt-get update
|
|
||||||
|
|
||||||
# Install base dependencies
|
|
||||||
RUN apt-get --assume-yes --no-install-recommends install \
|
|
||||||
# Compilers
|
|
||||||
clang lld llvm temurin-17-jdk \
|
|
||||||
# Build system
|
|
||||||
cmake ninja-build extra-cmake-modules pkg-config \
|
|
||||||
# Dependencies
|
|
||||||
cmark gamemode-dev libarchive-dev libcmark-dev libgamemode0 libgl1-mesa-dev libqrencode-dev libtomlplusplus-dev scdoc zlib1g-dev \
|
|
||||||
# Tooling
|
|
||||||
clang-format clang-tidy git
|
|
||||||
|
|
||||||
# Use LLD by default for faster linking
|
|
||||||
ENV CMAKE_LINKER_TYPE=lld
|
|
||||||
|
|
||||||
# Prepare and install Qt
|
|
||||||
## Setup UTF-8 locale (required, apparently)
|
|
||||||
RUN apt-get --assume-yes --no-install-recommends install locales
|
|
||||||
RUN echo "C.UTF-8 UTF-8" > /etc/locale.gen
|
|
||||||
RUN locale-gen
|
|
||||||
ENV LC_ALL=C.UTF-8
|
|
||||||
|
|
||||||
## Some libraries are required for the official binaries
|
|
||||||
RUN apt-get --assume-yes --no-install-recommends install \
|
|
||||||
libglib2.0-0t64 libxkbcommon0 python3-pip
|
|
||||||
|
|
||||||
RUN pip3 install --break-system-packages aqtinstall
|
|
||||||
RUN aqt install-qt \
|
|
||||||
${QT_HOST} ${QT_TARGET} ${QT_VERSION} ${QT_ARCH} \
|
|
||||||
--outputdir /opt/qt \
|
|
||||||
--modules qtimageformats qtnetworkauth
|
|
||||||
|
|
||||||
ENV PATH=/opt/qt/${QT_VERSION}/${QT_ABI}/bin:$PATH
|
|
||||||
ENV QT_PLUGIN_PATH=/opt/qt/${QT_VERSION}/${QT_ABI}/plugins/
|
|
||||||
|
|
||||||
## We don't use these. Nuke them
|
|
||||||
RUN rm -rf \
|
|
||||||
"$QT_PLUGIN_PATH"/designer \
|
|
||||||
"$QT_PLUGIN_PATH"/help \
|
|
||||||
# "$QT_PLUGIN_PATH"/platformthemes/libqgtk3.so \
|
|
||||||
"$QT_PLUGIN_PATH"/printsupport \
|
|
||||||
"$QT_PLUGIN_PATH"/qmllint \
|
|
||||||
"$QT_PLUGIN_PATH"/qmlls \
|
|
||||||
"$QT_PLUGIN_PATH"/qmltooling \
|
|
||||||
"$QT_PLUGIN_PATH"/sqldrivers
|
|
||||||
|
|
||||||
# Setup workspace
|
|
||||||
RUN mkdir /work
|
|
||||||
WORKDIR /work
|
|
||||||
|
|
||||||
ENTRYPOINT ["bash"]
|
|
||||||
CMD ["-i"]
|
|
||||||
15
README.md
15
README.md
|
|
@ -27,13 +27,17 @@ Please understand that these builds are not intended for most users. There may b
|
||||||
There are development builds available through:
|
There are development builds available through:
|
||||||
|
|
||||||
- [GitHub Actions](https://github.com/PrismLauncher/PrismLauncher/actions) (includes builds from pull requests opened by contributors)
|
- [GitHub Actions](https://github.com/PrismLauncher/PrismLauncher/actions) (includes builds from pull requests opened by contributors)
|
||||||
- [nightly.link](https://prismlauncher.org/nightly) (this will always point only to the latest version of develop)
|
- [nightly.link](https://nightly.link/PrismLauncher/PrismLauncher/workflows/build/develop) (this will always point only to the latest version of develop)
|
||||||
|
|
||||||
These have debug information in the binaries, so their file sizes are relatively larger.
|
These have debug information in the binaries, so their file sizes are relatively larger.
|
||||||
|
|
||||||
Prebuilt Development builds are provided for **Linux**, **Windows** and **macOS**.
|
Prebuilt Development builds are provided for **Linux**, **Windows** and **macOS**.
|
||||||
|
|
||||||
On Linux, we also offer our own [Flatpak nightly repository](https://github.com/PrismLauncher/flatpak). Most software centers are able to install it by opening [this link](https://flatpak.prismlauncher.org/prismlauncher-nightly.flatpakref).
|
For **Arch**, **Debian**, **Fedora**, **OpenSUSE (Tumbleweed)** and **Gentoo**, respectively, you can use these packages for the latest development versions:
|
||||||
|
|
||||||
|
[](https://aur.archlinux.org/packages/prismlauncher-git) [](https://aur.archlinux.org/packages/prismlauncher-qt5-git) [](https://mpr.makedeb.org/packages/prismlauncher-git)<br />[](https://copr.fedorainfracloud.org/coprs/g3tchoo/prismlauncher/) [](https://build.opensuse.org/project/show/home:getchoo) [](https://packages.gentoo.org/packages/games-action/prismlauncher)
|
||||||
|
|
||||||
|
These packages are also available to all the distributions based on the ones mentioned above.
|
||||||
|
|
||||||
## Community & Support
|
## Community & Support
|
||||||
|
|
||||||
|
|
@ -57,7 +61,12 @@ The translation effort for Prism Launcher is hosted on [Weblate](https://hosted.
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
If you want to build Prism Launcher yourself, check the [build instructions](https://prismlauncher.org/wiki/development/build-instructions).
|
If you want to build Prism Launcher yourself, check the build instructions:
|
||||||
|
|
||||||
|
- [Windows](https://prismlauncher.org/wiki/development/build-instructions/windows/)
|
||||||
|
- [Linux](https://prismlauncher.org/wiki/development/build-instructions/linux/)
|
||||||
|
- [MacOS](https://prismlauncher.org/wiki/development/build-instructions/macos/)
|
||||||
|
- [OpenBSD](https://prismlauncher.org/wiki/development/build-instructions/openbsd/)
|
||||||
|
|
||||||
## Sponsors & Partners
|
## Sponsors & Partners
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <qstringliteral.h>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "BuildConfig.h"
|
#include "BuildConfig.h"
|
||||||
|
|
||||||
|
|
@ -50,7 +51,6 @@ Config::Config()
|
||||||
LAUNCHER_GIT = "@Launcher_Git@";
|
LAUNCHER_GIT = "@Launcher_Git@";
|
||||||
LAUNCHER_APPID = "@Launcher_AppID@";
|
LAUNCHER_APPID = "@Launcher_AppID@";
|
||||||
LAUNCHER_SVGFILENAME = "@Launcher_SVGFileName@";
|
LAUNCHER_SVGFILENAME = "@Launcher_SVGFileName@";
|
||||||
LAUNCHER_ENVNAME = "@Launcher_ENVName@";
|
|
||||||
|
|
||||||
USER_AGENT = "@Launcher_UserAgent@";
|
USER_AGENT = "@Launcher_UserAgent@";
|
||||||
|
|
||||||
|
|
@ -106,14 +106,13 @@ Config::Config()
|
||||||
|
|
||||||
NEWS_RSS_URL = "@Launcher_NEWS_RSS_URL@";
|
NEWS_RSS_URL = "@Launcher_NEWS_RSS_URL@";
|
||||||
NEWS_OPEN_URL = "@Launcher_NEWS_OPEN_URL@";
|
NEWS_OPEN_URL = "@Launcher_NEWS_OPEN_URL@";
|
||||||
WIKI_URL = "@Launcher_WIKI_URL@";
|
|
||||||
HELP_URL = "@Launcher_HELP_URL@";
|
HELP_URL = "@Launcher_HELP_URL@";
|
||||||
LOGIN_CALLBACK_URL = "@Launcher_LOGIN_CALLBACK_URL@";
|
LOGIN_CALLBACK_URL = "@Launcher_LOGIN_CALLBACK_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@";
|
||||||
FLAME_API_KEY = "@Launcher_CURSEFORGE_API_KEY@";
|
FLAME_API_KEY = "@Launcher_CURSEFORGE_API_KEY@";
|
||||||
META_URL = "@Launcher_META_URL@";
|
META_URL = "@Launcher_META_URL@";
|
||||||
LEGACY_FMLLIBS_BASE_URL = "@Launcher_LEGACY_FMLLIBS_BASE_URL@";
|
FMLLIBS_BASE_URL = "@Launcher_FMLLIBS_BASE_URL@";
|
||||||
|
|
||||||
GLFW_LIBRARY_NAME = "@Launcher_GLFW_LIBRARY_NAME@";
|
GLFW_LIBRARY_NAME = "@Launcher_GLFW_LIBRARY_NAME@";
|
||||||
OPENAL_LIBRARY_NAME = "@Launcher_OPENAL_LIBRARY_NAME@";
|
OPENAL_LIBRARY_NAME = "@Launcher_OPENAL_LIBRARY_NAME@";
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,6 @@ class Config {
|
||||||
QString LAUNCHER_GIT;
|
QString LAUNCHER_GIT;
|
||||||
QString LAUNCHER_APPID;
|
QString LAUNCHER_APPID;
|
||||||
QString LAUNCHER_SVGFILENAME;
|
QString LAUNCHER_SVGFILENAME;
|
||||||
QString LAUNCHER_ENVNAME;
|
|
||||||
|
|
||||||
/// The major version number.
|
/// The major version number.
|
||||||
int VERSION_MAJOR;
|
int VERSION_MAJOR;
|
||||||
|
|
@ -129,12 +128,7 @@ class Config {
|
||||||
QString NEWS_OPEN_URL;
|
QString NEWS_OPEN_URL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URL that gets opened when the user clicks 'Launcher Help'
|
* URL (with arg %1 to be substituted with page-id) that gets opened when the user requests help
|
||||||
*/
|
|
||||||
QString WIKI_URL;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* URL (with arg %1 to be substituted with page-id) that gets opened when the user requests help in a dialog window
|
|
||||||
*/
|
*/
|
||||||
QString HELP_URL;
|
QString HELP_URL;
|
||||||
|
|
||||||
|
|
@ -175,10 +169,10 @@ class Config {
|
||||||
QString DEFAULT_RESOURCE_BASE = "https://resources.download.minecraft.net/";
|
QString DEFAULT_RESOURCE_BASE = "https://resources.download.minecraft.net/";
|
||||||
QString LIBRARY_BASE = "https://libraries.minecraft.net/";
|
QString LIBRARY_BASE = "https://libraries.minecraft.net/";
|
||||||
QString IMGUR_BASE_URL = "https://api.imgur.com/3/";
|
QString IMGUR_BASE_URL = "https://api.imgur.com/3/";
|
||||||
QString LEGACY_FMLLIBS_BASE_URL;
|
QString FMLLIBS_BASE_URL;
|
||||||
QString TRANSLATION_FILES_URL;
|
QString TRANSLATION_FILES_URL;
|
||||||
|
|
||||||
QString FTB_API_BASE_URL = "https://api.feed-the-beast.com/v1/modpacks/public";
|
QString MODPACKSCH_API_BASE_URL = "https://api.modpacks.ch/";
|
||||||
|
|
||||||
QString LEGACY_FTB_CDN_BASE_URL = "https://dist.creeper.host/FTB2/";
|
QString LEGACY_FTB_CDN_BASE_URL = "https://dist.creeper.host/FTB2/";
|
||||||
|
|
||||||
|
|
@ -194,10 +188,8 @@ 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";
|
||||||
QStringList MODRINTH_MRPACK_HOSTS{ "cdn.modrinth.com", "github.com", "raw.githubusercontent.com", "gitlab.com" };
|
QStringList MODRINTH_MRPACK_HOSTS{ "cdn.modrinth.com", "github.com", "raw.githubusercontent.com", "gitlab.com" };
|
||||||
QString MODRINTH_DOWNLOAD_HOST = "cdn.modrinth.com";
|
|
||||||
|
|
||||||
QString FLAME_BASE_URL = "https://api.curseforge.com/v1";
|
QString FLAME_BASE_URL = "https://api.curseforge.com/v1";
|
||||||
QString FLAME_DOWNLOAD_HOST = "edge.forgecdn.net";
|
|
||||||
|
|
||||||
QString versionString() const;
|
QString versionString() const;
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
163
cmake/CompilerWarnings.cmake
Normal file
163
cmake/CompilerWarnings.cmake
Normal file
|
|
@ -0,0 +1,163 @@
|
||||||
|
#
|
||||||
|
# Function to set compiler warnings with reasonable defaults at the project level.
|
||||||
|
# Taken from https://github.com/aminya/project_options/blob/main/src/CompilerWarnings.cmake
|
||||||
|
# under the folowing license:
|
||||||
|
#
|
||||||
|
# MIT License
|
||||||
|
#
|
||||||
|
# Copyright (c) 2022-2100 Amin Yahyaabadi
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
# in the Software without restriction, including without limitation the rights
|
||||||
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
# copies of the Software, and to permit persons to whom the Software is
|
||||||
|
# furnished to do so, subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
# SOFTWARE.
|
||||||
|
#
|
||||||
|
|
||||||
|
include_guard()
|
||||||
|
|
||||||
|
function(_set_project_warnings_add_target_link_option TARGET OPTIONS)
|
||||||
|
target_link_options(${_project_name} INTERFACE ${OPTIONS})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Set the compiler warnings
|
||||||
|
#
|
||||||
|
# https://clang.llvm.org/docs/DiagnosticsReference.html
|
||||||
|
# https://github.com/lefticus/cppbestpractices/blob/master/02-Use_the_Tools_Available.md
|
||||||
|
function(
|
||||||
|
set_project_warnings
|
||||||
|
_project_name
|
||||||
|
MSVC_WARNINGS
|
||||||
|
CLANG_WARNINGS
|
||||||
|
GCC_WARNINGS
|
||||||
|
)
|
||||||
|
if("${MSVC_WARNINGS}" STREQUAL "")
|
||||||
|
set(MSVC_WARNINGS
|
||||||
|
/W4 # Baseline reasonable warnings
|
||||||
|
/w14242 # 'identifier': conversion from 'type1' to 'type1', possible loss of data
|
||||||
|
/w14254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data
|
||||||
|
/w14263 # 'function': member function does not override any base class virtual member function
|
||||||
|
/w14265 # 'classname': class has virtual functions, but destructor is not virtual instances of this class may not
|
||||||
|
# be destructed correctly
|
||||||
|
/w14287 # 'operator': unsigned/negative constant mismatch
|
||||||
|
/we4289 # nonstandard extension used: 'variable': loop control variable declared in the for-loop is used outside
|
||||||
|
# the for-loop scope
|
||||||
|
/w14296 # 'operator': expression is always 'boolean_value'
|
||||||
|
/w14311 # 'variable': pointer truncation from 'type1' to 'type2'
|
||||||
|
/w14545 # expression before comma evaluates to a function which is missing an argument list
|
||||||
|
/w14546 # function call before comma missing argument list
|
||||||
|
/w14547 # 'operator': operator before comma has no effect; expected operator with side-effect
|
||||||
|
/w14549 # 'operator': operator before comma has no effect; did you intend 'operator'?
|
||||||
|
/w14555 # expression has no effect; expected expression with side- effect
|
||||||
|
/w14619 # pragma warning: there is no warning number 'number'
|
||||||
|
/w14640 # Enable warning on thread un-safe static member initialization
|
||||||
|
/w14826 # Conversion from 'type1' to 'type_2' is sign-extended. This may cause unexpected runtime behavior.
|
||||||
|
/w14905 # wide string literal cast to 'LPSTR'
|
||||||
|
/w14906 # string literal cast to 'LPWSTR'
|
||||||
|
/w14928 # illegal copy-initialization; more than one user-defined conversion has been implicitly applied
|
||||||
|
/permissive- # standards conformance mode for MSVC compiler.
|
||||||
|
|
||||||
|
/we4062 # forbid omitting a possible value of an enum in a switch statement
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if("${CLANG_WARNINGS}" STREQUAL "")
|
||||||
|
set(CLANG_WARNINGS
|
||||||
|
-Wall
|
||||||
|
-Wextra # reasonable and standard
|
||||||
|
-Wshadow # warn the user if a variable declaration shadows one from a parent context
|
||||||
|
-Wnon-virtual-dtor # warn the user if a class with virtual functions has a non-virtual destructor. This helps
|
||||||
|
# catch hard to track down memory errors
|
||||||
|
-Wold-style-cast # warn for c-style casts
|
||||||
|
-Wcast-align # warn for potential performance problem casts
|
||||||
|
-Wunused # warn on anything being unused
|
||||||
|
-Woverloaded-virtual # warn if you overload (not override) a virtual function
|
||||||
|
-Wpedantic # warn if non-standard C++ is used
|
||||||
|
-Wconversion # warn on type conversions that may lose data
|
||||||
|
-Wsign-conversion # warn on sign conversions
|
||||||
|
-Wnull-dereference # warn if a null dereference is detected
|
||||||
|
-Wdouble-promotion # warn if float is implicit promoted to double
|
||||||
|
-Wformat=2 # warn on security issues around functions that format output (ie printf)
|
||||||
|
-Wimplicit-fallthrough # warn on statements that fallthrough without an explicit annotation
|
||||||
|
# -Wgnu-zero-variadic-macro-arguments (part of -pedantic) is triggered by every qCDebug() call and therefore results
|
||||||
|
# in a lot of noise. This warning is only notifying us that clang is emulating the GCC behaviour
|
||||||
|
# instead of the exact standard wording so we can safely ignore it
|
||||||
|
-Wno-gnu-zero-variadic-macro-arguments
|
||||||
|
|
||||||
|
-Werror=switch # forbid omitting a possible value of an enum in a switch statement
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if("${GCC_WARNINGS}" STREQUAL "")
|
||||||
|
set(GCC_WARNINGS
|
||||||
|
${CLANG_WARNINGS}
|
||||||
|
-Wmisleading-indentation # warn if indentation implies blocks where blocks do not exist
|
||||||
|
-Wduplicated-cond # warn if if / else chain has duplicated conditions
|
||||||
|
-Wduplicated-branches # warn if if / else branches have duplicated code
|
||||||
|
-Wlogical-op # warn about logical operations being used where bitwise were probably wanted
|
||||||
|
-Wuseless-cast # warn if you perform a cast to the same type
|
||||||
|
|
||||||
|
-Werror=switch # forbid omitting a possible value of an enum in a switch statement
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
set(PROJECT_WARNINGS_CXX ${MSVC_WARNINGS})
|
||||||
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
|
||||||
|
set(PROJECT_WARNINGS_CXX ${CLANG_WARNINGS})
|
||||||
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
|
set(PROJECT_WARNINGS_CXX ${GCC_WARNINGS})
|
||||||
|
else()
|
||||||
|
message(AUTHOR_WARNING "No compiler warnings set for CXX compiler: '${CMAKE_CXX_COMPILER_ID}'")
|
||||||
|
# TODO support Intel compiler
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Add C warnings
|
||||||
|
set(PROJECT_WARNINGS_C "${PROJECT_WARNINGS_CXX}")
|
||||||
|
list(
|
||||||
|
REMOVE_ITEM
|
||||||
|
PROJECT_WARNINGS_C
|
||||||
|
-Wnon-virtual-dtor
|
||||||
|
-Wold-style-cast
|
||||||
|
-Woverloaded-virtual
|
||||||
|
-Wuseless-cast
|
||||||
|
-Wextra-semi
|
||||||
|
|
||||||
|
-Werror=switch # forbid omitting a possible value of an enum in a switch statement
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_options(
|
||||||
|
${_project_name}
|
||||||
|
INTERFACE # C++ warnings
|
||||||
|
$<$<COMPILE_LANGUAGE:CXX>:${PROJECT_WARNINGS_CXX}>
|
||||||
|
# C warnings
|
||||||
|
$<$<COMPILE_LANGUAGE:C>:${PROJECT_WARNINGS_C}>
|
||||||
|
)
|
||||||
|
|
||||||
|
# If we are using the compiler as a linker driver pass the warnings to it
|
||||||
|
# (most useful when using LTO or warnings as errors)
|
||||||
|
if(CMAKE_CXX_LINK_EXECUTABLE MATCHES "^<CMAKE_CXX_COMPILER>")
|
||||||
|
_set_project_warnings_add_target_link_option(
|
||||||
|
${_project_name} "$<$<COMPILE_LANGUAGE:CXX>:${PROJECT_WARNINGS_CXX}>"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_C_LINK_EXECUTABLE MATCHES "^<CMAKE_C_COMPILER>")
|
||||||
|
_set_project_warnings_add_target_link_option(
|
||||||
|
${_project_name} "$<$<COMPILE_LANGUAGE:C>:${PROJECT_WARNINGS_C}>"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endfunction()
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
<key>NSMicrophoneUsageDescription</key>
|
<key>NSMicrophoneUsageDescription</key>
|
||||||
<string>A Minecraft mod wants to access your microphone.</string>
|
<string>A Minecraft mod wants to access your microphone.</string>
|
||||||
<key>NSDownloadsFolderUsageDescription</key>
|
<key>NSDownloadsFolderUsageDescription</key>
|
||||||
<string>${Launcher_DisplayName} uses access to your Downloads folder to help you more quickly add mods that can't be automatically downloaded to your instance. You can change where ${Launcher_DisplayName} scans for downloaded mods in Settings or the prompt that appears.</string>
|
<string>Prism uses access to your Downloads folder to help you more quickly add mods that can't be automatically downloaded to your instance. You can change where Prism scans for downloaded mods in Settings or the prompt that appears.</string>
|
||||||
<key>NSLocalNetworkUsageDescription</key>
|
<key>NSLocalNetworkUsageDescription</key>
|
||||||
<string>Minecraft uses the local network to find and connect to LAN servers.</string>
|
<string>Minecraft uses the local network to find and connect to LAN servers.</string>
|
||||||
<key>NSPrincipalClass</key>
|
<key>NSPrincipalClass</key>
|
||||||
|
|
@ -44,8 +44,6 @@
|
||||||
<true/>
|
<true/>
|
||||||
<key>LSRequiresCarbon</key>
|
<key>LSRequiresCarbon</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>LSApplicationCategoryType</key>
|
|
||||||
<string>public.app-category.games</string>
|
|
||||||
<key>NSHumanReadableCopyright</key>
|
<key>NSHumanReadableCopyright</key>
|
||||||
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
|
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
|
||||||
<key>SUPublicEDKey</key>
|
<key>SUPublicEDKey</key>
|
||||||
|
|
@ -61,7 +59,7 @@
|
||||||
<string>mrpack</string>
|
<string>mrpack</string>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleTypeName</key>
|
<key>CFBundleTypeName</key>
|
||||||
<string>${Launcher_DisplayName} instance</string>
|
<string>Prism Launcher instance</string>
|
||||||
<key>CFBundleTypeOSTypes</key>
|
<key>CFBundleTypeOSTypes</key>
|
||||||
<array>
|
<array>
|
||||||
<string>TEXT</string>
|
<string>TEXT</string>
|
||||||
|
|
@ -87,11 +85,10 @@
|
||||||
</dict>
|
</dict>
|
||||||
<dict>
|
<dict>
|
||||||
<key>CFBundleURLName</key>
|
<key>CFBundleURLName</key>
|
||||||
<string>${Launcher_Name}</string>
|
<string>Prismlauncher</string>
|
||||||
<key>CFBundleURLSchemes</key>
|
<key>CFBundleURLSchemes</key>
|
||||||
<array>
|
<array>
|
||||||
<string>prismlauncher</string>
|
<string>prismlauncher</string>
|
||||||
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
|
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
|
|
|
||||||
16
flake.lock
generated
16
flake.lock
generated
|
|
@ -3,11 +3,11 @@
|
||||||
"libnbtplusplus": {
|
"libnbtplusplus": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1772016279,
|
"lastModified": 1744811532,
|
||||||
"narHash": "sha256-7itkptyjoRcXfGLwg1/jxajetZ3a4mDc66+w4X6yW8s=",
|
"narHash": "sha256-qhmjaRkt+O7A+gu6HjUkl7QzOEb4r8y8vWZMG2R/C6o=",
|
||||||
"owner": "PrismLauncher",
|
"owner": "PrismLauncher",
|
||||||
"repo": "libnbtplusplus",
|
"repo": "libnbtplusplus",
|
||||||
"rev": "687e43031df0dc641984b4256bcca50d5b3f7de3",
|
"rev": "531449ba1c930c98e0bcf5d332b237a8566f9d78",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -18,15 +18,15 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1778443072,
|
"lastModified": 1766473571,
|
||||||
"narHash": "sha256-rNDJzV2JTV5SUTwv1cgKZYMdyoUYU9/YfegSaUf3QfY=",
|
"narHash": "sha256-QvjEJNgMVuOootbR+DEfbiW+zSK57U32CE0jmVdcNjQ=",
|
||||||
"rev": "da5ad661ba4e5ef59ba743f0d112cbc30e474f32",
|
"rev": "76701a179d3a98b07653e2b0409847499b2a07d3",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://releases.nixos.org/nixos/unstable/nixos-26.05pre995699.da5ad661ba4e/nixexprs.tar.xz"
|
"url": "https://releases.nixos.org/nixos/25.11/nixos-25.11.2403.76701a179d3a/nixexprs.tar.xz"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz"
|
"url": "https://channels.nixos.org/nixos-25.11/nixexprs.tar.xz"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
|
|
|
||||||
44
flake.nix
44
flake.nix
|
|
@ -9,7 +9,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz";
|
nixpkgs.url = "https://channels.nixos.org/nixos-25.11/nixexprs.tar.xz";
|
||||||
|
|
||||||
libnbtplusplus = {
|
libnbtplusplus = {
|
||||||
url = "github:PrismLauncher/libnbtplusplus";
|
url = "github:PrismLauncher/libnbtplusplus";
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
let
|
let
|
||||||
pkgs = nixpkgsFor.${system};
|
pkgs = nixpkgsFor.${system};
|
||||||
llvm = pkgs.llvmPackages_22;
|
llvm = pkgs.llvmPackages_19;
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -85,9 +85,7 @@
|
||||||
|
|
||||||
let
|
let
|
||||||
pkgs = nixpkgsFor.${system};
|
pkgs = nixpkgsFor.${system};
|
||||||
llvm = pkgs.llvmPackages_22;
|
llvm = pkgs.llvmPackages_19;
|
||||||
python = pkgs.python3;
|
|
||||||
mkShell = pkgs.mkShell.override { inherit (llvm) stdenv; };
|
|
||||||
|
|
||||||
packages' = self.packages.${system};
|
packages' = self.packages.${system};
|
||||||
|
|
||||||
|
|
@ -133,36 +131,18 @@
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
default = mkShell {
|
default = pkgs.mkShell {
|
||||||
name = "prism-launcher";
|
name = "prism-launcher";
|
||||||
|
|
||||||
inputsFrom = [ packages'.prismlauncher-unwrapped ];
|
inputsFrom = [ packages'.prismlauncher-unwrapped ];
|
||||||
|
|
||||||
packages = [
|
packages = with pkgs; [
|
||||||
pkgs.ccache
|
ccache
|
||||||
llvm.clang-tools
|
llvm.clang-tools
|
||||||
python # NOTE(@getchoo): Required for run-clang-tidy, etc.
|
|
||||||
|
|
||||||
(pkgs.stdenvNoCC.mkDerivation {
|
|
||||||
pname = "clang-tidy-diff";
|
|
||||||
inherit (llvm.clang) version;
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
|
||||||
pkgs.installShellFiles
|
|
||||||
python.pkgs.wrapPython
|
|
||||||
];
|
|
||||||
|
|
||||||
dontUnpack = true;
|
|
||||||
dontConfigure = true;
|
|
||||||
dontBuild = true;
|
|
||||||
|
|
||||||
postInstall = "installBin ${llvm.libclang.python}/share/clang/clang-tidy-diff.py";
|
|
||||||
postFixup = "wrapPythonPrograms";
|
|
||||||
})
|
|
||||||
];
|
];
|
||||||
|
|
||||||
cmakeBuildType = "Debug";
|
cmakeBuildType = "Debug";
|
||||||
cmakeFlags = [ "-GNinja" ] ++ packages'.prismlauncher-unwrapped.cmakeFlags;
|
cmakeFlags = [ "-GNinja" ] ++ packages'.prismlauncher.cmakeFlags;
|
||||||
dontFixCmake = true;
|
dontFixCmake = true;
|
||||||
|
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
|
|
@ -185,16 +165,8 @@
|
||||||
|
|
||||||
formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style);
|
formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style);
|
||||||
|
|
||||||
overlays.default =
|
overlays.default = final: prev: {
|
||||||
final: prev:
|
|
||||||
|
|
||||||
let
|
|
||||||
llvm = final.llvmPackages_22 or prev.llvmPackages_22;
|
|
||||||
in
|
|
||||||
|
|
||||||
{
|
|
||||||
prismlauncher-unwrapped = prev.callPackage ./nix/unwrapped.nix {
|
prismlauncher-unwrapped = prev.callPackage ./nix/unwrapped.nix {
|
||||||
inherit (llvm) stdenv;
|
|
||||||
inherit
|
inherit
|
||||||
libnbtplusplus
|
libnbtplusplus
|
||||||
self
|
self
|
||||||
|
|
|
||||||
14
flatpak/cmark.yml
Normal file
14
flatpak/cmark.yml
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
name: cmark
|
||||||
|
buildsystem: cmake-ninja
|
||||||
|
builddir: true
|
||||||
|
config-opts:
|
||||||
|
- -DCMAKE_TESTS=OFF
|
||||||
|
sources:
|
||||||
|
- type: archive
|
||||||
|
url: https://github.com/commonmark/cmark/archive/0.31.1.tar.gz
|
||||||
|
sha256: 3da93db5469c30588cfeb283d9d62edfc6ded9eb0edc10a4f5bbfb7d722ea802
|
||||||
|
x-checker-data:
|
||||||
|
type: anitya
|
||||||
|
project-id: 9159
|
||||||
|
stable-only: true
|
||||||
|
url-template: https://github.com/commonmark/cmark/archive/$version.tar.gz
|
||||||
20
flatpak/flite.json
Normal file
20
flatpak/flite.json
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"name": "flite",
|
||||||
|
"config-opts": [
|
||||||
|
"--enable-shared",
|
||||||
|
"--with-audio=pulseaudio"
|
||||||
|
],
|
||||||
|
"no-parallel-make": true,
|
||||||
|
"sources": [
|
||||||
|
{
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/festvox/flite.git",
|
||||||
|
"tag": "v2.2",
|
||||||
|
"commit": "e9e2e37c329dbe98bfeb27a1828ef9a71fa84f88",
|
||||||
|
"x-checker-data": {
|
||||||
|
"type": "git",
|
||||||
|
"tag-pattern": "^v([\\d.]+)$"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
18
flatpak/libdecor.json
Normal file
18
flatpak/libdecor.json
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"name": "libdecor",
|
||||||
|
"buildsystem": "meson",
|
||||||
|
"config-opts": [
|
||||||
|
"-Ddemo=false"
|
||||||
|
],
|
||||||
|
"sources": [
|
||||||
|
{
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://gitlab.freedesktop.org/libdecor/libdecor.git",
|
||||||
|
"commit": "c2bd8ad6fa42c0cb17553ce77ad8a87d1f543b1f"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"cleanup": [
|
||||||
|
"/include",
|
||||||
|
"/lib/pkgconfig"
|
||||||
|
]
|
||||||
|
}
|
||||||
154
flatpak/org.prismlauncher.PrismLauncher.yml
Normal file
154
flatpak/org.prismlauncher.PrismLauncher.yml
Normal file
|
|
@ -0,0 +1,154 @@
|
||||||
|
id: org.prismlauncher.PrismLauncher
|
||||||
|
runtime: org.kde.Platform
|
||||||
|
runtime-version: '6.10'
|
||||||
|
sdk: org.kde.Sdk
|
||||||
|
sdk-extensions:
|
||||||
|
- org.freedesktop.Sdk.Extension.openjdk17
|
||||||
|
|
||||||
|
command: prismlauncher
|
||||||
|
finish-args:
|
||||||
|
- --share=ipc
|
||||||
|
- --socket=x11
|
||||||
|
- --socket=wayland
|
||||||
|
- --device=all
|
||||||
|
- --share=network
|
||||||
|
- --socket=pulseaudio
|
||||||
|
# for Discord RPC mods
|
||||||
|
- --filesystem=xdg-run/app/com.discordapp.Discord:create
|
||||||
|
# Mod drag&drop
|
||||||
|
- --filesystem=xdg-download:ro
|
||||||
|
# FTBApp import
|
||||||
|
- --filesystem=~/.ftba:ro
|
||||||
|
# Userspace visibility for manual hugepages configuration
|
||||||
|
# Required for -XX:+UseLargePages
|
||||||
|
- --filesystem=/sys/kernel/mm/hugepages:ro
|
||||||
|
# Userspace visibility for transparent hugepages configuration
|
||||||
|
# Required for -XX:+UseTransparentHugePages
|
||||||
|
- --filesystem=/sys/kernel/mm/transparent_hugepage:ro
|
||||||
|
|
||||||
|
modules:
|
||||||
|
- cmark.yml
|
||||||
|
- tomlplusplus.yml
|
||||||
|
|
||||||
|
# Might be needed by some Controller mods (see https://github.com/isXander/Controlify/issues/31)
|
||||||
|
- shared-modules/libusb/libusb.json
|
||||||
|
|
||||||
|
# Needed for proper Wayland support
|
||||||
|
- libdecor.json
|
||||||
|
|
||||||
|
# Text to Speech in the game
|
||||||
|
- flite.json
|
||||||
|
|
||||||
|
- name: prismlauncher
|
||||||
|
buildsystem: cmake-ninja
|
||||||
|
builddir: true
|
||||||
|
config-opts:
|
||||||
|
- -DLauncher_BUILD_PLATFORM=flatpak
|
||||||
|
# This allows us to manage and update Java independently of this Flatpak
|
||||||
|
- -DLauncher_ENABLE_JAVA_DOWNLOADER=ON
|
||||||
|
- -DCMAKE_BUILD_TYPE=RelWithDebInfo
|
||||||
|
build-options:
|
||||||
|
env:
|
||||||
|
JAVA_HOME: /usr/lib/sdk/openjdk17/jvm/openjdk-17
|
||||||
|
JAVA_COMPILER: /usr/lib/sdk/openjdk17/jvm/openjdk-17/bin/javac
|
||||||
|
run-tests: true
|
||||||
|
sources:
|
||||||
|
- type: dir
|
||||||
|
path: ../
|
||||||
|
|
||||||
|
- name: glfw
|
||||||
|
buildsystem: cmake-ninja
|
||||||
|
config-opts:
|
||||||
|
- -DCMAKE_BUILD_TYPE=RelWithDebInfo
|
||||||
|
- -DBUILD_SHARED_LIBS:BOOL=ON
|
||||||
|
- -DGLFW_BUILD_WAYLAND:BOOL=ON
|
||||||
|
- -DGLFW_BUILD_DOCS:BOOL=OFF
|
||||||
|
sources:
|
||||||
|
- type: git
|
||||||
|
url: https://github.com/glfw/glfw.git
|
||||||
|
commit: 7b6aead9fb88b3623e3b3725ebb42670cbe4c579 # 3.4
|
||||||
|
- type: patch
|
||||||
|
path: patches/0009-Defer-setting-cursor-position-until-the-cursor-is-lo.patch
|
||||||
|
cleanup:
|
||||||
|
- /include
|
||||||
|
- /lib/cmake
|
||||||
|
- /lib/pkgconfig
|
||||||
|
|
||||||
|
- name: xrandr
|
||||||
|
buildsystem: autotools
|
||||||
|
sources:
|
||||||
|
- type: archive
|
||||||
|
url: https://xorg.freedesktop.org/archive/individual/app/xrandr-1.5.3.tar.xz
|
||||||
|
sha256: f8dd7566adb74147fab9964680b6bbadee87cf406a7fcff51718a5e6949b841c
|
||||||
|
x-checker-data:
|
||||||
|
type: anitya
|
||||||
|
project-id: 14957
|
||||||
|
stable-only: true
|
||||||
|
url-template: https://xorg.freedesktop.org/archive/individual/app/xrandr-$version.tar.xz
|
||||||
|
cleanup:
|
||||||
|
- /share/man
|
||||||
|
- /bin/xkeystone
|
||||||
|
|
||||||
|
- name: gamemode
|
||||||
|
buildsystem: meson
|
||||||
|
config-opts:
|
||||||
|
- -Dwith-sd-bus-provider=no-daemon
|
||||||
|
- -Dwith-examples=false
|
||||||
|
post-install:
|
||||||
|
# gamemoderun is installed for users who want to use wrapper commands
|
||||||
|
# post-install is running inside the build dir, we need it from the source though
|
||||||
|
- install -Dm755 ../data/gamemoderun -t /app/bin
|
||||||
|
sources:
|
||||||
|
- type: archive
|
||||||
|
dest-filename: gamemode.tar.gz
|
||||||
|
url: https://api.github.com/repos/FeralInteractive/gamemode/tarball/1.8.2
|
||||||
|
sha256: 2886d4ce543c78bd2a364316d5e7fd59ef06b71de63f896b37c6d3dc97658f60
|
||||||
|
x-checker-data:
|
||||||
|
type: json
|
||||||
|
url: https://api.github.com/repos/FeralInteractive/gamemode/releases/latest
|
||||||
|
version-query: .tag_name
|
||||||
|
url-query: .tarball_url
|
||||||
|
timestamp-query: .published_at
|
||||||
|
cleanup:
|
||||||
|
- /include
|
||||||
|
- /lib/pkgconfig
|
||||||
|
- /lib/libgamemodeauto.a
|
||||||
|
|
||||||
|
- name: glxinfo
|
||||||
|
buildsystem: meson
|
||||||
|
config-opts:
|
||||||
|
- --bindir=/app/mesa-demos
|
||||||
|
- -Degl=disabled
|
||||||
|
- -Dglut=disabled
|
||||||
|
- -Dosmesa=disabled
|
||||||
|
- -Dvulkan=disabled
|
||||||
|
- -Dwayland=disabled
|
||||||
|
post-install:
|
||||||
|
- mv -v /app/mesa-demos/glxinfo /app/bin
|
||||||
|
sources:
|
||||||
|
- type: archive
|
||||||
|
url: https://archive.mesa3d.org/demos/mesa-demos-9.0.0.tar.xz
|
||||||
|
sha256: 3046a3d26a7b051af7ebdd257a5f23bfeb160cad6ed952329cdff1e9f1ed496b
|
||||||
|
x-checker-data:
|
||||||
|
type: anitya
|
||||||
|
project-id: 16781
|
||||||
|
stable-only: true
|
||||||
|
url-template: https://archive.mesa3d.org/demos/mesa-demos-$version.tar.xz
|
||||||
|
cleanup:
|
||||||
|
- /include
|
||||||
|
- /mesa-demos
|
||||||
|
- /share
|
||||||
|
modules:
|
||||||
|
- shared-modules/glu/glu-9.json
|
||||||
|
|
||||||
|
- name: enhance
|
||||||
|
buildsystem: simple
|
||||||
|
build-commands:
|
||||||
|
- install -Dm755 prime-run /app/bin/prime-run
|
||||||
|
- mv /app/bin/prismlauncher /app/bin/prismrun
|
||||||
|
- install -Dm755 prismlauncher /app/bin/prismlauncher
|
||||||
|
sources:
|
||||||
|
- type: file
|
||||||
|
path: prime-run
|
||||||
|
- type: file
|
||||||
|
path: prismlauncher
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
From 9997ae55a47de469ea26f8437c30b51483abda5f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Dan Klishch <danilklishch@gmail.com>
|
||||||
|
Date: Sat, 30 Sep 2023 23:38:05 -0400
|
||||||
|
Subject: Defer setting cursor position until the cursor is locked
|
||||||
|
|
||||||
|
---
|
||||||
|
src/wl_platform.h | 3 +++
|
||||||
|
src/wl_window.c | 14 ++++++++++++--
|
||||||
|
2 files changed, 15 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/wl_platform.h b/src/wl_platform.h
|
||||||
|
index ca34f66e..cd1f227f 100644
|
||||||
|
--- a/src/wl_platform.h
|
||||||
|
+++ b/src/wl_platform.h
|
||||||
|
@@ -403,6 +403,9 @@ typedef struct _GLFWwindowWayland
|
||||||
|
int scaleSize;
|
||||||
|
int compositorPreferredScale;
|
||||||
|
|
||||||
|
+ double askedCursorPosX, askedCursorPosY;
|
||||||
|
+ GLFWbool didAskForSetCursorPos;
|
||||||
|
+
|
||||||
|
struct zwp_relative_pointer_v1* relativePointer;
|
||||||
|
struct zwp_locked_pointer_v1* lockedPointer;
|
||||||
|
struct zwp_confined_pointer_v1* confinedPointer;
|
||||||
|
diff --git a/src/wl_window.c b/src/wl_window.c
|
||||||
|
index 1de26558..0df16747 100644
|
||||||
|
--- a/src/wl_window.c
|
||||||
|
+++ b/src/wl_window.c
|
||||||
|
@@ -2586,8 +2586,9 @@ void _glfwGetCursorPosWayland(_GLFWwindow* window, double* xpos, double* ypos)
|
||||||
|
|
||||||
|
void _glfwSetCursorPosWayland(_GLFWwindow* window, double x, double y)
|
||||||
|
{
|
||||||
|
- _glfwInputError(GLFW_FEATURE_UNAVAILABLE,
|
||||||
|
- "Wayland: The platform does not support setting the cursor position");
|
||||||
|
+ window->wl.didAskForSetCursorPos = true;
|
||||||
|
+ window->wl.askedCursorPosX = x;
|
||||||
|
+ window->wl.askedCursorPosY = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _glfwSetCursorModeWayland(_GLFWwindow* window, int mode)
|
||||||
|
@@ -2819,6 +2820,15 @@ static const struct zwp_relative_pointer_v1_listener relativePointerListener =
|
||||||
|
static void lockedPointerHandleLocked(void* userData,
|
||||||
|
struct zwp_locked_pointer_v1* lockedPointer)
|
||||||
|
{
|
||||||
|
+ _GLFWwindow* window = userData;
|
||||||
|
+
|
||||||
|
+ if (window->wl.didAskForSetCursorPos)
|
||||||
|
+ {
|
||||||
|
+ window->wl.didAskForSetCursorPos = false;
|
||||||
|
+ zwp_locked_pointer_v1_set_cursor_position_hint(window->wl.lockedPointer,
|
||||||
|
+ wl_fixed_from_double(window->wl.askedCursorPosX),
|
||||||
|
+ wl_fixed_from_double(window->wl.askedCursorPosY));
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
static void lockedPointerHandleUnlocked(void* userData,
|
||||||
|
--
|
||||||
|
2.42.0
|
||||||
|
|
||||||
4
flatpak/prime-run
Normal file
4
flatpak/prime-run
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
export __NV_PRIME_RENDER_OFFLOAD=1 __VK_LAYER_NV_optimus=NVIDIA_only __GLX_VENDOR_LIBRARY_NAME=nvidia
|
||||||
|
exec "$@"
|
||||||
11
flatpak/prismlauncher
Normal file
11
flatpak/prismlauncher
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# discord RPC
|
||||||
|
for i in {0..9}; do
|
||||||
|
test -S "$XDG_RUNTIME_DIR"/discord-ipc-"$i" || ln -sf {app/com.discordapp.Discord,"$XDG_RUNTIME_DIR"}/discord-ipc-"$i";
|
||||||
|
done
|
||||||
|
|
||||||
|
export PATH="${PATH}${PATH:+:}/usr/lib/extensions/vulkan/gamescope/bin:/usr/lib/extensions/vulkan/MangoHud/bin"
|
||||||
|
export VK_LAYER_PATH="/usr/lib/extensions/vulkan/share/vulkan/implicit_layer.d/"
|
||||||
|
|
||||||
|
exec /app/bin/prismrun "$@"
|
||||||
1
flatpak/shared-modules
Submodule
1
flatpak/shared-modules
Submodule
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 73f08ed2c3187f6648ca04ebef030930a6c9f0be
|
||||||
6
flatpak/tomlplusplus.yml
Normal file
6
flatpak/tomlplusplus.yml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
name: tomlplusplus
|
||||||
|
buildsystem: cmake-ninja
|
||||||
|
sources:
|
||||||
|
- type: archive
|
||||||
|
url: https://github.com/marzer/tomlplusplus/archive/v3.4.0.tar.gz
|
||||||
|
sha256: 8517f65938a4faae9ccf8ebb36631a38c1cadfb5efa85d9a72e15b9e97d25155
|
||||||
|
|
@ -50,7 +50,6 @@
|
||||||
#include "tools/GenericProfiler.h"
|
#include "tools/GenericProfiler.h"
|
||||||
#include "ui/InstanceWindow.h"
|
#include "ui/InstanceWindow.h"
|
||||||
#include "ui/MainWindow.h"
|
#include "ui/MainWindow.h"
|
||||||
#include "ui/ToolTipFilter.h"
|
|
||||||
#include "ui/ViewLogWindow.h"
|
#include "ui/ViewLogWindow.h"
|
||||||
|
|
||||||
#include "ui/dialogs/ProgressDialog.h"
|
#include "ui/dialogs/ProgressDialog.h"
|
||||||
|
|
@ -126,11 +125,12 @@
|
||||||
#include <LocalPeer.h>
|
#include <LocalPeer.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <sys.h>
|
||||||
#include "SysInfo.h"
|
#include "SysInfo.h"
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include "LibraryUtils.h"
|
#include "MangoHud.h"
|
||||||
#include "gamemode_client.h"
|
#include "gamemode_client.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -157,6 +157,7 @@
|
||||||
#endif
|
#endif
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <QStyleHints>
|
#include <QStyleHints>
|
||||||
|
#include "console/WindowsConsole.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "console/Console.h"
|
#include "console/Console.h"
|
||||||
|
|
@ -290,9 +291,21 @@ std::tuple<QDateTime, QString, QString, QString, QString> read_lock_File(const Q
|
||||||
|
|
||||||
Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
{
|
{
|
||||||
|
#if defined Q_OS_WIN32
|
||||||
|
// attach the parent console if stdout not already captured
|
||||||
|
if (AttachWindowsConsole()) {
|
||||||
|
consoleAttached = true;
|
||||||
|
if (auto err = EnableAnsiSupport(); !err) {
|
||||||
|
isANSIColorConsole = true;
|
||||||
|
} else {
|
||||||
|
std::cout << "Error setting up ansi console" << err.message() << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (console::isConsole()) {
|
if (console::isConsole()) {
|
||||||
isANSIColorConsole = true;
|
isANSIColorConsole = true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
setOrganizationName(BuildConfig.LAUNCHER_NAME);
|
setOrganizationName(BuildConfig.LAUNCHER_NAME);
|
||||||
setOrganizationDomain(BuildConfig.LAUNCHER_DOMAIN);
|
setOrganizationDomain(BuildConfig.LAUNCHER_DOMAIN);
|
||||||
|
|
@ -318,7 +331,6 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
{ { "a", "profile" }, "Use the account specified by its profile name (only valid in combination with --launch)", "profile" },
|
{ { "a", "profile" }, "Use the account specified by its profile name (only valid in combination with --launch)", "profile" },
|
||||||
{ { "o", "offline" }, "Launch offline, with given player name (only valid in combination with --launch)", "offline" },
|
{ { "o", "offline" }, "Launch offline, with given player name (only valid in combination with --launch)", "offline" },
|
||||||
{ "alive", "Write a small '" + liveCheckFile + "' file after the launcher starts" },
|
{ "alive", "Write a small '" + liveCheckFile + "' file after the launcher starts" },
|
||||||
{ "show-window", "Show the main launcher window (useful in combination with --launch)" },
|
|
||||||
{ { "I", "import" }, "Import instance or resource from specified local path or URL", "url" },
|
{ { "I", "import" }, "Import instance or resource from specified local path or URL", "url" },
|
||||||
{ "show", "Opens the window for the specified instance (by instance ID)", "show" } });
|
{ "show", "Opens the window for the specified instance (by instance ID)", "show" } });
|
||||||
// Has to be positional for some OS to handle that properly
|
// Has to be positional for some OS to handle that properly
|
||||||
|
|
@ -334,13 +346,12 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
m_worldToJoin = parser.value("world");
|
m_worldToJoin = parser.value("world");
|
||||||
m_profileToUse = parser.value("profile");
|
m_profileToUse = parser.value("profile");
|
||||||
if (parser.isSet("offline")) {
|
if (parser.isSet("offline")) {
|
||||||
m_launchOffline = true;
|
m_offline = true;
|
||||||
m_offlineName = parser.value("offline");
|
m_offlineName = parser.value("offline");
|
||||||
}
|
}
|
||||||
m_liveCheck = parser.isSet("alive");
|
m_liveCheck = parser.isSet("alive");
|
||||||
|
|
||||||
m_instanceIdToShowWindowOf = parser.value("show");
|
m_instanceIdToShowWindowOf = parser.value("show");
|
||||||
m_showMainWindow = parser.isSet("show-window");
|
|
||||||
|
|
||||||
for (auto url : parser.values("import")) {
|
for (auto url : parser.values("import")) {
|
||||||
m_urlsToImport.append(normalizeImportUrl(url));
|
m_urlsToImport.append(normalizeImportUrl(url));
|
||||||
|
|
@ -352,7 +363,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
// error if --launch is missing with --server or --profile
|
// error if --launch is missing with --server or --profile
|
||||||
if ((!m_serverToJoin.isEmpty() || !m_worldToJoin.isEmpty() || !m_profileToUse.isEmpty() || m_launchOffline) &&
|
if ((!m_serverToJoin.isEmpty() || !m_worldToJoin.isEmpty() || !m_profileToUse.isEmpty() || m_offline) &&
|
||||||
m_instanceIdToLaunch.isEmpty()) {
|
m_instanceIdToLaunch.isEmpty()) {
|
||||||
std::cerr << "--server, --profile and --offline can only be used in combination with --launch!" << std::endl;
|
std::cerr << "--server, --profile and --offline can only be used in combination with --launch!" << std::endl;
|
||||||
m_status = Application::Failed;
|
m_status = Application::Failed;
|
||||||
|
|
@ -394,7 +405,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
} else {
|
} else {
|
||||||
QDir foo;
|
QDir foo;
|
||||||
if (DesktopServices::isSnap()) {
|
if (DesktopServices::isSnap()) {
|
||||||
foo = QDir(qEnvironmentVariable("SNAP_USER_COMMON"));
|
foo = QDir(getenv("SNAP_USER_COMMON"));
|
||||||
} else {
|
} else {
|
||||||
foo = QDir(FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), ".."));
|
foo = QDir(FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), ".."));
|
||||||
}
|
}
|
||||||
|
|
@ -480,7 +491,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
if (!m_profileToUse.isEmpty()) {
|
if (!m_profileToUse.isEmpty()) {
|
||||||
launch.args["profile"] = m_profileToUse;
|
launch.args["profile"] = m_profileToUse;
|
||||||
}
|
}
|
||||||
if (m_launchOffline) {
|
if (m_offline) {
|
||||||
launch.args["offline_enabled"] = "true";
|
launch.args["offline_enabled"] = "true";
|
||||||
launch.args["offline_name"] = m_offlineName;
|
launch.args["offline_name"] = m_offlineName;
|
||||||
}
|
}
|
||||||
|
|
@ -514,13 +525,12 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
logFile = std::unique_ptr<QFile>(new QFile(logBase.arg(0)));
|
logFile = std::unique_ptr<QFile>(new QFile(logBase.arg(0)));
|
||||||
if (!logFile->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
|
if (!logFile->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
|
||||||
showFatalErrorMessage("The launcher data folder is not writable!",
|
showFatalErrorMessage("The launcher data folder is not writable!",
|
||||||
QString("The launcher couldn't create a log file - %1.\n"
|
QString("The launcher couldn't create a log file - the data folder is not writable.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Make sure you have write permissions to the data folder.\n"
|
"Make sure you have write permissions to the data folder.\n"
|
||||||
"(%2)\n"
|
"(%1)\n"
|
||||||
"\n"
|
"\n"
|
||||||
"The launcher cannot continue until you fix this problem.")
|
"The launcher cannot continue until you fix this problem.")
|
||||||
.arg(logFile->errorString())
|
|
||||||
.arg(dataPath));
|
.arg(dataPath));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -578,14 +588,16 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto migrated = handleDataMigration(
|
bool migrated = false;
|
||||||
|
|
||||||
|
if (!migrated)
|
||||||
|
migrated = handleDataMigration(
|
||||||
dataPath, FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), "../../PolyMC"), "PolyMC",
|
dataPath, FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), "../../PolyMC"), "PolyMC",
|
||||||
"polymc.cfg");
|
"polymc.cfg");
|
||||||
if (!migrated) {
|
if (!migrated)
|
||||||
handleDataMigration(dataPath,
|
migrated = handleDataMigration(
|
||||||
FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), "../../multimc"),
|
dataPath, FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), "../../multimc"), "MultiMC",
|
||||||
"MultiMC", "multimc.cfg");
|
"multimc.cfg");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -625,11 +637,11 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
if (check.write(payload) == payload.size()) {
|
if (check.write(payload) == payload.size()) {
|
||||||
check.close();
|
check.close();
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "Could not write into" << liveCheckFile << "error:" << check.errorString();
|
qWarning() << "Could not write into" << liveCheckFile << "!";
|
||||||
check.remove(); // also closes file!
|
check.remove(); // also closes file!
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "Could not open" << liveCheckFile << "for writing:" << check.errorString();
|
qWarning() << "Could not open" << liveCheckFile << "for writing!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -672,7 +684,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
QFontInfo consoleFontInfo(consoleFont);
|
QFontInfo consoleFontInfo(consoleFont);
|
||||||
QString resolvedDefaultMonospace = consoleFontInfo.family();
|
QString resolvedDefaultMonospace = consoleFontInfo.family();
|
||||||
QFont resolvedFont(resolvedDefaultMonospace);
|
QFont resolvedFont(resolvedDefaultMonospace);
|
||||||
qDebug().nospace() << "Detected default console font: " << resolvedDefaultMonospace
|
qDebug() << "Detected default console font:" << resolvedDefaultMonospace
|
||||||
<< ", substitutions:" << resolvedFont.substitutions().join(',');
|
<< ", substitutions:" << resolvedFont.substitutions().join(',');
|
||||||
|
|
||||||
m_settings->registerSetting("ConsoleFont", resolvedDefaultMonospace);
|
m_settings->registerSetting("ConsoleFont", resolvedDefaultMonospace);
|
||||||
|
|
@ -731,9 +743,8 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
|
|
||||||
// Memory
|
// Memory
|
||||||
m_settings->registerSetting({ "MinMemAlloc", "MinMemoryAlloc" }, 512);
|
m_settings->registerSetting({ "MinMemAlloc", "MinMemoryAlloc" }, 512);
|
||||||
m_settings->registerSetting({ "MaxMemAlloc", "MaxMemoryAlloc" }, SysInfo::defaultMaxJvmMem());
|
m_settings->registerSetting({ "MaxMemAlloc", "MaxMemoryAlloc" }, SysInfo::suitableMaxMem());
|
||||||
m_settings->registerSetting("PermGen", 128);
|
m_settings->registerSetting("PermGen", 128);
|
||||||
m_settings->registerSetting("LowMemWarning", true);
|
|
||||||
|
|
||||||
// Java Settings
|
// Java Settings
|
||||||
m_settings->registerSetting("JavaPath", "");
|
m_settings->registerSetting("JavaPath", "");
|
||||||
|
|
@ -776,8 +787,6 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
m_settings->registerSetting("ModMetadataDisabled", false);
|
m_settings->registerSetting("ModMetadataDisabled", false);
|
||||||
m_settings->registerSetting("ModDependenciesDisabled", false);
|
m_settings->registerSetting("ModDependenciesDisabled", false);
|
||||||
m_settings->registerSetting("SkipModpackUpdatePrompt", false);
|
m_settings->registerSetting("SkipModpackUpdatePrompt", false);
|
||||||
m_settings->registerSetting("ShowModIncompat", false);
|
|
||||||
m_settings->registerSetting("DownloadGameFilesDuringInstanceCreation", true);
|
|
||||||
|
|
||||||
// Minecraft offline player name
|
// Minecraft offline player name
|
||||||
m_settings->registerSetting("LastOfflinePlayerName", "");
|
m_settings->registerSetting("LastOfflinePlayerName", "");
|
||||||
|
|
@ -818,8 +827,6 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
|
|
||||||
m_settings->registerSetting("UpdateDialogGeometry", "");
|
m_settings->registerSetting("UpdateDialogGeometry", "");
|
||||||
|
|
||||||
m_settings->registerSetting("NewsGeometry", "");
|
|
||||||
|
|
||||||
m_settings->registerSetting("ModDownloadGeometry", "");
|
m_settings->registerSetting("ModDownloadGeometry", "");
|
||||||
m_settings->registerSetting("RPDownloadGeometry", "");
|
m_settings->registerSetting("RPDownloadGeometry", "");
|
||||||
m_settings->registerSetting("TPDownloadGeometry", "");
|
m_settings->registerSetting("TPDownloadGeometry", "");
|
||||||
|
|
@ -854,23 +861,25 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
auto resetIfInvalid = [this](const Setting* setting) {
|
|
||||||
if (const QUrl url(setting->get().toString()); !url.isValid() || (url.scheme() != "http" && url.scheme() != "https")) {
|
|
||||||
m_settings->reset(setting->id());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Meta URL
|
// Meta URL
|
||||||
resetIfInvalid(m_settings->registerSetting("MetaURLOverride", "").get());
|
m_settings->registerSetting("MetaURLOverride", "");
|
||||||
|
|
||||||
|
QUrl metaUrl(m_settings->get("MetaURLOverride").toString());
|
||||||
|
|
||||||
|
// get rid of invalid meta urls
|
||||||
|
if (!metaUrl.isValid() || (metaUrl.scheme() != "http" && metaUrl.scheme() != "https"))
|
||||||
|
m_settings->reset("MetaURLOverride");
|
||||||
|
|
||||||
// Resource URL
|
// Resource URL
|
||||||
resetIfInvalid(m_settings->registerSetting({ "ResourceURLOverride", "ResourceURL" }, "").get());
|
m_settings->registerSetting("ResourceURL", BuildConfig.DEFAULT_RESOURCE_BASE);
|
||||||
|
|
||||||
// Legacy FML libs URL
|
QUrl resourceUrl(m_settings->get("ResourceURL").toString());
|
||||||
resetIfInvalid(m_settings->registerSetting("LegacyFMLLibsURLOverride", "").get());
|
|
||||||
|
// get rid of invalid resource urls
|
||||||
|
if (!resourceUrl.isValid() || (resourceUrl.scheme() != "http" && resourceUrl.scheme() != "https"))
|
||||||
|
m_settings->reset("ResourceURL");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_settings->registerSetting("MetaRefreshOnLaunch", true);
|
|
||||||
m_settings->registerSetting("CloseAfterLaunch", false);
|
m_settings->registerSetting("CloseAfterLaunch", false);
|
||||||
m_settings->registerSetting("QuitAfterGameStop", false);
|
m_settings->registerSetting("QuitAfterGameStop", false);
|
||||||
|
|
||||||
|
|
@ -890,7 +899,6 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
m_settings->set("FlameKeyOverride", flameKey);
|
m_settings->set("FlameKeyOverride", flameKey);
|
||||||
m_settings->reset("CFKeyOverride");
|
m_settings->reset("CFKeyOverride");
|
||||||
}
|
}
|
||||||
m_settings->registerSetting("FallbackMRBlockedMods", true);
|
|
||||||
m_settings->registerSetting("ModrinthToken", "");
|
m_settings->registerSetting("ModrinthToken", "");
|
||||||
m_settings->registerSetting("UserAgentOverride", "");
|
m_settings->registerSetting("UserAgentOverride", "");
|
||||||
|
|
||||||
|
|
@ -902,7 +910,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
|
|
||||||
// Init page provider
|
// Init page provider
|
||||||
{
|
{
|
||||||
m_globalSettingsProvider = std::make_unique<GenericPageProvider>(tr("Settings"));
|
m_globalSettingsProvider = std::make_shared<GenericPageProvider>(tr("Settings"));
|
||||||
m_globalSettingsProvider->addPage<LauncherPage>();
|
m_globalSettingsProvider->addPage<LauncherPage>();
|
||||||
m_globalSettingsProvider->addPage<LanguagePage>();
|
m_globalSettingsProvider->addPage<LanguagePage>();
|
||||||
m_globalSettingsProvider->addPage<AppearancePage>();
|
m_globalSettingsProvider->addPage<AppearancePage>();
|
||||||
|
|
@ -935,6 +943,15 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
qInfo() << "<> Network done.";
|
qInfo() << "<> Network done.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// load translations
|
||||||
|
{
|
||||||
|
m_translations.reset(new TranslationsModel("translations"));
|
||||||
|
auto bcp47Name = m_settings->get("Language").toString();
|
||||||
|
m_translations->selectLanguage(bcp47Name);
|
||||||
|
qInfo() << "Your language is" << bcp47Name;
|
||||||
|
qInfo() << "<> Translations loaded.";
|
||||||
|
}
|
||||||
|
|
||||||
// Instance icons
|
// Instance icons
|
||||||
{
|
{
|
||||||
auto setting = APPLICATION->settings()->getSetting("IconsDir");
|
auto setting = APPLICATION->settings()->getSetting("IconsDir");
|
||||||
|
|
@ -974,7 +991,7 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
if (FS::checkProblemticPathJava(QDir(instDir))) {
|
if (FS::checkProblemticPathJava(QDir(instDir))) {
|
||||||
qWarning() << "Your instance path contains \'!\' and this is known to cause java problems!";
|
qWarning() << "Your instance path contains \'!\' and this is known to cause java problems!";
|
||||||
}
|
}
|
||||||
m_instances.reset(new InstanceList(m_settings.get(), instDir, this));
|
m_instances.reset(new InstanceList(m_settings, instDir, this));
|
||||||
connect(InstDirSetting.get(), &Setting::SettingChanged, m_instances.get(), &InstanceList::on_InstFolderChanged);
|
connect(InstDirSetting.get(), &Setting::SettingChanged, m_instances.get(), &InstanceList::on_InstFolderChanged);
|
||||||
qInfo() << "Loading Instances...";
|
qInfo() << "Loading Instances...";
|
||||||
m_instances->loadList();
|
m_instances->loadList();
|
||||||
|
|
@ -1008,30 +1025,24 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
m_metacache->addBase("translations", QDir("translations").absolutePath());
|
m_metacache->addBase("translations", QDir("translations").absolutePath());
|
||||||
m_metacache->addBase("meta", QDir("meta").absolutePath());
|
m_metacache->addBase("meta", QDir("meta").absolutePath());
|
||||||
m_metacache->addBase("java", QDir("cache/java").absolutePath());
|
m_metacache->addBase("java", QDir("cache/java").absolutePath());
|
||||||
m_metacache->addBase("feed", QDir("cache/feed").absolutePath());
|
|
||||||
m_metacache->Load();
|
m_metacache->Load();
|
||||||
qInfo() << "<> Cache initialized.";
|
qInfo() << "<> Cache initialized.";
|
||||||
}
|
}
|
||||||
|
|
||||||
// load translations
|
// now we have network, download translation updates
|
||||||
{
|
|
||||||
m_translations.reset(new TranslationsModel("translations"));
|
|
||||||
m_translations->downloadIndex();
|
m_translations->downloadIndex();
|
||||||
qInfo() << "Your language is" << m_translations->selectedLanguage();
|
|
||||||
qInfo() << "<> Translations loaded.";
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: what to do with these?
|
// FIXME: what to do with these?
|
||||||
m_profilers.insert("jprofiler", std::shared_ptr<BaseProfilerFactory>(new JProfilerFactory()));
|
m_profilers.insert("jprofiler", std::shared_ptr<BaseProfilerFactory>(new JProfilerFactory()));
|
||||||
m_profilers.insert("jvisualvm", std::shared_ptr<BaseProfilerFactory>(new JVisualVMFactory()));
|
m_profilers.insert("jvisualvm", std::shared_ptr<BaseProfilerFactory>(new JVisualVMFactory()));
|
||||||
m_profilers.insert("generic", std::shared_ptr<BaseProfilerFactory>(new GenericProfilerFactory()));
|
m_profilers.insert("generic", std::shared_ptr<BaseProfilerFactory>(new GenericProfilerFactory()));
|
||||||
for (auto profiler : m_profilers.values()) {
|
for (auto profiler : m_profilers.values()) {
|
||||||
profiler->registerSettings(m_settings.get());
|
profiler->registerSettings(m_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the MCEdit thing... why is this here?
|
// Create the MCEdit thing... why is this here?
|
||||||
{
|
{
|
||||||
m_mcedit.reset(new MCEditTool(m_settings.get()));
|
m_mcedit.reset(new MCEditTool(m_settings));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
|
|
@ -1188,10 +1199,6 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qgetenv("XDG_CURRENT_DESKTOP") == "gamescope") {
|
|
||||||
installEventFilter(new ToolTipFilter);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (createSetupWizard()) {
|
if (createSetupWizard()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1352,13 +1359,10 @@ void Application::performMainStartupAction()
|
||||||
qDebug() << " Launching with account" << m_profileToUse;
|
qDebug() << " Launching with account" << m_profileToUse;
|
||||||
}
|
}
|
||||||
|
|
||||||
launch(inst, m_launchOffline ? LaunchMode::Offline : LaunchMode::Normal, targetToJoin, accountToUse, m_offlineName);
|
launch(inst, !m_offline, false, targetToJoin, accountToUse, m_offlineName);
|
||||||
|
|
||||||
if (!m_showMainWindow) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!m_instanceIdToShowWindowOf.isEmpty()) {
|
if (!m_instanceIdToShowWindowOf.isEmpty()) {
|
||||||
auto inst = instances()->getInstanceById(m_instanceIdToShowWindowOf);
|
auto inst = instances()->getInstanceById(m_instanceIdToShowWindowOf);
|
||||||
if (inst) {
|
if (inst) {
|
||||||
|
|
@ -1409,6 +1413,16 @@ Application::~Application()
|
||||||
{
|
{
|
||||||
// Shut down logger by setting the logger function to nothing
|
// Shut down logger by setting the logger function to nothing
|
||||||
qInstallMessageHandler(nullptr);
|
qInstallMessageHandler(nullptr);
|
||||||
|
|
||||||
|
#if defined Q_OS_WIN32
|
||||||
|
// Detach from Windows console
|
||||||
|
if (consoleAttached) {
|
||||||
|
fclose(stdout);
|
||||||
|
fclose(stdin);
|
||||||
|
fclose(stderr);
|
||||||
|
FreeConsole();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::messageReceived(const QByteArray& message)
|
void Application::messageReceived(const QByteArray& message)
|
||||||
|
|
@ -1450,7 +1464,7 @@ void Application::messageReceived(const QByteArray& message)
|
||||||
bool offline = received.args["offline_enabled"] == "true";
|
bool offline = received.args["offline_enabled"] == "true";
|
||||||
QString offlineName = received.args["offline_name"];
|
QString offlineName = received.args["offline_name"];
|
||||||
|
|
||||||
BaseInstance* instance;
|
InstancePtr instance;
|
||||||
if (!id.isEmpty()) {
|
if (!id.isEmpty()) {
|
||||||
instance = instances()->getInstanceById(id);
|
instance = instances()->getInstanceById(id);
|
||||||
if (!instance) {
|
if (!instance) {
|
||||||
|
|
@ -1478,23 +1492,23 @@ void Application::messageReceived(const QByteArray& message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
launch(instance, offline ? LaunchMode::Offline : LaunchMode::Normal, serverObject, accountObject, offlineName);
|
launch(instance, !offline, false, serverObject, accountObject, offlineName);
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "Received invalid message" << message;
|
qWarning() << "Received invalid message" << message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TranslationsModel* Application::translations()
|
std::shared_ptr<TranslationsModel> Application::translations()
|
||||||
{
|
{
|
||||||
return m_translations.get();
|
return m_translations;
|
||||||
}
|
}
|
||||||
|
|
||||||
JavaInstallList* Application::javalist()
|
std::shared_ptr<JavaInstallList> Application::javalist()
|
||||||
{
|
{
|
||||||
if (!m_javalist) {
|
if (!m_javalist) {
|
||||||
m_javalist.reset(new JavaInstallList());
|
m_javalist.reset(new JavaInstallList());
|
||||||
}
|
}
|
||||||
return m_javalist.get();
|
return m_javalist;
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon Application::logo()
|
QIcon Application::logo()
|
||||||
|
|
@ -1513,8 +1527,9 @@ bool Application::openJsonEditor(const QString& filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::launch(BaseInstance* instance,
|
bool Application::launch(InstancePtr instance,
|
||||||
LaunchMode mode,
|
bool online,
|
||||||
|
bool demo,
|
||||||
MinecraftTarget::Ptr targetToJoin,
|
MinecraftTarget::Ptr targetToJoin,
|
||||||
MinecraftAccountPtr accountToUse,
|
MinecraftAccountPtr accountToUse,
|
||||||
const QString& offlineName)
|
const QString& offlineName)
|
||||||
|
|
@ -1533,7 +1548,8 @@ bool Application::launch(BaseInstance* instance,
|
||||||
auto& controller = extras.controller;
|
auto& controller = extras.controller;
|
||||||
controller.reset(new LaunchController());
|
controller.reset(new LaunchController());
|
||||||
controller->setInstance(instance);
|
controller->setInstance(instance);
|
||||||
controller->setLaunchMode(mode);
|
controller->setOnline(online);
|
||||||
|
controller->setDemo(demo);
|
||||||
controller->setProfiler(profilers().value(instance->settings()->get("Profiler").toString(), nullptr).get());
|
controller->setProfiler(profilers().value(instance->settings()->get("Profiler").toString(), nullptr).get());
|
||||||
controller->setTargetToJoin(targetToJoin);
|
controller->setTargetToJoin(targetToJoin);
|
||||||
controller->setAccountToUse(accountToUse);
|
controller->setAccountToUse(accountToUse);
|
||||||
|
|
@ -1543,7 +1559,9 @@ bool Application::launch(BaseInstance* instance,
|
||||||
} else if (m_mainWindow) {
|
} else if (m_mainWindow) {
|
||||||
controller->setParentWidget(m_mainWindow);
|
controller->setParentWidget(m_mainWindow);
|
||||||
}
|
}
|
||||||
connect(controller.get(), &LaunchController::finished, this, &Application::controllerFinished);
|
connect(controller.get(), &LaunchController::succeeded, this, &Application::controllerSucceeded);
|
||||||
|
connect(controller.get(), &LaunchController::failed, this, &Application::controllerFailed);
|
||||||
|
connect(controller.get(), &LaunchController::aborted, this, [this] { controllerFailed(tr("Aborted")); });
|
||||||
addRunningInstance();
|
addRunningInstance();
|
||||||
QMetaObject::invokeMethod(controller.get(), &Task::start, Qt::QueuedConnection);
|
QMetaObject::invokeMethod(controller.get(), &Task::start, Qt::QueuedConnection);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1557,7 +1575,7 @@ bool Application::launch(BaseInstance* instance,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::kill(BaseInstance* instance)
|
bool Application::kill(InstancePtr instance)
|
||||||
{
|
{
|
||||||
if (!instance->isRunning()) {
|
if (!instance->isRunning()) {
|
||||||
qWarning() << "Attempted to kill instance" << instance->id() << ", which isn't running.";
|
qWarning() << "Attempted to kill instance" << instance->id() << ", which isn't running.";
|
||||||
|
|
@ -1566,7 +1584,7 @@ bool Application::kill(BaseInstance* instance)
|
||||||
QMutexLocker locker(&m_instanceExtrasMutex);
|
QMutexLocker locker(&m_instanceExtrasMutex);
|
||||||
auto& extras = m_instanceExtras[instance->id()];
|
auto& extras = m_instanceExtras[instance->id()];
|
||||||
// NOTE: copy of the shared pointer keeps it alive
|
// NOTE: copy of the shared pointer keeps it alive
|
||||||
auto& controller = extras.controller;
|
auto controller = extras.controller;
|
||||||
locker.unlock();
|
locker.unlock();
|
||||||
if (controller) {
|
if (controller) {
|
||||||
return controller->abort();
|
return controller->abort();
|
||||||
|
|
@ -1615,7 +1633,7 @@ void Application::updateIsRunning(bool running)
|
||||||
m_updateRunning = running;
|
m_updateRunning = running;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::controllerFinished()
|
void Application::controllerSucceeded()
|
||||||
{
|
{
|
||||||
auto controller = qobject_cast<LaunchController*>(sender());
|
auto controller = qobject_cast<LaunchController*>(sender());
|
||||||
if (!controller)
|
if (!controller)
|
||||||
|
|
@ -1623,11 +1641,10 @@ void Application::controllerFinished()
|
||||||
auto id = controller->id();
|
auto id = controller->id();
|
||||||
|
|
||||||
QMutexLocker locker(&m_instanceExtrasMutex);
|
QMutexLocker locker(&m_instanceExtrasMutex);
|
||||||
auto& extras = m_instanceExtras.at(id);
|
auto& extras = m_instanceExtras[id];
|
||||||
|
|
||||||
const bool wasSuccessful = controller->wasSuccessful();
|
|
||||||
// on success, do...
|
// on success, do...
|
||||||
if (wasSuccessful && controller->instance()->settings()->get("AutoCloseConsole").toBool()) {
|
if (controller->instance()->settings()->get("AutoCloseConsole").toBool()) {
|
||||||
if (extras.window) {
|
if (extras.window) {
|
||||||
QMetaObject::invokeMethod(extras.window, &QWidget::close, Qt::QueuedConnection);
|
QMetaObject::invokeMethod(extras.window, &QWidget::close, Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
@ -1637,8 +1654,29 @@ void Application::controllerFinished()
|
||||||
|
|
||||||
// quit when there are no more windows.
|
// quit when there are no more windows.
|
||||||
if (shouldExitNow()) {
|
if (shouldExitNow()) {
|
||||||
m_status = wasSuccessful ? Succeeded : Failed;
|
m_status = Status::Succeeded;
|
||||||
exit(wasSuccessful ? 0 : 1);
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::controllerFailed(const QString& error)
|
||||||
|
{
|
||||||
|
Q_UNUSED(error);
|
||||||
|
auto controller = qobject_cast<LaunchController*>(sender());
|
||||||
|
if (!controller)
|
||||||
|
return;
|
||||||
|
auto id = controller->id();
|
||||||
|
QMutexLocker locker(&m_instanceExtrasMutex);
|
||||||
|
auto& extras = m_instanceExtras[id];
|
||||||
|
|
||||||
|
// on failure, do... nothing
|
||||||
|
extras.controller.reset();
|
||||||
|
subRunningInstance();
|
||||||
|
|
||||||
|
// quit when there are no more windows.
|
||||||
|
if (shouldExitNow()) {
|
||||||
|
m_status = Status::Failed;
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1695,7 +1733,7 @@ ViewLogWindow* Application::showLogWindow()
|
||||||
return m_viewLogWindow;
|
return m_viewLogWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
InstanceWindow* Application::showInstanceWindow(BaseInstance* instance, QString page)
|
InstanceWindow* Application::showInstanceWindow(InstancePtr instance, QString page)
|
||||||
{
|
{
|
||||||
if (!instance)
|
if (!instance)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
@ -1807,22 +1845,22 @@ void Application::updateProxySettings(QString proxyTypeStr, QString addr, int po
|
||||||
qDebug() << proxyDesc;
|
qDebug() << proxyDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpMetaCache* Application::metacache()
|
shared_qobject_ptr<HttpMetaCache> Application::metacache()
|
||||||
{
|
{
|
||||||
return m_metacache.get();
|
return m_metacache;
|
||||||
}
|
}
|
||||||
|
|
||||||
QNetworkAccessManager* Application::network()
|
shared_qobject_ptr<QNetworkAccessManager> Application::network()
|
||||||
{
|
{
|
||||||
return m_network.get();
|
return m_network;
|
||||||
}
|
}
|
||||||
|
|
||||||
Meta::Index* Application::metadataIndex()
|
shared_qobject_ptr<Meta::Index> Application::metadataIndex()
|
||||||
{
|
{
|
||||||
if (!m_metadataIndex) {
|
if (!m_metadataIndex) {
|
||||||
m_metadataIndex.reset(new Meta::Index());
|
m_metadataIndex.reset(new Meta::Index());
|
||||||
}
|
}
|
||||||
return m_metadataIndex.get();
|
return m_metadataIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::updateCapabilities()
|
void Application::updateCapabilities()
|
||||||
|
|
@ -1837,7 +1875,7 @@ void Application::updateCapabilities()
|
||||||
if (gamemode_query_status() >= 0)
|
if (gamemode_query_status() >= 0)
|
||||||
m_capabilities |= SupportsGameMode;
|
m_capabilities |= SupportsGameMode;
|
||||||
|
|
||||||
if (!LibraryUtils::findMangoHud().isEmpty())
|
if (!MangoHud::getLibraryString().isEmpty())
|
||||||
m_capabilities |= SupportsMangoHud;
|
m_capabilities |= SupportsMangoHud;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -1845,8 +1883,8 @@ void Application::updateCapabilities()
|
||||||
void Application::detectLibraries()
|
void Application::detectLibraries()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
m_detectedGLFWPath = LibraryUtils::find(BuildConfig.GLFW_LIBRARY_NAME);
|
m_detectedGLFWPath = MangoHud::findLibrary(BuildConfig.GLFW_LIBRARY_NAME);
|
||||||
m_detectedOpenALPath = LibraryUtils::find(BuildConfig.OPENAL_LIBRARY_NAME);
|
m_detectedOpenALPath = MangoHud::findLibrary(BuildConfig.OPENAL_LIBRARY_NAME);
|
||||||
qDebug() << "Detected native libraries:" << m_detectedGLFWPath << m_detectedOpenALPath;
|
qDebug() << "Detected native libraries:" << m_detectedGLFWPath << m_detectedOpenALPath;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -1953,7 +1991,7 @@ bool Application::handleDataMigration(const QString& currentData,
|
||||||
auto setDoNotMigrate = [&nomigratePath] {
|
auto setDoNotMigrate = [&nomigratePath] {
|
||||||
QFile file(nomigratePath);
|
QFile file(nomigratePath);
|
||||||
if (!file.open(QIODevice::WriteOnly)) {
|
if (!file.open(QIODevice::WriteOnly)) {
|
||||||
qWarning() << "setDoNotMigrate failed; Failed to open file" << file.fileName() << "for writing:" << file.errorString();
|
qWarning() << "setDoNotMigrate failed; Failed to open file '" << file.fileName() << "' for writing!";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -2007,7 +2045,7 @@ void Application::triggerUpdateCheck()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl Application::normalizeImportUrl(const QString& url)
|
QUrl Application::normalizeImportUrl(QString const& url)
|
||||||
{
|
{
|
||||||
auto local_file = QFileInfo(url);
|
auto local_file = QFileInfo(url);
|
||||||
if (local_file.exists()) {
|
if (local_file.exists()) {
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
@ -46,10 +44,12 @@
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "QObjectPtr.h"
|
#include <BaseInstance.h>
|
||||||
|
|
||||||
#include "minecraft/auth/MinecraftAccount.h"
|
#include "launch/LogModel.h"
|
||||||
|
#include "minecraft/launch/MinecraftTarget.h"
|
||||||
|
|
||||||
class LaunchController;
|
class LaunchController;
|
||||||
class LocalPeer;
|
class LocalPeer;
|
||||||
|
|
@ -74,12 +74,6 @@ class ITheme;
|
||||||
class MCEditTool;
|
class MCEditTool;
|
||||||
class ThemeManager;
|
class ThemeManager;
|
||||||
class IconTheme;
|
class IconTheme;
|
||||||
class BaseInstance;
|
|
||||||
|
|
||||||
class LogModel;
|
|
||||||
|
|
||||||
struct MinecraftTarget;
|
|
||||||
class MinecraftAccount;
|
|
||||||
|
|
||||||
namespace Meta {
|
namespace Meta {
|
||||||
class Index;
|
class Index;
|
||||||
|
|
@ -97,6 +91,7 @@ class Index;
|
||||||
#define APPLICATION_DYN (dynamic_cast<Application*>(QCoreApplication::instance()))
|
#define APPLICATION_DYN (dynamic_cast<Application*>(QCoreApplication::instance()))
|
||||||
|
|
||||||
class Application : public QApplication {
|
class Application : public QApplication {
|
||||||
|
// friends for the purpose of limiting access to deprecated stuff
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum Status { StartingUp, Failed, Succeeded, Initialized };
|
enum Status { StartingUp, Failed, Succeeded, Initialized };
|
||||||
|
|
@ -117,7 +112,7 @@ class Application : public QApplication {
|
||||||
|
|
||||||
bool event(QEvent* event) override;
|
bool event(QEvent* event) override;
|
||||||
|
|
||||||
SettingsObject* settings() const { return m_settings.get(); }
|
std::shared_ptr<SettingsObject> settings() const { return m_settings; }
|
||||||
|
|
||||||
qint64 timeSinceStart() const { return m_startTime.msecsTo(QDateTime::currentDateTime()); }
|
qint64 timeSinceStart() const { return m_startTime.msecsTo(QDateTime::currentDateTime()); }
|
||||||
|
|
||||||
|
|
@ -125,21 +120,21 @@ class Application : public QApplication {
|
||||||
|
|
||||||
ThemeManager* themeManager() { return m_themeManager.get(); }
|
ThemeManager* themeManager() { return m_themeManager.get(); }
|
||||||
|
|
||||||
ExternalUpdater* updater() { return m_updater.get(); }
|
shared_qobject_ptr<ExternalUpdater> updater() { return m_updater; }
|
||||||
|
|
||||||
void triggerUpdateCheck();
|
void triggerUpdateCheck();
|
||||||
|
|
||||||
TranslationsModel* translations();
|
std::shared_ptr<TranslationsModel> translations();
|
||||||
|
|
||||||
JavaInstallList* javalist();
|
std::shared_ptr<JavaInstallList> javalist();
|
||||||
|
|
||||||
InstanceList* instances() const { return m_instances.get(); }
|
std::shared_ptr<InstanceList> instances() const { return m_instances; }
|
||||||
|
|
||||||
IconList* icons() const { return m_icons.get(); }
|
std::shared_ptr<IconList> icons() const { return m_icons; }
|
||||||
|
|
||||||
MCEditTool* mcedit() const { return m_mcedit.get(); }
|
MCEditTool* mcedit() const { return m_mcedit.get(); }
|
||||||
|
|
||||||
AccountList* accounts() const { return m_accounts.get(); }
|
shared_qobject_ptr<AccountList> accounts() const { return m_accounts; }
|
||||||
|
|
||||||
Status status() const { return m_status; }
|
Status status() const { return m_status; }
|
||||||
|
|
||||||
|
|
@ -147,11 +142,11 @@ class Application : public QApplication {
|
||||||
|
|
||||||
void updateProxySettings(QString proxyTypeStr, QString addr, int port, QString user, QString password);
|
void updateProxySettings(QString proxyTypeStr, QString addr, int port, QString user, QString password);
|
||||||
|
|
||||||
QNetworkAccessManager* network();
|
shared_qobject_ptr<QNetworkAccessManager> network();
|
||||||
|
|
||||||
HttpMetaCache* metacache();
|
shared_qobject_ptr<HttpMetaCache> metacache();
|
||||||
|
|
||||||
Meta::Index* metadataIndex();
|
shared_qobject_ptr<Meta::Index> metadataIndex();
|
||||||
|
|
||||||
void updateCapabilities();
|
void updateCapabilities();
|
||||||
|
|
||||||
|
|
@ -187,7 +182,7 @@ class Application : public QApplication {
|
||||||
*/
|
*/
|
||||||
bool openJsonEditor(const QString& filename);
|
bool openJsonEditor(const QString& filename);
|
||||||
|
|
||||||
InstanceWindow* showInstanceWindow(BaseInstance* instance, QString page = QString());
|
InstanceWindow* showInstanceWindow(InstancePtr instance, QString page = QString());
|
||||||
MainWindow* showMainWindow(bool minimized = false);
|
MainWindow* showMainWindow(bool minimized = false);
|
||||||
ViewLogWindow* showLogWindow();
|
ViewLogWindow* showLogWindow();
|
||||||
|
|
||||||
|
|
@ -199,7 +194,7 @@ class Application : public QApplication {
|
||||||
bool updaterEnabled();
|
bool updaterEnabled();
|
||||||
QString updaterBinaryName();
|
QString updaterBinaryName();
|
||||||
|
|
||||||
QUrl normalizeImportUrl(const QString& url);
|
QUrl normalizeImportUrl(QString const& url);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void updateAllowedChanged(bool status);
|
void updateAllowedChanged(bool status);
|
||||||
|
|
@ -214,18 +209,20 @@ class Application : public QApplication {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool launch(BaseInstance* instance,
|
bool launch(InstancePtr instance,
|
||||||
LaunchMode mode = LaunchMode::Normal,
|
bool online = true,
|
||||||
std::shared_ptr<MinecraftTarget> targetToJoin = nullptr,
|
bool demo = false,
|
||||||
shared_qobject_ptr<MinecraftAccount> accountToUse = nullptr,
|
MinecraftTarget::Ptr targetToJoin = nullptr,
|
||||||
|
MinecraftAccountPtr accountToUse = nullptr,
|
||||||
const QString& offlineName = QString());
|
const QString& offlineName = QString());
|
||||||
bool kill(BaseInstance* instance);
|
bool kill(InstancePtr instance);
|
||||||
void closeCurrentWindow();
|
void closeCurrentWindow();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_windowClose();
|
void on_windowClose();
|
||||||
void messageReceived(const QByteArray& message);
|
void messageReceived(const QByteArray& message);
|
||||||
void controllerFinished();
|
void controllerSucceeded();
|
||||||
|
void controllerFailed(const QString& error);
|
||||||
void setupWizardFinished(int status);
|
void setupWizardFinished(int status);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -241,27 +238,23 @@ class Application : public QApplication {
|
||||||
void subRunningInstance();
|
void subRunningInstance();
|
||||||
bool shouldExitNow() const;
|
bool shouldExitNow() const;
|
||||||
|
|
||||||
private:
|
|
||||||
QHash<QString, int> m_qsaveResources;
|
|
||||||
mutable QMutex m_qsaveResourcesMutex;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QDateTime m_startTime;
|
QDateTime m_startTime;
|
||||||
|
|
||||||
std::unique_ptr<QNetworkAccessManager> m_network;
|
shared_qobject_ptr<QNetworkAccessManager> m_network;
|
||||||
|
|
||||||
std::unique_ptr<ExternalUpdater> m_updater;
|
shared_qobject_ptr<ExternalUpdater> m_updater;
|
||||||
std::unique_ptr<AccountList> m_accounts;
|
shared_qobject_ptr<AccountList> m_accounts;
|
||||||
|
|
||||||
std::unique_ptr<HttpMetaCache> m_metacache;
|
shared_qobject_ptr<HttpMetaCache> m_metacache;
|
||||||
std::unique_ptr<Meta::Index> m_metadataIndex;
|
shared_qobject_ptr<Meta::Index> m_metadataIndex;
|
||||||
|
|
||||||
std::unique_ptr<SettingsObject> m_settings;
|
std::shared_ptr<SettingsObject> m_settings;
|
||||||
std::unique_ptr<InstanceList> m_instances;
|
std::shared_ptr<InstanceList> m_instances;
|
||||||
std::unique_ptr<IconList> m_icons;
|
std::shared_ptr<IconList> m_icons;
|
||||||
std::unique_ptr<JavaInstallList> m_javalist;
|
std::shared_ptr<JavaInstallList> m_javalist;
|
||||||
std::unique_ptr<TranslationsModel> m_translations;
|
std::shared_ptr<TranslationsModel> m_translations;
|
||||||
std::unique_ptr<GenericPageProvider> m_globalSettingsProvider;
|
std::shared_ptr<GenericPageProvider> m_globalSettingsProvider;
|
||||||
std::unique_ptr<MCEditTool> m_mcedit;
|
std::unique_ptr<MCEditTool> m_mcedit;
|
||||||
QSet<QString> m_features;
|
QSet<QString> m_features;
|
||||||
std::unique_ptr<ThemeManager> m_themeManager;
|
std::unique_ptr<ThemeManager> m_themeManager;
|
||||||
|
|
@ -278,10 +271,15 @@ class Application : public QApplication {
|
||||||
Qt::ApplicationState m_prevAppState = Qt::ApplicationInactive;
|
Qt::ApplicationState m_prevAppState = Qt::ApplicationInactive;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined Q_OS_WIN32
|
||||||
|
// used on Windows to attach the standard IO streams
|
||||||
|
bool consoleAttached = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
// FIXME: attach to instances instead.
|
// FIXME: attach to instances instead.
|
||||||
struct InstanceXtras {
|
struct InstanceXtras {
|
||||||
InstanceWindow* window = nullptr;
|
InstanceWindow* window = nullptr;
|
||||||
std::unique_ptr<LaunchController> controller;
|
shared_qobject_ptr<LaunchController> controller;
|
||||||
};
|
};
|
||||||
std::map<QString, InstanceXtras> m_instanceExtras;
|
std::map<QString, InstanceXtras> m_instanceExtras;
|
||||||
mutable QMutex m_instanceExtrasMutex;
|
mutable QMutex m_instanceExtrasMutex;
|
||||||
|
|
@ -309,17 +307,20 @@ class Application : public QApplication {
|
||||||
QString m_serverToJoin;
|
QString m_serverToJoin;
|
||||||
QString m_worldToJoin;
|
QString m_worldToJoin;
|
||||||
QString m_profileToUse;
|
QString m_profileToUse;
|
||||||
bool m_launchOffline = false;
|
bool m_offline = false;
|
||||||
QString m_offlineName;
|
QString m_offlineName;
|
||||||
bool m_liveCheck = false;
|
bool m_liveCheck = false;
|
||||||
QList<QUrl> m_urlsToImport;
|
QList<QUrl> m_urlsToImport;
|
||||||
QString m_instanceIdToShowWindowOf;
|
QString m_instanceIdToShowWindowOf;
|
||||||
bool m_showMainWindow = false;
|
|
||||||
std::unique_ptr<QFile> logFile;
|
std::unique_ptr<QFile> logFile;
|
||||||
std::unique_ptr<LogModel> logModel;
|
shared_qobject_ptr<LogModel> logModel;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void addQSavePath(QString);
|
void addQSavePath(QString);
|
||||||
void removeQSavePath(QString);
|
void removeQSavePath(QString);
|
||||||
bool checkQSavePath(QString);
|
bool checkQSavePath(QString);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QHash<QString, int> m_qsaveResources;
|
||||||
|
mutable QMutex m_qsaveResourcesMutex;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
/*
|
|
||||||
* Prism Launcher - Minecraft Launcher
|
|
||||||
* Copyright (C) 2025 Octol1ttle <l1ttleofficial@outlook.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#if defined(ASSERT_NEVER)
|
|
||||||
#error ASSERT_NEVER already defined
|
|
||||||
#else
|
|
||||||
#define ASSERT_NEVER(cond) (Q_ASSERT((cond) == false), (cond))
|
|
||||||
#endif
|
|
||||||
|
|
@ -45,7 +45,6 @@
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "Json.h"
|
#include "Json.h"
|
||||||
#include "launch/LaunchTask.h"
|
|
||||||
#include "settings/INISettingsObject.h"
|
#include "settings/INISettingsObject.h"
|
||||||
#include "settings/OverrideSetting.h"
|
#include "settings/OverrideSetting.h"
|
||||||
#include "settings/Setting.h"
|
#include "settings/Setting.h"
|
||||||
|
|
@ -54,7 +53,7 @@
|
||||||
#include "Commandline.h"
|
#include "Commandline.h"
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
|
|
||||||
int getConsoleMaxLines(SettingsObject* settings)
|
int getConsoleMaxLines(SettingsObjectPtr settings)
|
||||||
{
|
{
|
||||||
auto lineSetting = settings->getSetting("ConsoleMaxLines");
|
auto lineSetting = settings->getSetting("ConsoleMaxLines");
|
||||||
bool conversionOk = false;
|
bool conversionOk = false;
|
||||||
|
|
@ -66,14 +65,14 @@ int getConsoleMaxLines(SettingsObject* settings)
|
||||||
return maxLines;
|
return maxLines;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool shouldStopOnConsoleOverflow(SettingsObject* settings)
|
bool shouldStopOnConsoleOverflow(SettingsObjectPtr settings)
|
||||||
{
|
{
|
||||||
return settings->get("ConsoleOverflowStop").toBool();
|
return settings->get("ConsoleOverflowStop").toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseInstance::BaseInstance(SettingsObject* globalSettings, std::unique_ptr<SettingsObject> settings, const QString& rootDir) : QObject()
|
BaseInstance::BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString& rootDir) : QObject()
|
||||||
{
|
{
|
||||||
m_settings = std::move(settings);
|
m_settings = settings;
|
||||||
m_global_settings = globalSettings;
|
m_global_settings = globalSettings;
|
||||||
m_rootDir = rootDir;
|
m_rootDir = rootDir;
|
||||||
|
|
||||||
|
|
@ -123,13 +122,10 @@ BaseInstance::BaseInstance(SettingsObject* globalSettings, std::unique_ptr<Setti
|
||||||
m_settings->registerSetting("ManagedPackName", "");
|
m_settings->registerSetting("ManagedPackName", "");
|
||||||
m_settings->registerSetting("ManagedPackVersionID", "");
|
m_settings->registerSetting("ManagedPackVersionID", "");
|
||||||
m_settings->registerSetting("ManagedPackVersionName", "");
|
m_settings->registerSetting("ManagedPackVersionName", "");
|
||||||
m_settings->registerSetting("ManagedPackURL", "");
|
|
||||||
|
|
||||||
m_settings->registerSetting("Profiler", "");
|
m_settings->registerSetting("Profiler", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseInstance::~BaseInstance() {}
|
|
||||||
|
|
||||||
QString BaseInstance::getPreLaunchCommand()
|
QString BaseInstance::getPreLaunchCommand()
|
||||||
{
|
{
|
||||||
return settings()->get("PreLaunchCommand").toString();
|
return settings()->get("PreLaunchCommand").toString();
|
||||||
|
|
@ -339,11 +335,11 @@ QString BaseInstance::instanceRoot() const
|
||||||
return m_rootDir;
|
return m_rootDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsObject* BaseInstance::settings()
|
SettingsObjectPtr BaseInstance::settings()
|
||||||
{
|
{
|
||||||
loadSpecificSettings();
|
loadSpecificSettings();
|
||||||
|
|
||||||
return m_settings.get();
|
return m_settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseInstance::canLaunch() const
|
bool BaseInstance::canLaunch() const
|
||||||
|
|
@ -471,9 +467,9 @@ QStringList BaseInstance::extraArguments()
|
||||||
return Commandline::splitArgs(settings()->get("JvmArgs").toString());
|
return Commandline::splitArgs(settings()->get("JvmArgs").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchTask* BaseInstance::getLaunchTask()
|
shared_qobject_ptr<LaunchTask> BaseInstance::getLaunchTask()
|
||||||
{
|
{
|
||||||
return m_launchProcess.get();
|
return m_launchProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseInstance::updateRuntimeContext()
|
void BaseInstance::updateRuntimeContext()
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,9 @@ class Task;
|
||||||
class LaunchTask;
|
class LaunchTask;
|
||||||
class BaseInstance;
|
class BaseInstance;
|
||||||
|
|
||||||
|
// pointer for lazy people
|
||||||
|
using InstancePtr = std::shared_ptr<BaseInstance>;
|
||||||
|
|
||||||
/// Shortcut saving target representations
|
/// Shortcut saving target representations
|
||||||
enum class ShortcutTarget { Desktop, Applications, Other };
|
enum class ShortcutTarget { Desktop, Applications, Other };
|
||||||
|
|
||||||
|
|
@ -75,8 +78,8 @@ struct ShortcutData {
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Console settings
|
/// Console settings
|
||||||
int getConsoleMaxLines(SettingsObject* settings);
|
int getConsoleMaxLines(SettingsObjectPtr settings);
|
||||||
bool shouldStopOnConsoleOverflow(SettingsObject* settings);
|
bool shouldStopOnConsoleOverflow(SettingsObjectPtr settings);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Base class for instances.
|
* \brief Base class for instances.
|
||||||
|
|
@ -86,11 +89,11 @@ bool shouldStopOnConsoleOverflow(SettingsObject* settings);
|
||||||
* To create a new instance type, create a new class inheriting from this class
|
* To create a new instance type, create a new class inheriting from this class
|
||||||
* and implement the pure virtual functions.
|
* and implement the pure virtual functions.
|
||||||
*/
|
*/
|
||||||
class BaseInstance : public QObject {
|
class BaseInstance : public QObject, public std::enable_shared_from_this<BaseInstance> {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
protected:
|
protected:
|
||||||
/// no-touchy!
|
/// no-touchy!
|
||||||
BaseInstance(SettingsObject* globalSettings, std::unique_ptr<SettingsObject> settings, const QString& rootDir);
|
BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString& rootDir);
|
||||||
|
|
||||||
public: /* types */
|
public: /* types */
|
||||||
enum class Status {
|
enum class Status {
|
||||||
|
|
@ -100,7 +103,7 @@ class BaseInstance : public QObject {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// virtual destructor to make sure the destruction is COMPLETE
|
/// virtual destructor to make sure the destruction is COMPLETE
|
||||||
virtual ~BaseInstance();
|
virtual ~BaseInstance() {}
|
||||||
|
|
||||||
virtual void saveNow() = 0;
|
virtual void saveNow() = 0;
|
||||||
|
|
||||||
|
|
@ -190,7 +193,7 @@ class BaseInstance : public QObject {
|
||||||
*
|
*
|
||||||
* \return A pointer to this instance's settings object.
|
* \return A pointer to this instance's settings object.
|
||||||
*/
|
*/
|
||||||
virtual SettingsObject* settings();
|
virtual SettingsObjectPtr settings();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Loads settings specific to an instance type if they're not already loaded.
|
* \brief Loads settings specific to an instance type if they're not already loaded.
|
||||||
|
|
@ -201,10 +204,10 @@ class BaseInstance : public QObject {
|
||||||
virtual QList<Task::Ptr> createUpdateTask() = 0;
|
virtual QList<Task::Ptr> createUpdateTask() = 0;
|
||||||
|
|
||||||
/// returns a valid launcher (task container)
|
/// returns a valid launcher (task container)
|
||||||
virtual LaunchTask* createLaunchTask(AuthSessionPtr account, MinecraftTarget::Ptr targetToJoin) = 0;
|
virtual shared_qobject_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account, MinecraftTarget::Ptr targetToJoin) = 0;
|
||||||
|
|
||||||
/// returns the current launch task (if any)
|
/// returns the current launch task (if any)
|
||||||
LaunchTask* getLaunchTask();
|
shared_qobject_ptr<LaunchTask> getLaunchTask();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Create envrironment variables for running the instance
|
* Create envrironment variables for running the instance
|
||||||
|
|
@ -283,7 +286,7 @@ class BaseInstance : public QObject {
|
||||||
protected:
|
protected:
|
||||||
void changeStatus(Status newStatus);
|
void changeStatus(Status newStatus);
|
||||||
|
|
||||||
SettingsObject* globalSettings() const { return m_global_settings; }
|
SettingsObjectPtr globalSettings() const { return m_global_settings.lock(); }
|
||||||
|
|
||||||
bool isSpecificSettingsLoaded() const { return m_specific_settings_loaded; }
|
bool isSpecificSettingsLoaded() const { return m_specific_settings_loaded; }
|
||||||
void setSpecificSettingsLoaded(bool loaded) { m_specific_settings_loaded = loaded; }
|
void setSpecificSettingsLoaded(bool loaded) { m_specific_settings_loaded = loaded; }
|
||||||
|
|
@ -294,7 +297,7 @@ class BaseInstance : public QObject {
|
||||||
*/
|
*/
|
||||||
void propertiesChanged(BaseInstance* inst);
|
void propertiesChanged(BaseInstance* inst);
|
||||||
|
|
||||||
void launchTaskChanged(LaunchTask*);
|
void launchTaskChanged(shared_qobject_ptr<LaunchTask>);
|
||||||
|
|
||||||
void runningStatusChanged(bool running);
|
void runningStatusChanged(bool running);
|
||||||
|
|
||||||
|
|
@ -307,10 +310,10 @@ class BaseInstance : public QObject {
|
||||||
|
|
||||||
protected: /* data */
|
protected: /* data */
|
||||||
QString m_rootDir;
|
QString m_rootDir;
|
||||||
std::unique_ptr<SettingsObject> m_settings;
|
SettingsObjectPtr m_settings;
|
||||||
// InstanceFlags m_flags;
|
// InstanceFlags m_flags;
|
||||||
bool m_isRunning = false;
|
bool m_isRunning = false;
|
||||||
std::unique_ptr<LaunchTask> m_launchProcess;
|
shared_qobject_ptr<LaunchTask> m_launchProcess;
|
||||||
QDateTime m_timeStarted;
|
QDateTime m_timeStarted;
|
||||||
RuntimeContext m_runtimeContext;
|
RuntimeContext m_runtimeContext;
|
||||||
|
|
||||||
|
|
@ -320,7 +323,7 @@ class BaseInstance : public QObject {
|
||||||
bool m_hasUpdate = false;
|
bool m_hasUpdate = false;
|
||||||
bool m_hasBrokenVersion = false;
|
bool m_hasBrokenVersion = false;
|
||||||
|
|
||||||
SettingsObject* m_global_settings;
|
SettingsObjectWeakPtr m_global_settings;
|
||||||
bool m_specific_settings_loaded = false;
|
bool m_specific_settings_loaded = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@
|
||||||
*/
|
*/
|
||||||
class BaseVersion {
|
class BaseVersion {
|
||||||
public:
|
public:
|
||||||
// TODO: delete
|
|
||||||
using Ptr = std::shared_ptr<BaseVersion>;
|
using Ptr = std::shared_ptr<BaseVersion>;
|
||||||
virtual ~BaseVersion() {}
|
virtual ~BaseVersion() {}
|
||||||
/*!
|
/*!
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ class BaseVersionList : public QAbstractListModel {
|
||||||
* The task returned by this function should reset the model when it's done.
|
* The task returned by this function should reset the model when it's done.
|
||||||
* \return A pointer to a task that reloads the version list.
|
* \return A pointer to a task that reloads the version list.
|
||||||
*/
|
*/
|
||||||
virtual Task::Ptr getLoadTask(bool forceReload = false) = 0;
|
virtual Task::Ptr getLoadTask() = 0;
|
||||||
|
|
||||||
//! Checks whether or not the list is loaded. If this returns false, the list should be
|
//! Checks whether or not the list is loaded. If this returns false, the list should be
|
||||||
// loaded.
|
// loaded.
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,9 @@ set(CORE_SOURCES
|
||||||
# RW lock protected map
|
# RW lock protected map
|
||||||
RWStorage.h
|
RWStorage.h
|
||||||
|
|
||||||
|
# A variable that has an implicit default value and keeps track of changes
|
||||||
|
DefaultVariable.h
|
||||||
|
|
||||||
# a smart pointer wrapper intended for safer use with Qt signal/slot mechanisms
|
# a smart pointer wrapper intended for safer use with Qt signal/slot mechanisms
|
||||||
QObjectPtr.h
|
QObjectPtr.h
|
||||||
|
|
||||||
|
|
@ -99,17 +102,14 @@ set(CORE_SOURCES
|
||||||
MMCTime.cpp
|
MMCTime.cpp
|
||||||
|
|
||||||
MTPixmapCache.h
|
MTPixmapCache.h
|
||||||
|
|
||||||
# Assertion helper
|
|
||||||
AssertHelpers.h
|
|
||||||
)
|
)
|
||||||
if (UNIX AND NOT CYGWIN AND NOT APPLE)
|
if (UNIX AND NOT CYGWIN AND NOT APPLE)
|
||||||
set(CORE_SOURCES
|
set(CORE_SOURCES
|
||||||
${CORE_SOURCES}
|
${CORE_SOURCES}
|
||||||
|
|
||||||
# LibraryUtils
|
# MangoHud
|
||||||
LibraryUtils.h
|
MangoHud.h
|
||||||
LibraryUtils.cpp
|
MangoHud.cpp
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
@ -119,7 +119,6 @@ set(NET_SOURCES
|
||||||
net/ChecksumValidator.h
|
net/ChecksumValidator.h
|
||||||
net/Download.cpp
|
net/Download.cpp
|
||||||
net/Download.h
|
net/Download.h
|
||||||
net/DummySink.h
|
|
||||||
net/FileSink.cpp
|
net/FileSink.cpp
|
||||||
net/FileSink.h
|
net/FileSink.h
|
||||||
net/HttpMetaCache.cpp
|
net/HttpMetaCache.cpp
|
||||||
|
|
@ -244,13 +243,15 @@ set(MINECRAFT_SOURCES
|
||||||
minecraft/auth/steps/MSAStep.h
|
minecraft/auth/steps/MSAStep.h
|
||||||
minecraft/auth/steps/XboxAuthorizationStep.cpp
|
minecraft/auth/steps/XboxAuthorizationStep.cpp
|
||||||
minecraft/auth/steps/XboxAuthorizationStep.h
|
minecraft/auth/steps/XboxAuthorizationStep.h
|
||||||
|
minecraft/auth/steps/XboxProfileStep.cpp
|
||||||
|
minecraft/auth/steps/XboxProfileStep.h
|
||||||
minecraft/auth/steps/XboxUserStep.cpp
|
minecraft/auth/steps/XboxUserStep.cpp
|
||||||
minecraft/auth/steps/XboxUserStep.h
|
minecraft/auth/steps/XboxUserStep.h
|
||||||
|
|
||||||
minecraft/update/AssetUpdateTask.h
|
minecraft/update/AssetUpdateTask.h
|
||||||
minecraft/update/AssetUpdateTask.cpp
|
minecraft/update/AssetUpdateTask.cpp
|
||||||
minecraft/update/LegacyFMLLibrariesTask.cpp
|
minecraft/update/FMLLibrariesTask.cpp
|
||||||
minecraft/update/LegacyFMLLibrariesTask.h
|
minecraft/update/FMLLibrariesTask.h
|
||||||
minecraft/update/FoldersTask.cpp
|
minecraft/update/FoldersTask.cpp
|
||||||
minecraft/update/FoldersTask.h
|
minecraft/update/FoldersTask.h
|
||||||
minecraft/update/LibrariesTask.cpp
|
minecraft/update/LibrariesTask.cpp
|
||||||
|
|
@ -260,10 +261,6 @@ set(MINECRAFT_SOURCES
|
||||||
minecraft/launch/ClaimAccount.h
|
minecraft/launch/ClaimAccount.h
|
||||||
minecraft/launch/CreateGameFolders.cpp
|
minecraft/launch/CreateGameFolders.cpp
|
||||||
minecraft/launch/CreateGameFolders.h
|
minecraft/launch/CreateGameFolders.h
|
||||||
minecraft/launch/EnsureAvailableMemory.cpp
|
|
||||||
minecraft/launch/EnsureAvailableMemory.h
|
|
||||||
minecraft/launch/EnsureOfflineLibraries.cpp
|
|
||||||
minecraft/launch/EnsureOfflineLibraries.h
|
|
||||||
minecraft/launch/ModMinecraftJar.cpp
|
minecraft/launch/ModMinecraftJar.cpp
|
||||||
minecraft/launch/ModMinecraftJar.h
|
minecraft/launch/ModMinecraftJar.h
|
||||||
minecraft/launch/ExtractNatives.cpp
|
minecraft/launch/ExtractNatives.cpp
|
||||||
|
|
@ -349,7 +346,6 @@ set(MINECRAFT_SOURCES
|
||||||
minecraft/mod/TexturePackFolderModel.h
|
minecraft/mod/TexturePackFolderModel.h
|
||||||
minecraft/mod/TexturePackFolderModel.cpp
|
minecraft/mod/TexturePackFolderModel.cpp
|
||||||
minecraft/mod/ShaderPackFolderModel.h
|
minecraft/mod/ShaderPackFolderModel.h
|
||||||
minecraft/mod/ShaderPackFolderModel.cpp
|
|
||||||
minecraft/mod/tasks/ResourceFolderLoadTask.h
|
minecraft/mod/tasks/ResourceFolderLoadTask.h
|
||||||
minecraft/mod/tasks/ResourceFolderLoadTask.cpp
|
minecraft/mod/tasks/ResourceFolderLoadTask.cpp
|
||||||
minecraft/mod/tasks/LocalModParseTask.h
|
minecraft/mod/tasks/LocalModParseTask.h
|
||||||
|
|
@ -529,11 +525,6 @@ set(FTB_SOURCES
|
||||||
modplatform/import_ftb/PackInstallTask.cpp
|
modplatform/import_ftb/PackInstallTask.cpp
|
||||||
modplatform/import_ftb/PackHelpers.h
|
modplatform/import_ftb/PackHelpers.h
|
||||||
modplatform/import_ftb/PackHelpers.cpp
|
modplatform/import_ftb/PackHelpers.cpp
|
||||||
|
|
||||||
modplatform/ftb/FTBPackInstallTask.h
|
|
||||||
modplatform/ftb/FTBPackInstallTask.cpp
|
|
||||||
modplatform/ftb/FTBPackManifest.h
|
|
||||||
modplatform/ftb/FTBPackManifest.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(FLAME_SOURCES
|
set(FLAME_SOURCES
|
||||||
|
|
@ -799,8 +790,6 @@ SET(LAUNCHER_SOURCES
|
||||||
ApplicationMessage.cpp
|
ApplicationMessage.cpp
|
||||||
SysInfo.h
|
SysInfo.h
|
||||||
SysInfo.cpp
|
SysInfo.cpp
|
||||||
HardwareInfo.cpp
|
|
||||||
HardwareInfo.h
|
|
||||||
|
|
||||||
# console utils
|
# console utils
|
||||||
console/Console.h
|
console/Console.h
|
||||||
|
|
@ -817,6 +806,23 @@ SET(LAUNCHER_SOURCES
|
||||||
KonamiCode.h
|
KonamiCode.h
|
||||||
KonamiCode.cpp
|
KonamiCode.cpp
|
||||||
|
|
||||||
|
# Bundled resources
|
||||||
|
resources/backgrounds/backgrounds.qrc
|
||||||
|
resources/multimc/multimc.qrc
|
||||||
|
resources/pe_dark/pe_dark.qrc
|
||||||
|
resources/pe_light/pe_light.qrc
|
||||||
|
resources/pe_colored/pe_colored.qrc
|
||||||
|
resources/pe_blue/pe_blue.qrc
|
||||||
|
resources/breeze_dark/breeze_dark.qrc
|
||||||
|
resources/breeze_light/breeze_light.qrc
|
||||||
|
resources/OSX/OSX.qrc
|
||||||
|
resources/iOS/iOS.qrc
|
||||||
|
resources/flat/flat.qrc
|
||||||
|
resources/flat_white/flat_white.qrc
|
||||||
|
resources/documents/documents.qrc
|
||||||
|
resources/shaders/shaders.qrc
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/../${Launcher_Branding_LogoQRC}"
|
||||||
|
|
||||||
# Icons
|
# Icons
|
||||||
icons/MMCIcon.h
|
icons/MMCIcon.h
|
||||||
icons/MMCIcon.cpp
|
icons/MMCIcon.cpp
|
||||||
|
|
@ -836,8 +842,6 @@ SET(LAUNCHER_SOURCES
|
||||||
ui/InstanceWindow.cpp
|
ui/InstanceWindow.cpp
|
||||||
ui/ViewLogWindow.h
|
ui/ViewLogWindow.h
|
||||||
ui/ViewLogWindow.cpp
|
ui/ViewLogWindow.cpp
|
||||||
ui/ToolTipFilter.h
|
|
||||||
ui/ToolTipFilter.cpp
|
|
||||||
|
|
||||||
# FIXME: maybe find a better home for this.
|
# FIXME: maybe find a better home for this.
|
||||||
FileIgnoreProxy.cpp
|
FileIgnoreProxy.cpp
|
||||||
|
|
@ -886,7 +890,6 @@ SET(LAUNCHER_SOURCES
|
||||||
ui/themes/CatPainter.h
|
ui/themes/CatPainter.h
|
||||||
|
|
||||||
# Processes
|
# Processes
|
||||||
LaunchMode.h
|
|
||||||
LaunchController.h
|
LaunchController.h
|
||||||
LaunchController.cpp
|
LaunchController.cpp
|
||||||
|
|
||||||
|
|
@ -997,13 +1000,6 @@ SET(LAUNCHER_SOURCES
|
||||||
ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp
|
ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp
|
||||||
ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.h
|
ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.h
|
||||||
|
|
||||||
ui/pages/modplatform/ftb/FtbFilterModel.cpp
|
|
||||||
ui/pages/modplatform/ftb/FtbFilterModel.h
|
|
||||||
ui/pages/modplatform/ftb/FtbListModel.cpp
|
|
||||||
ui/pages/modplatform/ftb/FtbListModel.h
|
|
||||||
ui/pages/modplatform/ftb/FtbPage.cpp
|
|
||||||
ui/pages/modplatform/ftb/FtbPage.h
|
|
||||||
|
|
||||||
ui/pages/modplatform/legacy_ftb/Page.cpp
|
ui/pages/modplatform/legacy_ftb/Page.cpp
|
||||||
ui/pages/modplatform/legacy_ftb/Page.h
|
ui/pages/modplatform/legacy_ftb/Page.h
|
||||||
ui/pages/modplatform/legacy_ftb/ListModel.h
|
ui/pages/modplatform/legacy_ftb/ListModel.h
|
||||||
|
|
@ -1067,8 +1063,6 @@ SET(LAUNCHER_SOURCES
|
||||||
ui/dialogs/ImportResourceDialog.h
|
ui/dialogs/ImportResourceDialog.h
|
||||||
ui/dialogs/MSALoginDialog.cpp
|
ui/dialogs/MSALoginDialog.cpp
|
||||||
ui/dialogs/MSALoginDialog.h
|
ui/dialogs/MSALoginDialog.h
|
||||||
ui/dialogs/NetworkJobFailedDialog.cpp
|
|
||||||
ui/dialogs/NetworkJobFailedDialog.h
|
|
||||||
ui/dialogs/NewComponentDialog.cpp
|
ui/dialogs/NewComponentDialog.cpp
|
||||||
ui/dialogs/NewComponentDialog.h
|
ui/dialogs/NewComponentDialog.h
|
||||||
ui/dialogs/NewInstanceDialog.cpp
|
ui/dialogs/NewInstanceDialog.cpp
|
||||||
|
|
@ -1206,6 +1200,76 @@ if(WIN32)
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
qt_wrap_ui(LAUNCHER_UI
|
||||||
|
ui/MainWindow.ui
|
||||||
|
ui/setupwizard/PasteWizardPage.ui
|
||||||
|
ui/setupwizard/AutoJavaWizardPage.ui
|
||||||
|
ui/setupwizard/LoginWizardPage.ui
|
||||||
|
ui/pages/global/AccountListPage.ui
|
||||||
|
ui/pages/global/JavaPage.ui
|
||||||
|
ui/pages/global/LauncherPage.ui
|
||||||
|
ui/pages/global/APIPage.ui
|
||||||
|
ui/pages/global/ProxyPage.ui
|
||||||
|
ui/pages/global/ExternalToolsPage.ui
|
||||||
|
ui/pages/instance/ExternalResourcesPage.ui
|
||||||
|
ui/pages/instance/NotesPage.ui
|
||||||
|
ui/pages/instance/LogPage.ui
|
||||||
|
ui/pages/instance/ServersPage.ui
|
||||||
|
ui/pages/instance/OtherLogsPage.ui
|
||||||
|
ui/pages/instance/VersionPage.ui
|
||||||
|
ui/pages/instance/ManagedPackPage.ui
|
||||||
|
ui/pages/instance/WorldListPage.ui
|
||||||
|
ui/pages/instance/ScreenshotsPage.ui
|
||||||
|
ui/pages/modplatform/atlauncher/AtlOptionalModDialog.ui
|
||||||
|
ui/pages/modplatform/atlauncher/AtlPage.ui
|
||||||
|
ui/pages/modplatform/CustomPage.ui
|
||||||
|
ui/pages/modplatform/ResourcePage.ui
|
||||||
|
ui/pages/modplatform/flame/FlamePage.ui
|
||||||
|
ui/pages/modplatform/legacy_ftb/Page.ui
|
||||||
|
ui/pages/modplatform/import_ftb/ImportFTBPage.ui
|
||||||
|
ui/pages/modplatform/ImportPage.ui
|
||||||
|
ui/pages/modplatform/OptionalModDialog.ui
|
||||||
|
ui/pages/modplatform/modrinth/ModrinthPage.ui
|
||||||
|
ui/pages/modplatform/technic/TechnicPage.ui
|
||||||
|
ui/widgets/CustomCommands.ui
|
||||||
|
ui/widgets/EnvironmentVariables.ui
|
||||||
|
ui/widgets/InfoFrame.ui
|
||||||
|
ui/widgets/ModFilterWidget.ui
|
||||||
|
ui/widgets/SubTaskProgressBar.ui
|
||||||
|
ui/widgets/AppearanceWidget.ui
|
||||||
|
ui/widgets/MinecraftSettingsWidget.ui
|
||||||
|
ui/widgets/JavaSettingsWidget.ui
|
||||||
|
ui/dialogs/CopyInstanceDialog.ui
|
||||||
|
ui/dialogs/CreateShortcutDialog.ui
|
||||||
|
ui/dialogs/ProfileSetupDialog.ui
|
||||||
|
ui/dialogs/ProgressDialog.ui
|
||||||
|
ui/dialogs/NewInstanceDialog.ui
|
||||||
|
ui/dialogs/NewComponentDialog.ui
|
||||||
|
ui/dialogs/NewsDialog.ui
|
||||||
|
ui/dialogs/ProfileSelectDialog.ui
|
||||||
|
ui/dialogs/ExportInstanceDialog.ui
|
||||||
|
ui/dialogs/ExportPackDialog.ui
|
||||||
|
ui/dialogs/ExportToModListDialog.ui
|
||||||
|
ui/dialogs/IconPickerDialog.ui
|
||||||
|
ui/dialogs/ImportResourceDialog.ui
|
||||||
|
ui/dialogs/MSALoginDialog.ui
|
||||||
|
ui/dialogs/AboutDialog.ui
|
||||||
|
ui/dialogs/ReviewMessageBox.ui
|
||||||
|
ui/dialogs/ScrollMessageBox.ui
|
||||||
|
ui/dialogs/BlockedModsDialog.ui
|
||||||
|
ui/dialogs/ChooseProviderDialog.ui
|
||||||
|
ui/dialogs/skins/SkinManageDialog.ui
|
||||||
|
ui/dialogs/ChooseOfflineNameDialog.ui
|
||||||
|
)
|
||||||
|
|
||||||
|
qt_wrap_ui(PRISM_UPDATE_UI
|
||||||
|
ui/dialogs/UpdateAvailableDialog.ui
|
||||||
|
)
|
||||||
|
|
||||||
|
if (NOT Apple)
|
||||||
|
set (LAUNCHER_UI ${LAUNCHER_UI} ${PRISM_UPDATE_UI})
|
||||||
|
endif()
|
||||||
|
|
||||||
qt_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
|
||||||
|
|
@ -1218,40 +1282,45 @@ qt_add_resources(LAUNCHER_RESOURCES
|
||||||
resources/OSX/OSX.qrc
|
resources/OSX/OSX.qrc
|
||||||
resources/iOS/iOS.qrc
|
resources/iOS/iOS.qrc
|
||||||
resources/flat/flat.qrc
|
resources/flat/flat.qrc
|
||||||
resources/flat_white/flat_white.qrc
|
|
||||||
resources/documents/documents.qrc
|
resources/documents/documents.qrc
|
||||||
resources/shaders/shaders.qrc
|
resources/shaders/shaders.qrc
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/../${Launcher_Branding_LogoQRC}"
|
"${CMAKE_CURRENT_BINARY_DIR}/../${Launcher_Branding_LogoQRC}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
qt_wrap_ui(PRISMUPDATER_UI
|
||||||
|
updater/prismupdater/SelectReleaseDialog.ui
|
||||||
|
ui/widgets/SubTaskProgressBar.ui
|
||||||
|
ui/dialogs/ProgressDialog.ui
|
||||||
|
)
|
||||||
|
|
||||||
######## Windows resource files ########
|
######## Windows resource files ########
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(LAUNCHER_RCS ${CMAKE_CURRENT_BINARY_DIR}/../${Launcher_Branding_WindowsRC})
|
set(LAUNCHER_RCS ${CMAKE_CURRENT_BINARY_DIR}/../${Launcher_Branding_WindowsRC})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
include(CompilerWarnings)
|
||||||
|
|
||||||
######## Precompiled Headers ###########
|
######## Precompiled Headers ###########
|
||||||
|
|
||||||
if(${Launcher_USE_PCH})
|
|
||||||
message(STATUS "Using precompiled headers for applicable launcher targets")
|
|
||||||
set(PRECOMPILED_HEADERS
|
set(PRECOMPILED_HEADERS
|
||||||
include/base.pch.hpp
|
include/base.pch.hpp
|
||||||
include/qtcore.pch.hpp
|
include/qtcore.pch.hpp
|
||||||
include/qtgui.pch.hpp
|
include/qtgui.pch.hpp
|
||||||
)
|
)
|
||||||
endif()
|
|
||||||
|
|
||||||
####### Targets ########
|
####### Targets ########
|
||||||
|
|
||||||
# Add executable
|
# Add executable
|
||||||
add_library(Launcher_logic STATIC ${LOGIC_SOURCES} ${LAUNCHER_SOURCES} ${LAUNCHER_RESOURCES})
|
add_library(Launcher_logic STATIC ${LOGIC_SOURCES} ${LAUNCHER_SOURCES} ${LAUNCHER_UI} ${LAUNCHER_RESOURCES})
|
||||||
|
set_project_warnings(Launcher_logic
|
||||||
|
"${Launcher_MSVC_WARNINGS}"
|
||||||
|
"${Launcher_CLANG_WARNINGS}"
|
||||||
|
"${Launcher_GCC_WARNINGS}")
|
||||||
target_include_directories(Launcher_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(Launcher_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
target_compile_definitions(Launcher_logic PUBLIC LAUNCHER_APPLICATION)
|
target_compile_definitions(Launcher_logic PUBLIC LAUNCHER_APPLICATION)
|
||||||
|
|
||||||
if(${Launcher_USE_PCH})
|
|
||||||
target_precompile_headers(Launcher_logic PRIVATE ${PRECOMPILED_HEADERS})
|
target_precompile_headers(Launcher_logic PRIVATE ${PRECOMPILED_HEADERS})
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(Launcher_logic
|
target_link_libraries(Launcher_logic
|
||||||
|
systeminfo
|
||||||
Launcher_murmur2
|
Launcher_murmur2
|
||||||
nbt++
|
nbt++
|
||||||
${ZLIB_LIBRARIES}
|
${ZLIB_LIBRARIES}
|
||||||
|
|
@ -1328,12 +1397,10 @@ if(APPLE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
target_link_libraries(Launcher_logic)
|
||||||
|
|
||||||
add_executable(${Launcher_Name} MACOSX_BUNDLE WIN32 main.cpp ${LAUNCHER_RCS})
|
add_executable(${Launcher_Name} MACOSX_BUNDLE WIN32 main.cpp ${LAUNCHER_RCS})
|
||||||
|
|
||||||
if(${Launcher_USE_PCH})
|
|
||||||
target_precompile_headers(${Launcher_Name} REUSE_FROM Launcher_logic)
|
target_precompile_headers(${Launcher_Name} REUSE_FROM Launcher_logic)
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(${Launcher_Name} Launcher_logic)
|
target_link_libraries(${Launcher_Name} Launcher_logic)
|
||||||
|
|
||||||
if(DEFINED Launcher_APP_BINARY_NAME)
|
if(DEFINED Launcher_APP_BINARY_NAME)
|
||||||
|
|
@ -1363,15 +1430,12 @@ endif()
|
||||||
|
|
||||||
if(Launcher_BUILD_UPDATER)
|
if(Launcher_BUILD_UPDATER)
|
||||||
# Updater
|
# Updater
|
||||||
add_library(prism_updater_logic STATIC ${PRISMUPDATER_SOURCES} ${TASKS_SOURCES})
|
add_library(prism_updater_logic STATIC ${PRISMUPDATER_SOURCES} ${TASKS_SOURCES} ${PRISMUPDATER_UI})
|
||||||
target_include_directories(prism_updater_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(prism_updater_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
if(${Launcher_USE_PCH})
|
|
||||||
target_precompile_headers(prism_updater_logic PRIVATE ${PRECOMPILED_HEADERS})
|
target_precompile_headers(prism_updater_logic PRIVATE ${PRECOMPILED_HEADERS})
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(prism_updater_logic
|
target_link_libraries(prism_updater_logic
|
||||||
${ZLIB_LIBRARIES}
|
${ZLIB_LIBRARIES}
|
||||||
|
systeminfo
|
||||||
BuildConfig
|
BuildConfig
|
||||||
Qt${QT_VERSION_MAJOR}::Widgets
|
Qt${QT_VERSION_MAJOR}::Widgets
|
||||||
Qt${QT_VERSION_MAJOR}::Core
|
Qt${QT_VERSION_MAJOR}::Core
|
||||||
|
|
@ -1388,10 +1452,7 @@ if(Launcher_BUILD_UPDATER)
|
||||||
add_executable("${Launcher_Name}_updater" WIN32 updater/prismupdater/updater_main.cpp)
|
add_executable("${Launcher_Name}_updater" WIN32 updater/prismupdater/updater_main.cpp)
|
||||||
target_sources("${Launcher_Name}_updater" PRIVATE updater/prismupdater/updater.exe.manifest)
|
target_sources("${Launcher_Name}_updater" PRIVATE updater/prismupdater/updater.exe.manifest)
|
||||||
target_link_libraries("${Launcher_Name}_updater" prism_updater_logic)
|
target_link_libraries("${Launcher_Name}_updater" prism_updater_logic)
|
||||||
|
|
||||||
if(${Launcher_USE_PCH})
|
|
||||||
target_precompile_headers("${Launcher_Name}_updater" REUSE_FROM prism_updater_logic)
|
target_precompile_headers("${Launcher_Name}_updater" REUSE_FROM prism_updater_logic)
|
||||||
endif()
|
|
||||||
|
|
||||||
if(DEFINED Launcher_APP_BINARY_NAME)
|
if(DEFINED Launcher_APP_BINARY_NAME)
|
||||||
set_target_properties("${Launcher_Name}_updater" PROPERTIES OUTPUT_NAME "${Launcher_APP_BINARY_NAME}_updater")
|
set_target_properties("${Launcher_Name}_updater" PROPERTIES OUTPUT_NAME "${Launcher_APP_BINARY_NAME}_updater")
|
||||||
|
|
@ -1416,14 +1477,16 @@ endif()
|
||||||
if(WIN32 OR (DEFINED Launcher_BUILD_FILELINKER AND Launcher_BUILD_FILELINKER))
|
if(WIN32 OR (DEFINED Launcher_BUILD_FILELINKER AND Launcher_BUILD_FILELINKER))
|
||||||
# File link
|
# File link
|
||||||
add_library(filelink_logic STATIC ${LINKEXE_SOURCES})
|
add_library(filelink_logic STATIC ${LINKEXE_SOURCES})
|
||||||
|
set_project_warnings(filelink_logic
|
||||||
|
"${Launcher_MSVC_WARNINGS}"
|
||||||
|
"${Launcher_CLANG_WARNINGS}"
|
||||||
|
"${Launcher_GCC_WARNINGS}")
|
||||||
|
|
||||||
target_include_directories(filelink_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(filelink_logic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
if(${Launcher_USE_PCH})
|
|
||||||
target_precompile_headers(filelink_logic PRIVATE ${PRECOMPILED_HEADERS})
|
target_precompile_headers(filelink_logic PRIVATE ${PRECOMPILED_HEADERS})
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(filelink_logic
|
target_link_libraries(filelink_logic
|
||||||
|
systeminfo
|
||||||
BuildConfig
|
BuildConfig
|
||||||
Qt${QT_VERSION_MAJOR}::Widgets
|
Qt${QT_VERSION_MAJOR}::Widgets
|
||||||
Qt${QT_VERSION_MAJOR}::Core
|
Qt${QT_VERSION_MAJOR}::Core
|
||||||
|
|
@ -1433,11 +1496,9 @@ if(WIN32 OR (DEFINED Launcher_BUILD_FILELINKER AND Launcher_BUILD_FILELINKER))
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable("${Launcher_Name}_filelink" WIN32 filelink/filelink_main.cpp)
|
add_executable("${Launcher_Name}_filelink" WIN32 filelink/filelink_main.cpp)
|
||||||
target_sources("${Launcher_Name}_filelink" PRIVATE filelink/filelink.exe.manifest)
|
|
||||||
|
|
||||||
if(${Launcher_USE_PCH})
|
target_sources("${Launcher_Name}_filelink" PRIVATE filelink/filelink.exe.manifest)
|
||||||
target_precompile_headers("${Launcher_Name}_filelink" REUSE_FROM filelink_logic)
|
target_precompile_headers("${Launcher_Name}_filelink" REUSE_FROM filelink_logic)
|
||||||
endif()
|
|
||||||
|
|
||||||
# HACK: Fix manifest issues with Ninja in release mode (and only release mode) and MSVC
|
# HACK: Fix manifest issues with Ninja in release mode (and only release mode) and MSVC
|
||||||
# I have no idea why this works or why it's needed. UPDATE THIS IF YOU EDIT THE MANIFEST!!! -@getchoo
|
# I have no idea why this works or why it's needed. UPDATE THIS IF YOU EDIT THE MANIFEST!!! -@getchoo
|
||||||
|
|
@ -1475,28 +1536,6 @@ if (UNIX AND APPLE AND Launcher_ENABLE_UPDATER)
|
||||||
install(DIRECTORY ${MACOSX_SPARKLE_DIR}/Sparkle.framework DESTINATION ${FRAMEWORK_DEST_DIR} USE_SOURCE_PERMISSIONS)
|
install(DIRECTORY ${MACOSX_SPARKLE_DIR}/Sparkle.framework DESTINATION ${FRAMEWORK_DEST_DIR} USE_SOURCE_PERMISSIONS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Set basic compiler warning/error flags for all targets
|
|
||||||
get_property(Launcher_TARGETS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS)
|
|
||||||
foreach(target ${Launcher_TARGETS})
|
|
||||||
message(STATUS "Enabling all warnings as errors for target '${target}'")
|
|
||||||
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
|
|
||||||
target_compile_options(${target} PRIVATE /W4 /WX /permissive-)
|
|
||||||
else()
|
|
||||||
target_compile_options(${target} PRIVATE -Wall -Wextra -Wpedantic -Werror)
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# Disable some warnings in main launcher target due to being present in a lot of places. TODO: Fix them.
|
|
||||||
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
|
|
||||||
target_compile_options(Launcher_logic PRIVATE /wd4100) # C4100 - unused parameter
|
|
||||||
target_compile_options(${Launcher_Name} PRIVATE /wd4100) # C4100 - unused parameter
|
|
||||||
else()
|
|
||||||
# sfinae-incomplete is a new GCC warning and triggers in Qt headers
|
|
||||||
# no-unknown-warning-option so that compilers that don't have sfinae-incomplete don't error
|
|
||||||
target_compile_options(Launcher_logic PRIVATE -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unknown-warning-option -Wno-sfinae-incomplete)
|
|
||||||
target_compile_options(${Launcher_Name} PRIVATE -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unknown-warning-option -Wno-sfinae-incomplete)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#### The bundle mess! ####
|
#### The bundle mess! ####
|
||||||
# Bundle utilities are used to complete packages for different platforms - they add all the libraries that would otherwise be missing on the target system.
|
# Bundle utilities are used to complete packages for different platforms - 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.
|
||||||
|
|
@ -1546,49 +1585,6 @@ if(WIN32 OR (UNIX AND APPLE))
|
||||||
SCRIPT ${QT_DEPLOY_SCRIPT}
|
SCRIPT ${QT_DEPLOY_SCRIPT}
|
||||||
COMPONENT bundle
|
COMPONENT bundle
|
||||||
)
|
)
|
||||||
# FIXME: remove this crap once we stop using msys2
|
|
||||||
if(MINGW)
|
|
||||||
# i've not found a solution better than injecting the config vars like this...
|
|
||||||
# with install(CODE" for everything everything just breaks
|
|
||||||
install(CODE "
|
|
||||||
set(QT_PLUGINS_DIR \"${QT_PLUGINS_DIR}\")
|
|
||||||
set(QT_LIBS_DIR \"${QT_LIBS_DIR}\")
|
|
||||||
set(QT_LIBEXECS_DIR \"${QT_LIBEXECS_DIR}\")
|
|
||||||
set(CMAKE_SYSTEM_LIBRARY_PATH \"${CMAKE_SYSTEM_LIBRARY_PATH}\")
|
|
||||||
set(CMAKE_INSTALL_PREFIX \"${CMAKE_INSTALL_PREFIX}\")
|
|
||||||
"
|
|
||||||
COMPONENT bundle)
|
|
||||||
|
|
||||||
install(CODE [[
|
|
||||||
file(GLOB QT_IMAGEFORMAT_DLLS "${QT_PLUGINS_DIR}/imageformats/*.dll")
|
|
||||||
set(CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL objdump)
|
|
||||||
file(GET_RUNTIME_DEPENDENCIES
|
|
||||||
RESOLVED_DEPENDENCIES_VAR imageformatdeps
|
|
||||||
LIBRARIES ${QT_IMAGEFORMAT_DLLS}
|
|
||||||
DIRECTORIES
|
|
||||||
${CMAKE_SYSTEM_LIBRARY_PATH}
|
|
||||||
${QT_PLUGINS_DIR}
|
|
||||||
${QT_LIBS_DIR}
|
|
||||||
${QT_LIBEXECS_DIR}
|
|
||||||
PRE_EXCLUDE_REGEXES
|
|
||||||
"^(api-ms-win|ext-ms)-.*\\.dll$"
|
|
||||||
# FIXME: Why aren't these caught by the below regex???
|
|
||||||
"^azure.*\\.dll$"
|
|
||||||
"^vcruntime.*\\.dll$"
|
|
||||||
POST_EXCLUDE_REGEXES
|
|
||||||
"system32"
|
|
||||||
)
|
|
||||||
foreach(_lib ${imageformatdeps})
|
|
||||||
file(INSTALL
|
|
||||||
DESTINATION ${CMAKE_INSTALL_PREFIX}
|
|
||||||
TYPE SHARED_LIBRARY
|
|
||||||
FOLLOW_SYMLINK_CHAIN
|
|
||||||
FILES ${_lib}
|
|
||||||
)
|
|
||||||
endforeach()
|
|
||||||
]]
|
|
||||||
COMPONENT bundle)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Add qt.conf - this makes Qt stop looking for things outside the bundle
|
# Add qt.conf - this makes Qt stop looking for things outside the bundle
|
||||||
install(
|
install(
|
||||||
|
|
@ -1602,15 +1598,3 @@ if(WIN32 OR (UNIX AND APPLE))
|
||||||
COMPONENT bundle
|
COMPONENT bundle
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_program(CLANG_FORMAT clang-format OPTIONAL)
|
|
||||||
if(CLANG_FORMAT)
|
|
||||||
message(STATUS "Creating clang-format target")
|
|
||||||
add_custom_target(
|
|
||||||
clang-format
|
|
||||||
COMMAND ${CLANG_FORMAT} -i --style=file:${CMAKE_SOURCE_DIR}/.clang-format ${LOGIC_SOURCES} ${LAUNCHER_SOURCES} ${PRISMUPDATER_SOURCES} ${LINKEXE_SOURCES} ${PRECOMPILED_HEADERS}
|
|
||||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
|
||||||
)
|
|
||||||
else()
|
|
||||||
message(WARNING "Unable to find `clang-format`. Not creating custom target")
|
|
||||||
endif()
|
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ void DataMigrationTask::dryRunFinished()
|
||||||
|
|
||||||
void DataMigrationTask::dryRunAborted()
|
void DataMigrationTask::dryRunAborted()
|
||||||
{
|
{
|
||||||
emitAborted();
|
emitFailed(tr("Aborted"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataMigrationTask::copyFinished()
|
void DataMigrationTask::copyFinished()
|
||||||
|
|
@ -81,5 +81,5 @@ void DataMigrationTask::copyFinished()
|
||||||
|
|
||||||
void DataMigrationTask::copyAborted()
|
void DataMigrationTask::copyAborted()
|
||||||
{
|
{
|
||||||
emitAborted();
|
emitFailed(tr("Aborted"));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
23
launcher/DefaultVariable.h
Normal file
23
launcher/DefaultVariable.h
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class DefaultVariable {
|
||||||
|
public:
|
||||||
|
DefaultVariable(const T& value) { defaultValue = value; }
|
||||||
|
DefaultVariable<T>& operator=(const T& value)
|
||||||
|
{
|
||||||
|
currentValue = value;
|
||||||
|
is_default = currentValue == defaultValue;
|
||||||
|
is_explicit = true;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
operator const T&() const { return is_default ? defaultValue : currentValue; }
|
||||||
|
bool isDefault() const { return is_default; }
|
||||||
|
bool isExplicit() const { return is_explicit; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
T currentValue;
|
||||||
|
T defaultValue;
|
||||||
|
bool is_default = true;
|
||||||
|
bool is_explicit = false;
|
||||||
|
};
|
||||||
|
|
@ -266,21 +266,7 @@ bool FileIgnoreProxy::filterAcceptsRow(int sourceRow, const QModelIndex& sourceP
|
||||||
|
|
||||||
bool FileIgnoreProxy::ignoreFile(QFileInfo fileInfo) const
|
bool FileIgnoreProxy::ignoreFile(QFileInfo fileInfo) const
|
||||||
{
|
{
|
||||||
if (m_ignoreFiles.contains(fileInfo.fileName())) {
|
return m_ignoreFiles.contains(fileInfo.fileName()) || m_ignoreFilePaths.covers(relPath(fileInfo.absoluteFilePath()));
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto& suffix : m_ignoreFilesSuffixes) {
|
|
||||||
if (fileInfo.fileName().endsWith(suffix)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_ignoreFilePaths.covers(relPath(fileInfo.absoluteFilePath()))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileIgnoreProxy::filterFile(const QFileInfo& file) const
|
bool FileIgnoreProxy::filterFile(const QFileInfo& file) const
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,6 @@ class FileIgnoreProxy : public QSortFilterProxyModel {
|
||||||
|
|
||||||
// list of file names that need to be removed completely from model
|
// list of file names that need to be removed completely from model
|
||||||
inline QStringList& ignoreFilesWithName() { return m_ignoreFiles; }
|
inline QStringList& ignoreFilesWithName() { return m_ignoreFiles; }
|
||||||
inline QStringList& ignoreFilesWithSuffix() { return m_ignoreFilesSuffixes; }
|
|
||||||
// list of relative paths that need to be removed completely from model
|
// list of relative paths that need to be removed completely from model
|
||||||
inline SeparatorPrefixTree<'/'>& ignoreFilesWithPath() { return m_ignoreFilePaths; }
|
inline SeparatorPrefixTree<'/'>& ignoreFilesWithPath() { return m_ignoreFilePaths; }
|
||||||
|
|
||||||
|
|
@ -86,6 +85,5 @@ class FileIgnoreProxy : public QSortFilterProxyModel {
|
||||||
const QString m_root;
|
const QString m_root;
|
||||||
SeparatorPrefixTree<'/'> m_blocked;
|
SeparatorPrefixTree<'/'> m_blocked;
|
||||||
QStringList m_ignoreFiles;
|
QStringList m_ignoreFiles;
|
||||||
QStringList m_ignoreFilesSuffixes;
|
|
||||||
SeparatorPrefixTree<'/'> m_ignoreFilePaths;
|
SeparatorPrefixTree<'/'> m_ignoreFilePaths;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
#include <qcontainerfwd.h>
|
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
|
|
||||||
#include "BuildConfig.h"
|
#include "BuildConfig.h"
|
||||||
|
|
@ -283,9 +282,6 @@ bool copyFileAttributes(QString src, QString dst)
|
||||||
if (attrs == INVALID_FILE_ATTRIBUTES)
|
if (attrs == INVALID_FILE_ATTRIBUTES)
|
||||||
return false;
|
return false;
|
||||||
return SetFileAttributesW(dst.toStdWString().c_str(), attrs);
|
return SetFileAttributesW(dst.toStdWString().c_str(), attrs);
|
||||||
#else
|
|
||||||
Q_UNUSED(src);
|
|
||||||
Q_UNUSED(dst);
|
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -436,7 +432,7 @@ void create_link::make_link_list(const QString& offset)
|
||||||
link_file(src, "");
|
link_file(src, "");
|
||||||
} else {
|
} else {
|
||||||
if (m_debug)
|
if (m_debug)
|
||||||
qDebug().nospace() << "linking recursively: " << src << " to " << dst << ", max_depth: " << m_max_depth;
|
qDebug() << "linking recursively:" << src << "to" << dst << ", max_depth:" << m_max_depth;
|
||||||
QDir src_dir(src);
|
QDir src_dir(src);
|
||||||
QDirIterator source_it(src, QDir::Filter::Files | QDir::Filter::Hidden, QDirIterator::Subdirectories);
|
QDirIterator source_it(src, QDir::Filter::Files | QDir::Filter::Hidden, QDirIterator::Subdirectories);
|
||||||
|
|
||||||
|
|
@ -596,7 +592,7 @@ void create_link::runPrivileged(const QString& offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
ExternalLinkFileProcess* linkFileProcess = new ExternalLinkFileProcess(serverName, m_useHardLinks, this);
|
ExternalLinkFileProcess* linkFileProcess = new ExternalLinkFileProcess(serverName, m_useHardLinks, this);
|
||||||
connect(linkFileProcess, &ExternalLinkFileProcess::processExited, this, [this, &gotResults]() { emit finishedPrivileged(gotResults); });
|
connect(linkFileProcess, &ExternalLinkFileProcess::processExited, this, [this, gotResults]() { emit finishedPrivileged(gotResults); });
|
||||||
connect(linkFileProcess, &ExternalLinkFileProcess::finished, linkFileProcess, &QObject::deleteLater);
|
connect(linkFileProcess, &ExternalLinkFileProcess::finished, linkFileProcess, &QObject::deleteLater);
|
||||||
|
|
||||||
linkFileProcess->start();
|
linkFileProcess->start();
|
||||||
|
|
@ -684,32 +680,6 @@ bool deletePath(QString path)
|
||||||
return err.value() == 0;
|
return err.value() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool deleteContents(const QString& path)
|
|
||||||
{
|
|
||||||
const QFileInfo info(path);
|
|
||||||
if (!info.exists()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!info.isDir()) {
|
|
||||||
qWarning() << "Attempted to delete contents of non-directory path:" << path;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ret = true;
|
|
||||||
|
|
||||||
for (const auto& entry : fs::directory_iterator(StringUtils::toStdString(path))) {
|
|
||||||
std::error_code err;
|
|
||||||
|
|
||||||
fs::remove_all(entry.path(), err);
|
|
||||||
if (err.value() != 0) {
|
|
||||||
qWarning().nospace() << "Could not delete directory entry " << entry.path() << ": " << QString::fromStdString(err.message());
|
|
||||||
ret = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool trash(QString path, QString* pathInTrash)
|
bool trash(QString path, QString* pathInTrash)
|
||||||
{
|
{
|
||||||
// FIXME: Figure out trash in Flatpak. Qt seemingly doesn't use the Trash portal
|
// FIXME: Figure out trash in Flatpak. Qt seemingly doesn't use the Trash portal
|
||||||
|
|
@ -823,33 +793,68 @@ QString NormalizePath(QString path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
static const QString BAD_WIN_CHARS = "<>:\"|?*\r\n";
|
||||||
const QString g_badChars = "<>:\"|?*\r\n!";
|
static const QString BAD_NTFS_CHARS = "<>:\"|?*";
|
||||||
QString removeChars(QString source, QChar replace, const QString& extraChars = "")
|
static const QString BAD_HFS_CHARS = ":";
|
||||||
{
|
|
||||||
auto badChars = g_badChars;
|
|
||||||
if (!extraChars.isEmpty()) {
|
|
||||||
badChars += extraChars;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto& c : source) {
|
static const QString BAD_FILENAME_CHARS = BAD_WIN_CHARS + "\\/";
|
||||||
if (c.unicode() < 0x20 || !c.isPrint() || badChars.contains(c)) {
|
|
||||||
c = replace;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return source;
|
|
||||||
}
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
QString RemoveInvalidFilenameChars(QString string, QChar replaceWith)
|
QString RemoveInvalidFilenameChars(QString string, QChar replaceWith)
|
||||||
{
|
{
|
||||||
return removeChars(std::move(string), replaceWith, "\\/");
|
for (int i = 0; i < string.length(); i++)
|
||||||
|
if (string.at(i) < ' ' || BAD_FILENAME_CHARS.contains(string.at(i)))
|
||||||
|
string[i] = replaceWith;
|
||||||
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RemoveInvalidPathChars(QString string, QChar replaceWith)
|
QString RemoveInvalidPathChars(QString path, QChar replaceWith)
|
||||||
{
|
{
|
||||||
return removeChars(std::move(string), replaceWith);
|
QString invalidChars;
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
invalidChars = BAD_WIN_CHARS;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// the null character is ignored in this check as it was not a problem until now
|
||||||
|
switch (statFS(path).fsType) {
|
||||||
|
case FilesystemType::FAT: // similar to NTFS
|
||||||
|
/* fallthrough */
|
||||||
|
case FilesystemType::NTFS:
|
||||||
|
/* fallthrough */
|
||||||
|
case FilesystemType::REFS: // similar to NTFS(should be available only on windows)
|
||||||
|
invalidChars += BAD_NTFS_CHARS;
|
||||||
|
break;
|
||||||
|
// case FilesystemType::EXT:
|
||||||
|
// case FilesystemType::EXT_2_OLD:
|
||||||
|
// case FilesystemType::EXT_2_3_4:
|
||||||
|
// case FilesystemType::XFS:
|
||||||
|
// case FilesystemType::BTRFS:
|
||||||
|
// case FilesystemType::NFS:
|
||||||
|
// case FilesystemType::ZFS:
|
||||||
|
case FilesystemType::APFS:
|
||||||
|
/* fallthrough */
|
||||||
|
case FilesystemType::HFS:
|
||||||
|
/* fallthrough */
|
||||||
|
case FilesystemType::HFSPLUS:
|
||||||
|
/* fallthrough */
|
||||||
|
case FilesystemType::HFSX:
|
||||||
|
invalidChars += BAD_HFS_CHARS;
|
||||||
|
break;
|
||||||
|
// case FilesystemType::FUSEBLK:
|
||||||
|
// case FilesystemType::F2FS:
|
||||||
|
// case FilesystemType::UNKNOWN:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (invalidChars.size() != 0) {
|
||||||
|
for (int i = 0; i < path.length(); i++) {
|
||||||
|
if (path.at(i) < ' ' || invalidChars.contains(path.at(i))) {
|
||||||
|
path[i] = replaceWith;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString DirNameFromString(QString string, QString inDir)
|
QString DirNameFromString(QString string, QString inDir)
|
||||||
|
|
@ -945,10 +950,7 @@ QString createShortcut(QString destination, QString target, QStringList args, QS
|
||||||
qWarning() << "Couldn't create directories within application";
|
qWarning() << "Couldn't create directories within application";
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
if (!info.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
info.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||||
qWarning() << "Failed to open file" << info.fileName() << "for writing:" << info.errorString();
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
QFile(icon).rename(resources.path() + "/Icon.icns");
|
QFile(icon).rename(resources.path() + "/Icon.icns");
|
||||||
|
|
||||||
|
|
@ -956,10 +958,7 @@ QString createShortcut(QString destination, QString target, QStringList args, QS
|
||||||
QString exec = binaryDir.path() + "/Run.command";
|
QString exec = binaryDir.path() + "/Run.command";
|
||||||
|
|
||||||
QFile f(exec);
|
QFile f(exec);
|
||||||
if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
f.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||||
qWarning() << "Failed to open file" << f.fileName() << "for writing:" << f.errorString();
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
QTextStream stream(&f);
|
QTextStream stream(&f);
|
||||||
|
|
||||||
auto argstring = quoteArgs(args, "\"", "\\\"");
|
auto argstring = quoteArgs(args, "\"", "\\\"");
|
||||||
|
|
@ -1002,7 +1001,7 @@ QString createShortcut(QString destination, QString target, QStringList args, QS
|
||||||
destination += ".desktop";
|
destination += ".desktop";
|
||||||
QFile f(destination);
|
QFile f(destination);
|
||||||
if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
qWarning() << "Failed to open file" << f.fileName() << "for writing:" << f.errorString();
|
qWarning() << "Failed to open file '" << f.fileName() << "' for writing!";
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
QTextStream stream(&f);
|
QTextStream stream(&f);
|
||||||
|
|
|
||||||
|
|
@ -291,13 +291,6 @@ bool move(const QString& source, const QString& dest);
|
||||||
*/
|
*/
|
||||||
bool deletePath(QString path);
|
bool deletePath(QString path);
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete a folder's contents recursively but not the folder itself.
|
|
||||||
* @param path The path to the folder.
|
|
||||||
* @return Whether the deletion was completely successful.
|
|
||||||
*/
|
|
||||||
bool deleteContents(const QString& path);
|
|
||||||
|
|
||||||
bool removeFiles(QStringList listFile);
|
bool removeFiles(QStringList listFile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -172,8 +172,7 @@ int inf(QFile* source, std::function<bool(const QByteArray&)> handleBlock)
|
||||||
assert(ret != Z_STREAM_ERROR); /* state not clobbered */
|
assert(ret != Z_STREAM_ERROR); /* state not clobbered */
|
||||||
switch (ret) {
|
switch (ret) {
|
||||||
case Z_NEED_DICT:
|
case Z_NEED_DICT:
|
||||||
ret = Z_DATA_ERROR;
|
ret = Z_DATA_ERROR; /* and fall through */
|
||||||
[[fallthrough]];
|
|
||||||
case Z_DATA_ERROR:
|
case Z_DATA_ERROR:
|
||||||
case Z_MEM_ERROR:
|
case Z_MEM_ERROR:
|
||||||
(void)inflateEnd(&strm);
|
(void)inflateEnd(&strm);
|
||||||
|
|
|
||||||
|
|
@ -1,355 +0,0 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
/*
|
|
||||||
* Prism Launcher - Minecraft Launcher
|
|
||||||
* Copyright (C) 2026 Octol1ttle <l1ttleofficial@outlook.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "HardwareInfo.h"
|
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QStringList>
|
|
||||||
|
|
||||||
#if defined(Q_OS_MACOS) || defined(Q_OS_LINUX)
|
|
||||||
namespace {
|
|
||||||
QString afterColon(QString str)
|
|
||||||
{
|
|
||||||
return str.remove(0, str.indexOf(':') + 2).trimmed();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename F>
|
|
||||||
bool readFromOutput(const char* command, F function)
|
|
||||||
{
|
|
||||||
FILE* file = popen(command, "r"); // NOLINT(*-command-processor)
|
|
||||||
if (!file) {
|
|
||||||
qWarning().nospace() << "Could not execute command '" << command << "': " << strerror(errno);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr size_t bufferSize = 512;
|
|
||||||
std::array<char, bufferSize> buffer{};
|
|
||||||
while (fgets(buffer.data(), bufferSize, file) != nullptr) {
|
|
||||||
function(buffer.data());
|
|
||||||
}
|
|
||||||
|
|
||||||
const int exitCode = pclose(file);
|
|
||||||
if (exitCode != 0) {
|
|
||||||
if (exitCode == -1) {
|
|
||||||
qWarning().nospace() << "Could not close stream for command '" << command << "': " << strerror(errno);
|
|
||||||
} else {
|
|
||||||
qWarning().nospace() << "Command '" << command << "' exited with code " << exitCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} // namespace
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef Q_OS_WINDOWS
|
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#endif
|
|
||||||
#include <QSettings>
|
|
||||||
|
|
||||||
#include <dxgi1_6.h>
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#include <wrl/client.h>
|
|
||||||
using Microsoft::WRL::ComPtr;
|
|
||||||
|
|
||||||
QString HardwareInfo::cpuInfo()
|
|
||||||
{
|
|
||||||
const QSettings registry(R"(HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0)", QSettings::NativeFormat);
|
|
||||||
return registry.value("ProcessorNameString").toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t HardwareInfo::totalRamMiB()
|
|
||||||
{
|
|
||||||
MEMORYSTATUSEX status;
|
|
||||||
status.dwLength = sizeof status;
|
|
||||||
|
|
||||||
if (GlobalMemoryStatusEx(&status) == TRUE) {
|
|
||||||
// transforming bytes -> mib
|
|
||||||
return status.ullTotalPhys / 1024 / 1024;
|
|
||||||
}
|
|
||||||
|
|
||||||
qWarning() << "Could not get total RAM: GlobalMemoryStatusEx";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t HardwareInfo::availableRamMiB()
|
|
||||||
{
|
|
||||||
MEMORYSTATUSEX status;
|
|
||||||
status.dwLength = sizeof status;
|
|
||||||
|
|
||||||
if (GlobalMemoryStatusEx(&status) == TRUE) {
|
|
||||||
// transforming bytes -> mib
|
|
||||||
return status.ullAvailPhys / 1024 / 1024;
|
|
||||||
}
|
|
||||||
|
|
||||||
qWarning() << "Could not get available RAM: GlobalMemoryStatusEx";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList HardwareInfo::gpuInfo()
|
|
||||||
{
|
|
||||||
ComPtr<IDXGIFactory6> factory;
|
|
||||||
HRESULT hr = CreateDXGIFactory1(IID_PPV_ARGS(&factory));
|
|
||||||
if (FAILED(hr)) {
|
|
||||||
qWarning() << "Could not create DXGI factory:" << Qt::hex << hr;
|
|
||||||
return { "GPU discovery failed: could not create DXGI factory" };
|
|
||||||
}
|
|
||||||
|
|
||||||
UINT i = 0;
|
|
||||||
ComPtr<IDXGIAdapter> adapter;
|
|
||||||
QStringList out;
|
|
||||||
while (factory->EnumAdapterByGpuPreference(i, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE, IID_PPV_ARGS(&adapter)) != DXGI_ERROR_NOT_FOUND) {
|
|
||||||
DXGI_ADAPTER_DESC desc;
|
|
||||||
hr = adapter->GetDesc(&desc);
|
|
||||||
if (SUCCEEDED(hr)) {
|
|
||||||
out << "GPU: " + QString::fromWCharArray(desc.Description); // NOLINT(*-pro-bounds-array-to-pointer-decay, *-no-array-decay)
|
|
||||||
} else {
|
|
||||||
qWarning() << "Could not get DXGI adapter description:" << Qt::hex << hr;
|
|
||||||
}
|
|
||||||
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(Q_OS_MACOS)
|
|
||||||
#include "sys/sysctl.h"
|
|
||||||
|
|
||||||
QString HardwareInfo::cpuInfo()
|
|
||||||
{
|
|
||||||
std::array<char, 512> buffer{};
|
|
||||||
size_t bufferSize = buffer.size();
|
|
||||||
if (sysctlbyname("machdep.cpu.brand_string", &buffer, &bufferSize, nullptr, 0) == 0) {
|
|
||||||
return { buffer.data() };
|
|
||||||
}
|
|
||||||
|
|
||||||
qWarning() << "Could not get CPU model: sysctlbyname";
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t HardwareInfo::totalRamMiB()
|
|
||||||
{
|
|
||||||
uint64_t memsize = 0;
|
|
||||||
size_t memsizeSize = sizeof memsize;
|
|
||||||
if (sysctlbyname("hw.memsize", &memsize, &memsizeSize, nullptr, 0) == 0) {
|
|
||||||
// transforming bytes -> mib
|
|
||||||
return memsize / 1024 / 1024;
|
|
||||||
}
|
|
||||||
|
|
||||||
qWarning() << "Could not get total RAM: sysctlbyname";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t HardwareInfo::availableRamMiB()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
MacOSHardwareInfo::MemoryPressureLevel MacOSHardwareInfo::memoryPressureLevel()
|
|
||||||
{
|
|
||||||
uint32_t level = 0;
|
|
||||||
size_t levelSize = sizeof level;
|
|
||||||
if (sysctlbyname("kern.memorystatus_vm_pressure_level", &level, &levelSize, nullptr, 0) == 0) {
|
|
||||||
return static_cast<MemoryPressureLevel>(level);
|
|
||||||
}
|
|
||||||
|
|
||||||
qWarning() << "Could not get memory pressure level: sysctlbyname";
|
|
||||||
return MemoryPressureLevel::Normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString MacOSHardwareInfo::memoryPressureLevelName()
|
|
||||||
{
|
|
||||||
// The names are internal, users refer to levels by their graph colors in Activity Monitor
|
|
||||||
switch (memoryPressureLevel()) {
|
|
||||||
case MemoryPressureLevel::Normal:
|
|
||||||
return "Green";
|
|
||||||
case MemoryPressureLevel::Warning:
|
|
||||||
return "Yellow";
|
|
||||||
case MemoryPressureLevel::Critical:
|
|
||||||
return "Red";
|
|
||||||
default:
|
|
||||||
Q_ASSERT(false);
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList HardwareInfo::gpuInfo()
|
|
||||||
{
|
|
||||||
QStringList out;
|
|
||||||
const bool success = readFromOutput("system_profiler SPDisplaysDataType", [&](const QString& str) {
|
|
||||||
// Chipset Model: Intel HD Graphics 620
|
|
||||||
if (str.contains("Chipset Model")) {
|
|
||||||
out << "GPU: " + afterColon(str);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (!success) {
|
|
||||||
return { "GPU discovery failed: could not read from system_profiler" };
|
|
||||||
}
|
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(Q_OS_LINUX)
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
QString HardwareInfo::cpuInfo()
|
|
||||||
{
|
|
||||||
std::ifstream cpuin("/proc/cpuinfo");
|
|
||||||
for (std::string line; std::getline(cpuin, line);) {
|
|
||||||
// model name : AMD Ryzen 7 5800X 8-Core Processor
|
|
||||||
if (const QString str = QString::fromStdString(line); str.startsWith("model name")) {
|
|
||||||
return afterColon(str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
qWarning() << "Could not get CPU model: /proc/cpuinfo";
|
|
||||||
return "unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
uint64_t readMemInfo(const QString& searchTarget)
|
|
||||||
{
|
|
||||||
std::ifstream memin("/proc/meminfo");
|
|
||||||
for (std::string line; std::getline(memin, line);) {
|
|
||||||
// MemTotal: 16287480 kB
|
|
||||||
if (const QString str = QString::fromStdString(line); str.startsWith(searchTarget)) {
|
|
||||||
bool ok = false;
|
|
||||||
const uint total = str.simplified().section(' ', 1, 1).toUInt(&ok);
|
|
||||||
if (!ok) {
|
|
||||||
qWarning() << "Could not read /proc/meminfo: failed to parse string:" << str;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// transforming kib -> mib
|
|
||||||
return total / 1024;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
qWarning() << "Could not read /proc/meminfo: search target not found:" << searchTarget;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
uint64_t HardwareInfo::totalRamMiB()
|
|
||||||
{
|
|
||||||
return readMemInfo("MemTotal");
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t HardwareInfo::availableRamMiB()
|
|
||||||
{
|
|
||||||
return readMemInfo("MemAvailable");
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList HardwareInfo::gpuInfo()
|
|
||||||
{
|
|
||||||
bool readingGpuInfo = false;
|
|
||||||
QString gpu;
|
|
||||||
QString driverInUse = "NONE";
|
|
||||||
QString driversAvailable = "NONE";
|
|
||||||
QStringList out;
|
|
||||||
|
|
||||||
const bool success = readFromOutput("lspci -k", [&](const QString& str) {
|
|
||||||
// clang-format off
|
|
||||||
// 04:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] (rev e7)
|
|
||||||
// Subsystem: Sapphire Technology Limited Radeon RX 580 Pulse 4GB
|
|
||||||
// Kernel driver in use: amdgpu
|
|
||||||
// Kernel modules: amdgpu
|
|
||||||
// clang-format on
|
|
||||||
if (str.contains("VGA compatible controller") || str.contains("3D controller")) {
|
|
||||||
readingGpuInfo = true;
|
|
||||||
} else if (!str.startsWith('\t')) {
|
|
||||||
if (readingGpuInfo) {
|
|
||||||
out << QString("GPU: %1 (driver in use: %2; drivers available: %3)").arg(gpu, driverInUse, driversAvailable);
|
|
||||||
driverInUse = "NONE";
|
|
||||||
driversAvailable = "NONE";
|
|
||||||
}
|
|
||||||
readingGpuInfo = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!readingGpuInfo) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString value = afterColon(str);
|
|
||||||
if (str.contains("Subsystem")) {
|
|
||||||
gpu = value;
|
|
||||||
}
|
|
||||||
if (str.contains("Kernel driver in use")) {
|
|
||||||
driverInUse = value;
|
|
||||||
}
|
|
||||||
if (str.contains("Kernel modules")) {
|
|
||||||
driversAvailable = value;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (!success) {
|
|
||||||
return { "GPU discovery failed: could not read from lspci" };
|
|
||||||
}
|
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
QString HardwareInfo::cpuInfo()
|
|
||||||
{
|
|
||||||
return "unknown";
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
uint64_t HardwareInfo::totalRamMiB()
|
|
||||||
{
|
|
||||||
uint64_t out = 0;
|
|
||||||
|
|
||||||
const bool success = readFromOutput("sysctl hw.physmem", [&](const QString& str) {
|
|
||||||
const uint64_t mem = str.mid(12).toULong();
|
|
||||||
|
|
||||||
// transforming kib -> mib
|
|
||||||
out = mem / 1024;
|
|
||||||
});
|
|
||||||
if (!success) {
|
|
||||||
qWarning() << "Could not get total RAM: could not read from sysctl";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
uint64_t HardwareInfo::totalRamMiB()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint64_t HardwareInfo::availableRamMiB()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList HardwareInfo::gpuInfo()
|
|
||||||
{
|
|
||||||
return { "GPU discovery failed: not implemented for this OS" };
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
/*
|
|
||||||
* Prism Launcher - Minecraft Launcher
|
|
||||||
* Copyright (C) 2026 Octol1ttle <l1ttleofficial@outlook.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
namespace HardwareInfo {
|
|
||||||
QString cpuInfo();
|
|
||||||
uint64_t totalRamMiB();
|
|
||||||
uint64_t availableRamMiB();
|
|
||||||
QStringList gpuInfo();
|
|
||||||
} // namespace HardwareInfo
|
|
||||||
|
|
||||||
#ifdef Q_OS_MACOS
|
|
||||||
namespace MacOSHardwareInfo {
|
|
||||||
enum class MemoryPressureLevel : uint8_t {
|
|
||||||
Normal = 1,
|
|
||||||
Warning = 2,
|
|
||||||
Critical = 4,
|
|
||||||
};
|
|
||||||
|
|
||||||
MemoryPressureLevel memoryPressureLevel();
|
|
||||||
QString memoryPressureLevelName();
|
|
||||||
} // namespace MacOSHardwareInfo
|
|
||||||
#endif
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#include "settings/INISettingsObject.h"
|
#include "settings/INISettingsObject.h"
|
||||||
#include "tasks/Task.h"
|
#include "tasks/Task.h"
|
||||||
|
|
||||||
InstanceCopyTask::InstanceCopyTask(BaseInstance* origInstance, const InstanceCopyPrefs& prefs)
|
InstanceCopyTask::InstanceCopyTask(InstancePtr origInstance, const InstanceCopyPrefs& prefs)
|
||||||
{
|
{
|
||||||
m_origInstance = origInstance;
|
m_origInstance = origInstance;
|
||||||
m_keepPlaytime = prefs.isKeepPlaytimeEnabled();
|
m_keepPlaytime = prefs.isKeepPlaytimeEnabled();
|
||||||
|
|
@ -64,6 +64,7 @@ void InstanceCopyTask::executeTask()
|
||||||
|
|
||||||
savesCopy = std::make_unique<FS::copy>(FS::PathCombine(m_origInstance->gameRoot(), "saves"),
|
savesCopy = std::make_unique<FS::copy>(FS::PathCombine(m_origInstance->gameRoot(), "saves"),
|
||||||
FS::PathCombine(staging_mc_dir, "saves"));
|
FS::PathCombine(staging_mc_dir, "saves"));
|
||||||
|
savesCopy->followSymlinks(true);
|
||||||
(*savesCopy)(true);
|
(*savesCopy)(true);
|
||||||
setProgress(0, savesCopy->totalCopied());
|
setProgress(0, savesCopy->totalCopied());
|
||||||
connect(savesCopy.get(), &FS::copy::fileCopied, [this](QString src) { setProgress(m_progress + 1, m_progressTotal); });
|
connect(savesCopy.get(), &FS::copy::fileCopied, [this](QString src) { setProgress(m_progress + 1, m_progressTotal); });
|
||||||
|
|
@ -125,11 +126,11 @@ void InstanceCopyTask::executeTask()
|
||||||
return !there_were_errors;
|
return !there_were_errors;
|
||||||
}
|
}
|
||||||
FS::copy folderCopy(m_origInstance->instanceRoot(), m_stagingPath);
|
FS::copy folderCopy(m_origInstance->instanceRoot(), m_stagingPath);
|
||||||
folderCopy.matcher(m_matcher);
|
folderCopy.followSymlinks(false).matcher(m_matcher);
|
||||||
|
|
||||||
folderCopy(true);
|
folderCopy(true);
|
||||||
setProgress(0, folderCopy.totalCopied());
|
setProgress(0, folderCopy.totalCopied());
|
||||||
connect(&folderCopy, &FS::copy::fileCopied, [this]() { setProgress(m_progress + 1, m_progressTotal); });
|
connect(&folderCopy, &FS::copy::fileCopied, [this](QString src) { setProgress(m_progress + 1, m_progressTotal); });
|
||||||
return folderCopy();
|
return folderCopy();
|
||||||
});
|
});
|
||||||
connect(&m_copyFutureWatcher, &QFutureWatcher<bool>::finished, this, &InstanceCopyTask::copyFinished);
|
connect(&m_copyFutureWatcher, &QFutureWatcher<bool>::finished, this, &InstanceCopyTask::copyFinished);
|
||||||
|
|
@ -146,9 +147,9 @@ void InstanceCopyTask::copyFinished()
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: shouldn't this be able to report errors?
|
// FIXME: shouldn't this be able to report errors?
|
||||||
auto instanceSettings = std::make_unique<INISettingsObject>(FS::PathCombine(m_stagingPath, "instance.cfg"));
|
auto instanceSettings = std::make_shared<INISettingsObject>(FS::PathCombine(m_stagingPath, "instance.cfg"));
|
||||||
|
|
||||||
BaseInstance* inst(new NullInstance(m_globalSettings, std::move(instanceSettings), m_stagingPath));
|
InstancePtr inst(new NullInstance(m_globalSettings, instanceSettings, m_stagingPath));
|
||||||
inst->setName(name());
|
inst->setName(name());
|
||||||
inst->setIconKey(m_instIcon);
|
inst->setIconKey(m_instIcon);
|
||||||
if (!m_keepPlaytime) {
|
if (!m_keepPlaytime) {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
class InstanceCopyTask : public InstanceTask {
|
class InstanceCopyTask : public InstanceTask {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit InstanceCopyTask(BaseInstance* origInstance, const InstanceCopyPrefs& prefs);
|
explicit InstanceCopyTask(InstancePtr origInstance, const InstanceCopyPrefs& prefs);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Entry point for tasks.
|
//! Entry point for tasks.
|
||||||
|
|
@ -26,7 +26,7 @@ class InstanceCopyTask : public InstanceTask {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* data */
|
/* data */
|
||||||
BaseInstance* m_origInstance;
|
InstancePtr m_origInstance;
|
||||||
QFuture<bool> m_copyFuture;
|
QFuture<bool> m_copyFuture;
|
||||||
QFutureWatcher<bool> m_copyFutureWatcher;
|
QFutureWatcher<bool> m_copyFutureWatcher;
|
||||||
Filter m_matcher;
|
Filter m_matcher;
|
||||||
|
|
|
||||||
|
|
@ -2,25 +2,7 @@
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include "FileSystem.h"
|
||||||
#include "Application.h"
|
|
||||||
#include "InstanceTask.h"
|
|
||||||
#include "minecraft/MinecraftLoadAndCheck.h"
|
|
||||||
#include "tasks/SequentialTask.h"
|
|
||||||
|
|
||||||
bool InstanceCreationTask::abort()
|
|
||||||
{
|
|
||||||
if (!canAbort()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_abort = true;
|
|
||||||
if (m_gameFilesTask) {
|
|
||||||
return m_gameFilesTask->abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
return InstanceTask::abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
void InstanceCreationTask::executeTask()
|
void InstanceCreationTask::executeTask()
|
||||||
{
|
{
|
||||||
|
|
@ -37,11 +19,9 @@ void InstanceCreationTask::executeTask()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_instance = createInstance();
|
if (!createInstance()) {
|
||||||
if (!m_instance) {
|
if (m_abort)
|
||||||
if (m_abort) {
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
qWarning() << "Instance creation failed!";
|
qWarning() << "Instance creation failed!";
|
||||||
if (!m_error_message.isEmpty()) {
|
if (!m_error_message.isEmpty()) {
|
||||||
|
|
@ -64,10 +44,9 @@ void InstanceCreationTask::executeTask()
|
||||||
setStatus(tr("Removing old conflicting files..."));
|
setStatus(tr("Removing old conflicting files..."));
|
||||||
qDebug() << "Removing old files";
|
qDebug() << "Removing old files";
|
||||||
|
|
||||||
for (const QString& path : m_filesToRemove) {
|
for (const QString& path : m_files_to_remove) {
|
||||||
if (!QFile::exists(path)) {
|
if (!QFile::exists(path))
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
qDebug() << "Removing" << path;
|
qDebug() << "Removing" << path;
|
||||||
|
|
||||||
|
|
@ -82,61 +61,6 @@ void InstanceCreationTask::executeTask()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!m_abort)
|
||||||
if (!m_abort) {
|
|
||||||
if (!APPLICATION->settings()->get("DownloadGameFilesDuringInstanceCreation").toBool()) {
|
|
||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
return;
|
|
||||||
}
|
|
||||||
setAbortable(true);
|
|
||||||
setAbortButtonText(tr("Skip"));
|
|
||||||
qDebug() << "Downloading game files";
|
|
||||||
|
|
||||||
auto updateTasks = m_instance->createUpdateTask();
|
|
||||||
if (updateTasks.isEmpty()) {
|
|
||||||
emitSucceeded();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto task = makeShared<SequentialTask>();
|
|
||||||
task->addTask(makeShared<MinecraftLoadAndCheck>(m_instance.get(), Net::Mode::Online));
|
|
||||||
for (const auto& t : updateTasks) {
|
|
||||||
task->addTask(t);
|
|
||||||
}
|
|
||||||
connect(task.get(), &Task::finished, this, [this, task] {
|
|
||||||
if (task->wasSuccessful() || m_abort) {
|
|
||||||
emitSucceeded();
|
|
||||||
} else {
|
|
||||||
emitFailed(tr("Could not download game files: %1").arg(task->failReason()));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
propagateFromOther(task.get());
|
|
||||||
setDetails(tr("Downloading game files"));
|
|
||||||
|
|
||||||
m_gameFilesTask = task;
|
|
||||||
m_gameFilesTask->start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void InstanceCreationTask::scheduleToDelete(QWidget* parent, const QDir& dir, const QString& path, bool checkDisabled)
|
|
||||||
{
|
|
||||||
if (path.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (path.startsWith("saves/")) {
|
|
||||||
if (m_shouldDeleteSaves == ShouldDeleteSaves::NotAsked) {
|
|
||||||
m_shouldDeleteSaves = askIfShouldDeleteSaves(parent);
|
|
||||||
}
|
|
||||||
if (m_shouldDeleteSaves == ShouldDeleteSaves::No) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
qDebug() << "Scheduling" << path << "for removal";
|
|
||||||
m_filesToRemove.append(dir.absoluteFilePath(path));
|
|
||||||
if (checkDisabled) {
|
|
||||||
if (path.endsWith(".disabled")) { // remove it if it was enabled/disabled by user
|
|
||||||
m_filesToRemove.append(dir.absoluteFilePath(path.chopped(9)));
|
|
||||||
} else {
|
|
||||||
m_filesToRemove.append(dir.absoluteFilePath(path + ".disabled"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include "BaseVersion.h"
|
#include "BaseVersion.h"
|
||||||
#include "InstanceTask.h"
|
#include "InstanceTask.h"
|
||||||
#include "minecraft/MinecraftInstance.h"
|
|
||||||
|
|
||||||
class InstanceCreationTask : public InstanceTask {
|
class InstanceCreationTask : public InstanceTask {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
@ -10,8 +9,6 @@ class InstanceCreationTask : public InstanceTask {
|
||||||
InstanceCreationTask() = default;
|
InstanceCreationTask() = default;
|
||||||
virtual ~InstanceCreationTask() = default;
|
virtual ~InstanceCreationTask() = default;
|
||||||
|
|
||||||
bool abort() override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void executeTask() final override;
|
void executeTask() final override;
|
||||||
|
|
||||||
|
|
@ -30,24 +27,20 @@ class InstanceCreationTask : public InstanceTask {
|
||||||
/**
|
/**
|
||||||
* Creates a new instance.
|
* Creates a new instance.
|
||||||
*
|
*
|
||||||
* Returns the instance if it was created or nullptr otherwise.
|
* Returns whether the instance creation was successful (true) or not (false).
|
||||||
*/
|
*/
|
||||||
virtual std::unique_ptr<MinecraftInstance> createInstance() { return nullptr; }
|
virtual bool createInstance() { return false; };
|
||||||
|
|
||||||
QString getError() const { return m_error_message; }
|
QString getError() const { return m_error_message; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setError(const QString& message) { m_error_message = message; };
|
void setError(const QString& message) { m_error_message = message; };
|
||||||
void scheduleToDelete(QWidget* parent, const QDir& dir, const QString& path, bool checkDisabled = false);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool m_abort = false;
|
bool m_abort = false;
|
||||||
|
|
||||||
QStringList m_filesToRemove;
|
QStringList m_files_to_remove;
|
||||||
ShouldDeleteSaves m_shouldDeleteSaves;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_error_message;
|
QString m_error_message;
|
||||||
std::unique_ptr<MinecraftInstance> m_instance;
|
|
||||||
Task::Ptr m_gameFilesTask;
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
#include "InstanceList.h"
|
#include "InstanceList.h"
|
||||||
#include "ui/dialogs/CustomMessageBox.h"
|
#include "ui/dialogs/CustomMessageBox.h"
|
||||||
|
|
||||||
QString askToUpdateInstanceDirName(BaseInstance* instance, const QString& oldName, const QString& newName, QWidget* parent)
|
QString askToUpdateInstanceDirName(InstancePtr instance, const QString& oldName, const QString& newName, QWidget* parent)
|
||||||
{
|
{
|
||||||
if (oldName == newName)
|
if (oldName == newName)
|
||||||
return QString();
|
return QString();
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
|
|
||||||
/// Update instanceRoot to make it sync with name/id; return newRoot if a directory rename happened
|
/// Update instanceRoot to make it sync with name/id; return newRoot if a directory rename happened
|
||||||
QString askToUpdateInstanceDirName(BaseInstance* instance, const QString& oldName, const QString& newName, QWidget* parent);
|
QString askToUpdateInstanceDirName(InstancePtr instance, const QString& oldName, const QString& newName, QWidget* parent);
|
||||||
|
|
||||||
/// Check if there are linked instances, and display a warning; return true if the operation should proceed
|
/// Check if there are linked instances, and display a warning; return true if the operation should proceed
|
||||||
bool checkLinkedInstances(const QString& id, QWidget* parent, const QString& verb);
|
bool checkLinkedInstances(const QString& id, QWidget* parent, const QString& verb);
|
||||||
|
|
|
||||||
|
|
@ -150,15 +150,22 @@ void InstanceImportTask::processZipPack()
|
||||||
extractDir.cd("minecraft");
|
extractDir.cd("minecraft");
|
||||||
m_modpackType = ModpackType::Technic;
|
m_modpackType = ModpackType::Technic;
|
||||||
stop = true;
|
stop = true;
|
||||||
} else if (fileName == "manifest.json") {
|
} else {
|
||||||
qDebug() << "Flame:" << true;
|
QFileInfo fileInfo(fileName);
|
||||||
m_modpackType = ModpackType::Flame;
|
if (fileInfo.fileName() == "instance.cfg") {
|
||||||
stop = true;
|
|
||||||
} else if (QFileInfo fileInfo(fileName); fileInfo.fileName() == "instance.cfg") {
|
|
||||||
qDebug() << "MultiMC:" << true;
|
qDebug() << "MultiMC:" << true;
|
||||||
m_modpackType = ModpackType::MultiMC;
|
m_modpackType = ModpackType::MultiMC;
|
||||||
root = cleanPath(fileInfo.path());
|
root = cleanPath(fileInfo.path());
|
||||||
stop = true;
|
stop = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (fileInfo.fileName() == "manifest.json") {
|
||||||
|
qDebug() << "Flame:" << true;
|
||||||
|
m_modpackType = ModpackType::Flame;
|
||||||
|
root = cleanPath(fileInfo.path());
|
||||||
|
stop = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -322,7 +329,6 @@ void InstanceImportTask::processFlame()
|
||||||
|
|
||||||
connect(inst_creation_task.get(), &Task::aborted, this, &InstanceImportTask::emitAborted);
|
connect(inst_creation_task.get(), &Task::aborted, this, &InstanceImportTask::emitAborted);
|
||||||
connect(inst_creation_task.get(), &Task::abortStatusChanged, this, &Task::setAbortable);
|
connect(inst_creation_task.get(), &Task::abortStatusChanged, this, &Task::setAbortable);
|
||||||
connect(inst_creation_task.get(), &Task::abortButtonTextChanged, this, &Task::setAbortButtonText);
|
|
||||||
|
|
||||||
connect(inst_creation_task.get(), &Task::warningLogged, this, [this](const QString& line) { m_Warnings.append(line); });
|
connect(inst_creation_task.get(), &Task::warningLogged, this, [this](const QString& line) { m_Warnings.append(line); });
|
||||||
|
|
||||||
|
|
@ -342,9 +348,9 @@ void InstanceImportTask::processTechnic()
|
||||||
void InstanceImportTask::processMultiMC()
|
void InstanceImportTask::processMultiMC()
|
||||||
{
|
{
|
||||||
QString configPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
QString configPath = FS::PathCombine(m_stagingPath, "instance.cfg");
|
||||||
auto instanceSettings = std::make_unique<INISettingsObject>(configPath);
|
auto instanceSettings = std::make_shared<INISettingsObject>(configPath);
|
||||||
|
|
||||||
NullInstance instance(m_globalSettings, std::move(instanceSettings), m_stagingPath);
|
NullInstance instance(m_globalSettings, instanceSettings, m_stagingPath);
|
||||||
|
|
||||||
// reset time played on import... because packs.
|
// reset time played on import... because packs.
|
||||||
instance.resetTimePlayed();
|
instance.resetTimePlayed();
|
||||||
|
|
@ -422,7 +428,6 @@ void InstanceImportTask::processModrinth()
|
||||||
|
|
||||||
connect(inst_creation_task.get(), &Task::aborted, this, &InstanceImportTask::emitAborted);
|
connect(inst_creation_task.get(), &Task::aborted, this, &InstanceImportTask::emitAborted);
|
||||||
connect(inst_creation_task.get(), &Task::abortStatusChanged, this, &Task::setAbortable);
|
connect(inst_creation_task.get(), &Task::abortStatusChanged, this, &Task::setAbortable);
|
||||||
connect(inst_creation_task.get(), &Task::abortButtonTextChanged, this, &Task::setAbortButtonText);
|
|
||||||
|
|
||||||
connect(inst_creation_task.get(), &Task::warningLogged, this, [this](const QString& line) { m_Warnings.append(line); });
|
connect(inst_creation_task.get(), &Task::warningLogged, this, [this](const QString& line) { m_Warnings.append(line); });
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,37 +34,42 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "InstanceList.h"
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
#include <QDirIterator>
|
#include <QDirIterator>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QFileSystemWatcher>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
#include <QPair>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QStack>
|
#include <QStack>
|
||||||
|
#include <QTextStream>
|
||||||
|
#include <QThread>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
#include <QXmlStreamReader>
|
||||||
|
|
||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
#include "ExponentialSeries.h"
|
#include "ExponentialSeries.h"
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
|
#include "InstanceList.h"
|
||||||
#include "InstanceTask.h"
|
#include "InstanceTask.h"
|
||||||
#include "NullInstance.h"
|
#include "NullInstance.h"
|
||||||
#include "WatchLock.h"
|
#include "WatchLock.h"
|
||||||
#include "minecraft/MinecraftInstance.h"
|
#include "minecraft/MinecraftInstance.h"
|
||||||
|
#include "minecraft/ShortcutUtils.h"
|
||||||
#include "settings/INISettingsObject.h"
|
#include "settings/INISettingsObject.h"
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
#include <windows.h>
|
#include <Windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const static int GROUP_FILE_FORMAT_VERSION = 1;
|
const static int GROUP_FILE_FORMAT_VERSION = 1;
|
||||||
|
|
||||||
InstanceList::InstanceList(SettingsObject* settings, const QString& instDir, QObject* parent)
|
InstanceList::InstanceList(SettingsObjectPtr settings, const QString& instDir, QObject* parent)
|
||||||
: QAbstractListModel(parent), m_globalSettings(settings)
|
: QAbstractListModel(parent), m_globalSettings(settings)
|
||||||
{
|
{
|
||||||
resumeWatch();
|
resumeWatch();
|
||||||
|
|
@ -138,7 +143,7 @@ QMimeData* InstanceList::mimeData(const QModelIndexList& indexes) const
|
||||||
QStringList InstanceList::getLinkedInstancesById(const QString& id) const
|
QStringList InstanceList::getLinkedInstancesById(const QString& id) const
|
||||||
{
|
{
|
||||||
QStringList linkedInstances;
|
QStringList linkedInstances;
|
||||||
for (auto& inst : m_instances) {
|
for (auto inst : m_instances) {
|
||||||
if (inst->isLinkedToInstanceId(id))
|
if (inst->isLinkedToInstanceId(id))
|
||||||
linkedInstances.append(inst->id());
|
linkedInstances.append(inst->id());
|
||||||
}
|
}
|
||||||
|
|
@ -148,15 +153,15 @@ QStringList InstanceList::getLinkedInstancesById(const QString& id) const
|
||||||
int InstanceList::rowCount(const QModelIndex& parent) const
|
int InstanceList::rowCount(const QModelIndex& parent) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
return count();
|
return m_instances.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex InstanceList::index(int row, int column, const QModelIndex& parent) const
|
QModelIndex InstanceList::index(int row, int column, const QModelIndex& parent) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
if (row < 0 || row >= count())
|
if (row < 0 || row >= m_instances.size())
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
return createIndex(row, column, m_instances.at(row).get());
|
return createIndex(row, column, (void*)m_instances.at(row).get());
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant InstanceList::data(const QModelIndex& index, int role) const
|
QVariant InstanceList::data(const QModelIndex& index, int role) const
|
||||||
|
|
@ -261,7 +266,7 @@ void InstanceList::setInstanceGroup(const InstanceId& id, GroupId name)
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
increaseGroupCount(name);
|
increaseGroupCount(name);
|
||||||
auto idx = getInstIndex(inst);
|
auto idx = getInstIndex(inst.get());
|
||||||
emit dataChanged(index(idx), index(idx), { GroupRole });
|
emit dataChanged(index(idx), index(idx), { GroupRole });
|
||||||
saveGroupList();
|
saveGroupList();
|
||||||
}
|
}
|
||||||
|
|
@ -452,7 +457,7 @@ void InstanceList::deleteInstance(const InstanceId& id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static QMap<InstanceId, InstanceLocator> getIdMapping(const std::vector<std::unique_ptr<BaseInstance>>& list)
|
static QMap<InstanceId, InstanceLocator> getIdMapping(const QList<InstancePtr>& list)
|
||||||
{
|
{
|
||||||
QMap<InstanceId, InstanceLocator> out;
|
QMap<InstanceId, InstanceLocator> out;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
@ -461,7 +466,7 @@ static QMap<InstanceId, InstanceLocator> getIdMapping(const std::vector<std::uni
|
||||||
if (out.contains(id)) {
|
if (out.contains(id)) {
|
||||||
qWarning() << "Duplicate ID" << id << "in instance list";
|
qWarning() << "Duplicate ID" << id << "in instance list";
|
||||||
}
|
}
|
||||||
out[id] = std::make_pair(item.get(), i);
|
out[id] = std::make_pair(item, i);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
|
|
@ -499,16 +504,17 @@ InstanceList::InstListError InstanceList::loadList()
|
||||||
{
|
{
|
||||||
auto existingIds = getIdMapping(m_instances);
|
auto existingIds = getIdMapping(m_instances);
|
||||||
|
|
||||||
std::vector<std::unique_ptr<BaseInstance>> newList;
|
QList<InstancePtr> newList;
|
||||||
|
|
||||||
for (auto& id : discoverInstances()) {
|
for (auto& id : discoverInstances()) {
|
||||||
if (existingIds.contains(id)) {
|
if (existingIds.contains(id)) {
|
||||||
|
auto instPair = existingIds[id];
|
||||||
existingIds.remove(id);
|
existingIds.remove(id);
|
||||||
qInfo() << "Should keep and soft-reload" << id;
|
qInfo() << "Should keep and soft-reload" << id;
|
||||||
} else {
|
} else {
|
||||||
std::unique_ptr<BaseInstance> instPtr = loadInstance(id);
|
InstancePtr instPtr = loadInstance(id);
|
||||||
if (instPtr) {
|
if (instPtr) {
|
||||||
newList.push_back(std::move(instPtr));
|
newList.append(instPtr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -560,8 +566,8 @@ InstanceList::InstListError InstanceList::loadList()
|
||||||
void InstanceList::updateTotalPlayTime()
|
void InstanceList::updateTotalPlayTime()
|
||||||
{
|
{
|
||||||
totalPlayTime = 0;
|
totalPlayTime = 0;
|
||||||
for (const auto& itr : m_instances) {
|
for (auto const& itr : m_instances) {
|
||||||
totalPlayTime += itr->totalTimePlayed();
|
totalPlayTime += itr.get()->totalTimePlayed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -572,12 +578,12 @@ void InstanceList::saveNow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceList::add(std::vector<std::unique_ptr<BaseInstance>>& t)
|
void InstanceList::add(const QList<InstancePtr>& t)
|
||||||
{
|
{
|
||||||
beginInsertRows(QModelIndex(), count(), static_cast<int>(count() + t.size() - 1));
|
beginInsertRows(QModelIndex(), m_instances.count(), m_instances.count() + t.size() - 1);
|
||||||
|
m_instances.append(t);
|
||||||
for (auto& ptr : t) {
|
for (auto& ptr : t) {
|
||||||
m_instances.push_back(std::move(ptr));
|
connect(ptr.get(), &BaseInstance::propertiesChanged, this, &InstanceList::propertiesChanged);
|
||||||
connect(m_instances.back().get(), &BaseInstance::propertiesChanged, this, &InstanceList::propertiesChanged);
|
|
||||||
}
|
}
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
@ -607,26 +613,26 @@ void InstanceList::providerUpdated()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseInstance* InstanceList::getInstanceById(QString instId) const
|
InstancePtr InstanceList::getInstanceById(QString instId) const
|
||||||
{
|
{
|
||||||
if (instId.isEmpty())
|
if (instId.isEmpty())
|
||||||
return nullptr;
|
return InstancePtr();
|
||||||
for (auto& inst : m_instances) {
|
for (auto& inst : m_instances) {
|
||||||
if (inst->id() == instId) {
|
if (inst->id() == instId) {
|
||||||
return inst.get();
|
return inst;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return InstancePtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseInstance* InstanceList::getInstanceByManagedName(const QString& managed_name) const
|
InstancePtr InstanceList::getInstanceByManagedName(const QString& managed_name) const
|
||||||
{
|
{
|
||||||
if (managed_name.isEmpty())
|
if (managed_name.isEmpty())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
for (auto& instance : m_instances) {
|
for (auto instance : m_instances) {
|
||||||
if (instance->getManagedPackName() == managed_name)
|
if (instance->getManagedPackName() == managed_name)
|
||||||
return instance.get();
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
|
@ -634,14 +640,14 @@ BaseInstance* InstanceList::getInstanceByManagedName(const QString& managed_name
|
||||||
|
|
||||||
QModelIndex InstanceList::getInstanceIndexById(const QString& id) const
|
QModelIndex InstanceList::getInstanceIndexById(const QString& id) const
|
||||||
{
|
{
|
||||||
return index(getInstIndex(getInstanceById(id)));
|
return index(getInstIndex(getInstanceById(id).get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
int InstanceList::getInstIndex(BaseInstance* inst) const
|
int InstanceList::getInstIndex(BaseInstance* inst) const
|
||||||
{
|
{
|
||||||
int count = this->count();
|
int count = m_instances.count();
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
if (inst == m_instances.at(i).get()) {
|
if (inst == m_instances[i].get()) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -657,15 +663,15 @@ void InstanceList::propertiesChanged(BaseInstance* inst)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<BaseInstance> InstanceList::loadInstance(const InstanceId& id)
|
InstancePtr InstanceList::loadInstance(const InstanceId& id)
|
||||||
{
|
{
|
||||||
if (!m_groupsLoaded) {
|
if (!m_groupsLoaded) {
|
||||||
loadGroupList();
|
loadGroupList();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto instanceRoot = FS::PathCombine(m_instDir, id);
|
auto instanceRoot = FS::PathCombine(m_instDir, id);
|
||||||
auto instanceSettings = std::make_unique<INISettingsObject>(FS::PathCombine(instanceRoot, "instance.cfg"));
|
auto instanceSettings = std::make_shared<INISettingsObject>(FS::PathCombine(instanceRoot, "instance.cfg"));
|
||||||
std::unique_ptr<BaseInstance> inst;
|
InstancePtr inst;
|
||||||
|
|
||||||
instanceSettings->registerSetting("InstanceType", "");
|
instanceSettings->registerSetting("InstanceType", "");
|
||||||
|
|
||||||
|
|
@ -674,9 +680,9 @@ std::unique_ptr<BaseInstance> InstanceList::loadInstance(const InstanceId& id)
|
||||||
// NOTE: Some launcher versions didn't save the InstanceType properly. We will just bank on the probability that this is probably a
|
// NOTE: Some launcher versions didn't save the InstanceType properly. We will just bank on the probability that this is probably a
|
||||||
// OneSix instance
|
// OneSix instance
|
||||||
if (inst_type == "OneSix" || inst_type.isEmpty()) {
|
if (inst_type == "OneSix" || inst_type.isEmpty()) {
|
||||||
inst.reset(new MinecraftInstance(m_globalSettings, std::move(instanceSettings), instanceRoot));
|
inst.reset(new MinecraftInstance(m_globalSettings, instanceSettings, instanceRoot));
|
||||||
} else {
|
} else {
|
||||||
inst.reset(new NullInstance(m_globalSettings, std::move(instanceSettings), instanceRoot));
|
inst.reset(new NullInstance(m_globalSettings, instanceSettings, instanceRoot));
|
||||||
}
|
}
|
||||||
qDebug() << "Loaded instance" << inst->name() << "from" << inst->instanceRoot();
|
qDebug() << "Loaded instance" << inst->name() << "from" << inst->instanceRoot();
|
||||||
|
|
||||||
|
|
@ -905,20 +911,20 @@ class InstanceStaging : public Task {
|
||||||
const unsigned maxBackoff = 16;
|
const unsigned maxBackoff = 16;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InstanceStaging(InstanceList* parent, InstanceTask* child, SettingsObject* settings) : m_parent(parent), backoff(minBackoff, maxBackoff)
|
InstanceStaging(InstanceList* parent, InstanceTask* child, SettingsObjectPtr settings)
|
||||||
|
: m_parent(parent), backoff(minBackoff, maxBackoff)
|
||||||
{
|
{
|
||||||
m_stagingPath = parent->getStagedInstancePath();
|
m_stagingPath = parent->getStagedInstancePath();
|
||||||
|
|
||||||
m_child.reset(child);
|
m_child.reset(child);
|
||||||
|
|
||||||
m_child->setStagingPath(m_stagingPath);
|
m_child->setStagingPath(m_stagingPath);
|
||||||
m_child->setParentSettings(settings);
|
m_child->setParentSettings(std::move(settings));
|
||||||
|
|
||||||
connect(child, &Task::succeeded, this, &InstanceStaging::childSucceeded);
|
connect(child, &Task::succeeded, this, &InstanceStaging::childSucceeded);
|
||||||
connect(child, &Task::failed, this, &InstanceStaging::childFailed);
|
connect(child, &Task::failed, this, &InstanceStaging::childFailed);
|
||||||
connect(child, &Task::aborted, this, &InstanceStaging::childAborted);
|
connect(child, &Task::aborted, this, &InstanceStaging::childAborted);
|
||||||
connect(child, &Task::abortStatusChanged, this, &InstanceStaging::setAbortable);
|
connect(child, &Task::abortStatusChanged, this, &InstanceStaging::setAbortable);
|
||||||
connect(child, &Task::abortButtonTextChanged, this, &InstanceStaging::setAbortButtonText);
|
|
||||||
connect(child, &Task::status, this, &InstanceStaging::setStatus);
|
connect(child, &Task::status, this, &InstanceStaging::setStatus);
|
||||||
connect(child, &Task::details, this, &InstanceStaging::setDetails);
|
connect(child, &Task::details, this, &InstanceStaging::setDetails);
|
||||||
connect(child, &Task::progress, this, &InstanceStaging::setProgress);
|
connect(child, &Task::progress, this, &InstanceStaging::setProgress);
|
||||||
|
|
@ -926,21 +932,22 @@ class InstanceStaging : public Task {
|
||||||
connect(&m_backoffTimer, &QTimer::timeout, this, &InstanceStaging::childSucceeded);
|
connect(&m_backoffTimer, &QTimer::timeout, this, &InstanceStaging::childSucceeded);
|
||||||
}
|
}
|
||||||
|
|
||||||
~InstanceStaging() override = default;
|
virtual ~InstanceStaging() {}
|
||||||
|
|
||||||
// FIXME/TODO: add ability to abort during instance commit retries
|
// FIXME/TODO: add ability to abort during instance commit retries
|
||||||
bool abort() override
|
bool abort() override
|
||||||
{
|
{
|
||||||
if (!canAbort()) {
|
if (!canAbort())
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
return m_child->abort();
|
m_child->abort();
|
||||||
|
|
||||||
|
return Task::abort();
|
||||||
}
|
}
|
||||||
bool canAbort() const override { return (m_child && m_child->canAbort()); }
|
bool canAbort() const override { return (m_child && m_child->canAbort()); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void executeTask() override
|
virtual void executeTask() override
|
||||||
{
|
{
|
||||||
if (m_stagingPath.isNull()) {
|
if (m_stagingPath.isNull()) {
|
||||||
emitFailed(tr("Could not create staging folder"));
|
emitFailed(tr("Could not create staging folder"));
|
||||||
|
|
@ -955,14 +962,12 @@ class InstanceStaging : public Task {
|
||||||
void childSucceeded()
|
void childSucceeded()
|
||||||
{
|
{
|
||||||
unsigned sleepTime = backoff();
|
unsigned sleepTime = backoff();
|
||||||
if (m_parent->commitStagedInstance(m_stagingPath, *m_child, m_child->group(), *m_child)) {
|
if (m_parent->commitStagedInstance(m_stagingPath, *m_child.get(), m_child->group(), *m_child.get())) {
|
||||||
m_backoffTimer.stop();
|
|
||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// we actually failed, retry?
|
// we actually failed, retry?
|
||||||
if (sleepTime == maxBackoff) {
|
if (sleepTime == maxBackoff) {
|
||||||
m_backoffTimer.stop();
|
|
||||||
emitFailed(tr("Failed to commit instance, even after multiple retries. It is being blocked by something."));
|
emitFailed(tr("Failed to commit instance, even after multiple retries. It is being blocked by something."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -971,14 +976,12 @@ class InstanceStaging : public Task {
|
||||||
}
|
}
|
||||||
void childFailed(const QString& reason)
|
void childFailed(const QString& reason)
|
||||||
{
|
{
|
||||||
m_backoffTimer.stop();
|
|
||||||
m_parent->destroyStagingPath(m_stagingPath);
|
m_parent->destroyStagingPath(m_stagingPath);
|
||||||
emitFailed(reason);
|
emitFailed(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
void childAborted()
|
void childAborted()
|
||||||
{
|
{
|
||||||
m_backoffTimer.stop();
|
|
||||||
m_parent->destroyStagingPath(m_stagingPath);
|
m_parent->destroyStagingPath(m_stagingPath);
|
||||||
emitAborted();
|
emitAborted();
|
||||||
}
|
}
|
||||||
|
|
@ -992,7 +995,7 @@ class InstanceStaging : public Task {
|
||||||
*/
|
*/
|
||||||
ExponentialSeries backoff;
|
ExponentialSeries backoff;
|
||||||
QString m_stagingPath;
|
QString m_stagingPath;
|
||||||
std::unique_ptr<InstanceTask> m_child;
|
unique_qobject_ptr<InstanceTask> m_child;
|
||||||
QTimer m_backoffTimer;
|
QTimer m_backoffTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1025,14 +1028,15 @@ QString InstanceList::getStagedInstancePath()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InstanceList::commitStagedInstance(const QString& path,
|
bool InstanceList::commitStagedInstance(const QString& path,
|
||||||
const InstanceName& instanceName,
|
InstanceName const& instanceName,
|
||||||
QString groupName,
|
QString groupName,
|
||||||
const InstanceTask& commiting)
|
InstanceTask const& commiting)
|
||||||
{
|
{
|
||||||
if (groupName.isEmpty() && !groupName.isNull())
|
if (groupName.isEmpty() && !groupName.isNull())
|
||||||
groupName = QString();
|
groupName = QString();
|
||||||
|
|
||||||
QString instID;
|
QString instID;
|
||||||
|
InstancePtr inst;
|
||||||
|
|
||||||
auto should_override = commiting.shouldOverride();
|
auto should_override = commiting.shouldOverride();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ struct InstanceName;
|
||||||
|
|
||||||
using InstanceId = QString;
|
using InstanceId = QString;
|
||||||
using GroupId = QString;
|
using GroupId = QString;
|
||||||
using InstanceLocator = std::pair<BaseInstance*, int>;
|
using InstanceLocator = std::pair<InstancePtr, int>;
|
||||||
|
|
||||||
enum class InstCreateError { NoCreateError = 0, NoSuchVersion, UnknownCreateError, InstExists, CantCreateDir };
|
enum class InstCreateError { NoCreateError = 0, NoSuchVersion, UnknownCreateError, InstExists, CantCreateDir };
|
||||||
|
|
||||||
|
|
@ -73,7 +73,7 @@ class InstanceList : public QAbstractListModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit InstanceList(SettingsObject* settings, const QString& instDir, QObject* parent = 0);
|
explicit InstanceList(SettingsObjectPtr settings, const QString& instDir, QObject* parent = 0);
|
||||||
virtual ~InstanceList();
|
virtual ~InstanceList();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -96,17 +96,17 @@ class InstanceList : public QAbstractListModel {
|
||||||
*/
|
*/
|
||||||
enum InstListError { NoError = 0, UnknownError };
|
enum InstListError { NoError = 0, UnknownError };
|
||||||
|
|
||||||
BaseInstance* at(int i) const { return m_instances.at(i).get(); }
|
InstancePtr at(int i) const { return m_instances.at(i); }
|
||||||
|
|
||||||
int count() const { return static_cast<int>(m_instances.size()); }
|
int count() const { return m_instances.count(); }
|
||||||
|
|
||||||
InstListError loadList();
|
InstListError loadList();
|
||||||
void saveNow();
|
void saveNow();
|
||||||
|
|
||||||
/* O(n) */
|
/* O(n) */
|
||||||
BaseInstance* getInstanceById(QString id) const;
|
InstancePtr getInstanceById(QString id) const;
|
||||||
/* O(n) */
|
/* O(n) */
|
||||||
BaseInstance* getInstanceByManagedName(const QString& managed_name) const;
|
InstancePtr getInstanceByManagedName(const QString& managed_name) const;
|
||||||
QModelIndex getInstanceIndexById(const QString& id) const;
|
QModelIndex getInstanceIndexById(const QString& id) const;
|
||||||
QStringList getGroups();
|
QStringList getGroups();
|
||||||
bool isGroupCollapsed(const QString& groupName);
|
bool isGroupCollapsed(const QString& groupName);
|
||||||
|
|
@ -179,11 +179,11 @@ class InstanceList : public QAbstractListModel {
|
||||||
void updateTotalPlayTime();
|
void updateTotalPlayTime();
|
||||||
void suspendWatch();
|
void suspendWatch();
|
||||||
void resumeWatch();
|
void resumeWatch();
|
||||||
void add(std::vector<std::unique_ptr<BaseInstance>>& list);
|
void add(const QList<InstancePtr>& list);
|
||||||
void loadGroupList();
|
void loadGroupList();
|
||||||
void saveGroupList();
|
void saveGroupList();
|
||||||
QList<InstanceId> discoverInstances();
|
QList<InstanceId> discoverInstances();
|
||||||
std::unique_ptr<BaseInstance> loadInstance(const InstanceId& id);
|
InstancePtr loadInstance(const InstanceId& id);
|
||||||
|
|
||||||
void increaseGroupCount(const QString& group);
|
void increaseGroupCount(const QString& group);
|
||||||
void decreaseGroupCount(const QString& group);
|
void decreaseGroupCount(const QString& group);
|
||||||
|
|
@ -192,11 +192,11 @@ class InstanceList : public QAbstractListModel {
|
||||||
int m_watchLevel = 0;
|
int m_watchLevel = 0;
|
||||||
int totalPlayTime = 0;
|
int totalPlayTime = 0;
|
||||||
bool m_dirty = false;
|
bool m_dirty = false;
|
||||||
std::vector<std::unique_ptr<BaseInstance>> m_instances;
|
QList<InstancePtr> m_instances;
|
||||||
// id -> refs
|
// id -> refs
|
||||||
QMap<QString, int> m_groupNameCache;
|
QMap<QString, int> m_groupNameCache;
|
||||||
|
|
||||||
SettingsObject* m_globalSettings;
|
SettingsObjectPtr m_globalSettings;
|
||||||
QString m_instDir;
|
QString m_instDir;
|
||||||
QFileSystemWatcher* m_watcher;
|
QFileSystemWatcher* m_watcher;
|
||||||
// FIXME: this is so inefficient that looking at it is almost painful.
|
// FIXME: this is so inefficient that looking at it is almost painful.
|
||||||
|
|
|
||||||
|
|
@ -21,26 +21,26 @@
|
||||||
class InstancePageProvider : protected QObject, public BasePageProvider {
|
class InstancePageProvider : protected QObject, public BasePageProvider {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit InstancePageProvider(BaseInstance* parent) { inst = parent; }
|
explicit InstancePageProvider(InstancePtr parent) { inst = parent; }
|
||||||
|
|
||||||
virtual ~InstancePageProvider() = default;
|
virtual ~InstancePageProvider() = default;
|
||||||
virtual QList<BasePage*> getPages() override
|
virtual QList<BasePage*> getPages() override
|
||||||
{
|
{
|
||||||
QList<BasePage*> values;
|
QList<BasePage*> values;
|
||||||
values.append(new LogPage(inst));
|
values.append(new LogPage(inst));
|
||||||
MinecraftInstance* onesix = dynamic_cast<MinecraftInstance*>(inst);
|
std::shared_ptr<MinecraftInstance> onesix = std::dynamic_pointer_cast<MinecraftInstance>(inst);
|
||||||
values.append(new VersionPage(onesix));
|
values.append(new VersionPage(onesix.get()));
|
||||||
values.append(ManagedPackPage::createPage(onesix));
|
values.append(ManagedPackPage::createPage(onesix.get()));
|
||||||
auto modsPage = new ModFolderPage(onesix, onesix->loaderModList());
|
auto modsPage = new ModFolderPage(onesix.get(), onesix->loaderModList());
|
||||||
modsPage->setFilter("%1 (*.zip *.jar *.litemod *.nilmod)");
|
modsPage->setFilter("%1 (*.zip *.jar *.litemod *.nilmod)");
|
||||||
values.append(modsPage);
|
values.append(modsPage);
|
||||||
values.append(new CoreModFolderPage(onesix, onesix->coreModList()));
|
values.append(new CoreModFolderPage(onesix.get(), onesix->coreModList()));
|
||||||
values.append(new NilModFolderPage(onesix, onesix->nilModList()));
|
values.append(new NilModFolderPage(onesix.get(), onesix->nilModList()));
|
||||||
values.append(new ResourcePackPage(onesix, onesix->resourcePackList()));
|
values.append(new ResourcePackPage(onesix.get(), onesix->resourcePackList()));
|
||||||
values.append(new GlobalDataPackPage(onesix));
|
values.append(new GlobalDataPackPage(onesix.get()));
|
||||||
values.append(new TexturePackPage(onesix, onesix->texturePackList()));
|
values.append(new TexturePackPage(onesix.get(), onesix->texturePackList()));
|
||||||
values.append(new ShaderPackPage(onesix, onesix->shaderPackList()));
|
values.append(new ShaderPackPage(onesix.get(), onesix->shaderPackList()));
|
||||||
values.append(new NotesPage(onesix));
|
values.append(new NotesPage(onesix.get()));
|
||||||
values.append(new WorldListPage(onesix, onesix->worldList()));
|
values.append(new WorldListPage(onesix, onesix->worldList()));
|
||||||
values.append(new ServersPage(onesix));
|
values.append(new ServersPage(onesix));
|
||||||
values.append(new ScreenshotsPage(FS::PathCombine(onesix->gameRoot(), "screenshots")));
|
values.append(new ScreenshotsPage(FS::PathCombine(onesix->gameRoot(), "screenshots")));
|
||||||
|
|
@ -52,5 +52,5 @@ class InstancePageProvider : protected QObject, public BasePageProvider {
|
||||||
virtual QString dialogTitle() override { return tr("Edit Instance (%1)").arg(inst->name()); }
|
virtual QString dialogTitle() override { return tr("Edit Instance (%1)").arg(inst->name()); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BaseInstance* inst;
|
InstancePtr inst;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
#include "InstanceTask.h"
|
#include "InstanceTask.h"
|
||||||
#include <QDir>
|
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "settings/SettingsObject.h"
|
#include "settings/SettingsObject.h"
|
||||||
|
|
@ -83,13 +82,3 @@ void InstanceName::setName(InstanceName& other)
|
||||||
}
|
}
|
||||||
|
|
||||||
InstanceTask::InstanceTask() : Task(), InstanceName() {}
|
InstanceTask::InstanceTask() : Task(), InstanceName() {}
|
||||||
|
|
||||||
ShouldDeleteSaves askIfShouldDeleteSaves(QWidget* parent)
|
|
||||||
{
|
|
||||||
auto dialog = CustomMessageBox::selectable(parent, QObject::tr("Delete Existing Save Files"),
|
|
||||||
QObject::tr("An earlier version of this mod pack installed save files.\n"
|
|
||||||
"Would you like to remove those existing saves as part of this update?"),
|
|
||||||
QMessageBox::Question, QMessageBox::No | QMessageBox::Yes);
|
|
||||||
auto result = dialog->exec();
|
|
||||||
return result == QMessageBox::Yes ? ShouldDeleteSaves::Yes : ShouldDeleteSaves::No;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,6 @@ enum class InstanceNameChange { ShouldChange, ShouldKeep };
|
||||||
[[nodiscard]] InstanceNameChange askForChangingInstanceName(QWidget* parent, const QString& old_name, const QString& new_name);
|
[[nodiscard]] InstanceNameChange askForChangingInstanceName(QWidget* parent, const QString& old_name, const QString& new_name);
|
||||||
enum class ShouldUpdate { Update, SkipUpdating, Cancel };
|
enum class ShouldUpdate { Update, SkipUpdating, Cancel };
|
||||||
[[nodiscard]] ShouldUpdate askIfShouldUpdate(QWidget* parent, QString original_version_name);
|
[[nodiscard]] ShouldUpdate askIfShouldUpdate(QWidget* parent, QString original_version_name);
|
||||||
enum class ShouldDeleteSaves { NotAsked, Yes, No };
|
|
||||||
[[nodiscard]] ShouldDeleteSaves askIfShouldDeleteSaves(QWidget* parent);
|
|
||||||
|
|
||||||
struct InstanceName {
|
struct InstanceName {
|
||||||
public:
|
public:
|
||||||
|
|
@ -37,7 +35,7 @@ class InstanceTask : public Task, public InstanceName {
|
||||||
InstanceTask();
|
InstanceTask();
|
||||||
~InstanceTask() override = default;
|
~InstanceTask() override = default;
|
||||||
|
|
||||||
void setParentSettings(SettingsObject* settings) { m_globalSettings = settings; }
|
void setParentSettings(SettingsObjectPtr settings) { m_globalSettings = settings; }
|
||||||
|
|
||||||
void setStagingPath(const QString& stagingPath) { m_stagingPath = stagingPath; }
|
void setStagingPath(const QString& stagingPath) { m_stagingPath = stagingPath; }
|
||||||
|
|
||||||
|
|
@ -62,7 +60,7 @@ class InstanceTask : public Task, public InstanceName {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected: /* data */
|
protected: /* data */
|
||||||
SettingsObject* m_globalSettings;
|
SettingsObjectPtr m_globalSettings;
|
||||||
QString m_instIcon;
|
QString m_instIcon;
|
||||||
QString m_instGroup;
|
QString m_instGroup;
|
||||||
QString m_stagingPath;
|
QString m_stagingPath;
|
||||||
|
|
|
||||||
|
|
@ -303,7 +303,7 @@ QStringList toStringList(const QString& jsonString)
|
||||||
return {};
|
return {};
|
||||||
try {
|
try {
|
||||||
return requireIsArrayOf<QString>(doc);
|
return requireIsArrayOf<QString>(doc);
|
||||||
} catch (Json::JsonException&) {
|
} catch (Json::JsonException& e) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,18 +40,22 @@
|
||||||
#include "minecraft/auth/AccountData.h"
|
#include "minecraft/auth/AccountData.h"
|
||||||
#include "minecraft/auth/AccountList.h"
|
#include "minecraft/auth/AccountList.h"
|
||||||
|
|
||||||
#include "net/NetUtils.h"
|
|
||||||
#include "ui/InstanceWindow.h"
|
#include "ui/InstanceWindow.h"
|
||||||
|
#include "ui/MainWindow.h"
|
||||||
#include "ui/dialogs/CustomMessageBox.h"
|
#include "ui/dialogs/CustomMessageBox.h"
|
||||||
#include "ui/dialogs/MSALoginDialog.h"
|
#include "ui/dialogs/MSALoginDialog.h"
|
||||||
#include "ui/dialogs/ProfileSelectDialog.h"
|
#include "ui/dialogs/ProfileSelectDialog.h"
|
||||||
#include "ui/dialogs/ProfileSetupDialog.h"
|
#include "ui/dialogs/ProfileSetupDialog.h"
|
||||||
#include "ui/dialogs/ProgressDialog.h"
|
#include "ui/dialogs/ProgressDialog.h"
|
||||||
|
|
||||||
|
#include <QHostAddress>
|
||||||
|
#include <QHostInfo>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
|
#include <QLineEdit>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <utility>
|
#include <QRegularExpression>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
#include "BuildConfig.h"
|
#include "BuildConfig.h"
|
||||||
#include "JavaCommon.h"
|
#include "JavaCommon.h"
|
||||||
|
|
@ -59,7 +63,7 @@
|
||||||
#include "tasks/Task.h"
|
#include "tasks/Task.h"
|
||||||
#include "ui/dialogs/ChooseOfflineNameDialog.h"
|
#include "ui/dialogs/ChooseOfflineNameDialog.h"
|
||||||
|
|
||||||
LaunchController::LaunchController() = default;
|
LaunchController::LaunchController() : Task() {}
|
||||||
|
|
||||||
void LaunchController::executeTask()
|
void LaunchController::executeTask()
|
||||||
{
|
{
|
||||||
|
|
@ -82,17 +86,9 @@ void LaunchController::decideAccount()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select the account to use. If the instance has a specific account set, that will be used. Otherwise, the default account will be used
|
// Find an account to use.
|
||||||
auto* accounts = APPLICATION->accounts();
|
auto accounts = APPLICATION->accounts();
|
||||||
const auto instanceAccountId = m_instance->settings()->get("InstanceAccountId").toString();
|
if (accounts->count() <= 0 || !accounts->anyAccountIsValid()) {
|
||||||
const auto instanceAccountIndex = accounts->findAccountByProfileId(instanceAccountId);
|
|
||||||
if (instanceAccountIndex == -1 || instanceAccountId.isEmpty()) {
|
|
||||||
m_accountToUse = accounts->defaultAccount();
|
|
||||||
} else {
|
|
||||||
m_accountToUse = accounts->at(instanceAccountIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!accounts->anyAccountIsValid()) {
|
|
||||||
// Tell the user they need to log in at least one account in order to play.
|
// Tell the user they need to log in at least one account in order to play.
|
||||||
auto reply = CustomMessageBox::selectable(m_parentWidget, tr("No Accounts"),
|
auto reply = CustomMessageBox::selectable(m_parentWidget, tr("No Accounts"),
|
||||||
tr("In order to play Minecraft, you must have at least one Microsoft "
|
tr("In order to play Minecraft, you must have at least one Microsoft "
|
||||||
|
|
@ -110,7 +106,16 @@ void LaunchController::decideAccount()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_accountToUse && accounts->anyAccountIsValid()) {
|
// Select the account to use. If the instance has a specific account set, that will be used. Otherwise, the default account will be used
|
||||||
|
auto instanceAccountId = m_instance->settings()->get("InstanceAccountId").toString();
|
||||||
|
auto instanceAccountIndex = accounts->findAccountByProfileId(instanceAccountId);
|
||||||
|
if (instanceAccountIndex == -1 || instanceAccountId.isEmpty()) {
|
||||||
|
m_accountToUse = accounts->defaultAccount();
|
||||||
|
} else {
|
||||||
|
m_accountToUse = accounts->at(instanceAccountIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_accountToUse) {
|
||||||
// If no default account is set, ask the user which one to use.
|
// If no default account is set, ask the user which one to use.
|
||||||
ProfileSelectDialog selectDialog(tr("Which account would you like to use?"), ProfileSelectDialog::GlobalDefaultCheckbox,
|
ProfileSelectDialog selectDialog(tr("Which account would you like to use?"), ProfileSelectDialog::GlobalDefaultCheckbox,
|
||||||
m_parentWidget);
|
m_parentWidget);
|
||||||
|
|
@ -127,146 +132,46 @@ void LaunchController::decideAccount()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchDecision LaunchController::decideLaunchMode()
|
bool LaunchController::askPlayDemo()
|
||||||
{
|
|
||||||
if (!m_accountToUse || m_wantedLaunchMode == LaunchMode::Demo) {
|
|
||||||
m_actualLaunchMode = LaunchMode::Demo;
|
|
||||||
return LaunchDecision::Continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto* accounts = APPLICATION->accounts();
|
|
||||||
MinecraftAccountPtr accountToCheck = nullptr;
|
|
||||||
|
|
||||||
if (m_accountToUse->accountType() != AccountType::Offline) {
|
|
||||||
accountToCheck = m_accountToUse->ownsMinecraft() ? m_accountToUse : nullptr;
|
|
||||||
} else if (const auto defaultAccount = accounts->defaultAccount(); defaultAccount && defaultAccount->ownsMinecraft()) {
|
|
||||||
accountToCheck = defaultAccount;
|
|
||||||
} else {
|
|
||||||
for (int i = 0; i < accounts->count(); i++) {
|
|
||||||
if (const auto account = accounts->at(i); account->ownsMinecraft()) {
|
|
||||||
accountToCheck = account;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!accountToCheck) {
|
|
||||||
m_actualLaunchMode = LaunchMode::Demo;
|
|
||||||
return LaunchDecision::Continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto state = accountToCheck->accountState();
|
|
||||||
const bool needsRefresh =
|
|
||||||
m_wantedLaunchMode == LaunchMode::Normal && (state == AccountState::Offline || accountToCheck->shouldRefresh());
|
|
||||||
if (state == AccountState::Unchecked || state == AccountState::Errored || needsRefresh) {
|
|
||||||
accountToCheck->refresh();
|
|
||||||
state = AccountState::Working;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state == AccountState::Working) {
|
|
||||||
// refresh is in progress, we need to wait for it to finish to proceed.
|
|
||||||
ProgressDialog progDialog(m_parentWidget);
|
|
||||||
progDialog.setSkipButton(true, tr("Abort"));
|
|
||||||
|
|
||||||
// TODO: this relies on tasks' synchronous signal dispatching nature
|
|
||||||
// TODO: meaning currentTask can't complete and become null while this code is running
|
|
||||||
// TODO: this code will produce a race condition when tasks become fully async
|
|
||||||
auto task = accountToCheck->currentTask();
|
|
||||||
progDialog.execWithTask(task.get());
|
|
||||||
|
|
||||||
if (task->getState() == State::AbortedByUser) {
|
|
||||||
return LaunchDecision::Abort;
|
|
||||||
}
|
|
||||||
|
|
||||||
state = accountToCheck->accountState();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString reauthReason;
|
|
||||||
switch (state) {
|
|
||||||
case AccountState::Errored:
|
|
||||||
reauthReason = tr("An error occurred while refreshing '%1'").arg(accountToCheck->profileName());
|
|
||||||
break;
|
|
||||||
case AccountState::Expired:
|
|
||||||
reauthReason = tr("'%1' has expired and needs to be reauthenticated").arg(accountToCheck->profileName());
|
|
||||||
break;
|
|
||||||
case AccountState::Disabled:
|
|
||||||
reauthReason = tr("The launcher's client identification has changed");
|
|
||||||
break;
|
|
||||||
case AccountState::Gone:
|
|
||||||
reauthReason = tr("'%1' no longer exists on the servers").arg(accountToCheck->profileName());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
m_actualLaunchMode =
|
|
||||||
state == AccountState::Online && m_wantedLaunchMode == LaunchMode::Normal ? LaunchMode::Normal : LaunchMode::Offline;
|
|
||||||
return LaunchDecision::Continue; // All good to go
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reauthenticateAccount(accountToCheck, reauthReason)) {
|
|
||||||
return LaunchDecision::Undecided;
|
|
||||||
}
|
|
||||||
|
|
||||||
return LaunchDecision::Abort;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LaunchController::askPlayDemo() const
|
|
||||||
{
|
{
|
||||||
QMessageBox box(m_parentWidget);
|
QMessageBox box(m_parentWidget);
|
||||||
box.setWindowTitle(tr("Play demo?"));
|
box.setWindowTitle(tr("Play demo?"));
|
||||||
QString text = m_accountToUse
|
box.setText(
|
||||||
? tr("This account does not own Minecraft.\nYou need to purchase the game first to play the full version.")
|
tr("This account does not own Minecraft.\nYou need to purchase the game first to play it.\n\nDo you want to play "
|
||||||
: tr("No account was selected for launch.");
|
"the demo?"));
|
||||||
text += tr("\n\nDo you want to play the demo?");
|
|
||||||
box.setText(text);
|
|
||||||
box.setIcon(QMessageBox::Warning);
|
box.setIcon(QMessageBox::Warning);
|
||||||
const auto* demoButton = box.addButton(tr("Play Demo"), QMessageBox::ButtonRole::YesRole);
|
auto demoButton = box.addButton(tr("Play Demo"), QMessageBox::ButtonRole::YesRole);
|
||||||
auto* cancelButton = box.addButton(tr("Cancel"), QMessageBox::ButtonRole::NoRole);
|
auto cancelButton = box.addButton(tr("Cancel"), QMessageBox::ButtonRole::NoRole);
|
||||||
box.setDefaultButton(cancelButton);
|
box.setDefaultButton(cancelButton);
|
||||||
|
|
||||||
box.exec();
|
box.exec();
|
||||||
return box.clickedButton() == demoButton;
|
return box.clickedButton() == demoButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString LaunchController::askOfflineName(const QString& playerName, bool* ok)
|
QString LaunchController::askOfflineName(QString playerName, bool demo, bool* ok)
|
||||||
{
|
{
|
||||||
if (ok != nullptr) {
|
if (ok != nullptr) {
|
||||||
*ok = false;
|
*ok = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString title, message;
|
// we ask the user for a player name
|
||||||
title = tr("Player name");
|
QString message = tr("Choose your offline mode player name.");
|
||||||
switch (m_actualLaunchMode) {
|
if (demo) {
|
||||||
case LaunchMode::Normal:
|
message = tr("Choose your demo mode player name.");
|
||||||
Q_ASSERT(false);
|
|
||||||
return "";
|
|
||||||
case LaunchMode::Demo:
|
|
||||||
message = tr("Choose your demo mode player name");
|
|
||||||
break;
|
|
||||||
case LaunchMode::Offline:
|
|
||||||
if (m_wantedLaunchMode == LaunchMode::Normal) {
|
|
||||||
auto netErr = m_accountToUse->accountData()->networkError;
|
|
||||||
if (Net::isServerError(netErr)) {
|
|
||||||
title = tr("Auth servers offline");
|
|
||||||
message = tr("The Minecraft authentication servers are currently unavailable, launching in offline mode.\n\n");
|
|
||||||
} else {
|
|
||||||
title = tr("No internet connection");
|
|
||||||
message = tr("You are not connected to the Internet, launching in offline mode.\n\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
message += tr("Choose your offline mode player name");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString lastOfflinePlayerName = APPLICATION->settings()->get("LastOfflinePlayerName").toString();
|
QString lastOfflinePlayerName = APPLICATION->settings()->get("LastOfflinePlayerName").toString();
|
||||||
QString usedname = lastOfflinePlayerName.isEmpty() ? playerName : lastOfflinePlayerName;
|
QString usedname = lastOfflinePlayerName.isEmpty() ? playerName : lastOfflinePlayerName;
|
||||||
|
|
||||||
ChooseOfflineNameDialog dialog(message, m_parentWidget);
|
ChooseOfflineNameDialog dialog(message, m_parentWidget);
|
||||||
dialog.setWindowTitle(title);
|
dialog.setWindowTitle(tr("Player name"));
|
||||||
dialog.setUsername(usedname);
|
dialog.setUsername(usedname);
|
||||||
if (dialog.exec() != QDialog::Accepted) {
|
if (dialog.exec() != QDialog::Accepted) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
usedname = dialog.getUsername();
|
const QString name = dialog.getUsername();
|
||||||
|
usedname = name;
|
||||||
APPLICATION->settings()->set("LastOfflinePlayerName", usedname);
|
APPLICATION->settings()->set("LastOfflinePlayerName", usedname);
|
||||||
|
|
||||||
if (ok != nullptr) {
|
if (ok != nullptr) {
|
||||||
|
|
@ -279,79 +184,189 @@ void LaunchController::login()
|
||||||
{
|
{
|
||||||
decideAccount();
|
decideAccount();
|
||||||
|
|
||||||
LaunchDecision decision = decideLaunchMode();
|
if (!m_accountToUse) {
|
||||||
while (decision == LaunchDecision::Undecided) {
|
// if no account is selected, ask about demo
|
||||||
decision = decideLaunchMode();
|
if (!m_demo) {
|
||||||
|
m_demo = askPlayDemo();
|
||||||
}
|
}
|
||||||
if (decision == LaunchDecision::Abort) {
|
if (m_demo) {
|
||||||
emitAborted();
|
// we ask the user for a player name
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_actualLaunchMode == LaunchMode::Demo) {
|
|
||||||
if (m_wantedLaunchMode == LaunchMode::Demo || askPlayDemo()) {
|
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
auto name = askOfflineName("Player", &ok);
|
auto name = askOfflineName("Player", m_demo, &ok);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
m_session = std::make_shared<AuthSession>();
|
m_session = std::make_shared<AuthSession>();
|
||||||
m_session->MakeDemo(name, MinecraftAccount::uuidFromUsername(name).toString(QUuid::Id128));
|
static const QRegularExpression s_removeChars("[{}-]");
|
||||||
|
m_session->MakeDemo(name, MinecraftAccount::uuidFromUsername(name).toString().remove(s_removeChars));
|
||||||
launchInstance();
|
launchInstance();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// if no account is selected, we bail
|
||||||
emitFailed(tr("No account selected for launch"));
|
emitFailed(tr("No account selected for launch."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we loop until the user succeeds in logging in or gives up
|
||||||
|
bool tryagain = true;
|
||||||
|
unsigned int tries = 0;
|
||||||
|
|
||||||
|
if ((m_accountToUse->accountType() != AccountType::Offline && m_accountToUse->accountState() == AccountState::Offline) ||
|
||||||
|
m_accountToUse->shouldRefresh()) {
|
||||||
|
// Force account refresh on the account used to launch the instance updating the AccountState
|
||||||
|
// only on first try and if it is not meant to be offline
|
||||||
|
m_accountToUse->refresh();
|
||||||
|
}
|
||||||
|
while (tryagain) {
|
||||||
|
if (tries > 0 && tries % 3 == 0) {
|
||||||
|
auto result =
|
||||||
|
QMessageBox::question(m_parentWidget, tr("Continue launch?"),
|
||||||
|
tr("It looks like we couldn't launch after %1 tries. Do you want to continue trying?").arg(tries));
|
||||||
|
|
||||||
|
if (result == QMessageBox::No) {
|
||||||
|
emitAborted();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tries++;
|
||||||
m_session = std::make_shared<AuthSession>();
|
m_session = std::make_shared<AuthSession>();
|
||||||
m_session->launchMode = m_actualLaunchMode;
|
m_session->wants_online = m_online;
|
||||||
|
m_session->demo = m_demo;
|
||||||
m_accountToUse->fillSession(m_session);
|
m_accountToUse->fillSession(m_session);
|
||||||
|
|
||||||
if (m_accountToUse->accountType() != AccountType::Offline) {
|
MinecraftAccountPtr accountToCheck;
|
||||||
if (m_actualLaunchMode == LaunchMode::Normal && !m_accountToUse->hasProfile()) {
|
|
||||||
// Now handle setting up a profile name here...
|
if (m_accountToUse->ownsMinecraft())
|
||||||
if (ProfileSetupDialog dialog(m_accountToUse, m_parentWidget); dialog.exec() != QDialog::Accepted) {
|
accountToCheck = m_accountToUse;
|
||||||
emitAborted();
|
else if (const MinecraftAccountPtr defaultAccount = APPLICATION->accounts()->defaultAccount();
|
||||||
return;
|
defaultAccount != nullptr && defaultAccount->ownsMinecraft()) {
|
||||||
|
accountToCheck = defaultAccount;
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < APPLICATION->accounts()->count(); i++) {
|
||||||
|
MinecraftAccountPtr account = APPLICATION->accounts()->at(i);
|
||||||
|
if (account->ownsMinecraft())
|
||||||
|
accountToCheck = account;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_actualLaunchMode == LaunchMode::Offline && m_accountToUse->accountType() != AccountType::Offline) {
|
if (accountToCheck == nullptr) {
|
||||||
bool ok = false;
|
if (!m_session->demo)
|
||||||
QString name = m_offlineName;
|
m_session->demo = askPlayDemo();
|
||||||
if (name.isEmpty()) {
|
|
||||||
name = askOfflineName(m_session->player_name, &ok);
|
if (m_session->demo)
|
||||||
if (!ok) {
|
launchInstance();
|
||||||
emitAborted();
|
else
|
||||||
|
emitFailed(tr("Launch cancelled - account does not own Minecraft."));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (accountToCheck->accountState()) {
|
||||||
|
case AccountState::Offline: {
|
||||||
|
m_session->wants_online = false;
|
||||||
|
}
|
||||||
|
/* fallthrough */
|
||||||
|
case AccountState::Online: {
|
||||||
|
if (!m_session->wants_online) {
|
||||||
|
// we ask the user for a player name
|
||||||
|
bool ok = false;
|
||||||
|
QString name;
|
||||||
|
if (m_offlineName.isEmpty()) {
|
||||||
|
name = askOfflineName(m_session->player_name, m_session->demo, &ok);
|
||||||
|
if (!ok) {
|
||||||
|
tryagain = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
name = m_offlineName;
|
||||||
}
|
}
|
||||||
m_session->MakeOffline(name);
|
m_session->MakeOffline(name);
|
||||||
|
// offline flavored game from here :3
|
||||||
|
} else if (m_accountToUse == accountToCheck && !m_accountToUse->hasProfile()) {
|
||||||
|
// Now handle setting up a profile name here...
|
||||||
|
ProfileSetupDialog dialog(m_accountToUse, m_parentWidget);
|
||||||
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
|
tryagain = true;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
emitFailed(tr("Received undetermined session status during login."));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_accountToUse->accountType() == AccountType::Offline)
|
||||||
|
m_session->wants_online = false;
|
||||||
|
|
||||||
|
// we own Minecraft, there is a profile, it's all ready to go!
|
||||||
launchInstance();
|
launchInstance();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case AccountState::Errored:
|
||||||
|
// This means some sort of soft error that we can fix with a refresh ... so let's refresh.
|
||||||
|
case AccountState::Unchecked: {
|
||||||
|
accountToCheck->refresh();
|
||||||
|
}
|
||||||
|
/* fallthrough */
|
||||||
|
case AccountState::Working: {
|
||||||
|
// refresh is in progress, we need to wait for it to finish to proceed.
|
||||||
|
ProgressDialog progDialog(m_parentWidget);
|
||||||
|
progDialog.setSkipButton(true, tr("Abort"));
|
||||||
|
|
||||||
|
auto task = accountToCheck->currentTask();
|
||||||
|
progDialog.execWithTask(task.get());
|
||||||
|
|
||||||
|
// don't retry if aborted
|
||||||
|
if (task->getState() == Task::State::AbortedByUser)
|
||||||
|
tryagain = false;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
case AccountState::Expired: {
|
||||||
|
if (reauthenticateAccount(accountToCheck))
|
||||||
|
continue;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case AccountState::Disabled: {
|
||||||
|
auto errorString = tr("The launcher's client identification has changed. Please remove '%1' and try again.")
|
||||||
|
.arg(accountToCheck->profileName());
|
||||||
|
|
||||||
|
QMessageBox::warning(m_parentWidget, tr("Client identification changed"), errorString, QMessageBox::StandardButton::Ok,
|
||||||
|
QMessageBox::StandardButton::Ok);
|
||||||
|
emitFailed(errorString);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case AccountState::Gone: {
|
||||||
|
auto errorString =
|
||||||
|
tr("'%1' no longer exists on the servers. It may have been migrated, in which case please add the new account "
|
||||||
|
"you migrated this one to.")
|
||||||
|
.arg(accountToCheck->profileName());
|
||||||
|
QMessageBox::warning(m_parentWidget, tr("Account gone"), errorString, QMessageBox::StandardButton::Ok,
|
||||||
|
QMessageBox::StandardButton::Ok);
|
||||||
|
emitFailed(errorString);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
emitFailed(tr("Failed to launch."));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LaunchController::reauthenticateAccount(const MinecraftAccountPtr& account, const QString& reason)
|
bool LaunchController::reauthenticateAccount(MinecraftAccountPtr account)
|
||||||
{
|
{
|
||||||
auto button = QMessageBox::warning(
|
auto button = QMessageBox::warning(
|
||||||
m_parentWidget, tr("Account refresh failed"), tr("%1. Do you want to reauthenticate this account?").arg(reason),
|
m_parentWidget, tr("Account refresh failed"),
|
||||||
|
tr("'%1' has expired and needs to be reauthenticated. Do you want to reauthenticate this account?").arg(account->profileName()),
|
||||||
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, QMessageBox::StandardButton::Yes);
|
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, QMessageBox::StandardButton::Yes);
|
||||||
if (button == QMessageBox::StandardButton::Yes) {
|
if (button == QMessageBox::StandardButton::Yes) {
|
||||||
auto* accounts = APPLICATION->accounts();
|
auto accounts = APPLICATION->accounts();
|
||||||
const bool isDefault = accounts->defaultAccount() == account;
|
bool isDefault = accounts->defaultAccount() == account;
|
||||||
|
accounts->removeAccount(accounts->index(accounts->findAccountByProfileId(account->profileId())));
|
||||||
if (account->accountType() == AccountType::MSA) {
|
if (account->accountType() == AccountType::MSA) {
|
||||||
auto newAccount = MSALoginDialog::newAccount(m_parentWidget);
|
auto newAccount = MSALoginDialog::newAccount(m_parentWidget);
|
||||||
|
|
||||||
if (newAccount != nullptr) {
|
if (newAccount != nullptr) {
|
||||||
accounts->removeAccount(accounts->index(accounts->findAccountByProfileId(account->profileId())));
|
|
||||||
accounts->addAccount(newAccount);
|
accounts->addAccount(newAccount);
|
||||||
|
|
||||||
if (isDefault) {
|
if (isDefault)
|
||||||
accounts->setDefaultAccount(newAccount);
|
accounts->setDefaultAccount(newAccount);
|
||||||
}
|
|
||||||
|
|
||||||
if (m_accountToUse == account) {
|
if (m_accountToUse == account) {
|
||||||
m_accountToUse = nullptr;
|
m_accountToUse = nullptr;
|
||||||
|
|
@ -362,13 +377,14 @@ bool LaunchController::reauthenticateAccount(const MinecraftAccountPtr& account,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emitFailed(tr("The account has expired and needs to be reauthenticated"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LaunchController::launchInstance()
|
void LaunchController::launchInstance()
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_instance != nullptr);
|
Q_ASSERT_X(m_instance != NULL, "launchInstance", "instance is NULL");
|
||||||
Q_ASSERT(m_session.get() != nullptr);
|
Q_ASSERT_X(m_session.get() != nullptr, "launchInstance", "session is NULL");
|
||||||
|
|
||||||
if (!m_instance->reloadSettings()) {
|
if (!m_instance->reloadSettings()) {
|
||||||
QMessageBox::critical(m_parentWidget, tr("Error!"), tr("Couldn't load the instance profile."));
|
QMessageBox::critical(m_parentWidget, tr("Error!"), tr("Couldn't load the instance profile."));
|
||||||
|
|
@ -382,36 +398,37 @@ void LaunchController::launchInstance()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto* console = qobject_cast<InstanceWindow*>(m_parentWidget);
|
auto console = qobject_cast<InstanceWindow*>(m_parentWidget);
|
||||||
const auto showConsole = m_instance->settings()->get("ShowConsole").toBool();
|
auto showConsole = m_instance->settings()->get("ShowConsole").toBool();
|
||||||
if (!console && showConsole) {
|
if (!console && showConsole) {
|
||||||
APPLICATION->showInstanceWindow(m_instance);
|
APPLICATION->showInstanceWindow(m_instance);
|
||||||
}
|
}
|
||||||
connect(m_launcher, &LaunchTask::readyForLaunch, this, &LaunchController::readyForLaunch);
|
connect(m_launcher.get(), &LaunchTask::readyForLaunch, this, &LaunchController::readyForLaunch);
|
||||||
connect(m_launcher, &LaunchTask::succeeded, this, &LaunchController::onSucceeded);
|
connect(m_launcher.get(), &LaunchTask::succeeded, this, &LaunchController::onSucceeded);
|
||||||
connect(m_launcher, &LaunchTask::failed, this, &LaunchController::onFailed);
|
connect(m_launcher.get(), &LaunchTask::failed, this, &LaunchController::onFailed);
|
||||||
connect(m_launcher, &LaunchTask::requestProgress, this, &LaunchController::onProgressRequested);
|
connect(m_launcher.get(), &LaunchTask::requestProgress, this, &LaunchController::onProgressRequested);
|
||||||
|
|
||||||
// Prepend Online and Auth Status
|
// Prepend Online and Auth Status
|
||||||
QString online_mode;
|
QString online_mode;
|
||||||
if (m_actualLaunchMode == LaunchMode::Normal) {
|
if (m_session->wants_online) {
|
||||||
online_mode = "online";
|
online_mode = "online";
|
||||||
|
|
||||||
// Prepend Server Status
|
// Prepend Server Status
|
||||||
const QStringList servers = { "login.microsoftonline.com", "session.minecraft.net", "textures.minecraft.net", "api.mojang.com" };
|
QStringList servers = { "login.microsoftonline.com", "session.minecraft.net", "textures.minecraft.net", "api.mojang.com" };
|
||||||
|
|
||||||
m_launcher->prependStep(makeShared<PrintServers>(m_launcher, servers));
|
m_launcher->prependStep(makeShared<PrintServers>(m_launcher.get(), servers));
|
||||||
} else {
|
} else {
|
||||||
online_mode = m_actualLaunchMode == LaunchMode::Demo ? "demo" : "offline";
|
online_mode = m_demo ? "demo" : "offline";
|
||||||
}
|
}
|
||||||
|
|
||||||
m_launcher->prependStep(makeShared<TextPrint>(m_launcher, "Launched instance in " + online_mode + " mode\n", MessageLevel::Launcher));
|
m_launcher->prependStep(
|
||||||
|
makeShared<TextPrint>(m_launcher.get(), "Launched instance in " + online_mode + " mode\n", MessageLevel::Launcher));
|
||||||
|
|
||||||
// Prepend Version
|
// Prepend Version
|
||||||
{
|
{
|
||||||
auto versionString = QString("%1 version: %2 (%3)")
|
auto versionString = QString("%1 version: %2 (%3)")
|
||||||
.arg(BuildConfig.LAUNCHER_DISPLAYNAME, BuildConfig.printableVersionString(), BuildConfig.BUILD_PLATFORM);
|
.arg(BuildConfig.LAUNCHER_DISPLAYNAME, BuildConfig.printableVersionString(), BuildConfig.BUILD_PLATFORM);
|
||||||
m_launcher->prependStep(makeShared<TextPrint>(m_launcher, versionString + "\n", MessageLevel::Launcher));
|
m_launcher->prependStep(makeShared<TextPrint>(m_launcher.get(), versionString + "\n\n", MessageLevel::Launcher));
|
||||||
}
|
}
|
||||||
m_launcher->start();
|
m_launcher->start();
|
||||||
}
|
}
|
||||||
|
|
@ -468,10 +485,10 @@ void LaunchController::onFailed(QString reason)
|
||||||
if (m_instance->settings()->get("ShowConsoleOnError").toBool()) {
|
if (m_instance->settings()->get("ShowConsoleOnError").toBool()) {
|
||||||
APPLICATION->showInstanceWindow(m_instance, "console");
|
APPLICATION->showInstanceWindow(m_instance, "console");
|
||||||
}
|
}
|
||||||
emitFailed(std::move(reason));
|
emitFailed(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LaunchController::onProgressRequested(Task* task) const
|
void LaunchController::onProgressRequested(Task* task)
|
||||||
{
|
{
|
||||||
ProgressDialog progDialog(m_parentWidget);
|
ProgressDialog progDialog(m_parentWidget);
|
||||||
progDialog.setSkipButton(true, tr("Abort"));
|
progDialog.setSkipButton(true, tr("Abort"));
|
||||||
|
|
|
||||||
|
|
@ -36,30 +36,30 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <BaseInstance.h>
|
#include <BaseInstance.h>
|
||||||
#include <tools/BaseProfiler.h>
|
#include <tools/BaseProfiler.h>
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
#include "minecraft/auth/MinecraftAccount.h"
|
#include "minecraft/auth/MinecraftAccount.h"
|
||||||
#include "minecraft/launch/MinecraftTarget.h"
|
#include "minecraft/launch/MinecraftTarget.h"
|
||||||
|
|
||||||
class InstanceWindow;
|
class InstanceWindow;
|
||||||
|
|
||||||
enum class LaunchDecision { Undecided, Continue, Abort };
|
|
||||||
|
|
||||||
class LaunchController : public Task {
|
class LaunchController : public Task {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
void executeTask() override;
|
void executeTask() override;
|
||||||
|
|
||||||
LaunchController();
|
LaunchController();
|
||||||
~LaunchController() override = default;
|
virtual ~LaunchController() = default;
|
||||||
|
|
||||||
void setInstance(BaseInstance* instance) { m_instance = instance; }
|
void setInstance(InstancePtr instance) { m_instance = instance; }
|
||||||
|
|
||||||
BaseInstance* instance() const { return m_instance; }
|
InstancePtr instance() { return m_instance; }
|
||||||
|
|
||||||
void setLaunchMode(const LaunchMode mode) { m_wantedLaunchMode = mode; }
|
void setOnline(bool online) { m_online = online; }
|
||||||
|
|
||||||
void setOfflineName(const QString& offlineName) { m_offlineName = offlineName; }
|
void setOfflineName(const QString& offlineName) { m_offlineName = offlineName; }
|
||||||
|
|
||||||
|
void setDemo(bool demo) { m_demo = demo; }
|
||||||
|
|
||||||
void setProfiler(BaseProfilerFactory* profiler) { m_profiler = profiler; }
|
void setProfiler(BaseProfilerFactory* profiler) { m_profiler = profiler; }
|
||||||
|
|
||||||
void setParentWidget(QWidget* widget) { m_parentWidget = widget; }
|
void setParentWidget(QWidget* widget) { m_parentWidget = widget; }
|
||||||
|
|
@ -68,7 +68,7 @@ class LaunchController : public Task {
|
||||||
|
|
||||||
void setAccountToUse(MinecraftAccountPtr accountToUse) { m_accountToUse = std::move(accountToUse); }
|
void setAccountToUse(MinecraftAccountPtr accountToUse) { m_accountToUse = std::move(accountToUse); }
|
||||||
|
|
||||||
QString id() const { return m_instance->id(); }
|
QString id() { return m_instance->id(); }
|
||||||
|
|
||||||
bool abort() override;
|
bool abort() override;
|
||||||
|
|
||||||
|
|
@ -76,28 +76,27 @@ class LaunchController : public Task {
|
||||||
void login();
|
void login();
|
||||||
void launchInstance();
|
void launchInstance();
|
||||||
void decideAccount();
|
void decideAccount();
|
||||||
LaunchDecision decideLaunchMode();
|
bool askPlayDemo();
|
||||||
bool askPlayDemo() const;
|
QString askOfflineName(QString playerName, bool demo, bool* ok = nullptr);
|
||||||
QString askOfflineName(const QString& playerName, bool* ok = nullptr);
|
bool reauthenticateAccount(MinecraftAccountPtr account);
|
||||||
bool reauthenticateAccount(const MinecraftAccountPtr& account, const QString& reason);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void readyForLaunch();
|
void readyForLaunch();
|
||||||
|
|
||||||
void onSucceeded();
|
void onSucceeded();
|
||||||
void onFailed(QString reason);
|
void onFailed(QString reason);
|
||||||
void onProgressRequested(Task* task) const;
|
void onProgressRequested(Task* task);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LaunchMode m_wantedLaunchMode = LaunchMode::Normal;
|
|
||||||
LaunchMode m_actualLaunchMode = LaunchMode::Normal;
|
|
||||||
BaseProfilerFactory* m_profiler = nullptr;
|
BaseProfilerFactory* m_profiler = nullptr;
|
||||||
|
bool m_online = true;
|
||||||
QString m_offlineName;
|
QString m_offlineName;
|
||||||
BaseInstance* m_instance = nullptr;
|
bool m_demo = false;
|
||||||
|
InstancePtr m_instance;
|
||||||
QWidget* m_parentWidget = nullptr;
|
QWidget* m_parentWidget = nullptr;
|
||||||
InstanceWindow* m_console = nullptr;
|
InstanceWindow* m_console = nullptr;
|
||||||
MinecraftAccountPtr m_accountToUse = nullptr;
|
MinecraftAccountPtr m_accountToUse = nullptr;
|
||||||
AuthSessionPtr m_session = nullptr;
|
AuthSessionPtr m_session;
|
||||||
LaunchTask* m_launcher = nullptr;
|
shared_qobject_ptr<LaunchTask> m_launcher;
|
||||||
MinecraftTarget::Ptr m_targetToJoin = nullptr;
|
MinecraftTarget::Ptr m_targetToJoin;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
/*
|
|
||||||
* Prism Launcher - Minecraft Launcher
|
|
||||||
* Copyright (C) 2026 Octol1ttle <l1ttleofficial@outlook.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, version 3.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
enum class LaunchMode {
|
|
||||||
Normal,
|
|
||||||
Offline,
|
|
||||||
Demo,
|
|
||||||
};
|
|
||||||
|
|
@ -15,18 +15,12 @@ fi
|
||||||
|
|
||||||
|
|
||||||
LAUNCHER_NAME=@Launcher_APP_BINARY_NAME@
|
LAUNCHER_NAME=@Launcher_APP_BINARY_NAME@
|
||||||
LAUNCHER_ENVNAME=@Launcher_ENVName@
|
|
||||||
LAUNCHER_DIR="$(dirname "$(readlink -f "$0")")"
|
LAUNCHER_DIR="$(dirname "$(readlink -f "$0")")"
|
||||||
echo "Launcher Dir: ${LAUNCHER_DIR}"
|
echo "Launcher Dir: ${LAUNCHER_DIR}"
|
||||||
|
|
||||||
# Makes the launcher use portals for file picking
|
# Makes the launcher use portals for file picking
|
||||||
export QT_QPA_PLATFORMTHEME=xdgdesktopportal
|
export QT_QPA_PLATFORMTHEME=xdgdesktopportal
|
||||||
|
|
||||||
# disable OpenGL and Vulkan launcher features on sharun until https://github.com/VHSgunzo/sharun/issues/35
|
|
||||||
if [[ -f "${LAUNCHER_DIR}/sharun" ]]; then
|
|
||||||
export ${LAUNCHER_ENVNAME}_DISABLE_GLVULKAN=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Just to be sure...
|
# Just to be sure...
|
||||||
chmod +x "${LAUNCHER_DIR}/bin/${LAUNCHER_NAME}"
|
chmod +x "${LAUNCHER_DIR}/bin/${LAUNCHER_NAME}"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ void LoggedProcess::on_error(QProcess::ProcessError error)
|
||||||
{
|
{
|
||||||
switch (error) {
|
switch (error) {
|
||||||
case QProcess::FailedToStart: {
|
case QProcess::FailedToStart: {
|
||||||
emit log({ tr("The process failed to start: %1").arg(errorString()) }, MessageLevel::Fatal);
|
emit log({ tr("The process failed to start.") }, MessageLevel::Fatal);
|
||||||
changeState(LoggedProcess::FailedToStart);
|
changeState(LoggedProcess::FailedToStart);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <MMCTime.h>
|
#include <MMCTime.h>
|
||||||
|
#include <qobject.h>
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,7 @@ std::optional<QStringList> extractSubDir(ArchiveReader* zip, const QString& subd
|
||||||
<< target;
|
<< target;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!f->writeFile(ext, target_file_path, target)) {
|
if (!f->writeFile(ext, target_file_path)) {
|
||||||
qWarning() << "Failed to extract file" << original_name << "to" << target_file_path;
|
qWarning() << "Failed to extract file" << original_name << "to" << target_file_path;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,26 +14,26 @@
|
||||||
else \
|
else \
|
||||||
type = Qt::DirectConnection;
|
type = Qt::DirectConnection;
|
||||||
|
|
||||||
#define DEFINE_FUNC_NO_PARAM(NAME, RET_TYPE, RET_DEF) \
|
#define DEFINE_FUNC_NO_PARAM(NAME, RET_TYPE) \
|
||||||
static RET_TYPE NAME() \
|
static RET_TYPE NAME() \
|
||||||
{ \
|
{ \
|
||||||
RET_TYPE ret = RET_DEF; \
|
RET_TYPE ret; \
|
||||||
GET_TYPE() \
|
GET_TYPE() \
|
||||||
QMetaObject::invokeMethod(s_instance, "_" #NAME, type, Q_RETURN_ARG(RET_TYPE, ret)); \
|
QMetaObject::invokeMethod(s_instance, "_" #NAME, type, Q_RETURN_ARG(RET_TYPE, ret)); \
|
||||||
return ret; \
|
return ret; \
|
||||||
}
|
}
|
||||||
#define DEFINE_FUNC_ONE_PARAM(NAME, RET_TYPE, RET_DEF, PARAM_1_TYPE) \
|
#define DEFINE_FUNC_ONE_PARAM(NAME, RET_TYPE, PARAM_1_TYPE) \
|
||||||
static RET_TYPE NAME(PARAM_1_TYPE p1) \
|
static RET_TYPE NAME(PARAM_1_TYPE p1) \
|
||||||
{ \
|
{ \
|
||||||
RET_TYPE ret = RET_DEF; \
|
RET_TYPE ret; \
|
||||||
GET_TYPE() \
|
GET_TYPE() \
|
||||||
QMetaObject::invokeMethod(s_instance, "_" #NAME, type, Q_RETURN_ARG(RET_TYPE, ret), Q_ARG(PARAM_1_TYPE, p1)); \
|
QMetaObject::invokeMethod(s_instance, "_" #NAME, type, Q_RETURN_ARG(RET_TYPE, ret), Q_ARG(PARAM_1_TYPE, p1)); \
|
||||||
return ret; \
|
return ret; \
|
||||||
}
|
}
|
||||||
#define DEFINE_FUNC_TWO_PARAM(NAME, RET_TYPE, RET_DEF, PARAM_1_TYPE, PARAM_2_TYPE) \
|
#define DEFINE_FUNC_TWO_PARAM(NAME, RET_TYPE, PARAM_1_TYPE, PARAM_2_TYPE) \
|
||||||
static RET_TYPE NAME(PARAM_1_TYPE p1, PARAM_2_TYPE p2) \
|
static RET_TYPE NAME(PARAM_1_TYPE p1, PARAM_2_TYPE p2) \
|
||||||
{ \
|
{ \
|
||||||
RET_TYPE ret = RET_DEF; \
|
RET_TYPE ret; \
|
||||||
GET_TYPE() \
|
GET_TYPE() \
|
||||||
QMetaObject::invokeMethod(s_instance, "_" #NAME, type, Q_RETURN_ARG(RET_TYPE, ret), Q_ARG(PARAM_1_TYPE, p1), \
|
QMetaObject::invokeMethod(s_instance, "_" #NAME, type, Q_RETURN_ARG(RET_TYPE, ret), Q_ARG(PARAM_1_TYPE, p1), \
|
||||||
Q_ARG(PARAM_2_TYPE, p2)); \
|
Q_ARG(PARAM_2_TYPE, p2)); \
|
||||||
|
|
@ -53,18 +53,18 @@ class PixmapCache final : public QObject {
|
||||||
static void setInstance(PixmapCache* i) { s_instance = i; }
|
static void setInstance(PixmapCache* i) { s_instance = i; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DEFINE_FUNC_NO_PARAM(cacheLimit, int, -1)
|
DEFINE_FUNC_NO_PARAM(cacheLimit, int)
|
||||||
DEFINE_FUNC_NO_PARAM(clear, bool, false)
|
DEFINE_FUNC_NO_PARAM(clear, bool)
|
||||||
DEFINE_FUNC_TWO_PARAM(find, bool, false, const QString&, QPixmap*)
|
DEFINE_FUNC_TWO_PARAM(find, bool, const QString&, QPixmap*)
|
||||||
DEFINE_FUNC_TWO_PARAM(find, bool, false, const QPixmapCache::Key&, QPixmap*)
|
DEFINE_FUNC_TWO_PARAM(find, bool, const QPixmapCache::Key&, QPixmap*)
|
||||||
DEFINE_FUNC_TWO_PARAM(insert, bool, false, const QString&, const QPixmap&)
|
DEFINE_FUNC_TWO_PARAM(insert, bool, const QString&, const QPixmap&)
|
||||||
DEFINE_FUNC_ONE_PARAM(insert, QPixmapCache::Key, {}, const QPixmap&)
|
DEFINE_FUNC_ONE_PARAM(insert, QPixmapCache::Key, const QPixmap&)
|
||||||
DEFINE_FUNC_ONE_PARAM(remove, bool, false, const QString&)
|
DEFINE_FUNC_ONE_PARAM(remove, bool, const QString&)
|
||||||
DEFINE_FUNC_ONE_PARAM(remove, bool, false, const QPixmapCache::Key&)
|
DEFINE_FUNC_ONE_PARAM(remove, bool, const QPixmapCache::Key&)
|
||||||
DEFINE_FUNC_TWO_PARAM(replace, bool, false, const QPixmapCache::Key&, const QPixmap&)
|
DEFINE_FUNC_TWO_PARAM(replace, bool, const QPixmapCache::Key&, const QPixmap&)
|
||||||
DEFINE_FUNC_ONE_PARAM(setCacheLimit, bool, false, int)
|
DEFINE_FUNC_ONE_PARAM(setCacheLimit, bool, int)
|
||||||
DEFINE_FUNC_NO_PARAM(markCacheMissByEviciton, bool, false)
|
DEFINE_FUNC_NO_PARAM(markCacheMissByEviciton, bool)
|
||||||
DEFINE_FUNC_ONE_PARAM(setFastEvictionThreshold, bool, false, int)
|
DEFINE_FUNC_ONE_PARAM(setFastEvictionThreshold, bool, int)
|
||||||
|
|
||||||
// NOTE: Every function returns something non-void to simplify the macros.
|
// NOTE: Every function returns something non-void to simplify the macros.
|
||||||
private slots:
|
private slots:
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
#include "Json.h"
|
#include "Json.h"
|
||||||
#include "LibraryUtils.h"
|
#include "MangoHud.h"
|
||||||
|
|
||||||
#ifdef __GLIBC__
|
#ifdef __GLIBC__
|
||||||
#ifndef _GNU_SOURCE
|
#ifndef _GNU_SOURCE
|
||||||
|
|
@ -36,9 +36,9 @@
|
||||||
#include <linux/limits.h>
|
#include <linux/limits.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace LibraryUtils {
|
namespace MangoHud {
|
||||||
|
|
||||||
QString findMangoHud()
|
QString getLibraryString()
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Guess MangoHud install location by searching for vulkan layers in this order:
|
* Guess MangoHud install location by searching for vulkan layers in this order:
|
||||||
|
|
@ -123,7 +123,7 @@ QString findMangoHud()
|
||||||
|
|
||||||
#ifdef __GLIBC__
|
#ifdef __GLIBC__
|
||||||
// Check whether mangohud is usable on a glibc based system
|
// Check whether mangohud is usable on a glibc based system
|
||||||
QString libraryPath = find(libraryName);
|
QString libraryPath = findLibrary(libraryName);
|
||||||
if (!libraryPath.isEmpty()) {
|
if (!libraryPath.isEmpty()) {
|
||||||
return libraryPath;
|
return libraryPath;
|
||||||
}
|
}
|
||||||
|
|
@ -138,7 +138,7 @@ QString findMangoHud()
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QString find(QString libName)
|
QString findLibrary(QString libName)
|
||||||
{
|
{
|
||||||
#ifdef __GLIBC__
|
#ifdef __GLIBC__
|
||||||
const char* library = libName.toLocal8Bit().constData();
|
const char* library = libName.toLocal8Bit().constData();
|
||||||
|
|
@ -161,11 +161,11 @@ QString find(QString libName)
|
||||||
dlclose(handle);
|
dlclose(handle);
|
||||||
return fullPath;
|
return fullPath;
|
||||||
#else
|
#else
|
||||||
qWarning() << "LibraryUtils::find is not implemented on this platform";
|
qWarning() << "MangoHud::findLibrary is not implemented on this platform";
|
||||||
return {};
|
return {};
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} // namespace LibraryUtils
|
} // namespace MangoHud
|
||||||
|
|
||||||
#ifdef UNDEF_GNU_SOURCE
|
#ifdef UNDEF_GNU_SOURCE
|
||||||
#undef _GNU_SOURCE
|
#undef _GNU_SOURCE
|
||||||
|
|
@ -21,9 +21,9 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
namespace LibraryUtils {
|
namespace MangoHud {
|
||||||
|
|
||||||
QString findMangoHud();
|
QString getLibraryString();
|
||||||
|
|
||||||
QString find(QString libName);
|
QString findLibrary(QString libName);
|
||||||
} // namespace LibraryUtils
|
} // namespace MangoHud
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <qlogging.h>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <compare>
|
#include <compare>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,8 @@
|
||||||
class NullInstance : public BaseInstance {
|
class NullInstance : public BaseInstance {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
NullInstance(SettingsObject* globalSettings, std::unique_ptr<SettingsObject> settings, const QString& rootDir)
|
NullInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString& rootDir)
|
||||||
: BaseInstance(globalSettings, std::move(settings), rootDir)
|
: BaseInstance(globalSettings, settings, rootDir)
|
||||||
{
|
{
|
||||||
setVersionBroken(true);
|
setVersionBroken(true);
|
||||||
}
|
}
|
||||||
|
|
@ -52,7 +52,7 @@ class NullInstance : public BaseInstance {
|
||||||
QString getStatusbarDescription() override { return tr("Unknown instance type"); };
|
QString getStatusbarDescription() override { return tr("Unknown instance type"); };
|
||||||
QSet<QString> traits() const override { return {}; };
|
QSet<QString> traits() const override { return {}; };
|
||||||
QString instanceConfigFolder() const override { return instanceRoot(); };
|
QString instanceConfigFolder() const override { return instanceRoot(); };
|
||||||
LaunchTask* createLaunchTask(AuthSessionPtr, MinecraftTarget::Ptr) override { return nullptr; }
|
shared_qobject_ptr<LaunchTask> createLaunchTask(AuthSessionPtr, MinecraftTarget::Ptr) override { return nullptr; }
|
||||||
QList<Task::Ptr> createUpdateTask() override { return {}; }
|
QList<Task::Ptr> createUpdateTask() override { return {}; }
|
||||||
QProcessEnvironment createEnvironment() override { return QProcessEnvironment(); }
|
QProcessEnvironment createEnvironment() override { return QProcessEnvironment(); }
|
||||||
QProcessEnvironment createLaunchEnvironment() override { return QProcessEnvironment(); }
|
QProcessEnvironment createLaunchEnvironment() override { return QProcessEnvironment(); }
|
||||||
|
|
|
||||||
|
|
@ -67,5 +67,5 @@ class PSaveFile : public QSaveFile {
|
||||||
QString m_absoluteFilePath;
|
QString m_absoluteFilePath;
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
using PSaveFile = QSaveFile;
|
#define PSaveFile QSaveFile
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -19,52 +19,23 @@
|
||||||
|
|
||||||
#include "ResourceDownloadTask.h"
|
#include "ResourceDownloadTask.h"
|
||||||
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
#include "minecraft/MinecraftInstance.h"
|
|
||||||
#include "minecraft/PackProfile.h"
|
|
||||||
#include "minecraft/mod/ResourceFolderModel.h"
|
#include "minecraft/mod/ResourceFolderModel.h"
|
||||||
|
|
||||||
#include "minecraft/mod/ShaderPackFolderModel.h"
|
#include "minecraft/mod/ShaderPackFolderModel.h"
|
||||||
#include "modplatform/ModIndex.h"
|
|
||||||
#include "modplatform/helpers/HashUtils.h"
|
#include "modplatform/helpers/HashUtils.h"
|
||||||
#include "net/ApiDownload.h"
|
#include "net/ApiDownload.h"
|
||||||
#include "net/ChecksumValidator.h"
|
#include "net/ChecksumValidator.h"
|
||||||
|
|
||||||
namespace {
|
|
||||||
Net::ModrinthDownloadMeta createModrinthMeta(BaseInstance* instance, QString reason)
|
|
||||||
{
|
|
||||||
auto* mcInstance = dynamic_cast<MinecraftInstance*>(instance);
|
|
||||||
if (!mcInstance) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
auto* profile = mcInstance->getPackProfile();
|
|
||||||
if (!profile) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
auto loaders = profile->getModLoadersList();
|
|
||||||
|
|
||||||
return {
|
|
||||||
.reason = std::move(reason),
|
|
||||||
.gameVersion = profile->getComponentVersion("net.minecraft"),
|
|
||||||
.loader = !loaders.isEmpty() ? ModPlatform::getModLoaderAsString(loaders.first()) : "",
|
|
||||||
};
|
|
||||||
}
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
ResourceDownloadTask::ResourceDownloadTask(ModPlatform::IndexedPack::Ptr pack,
|
ResourceDownloadTask::ResourceDownloadTask(ModPlatform::IndexedPack::Ptr pack,
|
||||||
ModPlatform::IndexedVersion version,
|
ModPlatform::IndexedVersion version,
|
||||||
ResourceFolderModel* packs,
|
const std::shared_ptr<ResourceFolderModel> packs,
|
||||||
bool isIndexed,
|
bool is_indexed)
|
||||||
QString downloadReason)
|
|
||||||
: m_pack(std::move(pack)), m_pack_version(std::move(version)), m_pack_model(packs)
|
: m_pack(std::move(pack)), m_pack_version(std::move(version)), m_pack_model(packs)
|
||||||
{
|
{
|
||||||
if (isIndexed) {
|
if (is_indexed) {
|
||||||
m_update_task.reset(new LocalResourceUpdateTask(m_pack_model->indexDir(), *m_pack, m_pack_version));
|
m_update_task.reset(new LocalResourceUpdateTask(m_pack_model->indexDir(), *m_pack, m_pack_version));
|
||||||
connect(m_update_task.get(), &LocalResourceUpdateTask::hasOldResource, this, &ResourceDownloadTask::hasOldResource);
|
connect(m_update_task.get(), &LocalResourceUpdateTask::hasOldResource, this, &ResourceDownloadTask::hasOldResource);
|
||||||
|
|
||||||
|
|
@ -74,9 +45,7 @@ ResourceDownloadTask::ResourceDownloadTask(ModPlatform::IndexedPack::Ptr pack,
|
||||||
m_filesNetJob.reset(new NetJob(tr("Resource download"), APPLICATION->network()));
|
m_filesNetJob.reset(new NetJob(tr("Resource download"), APPLICATION->network()));
|
||||||
m_filesNetJob->setStatus(tr("Downloading resource:\n%1").arg(m_pack_version.downloadUrl));
|
m_filesNetJob->setStatus(tr("Downloading resource:\n%1").arg(m_pack_version.downloadUrl));
|
||||||
|
|
||||||
auto action = Net::ApiDownload::makeFile(m_pack_version.downloadUrl, m_pack_model->dir().absoluteFilePath(getFilename()),
|
auto action = Net::ApiDownload::makeFile(m_pack_version.downloadUrl, m_pack_model->dir().absoluteFilePath(getFilename()));
|
||||||
Net::Download::Option::NoOptions,
|
|
||||||
createModrinthMeta(m_pack_model->instance(), std::move(downloadReason)));
|
|
||||||
if (!m_pack_version.hash_type.isEmpty() && !m_pack_version.hash.isEmpty()) {
|
if (!m_pack_version.hash_type.isEmpty() && !m_pack_version.hash.isEmpty()) {
|
||||||
switch (Hashing::algorithmFromString(m_pack_version.hash_type)) {
|
switch (Hashing::algorithmFromString(m_pack_version.hash_type)) {
|
||||||
case Hashing::Algorithm::Md4:
|
case Hashing::Algorithm::Md4:
|
||||||
|
|
@ -113,31 +82,29 @@ void ResourceDownloadTask::downloadSucceeded()
|
||||||
auto oldName = std::get<0>(to_delete);
|
auto oldName = std::get<0>(to_delete);
|
||||||
auto oldFilename = std::get<1>(to_delete);
|
auto oldFilename = std::get<1>(to_delete);
|
||||||
|
|
||||||
if (oldName.isEmpty() || oldFilename == m_pack_version.fileName) {
|
if (oldName.isEmpty() || oldFilename == m_pack_version.fileName)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
m_pack_model->uninstallResource(oldFilename, true);
|
m_pack_model->uninstallResource(oldFilename, true);
|
||||||
|
|
||||||
// also rename the shader config file
|
// also rename the shader config file
|
||||||
if (dynamic_cast<ShaderPackFolderModel*>(m_pack_model) != nullptr) {
|
if (dynamic_cast<ShaderPackFolderModel*>(m_pack_model.get()) != nullptr) {
|
||||||
QFileInfo oldConfig(m_pack_model->dir(), oldFilename + ".txt");
|
QFileInfo oldConfig(m_pack_model->dir(), oldFilename + ".txt");
|
||||||
QFileInfo newConfig(m_pack_model->dir(), getFilename() + ".txt");
|
QFileInfo newConfig(m_pack_model->dir(), getFilename() + ".txt");
|
||||||
|
|
||||||
if (oldConfig.exists() && !newConfig.exists()) {
|
if (oldConfig.exists() && !newConfig.exists()) {
|
||||||
bool success = FS::move(oldConfig.filePath(), newConfig.filePath());
|
bool success = FS::move(oldConfig.filePath(), newConfig.filePath());
|
||||||
|
|
||||||
if (!success) {
|
if (!success)
|
||||||
emit logWarning(tr("Failed to rename shader config from '%1' to '%2'").arg(oldConfig.fileName(), newConfig.fileName()));
|
emit logWarning(tr("Failed to rename shader config from '%1' to '%2'").arg(oldConfig.fileName(), newConfig.fileName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void ResourceDownloadTask::downloadFailed(QString reason)
|
void ResourceDownloadTask::downloadFailed(QString reason)
|
||||||
{
|
{
|
||||||
|
emitFailed(reason);
|
||||||
m_filesNetJob.reset();
|
m_filesNetJob.reset();
|
||||||
emitFailed(std::move(reason));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceDownloadTask::downloadProgressChanged(qint64 current, qint64 total)
|
void ResourceDownloadTask::downloadProgressChanged(qint64 current, qint64 total)
|
||||||
|
|
@ -147,7 +114,7 @@ void ResourceDownloadTask::downloadProgressChanged(qint64 current, qint64 total)
|
||||||
|
|
||||||
// This indirection is done so that we don't delete a mod before being sure it was
|
// This indirection is done so that we don't delete a mod before being sure it was
|
||||||
// downloaded successfully!
|
// downloaded successfully!
|
||||||
void ResourceDownloadTask::hasOldResource(const QString& name, const QString& filename)
|
void ResourceDownloadTask::hasOldResource(QString name, QString filename)
|
||||||
{
|
{
|
||||||
to_delete = { name, filename };
|
to_delete = { name, filename };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,8 @@ class ResourceDownloadTask : public SequentialTask {
|
||||||
public:
|
public:
|
||||||
explicit ResourceDownloadTask(ModPlatform::IndexedPack::Ptr pack,
|
explicit ResourceDownloadTask(ModPlatform::IndexedPack::Ptr pack,
|
||||||
ModPlatform::IndexedVersion version,
|
ModPlatform::IndexedVersion version,
|
||||||
ResourceFolderModel* packs,
|
std::shared_ptr<ResourceFolderModel> packs,
|
||||||
bool isIndexed = true,
|
bool is_indexed = true);
|
||||||
QString downloadReason = "standalone");
|
|
||||||
const QString& getFilename() const { return m_pack_version.fileName; }
|
const QString& getFilename() const { return m_pack_version.fileName; }
|
||||||
const QVariant& getVersionID() const { return m_pack_version.fileId; }
|
const QVariant& getVersionID() const { return m_pack_version.fileId; }
|
||||||
const ModPlatform::IndexedVersion& getVersion() const { return m_pack_version; }
|
const ModPlatform::IndexedVersion& getVersion() const { return m_pack_version; }
|
||||||
|
|
@ -45,7 +44,7 @@ class ResourceDownloadTask : public SequentialTask {
|
||||||
private:
|
private:
|
||||||
ModPlatform::IndexedPack::Ptr m_pack;
|
ModPlatform::IndexedPack::Ptr m_pack;
|
||||||
ModPlatform::IndexedVersion m_pack_version;
|
ModPlatform::IndexedVersion m_pack_version;
|
||||||
ResourceFolderModel* m_pack_model;
|
const std::shared_ptr<ResourceFolderModel> m_pack_model;
|
||||||
|
|
||||||
NetJob::Ptr m_filesNetJob;
|
NetJob::Ptr m_filesNetJob;
|
||||||
LocalResourceUpdateTask::Ptr m_update_task;
|
LocalResourceUpdateTask::Ptr m_update_task;
|
||||||
|
|
@ -57,5 +56,5 @@ class ResourceDownloadTask : public SequentialTask {
|
||||||
std::tuple<QString, QString> to_delete{ "", "" };
|
std::tuple<QString, QString> to_delete{ "", "" };
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void hasOldResource(const QString& name, const QString& filename);
|
void hasOldResource(QString name, QString filename);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ struct RuntimeContext {
|
||||||
return javaRealArchitecture;
|
return javaRealArchitecture;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateFromInstanceSettings(SettingsObject* instanceSettings)
|
void updateFromInstanceSettings(SettingsObjectPtr instanceSettings)
|
||||||
{
|
{
|
||||||
javaArchitecture = instanceSettings->get("JavaArchitecture").toString();
|
javaArchitecture = instanceSettings->get("JavaArchitecture").toString();
|
||||||
javaRealArchitecture = instanceSettings->get("JavaRealArchitecture").toString();
|
javaRealArchitecture = instanceSettings->get("JavaRealArchitecture").toString();
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "StringUtils.h"
|
#include "StringUtils.h"
|
||||||
|
#include <qpair.h>
|
||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
|
||||||
|
|
@ -1,54 +1,20 @@
|
||||||
|
#include <QDebug>
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
/*
|
|
||||||
* Prism Launcher - Minecraft Launcher
|
|
||||||
* Copyright (C) 2022 r58Playz <r58playz@gmail.com>
|
|
||||||
* Copyright (C) 2024 timoreo <contact@timoreo.fr>
|
|
||||||
* Copyright (C) 2024 Trial97 <alexandru.tripon97@gmail.com>
|
|
||||||
* Copyright (C) 2025 TheKodeToad <TheKodeToad@proton.me>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* 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 <QString>
|
#include <QString>
|
||||||
|
#include "sys.h"
|
||||||
#include "HardwareInfo.h"
|
|
||||||
|
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
|
#endif
|
||||||
|
#include <QFile>
|
||||||
|
#include <QMap>
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
bool rosettaDetect()
|
bool rosettaDetect()
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
size_t size = sizeof(ret);
|
size_t size = sizeof(ret);
|
||||||
if (sysctlbyname("sysctl.proc_translated", &ret, &size, nullptr, 0) == -1) {
|
if (sysctlbyname("sysctl.proc_translated", &ret, &size, NULL, 0) == -1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return ret == 1;
|
return ret == 1;
|
||||||
|
|
@ -85,13 +51,18 @@ QString useQTForArch()
|
||||||
return QSysInfo::currentCpuArchitecture();
|
return QSysInfo::currentCpuArchitecture();
|
||||||
}
|
}
|
||||||
|
|
||||||
int defaultMaxJvmMem()
|
int suitableMaxMem()
|
||||||
{
|
{
|
||||||
|
float totalRAM = (float)Sys::getSystemRam() / (float)Sys::mebibyte;
|
||||||
|
int maxMemoryAlloc;
|
||||||
|
|
||||||
// If totalRAM < 6GB, use (totalRAM / 1.5), else 4GB
|
// If totalRAM < 6GB, use (totalRAM / 1.5), else 4GB
|
||||||
if (const uint64_t totalRAM = HardwareInfo::totalRamMiB(); totalRAM < (4096 * 1.5))
|
if (totalRAM < (4096 * 1.5))
|
||||||
return totalRAM / 1.5;
|
maxMemoryAlloc = (int)(totalRAM / 1.5);
|
||||||
else
|
else
|
||||||
return 4096;
|
maxMemoryAlloc = 4096;
|
||||||
|
|
||||||
|
return maxMemoryAlloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString getSupportedJavaArchitecture()
|
QString getSupportedJavaArchitecture()
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace SysInfo {
|
namespace SysInfo {
|
||||||
QString currentSystem();
|
QString currentSystem();
|
||||||
QString useQTForArch();
|
QString useQTForArch();
|
||||||
QString getSupportedJavaArchitecture();
|
QString getSupportedJavaArchitecture();
|
||||||
int defaultMaxJvmMem();
|
int suitableMaxMem();
|
||||||
} // namespace SysInfo
|
} // namespace SysInfo
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ class Usable {
|
||||||
*/
|
*/
|
||||||
class UseLock {
|
class UseLock {
|
||||||
public:
|
public:
|
||||||
UseLock(Usable* usable) : m_usable(usable)
|
UseLock(shared_qobject_ptr<Usable> usable) : m_usable(usable)
|
||||||
{
|
{
|
||||||
// this doesn't use shared pointer use count, because that wouldn't be correct. this count is separate.
|
// this doesn't use shared pointer use count, because that wouldn't be correct. this count is separate.
|
||||||
m_usable->incrementUses();
|
m_usable->incrementUses();
|
||||||
|
|
@ -44,5 +44,5 @@ class UseLock {
|
||||||
~UseLock() { m_usable->decrementUses(); }
|
~UseLock() { m_usable->decrementUses(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Usable* m_usable;
|
shared_qobject_ptr<Usable> m_usable;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1,124 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
/*
|
|
||||||
* Prism Launcher - Minecraft Launcher
|
|
||||||
* Copyright (C) 2023 flowln <flowlnlnln@gmail.com>
|
|
||||||
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
|
||||||
* Copyright (c) 2026 Trial97 <alexandru.tripon97@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.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#include "Version.h"
|
#include "Version.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QRegularExpressionMatch>
|
#include <QRegularExpressionMatch>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <compare>
|
|
||||||
|
Version::Version(QString str) : m_string(std::move(str))
|
||||||
|
{
|
||||||
|
parse();
|
||||||
|
}
|
||||||
|
|
||||||
|
#define VERSION_OPERATOR(return_on_different) \
|
||||||
|
bool exclude_our_sections = false; \
|
||||||
|
bool exclude_their_sections = false; \
|
||||||
|
\
|
||||||
|
const auto size = qMax(m_sections.size(), other.m_sections.size()); \
|
||||||
|
for (int i = 0; i < size; ++i) { \
|
||||||
|
Section sec1 = (i >= m_sections.size()) ? Section() : m_sections.at(i); \
|
||||||
|
Section sec2 = (i >= other.m_sections.size()) ? Section() : other.m_sections.at(i); \
|
||||||
|
\
|
||||||
|
{ /* Don't include appendixes in the comparison */ \
|
||||||
|
if (sec1.isAppendix()) \
|
||||||
|
exclude_our_sections = true; \
|
||||||
|
if (sec2.isAppendix()) \
|
||||||
|
exclude_their_sections = true; \
|
||||||
|
\
|
||||||
|
if (exclude_our_sections) { \
|
||||||
|
sec1 = Section(); \
|
||||||
|
if (sec2.m_isNull) \
|
||||||
|
break; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
if (exclude_their_sections) { \
|
||||||
|
sec2 = Section(); \
|
||||||
|
if (sec1.m_isNull) \
|
||||||
|
break; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
if (sec1 != sec2) \
|
||||||
|
return return_on_different; \
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Version::operator<(const Version& other) const
|
||||||
|
{
|
||||||
|
VERSION_OPERATOR(sec1 < sec2)
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool Version::operator==(const Version& other) const
|
||||||
|
{
|
||||||
|
VERSION_OPERATOR(false)
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool Version::operator!=(const Version& other) const
|
||||||
|
{
|
||||||
|
return !operator==(other);
|
||||||
|
}
|
||||||
|
bool Version::operator<=(const Version& other) const
|
||||||
|
{
|
||||||
|
return *this < other || *this == other;
|
||||||
|
}
|
||||||
|
bool Version::operator>(const Version& other) const
|
||||||
|
{
|
||||||
|
return !(*this <= other);
|
||||||
|
}
|
||||||
|
bool Version::operator>=(const Version& other) const
|
||||||
|
{
|
||||||
|
return !(*this < other);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Version::parse()
|
||||||
|
{
|
||||||
|
m_sections.clear();
|
||||||
|
QString currentSection;
|
||||||
|
|
||||||
|
if (m_string.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto classChange = [¤tSection](QChar lastChar, QChar currentChar) {
|
||||||
|
if (lastChar.isNull())
|
||||||
|
return false;
|
||||||
|
if (lastChar.isDigit() != currentChar.isDigit())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
const QList<QChar> s_separators{ '.', '-', '+' };
|
||||||
|
if (s_separators.contains(currentChar) && currentSection.at(0) != currentChar)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
currentSection += m_string.at(0);
|
||||||
|
for (int i = 1; i < m_string.size(); ++i) {
|
||||||
|
const auto& current_char = m_string.at(i);
|
||||||
|
if (classChange(m_string.at(i - 1), current_char)) {
|
||||||
|
if (!currentSection.isEmpty())
|
||||||
|
m_sections.append(Section(currentSection));
|
||||||
|
currentSection = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
currentSection += current_char;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!currentSection.isEmpty())
|
||||||
|
m_sections.append(Section(currentSection));
|
||||||
|
}
|
||||||
|
|
||||||
/// qDebug print support for the Version class
|
/// qDebug print support for the Version class
|
||||||
QDebug operator<<(QDebug debug, const Version& v)
|
QDebug operator<<(QDebug debug, const Version& v)
|
||||||
{
|
{
|
||||||
const QDebugStateSaver saver(debug);
|
QDebugStateSaver saver(debug);
|
||||||
|
|
||||||
debug.nospace() << "Version{ string: " << v.toString() << ", sections: [ ";
|
debug.nospace() << "Version{ string: " << v.toString() << ", sections: [ ";
|
||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (const auto& s : v.m_sections) {
|
for (auto s : v.m_sections) {
|
||||||
if (!first) {
|
if (!first)
|
||||||
debug.nospace() << ", ";
|
debug.nospace() << ", ";
|
||||||
}
|
debug.nospace() << s.m_fullString;
|
||||||
debug.nospace() << s.value;
|
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -44,114 +126,3 @@ QDebug operator<<(QDebug debug, const Version& v)
|
||||||
|
|
||||||
return debug;
|
return debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::strong_ordering Version::Section::operator<=>(const Section& other) const
|
|
||||||
{
|
|
||||||
// If both components are numeric, compare numerically (codepoint-wise)
|
|
||||||
if (this->t == Type::Numeric && other.t == Type::Numeric) {
|
|
||||||
auto aLen = this->value.size();
|
|
||||||
if (aLen != other.value.size()) {
|
|
||||||
// Lengths differ; compare by length
|
|
||||||
return aLen <=> other.value.size();
|
|
||||||
}
|
|
||||||
// Compare by digits
|
|
||||||
auto cmp = QString::compare(this->value, other.value);
|
|
||||||
if (cmp < 0) {
|
|
||||||
return std::strong_ordering::less;
|
|
||||||
}
|
|
||||||
if (cmp > 0) {
|
|
||||||
return std::strong_ordering::greater;
|
|
||||||
}
|
|
||||||
return std::strong_ordering::equal;
|
|
||||||
}
|
|
||||||
// One or both are null
|
|
||||||
if (this->t == Type::Null) {
|
|
||||||
if (other.t == Type::PreRelease) {
|
|
||||||
return std::strong_ordering::greater;
|
|
||||||
}
|
|
||||||
return std::strong_ordering::less;
|
|
||||||
}
|
|
||||||
if (other.t == Type::Null) {
|
|
||||||
if (this->t == Type::PreRelease) {
|
|
||||||
return std::strong_ordering::less;
|
|
||||||
}
|
|
||||||
return std::strong_ordering::greater;
|
|
||||||
}
|
|
||||||
// Textual comparison (differing type, or both textual/pre-release)
|
|
||||||
auto minLen = qMin(this->value.size(), other.value.size());
|
|
||||||
for (int i = 0; i < minLen; i++) {
|
|
||||||
auto a = this->value.at(i);
|
|
||||||
auto b = other.value.at(i);
|
|
||||||
if (a != b) {
|
|
||||||
// Compare by rune
|
|
||||||
return a.unicode() <=> b.unicode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Compare by length
|
|
||||||
return this->value.size() <=> other.value.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
void removeLeadingZeros(QString& s)
|
|
||||||
{
|
|
||||||
s.remove(0, std::distance(s.begin(), std::ranges::find_if_not(s, [](QChar c) { return c == '0'; })));
|
|
||||||
}
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
void Version::parse()
|
|
||||||
{
|
|
||||||
auto len = m_string.size();
|
|
||||||
for (int i = 0; i < len;) {
|
|
||||||
Section cur(Section::Type::Textual);
|
|
||||||
auto c = m_string.at(i);
|
|
||||||
if (c == '+') {
|
|
||||||
break; // Ignore appendices
|
|
||||||
}
|
|
||||||
// custom: the space is special to handle the strings like "1.20 Pre-Release 1"
|
|
||||||
// this is needed to support Modrinth versions
|
|
||||||
if (c == '-' || c == ' ') {
|
|
||||||
// Add dash to component
|
|
||||||
cur.value += c;
|
|
||||||
i++;
|
|
||||||
// If the next rune is non-digit, mark as pre-release (requires >= 1 non-digit after dash so the component has length > 1)
|
|
||||||
if (i < len && !m_string.at(i).isDigit()) {
|
|
||||||
cur.t = Section::Type::PreRelease;
|
|
||||||
}
|
|
||||||
} else if (c.isDigit()) {
|
|
||||||
// Mark as numeric
|
|
||||||
cur.t = Section::Type::Numeric;
|
|
||||||
}
|
|
||||||
for (; i < len; i++) {
|
|
||||||
auto r = m_string.at(i);
|
|
||||||
if ((r.isDigit() != (cur.t == Section::Type::Numeric)) // starts a new section
|
|
||||||
|| (r == ' ' && cur.t == Section::Type::Numeric) // custom: numeric section then a space is a pre-release
|
|
||||||
|| (r == '-' && cur.t != Section::Type::PreRelease) // "---" is a valid pre-release component
|
|
||||||
|| r == '+') {
|
|
||||||
// Run completed (do not consume this rune)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// Add rune to current run
|
|
||||||
cur.value += r;
|
|
||||||
}
|
|
||||||
if (!cur.value.isEmpty()) {
|
|
||||||
if (cur.t == Section::Type::Numeric) {
|
|
||||||
removeLeadingZeros(cur.value);
|
|
||||||
}
|
|
||||||
m_sections.append(cur);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::strong_ordering Version::operator<=>(const Version& other) const
|
|
||||||
{
|
|
||||||
const auto size = qMax(m_sections.size(), other.m_sections.size());
|
|
||||||
for (int i = 0; i < size; ++i) {
|
|
||||||
auto sec1 = (i >= m_sections.size()) ? Section() : m_sections.at(i);
|
|
||||||
auto sec2 = (i >= other.m_sections.size()) ? Section() : other.m_sections.at(i);
|
|
||||||
|
|
||||||
if (auto cmp = sec1 <=> sec2; cmp != std::strong_ordering::equal) {
|
|
||||||
return cmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return std::strong_ordering::equal;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
* Prism Launcher - Minecraft Launcher
|
* Prism Launcher - Minecraft Launcher
|
||||||
* Copyright (C) 2023 flowln <flowlnlnln@gmail.com>
|
* Copyright (C) 2023 flowln <flowlnlnln@gmail.com>
|
||||||
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||||
* Copyright (c) 2026 Trial97 <alexandru.tripon97@gmail.com>
|
|
||||||
*
|
*
|
||||||
* 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
|
||||||
|
|
@ -16,6 +15,23 @@
|
||||||
*
|
*
|
||||||
* 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/>.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
|
@ -25,36 +41,115 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringView>
|
#include <QStringView>
|
||||||
|
|
||||||
// this implements the FlexVer
|
class QUrl;
|
||||||
// https://git.sleeping.town/exa/FlexVer
|
|
||||||
class Version {
|
class Version {
|
||||||
public:
|
public:
|
||||||
Version(QString str) : m_string(std::move(str)) { parse(); } // NOLINT(hicpp-explicit-conversions)
|
Version(QString str);
|
||||||
Version() = default;
|
Version() = default;
|
||||||
|
|
||||||
private:
|
bool operator<(const Version& other) const;
|
||||||
struct Section {
|
bool operator<=(const Version& other) const;
|
||||||
enum class Type : std::uint8_t { Null, Textual, Numeric, PreRelease };
|
bool operator>(const Version& other) const;
|
||||||
explicit Section(Type t = Type::Null, QString value = "") : t(t), value(std::move(value)) {}
|
bool operator>=(const Version& other) const;
|
||||||
Type t;
|
bool operator==(const Version& other) const;
|
||||||
QString value;
|
bool operator!=(const Version& other) const;
|
||||||
bool operator==(const Section& other) const = default;
|
|
||||||
std::strong_ordering operator<=>(const Section& other) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
|
||||||
void parse();
|
|
||||||
|
|
||||||
public:
|
|
||||||
QString toString() const { return m_string; }
|
QString toString() const { return m_string; }
|
||||||
bool isEmpty() const { return m_string.isEmpty(); }
|
bool isEmpty() const { return m_string.isEmpty(); }
|
||||||
|
|
||||||
friend QDebug operator<<(QDebug debug, const Version& v);
|
friend QDebug operator<<(QDebug debug, const Version& v);
|
||||||
|
|
||||||
bool operator==(const Version& other) const { return (*this <=> other) == std::strong_ordering::equal; }
|
private:
|
||||||
std::strong_ordering operator<=>(const Version& other) const;
|
struct Section {
|
||||||
|
explicit Section(QString fullString) : m_fullString(std::move(fullString))
|
||||||
|
{
|
||||||
|
qsizetype cutoff = m_fullString.size();
|
||||||
|
for (int i = 0; i < m_fullString.size(); i++) {
|
||||||
|
if (!m_fullString[i].isDigit()) {
|
||||||
|
cutoff = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto numPart = QStringView{ m_fullString }.left(cutoff);
|
||||||
|
|
||||||
|
if (!numPart.isEmpty()) {
|
||||||
|
m_isNull = false;
|
||||||
|
m_numPart = numPart.toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto stringPart = QStringView{ m_fullString }.mid(cutoff);
|
||||||
|
|
||||||
|
if (!stringPart.isEmpty()) {
|
||||||
|
m_isNull = false;
|
||||||
|
m_stringPart = stringPart.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
explicit Section() = default;
|
||||||
|
|
||||||
|
bool m_isNull = true;
|
||||||
|
|
||||||
|
int m_numPart = 0;
|
||||||
|
QString m_stringPart;
|
||||||
|
|
||||||
|
QString m_fullString;
|
||||||
|
|
||||||
|
inline bool isAppendix() const { return m_stringPart.startsWith('+'); }
|
||||||
|
inline bool isPreRelease() const { return m_stringPart.startsWith('-') && m_stringPart.length() > 1; }
|
||||||
|
|
||||||
|
inline bool operator==(const Section& other) const
|
||||||
|
{
|
||||||
|
if (m_isNull && !other.m_isNull)
|
||||||
|
return false;
|
||||||
|
if (!m_isNull && other.m_isNull)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!m_isNull && !other.m_isNull) {
|
||||||
|
return (m_numPart == other.m_numPart) && (m_stringPart == other.m_stringPart);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator<(const Section& other) const
|
||||||
|
{
|
||||||
|
static auto unequal_is_less = [](Section const& non_null) -> bool {
|
||||||
|
if (non_null.m_stringPart.isEmpty())
|
||||||
|
return non_null.m_numPart == 0;
|
||||||
|
return (non_null.m_stringPart != QLatin1Char('.')) && non_null.isPreRelease();
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!m_isNull && other.m_isNull)
|
||||||
|
return unequal_is_less(*this);
|
||||||
|
if (m_isNull && !other.m_isNull)
|
||||||
|
return !unequal_is_less(other);
|
||||||
|
|
||||||
|
if (!m_isNull && !other.m_isNull) {
|
||||||
|
if (m_numPart < other.m_numPart)
|
||||||
|
return true;
|
||||||
|
if (m_numPart == other.m_numPart && m_stringPart < other.m_stringPart)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!m_stringPart.isEmpty() && other.m_stringPart.isEmpty())
|
||||||
|
return false;
|
||||||
|
if (m_stringPart.isEmpty() && !other.m_stringPart.isEmpty())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_fullString < other.m_fullString;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator!=(const Section& other) const { return !(*this == other); }
|
||||||
|
inline bool operator>(const Section& other) const { return !(*this < other || *this == other); }
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_string;
|
QString m_string;
|
||||||
QList<Section> m_sections;
|
QList<Section> m_sections;
|
||||||
|
|
||||||
|
void parse();
|
||||||
};
|
};
|
||||||
|
|
@ -198,9 +198,10 @@ QVariant VersionProxyModel::data(const QModelIndex& index, int role) const
|
||||||
return tr("Latest");
|
return tr("Latest");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
return sourceModel()->data(parentIndex, BaseVersionList::VersionIdRole);
|
return sourceModel()->data(parentIndex, BaseVersionList::VersionIdRole);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
case Qt::DecorationRole: {
|
case Qt::DecorationRole: {
|
||||||
if (column == Name && hasRecommended) {
|
if (column == Name && hasRecommended) {
|
||||||
auto recommenced = sourceModel()->data(parentIndex, BaseVersionList::RecommendedRole);
|
auto recommenced = sourceModel()->data(parentIndex, BaseVersionList::RecommendedRole);
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue