Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Palworld + Voices of the Void support, initial Unreal engine support #1079

Merged
merged 24 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5ab80cc
implement shimloader support, add votv
ethangreen-dev Sep 23, 2023
dec845f
add UE4SS-settings.ini GUI config support
ethangreen-dev Jan 28, 2024
82135f0
resolve code review, various fixes
ethangreen-dev Jan 28, 2024
e132498
add `PackageInstaller` implementation for unreal_shimloader
ethangreen-dev Jan 30, 2024
b748f12
add dll mod support, update to new package format
ethangreen-dev Feb 7, 2024
91dbdc3
add `shimloader-plugin` installer + initial infra
ethangreen-dev Feb 7, 2024
bc142c6
fix tmm relative imports
ethangreen-dev Feb 8, 2024
2cae12f
fix build failure caused by bad syntax
ethangreen-dev Feb 8, 2024
bf7e3ec
fix broken shimloader uninstallation
ethangreen-dev Feb 8, 2024
6cf0ed2
Remove legacy install rule system for shimloader
MythicManiac Feb 9, 2024
1d844df
Remove unnecessary type cast
MythicManiac Feb 9, 2024
da2e2ba
Simplify getAllManagedPaths
MythicManiac Feb 9, 2024
e539b1f
A handful of minor improvements + missing await
MythicManiac Feb 9, 2024
2c28ea5
Improve test data populator
MythicManiac Feb 9, 2024
d84dab6
Add shimloader-plugin install test
MythicManiac Feb 9, 2024
fb4ea00
Update shimloader to using SUBDIR install method
MythicManiac Feb 9, 2024
4223d35
Fix shimloader uninstalls & add uninstall tests
MythicManiac Feb 9, 2024
b39c2f9
Delete SUBDIR_TRACKED install rule
MythicManiac Feb 9, 2024
6883657
Revert uninstallState logic to keep diffs smaller
MythicManiac Feb 9, 2024
38606d4
Remove state tracking from shimloader
MythicManiac Feb 9, 2024
45894d2
Copy shimloader files to the correct destination
MythicManiac Feb 9, 2024
f81f759
Remove unnecessary if statement
MythicManiac Feb 9, 2024
c7cc615
Add CI test run workflow
MythicManiac Feb 9, 2024
0bdd2c2
fix bad VotV entry in game list, remove shimloader vanilla arg
ethangreen-dev Feb 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added src/assets/images/game_selection/Palworld.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/game_selection/VotV.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/components/config-components/ConfigSelectionLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ import ProfileModList from '../../r2mm/mods/ProfileModList';
this.configFiles.push(new ConfigFile(file.substring(configLocation.length + 1), file, fileStat.mtime));
}
}

// HACK: Force the UE4SS-settings.ini file for shimloader mod installs to be visible.
const ue4ssSettingsPath = tree.getFiles().find(x => x.toLowerCase().endsWith("ue4ss-settings.ini"));
if (ue4ssSettingsPath) {
const lstat = await fs.lstat(ue4ssSettingsPath);
this.configFiles.push(new ConfigFile("UE4SS-settings.ini", ue4ssSettingsPath, lstat.mtime));
}

this.shownConfigFiles = [...this.configFiles];
}

Expand Down
46 changes: 46 additions & 0 deletions src/installers/InstallRuleInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,51 @@ async function installSubDirNoFlatten(profile: Profile, rule: ManagedRule, insta
}
}

async function installSubDirTracked(profile: Profile, rule: ManagedRule, installSources: string[], mod: ManifestV2) {
const fs = FsProvider.instance;
const subDir = path.join(profile.getPathOfProfile(), rule.route, mod.getName());
await FileUtils.ensureDirectory(subDir);

const relocations = new Map<string, string>();

let makeProfilePath = (input: string): string => {
const match = installSources.find((x) => input.startsWith(x));
if (match === undefined) {
return input;
}

return path.join(subDir, input.replace(match, ""));
}

const sources = [...installSources];
let source: string | undefined;

while ((source = sources.pop()) !== undefined) {
const lstat = await fs.lstat(source);

if (lstat.isFile()) {
const dest = makeProfilePath(source);
const destDir = path.dirname(dest);

if (!(await fs.exists(destDir))) {
await fs.mkdirs(destDir);
}

fs.copyFile(source, dest);

const profileRel = dest.replace(profile.getPathOfProfile(), "").substring(1);
relocations.set(source, profileRel);

continue;
}

const contents = (await fs.readdir(source)).map((x) => path.join(source as string, x));
sources.push(...contents);
}

await addToStateFile(mod, relocations, profile);
}

async function buildInstallForRuleSubtype(
rule: CoreRuleType,
location: string,
Expand Down Expand Up @@ -266,6 +311,7 @@ export class InstallRuleInstaller extends PackageInstaller {
case 'NONE': await installUntracked(profile, managedRule, files, mod); break;
case 'SUBDIR_NO_FLATTEN': await installSubDirNoFlatten(profile, managedRule, files, mod); break;
case 'PACKAGE_ZIP': await installPackageZip(profile, managedRule, files, mod); break;
case 'SUBDIR_TRACKED': await installSubDirTracked(profile, managedRule, files, mod); break;
}
}
return Promise.resolve(undefined);
Expand Down
69 changes: 69 additions & 0 deletions src/installers/ShimloaderInstaller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { InstallArgs, PackageInstaller } from "./PackageInstaller";
import path from "path";
import FsProvider from "../providers/generic/file/FsProvider";
import FileTree from "../model/file/FileTree";
import FileUtils from "../utils/FileUtils";
import R2Error from "../model/errors/R2Error";
import { InstallRuleInstaller, addToStateFile } from "./InstallRuleInstaller";
import InstallationRules from "../r2mm/installing/InstallationRules";
import GameManager from "../model/game/GameManager";

export class ShimloaderInstaller extends PackageInstaller {
/**
* Handle installation of unreal-shimloader
*/
async install(args: InstallArgs) {
const {
mod,
packagePath,
profile,
} = args;

const fs = FsProvider.instance;
const fileRelocations = new Map<string, string>();

const targets = [
["dwmapi.dll", "dwmapi.dll"],
["UE4SS/ue4ss.dll", "ue4ss.dll"],
["UE4SS/UE4SS-settings.ini", "UE4SS-settings.ini"],
];

const ue4ssTree = await FileTree.buildFromLocation(path.join(packagePath, "UE4SS/Mods"));
if (ue4ssTree instanceof R2Error) {
throw ue4ssTree;
}

for (const subFile of ue4ssTree.getRecursiveFiles()) {
const relSrc = path.relative(path.join(packagePath, "UE4SS/Mods"), subFile);

targets.push([path.join("UE4SS/Mods", relSrc), path.join("shimloader/mod", relSrc)]);
}

for (const targetPath of targets) {
const absSrc = path.join(packagePath, targetPath[0]);
const absDest = path.join(profile.getPathOfProfile(), targetPath[1]);

await FileUtils.ensureDirectory(path.dirname(absDest));
await fs.copyFile(absSrc, absDest);

fileRelocations.set(absSrc, targetPath[1]);
}

// The config subdir needs to be created for shimloader (it will get cranky if it's not there).
const configDir = path.join(profile.getPathOfProfile(), "shimloader", "cfg");
if (!await fs.exists(configDir)) {
await fs.mkdirs(configDir);
}

await addToStateFile(mod, fileRelocations, profile);
}
}

export class ShimloaderPluginInstaller extends PackageInstaller {
async install(args: InstallArgs) {
const rule = InstallationRules.RULES.find(value => value.gameName === GameManager.activeGame.internalFolderName)!;

const legacyInstaller = new InstallRuleInstaller(rule);
await legacyInstaller.install(args);
}
}
3 changes: 3 additions & 0 deletions src/installers/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ import { GodotMLInstaller } from "./GodotMLInstaller";
import { MelonLoaderInstaller } from "./MelonLoaderInstaller";
import { PackageInstaller } from "./PackageInstaller";
import { InstallRuleInstaller } from "./InstallRuleInstaller";
import { ShimloaderInstaller, ShimloaderPluginInstaller } from "./ShimloaderInstaller";


const _PackageInstallers = {
// "legacy": new InstallRuleInstaller(), // TODO: Enable
"bepinex": new BepInExInstaller(),
"godotml": new GodotMLInstaller(),
"melonloader": new MelonLoaderInstaller(),
"shimloader": new ShimloaderInstaller(),
"shimloader-plugin": new ShimloaderPluginInstaller(),
}

export type PackageInstallerId = keyof typeof _PackageInstallers;
Expand Down
13 changes: 13 additions & 0 deletions src/model/game/GameManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,19 @@ export default class GameManager {
"https://thunderstore.io/c/sailwind/api/v1/package/", "https://github.com/ebkr/r2modmanPlus/master/modExclusions.md",
[new StorePlatformMetadata(StorePlatform.STEAM, "1764530")], "Sailwind.png",
GameSelectionDisplayMode.VISIBLE, GameInstanceType.GAME, PackageLoader.BEPINEX, []),
new Game(
"Voices of the Void", "VotV", "VotV",
"", ["VotV-Win64-Shipping.exe"], "",
ethangreen-dev marked this conversation as resolved.
Show resolved Hide resolved
"https://thunderstore.io/c/voices-of-the-void/api/v1/package/", "https://github.com/ebkr/r2modmanPlus/master/modExclusions.md",
[new StorePlatformMetadata(StorePlatform.OTHER)], "VotV.png",
GameSelectionDisplayMode.VISIBLE, GameInstanceType.GAME, PackageLoader.SHIMLOADER, ["votv"]),

new Game(
"Palworld", "Palworld", "Palworld",
"Palworld", ["Palworld.exe"], "Pal",
"https://thunderstore.io/c/palworld/api/v1/package/", "https://github.com/ebkr/r2modmanPlus/master/modExclusions.md",
[new StorePlatformMetadata(StorePlatform.STEAM, "1623730")], "Palworld.png",
GameSelectionDisplayMode.VISIBLE, GameInstanceType.GAME, PackageLoader.SHIMLOADER, ["palworld"])
];

static get activeGame(): Game {
Expand Down
11 changes: 11 additions & 0 deletions src/model/installing/PackageLoader.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { PackageInstallerId, PackageInstallers } from "../../installers/registry";
import Game from "../game/Game";

export enum PackageLoader {
BEPINEX,
MELON_LOADER,
NORTHSTAR,
GODOT_ML,
ANCIENT_DUNGEON_VR,
SHIMLOADER,
}

export function GetInstallerIdForLoader(loader: PackageLoader): PackageInstallerId | null {
Expand All @@ -16,6 +18,15 @@ export function GetInstallerIdForLoader(loader: PackageLoader): PackageInstaller
case PackageLoader.MELON_LOADER: return "melonloader";
case PackageLoader.GODOT_ML: return "godotml";
case PackageLoader.NORTHSTAR: return "bepinex";
case PackageLoader.SHIMLOADER: return "shimloader";
case PackageLoader.ANCIENT_DUNGEON_VR: return null;
}
}

export function GetInstallerIdForPlugin(loader: PackageLoader): PackageInstallerId | null {
switch (loader) {
case PackageLoader.SHIMLOADER: return "shimloader-plugin";
}

return null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function buildRunners(runners: PlatformRunnersType): LoaderRunnersType {
[PackageLoader.NORTHSTAR]: runners,
[PackageLoader.ANCIENT_DUNGEON_VR]: runners,
[PackageLoader.GODOT_ML]: runners,
[PackageLoader.SHIMLOADER]: runners,
}
}

Expand Down
14 changes: 13 additions & 1 deletion src/r2mm/installing/ConflictManagementProviderImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ export default class ConflictManagementProviderImpl extends ConflictManagementPr
}
const modState: ModFileTracker = yaml.parse(stateFileContents);
modState.files.forEach(([key, value]) => {
if (mod.isEnabled()) {
// HACK: Never reset UE4SS-settings.ini, ever. Seriously. It should always be enabled.
MythicManiac marked this conversation as resolved.
Show resolved Hide resolved
if (value.toLocaleLowerCase() == "ue4ss-settings.ini") {
overallState.set(value, mod.getName());
} else if (mod.isEnabled()) {
overallState.set(value, mod.getName());
} else {
overallState.set(value + ".manager.disabled", mod.getName());
Expand All @@ -80,6 +83,15 @@ export default class ConflictManagementProviderImpl extends ConflictManagementPr
for (const [key, value] of modFiles.files) {
if (value === file) {
await FileUtils.ensureDirectory(path.dirname(path.join(profile.getPathOfProfile(), file)));

// HACK: Check if UE4SS-settings.ini exists and, if it doesn't, add it. If it does exist, DONT TOUCH.
if (file.toLocaleLowerCase() == "ue4ss-settings.ini") {
if (!await FsProvider.instance.exists(path.join(profile.getPathOfProfile(), file))) {
await FsProvider.instance.copyFile(key, path.join(profile.getPathOfProfile(), file));
}

break;
}
MythicManiac marked this conversation as resolved.
Show resolved Hide resolved
if (await FsProvider.instance.exists(path.join(profile.getPathOfProfile(), file))) {
await FsProvider.instance.unlink(path.join(profile.getPathOfProfile(), file));
}
Expand Down
2 changes: 1 addition & 1 deletion src/r2mm/installing/InstallationRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type CoreRuleType = {

export type RuleSubtype = {
route: string,
trackingMethod: "SUBDIR" | "STATE" | "NONE" | "SUBDIR_NO_FLATTEN" | "PACKAGE_ZIP",
trackingMethod: "SUBDIR" | "STATE" | "NONE" | "SUBDIR_NO_FLATTEN" | "PACKAGE_ZIP" | "SUBDIR_TRACKED",
subRoutes: RuleSubtype[],
defaultFileExtensions: string[],
isDefaultLocation?: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import InstallRules_Subnautica from '../default_installation_rules/game_rules/In
import InstallRules_SubnauticaBZ from '../default_installation_rules/game_rules/InstallRules_SubnauticaBZ';
import InstallRules_Titanfall2 from '../default_installation_rules/game_rules/InstallRules_Titanfall2';
import InstallRules_BONELAB from '../default_installation_rules/game_rules/InstallRules_BONELAB';
import { buildShimloaderRules } from './game_rules/InstallRules_Shimloader';
import { buildBepInExRules } from '../default_installation_rules/game_rules/InstallRules_BepInex';
import * as path from 'path';
import { buildGodotMLRules } from "../default_installation_rules/game_rules/InstallRules_GodotML";
Expand Down Expand Up @@ -119,6 +120,8 @@ export default class InstallationRuleApplicator {
buildBepInExRules("MeepleStation"),
buildBepInExRules("VoidCrew"),
buildBepInExRules("Sailwind"),
buildShimloaderRules("VotV"),
buildShimloaderRules("Palworld"),
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type { CoreRuleType } from '../../InstallationRules';
import * as path from 'path';
import { GAME_NAME } from '../../profile_installers/ModLoaderVariantRecord';
import { RuleSubtype } from "../../InstallationRules";

export function buildShimloaderRules(gameName: GAME_NAME, extraRules?: RuleSubtype[]): CoreRuleType {
return {
gameName: gameName,
relativeFileExclusions: ["manifest.json", "README.md", "icon.png", "LICENCE"],
rules: [
{
route: path.join("shimloader/mod"),
defaultFileExtensions: [".lua"],
trackingMethod: "SUBDIR_TRACKED",
subRoutes: [
{
route: "dll",
defaultFileExtensions: [".dll"],
trackingMethod: "SUBDIR_TRACKED",
subRoutes: [],
}
]
},
{
route: path.join("shimloader/pak"),
defaultFileExtensions: [".pak"],
trackingMethod: "SUBDIR_TRACKED",
subRoutes: [],
},
{
route: path.join("shimloader/cfg"),
defaultFileExtensions: [".cfg"],
trackingMethod: "NONE",
subRoutes: [],
}
]
}
}
Loading