diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a904141..da50eb3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,7 +24,9 @@ jobs: echo "|--|--|" >> NOTE.md echo "|Windows|[lovely-x86_64-pc-windows-msvc.zip](https://github.com/ethangreen-dev/lovely-injector/releases/download/${{ github.ref_name }}/lovely-x86_64-pc-windows-msvc.zip)|" >> NOTE.md echo "|Mac (Arm)|[lovely-aarch64-apple-darwin.tar.gz](https://github.com/ethangreen-dev/lovely-injector/releases/download/${{ github.ref_name }}/lovely-aarch64-apple-darwin.tar.gz)|" >> NOTE.md - echo "|Mac (x86)|[lovely-x86_64-apple-darwin.tar.gz](https://github.com/ethangreen-dev/lovely-injector/releases/download/${{ github.ref_name }}/lovely-x86_64-apple-darwin.tar.gz)|" >> NOTE.md + echo "|Mac (Arm) (Installer)|[lovely-aarch64-apple-darwin-installer.tar.gz](https://github.com/ethangreen-dev/lovely-injector/releases/download/${{ github.ref_name }}/lovely-aarch64-apple-darwin.tar.gz)|" >> NOTE.md + echo "|Mac (x86)|[lovely-x86_64-apple-darwin-installer.tar.gz](https://github.com/ethangreen-dev/lovely-injector/releases/download/${{ github.ref_name }}/lovely-x86_64-apple-darwin.tar.gz)|" >> NOTE.md + echo "|Mac (x86) (Installer)|[lovely-x86_64-apple-darwin-installer.tar.gz](https://github.com/ethangreen-dev/lovely-injector/releases/download/${{ github.ref_name }}/lovely-x86_64-apple-darwin-installer.tar.gz)|" >> NOTE.md gh release create ${{ github.ref_name }} \ --title "${{ github.ref_name }}" \ @@ -92,11 +94,11 @@ jobs: pip3 install cargo-zigbuild - name: Build - run: cargo zigbuild --target ${{ matrix.target }} --package lovely-mac --release + run: cargo zigbuild --target ${{ matrix.target }} --package lovely-unix --release - name: Compress tar.gz run: | - cp ./crates/lovely-mac/run_lovely.sh ./target/${{ matrix.target }}/release/ + cp ./crates/lovely-unix/run_lovely_macos.sh ./target/${{ matrix.target }}/release/run_lovely.sh cd ./target/${{ matrix.target }}/release/ tar czfv lovely-${{ matrix.target }}.tar.gz liblovely.dylib run_lovely.sh mv "lovely-${{ matrix.target }}.tar.gz" ${{ github.workspace }} @@ -106,3 +108,47 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: >- gh release upload ${{ github.ref_name }} lovely-${{ matrix.target }}.tar.gz + + build-mac-bundle: + needs: prepare + strategy: + matrix: + target: + - x86_64-apple-darwin + - aarch64-apple-darwin + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup toolchain + uses: dtolnay/rust-toolchain@nightly + with: + target: ${{ matrix.target }} + + - name: Install Mac SDK + run: | + curl -L "https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX10.9.sdk.tar.xz" | tar -J -x -C /opt + curl -L "https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX11.3.sdk.tar.xz" | tar -J -x -C /opt + echo "SDKROOT=/opt/MacOSX11.3.sdk" >> $GITHUB_ENV + + - name: Install cargo-zigbuild + run: | + pip3 install cargo-zigbuild + + - name: Build + run: cargo zigbuild --target ${{ matrix.target }} --package lovely-unix --release + + - name: Compress tar.gz + run: | + cp ./crates/lovely-unix/install_lovely_macos_bundle.sh ./target/${{ matrix.target }}/release/install_lovely.sh + cp -R ./crates/lovely-unix/resources-mac ./target/${{ matrix.target }}/release/assets + cd ./target/${{ matrix.target }}/release/ + tar czfv lovely-${{ matrix.target }}-installer.tar.gz liblovely.dylib install_lovely.sh assets + mv "lovely-${{ matrix.target }}-installer.tar.gz" ${{ github.workspace }} + + - name: Submit build artifact + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: >- + gh release upload ${{ github.ref_name }} lovely-${{ matrix.target }}-installer.tar.gz diff --git a/README.md b/README.md index f2d1a36..18e1143 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,15 @@ Lovely is a lua injector which embeds code into a [LÖVE 2d](https://love2d.org/ ### Mac +#### Bundle Installation (Easy) +1. Download the [latest release](https://github.com/ethangreen-dev/lovely-injector/releases) for Mac. If you have an M-series CPU (M1, M2, etc.) then this will be `lovely-aarch64-apple-darwin-installer.tar.gz`. If you have an Intel CPU then it will be `lovely-x86_64-apple-darwin-installer.tar.gz` +2. Open the .zip archive, copy `assets`, `liblovely.dylib` and `install_lovely.sh` into the game directory. You can navigate to the game's directory by right-clicking the game in Steam, hovering "Manage", and selecting "Browse local files". +3. Run `install_lovely.sh`, which will generate an app bundle, `Balatro + Mods.app`, in your user applications directory (`~/Applications`). +4. Put one or more mods into the Mac mod directory (NOT the same as the game directory). This should be `/Users/$USER/Library/Application Support/Balatro/Mods` where `$USER` is your username (if you are modding Balatro).\ +If you can't find this folder, try pressing `Shift-Command-.` (period) to show hidden files in Finder. +5. Open `Balatro + Mods.app`, either directly from `~/Applications`, or from Launchpad, and enjoy. + +#### Classic Installation (Advanced) 1. Download the [latest release](https://github.com/ethangreen-dev/lovely-injector/releases) for Mac. If you have an M-series CPU (M1, M2, etc.) then this will be `lovely-aarch64-apple-darwin.tar.gz`. If you have an Intel CPU then it will be `lovely-x86_64-apple-darwin.tar.gz` 2. Open the .zip archive, copy `liblovely.dylib` and `run_lovely.sh` into the game directory. You can navigate to the game's directory by right-clicking the game in Steam, hovering "Manage", and selecting "Browse local files". 3. Put one or more mods into the Mac mod directory (NOT the same as the game directory). This should be `/Users/$USER/Library/Application Support/Balatro/Mods` where `$USER` is your username (if you are modding Balatro).\ diff --git a/crates/lovely-unix/install_lovely_macos_bundle.sh b/crates/lovely-unix/install_lovely_macos_bundle.sh new file mode 100755 index 0000000..64a00af --- /dev/null +++ b/crates/lovely-unix/install_lovely_macos_bundle.sh @@ -0,0 +1,47 @@ +#!/bin/bash +gamename="Balatro" + +workingpath=$(cd "$(dirname "$0")"; pwd) +assetpath="${workingpath}/assets/" + +if ! [ -d "${workingpath}/${gamename}.app" ]; then + echo + echo "Balatro not found. Did you place everything in the right directory?" + echo + read -n1 -r -p "Press any key to exit..." key + exit +fi + +gamebundle="${workingpath}/${gamename}.app" + +bundlepath="/Users/$USER/Applications/${gamename} + Mods.app" +contentpath="${bundlepath}/Contents" + +echo +echo "Generating bundle..." +mkdir -p "${contentpath}" +cd "${contentpath}" +mkdir MacOS +mkdir Resources + +echo +echo "Copying assets..." +ln -s "${gamebundle}" ./MacOS/ +mv "${assetpath}/run_lovely.sh" ./MacOS/run_lovely +mv "${assetpath}/info.plist" ./ +mv "${workingpath}/liblovely.dylib" ./MacOS/ +mv "${assetpath}/application.icns" ./Resources/ + +chmod +x ./MacOS/run_lovely +echo "Signing application..." +codesign -s - --deep "${bundlepath}/Contents/MacOS/run_lovely" + +echo +echo "Cleaning up..." +rm "${workingpath}/install_lovely.sh" +rm -rf "${workingpath}/assets" + +echo +read -n1 -r -p "Installation complete! Press any key to exit..." key +open /Users/$USER/Applications +exit \ No newline at end of file diff --git a/crates/lovely-unix/resources-mac/Info.plist b/crates/lovely-unix/resources-mac/Info.plist new file mode 100755 index 0000000..aa05878 --- /dev/null +++ b/crates/lovely-unix/resources-mac/Info.plist @@ -0,0 +1,38 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + run_lovely + CFBundleIconFile + application.icns + CFBundleIdentifier + com.Balatro.localthunk.modded + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + Balatro + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1.0 + CFBundleSignature + LoVe + LSApplicationCategoryType + public.app-category.games + LSMinimumSystemVersion + 10.7 + NSHighResolutionCapable + + NSHumanReadableCopyright + © 2024 LocalThunk Inc. + NSPrincipalClass + NSApplication + NSSupportsAutomaticGraphicsSwitching + + + \ No newline at end of file diff --git a/crates/lovely-unix/resources-mac/application.icns b/crates/lovely-unix/resources-mac/application.icns new file mode 100644 index 0000000..1c4436e Binary files /dev/null and b/crates/lovely-unix/resources-mac/application.icns differ diff --git a/crates/lovely-unix/resources-mac/run_lovely.sh b/crates/lovely-unix/resources-mac/run_lovely.sh new file mode 100644 index 0000000..232bcc9 --- /dev/null +++ b/crates/lovely-unix/resources-mac/run_lovely.sh @@ -0,0 +1,8 @@ +#!/bin/bash +gamename="Balatro" +workingpath=$(cd "$(dirname "$0")"; pwd) + +export DYLD_INSERT_LIBRARIES=liblovely.dylib + +cd "${workingpath}" +./$gamename.app/Contents/MacOS/love "$@" diff --git a/crates/lovely-unix/run_lovely_macos.sh b/crates/lovely-unix/run_lovely_macos.sh index cfd3a96..cb77ec9 100755 --- a/crates/lovely-unix/run_lovely_macos.sh +++ b/crates/lovely-unix/run_lovely_macos.sh @@ -2,7 +2,21 @@ gamename="Balatro" defaultpath="/Users/$USER/Library/Application Support/Steam/steamapps/common/$gamename" +if ! [ -d "${workingpath}/${gamename}.app" ]; then + if ! [ -d cd "${defaultpath}/${gamename}.app" ]; then + echo + echo "Balatro not found. Did you place this in the right directory?" + echo + read -n1 -r -p "Press any key to exit..." key + exit + else + cd "$defaultpath" + fi +else + cd "$workingpath" +fi + export DYLD_INSERT_LIBRARIES=liblovely.dylib -cd "$defaultpath" + ./$gamename.app/Contents/MacOS/love "$@"