mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-07 06:56:04 +02:00
Fix launch args
This commit is contained in:
+13
-16
@@ -280,24 +280,21 @@ namespace VRCX
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Restarts the VRCX application for an update by launching a new process with the upgrade argument and exiting the current process.
|
/// Restarts the VRCX application for an update by launching a new process with the upgrade argument and exiting the current process.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void RestartApplication()
|
public void RestartApplication(bool isUpgrade)
|
||||||
{
|
{
|
||||||
List<string> args = [ StartupArgs.VrcxLaunchArguements.IsUpgradePrefix ];
|
var args = new List<string>();
|
||||||
|
|
||||||
if (StartupArgs.LaunchArguements.IsDebug == true)
|
if (isUpgrade)
|
||||||
{
|
args.Add(StartupArgs.VrcxLaunchArguments.IsUpgradePrefix);
|
||||||
args.Add(StartupArgs.VrcxLaunchArguements.IsDebugPrefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(StartupArgs.LaunchArguements.ConfigDirectory))
|
if (StartupArgs.LaunchArguments.IsDebug)
|
||||||
{
|
args.Add(StartupArgs.VrcxLaunchArguments.IsDebugPrefix);
|
||||||
args.Add($"{StartupArgs.VrcxLaunchArguements.ConfigDirectoryPrefix}={StartupArgs.LaunchArguements.ConfigDirectory}");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(StartupArgs.LaunchArguements.ProxyUrl))
|
if (!string.IsNullOrWhiteSpace(StartupArgs.LaunchArguments.ConfigDirectory))
|
||||||
{
|
args.Add($"{StartupArgs.VrcxLaunchArguments.ConfigDirectoryPrefix}={StartupArgs.LaunchArguments.ConfigDirectory}");
|
||||||
args.Add($"{StartupArgs.VrcxLaunchArguements.ProxyUrlPrefix}={StartupArgs.LaunchArguements.ProxyUrl}");
|
|
||||||
}
|
if (!string.IsNullOrWhiteSpace(StartupArgs.LaunchArguments.ProxyUrl))
|
||||||
|
args.Add($"{StartupArgs.VrcxLaunchArguments.ProxyUrlPrefix}={StartupArgs.LaunchArguments.ProxyUrl}");
|
||||||
|
|
||||||
var vrcxProcess = new Process
|
var vrcxProcess = new Process
|
||||||
{
|
{
|
||||||
@@ -379,8 +376,8 @@ namespace VRCX
|
|||||||
/// <returns>The launch command.</returns>
|
/// <returns>The launch command.</returns>
|
||||||
public string GetLaunchCommand()
|
public string GetLaunchCommand()
|
||||||
{
|
{
|
||||||
var command = StartupArgs.LaunchArguements.LaunchCommand;
|
var command = StartupArgs.LaunchArguments.LaunchCommand;
|
||||||
StartupArgs.LaunchArguements.LaunchCommand = string.Empty;
|
StartupArgs.LaunchArguments.LaunchCommand = string.Empty;
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,13 +59,14 @@ namespace VRCX
|
|||||||
|
|
||||||
if (Program.LaunchDebug)
|
if (Program.LaunchDebug)
|
||||||
{
|
{
|
||||||
// it's dead fuck https://github.com/chromiumembedded/cef/issues/3740
|
// chrome://inspect/#devices
|
||||||
|
// Discover network targets, Configure...
|
||||||
|
// Add Remote Target: localhost:8089
|
||||||
logger.Info("Debug mode enabled");
|
logger.Info("Debug mode enabled");
|
||||||
cefSettings.RemoteDebuggingPort = 8089;
|
cefSettings.RemoteDebuggingPort = 8089;
|
||||||
cefSettings.CefCommandLineArgs["remote-allow-origins"] = "*";
|
cefSettings.CefCommandLineArgs["remote-allow-origins"] = "*";
|
||||||
}
|
}
|
||||||
|
|
||||||
//CefSharpSettings.WcfEnabled = true; // TOOD: REMOVE THIS LINE YO (needed for synchronous configRepository)
|
|
||||||
CefSharpSettings.ShutdownOnExit = false;
|
CefSharpSettings.ShutdownOnExit = false;
|
||||||
CefSharpSettings.ConcurrentTaskExecution = true;
|
CefSharpSettings.ConcurrentTaskExecution = true;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -120,7 +120,7 @@ namespace VRCX
|
|||||||
MessageBox.Show(
|
MessageBox.Show(
|
||||||
"vc_redist has finished installing, if the issue persists upon next restart, please reinstall VRCX From GitHub,\nVRCX Will now restart.", "vc_redist installation complete", MessageBoxButtons.OK);
|
"vc_redist has finished installing, if the issue persists upon next restart, please reinstall VRCX From GitHub,\nVRCX Will now restart.", "vc_redist installation complete", MessageBoxButtons.OK);
|
||||||
Thread.Sleep(5000);
|
Thread.Sleep(5000);
|
||||||
AppApi.Instance.RestartApplication();
|
AppApi.Instance.RestartApplication(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DialogResult.No:
|
case DialogResult.No:
|
||||||
|
|||||||
+35
-41
@@ -18,7 +18,7 @@ namespace VRCX
|
|||||||
{
|
{
|
||||||
internal class StartupArgs
|
internal class StartupArgs
|
||||||
{
|
{
|
||||||
public static VrcxLaunchArguements LaunchArguements = new();
|
public static VrcxLaunchArguments LaunchArguments = new();
|
||||||
|
|
||||||
public static void ArgsCheck()
|
public static void ArgsCheck()
|
||||||
{
|
{
|
||||||
@@ -27,60 +27,57 @@ namespace VRCX
|
|||||||
Debug.Assert(Program.LaunchDebug = true);
|
Debug.Assert(Program.LaunchDebug = true);
|
||||||
|
|
||||||
var currentProcessArgs = ParseArgs(args);
|
var currentProcessArgs = ParseArgs(args);
|
||||||
LaunchArguements = currentProcessArgs;
|
LaunchArguments = currentProcessArgs;
|
||||||
|
|
||||||
if (LaunchArguements.IsDebug)
|
if (LaunchArguments.IsDebug)
|
||||||
Program.LaunchDebug = true;
|
Program.LaunchDebug = true;
|
||||||
|
|
||||||
if (LaunchArguements.ConfigDirectory != null)
|
if (LaunchArguments.ConfigDirectory != null)
|
||||||
{
|
{
|
||||||
if (File.Exists(LaunchArguements.ConfigDirectory))
|
if (File.Exists(LaunchArguments.ConfigDirectory))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Move your \"VRCX.sqlite3\" into a folder then specify the folder in the launch parameter e.g.\n--config=\"C:\\VRCX\\\"", "--config is now a directory", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Move your \"VRCX.sqlite3\" into a folder then specify the folder in the launch parameter e.g.\n--config=\"C:\\VRCX\\\"", "--config is now a directory", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Program.AppDataDirectory = LaunchArguements.ConfigDirectory;
|
Program.AppDataDirectory = LaunchArguments.ConfigDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
var disableClosing = false;
|
var disableClosing = LaunchArguments.IsUpgrade || // we're upgrading, allow it
|
||||||
|
!string.IsNullOrEmpty(CommandLineArgsParser.GetArgumentValue(args, CefSharpArguments.SubProcessTypeArgument)); // we're launching a subprocess, allow it
|
||||||
if (LaunchArguements.IsUpgrade || // we're upgrading, allow it
|
|
||||||
!string.IsNullOrEmpty(CommandLineArgsParser.GetArgumentValue(args, CefSharpArguments.SubProcessTypeArgument))) // we're launching a subprocess, allow it
|
|
||||||
disableClosing = true;
|
|
||||||
|
|
||||||
// if we're launching a second instance with same config directory, focus the first instance then exit
|
// if we're launching a second instance with same config directory, focus the first instance then exit
|
||||||
if (!disableClosing && IsDuplicateProcessRunning(LaunchArguements))
|
if (!disableClosing && IsDuplicateProcessRunning(LaunchArguments))
|
||||||
{
|
{
|
||||||
IPCToMain();
|
IPCToMain();
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static VrcxLaunchArguements ParseArgs(string[] args)
|
private static VrcxLaunchArguments ParseArgs(string[] args)
|
||||||
{
|
{
|
||||||
VrcxLaunchArguements arguements = new VrcxLaunchArguements();
|
var arguments = new VrcxLaunchArguments();
|
||||||
foreach (var arg in args)
|
foreach (var arg in args)
|
||||||
{
|
{
|
||||||
if (arg == VrcxLaunchArguements.IsUpgradePrefix)
|
if (arg == VrcxLaunchArguments.IsUpgradePrefix)
|
||||||
arguements.IsUpgrade = true;
|
arguments.IsUpgrade = true;
|
||||||
|
|
||||||
if (arg.StartsWith(VrcxLaunchArguements.IsDebugPrefix))
|
if (arg.StartsWith(VrcxLaunchArguments.IsDebugPrefix))
|
||||||
arguements.IsDebug = true;
|
arguments.IsDebug = true;
|
||||||
|
|
||||||
if (arg.StartsWith(VrcxLaunchArguements.LaunchCommandPrefix) && arg.Length > VrcxLaunchArguements.LaunchCommandPrefix.Length)
|
if (arg.StartsWith(VrcxLaunchArguments.LaunchCommandPrefix) && arg.Length > VrcxLaunchArguments.LaunchCommandPrefix.Length)
|
||||||
arguements.LaunchCommand = arg.Substring(VrcxLaunchArguements.LaunchCommandPrefix.Length);
|
arguments.LaunchCommand = arg.Substring(VrcxLaunchArguments.LaunchCommandPrefix.Length);
|
||||||
|
|
||||||
if (arg.StartsWith(VrcxLaunchArguements.ConfigDirectoryPrefix) && arg.Length > VrcxLaunchArguements.ConfigDirectoryPrefix.Length)
|
if (arg.StartsWith(VrcxLaunchArguments.ConfigDirectoryPrefix) && arg.Length > VrcxLaunchArguments.ConfigDirectoryPrefix.Length)
|
||||||
arguements.ConfigDirectory = arg.Substring(VrcxLaunchArguements.ConfigDirectoryPrefix.Length + 1);
|
arguments.ConfigDirectory = arg.Substring(VrcxLaunchArguments.ConfigDirectoryPrefix.Length + 1);
|
||||||
|
|
||||||
if (arg.StartsWith(VrcxLaunchArguements.ProxyUrlPrefix) && arg.Length > VrcxLaunchArguements.ProxyUrlPrefix.Length)
|
if (arg.StartsWith(VrcxLaunchArguments.ProxyUrlPrefix) && arg.Length > VrcxLaunchArguments.ProxyUrlPrefix.Length)
|
||||||
arguements.ProxyUrl = arg.Substring(VrcxLaunchArguements.ProxyUrlPrefix.Length + 1).Replace("'", string.Empty).Replace("\"", string.Empty);
|
arguments.ProxyUrl = arg.Substring(VrcxLaunchArguments.ProxyUrlPrefix.Length + 1).Replace("'", string.Empty).Replace("\"", string.Empty);
|
||||||
}
|
}
|
||||||
return arguements;
|
return arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class VrcxLaunchArguements
|
internal class VrcxLaunchArguments
|
||||||
{
|
{
|
||||||
public const string IsUpgradePrefix = "/Upgrade";
|
public const string IsUpgradePrefix = "/Upgrade";
|
||||||
public bool IsUpgrade { get; set; } = false;
|
public bool IsUpgrade { get; set; } = false;
|
||||||
@@ -98,7 +95,7 @@ namespace VRCX
|
|||||||
public string ProxyUrl { get; set; } = null;
|
public string ProxyUrl { get; set; } = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IsDuplicateProcessRunning(VrcxLaunchArguements launchArguements)
|
private static bool IsDuplicateProcessRunning(VrcxLaunchArguments launchArguments)
|
||||||
{
|
{
|
||||||
var processes = Process.GetProcessesByName("VRCX")
|
var processes = Process.GetProcessesByName("VRCX")
|
||||||
.Where(x => x.Id != Environment.ProcessId);
|
.Where(x => x.Id != Environment.ProcessId);
|
||||||
@@ -109,27 +106,24 @@ namespace VRCX
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var searcher = new ManagementObjectSearcher("SELECT CommandLine FROM Win32_Process WHERE ProcessId = " + process.Id))
|
using var searcher = new ManagementObjectSearcher("SELECT CommandLine FROM Win32_Process WHERE ProcessId = " + process.Id);
|
||||||
|
using var objects = searcher.Get();
|
||||||
|
commandLine =
|
||||||
|
objects.Cast<ManagementBaseObject>().SingleOrDefault()?["CommandLine"]?.ToString() ??
|
||||||
|
string.Empty;
|
||||||
|
}
|
||||||
|
catch
|
||||||
{
|
{
|
||||||
using (var objects = searcher.Get())
|
// ignored
|
||||||
{
|
|
||||||
commandLine = objects.Cast<ManagementBaseObject>().SingleOrDefault()?["CommandLine"]?.ToString() ?? string.Empty;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
|
|
||||||
if (commandLine.Contains(CefSharpArguments.SubProcessTypeArgument)) // ignore subprocesses
|
if (commandLine.Contains(CefSharpArguments.SubProcessTypeArgument)) // ignore subprocesses
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
var processArguements = ParseArgs(commandLine.Split(' '));
|
var processArguments = ParseArgs(commandLine.Split(' '));
|
||||||
if (processArguements.ConfigDirectory == launchArguements.ConfigDirectory)
|
if (processArguments.ConfigDirectory == launchArguments.ConfigDirectory)
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -142,7 +136,7 @@ namespace VRCX
|
|||||||
|
|
||||||
if (ipcClient.IsConnected)
|
if (ipcClient.IsConnected)
|
||||||
{
|
{
|
||||||
var buffer = Encoding.UTF8.GetBytes($"{{\"type\":\"LaunchCommand\",\"command\":\"{LaunchArguements.LaunchCommand}\"}}" + (char)0x00);
|
var buffer = Encoding.UTF8.GetBytes($"{{\"type\":\"LaunchCommand\",\"command\":\"{LaunchArguments.LaunchCommand}\"}}" + (char)0x00);
|
||||||
ipcClient.BeginWrite(buffer, 0, buffer.Length, IPCClient.Close, ipcClient);
|
ipcClient.BeginWrite(buffer, 0, buffer.Length, IPCClient.Close, ipcClient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -59,8 +59,8 @@ namespace VRCX
|
|||||||
|
|
||||||
private void SetProxy()
|
private void SetProxy()
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(StartupArgs.LaunchArguements.ProxyUrl))
|
if (!string.IsNullOrEmpty(StartupArgs.LaunchArguments.ProxyUrl))
|
||||||
ProxyUrl = StartupArgs.LaunchArguements.ProxyUrl;
|
ProxyUrl = StartupArgs.LaunchArguments.ProxyUrl;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(ProxyUrl))
|
if (string.IsNullOrEmpty(ProxyUrl))
|
||||||
{
|
{
|
||||||
|
|||||||
+13
-4
@@ -2920,6 +2920,10 @@ speechSynthesis.getVoices();
|
|||||||
break retryLoop;
|
break retryLoop;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
if (!API.currentUser.isLoggedIn) {
|
||||||
|
console.error(`User isn't logged in`);
|
||||||
|
break mainLoop;
|
||||||
|
}
|
||||||
if (err?.message?.includes('Not Found')) {
|
if (err?.message?.includes('Not Found')) {
|
||||||
console.error('Awful workaround for awful VRC API bug');
|
console.error('Awful workaround for awful VRC API bug');
|
||||||
break retryLoop;
|
break retryLoop;
|
||||||
@@ -25070,7 +25074,11 @@ speechSynthesis.getVoices();
|
|||||||
case -16:
|
case -16:
|
||||||
if (this.downloadCurrent.ref.id === 'VRCXUpdate') {
|
if (this.downloadCurrent.ref.id === 'VRCXUpdate') {
|
||||||
if (this.downloadCurrent.autoInstall) {
|
if (this.downloadCurrent.autoInstall) {
|
||||||
workerTimers.setTimeout(() => this.restartVRCX(), 2000);
|
var isUpgrade = true;
|
||||||
|
workerTimers.setTimeout(
|
||||||
|
() => this.restartVRCX(isUpgrade),
|
||||||
|
2000
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
this.downloadDialog.visible = false;
|
this.downloadDialog.visible = false;
|
||||||
this.pendingVRCXInstall = this.downloadCurrent.ref.name;
|
this.pendingVRCXInstall = this.downloadCurrent.ref.name;
|
||||||
@@ -26202,8 +26210,8 @@ speechSynthesis.getVoices();
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$app.methods.restartVRCX = function () {
|
$app.methods.restartVRCX = function (isUpgrade) {
|
||||||
AppApi.RestartApplication();
|
AppApi.RestartApplication(isUpgrade);
|
||||||
};
|
};
|
||||||
|
|
||||||
$app.methods.loadBranchVersions = async function () {
|
$app.methods.loadBranchVersions = async function () {
|
||||||
@@ -34005,7 +34013,8 @@ speechSynthesis.getVoices();
|
|||||||
workerTimers.setTimeout(resolve, 100);
|
workerTimers.setTimeout(resolve, 100);
|
||||||
});
|
});
|
||||||
if (action === 'confirm') {
|
if (action === 'confirm') {
|
||||||
AppApi.RestartApplication();
|
var isUpgrade = false;
|
||||||
|
this.restartVRCX(isUpgrade);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user