mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
实装说话随机功能
This commit is contained in:
parent
9d2594d057
commit
151d595294
@ -32,6 +32,11 @@ namespace VPet_Simulator.Core
|
||||
AutoReset = true,
|
||||
Enabled = true
|
||||
};
|
||||
readonly GraphCore.Helper.SayType[] sayTypes = new GraphCore.Helper.SayType[] { GraphCore.Helper.SayType.Serious, GraphCore.Helper.SayType.Shining, GraphCore.Helper.SayType.Self };
|
||||
public void SayRnd(string text)
|
||||
{
|
||||
Say(text, sayTypes[Function.Rnd.Next(sayTypes.Length)]);
|
||||
}
|
||||
/// <summary>
|
||||
/// 说话
|
||||
/// </summary>
|
||||
|
@ -310,7 +310,7 @@ namespace VPet_Simulator.Core
|
||||
{
|
||||
if (parant.Tag == this)
|
||||
{
|
||||
new Thread(() => Animations[0].Run(parant, EndAction)).Start();
|
||||
new Thread(() => Animations[0].Run((System.Windows.Controls.Image)parant.Child, EndAction)).Start();
|
||||
return;
|
||||
}
|
||||
System.Windows.Controls.Image img;
|
||||
@ -345,7 +345,7 @@ namespace VPet_Simulator.Core
|
||||
img.Source = new BitmapImage(new Uri(Path));
|
||||
|
||||
img.Width = Width;
|
||||
Task.Run(() => Animations[0].Run(parant, EndAction));
|
||||
Task.Run(() => Animations[0].Run((System.Windows.Controls.Image)parant.Child, EndAction));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -53,8 +53,13 @@ namespace VPet_Simulator.Core
|
||||
|
||||
public void Run(Border parant, Action EndAction = null)
|
||||
{
|
||||
if (PlayState)
|
||||
{
|
||||
IsLoop = true;
|
||||
return;
|
||||
}
|
||||
PlayState = true;
|
||||
StopEndAction = false;
|
||||
DoEndAction = true;
|
||||
parant.Dispatcher.Invoke(() =>
|
||||
{
|
||||
if (parant.Tag != this)
|
||||
@ -67,15 +72,17 @@ namespace VPet_Simulator.Core
|
||||
else
|
||||
{
|
||||
img = (Image)GraphCore.CommUIElements["Image2.Picture"];
|
||||
if (parant.Child != GraphCore.CommUIElements["Image2.Picture"])
|
||||
if (parant.Child != img)
|
||||
{
|
||||
if (img.Parent == null)
|
||||
{
|
||||
parant.Child = null;
|
||||
parant.Child = img;
|
||||
}
|
||||
else
|
||||
{
|
||||
img = (Image)GraphCore.CommUIElements["Image3.Picture"];
|
||||
parant.Child = null;
|
||||
parant.Child = img;
|
||||
}
|
||||
}
|
||||
@ -86,8 +93,8 @@ namespace VPet_Simulator.Core
|
||||
//bitmap.StreamSource = stream;
|
||||
//bitmap.CacheOption = BitmapCacheOption.OnLoad;
|
||||
//bitmap.EndInit();
|
||||
img.Source = new BitmapImage(new Uri(Path));
|
||||
parant.Tag = this;
|
||||
img.Source = new BitmapImage(new Uri(Path));
|
||||
parant.Tag = this;
|
||||
}
|
||||
Task.Run(() =>
|
||||
{
|
||||
@ -99,17 +106,17 @@ namespace VPet_Simulator.Core
|
||||
else
|
||||
{
|
||||
PlayState = false;
|
||||
if (!StopEndAction)
|
||||
if (DoEndAction)
|
||||
EndAction?.Invoke();//运行结束动画时事件
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
bool StopEndAction = false;
|
||||
bool DoEndAction = true;
|
||||
public void Stop(bool StopEndAction = false)
|
||||
{
|
||||
PlayState = false;
|
||||
this.StopEndAction = StopEndAction;
|
||||
this.DoEndAction = !StopEndAction;
|
||||
}
|
||||
|
||||
public void WaitForReadyRun(Border parant, Action EndAction = null) => Run(parant, EndAction);
|
||||
|
@ -242,7 +242,7 @@ namespace VPet_Simulator.Windows
|
||||
{
|
||||
lastclicktime = DateTime.Now.Ticks;
|
||||
var v = rndtext[Function.Rnd.Next(rndtext.Count)];
|
||||
Dispatcher.Invoke(() => Main.Say(v.Item1, v.Item2));
|
||||
Main.Say(v.Item1, v.Item2);
|
||||
}
|
||||
};
|
||||
Main.PlayVoiceVolume = Set.VoiceVolume;
|
||||
@ -322,14 +322,14 @@ namespace VPet_Simulator.Windows
|
||||
Main.Say("欢迎使用虚拟桌宠模拟器\n这是个早期的测试版,若有bug请多多包涵\n欢迎在菜单栏-管理-反馈中提交bug或建议", GraphCore.Helper.SayType.Shining);
|
||||
});
|
||||
}
|
||||
else if (Set["SingleTips"].GetDateTime("update") <= new DateTime(2023, 3, 27))
|
||||
else if (Set["SingleTips"].GetDateTime("update") <= new DateTime(2023, 5, 26))
|
||||
{
|
||||
if (Set["SingleTips"].GetDateTime("update") <= new DateTime(2023, 3, 4))
|
||||
notifyIcon.ShowBalloonTip(10, "更新通知 03/04",
|
||||
"现已接入ChatGPT, 右键和桌宠说话吧.\n已根据steamID独立创建的聊天API,调教你独属的桌宠吧", ToolTipIcon.Info);
|
||||
else
|
||||
notifyIcon.ShowBalloonTip(10, "更新通知 03/27",
|
||||
"全新图形核心引擎,现在桌宠对内存的占用更小!", ToolTipIcon.Info);
|
||||
// if (Set["SingleTips"].GetDateTime("update") <= new DateTime(2023, 3, 4))
|
||||
// notifyIcon.ShowBalloonTip(10, "更新通知 05/26",
|
||||
//"现已接入ChatGPT, 右键和桌宠说话吧.\n已根据steamID独立创建的聊天API,调教你独属的桌宠吧", ToolTipIcon.Info);
|
||||
// else
|
||||
notifyIcon.ShowBalloonTip(10, "更新通知 05/26",
|
||||
"新增学习打工等互动,新增开心的默认状态\n新增语音插件,请在设置中MOD管理开启", ToolTipIcon.Info);
|
||||
Set["SingleTips"].SetDateTime("update", DateTime.Now);
|
||||
}
|
||||
Save();
|
||||
|
@ -116,11 +116,11 @@ namespace VPet_Simulator.Windows
|
||||
responseString += "\n检测到模型错误,已重置桌宠聊天系统";
|
||||
ChatGPT_Reset();
|
||||
}
|
||||
m.Say(responseString, GraphCore.Helper.SayType.Serious);//todo
|
||||
m.SayRnd(responseString);//todo
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
m.Say(exp.ToString(), GraphCore.Helper.SayType.Serious);//todo
|
||||
m.Say(exp.ToString(), GraphCore.Helper.SayType.Serious);
|
||||
rettype = false;
|
||||
}
|
||||
Dispatcher.Invoke(() => this.IsEnabled = true);
|
||||
|
@ -70,7 +70,7 @@ namespace VPet_Simulator.Windows
|
||||
Dispatcher.Invoke(() => this.IsEnabled = false);
|
||||
try
|
||||
{
|
||||
m.Say(mw.CGPTClient.Ask("vpet", content).GetMessageContent(), GraphCore.Helper.SayType.Serious);
|
||||
m.SayRnd(mw.CGPTClient.Ask("vpet", content).GetMessageContent());
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
|
Before Width: | Height: | Size: 125 KiB After Width: | Height: | Size: 125 KiB |
Loading…
Reference in New Issue
Block a user