Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/.idea.MSUScripter/.idea/avalonia.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions MSUScripter/Configs/MsuSongMsuPcmInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ public class MsuSongMsuPcmInfo
[Description("Normalize the current track to the specified RMS level, overrides the global normalization value")]
public double? Normalization { get; set; }

[Description("Alter the volume after msupcm++ has generated the PCM file")]
public float? PostGenerateVolumeModifier { get; set; }

[Description("If the volume modifier after msupcm++ generation should be in decibels instead of percent")]
public bool IsPostGenerateVolumeDecibels { get; set; }

[Description("Apply dynamic range compression to the current track")]
public bool? Compression { get; set; }

Expand All @@ -59,10 +65,10 @@ public class MsuSongMsuPcmInfo
public bool ShowPanel { get; set; } = true;

[Description("Files which will be concatenated together to form the input to the parent track")]
public List<MsuSongMsuPcmInfo> SubTracks { get; set; } = new();
public List<MsuSongMsuPcmInfo> SubTracks { get; set; } = [];

[Description("Files which will be mixed together to form the input to the parent track")]
public List<MsuSongMsuPcmInfo> SubChannels { get; set; } = new();
public List<MsuSongMsuPcmInfo> SubChannels { get; set; } = [];

public void ClearFieldsForYaml()
{
Expand All @@ -81,12 +87,7 @@ public bool AreFilesValid()

public List<string> GetFiles()
{
if (!string.IsNullOrEmpty(Output))
{
var outputFile = Output;
}

List<string> files = new List<string>();
List<string> files = [];

if (!string.IsNullOrEmpty(File))
{
Expand Down
6 changes: 6 additions & 0 deletions MSUScripter/Configs/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,11 @@ public class Settings
public bool ProjectTreeDisplayCheckCopyrightIcon { get; set; }
public bool ProjectTreeDisplayCopyrightSafeIcon { get; set; }
public bool SkipDesktopFile { get; set; }
public bool TrackOverviewShowIsCompleteIcon { get; set; } = true;
public bool TrackOverviewShowHasSongIcon { get; set; }
public bool TrackOverviewShowCheckCopyrightIcon { get; set; }
public bool TrackOverviewShowCopyrightSafeIcon { get; set; }
public bool HasShownVolumeModifierWarning { get; set; }

public DefaultSongPanel DefaultSongPanel { get; set; } = DefaultSongPanel.Prompt;
}
3 changes: 0 additions & 3 deletions MSUScripter/FodyWeavers.xml

This file was deleted.

31 changes: 17 additions & 14 deletions MSUScripter/MSUScripter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,41 @@
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
<ApplicationIcon>MSUScripterIcon.ico</ApplicationIcon>
<PackageIcon>MSUScripterIcon.ico</PackageIcon>
<Version>5.0.3</Version>
<Version>5.1.0</Version>
<RuntimeFrameworkVersion>9.0.0</RuntimeFrameworkVersion>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<LangVersion>12</LangVersion>
<LangVersion>13</LangVersion>
</PropertyGroup>


<ItemGroup>
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.3.2" />
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.3.10" />
<PackageReference Include="Deadpikle.AvaloniaProgressRing" Version="0.10.10" />
<PackageReference Include="K4os.Hash.xxHash" Version="1.0.8" />
<PackageReference Include="MattEqualsCoder.AppImageManager" Version="0.1.3" />
<!--Condition
below is needed to remove Avalonia.Diagnostics package from build output in Release
configuration.-->
<PackageReference Include="MattEqualsCoder.AvaloniaControls" Version="1.9.1" />
<PackageReference Include="MattEqualsCoder.GitHubReleaseChecker" Version="1.1.3" />
<PackageReference Include="MattEqualsCoder.MSURandomizer.Library" Version="3.2.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.9" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.9" />
<PackageReference Include="MattEqualsCoder.AvaloniaControls" Version="2.0.0" />
<PackageReference Include="MattEqualsCoder.GitHubReleaseChecker" Version="1.1.4" />
<PackageReference Include="MattEqualsCoder.MSURandomizer.Library" Version="3.2.2" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.1" />
<PackageReference Include="NAudio" Version="2.2.1" />
<PackageReference Include="NAudio.WinMM" Version="2.2.1" />
<PackageReference Include="NJsonSchema.CodeGeneration.CSharp" Version="11.5.1" />
<PackageReference Include="ReactiveUI.Fody" Version="19.5.41" />
<PackageReference Include="NJsonSchema.CodeGeneration.CSharp" Version="11.5.2" />
<PackageReference Include="ReactiveUI.SourceGenerators" Version="2.5.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Serilog" Version="4.3.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="9.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="10.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.1.1" />
<PackageReference Include="Serilog.Sinks.Debug" Version="3.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
<PackageReference Include="SharpZipLib" Version="1.4.2" />
<PackageReference Include="SoundFlow" Version="1.1.1" />
<PackageReference Include="System.Management" Version="9.0.9" />
<PackageReference Include="SoundFlow" Version="1.1.2" />
<PackageReference Include="System.Management" Version="10.0.1" />
<PackageReference Include="TagLibSharp" Version="2.3.0" />
</ItemGroup>

Expand Down
7 changes: 6 additions & 1 deletion MSUScripter/Models/MsuProjectGenerationCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ public class MsuProjectGenerationCache

public class MsuProjectSongCache
{
public const int CurrentCacheVersion = 1;
public ulong JsonHash { get; init; }
public int JsonLength { get; init; }
public DateTime FileGenerationTime { get; init; }
public long FileLength { get; init; }
public int? CacheVersion { get; init; }
public float PostGenerateVolumeModifier { get; init; }
public bool IsPostGenerateVolumeDecibels { get; init; }

public static bool IsValid(MsuProjectSongCache? a, MsuProjectSongCache? b)
{
if (a is null || b is null) return false;
return a.JsonHash == b.JsonHash && a.JsonLength == b.JsonLength &&
a.FileGenerationTime == b.FileGenerationTime & a.FileLength == b.FileLength;
a.FileGenerationTime == b.FileGenerationTime & a.FileLength == b.FileLength && a.CacheVersion == b.CacheVersion &&
Math.Abs(a.PostGenerateVolumeModifier - b.PostGenerateVolumeModifier) < 0.01 && a.IsPostGenerateVolumeDecibels == b.IsPostGenerateVolumeDecibels;
}
}
53 changes: 52 additions & 1 deletion MSUScripter/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Avalonia;
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
// ReSharper disable once RedundantUsingDirective
using System.Linq;
using System.Threading;
Expand All @@ -13,9 +15,13 @@
using GitHubReleaseChecker;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using MSURandomizerLibrary;
using MSUScripter.Models;
using MSUScripter.Services;
using MSUScripter.ViewModels;
using ReactiveUI;
using ReactiveUI.SourceGenerators;
using Serilog;
using Win32RenderingMode = Avalonia.Win32RenderingMode;

Expand All @@ -32,7 +38,6 @@ class Program
[STAThread]
public static void Main(string[] args)
{

var loggerConfiguration = new LoggerConfiguration();

#if DEBUG
Expand All @@ -57,6 +62,10 @@ public static void Main(string[] args)
#endif
.CreateLogger();

#if DEBUG
CheckReactiveProperties();
#endif

if (args.Length == 1 && args[0].EndsWith(".msup", StringComparison.OrdinalIgnoreCase) && File.Exists(args[0]))
{
StartingProject = args[0];
Expand Down Expand Up @@ -121,6 +130,7 @@ private static IServiceCollection ConfigureServices(IServiceCollection collectio
.AddSingleton<StatusBarService>()
.AddSingleton<PythonCompanionService>()
.AddSingleton<DependencyInstallerService>()
.AddSingleton<PcmModifierService>()
.AddAvaloniaControlServices<Program>()
.AddTransient<ApplicationInitializationService>();

Expand Down Expand Up @@ -166,5 +176,46 @@ await Dispatcher.UIThread.Invoke(async () =>
#else
private static string LogPath => Path.Combine(Directories.LogFolder, "msu-scripter_.log");
#endif

private static void CheckReactiveProperties()
{
var assemblies = AppDomain.CurrentDomain.GetAssemblies();

foreach (var asm in assemblies)
{
foreach (var type in asm.GetTypes())
{
if (!InheritsFromType<ReactiveObject>(type))
{
continue;
}

var props = type.GetProperties(
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
.Select(x => (Property: x, Attributes: x.GetCustomAttributes(true)))
.Where(x => x.Attributes.Any(a => a is ReactiveAttribute) && !x.Attributes.Any(a => a is GeneratedCodeAttribute))
.ToList();

foreach (var prop in props)
{
Log.Logger.Warning("Class {Class} property {Property} has ReactiveAttribute but is missing partial", type.FullName, prop.Property.Name);
}
}
}
}

static bool InheritsFromType<T>(Type type)
{
var checkType = type;
while (checkType != null && checkType != typeof(object))
{
if (checkType == typeof(T))
return true;

checkType = checkType.BaseType;
}

return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.IO;
using System.Linq;
using System.Threading;
using AvaloniaControls.ControlServices;
using AvaloniaControls.Services;
using Microsoft.Extensions.Logging;
using MSURandomizerLibrary.Services;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Threading.Tasks;
using System.Timers;
using AvaloniaControls.ControlServices;
using AvaloniaControls.Services;
using Material.Icons;
using MSUScripter.Configs;
using MSUScripter.ViewModels;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Linq;
using System.Threading.Tasks;
using Avalonia.Platform.Storage;
using AvaloniaControls.ControlServices;
using AvaloniaControls.Services;
using Microsoft.Extensions.Logging;
using MSUScripter.Configs;
using MSUScripter.ViewModels;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Threading.Tasks;
using AvaloniaControls.ControlServices;
using AvaloniaControls.Services;
using MSUScripter.ViewModels;

namespace MSUScripter.Services.ControlServices;
Expand Down
1 change: 0 additions & 1 deletion MSUScripter/Services/ControlServices/MainWindowService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Net.Http;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using AvaloniaControls.ControlServices;
using AvaloniaControls.Services;
using GitHubReleaseChecker;
using Microsoft.Extensions.Logging;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using AvaloniaControls.ControlServices;
using AvaloniaControls.Services;
using Microsoft.Extensions.Logging;
using MSUScripter.Configs;
Expand Down
35 changes: 32 additions & 3 deletions MSUScripter/Services/ControlServices/MsuProjectWindowService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Avalonia.Media;
using Avalonia.Threading;
using AvaloniaControls.Controls;
using AvaloniaControls.ControlServices;
using AvaloniaControls.Services;
using DynamicData;
using Material.Icons;
Expand Down Expand Up @@ -64,6 +63,15 @@ public MsuProjectWindowViewModel InitViewModel(MsuProject project)
ShowCheckbox = false,
SortIndex = -10000,
MsuDetails = true
},
new()
{
Name = "Track Overview",
CollapseIcon = MaterialIconKind.ListBox,
LeftSpacing = 0,
ShowCheckbox = false,
SortIndex = -9999,
TrackOverview = true
}
};

Expand Down Expand Up @@ -148,9 +156,10 @@ public MsuProjectWindowViewModel InitViewModel(MsuProject project)
SongSummary = $"{completedSongs}/{totalSongs} Songs Completed",
TrackSummary = $"{completedTracks}/{totalTracks} Tracks With Songs Added",
WindowTitle = windowTitle,
PreviousVideoPath = settingsService.Settings.PreviousVideoPath
PreviousVideoPath = settingsService.Settings.PreviousVideoPath,
};


_viewModel.BasicInfoViewModel.IsVisible = true;
_viewModel.BasicInfoViewModel.UpdateModel(project);

_viewModel.TreeItems.AddRange(sidebarItems.OrderBy(x => x.SortIndex));
Expand Down Expand Up @@ -333,6 +342,7 @@ public void SelectedTreeItem(MsuProjectWindowViewModelTreeData treeData, bool is
SaveCurrentPanel();
_viewModel.CurrentTreeItem = treeData;
_viewModel.BasicInfoViewModel.IsVisible = false;
_viewModel.TrackOverviewPanelViewModel.IsVisible = false;
_viewModel.MsuSongViewModel.BasicPanelViewModel.PyMusicLooperEnabled = pythonCompanionService.IsValid;
_viewModel.MsuSongViewModel.UpdateViewModel(_project, treeData.TrackInfo!, null, treeData);
}
Expand All @@ -342,6 +352,7 @@ public void SelectedTreeItem(MsuProjectWindowViewModelTreeData treeData, bool is
SaveCurrentPanel();
_viewModel.CurrentTreeItem = treeData;
_viewModel.BasicInfoViewModel.IsVisible = false;
_viewModel.TrackOverviewPanelViewModel.IsVisible = false;
_viewModel.MsuSongViewModel.BasicPanelViewModel.PyMusicLooperEnabled = pythonCompanionService.IsValid;
_viewModel.MsuSongViewModel.UpdateViewModel(_project, treeData.TrackInfo!, treeData.SongInfo, treeData);
}
Expand All @@ -355,6 +366,19 @@ public void SelectedTreeItem(MsuProjectWindowViewModelTreeData treeData, bool is
_viewModel.CurrentTreeItem = treeData;
_viewModel.BasicInfoViewModel.UpdateModel(_project);
_viewModel.BasicInfoViewModel.IsVisible = true;
_viewModel.TrackOverviewPanelViewModel.IsVisible = false;
}
else if (treeData.TrackOverview)
{
if (_viewModel.MsuSongViewModel.IsEnabled)
{
_viewModel.MsuSongViewModel.SaveChanges();
_viewModel.MsuSongViewModel.IsEnabled = false;
}
_viewModel.CurrentTreeItem = treeData;
_viewModel.TrackOverviewPanelViewModel.UpdateModel(_project, Settings);
_viewModel.BasicInfoViewModel.IsVisible = false;
_viewModel.TrackOverviewPanelViewModel.IsVisible = true;
}
}

Expand Down Expand Up @@ -799,6 +823,11 @@ await Parallel.ForEachAsync(songs,
}, cancellationToken);
}

public void SaveSettings()
{
settingsService.TrySaveSettings();
}

private void HandleDragged(MsuProjectWindowViewModelTreeData from, MsuProjectWindowViewModelTreeData to)
{
if (_viewModel.MsuProject == null || from.TrackInfo == null || to.TrackInfo == null || from.SongInfo == null)
Expand Down
Loading