Files
VRCX/Program.cs
Teacup 24f1a57c5d 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>
2023-05-13 22:26:29 +12:00

116 lines
3.9 KiB
C#

// Copyright(c) 2019-2022 pypy, Natsumi and individual contributors.
// All rights reserved.
//
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://opensource.org/licenses/MIT>.
using System;
using System.IO;
using System.Windows.Forms;
namespace VRCX
{
public static class Program
{
public static string BaseDirectory { get; private set; }
public static string AppDataDirectory { get; private set; }
public static string ConfigLocation;
public static string Version { get; private set; }
public static bool LaunchDebug;
public static bool GPUFix;
static Program()
{
BaseDirectory = AppDomain.CurrentDomain.BaseDirectory;
AppDataDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "VRCX");
ConfigLocation = Path.Combine(Program.AppDataDirectory, "VRCX.sqlite3");
if (!Directory.Exists(AppDataDirectory))
{
Directory.CreateDirectory(AppDataDirectory);
// Migrate config to AppData
if (File.Exists(Path.Combine(BaseDirectory, "VRCX.json")))
{
File.Move(Path.Combine(BaseDirectory, "VRCX.json"), Path.Combine(AppDataDirectory, "VRCX.json"));
File.Copy(Path.Combine(AppDataDirectory, "VRCX.json"), Path.Combine(AppDataDirectory, "VRCX-backup.json"));
}
if (File.Exists(Path.Combine(BaseDirectory, "VRCX.sqlite3")))
{
File.Move(Path.Combine(BaseDirectory, "VRCX.sqlite3"), Path.Combine(AppDataDirectory, "VRCX.sqlite3"));
File.Copy(Path.Combine(AppDataDirectory, "VRCX.sqlite3"), Path.Combine(AppDataDirectory, "VRCX-backup.sqlite3"));
}
}
}
[STAThread]
private static void Main()
{
try
{
Run();
}
catch (Exception e)
{
MessageBox.Show(e.ToString(), "PLEASE REPORT IN https://vrcx.pypy.moe/discord", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(0);
}
}
private static void GetVersion()
{
var buildName = "VRCX";
try
{
Version = $"{buildName} {File.ReadAllText(Path.Combine(BaseDirectory, "Version"))}";
}
catch (Exception)
{
Version = $"{buildName} Build";
}
}
private static void Run()
{
Update.Check();
StartupArgs.ArgsCheck();
GetVersion();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
ProcessMonitor.Instance.Init();
SQLite.Instance.Init();
VRCXStorage.Load();
LoadFromConfig();
CpuMonitor.Instance.Init();
Discord.Instance.Init();
WebApi.Instance.Init();
LogWatcher.Instance.Init();
AutoAppLaunchManager.Instance.Init();
CefService.Instance.Init();
IPCServer.Instance.Init();
VRCXVR.Instance.Init();
Application.Run(new MainForm());
WebApi.Instance.SaveCookies();
VRCXVR.Instance.Exit();
CefService.Instance.Exit();
AutoAppLaunchManager.Instance.Exit();
LogWatcher.Instance.Exit();
WebApi.Instance.Exit();
Discord.Instance.Exit();
CpuMonitor.Instance.Exit();
VRCXStorage.Save();
SQLite.Instance.Exit();
ProcessMonitor.Instance.Exit();
}
private static void LoadFromConfig()
{
if (!GPUFix)
GPUFix = VRCXStorage.Instance.Get("VRCX_GPUFix") == "true";
}
}
}