点击乱说话功能

This commit is contained in:
ZouJin 2023-08-14 00:39:46 +10:00
parent f54b12f960
commit f39108bc00
11 changed files with 193 additions and 74 deletions

View File

@ -15,37 +15,42 @@
<SolidColorBrush x:Key="Foreground" Color="#FF0286C6" /> <SolidColorBrush x:Key="Foreground" Color="#FF0286C6" />
</ResourceDictionary> </ResourceDictionary>
</Viewbox.Resources> </Viewbox.Resources>
<Border BorderThickness="4" CornerRadius="5" Background="{DynamicResource Background}" <Grid Height="180" Width="300">
BorderBrush="{DynamicResource BorderBrush}" Height="180" Width="300"> <Border x:Name="DisplayBorder" BorderThickness="4" CornerRadius="5" Background="{DynamicResource Background}"
<Grid> BorderBrush="{DynamicResource BorderBrush}">
<Grid.ColumnDefinitions> <Grid>
<ColumnDefinition Width="2*" /> <Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" /> <ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions> <ColumnDefinition Width="1*" />
<Grid.RowDefinitions> </Grid.ColumnDefinitions>
<RowDefinition Height="2*" /> <Grid.RowDefinitions>
<RowDefinition Height="4*" /> <RowDefinition Height="2*" />
<RowDefinition Height="1.5*" /> <RowDefinition Height="4*" />
</Grid.RowDefinitions> <RowDefinition Height="1.5*" />
<TextBlock x:Name="tNow" Foreground="{DynamicResource Foreground}" FontSize="36" FontWeight="Bold" </Grid.RowDefinitions>
HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,0,5,0" Grid.ColumnSpan="2" <TextBlock x:Name="tNow" Foreground="{DynamicResource Foreground}" FontSize="36" FontWeight="Bold"
Text="当前已工作" /> HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,0,5,0" Grid.ColumnSpan="2"
<TextBlock x:Name="tNumber" Background="{x:Null}" Text="15.0" Grid.Row="1" FontSize="80" FontWeight="Bold" Text="当前已工作" />
HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{DynamicResource Foreground}" /> <TextBlock x:Name="tNumber" Background="{x:Null}" Text="15.0" Grid.Row="1" FontSize="80"
<TextBlock x:Name="tNumberUnit" Text="分钟" Foreground="{DynamicResource Foreground}" Grid.Row="1" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"
Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,15" Foreground="{DynamicResource Foreground}" />
FontSize="36" /> <TextBlock x:Name="tNumberUnit" Text="分钟" Foreground="{DynamicResource Foreground}" Grid.Row="1"
<ProgressBar x:Name="PBLeft" Grid.Row="2" Grid.ColumnSpan="2" Background="{x:Null}" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,15"
Foreground="{DynamicResource ButtonBackgroundHover}" Value="20" /> FontSize="36" />
<Button x:Name="btnStop" Grid.Row="2" Grid.ColumnSpan="2" Foreground="{DynamicResource ButtonForeground}" <ProgressBar x:Name="PBLeft" Grid.Row="2" Grid.ColumnSpan="2" Background="{x:Null}"
Background="{DynamicResource ButtonBackground}" Content="{ll:Str 停止工作}" FontSize="24" Click="btnStop_Click" Foreground="{DynamicResource ButtonBackgroundHover}" Value="20" />
pu:ButtonHelper.HoverBackground="{DynamicResource ButtonBackgroundHover}" /> <Button x:Name="btnStop" Grid.Row="2" Grid.ColumnSpan="2"
<Button HorizontalAlignment="Left" VerticalAlignment="Center" Padding="5,5,8,7" Foreground="{DynamicResource ButtonForeground}" Background="{DynamicResource ButtonBackground}"
Background="{DynamicResource BorderBrush}" pu:ButtonHelper.CornerRadius="5" Margin="10,0,0,0" Content="{ll:Str 停止工作}" FontSize="24" Click="btnStop_Click"
Click="SwitchState_Click"> pu:ButtonHelper.HoverBackground="{DynamicResource ButtonBackgroundHover}" />
<Path Fill="{DynamicResource ButtonForeground}" </Grid>
Data="M3 2.9918C3 2.44405 3.44495 2 3.9934 2H20.0066C20.5552 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5447 3 21.0082V2.9918ZM19 11V4H5V11H19ZM19 13H5V20H19V13ZM9 6H15V8H9V6ZM9 15H15V17H9V15Z" /> </Border>
</Button> <Button HorizontalAlignment="Left" VerticalAlignment="Top" Padding="5,5,8,7"
</Grid> Background="{DynamicResource BorderBrush}" pu:ButtonHelper.CornerRadius="5" Margin="10,10,0,0"
</Border> Click="SwitchState_Click">
<Path Fill="{DynamicResource ButtonForeground}"
Data="M3 2.9918C3 2.44405 3.44495 2 3.9934 2H20.0066C20.5552 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5447 3 21.0082V2.9918ZM19 11V4H5V11H19ZM19 13H5V20H19V13ZM9 6H15V8H9V6ZM9 15H15V17H9V15Z" />
</Button>
</Grid>
</Viewbox> </Viewbox>

View File

@ -86,6 +86,8 @@ namespace VPet_Simulator.Core
else else
tNumberUnit.Text = LocalizeCore.Translate("EXP"); tNumberUnit.Text = LocalizeCore.Translate("EXP");
break; break;
case 3:
break;
} }
} }
public void ShowTimeSpan(TimeSpan ts) public void ShowTimeSpan(TimeSpan ts)
@ -108,31 +110,38 @@ namespace VPet_Simulator.Core
} }
public void DisplayUI() public void DisplayUI()
{ {
btnStop.Content = LocalizeCore.Translate("停止") + nowWork.NameTrans; if (DisplayType == 3)
switch (DisplayType)
{ {
default: DisplayBorder.Visibility = Visibility.Collapsed;
case 0:
tNow.Text = LocalizeCore.Translate("当前已") + nowWork.NameTrans;
break;
case 1:
tNow.Text = LocalizeCore.Translate("剩余{0}时间", nowWork.NameTrans);
break;
case 2:
if (nowWork.Type == Work.WorkType.Work)
tNow.Text = LocalizeCore.Translate("累计金钱收益");
else
tNow.Text = LocalizeCore.Translate("获得经验值");
break;
} }
else
{
DisplayBorder.Visibility = Visibility.Visible;
btnStop.Content = LocalizeCore.Translate("停止") + nowWork.NameTrans;
switch (DisplayType)
{
default:
case 0:
tNow.Text = LocalizeCore.Translate("当前已") + nowWork.NameTrans;
break;
case 1:
tNow.Text = LocalizeCore.Translate("剩余{0}时间", nowWork.NameTrans);
break;
case 2:
if (nowWork.Type == Work.WorkType.Work)
tNow.Text = LocalizeCore.Translate("累计金钱收益");
else
tNow.Text = LocalizeCore.Translate("获得经验值");
break;
}
}
M_TimeUIHandle(m); M_TimeUIHandle(m);
} }
private void SwitchState_Click(object sender, RoutedEventArgs e) private void SwitchState_Click(object sender, RoutedEventArgs e)
{ {
DisplayType++; DisplayType++;
if (DisplayType >= 3) if (DisplayType >= 4)
DisplayType = 0; DisplayType = 0;
DisplayUI(); DisplayUI();
} }
public void Start(Work work) public void Start(Work work)

View File

@ -60,6 +60,15 @@ namespace VPet_Simulator.Windows.Interface
/// </summary> /// </summary>
List<LowText> LowDrinkText { get; } List<LowText> LowDrinkText { get; }
/// <summary> /// <summary>
/// 点击时会说的话
/// </summary>
List<ClickText> ClickTexts { get; }
/// <summary>
/// 获得自动点击的文本
/// </summary>
/// <returns>说话内容</returns>
ClickText GetClickText();
/// <summary>
/// 图片资源 /// 图片资源
/// </summary> /// </summary>
ImageResources ImageSources { get; } ImageResources ImageSources { get; }

View File

@ -5,6 +5,8 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using VPet_Simulator.Core;
using static VPet_Simulator.Core.Main;
namespace VPet_Simulator.Windows.Interface namespace VPet_Simulator.Windows.Interface
{ {
@ -13,8 +15,17 @@ namespace VPet_Simulator.Windows.Interface
/// </summary> /// </summary>
public class ClickText public class ClickText
{ {
public ClickText()
{
}
public ClickText(string text)
{
Text = text;
}
[Line(ignoreCase: true)] [Line(ignoreCase: true)]
private int mode { get; set; } = 15; private int mode { get; set; } = 7;
/// <summary> /// <summary>
/// 需求状态模式 /// 需求状态模式
/// </summary> /// </summary>
@ -28,7 +39,7 @@ namespace VPet_Simulator.Windows.Interface
/// </summary> /// </summary>
[Flags] [Flags]
public enum ModeType public enum ModeType
{ {
/// <summary> /// <summary>
/// 高兴 /// 高兴
/// </summary> /// </summary>
@ -57,7 +68,7 @@ namespace VPet_Simulator.Windows.Interface
/// </summary> /// </summary>
[Flags] [Flags]
public enum DayTime public enum DayTime
{ {
Morning = 1, Morning = 1,
Afternoon = 2, Afternoon = 2,
Night = 4, Night = 4,
@ -86,7 +97,11 @@ namespace VPet_Simulator.Windows.Interface
/// </summary> /// </summary>
[Line(IgnoreCase = true)] [Line(IgnoreCase = true)]
public int LikeMax = int.MaxValue; public int LikeMax = int.MaxValue;
/// <summary>
/// 工作状态
/// </summary>
[Line(IgnoreCase = true)]
public WorkingState State { get; set; } = WorkingState.Nomal;
/// <summary> /// <summary>
/// 说话的内容 /// 说话的内容
/// </summary> /// </summary>
@ -106,6 +121,31 @@ namespace VPet_Simulator.Windows.Interface
} }
return transText; return transText;
} }
set
{
transText = value;
}
}
/// <summary>
/// 检查部分状态是否满足需求
/// </summary>之所以不是全部的,是因为挨个取效率太差了
public bool CheckState(Main m)
{
if (m.Core.Save.Likability < LikeMin || m.Core.Save.Likability > LikeMax)
return false;
if (string.IsNullOrWhiteSpace(Working))
{
if (State != m.State)
return false;
}
else
{
if (State != WorkingState.Work)
return false;
if (m.nowWork.Name != Working)
return false;
}
return true;
} }
} }
} }

View File

@ -97,7 +97,7 @@ namespace VPet_Simulator.Windows
if (!IsOnMOD(mw)) if (!IsOnMOD(mw))
{ {
//Content = "该模组已停用".Translate(); Tag.Add("该模组已停用");
return; return;
} }

View File

@ -53,6 +53,47 @@ namespace VPet_Simulator.Windows
public List<LowText> LowFoodText { get; set; } = new List<LowText>(); public List<LowText> LowFoodText { get; set; } = new List<LowText>();
public List<LowText> LowDrinkText { get; set; } = new List<LowText>(); public List<LowText> LowDrinkText { get; set; } = new List<LowText>();
public List<ClickText> ClickTexts { get; set; } = new List<ClickText>();
/// <summary>
/// 获得自动点击的文本
/// </summary>
/// <returns>说话内容</returns>
public ClickText GetClickText()
{
ClickText.DayTime dt;
var now = DateTime.Now.Hour;
if (now < 6)
dt = ClickText.DayTime.Midnight;
else if (now < 12)
dt = ClickText.DayTime.Morning;
else if (now < 18)
dt = ClickText.DayTime.Afternoon;
else
dt = ClickText.DayTime.Night;
ClickText.ModeType mt;
switch (Core.Save.Mode)
{
case GameSave.ModeType.PoorCondition:
mt = ClickText.ModeType.PoorCondition;
break;
default:
case GameSave.ModeType.Nomal:
mt = ClickText.ModeType.Nomal;
break;
case GameSave.ModeType.Happy:
mt = ClickText.ModeType.Happy;
break;
case GameSave.ModeType.Ill:
mt = ClickText.ModeType.Ill;
break;
}
var list = ClickTexts.FindAll(x => x.DaiTime.HasFlag(dt) && x.Mode.HasFlag(mt) && x.CheckState(Main));
if (list.Count == 0)
return null;
return list[Function.Rnd.Next(list.Count)];
}
/// <summary> /// <summary>
/// 存档 Hash检查 是否通过 /// 存档 Hash检查 是否通过
/// </summary> /// </summary>

View File

@ -154,7 +154,6 @@ namespace VPet_Simulator.Windows
System.Environment.Exit(0); System.Environment.Exit(0);
} }
private List<string> rndtext;
public long lastclicktime { get; set; } public long lastclicktime { get; set; }
public void LoadLatestSave(string petname) public void LoadLatestSave(string petname)
@ -278,25 +277,27 @@ namespace VPet_Simulator.Windows
AutoSaveTimer.Interval = Set.AutoSaveInterval * 60000; AutoSaveTimer.Interval = Set.AutoSaveInterval * 60000;
AutoSaveTimer.Start(); AutoSaveTimer.Start();
} }
ClickTexts.Add(new ClickText("你知道吗? 鼠标右键可以打开菜单栏"));
ClickTexts.Add(new ClickText("你知道吗? 你可以在设置里面修改游戏的缩放比例"));
ClickTexts.Add(new ClickText("想要宠物不乱动? 设置里可以设置智能移动或者关闭移动"));
ClickTexts.Add(new ClickText("有建议/游玩反馈? 来 菜单-系统-反馈中心 反馈吧"));
ClickTexts.Add(new ClickText("长按脑袋拖动桌宠到你喜欢的任意位置"));
ClickTexts.Add(new ClickText("长按脑袋拖动桌宠到你喜欢的任意位置"));
//"如果你觉得目前功能太少,那就多挂会机. 宠物会自己动的".Translate(),
//"你知道吗? 你可以在设置里面修改游戏的缩放比例".Translate(),
//"你现在乱点说话是说话系统的一部分,不过还没做,在做了在做了ing".Translate(),
//"你添加了虚拟主播模拟器和虚拟桌宠模拟器到愿望单了吗? 快去加吧".Translate(),
//"这游戏开发这么慢,都怪画师太咕了".Translate(),
//"欢迎加入 虚拟主播模拟器群 430081239".Translate()
rndtext = new List<string>
{
"你知道吗? 鼠标右键可以打开菜单栏".Translate(),
"如果你觉得目前功能太少,那就多挂会机. 宠物会自己动的".Translate(),
"你知道吗? 你可以在设置里面修改游戏的缩放比例".Translate(),
"想要宠物不乱动? 设置里可以设置智能移动或者关闭移动".Translate(),
"有建议/游玩反馈? 来 菜单-系统-反馈中心 反馈吧".Translate(),
"你现在乱点说话是说话系统的一部分,不过还没做,在做了在做了ing".Translate(),
"你添加了虚拟主播模拟器和虚拟桌宠模拟器到愿望单了吗? 快去加吧".Translate(),
"这游戏开发这么慢,都怪画师太咕了".Translate(),
"长按脑袋拖动桌宠到你喜欢的任意位置".Translate(),
"欢迎加入 虚拟主播模拟器群 430081239".Translate()
};
await Dispatcher.InvokeAsync(new Action(() => LoadingText.Content = "尝试加载Steam内容".Translate())); await Dispatcher.InvokeAsync(new Action(() => LoadingText.Content = "尝试加载Steam内容".Translate()));
//给正在玩这个游戏的主播/游戏up主做个小功能 //给正在玩这个游戏的主播/游戏up主做个小功能
if (IsSteamUser) if (IsSteamUser)
{ {
rndtext.Add("关注 {0} 谢谢喵".Translate(SteamClient.Name)); ClickTexts.Add(new ClickText("关注 {0} 谢谢喵")
{
TranslateText = "关注 {0} 谢谢喵".Translate(SteamClient.Name)
});
//Steam成就 //Steam成就
Set.Statistics.StatisticChanged += Statistics_StatisticChanged; Set.Statistics.StatisticChanged += Statistics_StatisticChanged;
//Steam通知 //Steam通知
@ -306,7 +307,10 @@ namespace VPet_Simulator.Windows
} }
else else
{ {
rndtext.Add("关注 {0} 谢谢喵".Translate(Environment.UserName)); ClickTexts.Add(new ClickText("关注 {0} 谢谢喵")
{
TranslateText = "关注 {0} 谢谢喵".Translate(Environment.UserName)
});
} }
//音乐识别timer加载 //音乐识别timer加载
@ -380,7 +384,9 @@ 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;
Main.SayRnd(rndtext[Function.Rnd.Next(rndtext.Count)]); var rt = GetClickText();
if (rt != null)
Main.SayRnd(rt.TranslateText);
} }
}; };
Main.PlayVoiceVolume = Set.VoiceVolume; Main.PlayVoiceVolume = Set.VoiceVolume;

View File

@ -135,7 +135,7 @@ namespace VPet_Simulator.Windows
foreach (Sub sub in mw.Set["diy"]) foreach (Sub sub in mw.Set["diy"])
StackDIY.Children.Add(new DIYViewer(sub)); StackDIY.Children.Add(new DIYViewer(sub));
SliderResolution.Maximum = Math.Min(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, SliderResolution.Maximum = Math.Min(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width,
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height); System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height);
SliderResolution.Value = mw.Set.Resolution; SliderResolution.Value = mw.Set.Resolution;
@ -786,7 +786,10 @@ namespace VPet_Simulator.Windows
ButtonRestartGraph.Visibility = Visibility.Visible; ButtonRestartGraph.Visibility = Visibility.Visible;
if (ischangename) if (ischangename)
{
mw.Core.Save.Name = petloader.PetName.Translate(); mw.Core.Save.Name = petloader.PetName.Translate();
TextBoxPetName.Text = mw.Core.Save.Name;
}
} }
private void TextBoxPetName_TextChanged(object sender, TextChangedEventArgs e) private void TextBoxPetName_TextChanged(object sender, TextChangedEventArgs e)
@ -1070,7 +1073,10 @@ namespace VPet_Simulator.Windows
LocalizeCore.LoadCulture((string)LanguageBox.SelectedItem); LocalizeCore.LoadCulture((string)LanguageBox.SelectedItem);
mw.Set.Language = LocalizeCore.CurrentCulture; mw.Set.Language = LocalizeCore.CurrentCulture;
if (ischangename) if (ischangename)
{
mw.Core.Save.Name = petloader.PetName.Translate(); mw.Core.Save.Name = petloader.PetName.Translate();
TextBoxPetName.Text = mw.Core.Save.Name;
}
} }
private void MainTab_SelectionChanged(object sender, SelectionChangedEventArgs e) private void MainTab_SelectionChanged(object sender, SelectionChangedEventArgs e)

View File

@ -27,3 +27,4 @@ Happyly#Happily:|
Nomally#Nomally:| Nomally#Nomally:|
PoorConditionly#Sadly:| PoorConditionly#Sadly:|
Illly#Sickly:| Illly#Sickly:|
plugin#Code Plugin:|

View File

@ -27,3 +27,4 @@ Happyly#高兴地:|
Nomally#普通地:| Nomally#普通地:|
PoorConditionly#悲伤地:| PoorConditionly#悲伤地:|
Illly#生病地:| Illly#生病地:|
plugin#代码插件:|

View File

@ -27,3 +27,4 @@ Happyly#高興地:|
Nomally#普通地:| Nomally#普通地:|
PoorConditionly#悲傷地:| PoorConditionly#悲傷地:|
Illly#生病地:| Illly#生病地:|
plugin#代碼外掛:|