diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c0e5b50a..1ba5d0e4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,6 +15,9 @@ on: SPARKLE_ED25519_KEY: description: Private key for signing Sparkle updates required: false + CACHIX_AUTH_TOKEN: + description: Private token for authenticating against Cachix cache + required: false jobs: build: @@ -35,17 +38,11 @@ jobs: qt_tools: '' - os: windows-2022 - name: "Windows-Legacy" - msystem: clang32 - qt_ver: 5 - - - os: windows-2022 - name: "Windows" + name: "Windows-MinGW-w64" msystem: clang64 - qt_ver: 6 - os: windows-2022 - name: "Windows-Legacy-MSVC" + name: "Windows-MSVC-Legacy" msystem: '' architecture: 'win32' vcvars_arch: 'amd64_x86' @@ -64,7 +61,19 @@ jobs: qt_ver: 6 qt_host: windows qt_arch: '' - qt_version: '6.4.1' + qt_version: '6.4.0' + qt_modules: 'qt5compat qtimageformats' + qt_tools: '' + + - os: windows-2022 + name: "Windows-MSVC-arm64" + msystem: '' + architecture: 'arm64' + vcvars_arch: 'amd64_arm64' + qt_ver: 6 + qt_host: windows + qt_arch: 'win64_msvc2019_arm64' + qt_version: '6.4.0' qt_modules: 'qt5compat qtimageformats' qt_tools: '' @@ -120,12 +129,12 @@ jobs: cmake:p extra-cmake-modules:p ninja:p - qt${{ matrix.qt_ver }}-base:p - qt${{ matrix.qt_ver }}-svg:p - qt${{ matrix.qt_ver }}-imageformats:p - quazip-qt${{ matrix.qt_ver }}:p + qt6-base:p + qt6-svg:p + qt6-imageformats:p + quazip-qt6:p ccache:p - ${{ matrix.qt_ver == 6 && 'qt6-5compat:p' || '' }} + qt6-5compat:p - name: Force newer ccache if: runner.os == 'Windows' && matrix.msystem == '' && inputs.build_type == 'Debug' @@ -136,7 +145,7 @@ jobs: if: (runner.os != 'Windows' || matrix.msystem == '') && inputs.build_type == 'Debug' uses: hendrikmuhs/ccache-action@v1.2.5 with: - key: ${{ matrix.os }}-qt${{ matrix.qt_ver }} + key: ${{ matrix.os }}-qt${{ matrix.qt_ver }}-${{ matrix.architecture }} - name: Setup ccache (Windows MinGW-w64) if: runner.os == 'Windows' && matrix.msystem != '' && inputs.build_type == 'Debug' @@ -159,9 +168,9 @@ jobs: uses: actions/cache@v3.0.11 with: path: '${{ github.workspace }}\.ccache' - key: ${{ matrix.os }}-qt${{ matrix.qt_ver }} + key: ${{ matrix.os }}-mingw-w64 restore-keys: | - ${{ matrix.os }}-qt${{ matrix.qt_ver }} + ${{ matrix.os }}-mingw-w64 - name: Set short version shell: bash @@ -185,8 +194,23 @@ jobs: if: runner.os == 'Linux' && matrix.qt_ver != 6 run: | sudo apt-get -y install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libqt5core5a libqt5network5 libqt5gui5 - - - name: Install Qt (macOS, AppImage & Windows MSVC) + + - name: Install host Qt (Windows MSVC arm64) + if: runner.os == 'Windows' && matrix.architecture == 'arm64' + uses: jurplel/install-qt-action@v3 + with: + version: ${{ matrix.qt_version }} + host: 'windows' + target: 'desktop' + arch: '' + modules: ${{ matrix.qt_modules }} + tools: ${{ matrix.qt_tools }} + cache: ${{ inputs.is_qt_cached }} + cache-key-prefix: host-qt-arm64-windows + dir: ${{ github.workspace }}\HostQt + set-env: false + + - name: Install Qt (macOS, Linux, Qt 6 & Windows MSVC) if: runner.os == 'Linux' && matrix.qt_ver == 6 || runner.os == 'macOS' || (runner.os == 'Windows' && matrix.msystem == '') uses: jurplel/install-qt-action@v3 with: @@ -198,6 +222,13 @@ jobs: tools: ${{ matrix.qt_tools }} cache: ${{ inputs.is_qt_cached }} + - name: Install MSVC (Windows MSVC) + if: runner.os == 'Windows' && matrix.msystem == '' + uses: ilammy/msvc-dev-cmd@v1 + with: + vsversion: 2022 + arch: ${{ matrix.vcvars_arch }} + - name: Prepare AppImage (Linux) if: runner.os == 'Linux' && matrix.qt_ver != 5 run: | @@ -207,6 +238,11 @@ jobs: ${{ github.workspace }}/.github/scripts/prepare_JREs.sh + - name: Add QT_HOST_PATH var (Windows MSVC arm64) + if: runner.os == 'Windows' && matrix.architecture == 'arm64' + run: | + echo "QT_HOST_PATH=${{ github.workspace }}\HostQt\Qt\${{ matrix.qt_version }}\msvc2019_64" >> $env:GITHUB_ENV + ## # CONFIGURE ## @@ -225,12 +261,12 @@ jobs: if: runner.os == 'Windows' && matrix.msystem != '' shell: msys2 {0} run: | - cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_BUILD_PLATFORM=${{ matrix.name }} -DCMAKE_C_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -DCMAKE_CXX_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -DLauncher_QT_VERSION_MAJOR=${{ matrix.qt_ver }} -DCMAKE_OBJDUMP=/mingw64/bin/objdump.exe -G Ninja + cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_BUILD_PLATFORM=${{ matrix.name }} -DCMAKE_C_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -DCMAKE_CXX_COMPILER_LAUNCHER=${{ env.CCACHE_VAR }} -DLauncher_QT_VERSION_MAJOR=6 -DCMAKE_OBJDUMP=/mingw64/bin/objdump.exe -G Ninja - name: Configure CMake (Windows MSVC) if: runner.os == 'Windows' && matrix.msystem == '' run: | - cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_BUILD_PLATFORM=${{ matrix.name }} -DLauncher_QT_VERSION_MAJOR=${{ matrix.qt_ver }} -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreadedDLL" -A${{ matrix.architecture}} + cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_BUILD_PLATFORM=${{ matrix.name }} -DLauncher_QT_VERSION_MAJOR=${{ matrix.qt_ver }} -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreadedDLL" -A${{ matrix.architecture}} -DLauncher_FORCE_BUNDLED_LIBS=ON # https://github.com/ccache/ccache/wiki/MS-Visual-Studio (I coudn't figure out the compiler prefix) if ("${{ env.CCACHE_VAR }}") { @@ -283,7 +319,7 @@ jobs: ctest -E "^example64|example$" --test-dir build --output-on-failure - name: Test (Windows MSVC) - if: runner.os == 'Windows' && matrix.msystem == '' + if: runner.os == 'Windows' && matrix.msystem == '' && matrix.architecture != 'arm64' run: | ctest -E "^example64|example$" --test-dir build --output-on-failure -C ${{ inputs.build_type }} @@ -321,23 +357,12 @@ jobs: EOF fi - - name: Add VC Enviroment Variables - if: runner.os == 'Windows' && matrix.msystem == '' - uses: ilammy/msvc-dev-cmd@v1 - with: - arch: ${{ matrix.vcvars_arch }} - - name: Package (Windows MinGW-w64) if: runner.os == 'Windows' && matrix.msystem != '' shell: msys2 {0} run: | cmake --install ${{ env.BUILD_DIR }} - cd ${{ env.INSTALL_DIR }} - if [ "${{ matrix.qt_ver }}" == "5" ]; then - cp /clang32/bin/libcrypto-1_1.dll /clang32/bin/libssl-1_1.dll ./ - fi - - name: Package (Windows MSVC) if: runner.os == 'Windows' && matrix.msystem == '' run: | @@ -526,3 +551,33 @@ jobs: bundle: "Prism Launcher.flatpak" manifest-path: flatpak/org.prismlauncher.PrismLauncher.yml cache-key: flatpak-${{ github.sha }}-x86_64 + + nix: + runs-on: ubuntu-latest + strategy: + matrix: + package: + - prismlauncher + - prismlauncher-qt5 + steps: + - name: Clone repository + if: inputs.build_type == 'Debug' + uses: actions/checkout@v3 + with: + submodules: 'true' + - name: Install nix + if: inputs.build_type == 'Debug' + uses: cachix/install-nix-action@v18 + with: + install_url: https://nixos.org/nix/install + extra_nix_config: | + auto-optimise-store = true + experimental-features = nix-command flakes + - uses: cachix/cachix-action@v12 + if: inputs.build_type == 'Debug' + with: + name: prismlauncher + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - name: Build + if: inputs.build_type == 'Debug' + run: nix build .#${{ matrix.package }} --print-build-logs diff --git a/.github/workflows/trigger_builds.yml b/.github/workflows/trigger_builds.yml index 44751fbc..a08193a0 100644 --- a/.github/workflows/trigger_builds.yml +++ b/.github/workflows/trigger_builds.yml @@ -8,7 +8,6 @@ on: - '**.md' - '**/LICENSE' - 'flake.lock' - - '**.nix' - 'packages/**' - '.github/ISSUE_TEMPLATE/**' - '.markdownlint**' @@ -17,7 +16,6 @@ on: - '**.md' - '**/LICENSE' - 'flake.lock' - - '**.nix' - 'packages/**' - '.github/ISSUE_TEMPLATE/**' - '.markdownlint**' @@ -33,3 +31,4 @@ jobs: is_qt_cached: true secrets: SPARKLE_ED25519_KEY: ${{ secrets.SPARKLE_ED25519_KEY }} + CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }} diff --git a/.github/workflows/trigger_release.yml b/.github/workflows/trigger_release.yml index 8baa9693..a2f89819 100644 --- a/.github/workflows/trigger_release.yml +++ b/.github/workflows/trigger_release.yml @@ -46,15 +46,26 @@ jobs: tar -czf PrismLauncher-${{ env.VERSION }}.tar.gz PrismLauncher-${{ env.VERSION }} - for d in PrismLauncher-Windows-*; do + for d in PrismLauncher-Windows-MSVC*; do cd "${d}" || continue - MSVC="$(echo -n ${d} | grep -o MSVC || true)" LEGACY="$(echo -n ${d} | grep -o Legacy || true)" + ARM64="$(echo -n ${d} | grep -o arm64 || true)" INST="$(echo -n ${d} | grep -o Setup || true)" PORT="$(echo -n ${d} | grep -o Portable || true)" - NAME="PrismLauncher-Windows" - test -z "${MSVC}" && NAME="${NAME}-MinGW" || NAME="${NAME}-MSVC" + NAME="PrismLauncher-Windows-MSVC" test -z "${LEGACY}" || NAME="${NAME}-Legacy" + test -z "${ARM64}" || NAME="${NAME}-arm64" + test -z "${PORT}" || NAME="${NAME}-Portable" + test -z "${INST}" || mv PrismLauncher-*.exe ../${NAME}-Setup-${{ env.VERSION }}.exe + test -n "${INST}" || zip -r -9 "../${NAME}-${{ env.VERSION }}.zip" * + cd .. + done + + for d in PrismLauncher-Windows-MinGW-w64*; do + cd "${d}" || continue + INST="$(echo -n ${d} | grep -o Setup || true)" + PORT="$(echo -n ${d} | grep -o Portable || true)" + NAME="PrismLauncher-Windows-MinGW-w64" test -z "${PORT}" || NAME="${NAME}-Portable" test -z "${INST}" || mv PrismLauncher-*.exe ../${NAME}-Setup-${{ env.VERSION }}.exe test -n "${INST}" || zip -r -9 "../${NAME}-${{ env.VERSION }}.zip" * @@ -77,15 +88,15 @@ jobs: PrismLauncher-Linux-${{ env.VERSION }}-x86_64.AppImage PrismLauncher-Linux-Qt6-${{ env.VERSION }}.tar.gz PrismLauncher-Linux-Qt6-Portable-${{ env.VERSION }}.tar.gz - PrismLauncher-Windows-MinGW-Legacy-${{ env.VERSION }}.zip - PrismLauncher-Windows-MinGW-Legacy-Portable-${{ env.VERSION }}.zip - PrismLauncher-Windows-MinGW-Legacy-Setup-${{ env.VERSION }}.exe - PrismLauncher-Windows-MinGW-${{ env.VERSION }}.zip - PrismLauncher-Windows-MinGW-Portable-${{ env.VERSION }}.zip - PrismLauncher-Windows-MinGW-Setup-${{ env.VERSION }}.exe + PrismLauncher-Windows-MinGW-w64-${{ env.VERSION }}.zip + PrismLauncher-Windows-MinGW-w64-Portable-${{ env.VERSION }}.zip + PrismLauncher-Windows-MinGW-w64-Setup-${{ env.VERSION }}.exe PrismLauncher-Windows-MSVC-Legacy-${{ env.VERSION }}.zip PrismLauncher-Windows-MSVC-Legacy-Portable-${{ env.VERSION }}.zip PrismLauncher-Windows-MSVC-Legacy-Setup-${{ env.VERSION }}.exe + PrismLauncher-Windows-MSVC-arm64-${{ env.VERSION }}.zip + PrismLauncher-Windows-MSVC-arm64-Portable-${{ env.VERSION }}.zip + PrismLauncher-Windows-MSVC-arm64-Setup-${{ env.VERSION }}.exe PrismLauncher-Windows-MSVC-${{ env.VERSION }}.zip PrismLauncher-Windows-MSVC-Portable-${{ env.VERSION }}.zip PrismLauncher-Windows-MSVC-Setup-${{ env.VERSION }}.exe diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fc0d326..2bdd4811 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -221,7 +221,7 @@ if(Launcher_QT_VERSION_MAJOR EQUAL 5) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUNICODE -D_UNICODE") elseif(Launcher_QT_VERSION_MAJOR EQUAL 6) set(QT_VERSION_MAJOR 6) - find_package(Qt6 REQUIRED COMPONENTS Core Widgets Concurrent Network Test Xml Core5Compat) + find_package(Qt6 REQUIRED COMPONENTS Core CoreTools Widgets Concurrent Network Test Xml Core5Compat) list(APPEND Launcher_QT_LIBS Qt6::Core5Compat) if(NOT Launcher_FORCE_BUNDLED_LIBS) @@ -235,12 +235,16 @@ else() message(FATAL_ERROR "Qt version ${Launcher_QT_VERSION_MAJOR} is not supported") endif() -include(ECMQueryQt) -ecm_query_qt(QT_PLUGINS_DIR QT_INSTALL_PLUGINS) -ecm_query_qt(QT_LIBS_DIR QT_INSTALL_LIBS) -ecm_query_qt(QT_LIBEXECS_DIR QT_INSTALL_LIBEXECS) -ecm_query_qt(QT_DATA_DIR QT_HOST_DATA) -set(QT_MKSPECS_DIR ${QT_DATA_DIR}/mkspecs) +if(Launcher_QT_VERSION_MAJOR EQUAL 5) + include(ECMQueryQt) + ecm_query_qt(QT_PLUGINS_DIR QT_INSTALL_PLUGINS) + ecm_query_qt(QT_LIBS_DIR QT_INSTALL_LIBS) + ecm_query_qt(QT_LIBEXECS_DIR QT_INSTALL_LIBEXECS) +else() + set(QT_PLUGINS_DIR ${QT${QT_VERSION_MAJOR}_INSTALL_PREFIX}/${QT${QT_VERSION_MAJOR}_INSTALL_PLUGINS}) + set(QT_LIBS_DIR ${QT${QT_VERSION_MAJOR}_INSTALL_PREFIX}/${QT${QT_VERSION_MAJOR}_INSTALL_LIBS}) + set(QT_LIBEXECS_DIR ${QT${QT_VERSION_MAJOR}_INSTALL_PREFIX}/${QT${QT_VERSION_MAJOR}_INSTALL_LIBEXECS}) +endif() # NOTE: Qt 6 already sets this by default if (Qt5_POSITION_INDEPENDENT_CODE) @@ -368,11 +372,11 @@ if(NOT ZLIB_FOUND) set(SKIP_INSTALL_ALL ON) add_subdirectory(libraries/zlib EXCLUDE_FROM_ALL) - set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libraries/zlib" "${CMAKE_CURRENT_BINARY_DIR}/libraries/zlib") + set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libraries/zlib" "${CMAKE_CURRENT_BINARY_DIR}/libraries/zlib" CACHE STRING "") set_target_properties(zlibstatic PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${ZLIB_INCLUDE_DIR}") add_library(ZLIB::ZLIB ALIAS zlibstatic) - set(ZLIB_LIBRARY ZLIB::ZLIB) - set(ZLIB_FOUND true) + set(ZLIB_LIBRARY ZLIB::ZLIB CACHE STRING "zlib library name") + find_package(ZLIB REQUIRED) else() message(STATUS "Using system zlib") diff --git a/flake.nix b/flake.nix index d4a25338..b1e07c91 100644 --- a/flake.nix +++ b/flake.nix @@ -23,8 +23,8 @@ pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system}); packagesFn = pkgs: rec { - prismlauncher = pkgs.libsForQt5.callPackage ./nix { inherit version self libnbtplusplus tomlplusplus; }; - prismlauncher-qt6 = pkgs.qt6Packages.callPackage ./nix { inherit version self libnbtplusplus tomlplusplus; }; + prismlauncher-qt5 = pkgs.libsForQt5.callPackage ./nix { inherit version self libnbtplusplus tomlplusplus; }; + prismlauncher = pkgs.qt6Packages.callPackage ./nix { inherit version self libnbtplusplus tomlplusplus; }; }; in { diff --git a/launcher/Application.cpp b/launcher/Application.cpp index ea8d2326..4ba9eb9b 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -915,13 +915,13 @@ bool Application::createSetupWizard() return false; } -bool Application::event(QEvent* event) { +bool Application::event(QEvent* event) +{ #ifdef Q_OS_MACOS if (event->type() == QEvent::ApplicationStateChange) { auto ev = static_cast(event); - if (m_prevAppState == Qt::ApplicationActive - && ev->applicationState() == Qt::ApplicationActive) { + if (m_prevAppState == Qt::ApplicationActive && ev->applicationState() == Qt::ApplicationActive) { emit clickedOnDock(); } m_prevAppState = ev->applicationState(); diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index e8afa6b8..3eb765dc 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -796,6 +796,8 @@ SET(LAUNCHER_SOURCES ui/dialogs/ExportInstanceDialog.h ui/dialogs/IconPickerDialog.cpp ui/dialogs/IconPickerDialog.h + ui/dialogs/ImportResourcePackDialog.cpp + ui/dialogs/ImportResourcePackDialog.h ui/dialogs/LoginDialog.cpp ui/dialogs/LoginDialog.h ui/dialogs/MSALoginDialog.cpp @@ -944,6 +946,7 @@ qt_wrap_ui(LAUNCHER_UI ui/dialogs/SkinUploadDialog.ui ui/dialogs/ExportInstanceDialog.ui ui/dialogs/IconPickerDialog.ui + ui/dialogs/ImportResourcePackDialog.ui ui/dialogs/MSALoginDialog.ui ui/dialogs/OfflineLoginDialog.ui ui/dialogs/AboutDialog.ui diff --git a/launcher/FileSystem.cpp b/launcher/FileSystem.cpp index 987f4e74..1da50e21 100644 --- a/launcher/FileSystem.cpp +++ b/launcher/FileSystem.cpp @@ -49,6 +49,7 @@ #include "StringUtils.h" #if defined Q_OS_WIN32 +#define WIN32_LEAN_AND_MEAN #include #include #include @@ -343,12 +344,37 @@ QString getDesktopDir() } // Cross-platform Shortcut creation -bool createShortCut(QString location, QString dest, QStringList args, QString name, QString icon) +bool createShortcut(QString destination, QString target, QStringList args, QString name, QString icon) { -#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) - location = PathCombine(location, name + ".desktop"); +#if defined(Q_OS_MACOS) + destination += ".command"; - QFile f(location); + QFile f(destination); + f.open(QIODevice::WriteOnly | QIODevice::Text); + QTextStream stream(&f); + + QString argstring; + if (!args.empty()) + argstring = " \"" + args.join("\" \"") + "\""; + + stream << "#!/bin/bash" + << "\n"; + stream << "\"" + << target + << "\" " + << argstring + << "\n"; + + stream.flush(); + f.close(); + + f.setPermissions(f.permissions() | QFileDevice::ExeOwner | QFileDevice::ExeGroup | QFileDevice::ExeOther); + + return true; +#elif defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD) + destination += ".desktop"; + + QFile f(destination); f.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream stream(&f); @@ -360,10 +386,12 @@ bool createShortCut(QString location, QString dest, QStringList args, QString na << "\n"; stream << "Type=Application" << "\n"; - stream << "TryExec=" << dest.toLocal8Bit() << "\n"; - stream << "Exec=" << dest.toLocal8Bit() << argstring.toLocal8Bit() << "\n"; + stream << "Exec=\"" << target.toLocal8Bit() << "\"" << argstring.toLocal8Bit() << "\n"; stream << "Name=" << name.toLocal8Bit() << "\n"; - stream << "Icon=" << icon.toLocal8Bit() << "\n"; + if (!icon.isEmpty()) + { + stream << "Icon=" << icon.toLocal8Bit() << "\n"; + } stream.flush(); f.close(); @@ -371,25 +399,132 @@ bool createShortCut(QString location, QString dest, QStringList args, QString na f.setPermissions(f.permissions() | QFileDevice::ExeOwner | QFileDevice::ExeGroup | QFileDevice::ExeOther); return true; -#elif defined Q_OS_WIN - // TODO: Fix - // QFile file(PathCombine(location, name + ".lnk")); - // WCHAR *file_w; - // WCHAR *dest_w; - // WCHAR *args_w; - // file.fileName().toWCharArray(file_w); - // dest.toWCharArray(dest_w); +#elif defined(Q_OS_WIN) + QFileInfo targetInfo(target); - // QString argStr; - // for (int i = 0; i < args.count(); i++) - // { - // argStr.append(args[i]); - // argStr.append(" "); - // } - // argStr.toWCharArray(args_w); + if (!targetInfo.exists()) + { + qWarning() << "Target file does not exist!"; + return false; + } - // return SUCCEEDED(CreateLink(file_w, dest_w, args_w)); - return false; + target = targetInfo.absoluteFilePath(); + + if (target.length() >= MAX_PATH) + { + qWarning() << "Target file path is too long!"; + return false; + } + + if (!icon.isEmpty() && icon.length() >= MAX_PATH) + { + qWarning() << "Icon path is too long!"; + return false; + } + + destination += ".lnk"; + + if (destination.length() >= MAX_PATH) + { + qWarning() << "Destination path is too long!"; + return false; + } + + QString argStr; + int argCount = args.count(); + for (int i = 0; i < argCount; i++) + { + if (args[i].contains(' ')) + { + argStr.append('"').append(args[i]).append('"'); + } + else + { + argStr.append(args[i]); + } + + if (i < argCount - 1) + { + argStr.append(" "); + } + } + + if (argStr.length() >= MAX_PATH) + { + qWarning() << "Arguments string is too long!"; + return false; + } + + HRESULT hres; + + // ...yes, you need to initialize the entire COM stack just to make a shortcut + hres = CoInitialize(nullptr); + if (FAILED(hres)) + { + qWarning() << "Failed to initialize COM!"; + return false; + } + + WCHAR wsz[MAX_PATH]; + + IShellLink* psl; + + // create an IShellLink instance - this stores the shortcut's attributes + hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl); + if (SUCCEEDED(hres)) + { + wmemset(wsz, 0, MAX_PATH); + target.toWCharArray(wsz); + psl->SetPath(wsz); + + wmemset(wsz, 0, MAX_PATH); + argStr.toWCharArray(wsz); + psl->SetArguments(wsz); + + wmemset(wsz, 0, MAX_PATH); + targetInfo.absolutePath().toWCharArray(wsz); + psl->SetWorkingDirectory(wsz); // "Starts in" attribute + + if (!icon.isEmpty()) + { + wmemset(wsz, 0, MAX_PATH); + icon.toWCharArray(wsz); + psl->SetIconLocation(wsz, 0); + } + + // query an IPersistFile interface from our IShellLink instance + // this is the interface that will actually let us save the shortcut to disk! + IPersistFile* ppf; + hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf); + if (SUCCEEDED(hres)) + { + wmemset(wsz, 0, MAX_PATH); + destination.toWCharArray(wsz); + hres = ppf->Save(wsz, TRUE); + if (FAILED(hres)) + { + qWarning() << "IPresistFile->Save() failed"; + qWarning() << "hres = " << hres; + } + ppf->Release(); + } + else + { + qWarning() << "Failed to query IPersistFile interface from IShellLink instance"; + qWarning() << "hres = " << hres; + } + psl->Release(); + } + else + { + qWarning() << "Failed to create IShellLink instance"; + qWarning() << "hres = " << hres; + } + + // go away COM, nobody likes you + CoUninitialize(); + + return SUCCEEDED(hres); #else qWarning("Desktop Shortcuts not supported on your platform!"); return false; diff --git a/launcher/FileSystem.h b/launcher/FileSystem.h index a9a81123..ac893725 100644 --- a/launcher/FileSystem.h +++ b/launcher/FileSystem.h @@ -172,4 +172,9 @@ QString getDesktopDir(); // Overrides one folder with the contents of another, preserving items exclusive to the first folder // Equivalent to doing QDir::rename, but allowing for overrides bool overrideFolder(QString overwritten_path, QString override_path); + +/** + * Creates a shortcut to the specified target file at the specified destination path. + */ +bool createShortcut(QString destination, QString target, QStringList args, QString name, QString icon); } diff --git a/launcher/InstanceCreationTask.cpp b/launcher/InstanceCreationTask.cpp index 3971effa..73dc1789 100644 --- a/launcher/InstanceCreationTask.cpp +++ b/launcher/InstanceCreationTask.cpp @@ -25,9 +25,13 @@ void InstanceCreationTask::executeTask() return; qWarning() << "Instance creation failed!"; - if (!m_error_message.isEmpty()) + if (!m_error_message.isEmpty()) { qWarning() << "Reason: " << m_error_message; - emitFailed(tr("Error while creating new instance.")); + emitFailed(tr("Error while creating new instance:\n%1").arg(m_error_message)); + } else { + emitFailed(tr("Error while creating new instance.")); + } + return; } diff --git a/launcher/InstanceImportTask.cpp b/launcher/InstanceImportTask.cpp index b490620d..5f459649 100644 --- a/launcher/InstanceImportTask.cpp +++ b/launcher/InstanceImportTask.cpp @@ -164,18 +164,14 @@ void InstanceImportTask::processZipPack() } else { - QString mmcRoot = MMCZip::findFolderOfFileInZip(m_packZip.get(), "instance.cfg"); - QString flameRoot = MMCZip::findFolderOfFileInZip(m_packZip.get(), "manifest.json"); + QStringList paths_to_ignore { "overrides/" }; - if (!mmcRoot.isNull()) - { + if (QString mmcRoot = MMCZip::findFolderOfFileInZip(m_packZip.get(), "instance.cfg", paths_to_ignore); !mmcRoot.isNull()) { // process as MultiMC instance/pack qDebug() << "MultiMC:" << mmcRoot; root = mmcRoot; m_modpackType = ModpackType::MultiMC; - } - else if(!flameRoot.isNull()) - { + } else if (QString flameRoot = MMCZip::findFolderOfFileInZip(m_packZip.get(), "manifest.json", paths_to_ignore); !flameRoot.isNull()) { // process as Flame pack qDebug() << "Flame:" << flameRoot; root = flameRoot; diff --git a/launcher/MMCZip.cpp b/launcher/MMCZip.cpp index 9f4e968f..f6600343 100644 --- a/launcher/MMCZip.cpp +++ b/launcher/MMCZip.cpp @@ -39,6 +39,7 @@ #include "MMCZip.h" #include "FileSystem.h" +#include #include // ours @@ -228,23 +229,27 @@ bool MMCZip::createModdedJar(QString sourceJarPath, QString targetJarPath, const } // ours -QString MMCZip::findFolderOfFileInZip(QuaZip * zip, const QString & what, const QString &root) +QString MMCZip::findFolderOfFileInZip(QuaZip* zip, const QString& what, const QStringList& ignore_paths, const QString& root) { QuaZipDir rootDir(zip, root); - for(auto fileName: rootDir.entryList(QDir::Files)) - { - if(fileName == what) + for (auto&& fileName : rootDir.entryList(QDir::Files)) { + if (fileName == what) return root; + + QCoreApplication::processEvents(); } - for(auto fileName: rootDir.entryList(QDir::Dirs)) - { - QString result = findFolderOfFileInZip(zip, what, root + fileName); - if(!result.isEmpty()) - { + + // Recurse the search to non-ignored subfolders + for (auto&& fileName : rootDir.entryList(QDir::Dirs)) { + if (ignore_paths.contains(fileName)) + continue; + + QString result = findFolderOfFileInZip(zip, what, ignore_paths, root + fileName); + if (!result.isEmpty()) return result; - } } - return QString(); + + return {}; } // ours diff --git a/launcher/MMCZip.h b/launcher/MMCZip.h index ce9775bd..81f9cb90 100644 --- a/launcher/MMCZip.h +++ b/launcher/MMCZip.h @@ -80,9 +80,11 @@ namespace MMCZip /** * Find a single file in archive by file name (not path) * + * \param ignore_paths paths to skip when recursing the search + * * \return the path prefix where the file is */ - QString findFolderOfFileInZip(QuaZip * zip, const QString & what, const QString &root = QString("")); + QString findFolderOfFileInZip(QuaZip * zip, const QString & what, const QStringList& ignore_paths = {}, const QString &root = QString("")); /** * Find a multiple files of the same name in archive by file name diff --git a/launcher/minecraft/Agent.h b/launcher/minecraft/Agent.h index 01109daf..374e6e94 100644 --- a/launcher/minecraft/Agent.h +++ b/launcher/minecraft/Agent.h @@ -10,7 +10,7 @@ typedef std::shared_ptr AgentPtr; class Agent { public: - Agent(LibraryPtr library, QString &argument) + Agent(LibraryPtr library, const QString &argument) { m_library = library; m_argument = argument; diff --git a/launcher/minecraft/MinecraftInstance.cpp b/launcher/minecraft/MinecraftInstance.cpp index 70d0b949..a3adb268 100644 --- a/launcher/minecraft/MinecraftInstance.cpp +++ b/launcher/minecraft/MinecraftInstance.cpp @@ -1110,8 +1110,6 @@ std::shared_ptr MinecraftInstance::resourcePackList() c if (!m_resource_pack_list) { m_resource_pack_list.reset(new ResourcePackFolderModel(resourcePacksDir())); - m_resource_pack_list->enableInteraction(!isRunning()); - connect(this, &BaseInstance::runningStatusChanged, m_resource_pack_list.get(), &ResourcePackFolderModel::disableInteraction); } return m_resource_pack_list; } @@ -1121,8 +1119,6 @@ std::shared_ptr MinecraftInstance::texturePackList() con if (!m_texture_pack_list) { m_texture_pack_list.reset(new TexturePackFolderModel(texturePacksDir())); - m_texture_pack_list->disableInteraction(isRunning()); - connect(this, &BaseInstance::runningStatusChanged, m_texture_pack_list.get(), &ModFolderModel::disableInteraction); } return m_texture_pack_list; } @@ -1132,8 +1128,6 @@ std::shared_ptr MinecraftInstance::shaderPackList() const if (!m_shader_pack_list) { m_shader_pack_list.reset(new ShaderPackFolderModel(shaderPacksDir())); - m_shader_pack_list->disableInteraction(isRunning()); - connect(this, &BaseInstance::runningStatusChanged, m_shader_pack_list.get(), &ModFolderModel::disableInteraction); } return m_shader_pack_list; } diff --git a/launcher/minecraft/PackProfile.cpp b/launcher/minecraft/PackProfile.cpp index 6ce525eb..43fa3f8d 100644 --- a/launcher/minecraft/PackProfile.cpp +++ b/launcher/minecraft/PackProfile.cpp @@ -1,7 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-only /* - * PolyMC - Minecraft Launcher + * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 Sefa Eyeoglu + * Copyright (C) 2022 TheKodeToad * * 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 @@ -47,7 +48,6 @@ #include "Exception.h" #include "minecraft/OneSixVersionFormat.h" #include "FileSystem.h" -#include "meta/Index.h" #include "minecraft/MinecraftInstance.h" #include "Json.h" @@ -55,7 +55,6 @@ #include "PackProfile_p.h" #include "ComponentUpdateTask.h" -#include "Application.h" #include "modplatform/ModAPI.h" static const QMap modloaderMapping{ @@ -738,6 +737,11 @@ void PackProfile::installCustomJar(QString selectedFile) installCustomJar_internal(selectedFile); } +void PackProfile::installAgents(QStringList selectedFiles) +{ + installAgents_internal(selectedFiles); +} + bool PackProfile::installEmpty(const QString& uid, const QString& name) { QString patchDir = FS::PathCombine(d->m_instance->instanceRoot(), "patches"); @@ -832,18 +836,14 @@ bool PackProfile::installJarMods_internal(QStringList filepaths) for(auto filepath:filepaths) { QFileInfo sourceInfo(filepath); - auto uuid = QUuid::createUuid(); - QString id = uuid.toString().remove('{').remove('}'); + QString id = QUuid::createUuid().toString(QUuid::WithoutBraces); QString target_filename = id + ".jar"; - QString target_id = "org.multimc.jarmod." + id; + QString target_id = "custom.jarmod." + id; QString target_name = sourceInfo.completeBaseName() + " (jar mod)"; QString finalPath = FS::PathCombine(d->m_instance->jarModsDir(), target_filename); QFileInfo targetInfo(finalPath); - if(targetInfo.exists()) - { - return false; - } + Q_ASSERT(!targetInfo.exists()); if (!QFile::copy(sourceInfo.absoluteFilePath(),QFileInfo(finalPath).absoluteFilePath())) { @@ -852,7 +852,7 @@ bool PackProfile::installJarMods_internal(QStringList filepaths) auto f = std::make_shared(); auto jarMod = std::make_shared(); - jarMod->setRawName(GradleSpecifier("org.multimc.jarmods:" + id + ":1")); + jarMod->setRawName(GradleSpecifier("custom.jarmods:" + id + ":1")); jarMod->setFilename(target_filename); jarMod->setDisplayName(sourceInfo.completeBaseName()); jarMod->setHint("local"); @@ -892,7 +892,7 @@ bool PackProfile::installCustomJar_internal(QString filepath) return false; } - auto specifier = GradleSpecifier("org.multimc:customjar:1"); + auto specifier = GradleSpecifier("custom:customjar:1"); QFileInfo sourceInfo(filepath); QString target_filename = specifier.getFileName(); QString target_id = specifier.artifactId(); @@ -939,6 +939,64 @@ bool PackProfile::installCustomJar_internal(QString filepath) return true; } +bool PackProfile::installAgents_internal(QStringList filepaths) +{ + // FIXME code duplication + const QString patchDir = FS::PathCombine(d->m_instance->instanceRoot(), "patches"); + if (!FS::ensureFolderPathExists(patchDir)) + return false; + + const QString libDir = d->m_instance->getLocalLibraryPath(); + if (!FS::ensureFolderPathExists(libDir)) + return false; + + for (const QString& source : filepaths) { + const QFileInfo sourceInfo(source); + const QString id = QUuid::createUuid().toString(QUuid::WithoutBraces); + const QString targetBaseName = id + ".jar"; + const QString targetId = "custom.agent." + id; + const QString targetName = sourceInfo.completeBaseName() + " (agent)"; + const QString target = FS::PathCombine(d->m_instance->getLocalLibraryPath(), targetBaseName); + + const QFileInfo targetInfo(target); + Q_ASSERT(!targetInfo.exists()); + + if (!QFile::copy(source, target)) + return false; + + auto versionFile = std::make_shared(); + + auto agent = std::make_shared(); + + agent->setRawName("custom.agents:" + id + ":1"); + agent->setFilename(targetBaseName); + agent->setDisplayName(sourceInfo.completeBaseName()); + agent->setHint("local"); + + versionFile->agents.append(std::make_shared(agent, QString())); + + versionFile->name = targetName; + versionFile->uid = targetId; + + QFile patchFile(FS::PathCombine(patchDir, targetId + ".json")); + + if (!patchFile.open(QFile::WriteOnly)) { + qCritical() << "Error opening" << patchFile.fileName() << "for reading:" << patchFile.errorString(); + return false; + } + + patchFile.write(OneSixVersionFormat::versionFileToJson(versionFile).toJson()); + patchFile.close(); + + appendComponent(new Component(this, versionFile->uid, versionFile)); + } + + scheduleSave(); + invalidateLaunchProfile(); + + return true; +} + std::shared_ptr PackProfile::getProfile() const { if(!d->m_profile) diff --git a/launcher/minecraft/PackProfile.h b/launcher/minecraft/PackProfile.h index 807511a2..2330cca1 100644 --- a/launcher/minecraft/PackProfile.h +++ b/launcher/minecraft/PackProfile.h @@ -1,7 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-only /* - * PolyMC - Minecraft Launcher + * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 Sefa Eyeoglu + * Copyright (C) 2022 TheKodeToad * * 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 @@ -85,6 +86,9 @@ public: /// install a jar/zip as a replacement for the main jar void installCustomJar(QString selectedFile); + /// install Java agent files + void installAgents(QStringList selectedFiles); + enum MoveDirection { MoveUp, MoveDown }; /// move component file # up or down the list void move(const int index, const MoveDirection direction); @@ -167,6 +171,7 @@ private: bool load(); bool installJarMods_internal(QStringList filepaths); bool installCustomJar_internal(QString filepath); + bool installAgents_internal(QStringList filepaths); bool removeComponent_internal(ComponentPtr patch); private: /* data */ diff --git a/launcher/minecraft/mod/ResourcePack.cpp b/launcher/minecraft/mod/ResourcePack.cpp index 3fc10a2f..4a9ad21b 100644 --- a/launcher/minecraft/mod/ResourcePack.cpp +++ b/launcher/minecraft/mod/ResourcePack.cpp @@ -15,7 +15,7 @@ static const QMap> s_pack_format_versions = { { 3, { Version("1.11"), Version("1.12.2") } }, { 4, { Version("1.13"), Version("1.14.4") } }, { 5, { Version("1.15"), Version("1.16.1") } }, { 6, { Version("1.16.2"), Version("1.16.5") } }, { 7, { Version("1.17"), Version("1.17.1") } }, { 8, { Version("1.18"), Version("1.18.2") } }, - { 9, { Version("1.19"), Version("1.19.2") } }, + { 9, { Version("1.19"), Version("1.19.2") } }, { 11, { Version("1.19.3"), Version("1.19.3") } }, }; void ResourcePack::setPackFormat(int new_format_id) @@ -114,3 +114,8 @@ bool ResourcePack::applyFilter(QRegularExpression filter) const return Resource::applyFilter(filter); } + +bool ResourcePack::valid() const +{ + return m_pack_format != 0; +} diff --git a/launcher/minecraft/mod/ResourcePack.h b/launcher/minecraft/mod/ResourcePack.h index 03121908..7cb414d8 100644 --- a/launcher/minecraft/mod/ResourcePack.h +++ b/launcher/minecraft/mod/ResourcePack.h @@ -42,6 +42,8 @@ class ResourcePack : public Resource { /** Thread-safe. */ void setImage(QImage new_image); + bool valid() const override; + [[nodiscard]] auto compare(Resource const& other, SortType type) const -> std::pair override; [[nodiscard]] bool applyFilter(QRegularExpression filter) const override; diff --git a/launcher/minecraft/mod/TexturePack.cpp b/launcher/minecraft/mod/TexturePack.cpp index 796eb69d..99d55584 100644 --- a/launcher/minecraft/mod/TexturePack.cpp +++ b/launcher/minecraft/mod/TexturePack.cpp @@ -62,3 +62,8 @@ QPixmap TexturePack::image(QSize size) TexturePackUtils::process(*this); return image(size); } + +bool TexturePack::valid() const +{ + return m_description != nullptr; +} diff --git a/launcher/minecraft/mod/TexturePack.h b/launcher/minecraft/mod/TexturePack.h index 6aa5e18e..81bd5c69 100644 --- a/launcher/minecraft/mod/TexturePack.h +++ b/launcher/minecraft/mod/TexturePack.h @@ -48,6 +48,8 @@ class TexturePack : public Resource { /** Thread-safe. */ void setImage(QImage new_image); + bool valid() const override; + protected: mutable QMutex m_data_lock; diff --git a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp index 4f87bc13..6fd4b024 100644 --- a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp +++ b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.cpp @@ -28,14 +28,14 @@ namespace ResourcePackUtils { -bool process(ResourcePack& pack) +bool process(ResourcePack& pack, ProcessingLevel level) { switch (pack.type()) { case ResourceType::FOLDER: - ResourcePackUtils::processFolder(pack); + ResourcePackUtils::processFolder(pack, level); return true; case ResourceType::ZIPFILE: - ResourcePackUtils::processZIP(pack); + ResourcePackUtils::processZIP(pack, level); return true; default: qWarning() << "Invalid type for resource pack parse task!"; @@ -43,7 +43,7 @@ bool process(ResourcePack& pack) } } -void processFolder(ResourcePack& pack) +void processFolder(ResourcePack& pack, ProcessingLevel level) { Q_ASSERT(pack.type() == ResourceType::FOLDER); @@ -60,6 +60,9 @@ void processFolder(ResourcePack& pack) mcmeta_file.close(); } + if (level == ProcessingLevel::BasicInfoOnly) + return; + QFileInfo image_file_info(FS::PathCombine(pack.fileinfo().filePath(), "pack.png")); if (image_file_info.isFile()) { QFile mcmeta_file(image_file_info.filePath()); @@ -74,7 +77,7 @@ void processFolder(ResourcePack& pack) } } -void processZIP(ResourcePack& pack) +void processZIP(ResourcePack& pack, ProcessingLevel level) { Q_ASSERT(pack.type() == ResourceType::ZIPFILE); @@ -98,6 +101,11 @@ void processZIP(ResourcePack& pack) file.close(); } + if (level == ProcessingLevel::BasicInfoOnly) { + zip.close(); + return; + } + if (zip.setCurrentFile("pack.png")) { if (!file.open(QIODevice::ReadOnly)) { qCritical() << "Failed to open file in zip."; @@ -138,6 +146,13 @@ void processPackPNG(ResourcePack& pack, QByteArray&& raw_data) qWarning() << "Failed to parse pack.png."; } } + +bool validate(QFileInfo file) +{ + ResourcePack rp{ file }; + return ResourcePackUtils::process(rp, ProcessingLevel::BasicInfoOnly) && rp.valid(); +} + } // namespace ResourcePackUtils LocalResourcePackParseTask::LocalResourcePackParseTask(int token, ResourcePack& rp) @@ -152,8 +167,6 @@ bool LocalResourcePackParseTask::abort() void LocalResourcePackParseTask::executeTask() { - Q_ASSERT(m_resource_pack.valid()); - if (!ResourcePackUtils::process(m_resource_pack)) return; diff --git a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.h b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.h index d3c25464..69dbd6ad 100644 --- a/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.h +++ b/launcher/minecraft/mod/tasks/LocalResourcePackParseTask.h @@ -26,13 +26,19 @@ #include "tasks/Task.h" namespace ResourcePackUtils { -bool process(ResourcePack& pack); -void processZIP(ResourcePack& pack); -void processFolder(ResourcePack& pack); +enum class ProcessingLevel { Full, BasicInfoOnly }; + +bool process(ResourcePack& pack, ProcessingLevel level = ProcessingLevel::Full); + +void processZIP(ResourcePack& pack, ProcessingLevel level = ProcessingLevel::Full); +void processFolder(ResourcePack& pack, ProcessingLevel level = ProcessingLevel::Full); void processMCMeta(ResourcePack& pack, QByteArray&& raw_data); void processPackPNG(ResourcePack& pack, QByteArray&& raw_data); + +/** Checks whether a file is valid as a resource pack or not. */ +bool validate(QFileInfo file); } // namespace ResourcePackUtils class LocalResourcePackParseTask : public Task { diff --git a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp index bf1e308f..adb19aca 100644 --- a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp +++ b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.cpp @@ -28,14 +28,14 @@ namespace TexturePackUtils { -bool process(TexturePack& pack) +bool process(TexturePack& pack, ProcessingLevel level) { switch (pack.type()) { case ResourceType::FOLDER: - TexturePackUtils::processFolder(pack); + TexturePackUtils::processFolder(pack, level); return true; case ResourceType::ZIPFILE: - TexturePackUtils::processZIP(pack); + TexturePackUtils::processZIP(pack, level); return true; default: qWarning() << "Invalid type for resource pack parse task!"; @@ -43,7 +43,7 @@ bool process(TexturePack& pack) } } -void processFolder(TexturePack& pack) +void processFolder(TexturePack& pack, ProcessingLevel level) { Q_ASSERT(pack.type() == ResourceType::FOLDER); @@ -60,6 +60,9 @@ void processFolder(TexturePack& pack) mcmeta_file.close(); } + if (level == ProcessingLevel::BasicInfoOnly) + return; + QFileInfo image_file_info(FS::PathCombine(pack.fileinfo().filePath(), "pack.png")); if (image_file_info.isFile()) { QFile mcmeta_file(image_file_info.filePath()); @@ -74,7 +77,7 @@ void processFolder(TexturePack& pack) } } -void processZIP(TexturePack& pack) +void processZIP(TexturePack& pack, ProcessingLevel level) { Q_ASSERT(pack.type() == ResourceType::ZIPFILE); @@ -98,6 +101,11 @@ void processZIP(TexturePack& pack) file.close(); } + if (level == ProcessingLevel::BasicInfoOnly) { + zip.close(); + return; + } + if (zip.setCurrentFile("pack.png")) { if (!file.open(QIODevice::ReadOnly)) { qCritical() << "Failed to open file in zip."; @@ -129,6 +137,13 @@ void processPackPNG(TexturePack& pack, QByteArray&& raw_data) qWarning() << "Failed to parse pack.png."; } } + +bool validate(QFileInfo file) +{ + TexturePack rp{ file }; + return TexturePackUtils::process(rp, ProcessingLevel::BasicInfoOnly) && rp.valid(); +} + } // namespace TexturePackUtils LocalTexturePackParseTask::LocalTexturePackParseTask(int token, TexturePack& rp) @@ -143,8 +158,6 @@ bool LocalTexturePackParseTask::abort() void LocalTexturePackParseTask::executeTask() { - Q_ASSERT(m_texture_pack.valid()); - if (!TexturePackUtils::process(m_texture_pack)) return; diff --git a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.h b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.h index cb0e404a..9f7aab75 100644 --- a/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.h +++ b/launcher/minecraft/mod/tasks/LocalTexturePackParseTask.h @@ -27,13 +27,19 @@ #include "tasks/Task.h" namespace TexturePackUtils { -bool process(TexturePack& pack); -void processZIP(TexturePack& pack); -void processFolder(TexturePack& pack); +enum class ProcessingLevel { Full, BasicInfoOnly }; + +bool process(TexturePack& pack, ProcessingLevel level = ProcessingLevel::Full); + +void processZIP(TexturePack& pack, ProcessingLevel level = ProcessingLevel::Full); +void processFolder(TexturePack& pack, ProcessingLevel level = ProcessingLevel::Full); void processPackTXT(TexturePack& pack, QByteArray&& raw_data); void processPackPNG(TexturePack& pack, QByteArray&& raw_data); + +/** Checks whether a file is valid as a texture pack or not. */ +bool validate(QFileInfo file); } // namespace TexturePackUtils class LocalTexturePackParseTask : public Task { diff --git a/launcher/modplatform/flame/FileResolvingTask.cpp b/launcher/modplatform/flame/FileResolvingTask.cpp index 25b56fbd..7f1beb1a 100644 --- a/launcher/modplatform/flame/FileResolvingTask.cpp +++ b/launcher/modplatform/flame/FileResolvingTask.cpp @@ -42,12 +42,25 @@ void Flame::FileResolvingTask::executeTask() void Flame::FileResolvingTask::netJobFinished() { setProgress(1, 3); - int index = 0; // job to check modrinth for blocked projects m_checkJob = new NetJob("Modrinth check", m_network); blockedProjects = QMap(); - auto doc = Json::requireDocument(*result); - auto array = Json::requireArray(doc.object()["data"]); + + QJsonDocument doc; + QJsonArray array; + + try { + doc = Json::requireDocument(*result); + array = Json::requireArray(doc.object()["data"]); + } catch (Json::JsonException& e) { + qCritical() << "Non-JSON data returned from the CF API"; + qCritical() << e.cause(); + + emitFailed(tr("Invalid data returned from the API.")); + + return; + } + for (QJsonValueRef file : array) { auto fileid = Json::requireInteger(Json::requireObject(file)["id"]); auto& out = m_toProcess.files[fileid]; @@ -68,7 +81,6 @@ void Flame::FileResolvingTask::netJobFinished() blockedProjects.insert(&out, output); } } - index++; } connect(m_checkJob.get(), &NetJob::finished, this, &Flame::FileResolvingTask::modrinthCheckFinished); diff --git a/launcher/modplatform/flame/FlameInstanceCreationTask.cpp b/launcher/modplatform/flame/FlameInstanceCreationTask.cpp index 91554b58..a00c948a 100644 --- a/launcher/modplatform/flame/FlameInstanceCreationTask.cpp +++ b/launcher/modplatform/flame/FlameInstanceCreationTask.cpp @@ -338,6 +338,7 @@ bool FlameCreationTask::createInstance() connect(m_mod_id_resolver.get(), &Flame::FileResolvingTask::failed, [&](QString reason) { m_mod_id_resolver.reset(); setError(tr("Unable to resolve mod IDs:\n") + reason); + loop.quit(); }); connect(m_mod_id_resolver.get(), &Flame::FileResolvingTask::progress, this, &FlameCreationTask::setProgress); connect(m_mod_id_resolver.get(), &Flame::FileResolvingTask::status, this, &FlameCreationTask::setStatus); diff --git a/launcher/resources/OSX/OSX.qrc b/launcher/resources/OSX/OSX.qrc index 19fe312b..9d4511d1 100644 --- a/launcher/resources/OSX/OSX.qrc +++ b/launcher/resources/OSX/OSX.qrc @@ -39,5 +39,6 @@ scalable/export.svg scalable/rename.svg scalable/launch.svg + scalable/shortcut.svg diff --git a/launcher/resources/OSX/scalable/shortcut.svg b/launcher/resources/OSX/scalable/shortcut.svg new file mode 100644 index 00000000..a2b7488e --- /dev/null +++ b/launcher/resources/OSX/scalable/shortcut.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/launcher/resources/breeze_dark/breeze_dark.qrc b/launcher/resources/breeze_dark/breeze_dark.qrc index 4d7a69b2..97434abc 100644 --- a/launcher/resources/breeze_dark/breeze_dark.qrc +++ b/launcher/resources/breeze_dark/breeze_dark.qrc @@ -27,6 +27,7 @@ scalable/refresh.svg scalable/resourcepacks.svg scalable/shaderpacks.svg + scalable/shortcut.svg scalable/screenshots.svg scalable/settings.svg scalable/status-bad.svg diff --git a/launcher/resources/breeze_dark/scalable/shortcut.svg b/launcher/resources/breeze_dark/scalable/shortcut.svg new file mode 100644 index 00000000..5559be1d --- /dev/null +++ b/launcher/resources/breeze_dark/scalable/shortcut.svg @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/launcher/resources/breeze_light/breeze_light.qrc b/launcher/resources/breeze_light/breeze_light.qrc index 7d9d99f5..6d868b18 100644 --- a/launcher/resources/breeze_light/breeze_light.qrc +++ b/launcher/resources/breeze_light/breeze_light.qrc @@ -27,6 +27,7 @@ scalable/refresh.svg scalable/resourcepacks.svg scalable/shaderpacks.svg + scalable/shortcut.svg scalable/screenshots.svg scalable/settings.svg scalable/status-bad.svg diff --git a/launcher/resources/breeze_light/scalable/shortcut.svg b/launcher/resources/breeze_light/scalable/shortcut.svg new file mode 100644 index 00000000..426769d1 --- /dev/null +++ b/launcher/resources/breeze_light/scalable/shortcut.svg @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/launcher/resources/flat/flat.qrc b/launcher/resources/flat/flat.qrc index 508e0a9f..a846bd2d 100644 --- a/launcher/resources/flat/flat.qrc +++ b/launcher/resources/flat/flat.qrc @@ -35,6 +35,7 @@ scalable/screenshot-placeholder.svg scalable/screenshots.svg scalable/settings.svg + scalable/shortcut.svg scalable/star.svg scalable/status-bad.svg scalable/status-good.svg diff --git a/launcher/resources/flat/scalable/shortcut.svg b/launcher/resources/flat/scalable/shortcut.svg new file mode 100644 index 00000000..83878d19 --- /dev/null +++ b/launcher/resources/flat/scalable/shortcut.svg @@ -0,0 +1,3 @@ + + + diff --git a/launcher/resources/flat_white/flat_white.qrc b/launcher/resources/flat_white/flat_white.qrc index e11d6316..b0759d8f 100644 --- a/launcher/resources/flat_white/flat_white.qrc +++ b/launcher/resources/flat_white/flat_white.qrc @@ -35,6 +35,7 @@ scalable/screenshot-placeholder.svg scalable/screenshots.svg scalable/settings.svg + scalable/shortcut.svg scalable/star.svg scalable/status-bad.svg scalable/status-good.svg diff --git a/launcher/resources/flat_white/scalable/shortcut.svg b/launcher/resources/flat_white/scalable/shortcut.svg new file mode 100644 index 00000000..b419a77d --- /dev/null +++ b/launcher/resources/flat_white/scalable/shortcut.svg @@ -0,0 +1,3 @@ + + + diff --git a/launcher/resources/iOS/iOS.qrc b/launcher/resources/iOS/iOS.qrc index aa08d811..0b79efb2 100644 --- a/launcher/resources/iOS/iOS.qrc +++ b/launcher/resources/iOS/iOS.qrc @@ -39,5 +39,6 @@ scalable/export.svg scalable/rename.svg scalable/launch.svg + scalable/shortcut.svg diff --git a/launcher/resources/iOS/scalable/shortcut.svg b/launcher/resources/iOS/scalable/shortcut.svg new file mode 100644 index 00000000..16e9fa48 --- /dev/null +++ b/launcher/resources/iOS/scalable/shortcut.svg @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/launcher/resources/multimc/128x128/instances/chicken.png b/launcher/resources/multimc/128x128/instances/chicken_legacy.png similarity index 100% rename from launcher/resources/multimc/128x128/instances/chicken.png rename to launcher/resources/multimc/128x128/instances/chicken_legacy.png diff --git a/launcher/resources/multimc/128x128/instances/creeper.png b/launcher/resources/multimc/128x128/instances/creeper_legacy.png similarity index 100% rename from launcher/resources/multimc/128x128/instances/creeper.png rename to launcher/resources/multimc/128x128/instances/creeper_legacy.png diff --git a/launcher/resources/multimc/128x128/instances/enderpearl.png b/launcher/resources/multimc/128x128/instances/enderpearl_legacy.png similarity index 100% rename from launcher/resources/multimc/128x128/instances/enderpearl.png rename to launcher/resources/multimc/128x128/instances/enderpearl_legacy.png diff --git a/launcher/resources/multimc/128x128/instances/flame.png b/launcher/resources/multimc/128x128/instances/flame_legacy.png similarity index 100% rename from launcher/resources/multimc/128x128/instances/flame.png rename to launcher/resources/multimc/128x128/instances/flame_legacy.png diff --git a/launcher/resources/multimc/128x128/instances/ftb_logo.png b/launcher/resources/multimc/128x128/instances/ftb_logo_legacy.png similarity index 100% rename from launcher/resources/multimc/128x128/instances/ftb_logo.png rename to launcher/resources/multimc/128x128/instances/ftb_logo_legacy.png diff --git a/launcher/resources/multimc/128x128/instances/gear.png b/launcher/resources/multimc/128x128/instances/gear_legacy.png similarity index 100% rename from launcher/resources/multimc/128x128/instances/gear.png rename to launcher/resources/multimc/128x128/instances/gear_legacy.png diff --git a/launcher/resources/multimc/128x128/instances/herobrine.png b/launcher/resources/multimc/128x128/instances/herobrine_legacy.png similarity index 100% rename from launcher/resources/multimc/128x128/instances/herobrine.png rename to launcher/resources/multimc/128x128/instances/herobrine_legacy.png diff --git a/launcher/resources/multimc/128x128/instances/infinity.png b/launcher/resources/multimc/128x128/instances/infinity_legacy.png similarity index 100% rename from launcher/resources/multimc/128x128/instances/infinity.png rename to launcher/resources/multimc/128x128/instances/infinity_legacy.png diff --git a/launcher/resources/multimc/128x128/instances/magitech.png b/launcher/resources/multimc/128x128/instances/magitech_legacy.png similarity index 100% rename from launcher/resources/multimc/128x128/instances/magitech.png rename to launcher/resources/multimc/128x128/instances/magitech_legacy.png diff --git a/launcher/resources/multimc/128x128/instances/meat.png b/launcher/resources/multimc/128x128/instances/meat_legacy.png similarity index 100% rename from launcher/resources/multimc/128x128/instances/meat.png rename to launcher/resources/multimc/128x128/instances/meat_legacy.png diff --git a/launcher/resources/multimc/128x128/instances/netherstar.png b/launcher/resources/multimc/128x128/instances/netherstar_legacy.png similarity index 100% rename from launcher/resources/multimc/128x128/instances/netherstar.png rename to launcher/resources/multimc/128x128/instances/netherstar_legacy.png diff --git a/launcher/resources/multimc/128x128/instances/skeleton.png b/launcher/resources/multimc/128x128/instances/skeleton_legacy.png similarity index 100% rename from launcher/resources/multimc/128x128/instances/skeleton.png rename to launcher/resources/multimc/128x128/instances/skeleton_legacy.png diff --git a/launcher/resources/multimc/128x128/instances/squarecreeper.png b/launcher/resources/multimc/128x128/instances/squarecreeper_legacy.png similarity index 100% rename from launcher/resources/multimc/128x128/instances/squarecreeper.png rename to launcher/resources/multimc/128x128/instances/squarecreeper_legacy.png diff --git a/launcher/resources/multimc/128x128/instances/steve.png b/launcher/resources/multimc/128x128/instances/steve_legacy.png similarity index 100% rename from launcher/resources/multimc/128x128/instances/steve.png rename to launcher/resources/multimc/128x128/instances/steve_legacy.png diff --git a/launcher/resources/multimc/32x32/instances/brick.png b/launcher/resources/multimc/32x32/instances/brick_legacy.png similarity index 100% rename from launcher/resources/multimc/32x32/instances/brick.png rename to launcher/resources/multimc/32x32/instances/brick_legacy.png diff --git a/launcher/resources/multimc/32x32/instances/chicken.png b/launcher/resources/multimc/32x32/instances/chicken_legacy.png similarity index 100% rename from launcher/resources/multimc/32x32/instances/chicken.png rename to launcher/resources/multimc/32x32/instances/chicken_legacy.png diff --git a/launcher/resources/multimc/32x32/instances/creeper.png b/launcher/resources/multimc/32x32/instances/creeper_legacy.png similarity index 100% rename from launcher/resources/multimc/32x32/instances/creeper.png rename to launcher/resources/multimc/32x32/instances/creeper_legacy.png diff --git a/launcher/resources/multimc/32x32/instances/diamond.png b/launcher/resources/multimc/32x32/instances/diamond_legacy.png similarity index 100% rename from launcher/resources/multimc/32x32/instances/diamond.png rename to launcher/resources/multimc/32x32/instances/diamond_legacy.png diff --git a/launcher/resources/multimc/32x32/instances/dirt.png b/launcher/resources/multimc/32x32/instances/dirt_legacy.png similarity index 100% rename from launcher/resources/multimc/32x32/instances/dirt.png rename to launcher/resources/multimc/32x32/instances/dirt_legacy.png diff --git a/launcher/resources/multimc/32x32/instances/enderpearl.png b/launcher/resources/multimc/32x32/instances/enderpearl_legacy.png similarity index 100% rename from launcher/resources/multimc/32x32/instances/enderpearl.png rename to launcher/resources/multimc/32x32/instances/enderpearl_legacy.png diff --git a/launcher/resources/multimc/32x32/instances/ftb_logo.png b/launcher/resources/multimc/32x32/instances/ftb_logo_legacy.png similarity index 100% rename from launcher/resources/multimc/32x32/instances/ftb_logo.png rename to launcher/resources/multimc/32x32/instances/ftb_logo_legacy.png diff --git a/launcher/resources/multimc/32x32/instances/gear.png b/launcher/resources/multimc/32x32/instances/gear_legacy.png similarity index 100% rename from launcher/resources/multimc/32x32/instances/gear.png rename to launcher/resources/multimc/32x32/instances/gear_legacy.png diff --git a/launcher/resources/multimc/32x32/instances/gold.png b/launcher/resources/multimc/32x32/instances/gold_legacy.png similarity index 100% rename from launcher/resources/multimc/32x32/instances/gold.png rename to launcher/resources/multimc/32x32/instances/gold_legacy.png diff --git a/launcher/resources/multimc/32x32/instances/grass.png b/launcher/resources/multimc/32x32/instances/grass_legacy.png similarity index 100% rename from launcher/resources/multimc/32x32/instances/grass.png rename to launcher/resources/multimc/32x32/instances/grass_legacy.png diff --git a/launcher/resources/multimc/32x32/instances/herobrine.png b/launcher/resources/multimc/32x32/instances/herobrine_legacy.png similarity index 100% rename from launcher/resources/multimc/32x32/instances/herobrine.png rename to launcher/resources/multimc/32x32/instances/herobrine_legacy.png diff --git a/launcher/resources/multimc/32x32/instances/infinity.png b/launcher/resources/multimc/32x32/instances/infinity_legacy.png similarity index 100% rename from launcher/resources/multimc/32x32/instances/infinity.png rename to launcher/resources/multimc/32x32/instances/infinity_legacy.png diff --git a/launcher/resources/multimc/32x32/instances/iron.png b/launcher/resources/multimc/32x32/instances/iron_legacy.png similarity index 100% rename from launcher/resources/multimc/32x32/instances/iron.png rename to launcher/resources/multimc/32x32/instances/iron_legacy.png diff --git a/launcher/resources/multimc/32x32/instances/magitech.png b/launcher/resources/multimc/32x32/instances/magitech_legacy.png similarity index 100% rename from launcher/resources/multimc/32x32/instances/magitech.png rename to launcher/resources/multimc/32x32/instances/magitech_legacy.png diff --git a/launcher/resources/multimc/32x32/instances/meat.png b/launcher/resources/multimc/32x32/instances/meat_legacy.png similarity index 100% rename from launcher/resources/multimc/32x32/instances/meat.png rename to launcher/resources/multimc/32x32/instances/meat_legacy.png diff --git a/launcher/resources/multimc/32x32/instances/netherstar.png b/launcher/resources/multimc/32x32/instances/netherstar_legacy.png similarity index 100% rename from launcher/resources/multimc/32x32/instances/netherstar.png rename to launcher/resources/multimc/32x32/instances/netherstar_legacy.png diff --git a/launcher/resources/multimc/32x32/instances/planks.png b/launcher/resources/multimc/32x32/instances/planks_legacy.png similarity index 100% rename from launcher/resources/multimc/32x32/instances/planks.png rename to launcher/resources/multimc/32x32/instances/planks_legacy.png diff --git a/launcher/resources/multimc/32x32/instances/skeleton.png b/launcher/resources/multimc/32x32/instances/skeleton_legacy.png similarity index 100% rename from launcher/resources/multimc/32x32/instances/skeleton.png rename to launcher/resources/multimc/32x32/instances/skeleton_legacy.png diff --git a/launcher/resources/multimc/32x32/instances/squarecreeper.png b/launcher/resources/multimc/32x32/instances/squarecreeper_legacy.png similarity index 100% rename from launcher/resources/multimc/32x32/instances/squarecreeper.png rename to launcher/resources/multimc/32x32/instances/squarecreeper_legacy.png diff --git a/launcher/resources/multimc/32x32/instances/steve.png b/launcher/resources/multimc/32x32/instances/steve_legacy.png similarity index 100% rename from launcher/resources/multimc/32x32/instances/steve.png rename to launcher/resources/multimc/32x32/instances/steve_legacy.png diff --git a/launcher/resources/multimc/32x32/instances/stone.png b/launcher/resources/multimc/32x32/instances/stone_legacy.png similarity index 100% rename from launcher/resources/multimc/32x32/instances/stone.png rename to launcher/resources/multimc/32x32/instances/stone_legacy.png diff --git a/launcher/resources/multimc/32x32/instances/tnt.png b/launcher/resources/multimc/32x32/instances/tnt_legacy.png similarity index 100% rename from launcher/resources/multimc/32x32/instances/tnt.png rename to launcher/resources/multimc/32x32/instances/tnt_legacy.png diff --git a/launcher/resources/multimc/50x50/instances/enderman.png b/launcher/resources/multimc/50x50/instances/enderman_legacy.png similarity index 100% rename from launcher/resources/multimc/50x50/instances/enderman.png rename to launcher/resources/multimc/50x50/instances/enderman_legacy.png diff --git a/launcher/resources/multimc/multimc.qrc b/launcher/resources/multimc/multimc.qrc index 3f3d22fc..42b496da 100644 --- a/launcher/resources/multimc/multimc.qrc +++ b/launcher/resources/multimc/multimc.qrc @@ -6,9 +6,6 @@ scalable/reddit-alien.svg - - 128x128/instances/flame.png - scalable/launcher.svg @@ -254,63 +251,100 @@ scalable/discord.svg + + scalable/instances/flame.svg + scalable/instances/chicken.svg + scalable/instances/creeper.svg + scalable/instances/enderpearl.svg + scalable/instances/ftb_logo.svg + scalable/instances/flame.svg + scalable/instances/gear.svg + scalable/instances/herobrine.svg + scalable/instances/magitech.svg + scalable/instances/meat.svg + scalable/instances/netherstar.svg + scalable/instances/skeleton.svg + scalable/instances/squarecreeper.svg + scalable/instances/steve.svg + scalable/instances/diamond.svg + scalable/instances/dirt.svg + scalable/instances/grass.svg + scalable/instances/brick.svg + scalable/instances/gold.svg + scalable/instances/iron.svg + scalable/instances/planks.svg + scalable/instances/stone.svg + scalable/instances/tnt.svg + scalable/instances/enderman.svg + scalable/instances/fox.svg + scalable/instances/bee.svg + - 32x32/instances/chicken.png - 128x128/instances/chicken.png + 32x32/instances/chicken_legacy.png + 128x128/instances/chicken_legacy.png - 32x32/instances/creeper.png - 128x128/instances/creeper.png + 32x32/instances/creeper_legacy.png + 128x128/instances/creeper_legacy.png - 32x32/instances/enderpearl.png - 128x128/instances/enderpearl.png + 32x32/instances/enderpearl_legacy.png + 128x128/instances/enderpearl_legacy.png 32x32/instances/ftb_glow.png 128x128/instances/ftb_glow.png - 32x32/instances/ftb_logo.png - 128x128/instances/ftb_logo.png + 32x32/instances/ftb_logo_legacy.png + 128x128/instances/ftb_logo_legacy.png - 128x128/instances/flame.png + 128x128/instances/flame_legacy.png - 32x32/instances/gear.png - 128x128/instances/gear.png + 32x32/instances/gear_legacy.png + 128x128/instances/gear_legacy.png - 32x32/instances/herobrine.png - 128x128/instances/herobrine.png + 32x32/instances/herobrine_legacy.png + 128x128/instances/herobrine_legacy.png - 32x32/instances/magitech.png - 128x128/instances/magitech.png + 32x32/instances/magitech_legacy.png + 128x128/instances/magitech_legacy.png - 32x32/instances/meat.png - 128x128/instances/meat.png + 32x32/instances/meat_legacy.png + 128x128/instances/meat_legacy.png - 32x32/instances/netherstar.png - 128x128/instances/netherstar.png + 32x32/instances/netherstar_legacy.png + 128x128/instances/netherstar_legacy.png - 32x32/instances/skeleton.png - 128x128/instances/skeleton.png + 32x32/instances/skeleton_legacy.png + 128x128/instances/skeleton_legacy.png - 32x32/instances/squarecreeper.png - 128x128/instances/squarecreeper.png + 32x32/instances/squarecreeper_legacy.png + 128x128/instances/squarecreeper_legacy.png - 32x32/instances/steve.png - 128x128/instances/steve.png + 32x32/instances/steve_legacy.png + 128x128/instances/steve_legacy.png - 32x32/instances/brick.png - 32x32/instances/diamond.png - 32x32/instances/dirt.png - 32x32/instances/gold.png - 32x32/instances/grass.png - 32x32/instances/iron.png - 32x32/instances/planks.png - 32x32/instances/stone.png - 32x32/instances/tnt.png + 32x32/instances/brick_legacy.png + 32x32/instances/diamond_legacy.png + 32x32/instances/dirt_legacy.png + 32x32/instances/gold_legacy.png + 32x32/instances/grass_legacy.png + 32x32/instances/iron_legacy.png + 32x32/instances/planks_legacy.png + 32x32/instances/stone_legacy.png + 32x32/instances/tnt_legacy.png - 50x50/instances/enderman.png + 50x50/instances/enderman_legacy.png - scalable/instances/fox.svg - scalable/instances/bee.svg scalable/instances/prismlauncher.svg + scalable/instances/fox_legacy.svg + scalable/instances/bee_legacy.svg + + + scalable/delete.svg + scalable/tag.svg + scalable/rename.svg + scalable/shortcut.svg + + scalable/export.svg + scalable/launch.svg diff --git a/launcher/resources/multimc/scalable/delete.svg b/launcher/resources/multimc/scalable/delete.svg new file mode 100644 index 00000000..414cbd5c --- /dev/null +++ b/launcher/resources/multimc/scalable/delete.svg @@ -0,0 +1,282 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/multimc/scalable/export.svg b/launcher/resources/multimc/scalable/export.svg new file mode 100644 index 00000000..2605de14 --- /dev/null +++ b/launcher/resources/multimc/scalable/export.svg @@ -0,0 +1,466 @@ + + + + + + + + + + + unsorted + + + + + Open Clip Art Library, Source: Oxygen Icons, Source: Oxygen Icons, Source: Oxygen Icons, Source: Oxygen Icons + + + + + + + + + + + + + + image/svg+xml + + + en + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/multimc/scalable/instances/bee.svg b/launcher/resources/multimc/scalable/instances/bee.svg index 49f216c8..110b224c 100644 --- a/launcher/resources/multimc/scalable/instances/bee.svg +++ b/launcher/resources/multimc/scalable/instances/bee.svg @@ -1,159 +1,136 @@ + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + viewBox="0 0 24 24" + id="svg168" + xml:space="preserve" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/">Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/bee_legacy.svg b/launcher/resources/multimc/scalable/instances/bee_legacy.svg new file mode 100644 index 00000000..49f216c8 --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/bee_legacy.svg @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/multimc/scalable/instances/brick.svg b/launcher/resources/multimc/scalable/instances/brick.svg new file mode 100644 index 00000000..b600eba8 --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/brick.svg @@ -0,0 +1,67 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/chicken.svg b/launcher/resources/multimc/scalable/instances/chicken.svg new file mode 100644 index 00000000..0b5bf017 --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/chicken.svg @@ -0,0 +1,130 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/creeper.svg b/launcher/resources/multimc/scalable/instances/creeper.svg new file mode 100644 index 00000000..4a9fe380 --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/creeper.svg @@ -0,0 +1,68 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/diamond.svg b/launcher/resources/multimc/scalable/instances/diamond.svg new file mode 100644 index 00000000..1d490b91 --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/diamond.svg @@ -0,0 +1,62 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/dirt.svg b/launcher/resources/multimc/scalable/instances/dirt.svg new file mode 100644 index 00000000..df28ae92 --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/dirt.svg @@ -0,0 +1,52 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/enderman.svg b/launcher/resources/multimc/scalable/instances/enderman.svg new file mode 100644 index 00000000..29f25a2f --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/enderman.svg @@ -0,0 +1,96 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/enderpearl.svg b/launcher/resources/multimc/scalable/instances/enderpearl.svg new file mode 100644 index 00000000..e4c1e104 --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/enderpearl.svg @@ -0,0 +1,95 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/flame.svg b/launcher/resources/multimc/scalable/instances/flame.svg new file mode 100644 index 00000000..775914b8 --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/flame.svg @@ -0,0 +1,49 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/fox.svg b/launcher/resources/multimc/scalable/instances/fox.svg index fcf16b2f..95ca6ef9 100644 --- a/launcher/resources/multimc/scalable/instances/fox.svg +++ b/launcher/resources/multimc/scalable/instances/fox.svg @@ -1,290 +1,151 @@ + + - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + viewBox="0 0 24 24" + id="svg168" + xml:space="preserve" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/">Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/fox_legacy.svg b/launcher/resources/multimc/scalable/instances/fox_legacy.svg new file mode 100644 index 00000000..fcf16b2f --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/fox_legacy.svg @@ -0,0 +1,290 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/multimc/scalable/instances/ftb_logo.svg b/launcher/resources/multimc/scalable/instances/ftb_logo.svg new file mode 100644 index 00000000..85e8295e --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/ftb_logo.svg @@ -0,0 +1,82 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/gear.svg b/launcher/resources/multimc/scalable/instances/gear.svg new file mode 100644 index 00000000..b2923d67 --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/gear.svg @@ -0,0 +1,68 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/gold.svg b/launcher/resources/multimc/scalable/instances/gold.svg new file mode 100644 index 00000000..f1513d70 --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/gold.svg @@ -0,0 +1,63 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/grass.svg b/launcher/resources/multimc/scalable/instances/grass.svg new file mode 100644 index 00000000..cd29fd83 --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/grass.svg @@ -0,0 +1,84 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/herobrine.svg b/launcher/resources/multimc/scalable/instances/herobrine.svg new file mode 100644 index 00000000..24f4d2c9 --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/herobrine.svg @@ -0,0 +1,111 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/iron.svg b/launcher/resources/multimc/scalable/instances/iron.svg new file mode 100644 index 00000000..6a6faf77 --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/iron.svg @@ -0,0 +1,178 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/magitech.svg b/launcher/resources/multimc/scalable/instances/magitech.svg new file mode 100644 index 00000000..57ef6df1 --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/magitech.svg @@ -0,0 +1,85 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/meat.svg b/launcher/resources/multimc/scalable/instances/meat.svg new file mode 100644 index 00000000..36f0551b --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/meat.svg @@ -0,0 +1,121 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/modrinth.svg b/launcher/resources/multimc/scalable/instances/modrinth.svg index a40f0e72..7982b6d4 100644 --- a/launcher/resources/multimc/scalable/instances/modrinth.svg +++ b/launcher/resources/multimc/scalable/instances/modrinth.svg @@ -1,4 +1,70 @@ - - - - + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/netherstar.svg b/launcher/resources/multimc/scalable/instances/netherstar.svg new file mode 100644 index 00000000..a5d9606e --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/netherstar.svg @@ -0,0 +1,81 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/planks.svg b/launcher/resources/multimc/scalable/instances/planks.svg new file mode 100644 index 00000000..8febfa6b --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/planks.svg @@ -0,0 +1,93 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/skeleton.svg b/launcher/resources/multimc/scalable/instances/skeleton.svg new file mode 100644 index 00000000..ca9e8dd4 --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/skeleton.svg @@ -0,0 +1,134 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/squarecreeper.svg b/launcher/resources/multimc/scalable/instances/squarecreeper.svg new file mode 100644 index 00000000..ddb9aec8 --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/squarecreeper.svg @@ -0,0 +1,81 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/steve.svg b/launcher/resources/multimc/scalable/instances/steve.svg new file mode 100644 index 00000000..9b6d2595 --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/steve.svg @@ -0,0 +1,154 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/stone.svg b/launcher/resources/multimc/scalable/instances/stone.svg new file mode 100644 index 00000000..6df534d2 --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/stone.svg @@ -0,0 +1,55 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/instances/tnt.svg b/launcher/resources/multimc/scalable/instances/tnt.svg new file mode 100644 index 00000000..e876eba3 --- /dev/null +++ b/launcher/resources/multimc/scalable/instances/tnt.svg @@ -0,0 +1,126 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher diff --git a/launcher/resources/multimc/scalable/launch.svg b/launcher/resources/multimc/scalable/launch.svg new file mode 100644 index 00000000..321647a0 --- /dev/null +++ b/launcher/resources/multimc/scalable/launch.svg @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/multimc/scalable/rename.svg b/launcher/resources/multimc/scalable/rename.svg new file mode 100644 index 00000000..a585e264 --- /dev/null +++ b/launcher/resources/multimc/scalable/rename.svg @@ -0,0 +1,437 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/multimc/scalable/shortcut.svg b/launcher/resources/multimc/scalable/shortcut.svg new file mode 100644 index 00000000..549c3724 --- /dev/null +++ b/launcher/resources/multimc/scalable/shortcut.svg @@ -0,0 +1,157 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/launcher/resources/multimc/scalable/tag.svg b/launcher/resources/multimc/scalable/tag.svg new file mode 100644 index 00000000..81b5d545 --- /dev/null +++ b/launcher/resources/multimc/scalable/tag.svg @@ -0,0 +1,398 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/pe_blue/pe_blue.qrc b/launcher/resources/pe_blue/pe_blue.qrc index 3121ffe6..639675f0 100644 --- a/launcher/resources/pe_blue/pe_blue.qrc +++ b/launcher/resources/pe_blue/pe_blue.qrc @@ -39,5 +39,6 @@ scalable/export.svg scalable/rename.svg scalable/launch.svg + scalable/shortcut.svg diff --git a/launcher/resources/pe_blue/scalable/shortcut.svg b/launcher/resources/pe_blue/scalable/shortcut.svg new file mode 100644 index 00000000..45b73496 --- /dev/null +++ b/launcher/resources/pe_blue/scalable/shortcut.svg @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/pe_colored/pe_colored.qrc b/launcher/resources/pe_colored/pe_colored.qrc index ce5ad8e2..fac58da8 100644 --- a/launcher/resources/pe_colored/pe_colored.qrc +++ b/launcher/resources/pe_colored/pe_colored.qrc @@ -39,5 +39,6 @@ scalable/export.svg scalable/rename.svg scalable/launch.svg + scalable/shortcut.svg diff --git a/launcher/resources/pe_colored/scalable/shortcut.svg b/launcher/resources/pe_colored/scalable/shortcut.svg new file mode 100644 index 00000000..1469674f --- /dev/null +++ b/launcher/resources/pe_colored/scalable/shortcut.svg @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/launcher/resources/pe_dark/pe_dark.qrc b/launcher/resources/pe_dark/pe_dark.qrc index 156d8f8b..c0c6ee6c 100644 --- a/launcher/resources/pe_dark/pe_dark.qrc +++ b/launcher/resources/pe_dark/pe_dark.qrc @@ -39,5 +39,6 @@ scalable/export.svg scalable/rename.svg scalable/launch.svg + scalable/shortcut.svg diff --git a/launcher/resources/pe_dark/scalable/shortcut.svg b/launcher/resources/pe_dark/scalable/shortcut.svg new file mode 100644 index 00000000..29b45f26 --- /dev/null +++ b/launcher/resources/pe_dark/scalable/shortcut.svg @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/resources/pe_light/pe_light.qrc b/launcher/resources/pe_light/pe_light.qrc index d8e4a1bd..bd6a2496 100644 --- a/launcher/resources/pe_light/pe_light.qrc +++ b/launcher/resources/pe_light/pe_light.qrc @@ -39,5 +39,6 @@ scalable/export.svg scalable/rename.svg scalable/launch.svg + scalable/shortcut.svg diff --git a/launcher/resources/pe_light/scalable/shortcut.svg b/launcher/resources/pe_light/scalable/shortcut.svg new file mode 100644 index 00000000..4d232bcf --- /dev/null +++ b/launcher/resources/pe_light/scalable/shortcut.svg @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/launcher/ui/MainWindow.cpp b/launcher/ui/MainWindow.cpp index 929f2a85..b626bbae 100644 --- a/launcher/ui/MainWindow.cpp +++ b/launcher/ui/MainWindow.cpp @@ -39,6 +39,7 @@ #include "Application.h" #include "BuildConfig.h" +#include "FileSystem.h" #include "MainWindow.h" @@ -71,6 +72,7 @@ #include #include +#include #include #include #include @@ -106,8 +108,14 @@ #include "ui/dialogs/UpdateDialog.h" #include "ui/dialogs/EditAccountDialog.h" #include "ui/dialogs/ExportInstanceDialog.h" +#include "ui/dialogs/ImportResourcePackDialog.h" #include "ui/themes/ITheme.h" +#include +#include +#include +#include + #include "UpdateController.h" #include "KonamiCode.h" @@ -239,6 +247,7 @@ public: TranslatedAction actionLaunchInstanceOffline; TranslatedAction actionLaunchInstanceDemo; TranslatedAction actionExportInstance; + TranslatedAction actionCreateInstanceShortcut; QVector all_actions; LabeledToolButton *renameButton = nullptr; @@ -626,6 +635,7 @@ public: actionExportInstance->setEnabled(enabled); actionDeleteInstance->setEnabled(enabled); actionCopyInstance->setEnabled(enabled); + actionCreateInstanceShortcut->setEnabled(enabled); } void createStatusBar(QMainWindow *MainWindow) @@ -764,6 +774,15 @@ public: actionCopyInstance->setIcon(APPLICATION->getThemedIcon("copy")); all_actions.append(&actionCopyInstance); + actionCreateInstanceShortcut = TranslatedAction(MainWindow); + actionCreateInstanceShortcut->setObjectName(QStringLiteral("actionCreateInstanceShortcut")); + actionCreateInstanceShortcut.setTextId(QT_TRANSLATE_NOOP("MainWindow", "Create Shortcut")); + actionCreateInstanceShortcut.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Creates a shortcut on your desktop to launch the selected instance.")); + //actionCreateInstanceShortcut->setShortcut(QKeySequence(tr("Ctrl+D"))); // TODO + // FIXME missing on Legacy, Flat and Flat (White) + actionCreateInstanceShortcut->setIcon(APPLICATION->getThemedIcon("shortcut")); + all_actions.append(&actionCreateInstanceShortcut); + setInstanceActionsEnabled(false); } @@ -802,6 +821,8 @@ public: instanceToolBar->addAction(actionCopyInstance); instanceToolBar->addAction(actionDeleteInstance); + instanceToolBar->addAction(actionCreateInstanceShortcut); // TODO find better position for this + QLayout * lay = instanceToolBar->layout(); for(int i = 0; i < lay->count(); i++) { @@ -1794,17 +1815,41 @@ void MainWindow::on_actionAddInstance_triggered() void MainWindow::droppedURLs(QList urls) { - for(auto & url:urls) - { - if(url.isLocalFile()) - { - addInstance(url.toLocalFile()); - } - else - { + // NOTE: This loop only processes one dropped file! + for (auto& url : urls) { + // The isLocalFile() check below doesn't work as intended without an explicit scheme. + if (url.scheme().isEmpty()) + url.setScheme("file"); + + if (!url.isLocalFile()) { // probably instance/modpack addInstance(url.toString()); + break; } - // Only process one dropped file... + + auto localFileName = url.toLocalFile(); + QFileInfo localFileInfo(localFileName); + + bool isResourcePack = ResourcePackUtils::validate(localFileInfo); + bool isTexturePack = TexturePackUtils::validate(localFileInfo); + + if (!isResourcePack && !isTexturePack) { // probably instance/modpack + addInstance(localFileName); + break; + } + + ImportResourcePackDialog dlg(this); + + if (dlg.exec() != QDialog::Accepted) + break; + + qDebug() << "Adding resource/texture pack" << localFileName << "to" << dlg.selectedInstanceKey; + + auto inst = APPLICATION->instances()->getInstanceById(dlg.selectedInstanceKey); + auto minecraftInst = std::dynamic_pointer_cast(inst); + if (isResourcePack) + minecraftInst->resourcePackList()->installResource(localFileName); + else if (isTexturePack) + minecraftInst->texturePackList()->installResource(localFileName); break; } } @@ -2161,6 +2206,130 @@ void MainWindow::on_actionKillInstance_triggered() } } +void MainWindow::on_actionCreateInstanceShortcut_triggered() +{ + if (m_selectedInstance) + { + auto desktopPath = FS::getDesktopDir(); + if (desktopPath.isEmpty()) { + // TODO come up with an alternative solution (open "save file" dialog) + QMessageBox::critical(this, tr("Create instance shortcut"), tr("Couldn't find desktop?!")); + return; + } + +#if defined(Q_OS_MACOS) + QString appPath = QApplication::applicationFilePath(); + if (appPath.startsWith("/private/var/")) { + QMessageBox::critical(this, tr("Create instance shortcut"), tr("The launcher is in the folder it was extracted from, therefore it cannot create shortcuts.")); + return; + } + + if (FS::createShortcut(FS::PathCombine(desktopPath, m_selectedInstance->name()), + appPath, { "--launch", m_selectedInstance->id() }, + m_selectedInstance->name(), "")) { + QMessageBox::information(this, tr("Create instance shortcut"), tr("Created a shortcut to this instance on your desktop!")); + } + else + { + QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!")); + } +#elif defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD) + QString appPath = QApplication::applicationFilePath(); + if (appPath.startsWith("/tmp/.mount_")) { + // AppImage! + appPath = QProcessEnvironment::systemEnvironment().value(QStringLiteral("APPIMAGE")); + if (appPath.isEmpty()) + { + QMessageBox::critical(this, tr("Create instance shortcut"), tr("Launcher is running as misconfigured AppImage? ($APPIMAGE environment variable is missing)")); + } + else if (appPath.endsWith("/")) + { + appPath.chop(1); + } + } + + auto icon = APPLICATION->icons()->icon(m_selectedInstance->iconKey()); + if (icon == nullptr) + { + icon = APPLICATION->icons()->icon("grass"); + } + + QString iconPath = FS::PathCombine(m_selectedInstance->instanceRoot(), "icon.png"); + + QFile iconFile(iconPath); + if (!iconFile.open(QFile::WriteOnly)) + { + QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create icon for shortcut.")); + return; + } + bool success = icon->icon().pixmap(64, 64).save(&iconFile, "PNG"); + iconFile.close(); + + if (!success) + { + iconFile.remove(); + QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create icon for shortcut.")); + return; + } + + if (FS::createShortcut(FS::PathCombine(desktopPath, m_selectedInstance->name()), + appPath, { "--launch", m_selectedInstance->id() }, + m_selectedInstance->name(), iconPath)) { + QMessageBox::information(this, tr("Create instance shortcut"), tr("Created a shortcut to this instance on your desktop!")); + } + else + { + iconFile.remove(); + QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!")); + } +#elif defined(Q_OS_WIN) + auto icon = APPLICATION->icons()->icon(m_selectedInstance->iconKey()); + if (icon == nullptr) + { + icon = APPLICATION->icons()->icon("grass"); + } + + QString iconPath = FS::PathCombine(m_selectedInstance->instanceRoot(), "icon.ico"); + + // part of fix for weird bug involving the window icon being replaced + // dunno why it happens, but this 2-line fix seems to be enough, so w/e + auto appIcon = APPLICATION->getThemedIcon("logo"); + + QFile iconFile(iconPath); + if (!iconFile.open(QFile::WriteOnly)) + { + QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create icon for shortcut.")); + return; + } + bool success = icon->icon().pixmap(64, 64).save(&iconFile, "ICO"); + iconFile.close(); + + // restore original window icon + QGuiApplication::setWindowIcon(appIcon); + + if (!success) + { + iconFile.remove(); + QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create icon for shortcut.")); + return; + } + + if (FS::createShortcut(FS::PathCombine(desktopPath, m_selectedInstance->name()), + QApplication::applicationFilePath(), { "--launch", m_selectedInstance->id() }, + m_selectedInstance->name(), iconPath)) { + QMessageBox::information(this, tr("Create instance shortcut"), tr("Created a shortcut to this instance on your desktop!")); + } + else + { + iconFile.remove(); + QMessageBox::critical(this, tr("Create instance shortcut"), tr("Failed to create instance shortcut!")); + } +#else + QMessageBox::critical(this, tr("Create instance shortcut"), tr("Not supported on your platform!")); +#endif + } +} + void MainWindow::taskEnd() { QObject *sender = QObject::sender(); diff --git a/launcher/ui/MainWindow.h b/launcher/ui/MainWindow.h index 0aa01ee2..f96f641d 100644 --- a/launcher/ui/MainWindow.h +++ b/launcher/ui/MainWindow.h @@ -161,6 +161,8 @@ private slots: void on_actionEditInstance_triggered(); + void on_actionCreateInstanceShortcut_triggered(); + void taskEnd(); /** diff --git a/launcher/ui/dialogs/ImportResourcePackDialog.cpp b/launcher/ui/dialogs/ImportResourcePackDialog.cpp new file mode 100644 index 00000000..e807e926 --- /dev/null +++ b/launcher/ui/dialogs/ImportResourcePackDialog.cpp @@ -0,0 +1,66 @@ +#include "ImportResourcePackDialog.h" +#include "ui_ImportResourcePackDialog.h" + +#include +#include + +#include "Application.h" +#include "InstanceList.h" + +#include +#include "ui/instanceview/InstanceProxyModel.h" +#include "ui/instanceview/InstanceDelegate.h" + +ImportResourcePackDialog::ImportResourcePackDialog(QWidget* parent) : QDialog(parent), ui(new Ui::ImportResourcePackDialog) +{ + ui->setupUi(this); + setWindowModality(Qt::WindowModal); + + auto contentsWidget = ui->instanceView; + contentsWidget->setViewMode(QListView::ListMode); + contentsWidget->setFlow(QListView::LeftToRight); + contentsWidget->setIconSize(QSize(48, 48)); + contentsWidget->setMovement(QListView::Static); + contentsWidget->setResizeMode(QListView::Adjust); + contentsWidget->setSelectionMode(QAbstractItemView::SingleSelection); + contentsWidget->setSpacing(5); + contentsWidget->setWordWrap(true); + contentsWidget->setWrapping(true); + // NOTE: We can't have uniform sizes because the text may wrap if it's too long. If we set this, it will cut off the wrapped text. + contentsWidget->setUniformItemSizes(false); + contentsWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); + contentsWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); + contentsWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + contentsWidget->setItemDelegate(new ListViewDelegate()); + + proxyModel = new InstanceProxyModel(this); + proxyModel->setSourceModel(APPLICATION->instances().get()); + proxyModel->sort(0); + contentsWidget->setModel(proxyModel); + + connect(contentsWidget, SIGNAL(doubleClicked(QModelIndex)), SLOT(activated(QModelIndex))); + connect(contentsWidget->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), + SLOT(selectionChanged(QItemSelection, QItemSelection))); +} + +void ImportResourcePackDialog::activated(QModelIndex index) +{ + selectedInstanceKey = index.data(InstanceList::InstanceIDRole).toString(); + accept(); +} + +void ImportResourcePackDialog::selectionChanged(QItemSelection selected, QItemSelection deselected) +{ + if (selected.empty()) + return; + + QString key = selected.first().indexes().first().data(InstanceList::InstanceIDRole).toString(); + if (!key.isEmpty()) { + selectedInstanceKey = key; + } +} + +ImportResourcePackDialog::~ImportResourcePackDialog() +{ + delete ui; +} diff --git a/launcher/ui/dialogs/ImportResourcePackDialog.h b/launcher/ui/dialogs/ImportResourcePackDialog.h new file mode 100644 index 00000000..8356f204 --- /dev/null +++ b/launcher/ui/dialogs/ImportResourcePackDialog.h @@ -0,0 +1,27 @@ +#pragma once + +#include +#include + +#include "ui/instanceview/InstanceProxyModel.h" + +namespace Ui { +class ImportResourcePackDialog; +} + +class ImportResourcePackDialog : public QDialog { + Q_OBJECT + + public: + explicit ImportResourcePackDialog(QWidget* parent = 0); + ~ImportResourcePackDialog(); + InstanceProxyModel* proxyModel; + QString selectedInstanceKey; + + private: + Ui::ImportResourcePackDialog* ui; + + private slots: + void selectionChanged(QItemSelection, QItemSelection); + void activated(QModelIndex); +}; diff --git a/launcher/ui/dialogs/ImportResourcePackDialog.ui b/launcher/ui/dialogs/ImportResourcePackDialog.ui new file mode 100644 index 00000000..20cb9177 --- /dev/null +++ b/launcher/ui/dialogs/ImportResourcePackDialog.ui @@ -0,0 +1,74 @@ + + + ImportResourcePackDialog + + + + 0 + 0 + 676 + 555 + + + + Choose instance to import + + + + + + Choose the instance you would like to import this resource pack to. + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + ImportResourcePackDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + ImportResourcePackDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/launcher/ui/pages/global/JavaPage.cpp b/launcher/ui/pages/global/JavaPage.cpp index 2cee15bf..81dd4cc1 100644 --- a/launcher/ui/pages/global/JavaPage.cpp +++ b/launcher/ui/pages/global/JavaPage.cpp @@ -58,9 +58,8 @@ JavaPage::JavaPage(QWidget *parent) : QWidget(parent), ui(new Ui::JavaPage) ui->setupUi(this); ui->tabWidget->tabBar()->hide(); - auto sysMiB = Sys::getSystemRam() / Sys::mebibyte; - ui->maxMemSpinBox->setMaximum(sysMiB); loadSettings(); + updateThresholds(); } JavaPage::~JavaPage() @@ -177,6 +176,11 @@ void JavaPage::on_javaTestBtn_clicked() checker->run(); } +void JavaPage::on_maxMemSpinBox_valueChanged(int i) +{ + updateThresholds(); +} + void JavaPage::checkerFinished() { checker.reset(); @@ -186,3 +190,29 @@ void JavaPage::retranslate() { ui->retranslateUi(this); } + +void JavaPage::updateThresholds() +{ + auto sysMiB = Sys::getSystemRam() / Sys::mebibyte; + unsigned int maxMem = ui->maxMemSpinBox->value(); + + QString iconName; + + if (maxMem >= sysMiB) { + iconName = "status-bad"; + ui->labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation exceeds your system memory capacity.")); + } else if (maxMem > (sysMiB * 0.9)) { + iconName = "status-yellow"; + ui->labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation approaches your system memory capacity.")); + } else { + iconName = "status-good"; + ui->labelMaxMemIcon->setToolTip(""); + } + + { + auto height = ui->labelMaxMemIcon->fontInfo().pixelSize(); + QIcon icon = APPLICATION->getThemedIcon(iconName); + QPixmap pix = icon.pixmap(height, height); + ui->labelMaxMemIcon->setPixmap(pix); + } +} diff --git a/launcher/ui/pages/global/JavaPage.h b/launcher/ui/pages/global/JavaPage.h index 64d4098e..2ef6d749 100644 --- a/launcher/ui/pages/global/JavaPage.h +++ b/launcher/ui/pages/global/JavaPage.h @@ -76,6 +76,8 @@ public: bool apply() override; void retranslate() override; + void updateThresholds(); + private: void applySettings(); void loadSettings(); @@ -85,6 +87,7 @@ slots: void on_javaDetectBtn_clicked(); void on_javaTestBtn_clicked(); void on_javaBrowseBtn_clicked(); + void on_maxMemSpinBox_valueChanged(int i); void checkerFinished(); private: diff --git a/launcher/ui/pages/global/JavaPage.ui b/launcher/ui/pages/global/JavaPage.ui index 6ccffed4..6749cbe4 100644 --- a/launcher/ui/pages/global/JavaPage.ui +++ b/launcher/ui/pages/global/JavaPage.ui @@ -44,39 +44,7 @@ Memory - - - - - The maximum amount of memory Minecraft is allowed to use. - - - MiB - - - 128 - - - 65536 - - - 128 - - - 1024 - - - - - - - &Minimum memory allocation: - - - minMemSpinBox - - - + @@ -87,28 +55,6 @@ - - - - The amount of memory Minecraft is started with. - - - MiB - - - 128 - - - 65536 - - - 128 - - - 256 - - - @@ -119,7 +65,61 @@ - + + + + &Minimum memory allocation: + + + minMemSpinBox + + + + + + + The amount of memory Minecraft is started with. + + + MiB + + + 128 + + + 1048576 + + + 128 + + + 256 + + + + + + + The maximum amount of memory Minecraft is allowed to use. + + + MiB + + + 128 + + + 1048576 + + + 128 + + + 1024 + + + + The amount of memory available to store loaded Java classes. @@ -141,6 +141,16 @@ + + + + + + + maxMemSpinBox + + + diff --git a/launcher/ui/pages/instance/ExternalResourcesPage.cpp b/launcher/ui/pages/instance/ExternalResourcesPage.cpp index b6c873cc..5c919573 100644 --- a/launcher/ui/pages/instance/ExternalResourcesPage.cpp +++ b/launcher/ui/pages/instance/ExternalResourcesPage.cpp @@ -14,8 +14,6 @@ ExternalResourcesPage::ExternalResourcesPage(BaseInstance* instance, std::shared { ui->setupUi(this); - ExternalResourcesPage::runningStateChanged(m_instance && m_instance->isRunning()); - ui->actionsToolbar->insertSpacer(ui->actionViewConfigs); m_filterModel = model->createFilterProxyModel(this); @@ -45,7 +43,6 @@ ExternalResourcesPage::ExternalResourcesPage(BaseInstance* instance, std::shared auto selection_model = ui->treeView->selectionModel(); connect(selection_model, &QItemSelectionModel::currentChanged, this, &ExternalResourcesPage::current); connect(ui->filterEdit, &QLineEdit::textChanged, this, &ExternalResourcesPage::filterTextChanged); - connect(m_instance, &BaseInstance::runningStatusChanged, this, &ExternalResourcesPage::runningStateChanged); } ExternalResourcesPage::~ExternalResourcesPage() @@ -97,14 +94,6 @@ void ExternalResourcesPage::filterTextChanged(const QString& newContents) m_filterModel->setFilterRegularExpression(m_viewFilter); } -void ExternalResourcesPage::runningStateChanged(bool running) -{ - if (m_controlsEnabled == !running) - return; - - m_controlsEnabled = !running; -} - bool ExternalResourcesPage::shouldDisplay() const { return true; diff --git a/launcher/ui/pages/instance/ExternalResourcesPage.h b/launcher/ui/pages/instance/ExternalResourcesPage.h index 8e352cef..11058bf6 100644 --- a/launcher/ui/pages/instance/ExternalResourcesPage.h +++ b/launcher/ui/pages/instance/ExternalResourcesPage.h @@ -47,7 +47,6 @@ class ExternalResourcesPage : public QMainWindow, public BasePage { protected slots: void itemActivated(const QModelIndex& index); void filterTextChanged(const QString& newContents); - virtual void runningStateChanged(bool running); virtual void addItem(); virtual void removeItem(); diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.cpp b/launcher/ui/pages/instance/InstanceSettingsPage.cpp index 5da7f19f..af2ba7c8 100644 --- a/launcher/ui/pages/instance/InstanceSettingsPage.cpp +++ b/launcher/ui/pages/instance/InstanceSettingsPage.cpp @@ -59,12 +59,12 @@ InstanceSettingsPage::InstanceSettingsPage(BaseInstance *inst, QWidget *parent) { m_settings = inst->settings(); ui->setupUi(this); - auto sysMB = Sys::getSystemRam() / Sys::mebibyte; - ui->maxMemSpinBox->setMaximum(sysMB); + connect(ui->openGlobalJavaSettingsButton, &QCommandLinkButton::clicked, this, &InstanceSettingsPage::globalSettingsButtonClicked); connect(APPLICATION, &Application::globalSettingsAboutToOpen, this, &InstanceSettingsPage::applySettings); connect(APPLICATION, &Application::globalSettingsClosed, this, &InstanceSettingsPage::loadSettings); loadSettings(); + updateThresholds(); } bool InstanceSettingsPage::shouldDisplay() const @@ -437,6 +437,11 @@ void InstanceSettingsPage::on_javaTestBtn_clicked() checker->run(); } +void InstanceSettingsPage::on_maxMemSpinBox_valueChanged(int i) +{ + updateThresholds(); +} + void InstanceSettingsPage::checkerFinished() { checker.reset(); @@ -447,3 +452,29 @@ void InstanceSettingsPage::retranslate() ui->retranslateUi(this); ui->customCommands->retranslate(); // TODO: why is this seperate from the others? } + +void InstanceSettingsPage::updateThresholds() +{ + auto sysMiB = Sys::getSystemRam() / Sys::mebibyte; + unsigned int maxMem = ui->maxMemSpinBox->value(); + + QString iconName; + + if (maxMem >= sysMiB) { + iconName = "status-bad"; + ui->labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation exceeds your system memory capacity.")); + } else if (maxMem > (sysMiB * 0.9)) { + iconName = "status-yellow"; + ui->labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation approaches your system memory capacity.")); + } else { + iconName = "status-good"; + ui->labelMaxMemIcon->setToolTip(""); + } + + { + auto height = ui->labelMaxMemIcon->fontInfo().pixelSize(); + QIcon icon = APPLICATION->getThemedIcon(iconName); + QPixmap pix = icon.pixmap(height, height); + ui->labelMaxMemIcon->setPixmap(pix); + } +} diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.h b/launcher/ui/pages/instance/InstanceSettingsPage.h index 97d1296f..7450188d 100644 --- a/launcher/ui/pages/instance/InstanceSettingsPage.h +++ b/launcher/ui/pages/instance/InstanceSettingsPage.h @@ -77,10 +77,13 @@ public: virtual bool shouldDisplay() const override; void retranslate() override; + void updateThresholds(); + private slots: void on_javaDetectBtn_clicked(); void on_javaTestBtn_clicked(); void on_javaBrowseBtn_clicked(); + void on_maxMemSpinBox_valueChanged(int i); void applySettings(); void loadSettings(); diff --git a/launcher/ui/pages/instance/InstanceSettingsPage.ui b/launcher/ui/pages/instance/InstanceSettingsPage.ui index 8b3c3370..b064367d 100644 --- a/launcher/ui/pages/instance/InstanceSettingsPage.ui +++ b/launcher/ui/pages/instance/InstanceSettingsPage.ui @@ -112,7 +112,14 @@ false - + + + + + PermGen: + + + @@ -120,29 +127,21 @@ - - - - The maximum amount of memory Minecraft is allowed to use. - - - MiB - - - 128 - - - 65536 - - - 128 - - - 1024 + + + + Maximum memory allocation: - + + + + Note: Permgen is set automatically by Java 8 and later + + + + The amount of memory Minecraft is started with. @@ -154,7 +153,7 @@ 128 - 65536 + 1048576 128 @@ -164,7 +163,29 @@ - + + + + The maximum amount of memory Minecraft is allowed to use. + + + MiB + + + 128 + + + 1048576 + + + 128 + + + 1024 + + + + The amount of memory available to store loaded Java classes. @@ -186,24 +207,16 @@ - - + + - PermGen: + - - - - - - Maximum memory allocation: + + Qt::AlignCenter - - - - - - Note: Permgen is set automatically by Java 8 and later + + maxMemSpinBox diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp index f0106066..0a2e6155 100644 --- a/launcher/ui/pages/instance/ModFolderPage.cpp +++ b/launcher/ui/pages/instance/ModFolderPage.cpp @@ -108,13 +108,13 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr disconnect(mods.get(), &ModFolderModel::updateFinished, this, 0); }); + connect(m_instance, &BaseInstance::runningStatusChanged, this, &ModFolderPage::runningStateChanged); ModFolderPage::runningStateChanged(m_instance && m_instance->isRunning()); } } void ModFolderPage::runningStateChanged(bool running) { - ExternalResourcesPage::runningStateChanged(running); ui->actionDownloadItem->setEnabled(!running); ui->actionUpdateItem->setEnabled(!running); ui->actionAddItem->setEnabled(!running); diff --git a/launcher/ui/pages/instance/ModFolderPage.h b/launcher/ui/pages/instance/ModFolderPage.h index c9a55bde..f20adf34 100644 --- a/launcher/ui/pages/instance/ModFolderPage.h +++ b/launcher/ui/pages/instance/ModFolderPage.h @@ -53,12 +53,12 @@ class ModFolderPage : public ExternalResourcesPage { virtual QString helpPage() const override { return "Loader-mods"; } virtual bool shouldDisplay() const override; - void runningStateChanged(bool running) override; public slots: bool onSelectionChanged(const QModelIndex& current, const QModelIndex& previous) override; private slots: + void runningStateChanged(bool running); void removeItem() override; void installMods(); diff --git a/launcher/ui/pages/instance/VersionPage.cpp b/launcher/ui/pages/instance/VersionPage.cpp index a021c633..7f98cba2 100644 --- a/launcher/ui/pages/instance/VersionPage.cpp +++ b/launcher/ui/pages/instance/VersionPage.cpp @@ -1,8 +1,9 @@ // SPDX-License-Identifier: GPL-3.0-only /* - * PolyMC - Minecraft Launcher + * Prism Launcher - Minecraft Launcher * Copyright (c) 2022 Jamie Mansfield * Copyright (C) 2022 Sefa Eyeoglu + * Copyright (C) 2022 TheKodeToad * * 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 @@ -270,6 +271,7 @@ void VersionPage::updateButtons(int row) ui->actionInstall_mods->setEnabled(controlsEnabled); ui->actionReplace_Minecraft_jar->setEnabled(controlsEnabled); ui->actionAdd_to_Minecraft_jar->setEnabled(controlsEnabled); + ui->actionAdd_Agents->setEnabled(controlsEnabled); } bool VersionPage::reloadPackProfile() @@ -342,6 +344,18 @@ void VersionPage::on_actionReplace_Minecraft_jar_triggered() updateButtons(); } + +void VersionPage::on_actionAdd_Agents_triggered() +{ + QStringList list = GuiUtil::BrowseForFiles("agent", tr("Select agents"), tr("Java agents (*.jar)"), + APPLICATION->settings()->get("CentralModsDir").toString(), this->parentWidget()); + + if (!list.isEmpty()) + m_profile->installAgents(list); + + updateButtons(); +} + void VersionPage::on_actionMove_up_triggered() { try diff --git a/launcher/ui/pages/instance/VersionPage.h b/launcher/ui/pages/instance/VersionPage.h index 979311fc..23d2a1b3 100644 --- a/launcher/ui/pages/instance/VersionPage.h +++ b/launcher/ui/pages/instance/VersionPage.h @@ -1,7 +1,8 @@ // SPDX-License-Identifier: GPL-3.0-only /* - * PolyMC - Minecraft Launcher + * Prism Launcher - Minecraft Launcher * Copyright (c) 2022 Jamie Mansfield + * Copyright (C) 2022 TheKodeToad * * 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 @@ -82,6 +83,7 @@ private slots: void on_actionMove_down_triggered(); void on_actionAdd_to_Minecraft_jar_triggered(); void on_actionReplace_Minecraft_jar_triggered(); + void on_actionAdd_Agents_triggered(); void on_actionRevert_triggered(); void on_actionEdit_triggered(); void on_actionInstall_mods_triggered(); diff --git a/launcher/ui/pages/instance/VersionPage.ui b/launcher/ui/pages/instance/VersionPage.ui index 14b7cd9f..74b9568a 100644 --- a/launcher/ui/pages/instance/VersionPage.ui +++ b/launcher/ui/pages/instance/VersionPage.ui @@ -109,6 +109,7 @@ + @@ -226,6 +227,14 @@ Replace Minecraft.jar + + + Add Agents + + + Add Java agents. + + Add Empty diff --git a/launcher/ui/widgets/JavaSettingsWidget.cpp b/launcher/ui/widgets/JavaSettingsWidget.cpp index c7c4dbbd..15994319 100644 --- a/launcher/ui/widgets/JavaSettingsWidget.cpp +++ b/launcher/ui/widgets/JavaSettingsWidget.cpp @@ -71,6 +71,7 @@ void JavaSettingsWidget::setupUi() m_memoryGroupBox->setObjectName(QStringLiteral("memoryGroupBox")); m_gridLayout_2 = new QGridLayout(m_memoryGroupBox); m_gridLayout_2->setObjectName(QStringLiteral("gridLayout_2")); + m_gridLayout_2->setColumnStretch(0, 1); m_labelMinMem = new QLabel(m_memoryGroupBox); m_labelMinMem->setObjectName(QStringLiteral("labelMinMem")); @@ -80,7 +81,7 @@ void JavaSettingsWidget::setupUi() m_minMemSpinBox->setObjectName(QStringLiteral("minMemSpinBox")); m_minMemSpinBox->setSuffix(QStringLiteral(" MiB")); m_minMemSpinBox->setMinimum(128); - m_minMemSpinBox->setMaximum(m_availableMemory); + m_minMemSpinBox->setMaximum(1048576); m_minMemSpinBox->setSingleStep(128); m_labelMinMem->setBuddy(m_minMemSpinBox); m_gridLayout_2->addWidget(m_minMemSpinBox, 0, 1, 1, 1); @@ -93,11 +94,15 @@ void JavaSettingsWidget::setupUi() m_maxMemSpinBox->setObjectName(QStringLiteral("maxMemSpinBox")); m_maxMemSpinBox->setSuffix(QStringLiteral(" MiB")); m_maxMemSpinBox->setMinimum(128); - m_maxMemSpinBox->setMaximum(m_availableMemory); + m_maxMemSpinBox->setMaximum(1048576); m_maxMemSpinBox->setSingleStep(128); m_labelMaxMem->setBuddy(m_maxMemSpinBox); m_gridLayout_2->addWidget(m_maxMemSpinBox, 1, 1, 1, 1); + m_labelMaxMemIcon = new QLabel(m_memoryGroupBox); + m_labelMaxMemIcon->setObjectName(QStringLiteral("labelMaxMemIcon")); + m_gridLayout_2->addWidget(m_labelMaxMemIcon, 1, 2, 1, 1); + m_labelPermGen = new QLabel(m_memoryGroupBox); m_labelPermGen->setObjectName(QStringLiteral("labelPermGen")); m_labelPermGen->setText(QStringLiteral("PermGen:")); @@ -108,7 +113,7 @@ void JavaSettingsWidget::setupUi() m_permGenSpinBox->setObjectName(QStringLiteral("permGenSpinBox")); m_permGenSpinBox->setSuffix(QStringLiteral(" MiB")); m_permGenSpinBox->setMinimum(64); - m_permGenSpinBox->setMaximum(m_availableMemory); + m_permGenSpinBox->setMaximum(1048576); m_permGenSpinBox->setSingleStep(8); m_gridLayout_2->addWidget(m_permGenSpinBox, 2, 1, 1, 1); m_permGenSpinBox->setVisible(false); @@ -130,6 +135,7 @@ void JavaSettingsWidget::initialize() m_minMemSpinBox->setValue(observedMinMemory); m_maxMemSpinBox->setValue(observedMaxMemory); m_permGenSpinBox->setValue(observedPermGenMemory); + updateThresholds(); } void JavaSettingsWidget::refresh() @@ -210,9 +216,9 @@ int JavaSettingsWidget::permGenSize() const void JavaSettingsWidget::memoryValueChanged(int) { bool actuallyChanged = false; - int min = m_minMemSpinBox->value(); - int max = m_maxMemSpinBox->value(); - int permgen = m_permGenSpinBox->value(); + unsigned int min = m_minMemSpinBox->value(); + unsigned int max = m_maxMemSpinBox->value(); + unsigned int permgen = m_permGenSpinBox->value(); QObject *obj = sender(); if (obj == m_minMemSpinBox && min != observedMinMemory) { @@ -242,6 +248,7 @@ void JavaSettingsWidget::memoryValueChanged(int) if(actuallyChanged) { checkJavaPathOnEdit(m_javaPathTextBox->text()); + updateThresholds(); } } @@ -435,3 +442,26 @@ void JavaSettingsWidget::retranslate() m_permGenSpinBox->setToolTip(tr("The amount of memory available to store loaded Java classes.")); m_javaBrowseBtn->setText(tr("Browse")); } + +void JavaSettingsWidget::updateThresholds() +{ + QString iconName; + + if (observedMaxMemory >= m_availableMemory) { + iconName = "status-bad"; + m_labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation exceeds your system memory capacity.")); + } else if (observedMaxMemory > (m_availableMemory * 0.9)) { + iconName = "status-yellow"; + m_labelMaxMemIcon->setToolTip(tr("Your maximum memory allocation approaches your system memory capacity.")); + } else { + iconName = "status-good"; + m_labelMaxMemIcon->setToolTip(""); + } + + { + auto height = m_labelMaxMemIcon->fontInfo().pixelSize(); + QIcon icon = APPLICATION->getThemedIcon(iconName); + QPixmap pix = icon.pixmap(height, height); + m_labelMaxMemIcon->setPixmap(pix); + } +} diff --git a/launcher/ui/widgets/JavaSettingsWidget.h b/launcher/ui/widgets/JavaSettingsWidget.h index 5344e2cd..e4b7c712 100644 --- a/launcher/ui/widgets/JavaSettingsWidget.h +++ b/launcher/ui/widgets/JavaSettingsWidget.h @@ -56,6 +56,8 @@ public: int maxHeapSize() const; QString javaPath() const; + void updateThresholds(); + protected slots: void memoryValueChanged(int); @@ -85,6 +87,7 @@ private: /* data */ QSpinBox *m_maxMemSpinBox = nullptr; QLabel *m_labelMinMem = nullptr; QLabel *m_labelMaxMem = nullptr; + QLabel *m_labelMaxMemIcon = nullptr; QSpinBox *m_minMemSpinBox = nullptr; QLabel *m_labelPermGen = nullptr; QSpinBox *m_permGenSpinBox = nullptr; @@ -92,9 +95,9 @@ private: /* data */ QIcon yellowIcon; QIcon badIcon; - int observedMinMemory = 0; - int observedMaxMemory = 0; - int observedPermGenMemory = 0; + unsigned int observedMinMemory = 0; + unsigned int observedMaxMemory = 0; + unsigned int observedPermGenMemory = 0; QString queuedCheck; uint64_t m_availableMemory = 0ull; shared_qobject_ptr m_checker; diff --git a/nix/default.nix b/nix/default.nix index c7fc7576..6050fd37 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -1,100 +1,99 @@ -{ stdenv -, lib -, fetchFromGitHub +{ lib +, stdenv , cmake -, ninja , jdk8 , jdk -, ghc_filesystem , zlib , file , wrapQtAppsHook , xorg , libpulseaudio , qtbase -, quazip +, qtsvg +, qtwayland , libGL -, msaClientID ? "" -, extraJDKs ? [ ] +, quazip +, glfw +, openal , extra-cmake-modules +, ghc_filesystem +, msaClientID ? "" +, jdks ? [ jdk jdk8 ] # flake , self , version , libnbtplusplus , tomlplusplus -, enableLTO ? false }: -let - # Libraries required to run Minecraft - libpath = with xorg; lib.makeLibraryPath [ - libX11 - libXext - libXcursor - libXrandr - libXxf86vm - libpulseaudio - libGL - ]; - - # This variable will be passed to Minecraft by Prism Launcher - gameLibraryPath = libpath + ":/run/opengl-driver/lib"; - - javaPaths = lib.makeSearchPath "bin/java" ([ jdk jdk8 ] ++ extraJDKs); -in - stdenv.mkDerivation rec { pname = "prismlauncher"; inherit version; src = lib.cleanSource self; - nativeBuildInputs = [ cmake extra-cmake-modules ninja jdk ghc_filesystem file wrapQtAppsHook ]; - buildInputs = [ qtbase quazip zlib ]; + nativeBuildInputs = [ extra-cmake-modules cmake file jdk wrapQtAppsHook ]; + buildInputs = [ + qtbase + qtsvg + zlib + quazip + ghc_filesystem + ] ++ lib.optional (lib.versionAtLeast qtbase.version "6") qtwayland; + cmakeFlags = lib.optionals (msaClientID != "") [ "-DLauncher_MSA_CLIENT_ID=${msaClientID}" ] + ++ lib.optionals (lib.versionAtLeast qtbase.version "6") [ "-DLauncher_QT_VERSION_MAJOR=6" ]; dontWrapQtApps = true; postUnpack = '' - # Copy libnbtplusplus rm -rf source/libraries/libnbtplusplus mkdir source/libraries/libnbtplusplus ln -s ${libnbtplusplus}/* source/libraries/libnbtplusplus chmod -R +r+w source/libraries/libnbtplusplus - # Copy tomlplusplus + chown -R $USER: source/libraries/libnbtplusplus rm -rf source/libraries/tomlplusplus mkdir source/libraries/tomlplusplus ln -s ${tomlplusplus}/* source/libraries/tomlplusplus chmod -R +r+w source/libraries/tomlplusplus + chown -R $USER: source/libraries/tomlplusplus ''; - cmakeFlags = [ - "-GNinja" - "-DLauncher_QT_VERSION_MAJOR=${lib.versions.major qtbase.version}" - ] ++ lib.optionals enableLTO [ "-DENABLE_LTO=on" ] - ++ lib.optionals (msaClientID != "") [ "-DLauncher_MSA_CLIENT_ID=${msaClientID}" ]; + postInstall = + let + libpath = with xorg; + lib.makeLibraryPath [ + libX11 + libXext + libXcursor + libXrandr + libXxf86vm + libpulseaudio + libGL + glfw + openal + stdenv.cc.cc.lib + ]; + in + '' + # xorg.xrandr needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128 + wrapQtApp $out/bin/prismlauncher \ + --set LD_LIBRARY_PATH /run/opengl-driver/lib:${libpath} \ + --prefix PRISMLAUNCHER_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks} \ + --prefix PATH : ${lib.makeBinPath [xorg.xrandr]} + ''; - # we have to check if the system is NixOS before adding stdenv.cc.cc.lib (#923) - postInstall = '' - # xorg.xrandr needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128 - wrapQtApp $out/bin/prismlauncher \ - --run '[ -f /etc/NIXOS ] && export LD_LIBRARY_PATH="${stdenv.cc.cc.lib}/lib:$LD_LIBRARY_PATH"' \ - --prefix LD_LIBRARY_PATH : ${gameLibraryPath} \ - --prefix PRISMLAUNCHER_JAVA_PATHS : ${javaPaths} \ - --prefix PATH : ${lib.makeBinPath [ xorg.xrandr ]} - ''; meta = with lib; { homepage = "https://prismlauncher.org/"; - downloadPage = "https://prismlauncher.org/download/"; - changelog = "https://github.com/PrismLauncher/PrismLauncher/releases"; description = "A free, open source launcher for Minecraft"; longDescription = '' Allows you to have multiple, separate instances of Minecraft (each with their own mods, texture packs, saves, etc) and helps you manage them and their associated options with a simple interface. ''; - platforms = platforms.unix; + platforms = platforms.linux; + changelog = "https://github.com/PrismLauncher/PrismLauncher/releases/tag/${version}"; license = licenses.gpl3Only; maintainers = with maintainers; [ minion3665 Scrumplex ]; }; diff --git a/program_info/instance_icons.svg b/program_info/instance_icons.svg new file mode 100644 index 00000000..84c0ef6f --- /dev/null +++ b/program_info/instance_icons.svg @@ -0,0 +1,2720 @@ + + + +Prism Launcher LogoPrism Launcher Logo19/10/2022Prism LauncherAutiOne, Boba, ely, Fulmine, gon sawa, Pankakes, tobimori, Zekehttps://github.com/PrismLauncher/PrismLauncherCC BY-SA 4.0Prism Launcher