launch through Steam (fixes #89)

This commit is contained in:
pypy
2020-10-25 18:29:22 +09:00
parent c0f2a87817
commit e9f65f4868
2 changed files with 30 additions and 3 deletions
+29 -2
View File
@@ -75,12 +75,39 @@ namespace VRCX
public void StartGame(string arguments) public void StartGame(string arguments)
{ {
// try stream first
try
{
using (var key = Registry.ClassesRoot.OpenSubKey(@"steam\shell\open\command"))
{
// "C:\Program Files (x86)\Steam\steam.exe" -- "%1"
var match = Regex.Match(key.GetValue(string.Empty) as string, "^\"(.+?)\\\\steam.exe\"");
if (match.Success)
{
var path = match.Groups[1].Value;
var _arguments = Uri.EscapeDataString(arguments);
Process.Start(new ProcessStartInfo
{
WorkingDirectory = path,
FileName = path + "\\steam.exe",
UseShellExecute = false,
Arguments = $"-- \"steam://rungameid/438100//{_arguments}\""
}).Close();
return;
}
}
}
catch
{
}
// fallback
try try
{ {
using (var key = Registry.ClassesRoot.OpenSubKey(@"VRChat\shell\open\command")) using (var key = Registry.ClassesRoot.OpenSubKey(@"VRChat\shell\open\command"))
{ {
// "C:\Program Files (x86)\Steam\steamapps\common\VRChat\launch.bat" "C:\Program Files (x86)\Steam\steamapps\common\VRChat" "%1" // "C:\Program Files (x86)\Steam\steamapps\common\VRChat\launch.bat" "C:\Program Files (x86)\Steam\steamapps\common\VRChat" "%1"
var match = Regex.Match(key.GetValue(string.Empty) as string, "^\"(.+\\\\VRChat)\\\\launch.bat\""); var match = Regex.Match(key.GetValue(string.Empty) as string, "^\"(.+?)\\\\launch.bat\"");
if (match.Success) if (match.Success)
{ {
var path = match.Groups[1].Value; var path = match.Groups[1].Value;
@@ -89,7 +116,7 @@ namespace VRCX
WorkingDirectory = path, WorkingDirectory = path,
FileName = path + "\\VRChat.exe", FileName = path + "\\VRChat.exe",
UseShellExecute = false, UseShellExecute = false,
Arguments = arguments Arguments = $"\"{arguments}\""
}).Close(); }).Close();
} }
} }
+1 -1
View File
@@ -7259,7 +7259,7 @@ CefSharp.BindObjectAsync(
}; };
$app.methods.locationToLaunchArg = function (location) { $app.methods.locationToLaunchArg = function (location) {
return `"vrchat://launch?id=${location}"`; return `vrchat://launch?id=${location}`;
} }
$app.methods.launchGame = function (...args) { $app.methods.launchGame = function (...args) {