mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-11 13:56:16 +00:00
feat: automatically adding wine prefix
This commit is contained in:
@@ -61,36 +61,30 @@ const createSteamShortcut = async (
|
||||
return;
|
||||
}
|
||||
|
||||
const icon = await downloadAsset(
|
||||
path.join(
|
||||
SystemPath.getPath("userData"),
|
||||
"Icons",
|
||||
`${game.shop}-${game.objectId}.ico`
|
||||
),
|
||||
assets?.iconUrl
|
||||
);
|
||||
|
||||
const newShortcut = composeSteamShortcut(
|
||||
game.title,
|
||||
game.executablePath,
|
||||
icon
|
||||
);
|
||||
|
||||
for (const steamUserId of steamUserIds) {
|
||||
logger.info("Adding shortcut for Steam user", steamUserId);
|
||||
|
||||
const steamShortcuts = await getSteamShortcuts(steamUserId);
|
||||
|
||||
if (
|
||||
steamShortcuts.some(
|
||||
(shortcut) =>
|
||||
shortcut.Exe === game.executablePath &&
|
||||
shortcut.appname === game.title
|
||||
)
|
||||
) {
|
||||
if (steamShortcuts.some((shortcut) => shortcut.appname === game.title)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const icon = await downloadAsset(
|
||||
path.join(
|
||||
SystemPath.getPath("userData"),
|
||||
"Icons",
|
||||
`${game.shop}-${game.objectId}.ico`
|
||||
),
|
||||
assets?.iconUrl
|
||||
);
|
||||
|
||||
const newShortcut = composeSteamShortcut(
|
||||
game.title,
|
||||
game.executablePath,
|
||||
icon
|
||||
);
|
||||
|
||||
const gridPath = path.join(
|
||||
await getSteamLocation(),
|
||||
"userdata",
|
||||
@@ -127,6 +121,26 @@ const createSteamShortcut = async (
|
||||
|
||||
await writeSteamShortcuts(steamUserId, steamShortcuts);
|
||||
}
|
||||
|
||||
if (process.platform === "linux" && !game.winePrefixPath) {
|
||||
const steamWinePrefixes = path.join(
|
||||
SystemPath.getPath("home"),
|
||||
".local",
|
||||
"share",
|
||||
"Steam",
|
||||
"steamapps",
|
||||
"compatdata"
|
||||
);
|
||||
|
||||
await gamesSublevel.put(gameKey, {
|
||||
...game,
|
||||
winePrefixPath: path.join(
|
||||
steamWinePrefixes,
|
||||
newShortcut.appid.toString(),
|
||||
"pfx"
|
||||
),
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -16,11 +16,7 @@ const getDefaultWinePrefixSelectionPath = async (
|
||||
"compatdata"
|
||||
);
|
||||
|
||||
if (fs.existsSync(steamWinePrefixes)) {
|
||||
return fs.promises.realpath(steamWinePrefixes);
|
||||
}
|
||||
|
||||
return null;
|
||||
return await fs.promises.realpath(steamWinePrefixes);
|
||||
} catch (err) {
|
||||
logger.error("Failed to get default wine prefix selection path", err);
|
||||
|
||||
|
||||
@@ -119,6 +119,8 @@ export function GameOptionsModal({
|
||||
t("create_shortcut_success"),
|
||||
t("you_might_need_to_restart_steam")
|
||||
);
|
||||
|
||||
updateGame();
|
||||
} catch (error: unknown) {
|
||||
logger.error("Failed to create Steam shortcut", error);
|
||||
showErrorToast(t("create_shortcut_error"));
|
||||
@@ -162,9 +164,12 @@ export function GameOptionsModal({
|
||||
};
|
||||
|
||||
const handleChangeWinePrefixPath = async () => {
|
||||
const defaultPath =
|
||||
await window.electron.getDefaultWinePrefixSelectionPath();
|
||||
|
||||
const { filePaths } = await window.electron.showOpenDialog({
|
||||
properties: ["openDirectory"],
|
||||
defaultPath: await window.electron.getDefaultWinePrefixSelectionPath(),
|
||||
defaultPath: defaultPath ?? game?.winePrefixPath ?? "",
|
||||
});
|
||||
|
||||
if (filePaths && filePaths.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user