mirror of
https://github.com/knah/VRCMelonAssistant.git
synced 2024-05-21 12:53:18 +12:00
Added Install Playlist button.
This commit is contained in:
parent
b4583a3530
commit
07c2d90b09
|
@ -1,6 +1,7 @@
|
|||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -309,7 +310,7 @@ namespace ModAssistant
|
|||
|
||||
public static string GetManualDir()
|
||||
{
|
||||
var dialog = new Microsoft.Win32.SaveFileDialog()
|
||||
var dialog = new SaveFileDialog()
|
||||
{
|
||||
Title = (string)Application.Current.FindResource("Utils:InstallDir:DialogTitle"),
|
||||
Filter = "Directory|*.this.directory",
|
||||
|
@ -339,6 +340,22 @@ namespace ModAssistant
|
|||
return null;
|
||||
}
|
||||
|
||||
public static string GetManualFile(string filter = "", string title = "Open File")
|
||||
{
|
||||
var dialog = new OpenFileDialog()
|
||||
{
|
||||
Title = title,
|
||||
Filter = filter,
|
||||
Multiselect = false,
|
||||
};
|
||||
|
||||
if (dialog.ShowDialog() == true)
|
||||
{
|
||||
return dialog.FileName;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static bool IsVoid()
|
||||
{
|
||||
string directory = App.BeatSaberInstallDirectory;
|
||||
|
@ -387,6 +404,13 @@ namespace ModAssistant
|
|||
MessageBox.Show($"{string.Format((string)Application.Current.FindResource("Utils:CannotOpenFolder"), location)}.");
|
||||
}
|
||||
|
||||
public static void Log(string message, string severity = "LOG")
|
||||
{
|
||||
string path = Path.GetDirectoryName(ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath);
|
||||
string logFile = $"{path}{Path.DirectorySeparatorChar}log.log";
|
||||
File.AppendAllText(logFile, $"[{DateTime.UtcNow.ToString("yyyy-mm-dd HH:mm:ss.ffffff")}][{severity.ToUpper()}] {message}\n");
|
||||
}
|
||||
|
||||
public static async Task Download(string link, string output)
|
||||
{
|
||||
var resp = await HttpClient.GetAsync(link);
|
||||
|
|
|
@ -102,6 +102,8 @@
|
|||
<sys:String x:Key="Options:GameType">Options:GameType</sys:String>
|
||||
<sys:String x:Key="Options:GameType:Steam">Options:GameType:Steam</sys:String>
|
||||
<sys:String x:Key="Options:GameType:Oculus">Options:GameType:Oculus</sys:String>
|
||||
<sys:String x:Key="Options:Tools">Options:Tools</sys:String>
|
||||
<sys:String x:Key="Options:InstallPlaylist">Options:InstallPlaylist</sys:String>
|
||||
<sys:String x:Key="Options:Diagnostics">Options:Diagnostics</sys:String>
|
||||
<sys:String x:Key="Options:OpenLogsButton">Options:OpenLogsButton</sys:String>
|
||||
<sys:String x:Key="Options:OpenAppDataButton">Options:OpenAppDataButton</sys:String>
|
||||
|
|
|
@ -142,6 +142,8 @@
|
|||
<sys:String x:Key="Options:GameType">Game Type</sys:String>
|
||||
<sys:String x:Key="Options:GameType:Steam">Steam</sys:String>
|
||||
<sys:String x:Key="Options:GameType:Oculus">Oculus</sys:String>
|
||||
<sys:String x:Key="Options:Tools">Tools</sys:String>
|
||||
<sys:String x:Key="Options:InstallPlaylist">Install Playlist</sys:String>
|
||||
<sys:String x:Key="Options:Diagnostics">Diagnostics</sys:String>
|
||||
<sys:String x:Key="Options:OpenLogsButton">Open Logs</sys:String>
|
||||
<sys:String x:Key="Options:OpenAppDataButton">Open AppData</sys:String>
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.IO.Compression" />
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto" />
|
||||
|
@ -265,13 +267,34 @@
|
|||
HorizontalAlignment="Left"
|
||||
FontSize="24"
|
||||
FontWeight="Bold"
|
||||
Text="{DynamicResource Options:Diagnostics}" />
|
||||
Text="{DynamicResource Options:Tools}" />
|
||||
<StackPanel
|
||||
Grid.Row="15"
|
||||
Grid.ColumnSpan="4"
|
||||
Margin="0"
|
||||
HorizontalAlignment="Left"
|
||||
Orientation="Horizontal">
|
||||
<Button
|
||||
Height="30"
|
||||
Margin="5"
|
||||
Padding="5"
|
||||
Click="InstallPlaylistButton_Click"
|
||||
Content="{DynamicResource Options:InstallPlaylist}" />
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="16"
|
||||
Margin="15,5,5,5"
|
||||
HorizontalAlignment="Left"
|
||||
FontSize="24"
|
||||
FontWeight="Bold"
|
||||
Text="{DynamicResource Options:Diagnostics}" />
|
||||
<StackPanel
|
||||
Grid.Row="17"
|
||||
Grid.ColumnSpan="4"
|
||||
Margin="0"
|
||||
HorizontalAlignment="Left"
|
||||
Orientation="Horizontal">
|
||||
<Button
|
||||
Height="30"
|
||||
Margin="5"
|
||||
|
|
|
@ -308,5 +308,13 @@ namespace ModAssistant.Pages
|
|||
MessageBox.Show((string)Application.Current.FindResource("Options:ThemeFolderNotFound"));
|
||||
}
|
||||
}
|
||||
|
||||
private void InstallPlaylistButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string playlistFile = Utils.GetManualFile();
|
||||
Utils.Log(playlistFile, "DEBUG");
|
||||
var result = Task.Run(async () => { API.Playlists.DownloadFrom(playlistFile).Wait(); });
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue