This repository has been archived by the owner on Jul 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
5,273 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<configSections> | ||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > | ||
<section name="BoxVR_Playlist_Manager.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> | ||
<section name="BOXVR_Playlist_Manager.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" /> | ||
</sectionGroup> | ||
</configSections> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1" /> | ||
</startup> | ||
<userSettings> | ||
<BoxVR_Playlist_Manager.Properties.Settings> | ||
<setting name="BoxVRExePath" serializeAs="String"> | ||
<value /> | ||
</setting> | ||
<setting name="BoxVRAppDataPath" serializeAs="String"> | ||
<value /> | ||
</setting> | ||
</BoxVR_Playlist_Manager.Properties.Settings> | ||
<BOXVR_Playlist_Manager.Properties.Settings> | ||
<setting name="BOXVRExePath" serializeAs="String"> | ||
<value /> | ||
</setting> | ||
<setting name="BOXVRAppDataPath" serializeAs="String"> | ||
<value /> | ||
</setting> | ||
</BOXVR_Playlist_Manager.Properties.Settings> | ||
</userSettings> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Application x:Class="BoxVR_Playlist_Manager.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="clr-namespace:BoxVR_Playlist_Manager" | ||
StartupUri="MainWindow.xaml"> | ||
<Application.Resources> | ||
|
||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
using Microsoft.Win32; | ||
using NLog; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Data; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text.RegularExpressions; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
|
||
namespace BoxVR_Playlist_Manager | ||
{ | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
const string DEFAULT_BOXVR_APPDATA = @"%userprofile%\AppData\LocalLow\FITXR\BOXVR"; | ||
const string REGISTRY_UNINSTALL_KEY = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"; | ||
const string REGISTRY_STEAM_KEY = @"HKEY_CURRENT_USER\Software\Valve\Steam"; | ||
|
||
|
||
public static Logger logger = LogManager.GetLogger("log"); | ||
|
||
[STAThread] | ||
public static void Main() | ||
{ | ||
AppDomain.CurrentDomain.UnhandledException += (sender, e) => logger.Error(e.ExceptionObject as Exception); | ||
|
||
var app = new App(); | ||
|
||
// check if BoxVRExePath is already set, if not try to locate it via registry or Steam | ||
if (string.IsNullOrWhiteSpace(BoxVR_Playlist_Manager.Properties.Settings.Default.BoxVRExePath)) | ||
{ | ||
logger.Trace("Starting search for BoxVR install location"); | ||
var location = LocateBoxVRExe(); | ||
logger.Trace($"Automatic search for BoxVR install location complete: {location}"); | ||
if (!string.IsNullOrWhiteSpace(location)) | ||
{ | ||
logger.Trace("Saving BoxVRExePath setting"); | ||
BoxVR_Playlist_Manager.Properties.Settings.Default.BoxVRExePath = location; | ||
BoxVR_Playlist_Manager.Properties.Settings.Default.Save(); | ||
} | ||
} | ||
logger.Trace($"BoxVRExePath setting: {BoxVR_Playlist_Manager.Properties.Settings.Default.BoxVRExePath}"); | ||
|
||
// check if BoxVRAppDataPath is already set, if not set to default | ||
if (string.IsNullOrWhiteSpace(BoxVR_Playlist_Manager.Properties.Settings.Default.BoxVRAppDataPath)) | ||
{ | ||
logger.Debug("BoxVRAppDataPath not set, setting default"); | ||
if (Directory.Exists(Environment.ExpandEnvironmentVariables(DEFAULT_BOXVR_APPDATA))) | ||
{ | ||
BoxVR_Playlist_Manager.Properties.Settings.Default.BoxVRAppDataPath = DEFAULT_BOXVR_APPDATA; | ||
BoxVR_Playlist_Manager.Properties.Settings.Default.Save(); | ||
} | ||
else | ||
{ | ||
logger.Debug($"Directory does not exist: {DEFAULT_BOXVR_APPDATA}"); | ||
} | ||
} | ||
logger.Trace($"BoxVRAppDataPath setting: {BoxVR_Playlist_Manager.Properties.Settings.Default.BoxVRAppDataPath}"); | ||
|
||
var mainWindow = new MainWindow(); | ||
app.Run(mainWindow); | ||
} | ||
|
||
private static string LocateBoxVRExe() | ||
{ | ||
logger.Debug("Searching registry for BoxVR install location"); | ||
using (var key = Registry.LocalMachine.OpenSubKey(REGISTRY_UNINSTALL_KEY)) | ||
{ | ||
foreach (var subkey_name in key.GetSubKeyNames()) | ||
{ | ||
using (var subkey = key.OpenSubKey(subkey_name)) | ||
{ | ||
logger.Trace($"Checking reg key {REGISTRY_UNINSTALL_KEY}\\{subkey_name}"); | ||
if (string.Equals(subkey.GetValue("DisplayName")?.ToString(), "BOXVR", StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
var location = subkey.GetValue("InstallLocation")?.ToString(); | ||
if(location != null) | ||
{ | ||
logger.Debug($"BoxVR location found in reg key {REGISTRY_UNINSTALL_KEY}\\{subkey_name}: {location}"); | ||
return location; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
logger.Debug("Searching registry for Steam install location"); | ||
var steamPath = Registry.GetValue(REGISTRY_STEAM_KEY, "SteamPath", null)?.ToString(); | ||
if (steamPath != null) | ||
{ | ||
logger.Trace($"{REGISTRY_STEAM_KEY}/SteamPath: {steamPath}"); | ||
var steamConfigPath = Path.Combine(steamPath, "config/config.vdf"); | ||
if (File.Exists(steamConfigPath)) | ||
{ | ||
var steamConfig = File.ReadAllText(steamConfigPath); | ||
var matches = Regex.Matches(steamConfig, @"""BaseInstallFolder_\d\""\s+""(.*?)"""); | ||
if (matches.Count > 0) | ||
{ | ||
foreach (Match match in matches) | ||
{ | ||
var libraryPath = match.Groups[1].Value; | ||
if (Directory.Exists(libraryPath)) | ||
{ | ||
logger.Trace($"Searching Steam library for BoxVR: {libraryPath}"); | ||
var BoxVRExePath = Path.Combine(libraryPath, "steamapps", "common", "BoxVR"); | ||
if (File.Exists(Path.Combine(BoxVRExePath, "BoxVR.exe"))) | ||
{ | ||
logger.Debug($"BoxVR.exe located at {BoxVRExePath}"); | ||
return BoxVRExePath; | ||
} | ||
else | ||
{ | ||
logger.Trace($"Could not find BoxVR.exe in library: {libraryPath}"); | ||
} | ||
} | ||
else | ||
{ | ||
logger.Trace($"Steam library does not exist: {libraryPath}"); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
logger.Debug($"Failed to find Steam library locations in {steamConfigPath}"); | ||
logger.Trace(steamConfig); | ||
} | ||
} | ||
else | ||
{ | ||
logger.Debug($"No Steam config found at {steamConfigPath}"); | ||
} | ||
} | ||
else | ||
{ | ||
logger.Debug("Failed to load HKCU/Software/Valve/Steam/SteamPath"); | ||
} | ||
|
||
logger.Debug("Could not automatically find BoxVR install location"); | ||
return string.Empty; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{7384CEB2-7BFF-4127-BF84-A145C3422CED}</ProjectGuid> | ||
<OutputType>WinExe</OutputType> | ||
<RootNamespace>BoxVR_Playlist_Manager</RootNamespace> | ||
<AssemblyName>BoxVR Playlist Manager</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
<WarningLevel>4</WarningLevel> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<StartupObject>BoxVR_Playlist_Manager.App</StartupObject> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="ATL, Version=2.5.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\z440.atl.core.2.5.0\lib\net30\ATL.dll</HintPath> | ||
</Reference> | ||
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\NLog.4.5.10\lib\net45\NLog.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Configuration" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="System.IO.Compression" /> | ||
<Reference Include="System.Runtime.Serialization" /> | ||
<Reference Include="System.ServiceModel" /> | ||
<Reference Include="System.Transactions" /> | ||
<Reference Include="System.Windows.Forms" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xaml"> | ||
<RequiredTargetFramework>4.0</RequiredTargetFramework> | ||
</Reference> | ||
<Reference Include="WindowsBase" /> | ||
<Reference Include="PresentationCore" /> | ||
<Reference Include="PresentationFramework" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Extensions.cs" /> | ||
<Compile Include="IsEnabledColorConverter.cs" /> | ||
<Compile Include="Track.cs" /> | ||
<Page Include="App.xaml"> | ||
<Generator>MSBuild:Compile</Generator> | ||
<SubType>Designer</SubType> | ||
</Page> | ||
<Compile Include="Playlist.cs" /> | ||
<Compile Include="SettingsWindow.xaml.cs"> | ||
<DependentUpon>SettingsWindow.xaml</DependentUpon> | ||
</Compile> | ||
<Page Include="MainWindow.xaml"> | ||
<Generator>MSBuild:Compile</Generator> | ||
<SubType>Designer</SubType> | ||
</Page> | ||
<Compile Include="App.xaml.cs"> | ||
<DependentUpon>App.xaml</DependentUpon> | ||
<SubType>Code</SubType> | ||
</Compile> | ||
<Compile Include="MainWindow.xaml.cs"> | ||
<DependentUpon>MainWindow.xaml</DependentUpon> | ||
<SubType>Code</SubType> | ||
</Compile> | ||
<Page Include="SettingsWindow.xaml"> | ||
<SubType>Designer</SubType> | ||
<Generator>MSBuild:Compile</Generator> | ||
</Page> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Properties\AssemblyInfo.cs"> | ||
<SubType>Code</SubType> | ||
</Compile> | ||
<Compile Include="Properties\Resources.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DesignTime>True</DesignTime> | ||
<DependentUpon>Resources.resx</DependentUpon> | ||
</Compile> | ||
<Compile Include="Properties\Settings.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>Settings.settings</DependentUpon> | ||
<DesignTimeSharedInput>True</DesignTimeSharedInput> | ||
</Compile> | ||
<None Include="Third Party Licenses.txt"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<Resource Include="Resources\btn_donate_LG.gif" /> | ||
<EmbeddedResource Include="Properties\Resources.resx"> | ||
<Generator>ResXFileCodeGenerator</Generator> | ||
<LastGenOutput>Resources.Designer.cs</LastGenOutput> | ||
</EmbeddedResource> | ||
<Content Include="NLog.config"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
<None Include="beatmap.bat"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Include="NLog.xsd"> | ||
<SubType>Designer</SubType> | ||
</None> | ||
<None Include="packages.config" /> | ||
<None Include="Properties\Settings.settings"> | ||
<Generator>SettingsSingleFileGenerator</Generator> | ||
<LastGenOutput>Settings.Designer.cs</LastGenOutput> | ||
</None> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config"> | ||
<SubType>Designer</SubType> | ||
</None> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Interop; | ||
|
||
namespace BoxVR_Playlist_Manager | ||
{ | ||
public static class Extensions | ||
{ | ||
#region modal folder browser code courtesy of Craig Shearer @ stackoverflow https://stackoverflow.com/a/315436 | ||
public static System.Windows.Forms.IWin32Window GetIWin32Window(this System.Windows.Media.Visual visual) | ||
{ | ||
var source = System.Windows.PresentationSource.FromVisual(visual) as HwndSource; | ||
var win = new OldWindow(source.Handle); | ||
return win; | ||
} | ||
|
||
private class OldWindow : System.Windows.Forms.IWin32Window | ||
{ | ||
private readonly IntPtr _handle; | ||
IntPtr System.Windows.Forms.IWin32Window.Handle => _handle; | ||
|
||
public OldWindow(IntPtr handle) | ||
{ | ||
_handle = handle; | ||
} | ||
} | ||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Data; | ||
|
||
namespace BoxVR_Playlist_Manager | ||
{ | ||
public class IsEnabledColorConverter : IValueConverter | ||
{ | ||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
var isEnabled = (bool)value; | ||
return isEnabled ? parameter.ToString() : "#ccc"; | ||
} | ||
|
||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
Oops, something went wrong.