Skip to content

Commit

Permalink
fix: style parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
InuInu2022 committed Oct 18, 2024
1 parent ed6777f commit 10f99ef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/YMM4VoiSonaPlugin/VoiSonaTalkParameter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Immutable;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;

using YukkuriMovieMaker.Controls;
using YukkuriMovieMaker.Plugin.Voice;
Expand Down Expand Up @@ -91,13 +92,23 @@ public ImmutableList<VoiSonaTalkStyleParameter> ItemsCollection
get => _styles;
set
{
GetCaller(value);
UnsubscribeFromItems(_styles);
Set(ref _styles, value);
SubscribeToItems(_styles);
OnPropertyChanged(nameof(ItemsCollection));
}
}

[Conditional("DEBUG")]
void GetCaller(ImmutableList<VoiSonaTalkStyleParameter> value)
{
var dump = value.Select(v => $"{v.DisplayName}:{v.Value}");
var stackTrace = new StackTrace();
var callerMethod = stackTrace.GetFrame(3)?.GetMethod();
var caller = callerMethod?.Name ?? "unknown";
Debug.WriteLine($"from: {caller} {_voice} {string.Join(",",dump)}");
}

// 個々のアイテムの PropertyChanged イベントに登録
void SubscribeToItems(ImmutableList<VoiSonaTalkStyleParameter> newItems)
{
Expand All @@ -120,11 +131,4 @@ void Item_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
OnPropertyChanged($"{nameof(ItemsCollection)}.{e.PropertyName}");
}

public IVoiceParameter Clone()
{
var clone = YukkuriMovieMaker.Json.Json.GetClone(this);
clone!.ItemsCollection = ItemsCollection;
return clone;
}
}
1 change: 1 addition & 0 deletions src/YMM4VoiSonaPlugin/VoiSonaTalkSpeaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public IVoiceParameter CreateVoiceParameter()
_styles = saved.AsReadOnly();
return new VoiSonaTalkParameter
{
Voice = _voiceName,
ItemsCollection = _styles
.Select(v => new VoiSonaTalkStyleParameter(){
DisplayName=v.Key,
Expand Down

0 comments on commit 10f99ef

Please sign in to comment.