Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix LyricsReplaceDialog bug #1124

Merged
merged 2 commits into from
Jun 9, 2024
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
2 changes: 2 additions & 0 deletions OpenUtau/Strings/Strings.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
<system:String x:Key="errors.failed.save">Failed to save</system:String>
<system:String x:Key="errors.failed.savesingerconfig">Failed to save singer config file</system:String>
<system:String x:Key="errors.failed.searchsinger">Failed to search singers</system:String>
<system:String x:Key="errors.lyrics.regex">Character not allowed in regular expression</system:String>
<system:String x:Key="errors.lyrics.regexpreview">- regular expression error -</system:String>

<system:String x:Key="exps.abbr">Abbreviation</system:String>
<system:String x:Key="exps.apply">Apply</system:String>
Expand Down
2 changes: 2 additions & 0 deletions OpenUtau/Strings/Strings.ja-JP.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@
<system:String x:Key="errors.failed.save">保存に失敗しました</system:String>
<system:String x:Key="errors.failed.savesingerconfig">シンガー設定の保存に失敗しました</system:String>
<system:String x:Key="errors.failed.searchsinger">シンガーの取得に失敗しました</system:String>
<system:String x:Key="errors.lyrics.regex">正規表現に使用できない文字が含まれています</system:String>
<system:String x:Key="errors.lyrics.regexpreview">- 正規表現エラー -</system:String>

<system:String x:Key="exps.abbr">パラメータの略称</system:String>
<system:String x:Key="exps.apply">適用</system:String>
Expand Down
18 changes: 14 additions & 4 deletions OpenUtau/ViewModels/LyricsReplaceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ public LyricsReplaceViewModel(UVoicePart part, UNote[] notes, string[] lyrics) {

this.WhenAnyValue(x => x.OldValue, x => x.NewValue)
.Subscribe(t => {
Preview = Replace();
try {
Preview = Replace();
} catch {
Preview = ThemeManager.GetString("errors.lyrics.regexpreview");
}
});
this.WhenValueChanged(x => SelectedPreset)
.Subscribe(p => {
Expand All @@ -55,16 +59,22 @@ public string Replace() {
return string.Join(", ", Lyrics);
}

public void Finish() {
DocManager.Inst.StartUndoGroup();
public bool Finish() {
try {
Replace();
} catch (Exception ex) {
DocManager.Inst.ExecuteCmd(new ErrorMessageNotification(new MessageCustomizableException("Character not allowed in regular expression.", "<translate:errors.lyrics.regex>", ex)));
return false;
}

DocManager.Inst.StartUndoGroup();
for (int i = 0; i < Lyrics.Length && i < notes.Length; ++i) {
if (notes[i].lyric != Lyrics[i]) {
DocManager.Inst.ExecuteCmd(new ChangeNoteLyricCommand(part, notes[i], Lyrics[i]));
}
}

DocManager.Inst.EndUndoGroup();
return true;
}
}

Expand Down
5 changes: 3 additions & 2 deletions OpenUtau/Views/LyricsReplaceDialog.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ void OnCancel(object? sender, RoutedEventArgs e) {
}

void OnFinish(object? sender, RoutedEventArgs e) {
(DataContext as LyricsReplaceViewModel)!.Finish();
Close();
if((DataContext as LyricsReplaceViewModel)!.Finish()) {
Close();
}
}

private void OnKeyDown(object? sender, KeyEventArgs e) {
Expand Down
Loading