支持多种说话动作

This commit is contained in:
ZouJin 2023-03-29 00:18:14 +11:00
parent a83b5a60b1
commit ccbe0b56cf
52 changed files with 177 additions and 160 deletions

3
.gitignore vendored
View File

@ -348,3 +348,6 @@ MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder # Ionide (cross platform F# VS Code tools) working folder
.ionide/ .ionide/
*.zip
*.rar

View File

@ -28,22 +28,22 @@ namespace VPet_Simulator.Core
/// 说话 /// 说话
/// </summary> /// </summary>
/// <param name="text">说话内容</param> /// <param name="text">说话内容</param>
public void Say(string text) public void Say(string text, GraphCore.Helper.SayType type)
{ {
if (DisplayType == GraphCore.GraphType.Default) if (type != GraphCore.Helper.SayType.None && DisplayType == GraphCore.GraphType.Default)
Display(GraphCore.GraphType.Say_A_Start, () => Display(GraphCore.Helper.Convert(type, GraphCore.Helper.AnimatType.A_Start), () =>
{ {
Dispatcher.Invoke(() => MsgBar.Show(Core.Save.Name, text)); Dispatcher.Invoke(() => MsgBar.Show(Core.Save.Name, text, type));
Saying(); Saying(type);
}); });
else else
{ {
Dispatcher.Invoke(() => MsgBar.Show(Core.Save.Name, text)); Dispatcher.Invoke(() => MsgBar.Show(Core.Save.Name, text, type));
} }
} }
public void Saying() public void Saying(GraphCore.Helper.SayType type)
{ {
Display(GraphCore.GraphType.Say_B_Loop, Saying); Display(GraphCore.Helper.Convert(type, GraphCore.Helper.AnimatType.B_Loop), () => Saying(type));
} }
private void EventTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) private void EventTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)

View File

@ -60,8 +60,8 @@ namespace VPet_Simulator.Core
Task.Run(() => Task.Run(() =>
{ {
Thread.Sleep(timeleft * 50); Thread.Sleep(timeleft * 50);
if (m.DisplayType == GraphCore.GraphType.Default || m.DisplayType.ToString().Contains("Say")) if (sayType != GraphCore.Helper.SayType.None && m.DisplayType.ToString().StartsWith("Say"))
m.Display(GraphCore.GraphType.Say_C_End, m.DisplayNomal); m.Display(GraphCore.Helper.Convert(sayType, GraphCore.Helper.AnimatType.C_End), m.DisplayNomal);
}); });
ShowTimer.Stop(); ShowTimer.Stop();
EndTimer.Start(); EndTimer.Start();
@ -81,12 +81,13 @@ namespace VPet_Simulator.Core
public Timer ShowTimer = new Timer() { Interval = 40 }; public Timer ShowTimer = new Timer() { Interval = 40 };
public Timer CloseTimer = new Timer() { Interval = 20 }; public Timer CloseTimer = new Timer() { Interval = 20 };
int timeleft; int timeleft;
GraphCore.Helper.SayType sayType;
/// <summary> /// <summary>
/// 显示消息 /// 显示消息
/// </summary> /// </summary>
/// <param name="name">名字</param> /// <param name="name">名字</param>
/// <param name="text">内容</param> /// <param name="text">内容</param>
public void Show(string name, string text) public void Show(string name, string text, GraphCore.Helper.SayType sayType)
{ {
if (m.UIGrid.Children.IndexOf(this) != m.UIGrid.Children.Count - 1) if (m.UIGrid.Children.IndexOf(this) != m.UIGrid.Children.Count - 1)
{ {
@ -100,6 +101,7 @@ namespace VPet_Simulator.Core
ShowTimer.Start(); EndTimer.Stop(); CloseTimer.Stop(); ShowTimer.Start(); EndTimer.Stop(); CloseTimer.Stop();
this.Visibility = Visibility.Visible; this.Visibility = Visibility.Visible;
Opacity = .8; Opacity = .8;
this.sayType = sayType;
} }
private void Border_MouseEnter(object sender, MouseEventArgs e) private void Border_MouseEnter(object sender, MouseEventArgs e)

View File

@ -3,10 +3,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Threading;
namespace VPet_Simulator.Core namespace VPet_Simulator.Core
{ {
@ -212,15 +209,27 @@ namespace VPet_Simulator.Core
/// <summary> /// <summary>
/// 说话 (开始) /// 说话 (开始)
/// </summary> /// </summary>
Say_A_Start, Say_Serious_A_Start,
/// <summary> /// <summary>
/// 说话 (循环) /// 说话 (循环)
/// </summary> /// </summary>
Say_B_Loop, Say_Serious_B_Loop,
/// <summary> /// <summary>
/// 说话 (结束) /// 说话 (结束)
/// </summary> /// </summary>
Say_C_End, Say_Serious_C_End,
/// <summary>
/// 说话 (开始)
/// </summary>
Say_Shining_A_Start,
/// <summary>
/// 说话 (循环)
/// </summary>
Say_Shining_B_Loop,
/// <summary>
/// 说话 (结束)
/// </summary>
Say_Shining_C_End,
/// <summary> /// <summary>
/// 待机 模式1 (开始) /// 待机 模式1 (开始)
/// </summary> /// </summary>
@ -254,40 +263,7 @@ namespace VPet_Simulator.Core
/// </summary> /// </summary>
Shutdown, Shutdown,
} }
///// <summary> loop 应该被取缔
///// 动画类型默认设置 前文本|是否循环|是否常用
///// </summary>
//public static readonly dynamic[][] GraphTypeValue = new dynamic[][]
//{
// new dynamic[]{ "raised_dynamic" ,false,true},
// new dynamic[]{ "raised_static_a", false,true},
// new dynamic[]{ "raised_static_b", false,true},
// new dynamic[]{ "climb_top_right", false,false},
// new dynamic[]{ "climb_top_left", false, false},
// new dynamic[]{ "Crawl_right", false,false},
// new dynamic[]{ "Crawl_left", false, false},
// new dynamic[]{ "climb_right", false, false},
// new dynamic[]{ "climb_left", false, false},
// new dynamic[]{ "default", true,true},
// new dynamic[]{ "touch_head_a", false,true},
// new dynamic[]{ "touch_head_b", false,true},
// new dynamic[]{ "touch_head_c", false,true},
// new dynamic[]{ "crawl_right", false, true},
// new dynamic[]{ "crawl_left", false, true},
// new dynamic[]{ "squat_a", false,true},
// new dynamic[]{ "squat_b", false, true},
// new dynamic[]{ "squat_c", false,true},
// new dynamic[]{ "fall_left_a", false, false},
// new dynamic[]{ "fall_left_b", false,true},
// new dynamic[]{ "fall_right_a", false, false},
// new dynamic[]{ "fall_right_b", false,true},
// new dynamic[]{ "walk_right_a", false,true},
// new dynamic[]{ "walk_right_b", false, true},
// new dynamic[]{ "walk_right_c", false,true},
// new dynamic[]{ "walk_left_a", false,true},
// new dynamic[]{ "walk_left_b", false, true},
// new dynamic[]{ "walk_left_c", false,true},
//};
/// <summary> /// <summary>
/// 图像字典 /// 图像字典
/// </summary> /// </summary>
@ -539,5 +515,27 @@ namespace VPet_Simulator.Core
} }
} }
} }
public static class Helper
{
public enum AnimatType
{
A_Start,
B_Loop,
C_End,
}
public enum SayType
{
None,
Default,
Serious,
Shining
}
public static GraphType Convert(SayType sayType, AnimatType type)
{
string say = "Say_" + sayType.ToString() + '_' + type.ToString(); // (type == null ? "" : '_' + type.ToString());
return (GraphType)Enum.Parse(typeof(GraphType), say);
}
}
} }
} }

View File

@ -344,7 +344,7 @@ namespace VPet_Simulator.Core
img.Source = new BitmapImage(new Uri(Path)); img.Source = new BitmapImage(new Uri(Path));
img.Width = Width; img.Width = Width;
new Thread(() => Animations[0].Run(parant, EndAction)).Start(); Task.Run(() => Animations[0].Run(parant, EndAction));
}); });
} }

View File

@ -8,6 +8,7 @@ using System.Windows.Media.Imaging;
using System.Windows; using System.Windows;
using System.IO; using System.IO;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Threading;
namespace VPet_Simulator.Core namespace VPet_Simulator.Core
{ {
@ -54,6 +55,8 @@ namespace VPet_Simulator.Core
{ {
PlayState = true; PlayState = true;
StopEndAction = false; StopEndAction = false;
parant.Dispatcher.Invoke(() =>
{
if (parant.Tag != this) if (parant.Tag != this)
{ {
System.Windows.Controls.Image img; System.Windows.Controls.Image img;
@ -100,6 +103,7 @@ namespace VPet_Simulator.Core
EndAction?.Invoke();//运行结束动画时事件 EndAction?.Invoke();//运行结束动画时事件
} }
}); });
});
} }
bool StopEndAction = false; bool StopEndAction = false;
public void Stop(bool StopEndAction = false) public void Stop(bool StopEndAction = false)

View File

@ -74,6 +74,10 @@ namespace VPet_Simulator.Core
{ {
graph.AddGraph(di.FullName, Save.ModeType.Ill, (GraphType)i); graph.AddGraph(di.FullName, Save.ModeType.Ill, (GraphType)i);
} }
else
{
graph.AddGraph(di.FullName, Save.ModeType.Nomal, (GraphType)i);
}
return; return;
} }
} }

View File

@ -15,6 +15,7 @@ using System.Timers;
using LinePutScript; using LinePutScript;
using System.Diagnostics; using System.Diagnostics;
using ChatGPT.API.Framework; using ChatGPT.API.Framework;
using static VPet_Simulator.Core.GraphCore;
namespace VPet_Simulator.Windows namespace VPet_Simulator.Windows
{ {
@ -50,11 +51,11 @@ namespace VPet_Simulator.Windows
//给正在玩这个游戏的主播/游戏up主做个小功能 //给正在玩这个游戏的主播/游戏up主做个小功能
if (IsSteamUser) if (IsSteamUser)
{ {
rndtext.Add($"关注 {Steamworks.SteamClient.Name} 谢谢喵"); rndtext.Add(new Tuple<string, Helper.SayType>($"关注 {SteamClient.Name} 谢谢喵", Helper.SayType.Shining));
} }
else else
{ {
rndtext.Add($"关注 {Environment.UserName} 谢谢喵"); rndtext.Add(new Tuple<string, Helper.SayType>($"关注 {Environment.UserName} 谢谢喵", Helper.SayType.Shining));
} }
//加载游戏设置 //加载游戏设置
if (new FileInfo(AppDomain.CurrentDomain.BaseDirectory + @"\Setting.lps").Exists) if (new FileInfo(AppDomain.CurrentDomain.BaseDirectory + @"\Setting.lps").Exists)
@ -111,18 +112,18 @@ namespace VPet_Simulator.Windows
System.Environment.Exit(0); System.Environment.Exit(0);
} }
private List<string> rndtext = new List<string> private List<Tuple<string, Helper.SayType>> rndtext = new List<Tuple<string, Helper.SayType>>
{ {
"你知道吗? 鼠标右键可以打开菜单栏", new Tuple<string, Helper.SayType>("你知道吗? 鼠标右键可以打开菜单栏", Helper.SayType.Serious),
"如果你觉得目前功能太少,那就多挂会机. 宠物会自己动的", new Tuple<string, Helper.SayType>("如果你觉得目前功能太少,那就多挂会机. 宠物会自己动的", Helper.SayType.Serious),
"你知道吗? 你可以在设置里面修改游戏的缩放比例", new Tuple<string, Helper.SayType>("你知道吗? 你可以在设置里面修改游戏的缩放比例", Helper.SayType.Serious),
"想要宠物不乱动? 设置里可以设置智能移动或者关闭移动", new Tuple<string, Helper.SayType>("想要宠物不乱动? 设置里可以设置智能移动或者关闭移动", Helper.SayType.Serious),
"有建议/游玩反馈? 来 菜单-系统-反馈中心 反馈吧", new Tuple<string, Helper.SayType>("有建议/游玩反馈? 来 菜单-系统-反馈中心 反馈吧", Helper.SayType.Serious),
"你现在乱点说话是说话系统的一部分,不过还没做,在做了在做了ing", new Tuple<string, Helper.SayType>("你现在乱点说话是说话系统的一部分,不过还没做,在做了在做了ing", Helper.SayType.Serious),
"你添加了虚拟主播模拟器和虚拟桌宠模拟器到愿望单了吗? 快去加吧", new Tuple<string, Helper.SayType>("你添加了虚拟主播模拟器和虚拟桌宠模拟器到愿望单了吗? 快去加吧", Helper.SayType.Serious),
"这游戏开发这么慢,都怪画师太咕了.\n记得多催催画师(@叶书天)画桌宠, 催的越快更新越快!", new Tuple<string, Helper.SayType>("这游戏开发这么慢,都怪画师太咕了.\n记得多催催画师(@叶书天)画桌宠, 催的越快更新越快!", Helper.SayType.Serious),
"长按脑袋拖动桌宠到你喜欢的任意位置", new Tuple<string, Helper.SayType>("长按脑袋拖动桌宠到你喜欢的任意位置", Helper.SayType.Serious),
"欢迎加入 虚拟主播模拟器群 430081239", new Tuple<string, Helper.SayType>("欢迎加入 虚拟主播模拟器群 430081239", Helper.SayType.Shining),
}; };
private long lastclicktime; private long lastclicktime;
public void GameLoad() public void GameLoad()
@ -201,7 +202,8 @@ namespace VPet_Simulator.Windows
if (new TimeSpan(DateTime.Now.Ticks - lastclicktime).TotalSeconds > 20) if (new TimeSpan(DateTime.Now.Ticks - lastclicktime).TotalSeconds > 20)
{ {
lastclicktime = DateTime.Now.Ticks; lastclicktime = DateTime.Now.Ticks;
Dispatcher.Invoke(() => Main.Say(rndtext[Function.Rnd.Next(rndtext.Count)])); var v = rndtext[Function.Rnd.Next(rndtext.Count)];
Dispatcher.Invoke(() => Main.Say(v.Item1, v.Item2));
} }
}; };
DisplayGrid.Child = Main; DisplayGrid.Child = Main;
@ -268,17 +270,17 @@ namespace VPet_Simulator.Windows
notifyIcon.ShowBalloonTip(10, "你好" + (IsSteamUser ? Steamworks.SteamClient.Name : Environment.UserName), notifyIcon.ShowBalloonTip(10, "你好" + (IsSteamUser ? Steamworks.SteamClient.Name : Environment.UserName),
"欢迎使用虚拟桌宠模拟器!\n如果遇到桌宠爬不见了,可以在我这里设置居中或退出桌宠", ToolTipIcon.Info); "欢迎使用虚拟桌宠模拟器!\n如果遇到桌宠爬不见了,可以在我这里设置居中或退出桌宠", ToolTipIcon.Info);
Thread.Sleep(2000); Thread.Sleep(2000);
Main.Say("欢迎使用虚拟桌宠模拟器\n这是个早期的测试版,若有bug请多多包涵\n欢迎在菜单栏-管理-反馈中提交bug或建议"); Main.Say("欢迎使用虚拟桌宠模拟器\n这是个早期的测试版,若有bug请多多包涵\n欢迎在菜单栏-管理-反馈中提交bug或建议", GraphCore.Helper.SayType.Shining);
}); });
} }
else if (Set["SingleTips"].GetDateTime("update") <= new DateTime(2023, 3, 4)) else if (Set["SingleTips"].GetDateTime("update") <= new DateTime(2023, 3, 27))
{ {
if (Set["SingleTips"].GetDateTime("update") <= new DateTime(2023, 2, 17)) if (Set["SingleTips"].GetDateTime("update") <= new DateTime(2023, 3, 4))
notifyIcon.ShowBalloonTip(10, "更新通知 02/17",
"现在使用缓存机制,不仅占用小,而且再也不会有那种闪闪的问题了!\n现已支持开机启动功能,前往设置设置开机启动", ToolTipIcon.Info);
else
notifyIcon.ShowBalloonTip(10, "更新通知 03/04", notifyIcon.ShowBalloonTip(10, "更新通知 03/04",
"现已接入ChatGPT, 右键和桌宠说话吧.\n已根据steamID独立创建的聊天API,调教你独属的桌宠吧", ToolTipIcon.Info); "现已接入ChatGPT, 右键和桌宠说话吧.\n已根据steamID独立创建的聊天API,调教你独属的桌宠吧", ToolTipIcon.Info);
else
notifyIcon.ShowBalloonTip(10, "更新通知 03/27",
"全新图形核心引擎,现在桌宠对内存的占用更小!", ToolTipIcon.Info);
Set["SingleTips"].SetDateTime("update", DateTime.Now); Set["SingleTips"].SetDateTime("update", DateTime.Now);
} }
Save(); Save();

View File

@ -115,11 +115,11 @@ namespace VPet_Simulator.Windows
responseString += "\n检测到模型错误,已重置桌宠聊天系统"; responseString += "\n检测到模型错误,已重置桌宠聊天系统";
ChatGPT_Reset(); ChatGPT_Reset();
} }
m.Say(responseString); m.Say(responseString, GraphCore.Helper.SayType.Serious);//todo
} }
catch (Exception exp) catch (Exception exp)
{ {
m.Say(exp.ToString()); m.Say(exp.ToString(), GraphCore.Helper.SayType.Serious);//todo
rettype = false; rettype = false;
} }
Dispatcher.Invoke(() => this.IsEnabled = true); Dispatcher.Invoke(() => this.IsEnabled = true);

View File

@ -66,17 +66,17 @@ namespace VPet_Simulator.Windows
} }
if (mw.CGPTClient == null) if (mw.CGPTClient == null)
{ {
m.Say("请先前往设置中设置 ChatGPT API"); m.Say("请先前往设置中设置 ChatGPT API", GraphCore.Helper.SayType.Serious);
return; return;
} }
Dispatcher.Invoke(() => this.IsEnabled = false); Dispatcher.Invoke(() => this.IsEnabled = false);
try try
{ {
m.Say(mw.CGPTClient.Ask("vpet", content).GetMessageContent()); m.Say(mw.CGPTClient.Ask("vpet", content).GetMessageContent(), GraphCore.Helper.SayType.Serious);
} }
catch (Exception exp) catch (Exception exp)
{ {
m.Say("API调用失败,请检查设置和网络连接\n" + exp.ToString()); m.Say("API调用失败,请检查设置和网络连接\n" + exp.ToString(), GraphCore.Helper.SayType.Serious);
} }
Dispatcher.Invoke(() => this.IsEnabled = true); Dispatcher.Invoke(() => this.IsEnabled = true);
} }

View File

@ -54,7 +54,7 @@
<TabItem Header="说话"> <TabItem Header="说话">
<Grid> <Grid>
<Label Background="{x:Null}" Content="输入要说的话,按说话键发送:&#13;选择说话类型:" /> <Label Background="{x:Null}" Content="输入要说的话,按说话键发送:&#13;选择说话类型:" />
<ComboBox VerticalAlignment="Top" Margin="110,26,5,0" /> <ComboBox x:Name="CombSay" VerticalAlignment="Top" Margin="110,26,5,0" />
<TextBox x:Name="SayTextBox" TextWrapping="Wrap" pu:TextBoxHelper.Watermark="在这里输入要说话的内容" VerticalAlignment="Top" <TextBox x:Name="SayTextBox" TextWrapping="Wrap" pu:TextBoxHelper.Watermark="在这里输入要说话的内容" VerticalAlignment="Top"
Margin="5,54,5,0" Height="200" AcceptsReturn="True" VerticalContentAlignment="Top" /> Margin="5,54,5,0" Height="200" AcceptsReturn="True" VerticalContentAlignment="Top" />
<Button VerticalAlignment="Bottom" Content="说话" Click="Say_Click" FontSize="24" /> <Button VerticalAlignment="Bottom" Content="说话" Click="Say_Click" FontSize="24" />

View File

@ -31,6 +31,10 @@ namespace VPet_Simulator.Windows
{ {
GraphListBox.Items.Add(v); GraphListBox.Items.Add(v);
} }
foreach (string v in Enum.GetNames(typeof(GraphCore.Helper.SayType)))
{
CombSay.Items.Add(v);
}
DestanceTimer.Elapsed += DestanceTimer_Elapsed; DestanceTimer.Elapsed += DestanceTimer_Elapsed;
} }
@ -146,7 +150,7 @@ namespace VPet_Simulator.Windows
private void Say_Click(object sender, RoutedEventArgs e) private void Say_Click(object sender, RoutedEventArgs e)
{ {
mw.Main.Say(SayTextBox.Text); mw.Main.Say(SayTextBox.Text, (Helper.SayType)Enum.Parse(typeof(Helper.SayType), CombSay.Text));
} }
Timer DestanceTimer = new Timer() Timer DestanceTimer = new Timer()
{ {

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB