Skip to content

Commit 477f765

Browse files
Add first time setup popup for msupcm++
1 parent e14860c commit 477f765

File tree

8 files changed

+97
-32
lines changed

8 files changed

+97
-32
lines changed

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

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

MSUScripter/Configs/Settings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ public class Settings
1616
public bool HideSubTracksSubChannelsWarning { get; set; }
1717
public bool AutomaticallyRunPyMusicLooper { get; set; } = true;
1818
public bool RunMsuPcmWithKeepTemps { get; set; }
19+
public bool HasDoneFirstTimeSetup { get; set; }
1920
}

MSUScripter/Services/ControlServices/MainWindowService.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,23 @@ namespace MSUScripter.Services.ControlServices;
1111

1212
public class MainWindowService(Settings settings, SettingsService settingsService, MsuPcmService msuPcmService, PyMusicLooperService pyMusicLooperService, ProjectService projectService, IGitHubReleaseCheckerService gitHubReleaseCheckerService) : ControlService
1313
{
14-
private MainWindowViewModel _model = new();
14+
private readonly MainWindowViewModel _model = new();
1515

1616
public MainWindowViewModel InitializeModel()
1717
{
1818
_ = CheckForNewRelease();
1919
_ = CleanUpFolders();
2020
OpenCommandlineArgsProject();
2121
_model.AppVersion = $" v{App.Version}";
22+
23+
if (!settings.HasDoneFirstTimeSetup && !string.IsNullOrEmpty(settings.MsuPcmPath))
24+
{
25+
settings.HasDoneFirstTimeSetup = true;
26+
settingsService.SaveSettings();
27+
}
28+
29+
_model.HasDoneFirstTimeSetup = settings.HasDoneFirstTimeSetup;
30+
2231
UpdateTitle();
2332
return _model;
2433
}
@@ -52,6 +61,18 @@ public void CloseNewReleaseBanner(bool permanently)
5261
_model.GitHubReleaseUrl = "";
5362
}
5463

64+
public bool ValidateMsuPcm(string msupcmPath)
65+
{
66+
return msuPcmService.ValidateMsuPcmPath(msupcmPath, out _);
67+
}
68+
69+
public void UpdateHasDoneFirstTimeSetup(string? msupcmPath)
70+
{
71+
settings.HasDoneFirstTimeSetup = true;
72+
settings.MsuPcmPath = msupcmPath;
73+
settingsService.SaveSettings();
74+
}
75+
5576
public void Shutdown()
5677
{
5778
settingsService.SaveSettings();

MSUScripter/ViewModels/MainWindowViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class MainWindowViewModel : ViewModelBase
1919

2020
[Reactive, ReactiveLinkedProperties(nameof(DisplayNewVersionBanner))]
2121
public string? GitHubReleaseUrl { get; set; }
22-
22+
public bool HasDoneFirstTimeSetup { get; set; }
2323
public bool DisplayNewPage => CurrentMsuProject == null;
2424
public bool DisplayEditPage => CurrentMsuProject != null;
2525
public string AppVersion { get; set; } = "";

MSUScripter/ViewModels/SettingsWindowViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class SettingsWindowViewModel : ViewModelBase
1818
[Reactive] public bool RunMsuPcmWithKeepTemps { get; set; }
1919
[Reactive] public bool AutomaticallyRunPyMusicLooper { get; set; }
2020
[Reactive] public bool HideSubTracksSubChannelsWarning { get; set; }
21+
public bool HasDoneFirstTimeSetup { get; set; }
2122

2223
public override ViewModelBase DesignerExample()
2324
{

MSUScripter/Views/EditProjectPanel.axaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,27 +94,24 @@
9494
<Grid ColumnDefinitions="*,*,*">
9595
<views:AudioControl Grid.Column="0" CanPopout="True" />
9696
<TextBlock Grid.Column="1" Name="StatusMessage" HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding StatusBarText}"></TextBlock>
97-
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0 0 5 5">
97+
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0 0 0 0" VerticalAlignment="Center">
9898
<Button x:Name="AddSongButton"
99-
Margin="0 2 0 1"
10099
IsVisible="{Binding MsuBasicInfoViewModel.IsMsuPcmProject }"
101100
Click="AddSongButton_OnClick"
102101
>Add _Song</Button>
103102
<Button x:Name="AnalysisButton"
104-
Margin="8 2 0 1"
105103
IsVisible="{Binding MsuBasicInfoViewModel.IsMsuPcmProject }"
104+
Margin="5 0 0 0"
106105
Click="AnalysisButton_OnClick"
107106
>_Audio Analysis</Button>
108107
<Button x:Name="ExportButton"
109108
IsVisible="{Binding !IsMsuPcmProject }"
110-
Margin="0 2 0 1"
111-
Padding="8 5"
112109
Click="ExportButton_OnClick"
113110
>_Export</Button>
114111
<SplitButton Content="_Export"
115112
Name="ExportMenuButton"
116113
IsVisible="{Binding IsMsuPcmProject }"
117-
Margin="8 2 0 1"
114+
Margin="5 0 0 0"
118115
Click="ExportButton_OnClick"
119116
>
120117
<SplitButton.Flyout>

MSUScripter/Views/MainWindow.axaml

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,30 @@
2222
<Grid RowDefinitions="Auto, *">
2323
<controls:HeaderFooter BorderSize="0 0 0 2" Grid.Row="0" IsVisible="{Binding DisplayNewVersionBanner}">
2424

25-
<Grid ColumnDefinitions="Auto, *, Auto" RowDefinitions="Auto, Auto">
26-
27-
<avalonia:MaterialIcon Grid.Row="0"
28-
Grid.Column="0"
29-
Grid.RowSpan="2"
30-
Kind="Update"
31-
Width="30"
32-
Height="30"
33-
Margin="5 0 0 0"
34-
></avalonia:MaterialIcon>
35-
36-
<StackPanel Grid.Row="" Grid.Column="1" Orientation="Horizontal" Margin="5">
37-
<TextBlock>A new version of the MSU Scripter is now available!</TextBlock>
38-
<controls:LinkControl Margin="5 0 0 0" Name="GitHubUrlLink" Click="GitHubUrlLink_OnClick">Click here to go to the download page.</controls:LinkControl>
39-
</StackPanel>
40-
41-
<controls:ImageButton Grid.Row="0" Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Top" Name="CloseUpdateButton" Click="CloseUpdateButton_OnClick" Margin="0 3 3 0">
42-
<avalonia:MaterialIcon Kind="Close" Width="12" Height="12" Background="Transparent"></avalonia:MaterialIcon>
43-
</controls:ImageButton>
44-
45-
<StackPanel Grid.Row="1" Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0 0 3 3">
46-
<controls:LinkControl FontSize="10" Margin="5 0 0 0" Name="DisableUpdatesLink" Click="DisableUpdatesLink_OnClick">Don't Check for Updates</controls:LinkControl>
47-
</StackPanel>
48-
</Grid>
25+
<Grid ColumnDefinitions="Auto, *, Auto" RowDefinitions="Auto, Auto">
26+
27+
<avalonia:MaterialIcon Grid.Row="0"
28+
Grid.Column="0"
29+
Grid.RowSpan="2"
30+
Kind="Update"
31+
Width="30"
32+
Height="30"
33+
Margin="5 0 0 0"
34+
></avalonia:MaterialIcon>
35+
36+
<StackPanel Grid.Row="" Grid.Column="1" Orientation="Horizontal" Margin="5">
37+
<TextBlock>A new version of the MSU Scripter is now available!</TextBlock>
38+
<controls:LinkControl Margin="5 0 0 0" Name="GitHubUrlLink" Click="GitHubUrlLink_OnClick">Click here to go to the download page.</controls:LinkControl>
39+
</StackPanel>
4940

41+
<controls:ImageButton Grid.Row="0" Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Top" Name="CloseUpdateButton" Click="CloseUpdateButton_OnClick" Margin="0 3 3 0">
42+
<avalonia:MaterialIcon Kind="Close" Width="12" Height="12" Background="Transparent"></avalonia:MaterialIcon>
43+
</controls:ImageButton>
44+
45+
<StackPanel Grid.Row="1" Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0 0 3 3">
46+
<controls:LinkControl FontSize="10" Margin="5 0 0 0" Name="DisableUpdatesLink" Click="DisableUpdatesLink_OnClick">Don't Check for Updates</controls:LinkControl>
47+
</StackPanel>
48+
</Grid>
5049

5150
</controls:HeaderFooter>
5251

MSUScripter/Views/MainWindow.axaml.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
using System;
22
using System.IO;
3+
using System.Threading.Tasks;
34
using Avalonia.Controls;
45
using Avalonia.Interactivity;
6+
using AvaloniaControls;
57
using AvaloniaControls.Controls;
68
using AvaloniaControls.Extensions;
79
using MSUScripter.Configs;
810
using MSUScripter.Events;
911
using MSUScripter.Models;
1012
using MSUScripter.Services.ControlServices;
13+
using MSUScripter.Tools;
1114
using MSUScripter.ViewModels;
15+
using FileInputControlType = AvaloniaControls.FileInputControlType;
1216

1317
namespace MSUScripter.Views;
1418

@@ -45,6 +49,47 @@ private async void Control_OnLoaded(object? sender, RoutedEventArgs e)
4549
{
4650
await GetNewProjectPanel().LoadProject(_model.InitProject, _model.InitBackupProject);
4751
}
52+
53+
if (_model.HasDoneFirstTimeSetup) return;
54+
await SetupMsuPcm();
55+
}
56+
57+
private async Task SetupMsuPcm()
58+
{
59+
if (_service == null) return;
60+
61+
var result = await MessageWindow.ShowYesNoDialog(
62+
"If you want to use msupcm++, you'll need to point the MSU Scripter to its location. Would you like to set the msupcm++ path now? You can always set it later in the settings if needed.",
63+
"Setup msupcm++", this);
64+
if (!result)
65+
{
66+
_service.UpdateHasDoneFirstTimeSetup(null);
67+
}
68+
69+
var documentsFolderPath = await this.GetDocumentsFolderPath();
70+
var filter = OperatingSystem.IsWindows()
71+
? "msupcm Executable:msupcm.exe;All Files:*.*"
72+
: "msupcm Executable:msupcm;All Files:*";
73+
var msuPcmPath = await CrossPlatformTools.OpenFileDialogAsync(this, FileInputControlType.OpenFile, filter, documentsFolderPath);
74+
75+
if (msuPcmPath == null)
76+
{
77+
_service.UpdateHasDoneFirstTimeSetup(null);
78+
return;
79+
}
80+
81+
_service.UpdateHasDoneFirstTimeSetup(msuPcmPath.Path.LocalPath);
82+
83+
if (!_service.ValidateMsuPcm(msuPcmPath.Path.LocalPath))
84+
{
85+
await MessageWindow.ShowErrorDialog(
86+
"msupcm++ failed to run successfully. Make sure you can run msupcm -v in the commandline.",
87+
"msupcm++ Error", this);
88+
}
89+
else
90+
{
91+
await MessageWindow.ShowInfoDialog("msupcm++ setup successful.", "Success", this);
92+
}
4893
}
4994

5095
private async void Window_OnClosing(object? sender, WindowClosingEventArgs e)

0 commit comments

Comments
 (0)