diff --git a/VPet-Simulator.Core/Display/Main.xaml b/VPet-Simulator.Core/Display/Main.xaml index 4c86f65..e4e41d3 100644 --- a/VPet-Simulator.Core/Display/Main.xaml +++ b/VPet-Simulator.Core/Display/Main.xaml @@ -7,7 +7,7 @@ - + diff --git a/VPet-Simulator.Core/Display/Main.xaml.cs b/VPet-Simulator.Core/Display/Main.xaml.cs index e44a5bb..6ee7fea 100644 --- a/VPet-Simulator.Core/Display/Main.xaml.cs +++ b/VPet-Simulator.Core/Display/Main.xaml.cs @@ -107,12 +107,44 @@ namespace VPet_Simulator.Core Core.TouchEvent.Add(new TouchArea(Core.Graph.GraphConfig.TouchRaisedLocate, Core.Graph.GraphConfig.TouchRaisedSize, DisplayRaised, true)); } /// - /// 播放语音 + /// 播放语音 语音播放时不会停止播放说话表情 /// /// 语音位置 - public void PlayVoice(Uri VoicePath) + public void PlayVoice(Uri VoicePath)//, TimeSpan timediff = TimeSpan.Zero) TODO { - VoicePlayer.Source = VoicePath; + PlayingVoice = true; + Dispatcher.Invoke(() => + { + VoicePlayer.Clock = new MediaTimeline(VoicePath).CreateClock(); + VoicePlayer.Clock.Completed += Clock_Completed; + VoicePlayer.Play(); + //Task.Run(() => + //{ + // Thread.Sleep(1000); + // Dispatcher.Invoke(() => + // { + // if (VoicePlayer?.Clock?.NaturalDuration.HasTimeSpan == true) + // PlayEndTime += VoicePlayer.Clock.NaturalDuration.TimeSpan - TimeSpan.FromSeconds(0.8); + // }); + //}); + }); + } + /// + /// 声音音量 + /// + public double PlayVoiceVolume + { + get => Dispatcher.Invoke(() => VoicePlayer.Volume); + set => Dispatcher.Invoke(() => VoicePlayer.Volume = value); + } + /// + /// 当前是否正在播放 + /// + public bool PlayingVoice = false; + private void Clock_Completed(object sender, EventArgs e) + { + PlayingVoice = false; + VoicePlayer.Clock = null; } private void SmartMoveTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) diff --git a/VPet-Simulator.Core/Display/MessageBar.xaml.cs b/VPet-Simulator.Core/Display/MessageBar.xaml.cs index c37d35f..4da1af7 100644 --- a/VPet-Simulator.Core/Display/MessageBar.xaml.cs +++ b/VPet-Simulator.Core/Display/MessageBar.xaml.cs @@ -57,6 +57,18 @@ namespace VPet_Simulator.Core } else { + if (m.PlayingVoice) + { + TimeSpan ts = Dispatcher.Invoke(() => m.VoicePlayer?.Clock?.NaturalDuration.HasTimeSpan == true ? (m.VoicePlayer.Clock.NaturalDuration.TimeSpan - m.VoicePlayer.Clock.CurrentTime.Value) : TimeSpan.Zero); + if (ts.TotalSeconds > 2) + { + return; + } + else + { + Console.WriteLine(1); + } + } Task.Run(() => { Thread.Sleep(timeleft * 50); @@ -78,7 +90,7 @@ namespace VPet_Simulator.Core } public Timer EndTimer = new Timer() { Interval = 200 }; - public Timer ShowTimer = new Timer() { Interval = 40 }; + public Timer ShowTimer = new Timer() { Interval = 50 }; public Timer CloseTimer = new Timer() { Interval = 20 }; int timeleft; GraphCore.Helper.SayType sayType; @@ -91,7 +103,7 @@ namespace VPet_Simulator.Core { if (m.UIGrid.Children.IndexOf(this) != m.UIGrid.Children.Count - 1) { - Panel.SetZIndex(this, m.UIGrid.Children.Count); + Panel.SetZIndex(this, m.UIGrid.Children.Count); } TText.Text = ""; outputtext = text.ToList(); diff --git a/VPet-Simulator.Core/Handle/GameSave.cs b/VPet-Simulator.Core/Handle/GameSave.cs index 053aa57..33fad69 100644 --- a/VPet-Simulator.Core/Handle/GameSave.cs +++ b/VPet-Simulator.Core/Handle/GameSave.cs @@ -33,7 +33,6 @@ namespace VPet_Simulator.Core /// public int Level => (int)(Math.Sqrt(Exp) / 5) + 1; - /// /// 升级所需经验值 /// @@ -239,6 +238,5 @@ namespace VPet_Simulator.Core //save.SetFloat("Likability", Likability); return LPSConvert.SerializeObject(this, "vpet"); } - } } diff --git a/VPet-Simulator.Windows.Interface/Setting.cs b/VPet-Simulator.Windows.Interface/Setting.cs index 1580c3f..dfa32c1 100644 --- a/VPet-Simulator.Windows.Interface/Setting.cs +++ b/VPet-Simulator.Windows.Interface/Setting.cs @@ -72,6 +72,14 @@ namespace VPet_Simulator.Windows.Interface } } /// + /// 播放声音大小 + /// + public double VoiceVolume + { + get => GetFloat("voicevolume", 0.5); + set => SetFloat("voicevolume", value); + } + /// /// 是否为更大的屏幕 /// public bool IsBiggerScreen diff --git a/VPet-Simulator.Windows/MainWindow.cs b/VPet-Simulator.Windows/MainWindow.cs index 7e06ca0..4eed823 100644 --- a/VPet-Simulator.Windows/MainWindow.cs +++ b/VPet-Simulator.Windows/MainWindow.cs @@ -55,7 +55,10 @@ namespace VPet_Simulator.Windows mp.Save(); //游戏存档 if (Set != null) + { + Set.VoiceVolume = Main.PlayVoiceVolume; File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + @"\Setting.lps", Set.ToString()); + } if (Core != null && Core.Save != null) File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + @"\Save.lps", Core.Save.ToLine().ToString()); if (CGPTClient != null) diff --git a/VPet-Simulator.Windows/MainWindow.xaml.cs b/VPet-Simulator.Windows/MainWindow.xaml.cs index a6e7083..133c552 100644 --- a/VPet-Simulator.Windows/MainWindow.xaml.cs +++ b/VPet-Simulator.Windows/MainWindow.xaml.cs @@ -245,6 +245,7 @@ namespace VPet_Simulator.Windows Dispatcher.Invoke(() => Main.Say(v.Item1, v.Item2)); } }; + Main.PlayVoiceVolume = Set.VoiceVolume; DisplayGrid.Child = Main; Task.Run(() => { diff --git a/VPet-Simulator.Windows/mod/1101_EdgeTTS b/VPet-Simulator.Windows/mod/1101_EdgeTTS new file mode 120000 index 0000000..a19acc3 --- /dev/null +++ b/VPet-Simulator.Windows/mod/1101_EdgeTTS @@ -0,0 +1 @@ +C:/Users/ZouJin/Documents/Visual Studio 2022/Project/VPet.Plugin.DemoClock/VPet.Plugin.EdgeTTS/1101_EdgeTTS \ No newline at end of file