mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-05 06:16:05 +02:00
Add applauncher settings, refactor some pug code (#544)
* fix(.NET): Stop CheckGameRunning from force checking processes I'm not really sure what I was thinking when I did that the way I did; They are not supposed to force check if they're closed after the first time...That's what the monitor is for. * feat(.NET): Add optional child process culling, clean up applauncher Add an AppApi method to set applauncher settings Enabled/KillChildrenOnExit Refactor repeated applauncher event code, move into methods * refactor: Move the pug code for every tab into its own file * refactor: Add PoC mixins to settings.pug ^& add comments for navigation Some proof of concept replacements of the categories, switches and a radio group in the General settings seection. Also added comments for each header-separated section for marginally better navigation of the file. * refactor: Move the login page to its own file * fix(.NET): Correct wrong variable being set in SetAppLauncherSettings * fix(.NET): Remove redundant/exception causing process refresh in monitor * refactor(.NET): Allow launcher to be disabled; Disabled by default. * refactor: Change screenshot helper default to true * feat: Expose new app launcher settings, add new settings category Translation keys added/removed: + view.settings.advanced.advanced.app_launcher.header + view.settings.advanced.advanced.app_launcher.folder_tooltip + view.settings.advanced.advanced.app_launcher.enable + view.settings.advanced.advanced.app_launcher.auto_close - view.settings.advanced.advanced.auto_launch - view.settings.advanced.advanced.auto_launch_tooltip * Add GPU Fix and Udon Exception Logging options, unload favorites tab when not in use * Fix GPUFix typo * Fix GPUFix typo 1 * Add logging for AVPro streams without usharp videoplayer * Lint --------- Co-authored-by: Natsumi <cmcooper123@hotmail.com>
This commit is contained in:
+70
-32
@@ -12,19 +12,23 @@ namespace VRCX
|
||||
public class AutoAppLaunchManager
|
||||
{
|
||||
public static AutoAppLaunchManager Instance { get; private set; }
|
||||
public bool Enabled = true;
|
||||
public static readonly string VRChatProcessName = "VRChat";
|
||||
|
||||
public bool Enabled = false;
|
||||
/// <summary> Whether or not to kill child processes when VRChat closes. </summary>
|
||||
public bool KillChildrenOnExit = true;
|
||||
public readonly string AppShortcutDirectory;
|
||||
|
||||
private DateTime startTime = DateTime.Now;
|
||||
private List<Process> startedProcesses = new List<Process>();
|
||||
private Dictionary<string, Process> startedProcesses = new Dictionary<string, Process>();
|
||||
private static readonly byte[] shortcutSignatureBytes = { 0x4C, 0x00, 0x00, 0x00 }; // signature for ShellLinkHeader\
|
||||
|
||||
static AutoAppLaunchManager()
|
||||
static AutoAppLaunchManager()
|
||||
{
|
||||
Instance = new AutoAppLaunchManager();
|
||||
}
|
||||
|
||||
public AutoAppLaunchManager()
|
||||
public AutoAppLaunchManager()
|
||||
{
|
||||
AppShortcutDirectory = Path.Combine(Program.AppDataDirectory, "startup");
|
||||
|
||||
@@ -39,11 +43,41 @@ namespace VRCX
|
||||
|
||||
private void OnProcessExited(MonitoredProcess monitoredProcess)
|
||||
{
|
||||
if (startedProcesses.Count == 0 || !monitoredProcess.HasName("VRChat"))
|
||||
if (startedProcesses.Count == 0 || !monitoredProcess.HasName(VRChatProcessName))
|
||||
return;
|
||||
|
||||
foreach (var process in startedProcesses)
|
||||
if (KillChildrenOnExit)
|
||||
KillChildProcesses();
|
||||
}
|
||||
|
||||
private void OnProcessStarted(MonitoredProcess monitoredProcess)
|
||||
{
|
||||
if (!Enabled || !monitoredProcess.HasName(VRChatProcessName) || monitoredProcess.Process.StartTime < startTime)
|
||||
return;
|
||||
|
||||
if (KillChildrenOnExit)
|
||||
KillChildProcesses();
|
||||
|
||||
var shortcutFiles = FindShortcutFiles(AppShortcutDirectory);
|
||||
|
||||
foreach (var file in shortcutFiles)
|
||||
{
|
||||
if (!IsChildProcessRunning(file))
|
||||
{
|
||||
StartChildProcess(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kills all running child processes.
|
||||
/// </summary>
|
||||
internal void KillChildProcesses()
|
||||
{
|
||||
foreach (var pair in startedProcesses)
|
||||
{
|
||||
var process = pair.Value;
|
||||
|
||||
if (!process.HasExited)
|
||||
process.Kill();
|
||||
}
|
||||
@@ -51,32 +85,40 @@ namespace VRCX
|
||||
startedProcesses.Clear();
|
||||
}
|
||||
|
||||
private void OnProcessStarted(MonitoredProcess monitoredProcess)
|
||||
/// <summary>
|
||||
/// Starts a new child process.
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
internal void StartChildProcess(string path)
|
||||
{
|
||||
if (!monitoredProcess.HasName("VRChat") || monitoredProcess.Process.StartTime < startTime)
|
||||
return;
|
||||
var process = Process.Start(path);
|
||||
startedProcesses.Add(path, process);
|
||||
}
|
||||
|
||||
if (startedProcesses.Count > 0)
|
||||
/// <summary>
|
||||
/// Updates the child processes list.
|
||||
/// Removes any processes that have exited.
|
||||
/// </summary>
|
||||
internal void UpdateChildProcesses()
|
||||
{
|
||||
foreach (var pair in startedProcesses.ToList())
|
||||
{
|
||||
foreach (var process in startedProcesses)
|
||||
{
|
||||
if (!process.HasExited)
|
||||
process.Kill();
|
||||
}
|
||||
|
||||
startedProcesses.Clear();
|
||||
var process = pair.Value;
|
||||
if (process.HasExited)
|
||||
startedProcesses.Remove(pair.Key);
|
||||
}
|
||||
}
|
||||
|
||||
var shortcutFiles = FindShortcutFiles(AppShortcutDirectory);
|
||||
|
||||
if (shortcutFiles.Length > 0)
|
||||
{
|
||||
foreach (var file in shortcutFiles)
|
||||
{
|
||||
var process = Process.Start(file);
|
||||
startedProcesses.Add(process);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Checks to see if a given file matches a current running child process.
|
||||
/// </summary>
|
||||
/// <param name="path">The path.</param>
|
||||
/// <returns>
|
||||
/// <c>true</c> if child process running; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
internal bool IsChildProcessRunning(string path)
|
||||
{
|
||||
return startedProcesses.ContainsKey(path);
|
||||
}
|
||||
|
||||
internal void Init()
|
||||
@@ -88,11 +130,7 @@ namespace VRCX
|
||||
{
|
||||
Enabled = false;
|
||||
|
||||
foreach (var process in startedProcesses)
|
||||
{
|
||||
if (!process.HasExited)
|
||||
process.Kill();
|
||||
}
|
||||
KillChildProcesses();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user