Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
float3 committed Feb 25, 2022
0 parents commit c034c5d
Show file tree
Hide file tree
Showing 12 changed files with 585 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bin/
obj/
/packages/
riderModule.iml
/_ReSharper.Caches/
16 changes: 16 additions & 0 deletions VRCLauncher.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VRCLauncher", "VRCLauncher\VRCLauncher.csproj", "{80B0E6EE-8824-4981-9331-9C36BCAE6343}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{80B0E6EE-8824-4981-9331-9C36BCAE6343}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{80B0E6EE-8824-4981-9331-9C36BCAE6343}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80B0E6EE-8824-4981-9331-9C36BCAE6343}.Release|Any CPU.ActiveCfg = Release|Any CPU
{80B0E6EE-8824-4981-9331-9C36BCAE6343}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
2 changes: 2 additions & 0 deletions VRCLauncher.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/CodeAnnotations/NamespacesWithAnnotations/=VRCLauncher_002EAnnotations/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
8 changes: 8 additions & 0 deletions VRCLauncher/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Application x:Class="VRCLauncher.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="View/MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
15 changes: 15 additions & 0 deletions VRCLauncher/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Threading.Tasks;
using System.Windows;

namespace VRCLauncher
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
9 changes: 9 additions & 0 deletions VRCLauncher/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Windows;

[assembly: ThemeInfo(ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
123 changes: 123 additions & 0 deletions VRCLauncher/Model/Config.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text.Json;
using System.Windows;
using Microsoft.Win32;

// ReSharper disable InconsistentNaming

namespace VRCLauncher.Model
{
public class Config
{
static string AppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\3\\VRCLauncher";

//private static string ExpandedUserFolderPath = Environment.ExpandEnvironmentVariables(@"%AppData%\..\LocalLow\VRCLauncher");
//private static string _VRChatLocation = FindVRCexePath();
//public string GetLocalResourcePath(string path) => Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + path;

public bool NoVR { get; set; }
public int FPS { get; set; }
public bool LegacyFBTCalibrate { get; set; }
public int Profile { get; set; }
public bool WatchWorlds { get; set; }
public bool WatchAvatars { get; set; }
public bool Fullscreen { get; set; }
public int Width { get; set; }
public int Height { get; set; }
public bool UdonDebugLogging { get; set; }
public bool DebugGUI { get; set; }
public bool SDKLogLevels { get; set; }
public string MidiDevice { get; set; }
public string OSCPorts { get; set; }

public Config()
{
NoVR = false;
FPS = 90;
LegacyFBTCalibrate = false;
Profile = 0;
WatchWorlds = false;
WatchAvatars = false;
Fullscreen = true;
Width = 0;
Height = 0;
UdonDebugLogging = false;
DebugGUI = false;
SDKLogLevels = false;
MidiDevice = "";
OSCPorts = "";
}

// ReSharper disable once IdentifierTypo
public static string FindVRCexePath()
{
try
{
return Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App " + 438100).GetValue("InstallLocation").ToString();
}
catch
{
MessageBox.Show("Error - Registry entry not present or null");
throw new Exception("VRChat not installed through steam");
}
}

public void Save()
{
if (!Directory.Exists(AppDataPath)) Directory.CreateDirectory(AppDataPath);

string json = JsonSerializer.Serialize(this);
File.WriteAllText(AppDataPath + "\\config.json", json);
}

public static Config Load()
{
if (File.Exists(AppDataPath + "\\config.json"))
{
string json = File.ReadAllText(AppDataPath + "\\config.json");
return JsonSerializer.Deserialize<Config>(json)!;
}
else
{
return new Config();
}
}

public List<string> GetArgs()
{
List<string> args = new();
if (NoVR) args.Add("--no-vr");

args.Add("--fps=" + FPS);

if (LegacyFBTCalibrate) args.Add("--legacy-fbt-calibrate");

args.Add("-profile=" + Profile);

if (WatchWorlds) args.Add("--watch-worlds");

if (WatchAvatars) args.Add("--watch-avatars");

if (UdonDebugLogging) args.Add("--enable-udon-debug-logging");

if (DebugGUI) args.Add("--enable-debug-gui");

if (SDKLogLevels) args.Add("--enable-sdk-log-levels");

if (Fullscreen) args.Add("-screen-fullscreen 1");

if (Width != 0) args.Add("-screen-width " + Width);

if (Height != 0) args.Add("-screen-height " + Height);

if (MidiDevice != "") args.Add("-midi=" + MidiDevice);

if (OSCPorts != "") args.Add("-osc-ports=" + OSCPorts);

return args;
}
}
}
10 changes: 10 additions & 0 deletions VRCLauncher/VRCLauncher.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>

</Project>
2 changes: 2 additions & 0 deletions VRCLauncher/VRCLauncher.csproj.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=mvvm/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
121 changes: 121 additions & 0 deletions VRCLauncher/View/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<Window x:Class="VRCLauncher.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<GroupBox Header="Main" Margin="10" Padding="10" Grid.Row="0" Grid.Column="0">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="--no-vr" />
<ToggleButton IsChecked="{Binding NoVR}" Width="15" Height="15" />
</StackPanel>

<StackPanel Orientation="Horizontal">
<Label Content="--fps=" />
<TextBox Text="{Binding FPS}" Width="25" TextAlignment="Center" HorizontalContentAlignment="Center"
HorizontalAlignment="Center" VerticalAlignment="Center" />
</StackPanel>

<StackPanel Orientation="Horizontal">
<Label Content="--legacy-fbt-calibrate" />
<ToggleButton IsChecked="{Binding LegacyFBTCalibrate}" Width="15" Height="15" />
</StackPanel>

<StackPanel Orientation="Horizontal">
<Label Content="-profile=" />
<TextBox Text="{Binding Profile}" Width="25" TextAlignment="Center" HorizontalContentAlignment="Center"
HorizontalAlignment="Center" VerticalAlignment="Center" />
</StackPanel>
</StackPanel>
</GroupBox>

<GroupBox Header="Watchers" Margin="10" Padding="10" Grid.Row="0" Grid.Column="1">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="--watch-worlds" />
<ToggleButton IsChecked="{Binding WatchWorlds}" Width="15" Height="15" />
</StackPanel>

<StackPanel Orientation="Horizontal">
<Label Content="--watch-avatars" />
<ToggleButton IsChecked="{Binding WatchAvatars}" Width="15" Height="15" />
</StackPanel>
</StackPanel>
</GroupBox>

<GroupBox Header="Screen Overrides" Margin="10" Padding="10" Grid.Row="0" Grid.Column="2">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="-screen-fullscreen " Width="110" HorizontalContentAlignment="Left" />
<ToggleButton Width="15" Height="15" IsChecked="{Binding Fullscreen}"
HorizontalAlignment="Center" VerticalAlignment="Center" Margin="32.5,0,0,0" />
</StackPanel>

<StackPanel Orientation="Horizontal">
<Label Content="-screen-width " Width="100" HorizontalContentAlignment="Left" />
<TextBox Text="{Binding Width}" Width="80" TextAlignment="Center" HorizontalContentAlignment="Center"
HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10,0,0,0" />
</StackPanel>

<StackPanel Orientation="Horizontal">
<Label Content="-screen-heigth " Width="100" HorizontalContentAlignment="Left" />
<TextBox Text="{Binding Height}" Width="80" TextAlignment="Center" HorizontalContentAlignment="Center"
HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10,0,0,0" />
</StackPanel>

</StackPanel>
</GroupBox>

<GroupBox Header="Logging" Margin="10" Padding="10" Grid.Row="1" Grid.Column="0">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="--enable-udon-debug-logging" />
<ToggleButton IsChecked="{Binding UdonDebugLogging}" Width="15" Height="15" />
</StackPanel>

<StackPanel Orientation="Horizontal">
<Label Content="--enable-debug-gui" />
<ToggleButton IsChecked="{Binding DebugGUI}" Width="15" Height="15" />
</StackPanel>

<StackPanel Orientation="Horizontal">
<Label Content="--enable-sdk-log-levels" />
<ToggleButton IsChecked="{Binding SdkLogLevels}" Width="15" Height="15" />
</StackPanel>
</StackPanel>
</GroupBox>

<GroupBox Header="Misc" Margin="10" Padding="10" Grid.Row="1" Grid.Column="1">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="--midi=" Width="50" HorizontalContentAlignment="Left" />
<TextBox Text="{Binding MidiDevice}" Width="150" TextAlignment="Center"
HorizontalContentAlignment="Center"
HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10,0,0,0" />
</StackPanel>

<StackPanel Orientation="Horizontal">
<Label Content="--osc=" Width="50" HorizontalContentAlignment="Left" />
<TextBox Text="{Binding OSCPorts}" Width="150" TextAlignment="Center"
HorizontalContentAlignment="Center"
HorizontalAlignment="Center" VerticalAlignment="Center" Margin="10,0,0,0" />
</StackPanel>
</StackPanel>
</GroupBox>

<Button Content="Launch" Margin="10" Padding="10" Grid.Row="1" Grid.Column="2" Click="Launch" />
</Grid>
</Window>
33 changes: 33 additions & 0 deletions VRCLauncher/View/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Diagnostics;
using System.Windows;
using VRCLauncher.Model;

namespace VRCLauncher
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private ViewModel.ViewModel _viewModel = new();


public MainWindow()
{
InitializeComponent();
DataContext = _viewModel;
Application.Current.Exit += OnApplicationExit;
}

private void OnApplicationExit(object sender, ExitEventArgs e)
{
_viewModel.Config.Save();
}

private void Launch(object sender, RoutedEventArgs e)
{
Process.Start(Config.FindVRCexePath() + "\\VRChat.exe", _viewModel.Config.GetArgs());
}
}
}
Loading

0 comments on commit c034c5d

Please sign in to comment.