Skip to content

Commit

Permalink
Fixed a few bugs in release mode, added an indicator of which track i…
Browse files Browse the repository at this point in the history
…s being processed.

Created a new .NET 5 project that will be the main project on the next release.
  • Loading branch information
binginsin committed Mar 21, 2021
1 parent 364e890 commit e580d6c
Show file tree
Hide file tree
Showing 82 changed files with 4,903 additions and 56 deletions.
2 changes: 1 addition & 1 deletion BOXVR Playlist Manager/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
<userSettings>
<BoxVR_Playlist_Manager.Properties.Settings>
Expand Down
4 changes: 3 additions & 1 deletion BOXVR Playlist Manager/BOXVR Playlist Manager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
<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="HtmlAgilityPack">
<HintPath>..\..\SpotiSharp\bin\Debug\netcoreapp3.1\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -141,7 +144,6 @@
<Compile Include="IsEnabledColorConverter.cs" />
<Compile Include="MainWindowViewModel.cs" />
<Compile Include="RelayCommand.cs" />
<Compile Include="SongViewModel.cs" />
<Compile Include="SafeNativeMethods.cs" />
<Page Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
Expand Down
7 changes: 4 additions & 3 deletions BOXVR Playlist Manager/FitXr/BeatStructure/FFmpegQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ private void RunFFMPEG(FFmpegJob job)
{
Directory.CreateDirectory(Paths.TrackDataFolder(LocationMode.PlayerData));
App.logger.Debug(("FFMPEG start: " + FFmpegQueue.binaryPath + " " + job.GetCommand()));
bool done = false;
CancellationTokenSource doneCts = new CancellationTokenSource();
var done = doneCts.Token;
string exepath = FFmpegQueue.binaryPath;
string command = job.GetCommand();
new Thread((ThreadStart)(() =>
Expand All @@ -38,9 +39,9 @@ private void RunFFMPEG(FFmpegJob job)
process.WaitForExit();
process.Close();
job._message = output;
done = true;
doneCts.Cancel();
})).Start();
while(!done) { }
while(!done.IsCancellationRequested) { }
job._onFinished.Invoke(job);
App.logger.Debug("FFMEG done");
}
Expand Down
2 changes: 1 addition & 1 deletion BOXVR Playlist Manager/Helpers/NotifyingObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace BoxVR_Playlist_Manager.Helpers
{
public class NotifyingObject : INotifyPropertyChanged
{
Dispatcher _dispatcher;
protected Dispatcher _dispatcher;
public NotifyingObject(Dispatcher dispatcher)
{
_dispatcher = dispatcher;
Expand Down
16 changes: 12 additions & 4 deletions BOXVR Playlist Manager/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
</Setter.Value>
</Setter>
</Style>

<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<local:IsEnabledColorConverter x:Key="IsEnabledColorConverter" />
<Geometry x:Key="fas_fa-cog">M444.788 291.1l42.616 24.599c4.867 2.809 7.126 8.618 5.459 13.985-11.07 35.642-29.97 67.842-54.689 94.586a12.016 12.016 0 0 1-14.832 2.254l-42.584-24.595a191.577 191.577 0 0 1-60.759 35.13v49.182a12.01 12.01 0 0 1-9.377 11.718c-34.956 7.85-72.499 8.256-109.219.007-5.49-1.233-9.403-6.096-9.403-11.723v-49.184a191.555 191.555 0 0 1-60.759-35.13l-42.584 24.595a12.016 12.016 0 0 1-14.832-2.254c-24.718-26.744-43.619-58.944-54.689-94.586-1.667-5.366.592-11.175 5.459-13.985L67.212 291.1a193.48 193.48 0 0 1 0-70.199l-42.616-24.599c-4.867-2.809-7.126-8.618-5.459-13.985 11.07-35.642 29.97-67.842 54.689-94.586a12.016 12.016 0 0 1 14.832-2.254l42.584 24.595a191.577 191.577 0 0 1 60.759-35.13V25.759a12.01 12.01 0 0 1 9.377-11.718c34.956-7.85 72.499-8.256 109.219-.007 5.49 1.233 9.403 6.096 9.403 11.723v49.184a191.555 191.555 0 0 1 60.759 35.13l42.584-24.595a12.016 12.016 0 0 1 14.832 2.254c24.718 26.744 43.619 58.944 54.689 94.586 1.667 5.366-.592 11.175-5.459 13.985L444.788 220.9a193.485 193.485 0 0 1 0 70.2zM336 256c0-44.112-35.888-80-80-80s-80 35.888-80 80 35.888 80 80 80 80-35.888 80-80z</Geometry>
Expand Down Expand Up @@ -69,7 +68,7 @@
<Path Data="{StaticResource fas_fa-file-import}" Stretch="Uniform" Width="20" Height="20" RenderTransformOrigin="0.5,0.5" Fill="#c23616"/>
</Grid>
</Button>-->
<Button x:Name="btnAddPlaylist" Grid.Column="1" Background="Transparent" BorderBrush="{x:Null}" ToolTip="New Playlist" Margin="4,0" Command="{Binding AddPlaylistCommand}">
<Button x:Name="btnAddPlaylist" Grid.Column="1" Background="Transparent" BorderBrush="{x:Null}" ToolTip="New Playlist" Margin="4,0" Command="{Binding AddLocalPlaylistCommand}">
<Grid>
<Path Data="{StaticResource fas_fa-plus}" Stretch="Uniform" Width="20" Height="20" RenderTransformOrigin="0.5,0.5" Fill="#4cd137"/>
</Grid>
Expand Down Expand Up @@ -208,8 +207,17 @@
</Grid>
</Grid>

<Grid x:Name="gridGeneratingBeatmaps" Background="#eef5f6fa" Visibility="{Binding SelectedPlaylist.IsGeneratingBeatmaps, Converter={StaticResource BooleanToVisibilityConverter},FallbackValue=Collapsed}">
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="32" Foreground="#2f3640">Please wait, generating beatmaps...</TextBlock>
<Grid x:Name="gridGeneratingBeatmaps" Background="#eef5f6fa" Visibility="{Binding SelectedPlaylist.IsGeneratingBeatmaps, Converter={StaticResource BooleanToVisibilityConverter},FallbackValue=Collapsed}" VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock HorizontalAlignment="Center" FontSize="32" Foreground="#2f3640" VerticalAlignment="Center">
<Run>Please wait, generating beatmaps...</Run>
</TextBlock>
<TextBlock Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="24" Foreground="#2f3640">
<Run Text="Processing "/><Run Text="{Binding SelectedPlaylist.ProcessingTrackNum}"/><Run Text=". "/><Run Text="{Binding SelectedPlaylist.ProcessingTrackName}"/>
</TextBlock>
</Grid>

<Grid x:Name="pleaseSetPaths" Background="#eef5f6fa" Visibility="{Binding PathsNotSetup, Converter={StaticResource BooleanToVisibilityConverter}}" Margin="0, 0, 0, 30">
Expand Down
30 changes: 16 additions & 14 deletions BOXVR Playlist Manager/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using System.Collections.ObjectModel;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
Expand All @@ -23,20 +27,24 @@ public PlaylistViewModel SelectedPlaylist
set => SetProperty(ref _selectedPlaylist, value);
}

public ICommand AddPlaylistCommand { get; set; }
public ICommand AddLocalPlaylistCommand { get; set; }
public ICommand SettingsCommand { get; set; }
public ICommand RemovePlaylistCommand { get; set; }

private bool _pathsNotSetup;
public bool PathsNotSetup { get => _pathsNotSetup; set => SetProperty(ref _pathsNotSetup, value); }

private bool _displayAddPlaylistSubmenu;
public bool DisplayAddPlayListSubmenu { get => _displayAddPlaylistSubmenu; set => SetProperty(ref _displayAddPlaylistSubmenu, value); }


public MainWindowViewModel(Dispatcher dispatcher):base(dispatcher)
{
_dispatcher = dispatcher;
AddPlaylistCommand = new RelayCommand(NewPlaylistCommandExecute);
AddLocalPlaylistCommand = new RelayCommand(NewLocalPlaylistCommandExecute);
RemovePlaylistCommand = new RelayCommand(RemovePlaylistCommandExecute);
SettingsCommand = new RelayCommand(SettingsCommandExecute);
Playlists = new ObservableCollection<PlaylistViewModel>();
if(string.IsNullOrEmpty(Paths.PersistentDataPath) || string.IsNullOrEmpty(Paths.ApplicationPath))
{
PathsNotSetup = true;
Expand All @@ -47,12 +55,13 @@ public MainWindowViewModel(Dispatcher dispatcher):base(dispatcher)

private void LoadPlaylists()
{
Playlists = new ObservableCollection<PlaylistViewModel>();

PlaylistManager.instance.LoadWorkoutPlaylists();
var playlists = PlaylistManager.instance.GetAllWorkoutPlaylists();

_dispatcher.Invoke(() =>
{
Playlists.Clear();
foreach(var playlist in playlists)
{
Playlists.Add(new PlaylistViewModel(playlist, _dispatcher));
Expand All @@ -63,8 +72,9 @@ private void LoadPlaylists()
_log.Debug($"{Playlists.Count} playlists loaded from");
}

public void NewPlaylistCommandExecute(object arg)
public void NewLocalPlaylistCommandExecute(object arg)
{
DisplayAddPlayListSubmenu = false;
var workoutPlaylist = PlaylistManager.instance.AddNewPlaylist();
Playlists.Add(new PlaylistViewModel(workoutPlaylist, _dispatcher));
}
Expand All @@ -91,15 +101,7 @@ private void SettingsCommandExecute(object arg)
return;
}
PathsNotSetup = false;
if(settingsChanged.HasValue && settingsChanged.Value)
{
_log.Debug("Settings were changed");
LoadPlaylists();
}
else
{
_log.Debug("No settings changed");
}
Task.Run(LoadPlaylists);
}
}
}
50 changes: 38 additions & 12 deletions BOXVR Playlist Manager/PlaylistViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Threading;

Expand Down Expand Up @@ -76,6 +77,12 @@ public SongDefinition SelectedTrack
set => SetProperty(ref _selectedTrack, value);
}

private string _processingTrackName;
public string ProcessingTrackName { get => _processingTrackName; set => SetProperty(ref _processingTrackName, value); }

private int _processingTrackNum;
public int ProcessingTrackNum { get => _processingTrackNum; set => SetProperty(ref _processingTrackNum, value); }


// ------------------ Commands ---------------------

Expand Down Expand Up @@ -198,23 +205,42 @@ public void SaveCommandExecute(object arg)
IsGeneratingBeatmaps = true;
Task.Run(() =>
{
List<SongDefinition> list = new List<SongDefinition>();
foreach(var track in Tracks)
try
{
if(!_originalWorkoutPlaylist.songs.Contains(track))
List<SongDefinition> list = new List<SongDefinition>();
int i = 1;
foreach(var track in Tracks)
{
var addedSong = PlaylistManager.instance.PlaylistAddEntry(_workoutPlaylist, track.trackDefinition.trackData.originalFilePath, FitXr.Enums.LocationMode.PlayerData);
list.Add(addedSong);
ProcessingTrackName = track.trackDefinition.tagLibTitle;
ProcessingTrackNum = i;
if(!_originalWorkoutPlaylist.songs.Contains(track))
{
var addedSong = PlaylistManager.instance.PlaylistAddEntry(_workoutPlaylist, track.trackDefinition.trackData.originalFilePath, FitXr.Enums.LocationMode.PlayerData);
list.Add(addedSong);
}
else
{
list.Add(track);
}
i++;
}
else
_workoutPlaylist.songs = list;
PlaylistManager.instance.ExportPlaylistJson(_workoutPlaylist);
_dispatcher.Invoke(() =>
{
list.Add(track);
}
Tracks.Clear();
foreach(var song in _workoutPlaylist.songs)
{
Tracks.Add(song);
}
IsGeneratingBeatmaps = false;
IsModified = false;
});
}
catch(Exception ex)
{
MessageBox.Show($"FAILED {ex.Message}");
}
_workoutPlaylist.songs = list;
PlaylistManager.instance.ExportPlaylistJson(_workoutPlaylist);
IsGeneratingBeatmaps = false;
IsModified = false;
});
}
}
Expand Down
6 changes: 3 additions & 3 deletions BOXVR Playlist Manager/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BoxVR Playlist Manager")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down Expand Up @@ -51,7 +51,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: NeutralResourcesLanguage("en-GB")]

15 changes: 0 additions & 15 deletions BOXVR Playlist Manager/SongViewModel.cs

This file was deleted.

20 changes: 18 additions & 2 deletions BOXVRPlaylistManager.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2048
# Visual Studio Version 16
VisualStudioVersion = 16.0.31112.23
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BOXVR Playlist Manager", "BOXVR Playlist Manager\BOXVR Playlist Manager.csproj", "{7384CEB2-7BFF-4127-BF84-A145C3422CED}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BoxVRPlaylistManagerNETCore", "BoxVRPlaylistManagerNETCore\BoxVRPlaylistManagerNETCore.csproj", "{CDB99F3A-0C5F-4E4B-9A2C-57340389B0B5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SpotiSharp", "..\SpotiSharp\SpotiSharp.csproj", "{AFB48153-F9A2-49C2-9BE8-2F1F8EAD058D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -18,6 +22,18 @@ Global
{7384CEB2-7BFF-4127-BF84-A145C3422CED}.Publish|Any CPU.Build.0 = Publish|Any CPU
{7384CEB2-7BFF-4127-BF84-A145C3422CED}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7384CEB2-7BFF-4127-BF84-A145C3422CED}.Release|Any CPU.Build.0 = Release|Any CPU
{CDB99F3A-0C5F-4E4B-9A2C-57340389B0B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CDB99F3A-0C5F-4E4B-9A2C-57340389B0B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CDB99F3A-0C5F-4E4B-9A2C-57340389B0B5}.Publish|Any CPU.ActiveCfg = Debug|Any CPU
{CDB99F3A-0C5F-4E4B-9A2C-57340389B0B5}.Publish|Any CPU.Build.0 = Debug|Any CPU
{CDB99F3A-0C5F-4E4B-9A2C-57340389B0B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CDB99F3A-0C5F-4E4B-9A2C-57340389B0B5}.Release|Any CPU.Build.0 = Release|Any CPU
{AFB48153-F9A2-49C2-9BE8-2F1F8EAD058D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AFB48153-F9A2-49C2-9BE8-2F1F8EAD058D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AFB48153-F9A2-49C2-9BE8-2F1F8EAD058D}.Publish|Any CPU.ActiveCfg = Debug|Any CPU
{AFB48153-F9A2-49C2-9BE8-2F1F8EAD058D}.Publish|Any CPU.Build.0 = Debug|Any CPU
{AFB48153-F9A2-49C2-9BE8-2F1F8EAD058D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AFB48153-F9A2-49C2-9BE8-2F1F8EAD058D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
9 changes: 9 additions & 0 deletions BoxVRPlaylistManagerNETCore/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Application x:Class="BoxVRPlaylistManagerNETCore.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:BoxVRPlaylistManagerNETCore"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
Loading

0 comments on commit e580d6c

Please sign in to comment.