-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Balatro + Love2D support via lovely-injector (#1267)
lovely-injector is "JIT-like" lua injector for Love2D games: https://github.com/ethangreen-dev/lovely-injector. It injects lua into the game process at runtime, bypassing the need for manual executable patching. --------- Co-authored-by: Oksamies <[email protected]>
- Loading branch information
1 parent
dd003ba
commit f22547b
Showing
10 changed files
with
117 additions
and
2 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { InstallArgs, PackageInstaller } from "./PackageInstaller"; | ||
import { InstallRuleInstaller, addToStateFile } from "./InstallRuleInstaller"; | ||
import FsProvider from "../providers/generic/file/FsProvider"; | ||
import FileUtils from "../utils/FileUtils"; | ||
import FileTree from "../model/file/FileTree"; | ||
import R2Error from "../model/errors/R2Error"; | ||
import path from "path"; | ||
|
||
export class LovelyInstaller extends PackageInstaller { | ||
async install(args: InstallArgs) { | ||
const { | ||
mod, | ||
packagePath, | ||
profile, | ||
} = args; | ||
|
||
const profilePath = profile.getPathOfProfile(); | ||
const fs = FsProvider.instance; | ||
const fileRelocations = new Map<string, string>(); | ||
|
||
// Manually copy over version.dll | ||
const dwmSrc = path.join(packagePath, "version.dll"); | ||
const dwmDest = path.join(profilePath, "version.dll"); | ||
await fs.copyFile(dwmSrc, dwmDest); | ||
fileRelocations.set(dwmSrc, "version.dll"); | ||
|
||
// Files within the lovely subdirectory need to be recursively copied into the destination. | ||
const lovelyTree = await FileTree.buildFromLocation(path.join(packagePath, "lovely")); | ||
if (lovelyTree instanceof R2Error) { | ||
throw lovelyTree; | ||
} | ||
|
||
const targets = lovelyTree.getRecursiveFiles().map((x) => x.replace(packagePath, "")).map((x) => [x, path.join("mods", x)]); | ||
for (const target of targets) { | ||
const absSrc = path.join(packagePath, target[0]); | ||
const absDest = path.join(profilePath, target[1]); | ||
|
||
await FileUtils.ensureDirectory(path.dirname(absDest)); | ||
await fs.copyFile(absSrc, absDest); | ||
|
||
fileRelocations.set(absSrc, target[1]); | ||
} | ||
|
||
await addToStateFile(mod, fileRelocations, profile); | ||
} | ||
} | ||
|
||
export class LovelyPluginInstaller extends PackageInstaller { | ||
async install(args: InstallArgs) { | ||
const { | ||
mod, | ||
packagePath, | ||
profile, | ||
} = args; | ||
|
||
const profilePath = profile.getPathOfProfile(); | ||
const installDir = path.join("mods", mod.getName()); | ||
|
||
const fs = FsProvider.instance; | ||
const fileRelocations = new Map<string, string>(); | ||
|
||
const srcTree = await FileTree.buildFromLocation(packagePath); | ||
if (srcTree instanceof R2Error) { | ||
throw R2Error; | ||
} | ||
|
||
const srcFiles = srcTree.getRecursiveFiles(); | ||
for (const srcFile of srcFiles) { | ||
const relFile = srcFile.replace(packagePath, ""); | ||
const destFile = path.join(profilePath, installDir, relFile); | ||
|
||
await FileUtils.ensureDirectory(path.dirname(destFile)); | ||
await fs.copyFile(srcFile, destFile); | ||
|
||
fileRelocations.set(srcFile, path.join(installDir, relFile)); | ||
} | ||
|
||
await addToStateFile(mod, fileRelocations, profile); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/r2mm/launching/instructions/instructions/loader/LovelyGameInstructions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import GameInstructionGenerator from '../GameInstructionGenerator'; | ||
import { GameInstruction } from '../../GameInstructions'; | ||
import Game from '../../../../../model/game/Game'; | ||
import Profile from '../../../../../model/Profile'; | ||
import * as path from 'path'; | ||
|
||
export default class LovelyGameInstructions extends GameInstructionGenerator { | ||
|
||
public async generate(game: Game, profile: Profile): Promise<GameInstruction> { | ||
const modDir = path.join(profile.getPathOfProfile(), "mods"); | ||
|
||
return { | ||
moddedParameters: `--mod-dir "${modDir}"`, | ||
vanillaParameters: "--vanilla" | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters