Skip to content

Commit f425661

Browse files
Updates to make the pcm warning header more consistent
1 parent bb91ce7 commit f425661

File tree

4 files changed

+34
-15
lines changed

4 files changed

+34
-15
lines changed

MSUScripter/Services/ControlServices/MsuSongMsuPcmInfoPanelService.cs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ public void AddSubTrack(int? index = null, bool addToParent = false)
5151
{ Project = _model.Project, Song = _model.Song, IsAlt = _model.IsAlt, ParentMsuPcmInfo = _model });
5252
}
5353
}
54-
54+
55+
var topLevelPcmInfo = _model.TopLevel;
56+
topLevelPcmInfo.UpdateSubTrackSubChannelWarning();
5557
}
5658

5759
public void AddSubChannel(int? index = null, bool addToParent = false)
@@ -82,6 +84,9 @@ public void AddSubChannel(int? index = null, bool addToParent = false)
8284
{ Project = _model.Project, Song = _model.Song, IsAlt = _model.IsAlt, ParentMsuPcmInfo = _model });
8385
}
8486
}
87+
88+
var topLevelPcmInfo = _model.TopLevel;
89+
topLevelPcmInfo.UpdateSubTrackSubChannelWarning();
8590
}
8691

8792
public void Delete()
@@ -99,13 +104,16 @@ public void Delete()
99104
{
100105
_model.ParentMsuPcmInfo.SubTracks.Remove(_model);
101106
}
107+
108+
var topLevelPcmInfo = _model.TopLevel;
109+
topLevelPcmInfo.UpdateSubTrackSubChannelWarning();
102110
}
103111

104112
public bool ShouldShowSubTracksSubChannelsWarningPopup(bool newSubTrack, bool newSubChannel)
105113
{
106114
var numSubTracks = _model.SubTracks.Count + (newSubTrack ? 1 : 0);
107115
var numSubChannels = _model.SubChannels.Count + (newSubChannel ? 1 : 0);
108-
return !settings.HideSubTracksSubChannelsWarning && numSubTracks > 1 && numSubChannels > 1;
116+
return !settings.HideSubTracksSubChannelsWarning && numSubTracks > 0 && numSubChannels > 0;
109117
}
110118

111119
public void HideSubTracksSubChannelsWarning()
@@ -208,20 +216,18 @@ public bool HasLoopDetails()
208216

209217
public void ImportAudioMetadata()
210218
{
219+
var topLevelPcmInfo = _model.TopLevel;
220+
211221
if (string.IsNullOrEmpty(_model.File) || !File.Exists(_model.File))
212222
{
223+
topLevelPcmInfo.UpdateHertzWarning(audioAnalysisService.GetAudioSampleRate(_model.File));
224+
topLevelPcmInfo.UpdateMultiWarning();
213225
return;
214226
}
215227

216228
var metadata = audioMetadataService.GetAudioMetadata(_model.File);
217229
_model.Song.ApplyAudioMetadata(metadata, false);
218-
219-
var topLevelPcmInfo = _model;
220-
while (topLevelPcmInfo.ParentMsuPcmInfo != null)
221-
{
222-
topLevelPcmInfo = topLevelPcmInfo.ParentMsuPcmInfo;
223-
}
224-
230+
225231
topLevelPcmInfo.UpdateHertzWarning(audioAnalysisService.GetAudioSampleRate(_model.File));
226232
topLevelPcmInfo.UpdateMultiWarning();
227233
}

MSUScripter/ViewModels/MsuSongMsuPcmInfoViewModel.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,19 @@ public MsuSongMsuPcmInfoViewModel()
9696
[SkipConvert]
9797
public MsuSongMsuPcmInfoViewModel? ParentMsuPcmInfo { get; set; }
9898

99+
[SkipConvert]
100+
public MsuSongMsuPcmInfoViewModel TopLevel
101+
{
102+
get
103+
{
104+
if (IsTopLevel) return this;
105+
var topModel = ParentMsuPcmInfo;
106+
while (topModel?.ParentMsuPcmInfo != null)
107+
topModel = topModel.ParentMsuPcmInfo;
108+
return topModel ?? this;
109+
}
110+
}
111+
99112
public bool CanDelete => !IsTopLevel;
100113

101114
public bool CanEditFile => !SubTracks.Any() && !SubChannels.Any();
@@ -167,7 +180,7 @@ public void ApplyCascadingSettings(MsuProjectViewModel projectModel, MsuSongInfo
167180

168181
public void UpdateHertzWarning(int? sampleRate)
169182
{
170-
DisplayHertzWarning = sampleRate > 44100;
183+
DisplayHertzWarning = sampleRate != 44100;
171184
}
172185

173186
public void UpdateMultiWarning()

MSUScripter/Views/AddSongWindow.axaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@
4848
<StackPanel Orientation="Horizontal"
4949
Margin="10 0 5 0"
5050
IsVisible="{Binding DisplayHertzWarning}"
51-
ToolTip.Tip="This is a non-44100Hz track. If using Audacity or another editor, make sure the project sample rate matches the audio source rate."
51+
ToolTip.Tip="This is a non-44100Hz file. If using Audacity or another editor, make sure the project sample rate matches the audio source rate."
5252
>
5353
<avalonia:MaterialIcon Kind="Info" Margin="0 0 3 0"></avalonia:MaterialIcon>
5454
<TextBlock VerticalAlignment="Center">
55-
Non-44100Hz Track
55+
Non-44100Hz File
5656
</TextBlock>
5757
</StackPanel>
5858
</controls1:CardControl.HeaderButtons>

MSUScripter/Views/MsuSongMsuPcmInfoPanel.axaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@
4343
<StackPanel Orientation="Horizontal"
4444
Margin="10 0 5 0"
4545
IsVisible="{Binding DisplayHertzWarning}"
46-
ToolTip.Tip="This is a non-44100Hz track. If using Audacity or another editor, make sure the project sample rate matches the audio source rate."
46+
ToolTip.Tip="This is a non-44100Hz file. If using Audacity or another editor, make sure the project sample rate matches the audio source rate."
4747
>
4848
<avalonia:MaterialIcon Kind="Info" Margin="0 0 3 0"></avalonia:MaterialIcon>
4949
<TextBlock VerticalAlignment="Center">
50-
Non-44100Hz Track
50+
Non-44100Hz File
5151
</TextBlock>
5252
</StackPanel>
5353
<Button
@@ -171,7 +171,7 @@
171171
<DataTemplate>
172172
<views:MsuSongMsuPcmInfoPanel
173173
DataContext="{Binding}"
174-
MsuPcmData="{Binding}"
174+
MsuPcmData="{Binding}"
175175
></views:MsuSongMsuPcmInfoPanel>
176176
</DataTemplate>
177177
</ItemsControl.ItemTemplate>

0 commit comments

Comments
 (0)