Skip to content

Commit 1b23cac

Browse files
Merge pull request #132 from MattEqualsCoder/v3.3.0-changes
v4.0.0 Changes (Beta)
2 parents f30661e + bf0ef5b commit 1b23cac

File tree

166 files changed

+7812
-8149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+7812
-8149
lines changed

.idea/.idea.MSUScripter/.idea/avalonia.xml

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MSUScripter.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Microsoft Visual Studio Solution File, Format Version 12.00
33
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSUScripter", "MSUScripter\MSUScripter.csproj", "{2575FDC5-ED6A-49D5-A497-D56AB4360593}"
44
EndProject
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SchemaGenerator", "SchemaGenerator\SchemaGenerator.csproj", "{91EAB44F-EF9B-4439-AFA3-E27D9AAA49D1}"
6+
EndProject
57
Global
68
GlobalSection(SolutionConfigurationPlatforms) = preSolution
79
Debug|Any CPU = Debug|Any CPU
@@ -12,5 +14,9 @@ Global
1214
{2575FDC5-ED6A-49D5-A497-D56AB4360593}.Debug|Any CPU.Build.0 = Debug|Any CPU
1315
{2575FDC5-ED6A-49D5-A497-D56AB4360593}.Release|Any CPU.ActiveCfg = Release|Any CPU
1416
{2575FDC5-ED6A-49D5-A497-D56AB4360593}.Release|Any CPU.Build.0 = Release|Any CPU
17+
{91EAB44F-EF9B-4439-AFA3-E27D9AAA49D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18+
{91EAB44F-EF9B-4439-AFA3-E27D9AAA49D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
19+
{91EAB44F-EF9B-4439-AFA3-E27D9AAA49D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
20+
{91EAB44F-EF9B-4439-AFA3-E27D9AAA49D1}.Release|Any CPU.Build.0 = Release|Any CPU
1521
EndGlobalSection
1622
EndGlobal

MSUScripter/App.axaml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
<Application xmlns="https://github.com/avaloniaui"
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3-
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
4-
xmlns:tools="clr-namespace:MSUScripter.Tools"
3+
xmlns:msuScripter="clr-namespace:MSUScripter"
54
x:Class="MSUScripter.App"
6-
75
RequestedThemeVariant="Dark">
86
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
97

8+
<Application.DataTemplates>
9+
<msuScripter:ViewLocator/>
10+
</Application.DataTemplates>
11+
1012
<Application.Resources>
11-
<tools:NullableBoolToStringConverter x:Key="NullableBoolToStringConverter" />
12-
<tools:BoolToStringConverter x:Key="BoolToStringConverter" />
13+
<ResourceDictionary>
14+
<ResourceDictionary.MergedDictionaries>
15+
<ResourceInclude Source="avares://AvaloniaControls/Themes/Resources.axaml"></ResourceInclude>
16+
</ResourceDictionary.MergedDictionaries>
17+
</ResourceDictionary>
1318
</Application.Resources>
19+
1420
<Application.Styles>
15-
<!--<StyleInclude Source="avares://Semi.Avalonia/Themes/Index.axaml" />-->
1621
<SimpleTheme />
17-
<avalonia:MaterialIconStyles />
18-
<StyleInclude Source="Controls/CardControl.axaml"></StyleInclude>
19-
<StyleInclude Source="Controls/LabeledControl.axaml"></StyleInclude>
20-
<StyleInclude Source="Controls/LinkControl.axaml"></StyleInclude>
21-
<StyleInclude Source="Themes/Themes.axaml"></StyleInclude>
2222
<StyleInclude Source="avares://Avalonia.Controls.DataGrid/Themes/Simple.xaml"/>
23+
<StyleInclude Source="avares://AvaloniaControls/Themes/Themes.axaml"></StyleInclude>
2324
</Application.Styles>
2425

2526
</Application>

MSUScripter/App.axaml.cs

Lines changed: 16 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,46 @@
1-
using System;
21
using System.Diagnostics;
3-
using System.IO;
4-
using System.Linq;
52
using System.Reflection;
6-
using System.Runtime.InteropServices;
7-
using System.Threading.Tasks;
83
using Avalonia;
94
using Avalonia.Controls.ApplicationLifetimes;
105
using Avalonia.Markup.Xaml;
116
using Avalonia.Styling;
7+
using AvaloniaControls.Controls;
128
using Microsoft.Extensions.DependencyInjection;
13-
using Microsoft.Extensions.Logging;
14-
using MSURandomizerLibrary.Models;
15-
using MSURandomizerLibrary.Services;
16-
using MSUScripter.Controls;
17-
using MSUScripter.Models;
18-
using MSUScripter.Services;
9+
using MSUScripter.Configs;
10+
using MSUScripter.Views;
1911

2012
namespace MSUScripter;
2113

2214
public partial class App : Application
2315
{
24-
private ILogger<App>? _logger;
25-
public static MainWindow? MainWindow { get; private set; }
26-
private IServiceProvider? _services;
16+
public static MainWindow MainWindow = null!;
2717

28-
public override void Initialize()
29-
{
30-
AvaloniaXamlLoader.Load(this);
31-
}
32-
33-
public static string GetAppVersion()
18+
public static string Version
3419
{
35-
var version = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly()!.Location);
36-
return (version.ProductVersion ?? "").Split("+")[0];
20+
get
21+
{
22+
var version = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly()!.Location);
23+
return (version.ProductVersion ?? "").Split("+")[0];
24+
}
3725
}
3826

39-
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
27+
public override void Initialize()
4028
{
41-
if (e.ExceptionObject is Exception ex)
42-
_logger?.LogCritical(ex, "[CRASH] Uncaught {ExceptionType}: ", ex.GetType().Name);
43-
else
44-
_logger?.LogCritical("Unhandled exception in current domain but exception object is not an exception ({Obj})", e.ExceptionObject);
29+
AvaloniaXamlLoader.Load(this);
4530
}
46-
4731

4832
public override void OnFrameworkInitializationCompleted()
4933
{
5034
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
5135
{
52-
_services = Program.GetServiceProvider();
53-
_logger = _services.GetRequiredService<ILogger<App>>();
54-
55-
desktop.ShutdownRequested += DesktopOnShutdownRequested;
56-
57-
_logger.LogInformation("Assembly Location: {Location}", Assembly.GetExecutingAssembly().Location);
58-
var version = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly()!.Location);
59-
_logger.LogInformation("Starting MSU Scripter {Version}", GetAppVersion());
60-
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
61-
62-
var settings = _services.GetRequiredService<SettingsService>().Settings;
36+
var settings = Program.MainHost.Services.GetRequiredService<Settings>();
6337
Current!.RequestedThemeVariant = settings.DarkTheme ? ThemeVariant.Dark : ThemeVariant.Light;
64-
65-
var msuInitializationRequest = new MsuRandomizerInitializationRequest
66-
{
67-
MsuAppSettingsStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MSUScripter.msu-randomizer-settings.yaml"),
68-
UserOptionsPath = Path.Combine(Directories.BaseFolder, "msu-user-settings.yml")
69-
};
7038

71-
#if DEBUG
72-
msuInitializationRequest.UserOptionsPath = Path.Combine(Directories.BaseFolder, "msu-user-settings-debug.yml");
73-
#endif
74-
75-
_services.GetRequiredService<IMsuRandomizerInitializationService>().Initialize(msuInitializationRequest);
76-
_services.GetRequiredService<ConverterService>();
77-
Resources[typeof(IServiceProvider)] = _services;
78-
desktop.MainWindow = MainWindow = _services?.GetRequiredService<MainWindow>();
39+
var mainWindow = new MainWindow();
40+
MessageWindow.GlobalParentWindow = mainWindow;
41+
desktop.MainWindow = MainWindow = mainWindow;
7942
}
8043

8144
base.OnFrameworkInitializationCompleted();
8245
}
83-
84-
private void DesktopOnShutdownRequested(object? sender, ShutdownRequestedEventArgs e)
85-
{
86-
if (MainWindow == null) return;
87-
88-
var hasPendingChanges = MainWindow.CheckPendingChanges();
89-
if (!hasPendingChanges) return;
90-
91-
e.Cancel = true;
92-
93-
var window = new MessageWindow("You currently have unsaved changes. Do you want to save your changes?", MessageWindowType.YesNo, "MSU Scripter", MainWindow);
94-
window.Show();
95-
96-
window.OnButtonClick += (o, args) =>
97-
{
98-
var result = window.Result;
99-
if (result == MessageWindowResult.Yes)
100-
{
101-
MainWindow.SaveChanges();
102-
}
103-
};
104-
}
105-
10646
}

MSUScripter/Configs/MsuProject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class MsuProject
1414
public string MsuPath { get; set; } = "";
1515
public string MsuTypeName { get; set; } = "";
1616
public DateTime LastSaveTime { get; set; }
17-
public List<string> IgnoreWarnings { get; set; } = new List<string>();
17+
public List<string> IgnoreWarnings { get; set; } = new();
1818
[YamlIgnore, SkipConvert]
1919
public MsuType MsuType { get; set; } = null!;
2020
[SkipConvert]

MSUScripter/Configs/MsuSongInfo.cs

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,53 @@
11
using System;
2+
using System.ComponentModel;
3+
using NJsonSchema.Annotations;
24

35
namespace MSUScripter.Configs;
46

7+
[Description("Details about a song for YAML and PCM generation")]
58
public class MsuSongInfo
69
{
10+
[JsonSchemaIgnore]
711
public int TrackNumber { get; set; }
8-
public string TrackName { get; set; } = "";
12+
13+
[JsonSchemaIgnore]
14+
public string? TrackName { get; set; }
15+
16+
[Description("The title of the song")]
917
public string? SongName { get; set; }
18+
19+
[Description("The artist(s) that created the song")]
1020
public string? Artist { get; set; }
21+
22+
[Description("The album in which the song was released on or the game the song is from")]
1123
public string? Album { get; set; }
24+
25+
[Description("A url in which the user can purchase the song/album")]
1226
public string? Url { get; set; }
13-
public string OutputPath { get; set; } = "";
27+
28+
[Description("Details that are passed to msupcm++ for generation")]
29+
public MsuSongMsuPcmInfo MsuPcmInfo { get; set; } = new();
30+
31+
[JsonSchemaIgnore]
32+
public string? OutputPath { get; set; } = "";
33+
34+
[JsonSchemaIgnore]
1435
public bool IsAlt { get; set; }
36+
37+
[JsonSchemaIgnore]
1538
public bool IsComplete { get; set; }
39+
40+
[JsonSchemaIgnore]
1641
public bool CheckCopyright { get; set; } = true;
42+
43+
[JsonSchemaIgnore]
44+
public bool ShowPanel { get; set; } = true;
45+
46+
[JsonSchemaIgnore]
1747
public DateTime LastModifiedDate { get; set; }
48+
49+
[JsonSchemaIgnore]
1850
public DateTime LastGeneratedDate { get; set; }
1951

20-
public MsuSongMsuPcmInfo MsuPcmInfo { get; set; } = new();
52+
2153
}

MSUScripter/Configs/MsuSongMsuPcmInfo.cs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,76 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.ComponentModel;
34
using System.Linq;
5+
using NJsonSchema.Annotations;
6+
using YamlDotNet.Serialization;
47

58
namespace MSUScripter.Configs;
69

10+
[Description("Details that are passed to msupcm++ for generation")]
711
public class MsuSongMsuPcmInfo
812
{
13+
[Description("The loop point of the current track, relative to this track/sub-track/sub-channel, in samples")]
914
public int? Loop { get; set; }
15+
16+
[Description("Trim the start of the current track at the specified sample")]
1017
public int? TrimStart { get; set; }
18+
19+
[Description("Trim the end of the current track at the specified sample")]
1120
public int? TrimEnd { get; set; }
21+
22+
[Description("Apply a fade in effect to the current track lasting a specified number of samples")]
1223
public int? FadeIn { get; set; }
24+
25+
[Description("Apply a fade out effect to the current track lasting a specified number of samples")]
1326
public int? FadeOut { get; set; }
27+
28+
[Description("Apply a cross fade effect from the end of the current track to its loop point lasting a specified number of samples")]
1429
public int? CrossFade { get; set; }
30+
31+
[Description("Pad the beginning of the current track with a specified number of silent samples")]
1532
public int? PadStart { get; set; }
33+
34+
[Description("Pad the end of the current track with a specified number of silent samples")]
1635
public int? PadEnd { get; set; }
36+
37+
[Description("Alter the tempo of the current track by a specified ratio")]
1738
public double? Tempo { get; set; }
39+
40+
[Description("Normalize the current track to the specified RMS level, overrides the global normalization value")]
1841
public double? Normalization { get; set; }
42+
43+
[Description("Apply dynamic range compression to the current track")]
1944
public bool? Compression { get; set; }
45+
46+
[JsonSchemaIgnore]
2047
public DateTime LastModifiedDate { get; set; }
48+
49+
[JsonSchemaIgnore]
2150
public string? Output { get; set; }
51+
52+
[Description("The file to be used as the input for this track/sub-track/sub-channel")]
2253
public string? File { get; set; }
2354

55+
[JsonSchemaIgnore]
56+
public bool ShowPanel { get; set; } = true;
57+
58+
[Description("Files which will be concatenated together to form the input to the parent track")]
2459
public List<MsuSongMsuPcmInfo> SubTracks { get; set; } = new();
60+
61+
[Description("Files which will be mixed together to form the input to the parent track")]
2562
public List<MsuSongMsuPcmInfo> SubChannels { get; set; } = new();
2663

64+
public void ClearFieldsForYaml()
65+
{
66+
LastModifiedDate = new DateTime();
67+
ShowPanel = false;
68+
foreach (var subItem in SubChannels.Concat(SubTracks))
69+
{
70+
subItem.ClearFieldsForYaml();
71+
}
72+
}
73+
2774
public List<string> GetFiles()
2875
{
2976
List<string> files = new List<string>();
@@ -38,4 +85,15 @@ public List<string> GetFiles()
3885

3986
return files;
4087
}
88+
89+
[YamlIgnore]
90+
public bool HasBothSubTracksAndSubChannels
91+
{
92+
get
93+
{
94+
return (SubTracks.Count > 0 && SubChannels.Count > 0) ||
95+
SubChannels.Any(x => x.HasBothSubTracksAndSubChannels) ||
96+
SubTracks.Any(x => x.HasBothSubTracksAndSubChannels);
97+
}
98+
}
4199
}

MSUScripter/Configs/Settings.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Collections.Generic;
2-
using MSUScripter.Models;
32

43
namespace MSUScripter.Configs;
54

@@ -14,5 +13,7 @@ public class Settings
1413
public ICollection<RecentProject> RecentProjects { get; set; } = new List<RecentProject>();
1514
public double Volume { get; set; } = 1;
1615
public string? PreviousPath { get; set; }
17-
public WindowRestoreDetails? MainWindowRestoreDetails { get; set; }
16+
public bool HideSubTracksSubChannelsWarning { get; set; }
17+
public bool AutomaticallyRunPyMusicLooper { get; set; } = true;
18+
public bool RunMsuPcmWithKeepTemps { get; set; }
1819
}

0 commit comments

Comments
 (0)