Skip to content

Commit

Permalink
点击乱说话功能
Browse files Browse the repository at this point in the history
  • Loading branch information
LorisYounger committed Aug 13, 2023
1 parent f54b12f commit f39108b
Show file tree
Hide file tree
Showing 11 changed files with 193 additions and 74 deletions.
71 changes: 38 additions & 33 deletions VPet-Simulator.Core/Display/WorkTimer.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,42 @@
<SolidColorBrush x:Key="Foreground" Color="#FF0286C6" />
</ResourceDictionary>
</Viewbox.Resources>
<Border BorderThickness="4" CornerRadius="5" Background="{DynamicResource Background}"
BorderBrush="{DynamicResource BorderBrush}" Height="180" Width="300">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="2*" />
<RowDefinition Height="4*" />
<RowDefinition Height="1.5*" />
</Grid.RowDefinitions>
<TextBlock x:Name="tNow" Foreground="{DynamicResource Foreground}" FontSize="36" FontWeight="Bold"
HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,0,5,0" Grid.ColumnSpan="2"
Text="当前已工作" />
<TextBlock x:Name="tNumber" Background="{x:Null}" Text="15.0" Grid.Row="1" FontSize="80" FontWeight="Bold"
HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{DynamicResource Foreground}" />
<TextBlock x:Name="tNumberUnit" Text="分钟" Foreground="{DynamicResource Foreground}" Grid.Row="1"
Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,15"
FontSize="36" />
<ProgressBar x:Name="PBLeft" Grid.Row="2" Grid.ColumnSpan="2" Background="{x:Null}"
Foreground="{DynamicResource ButtonBackgroundHover}" Value="20" />
<Button x:Name="btnStop" Grid.Row="2" Grid.ColumnSpan="2" Foreground="{DynamicResource ButtonForeground}"
Background="{DynamicResource ButtonBackground}" Content="{ll:Str 停止工作}" FontSize="24" Click="btnStop_Click"
pu:ButtonHelper.HoverBackground="{DynamicResource ButtonBackgroundHover}" />
<Button HorizontalAlignment="Left" VerticalAlignment="Center" Padding="5,5,8,7"
Background="{DynamicResource BorderBrush}" pu:ButtonHelper.CornerRadius="5" Margin="10,0,0,0"
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>
</Border>
<Grid Height="180" Width="300">
<Border x:Name="DisplayBorder" BorderThickness="4" CornerRadius="5" Background="{DynamicResource Background}"
BorderBrush="{DynamicResource BorderBrush}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="2*" />
<RowDefinition Height="4*" />
<RowDefinition Height="1.5*" />
</Grid.RowDefinitions>
<TextBlock x:Name="tNow" Foreground="{DynamicResource Foreground}" FontSize="36" FontWeight="Bold"
HorizontalAlignment="Right" VerticalAlignment="Center" Margin="5,0,5,0" Grid.ColumnSpan="2"
Text="当前已工作" />
<TextBlock x:Name="tNumber" Background="{x:Null}" Text="15.0" Grid.Row="1" FontSize="80"
FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center"
Foreground="{DynamicResource Foreground}" />
<TextBlock x:Name="tNumberUnit" Text="分钟" Foreground="{DynamicResource Foreground}" Grid.Row="1"
Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,15"
FontSize="36" />
<ProgressBar x:Name="PBLeft" Grid.Row="2" Grid.ColumnSpan="2" Background="{x:Null}"
Foreground="{DynamicResource ButtonBackgroundHover}" Value="20" />
<Button x:Name="btnStop" Grid.Row="2" Grid.ColumnSpan="2"
Foreground="{DynamicResource ButtonForeground}" Background="{DynamicResource ButtonBackground}"
Content="{ll:Str 停止工作}" FontSize="24" Click="btnStop_Click"
pu:ButtonHelper.HoverBackground="{DynamicResource ButtonBackgroundHover}" />
</Grid>
</Border>
<Button HorizontalAlignment="Left" VerticalAlignment="Top" Padding="5,5,8,7"
Background="{DynamicResource BorderBrush}" pu:ButtonHelper.CornerRadius="5" Margin="10,10,0,0"
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>
45 changes: 27 additions & 18 deletions VPet-Simulator.Core/Display/WorkTimer.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ private void M_TimeUIHandle(Main m)
else
tNumberUnit.Text = LocalizeCore.Translate("EXP");
break;
case 3:
break;
}
}
public void ShowTimeSpan(TimeSpan ts)
Expand All @@ -108,31 +110,38 @@ public void ShowTimeSpan(TimeSpan ts)
}
public void DisplayUI()
{
btnStop.Content = LocalizeCore.Translate("停止") + nowWork.NameTrans;
switch (DisplayType)
if (DisplayType == 3)
{
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;
DisplayBorder.Visibility = Visibility.Collapsed;
}
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);
}
private void SwitchState_Click(object sender, RoutedEventArgs e)
{
DisplayType++;
if (DisplayType >= 3)
DisplayType = 0;

if (DisplayType >= 4)
DisplayType = 0;
DisplayUI();
}
public void Start(Work work)
Expand Down
9 changes: 9 additions & 0 deletions VPet-Simulator.Windows.Interface/IMainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ public interface IMainWindow
/// </summary>
List<LowText> LowDrinkText { get; }
/// <summary>
/// 点击时会说的话
/// </summary>
List<ClickText> ClickTexts { get; }
/// <summary>
/// 获得自动点击的文本
/// </summary>
/// <returns>说话内容</returns>
ClickText GetClickText();
/// <summary>
/// 图片资源
/// </summary>
ImageResources ImageSources { get; }
Expand Down
48 changes: 44 additions & 4 deletions VPet-Simulator.Windows.Interface/Mod/ClickText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VPet_Simulator.Core;
using static VPet_Simulator.Core.Main;

namespace VPet_Simulator.Windows.Interface
{
Expand All @@ -13,8 +15,17 @@ namespace VPet_Simulator.Windows.Interface
/// </summary>
public class ClickText
{
public ClickText()
{

}
public ClickText(string text)
{
Text = text;
}

[Line(ignoreCase: true)]
private int mode { get; set; } = 15;
private int mode { get; set; } = 7;
/// <summary>
/// 需求状态模式
/// </summary>
Expand All @@ -28,7 +39,7 @@ public ModeType Mode
/// </summary>
[Flags]
public enum ModeType
{
{
/// <summary>
/// 高兴
/// </summary>
Expand Down Expand Up @@ -57,7 +68,7 @@ public enum ModeType
/// </summary>
[Flags]
public enum DayTime
{
{
Morning = 1,
Afternoon = 2,
Night = 4,
Expand Down Expand Up @@ -86,7 +97,11 @@ public DayTime DaiTime
/// </summary>
[Line(IgnoreCase = true)]
public int LikeMax = int.MaxValue;

/// <summary>
/// 工作状态
/// </summary>
[Line(IgnoreCase = true)]
public WorkingState State { get; set; } = WorkingState.Nomal;
/// <summary>
/// 说话的内容
/// </summary>
Expand All @@ -106,6 +121,31 @@ public string TranslateText
}
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;
}
}
}
2 changes: 1 addition & 1 deletion VPet-Simulator.Windows/Function/CoreMOD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public CoreMOD(DirectoryInfo directory, MainWindow mw)

if (!IsOnMOD(mw))
{
//Content = "该模组已停用".Translate();
Tag.Add("该模组已停用");
return;
}

Expand Down
41 changes: 41 additions & 0 deletions VPet-Simulator.Windows/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,47 @@ public partial class MainWindow : IMainWindow
public List<LowText> LowFoodText { 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>
/// 存档 Hash检查 是否通过
/// </summary>
Expand Down
40 changes: 23 additions & 17 deletions VPet-Simulator.Windows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ private void Restart_Closed(object sender, EventArgs e)
System.Environment.Exit(0);
}

private List<string> rndtext;
public long lastclicktime { get; set; }

public void LoadLatestSave(string petname)
Expand Down Expand Up @@ -278,25 +277,27 @@ public async void GameLoad()
AutoSaveTimer.Interval = Set.AutoSaveInterval * 60000;
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()));
//给正在玩这个游戏的主播/游戏up主做个小功能
if (IsSteamUser)
{
rndtext.Add("关注 {0} 谢谢喵".Translate(SteamClient.Name));
ClickTexts.Add(new ClickText("关注 {0} 谢谢喵")
{
TranslateText = "关注 {0} 谢谢喵".Translate(SteamClient.Name)
});
//Steam成就
Set.Statistics.StatisticChanged += Statistics_StatisticChanged;
//Steam通知
Expand All @@ -306,7 +307,10 @@ public async void GameLoad()
}
else
{
rndtext.Add("关注 {0} 谢谢喵".Translate(Environment.UserName));
ClickTexts.Add(new ClickText("关注 {0} 谢谢喵")
{
TranslateText = "关注 {0} 谢谢喵".Translate(Environment.UserName)
});
}

//音乐识别timer加载
Expand Down Expand Up @@ -380,7 +384,9 @@ await Dispatcher.InvokeAsync(new Action(() =>
if (new TimeSpan(DateTime.Now.Ticks - lastclicktime).TotalSeconds > 20)
{
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;
Expand Down
Loading

0 comments on commit f39108b

Please sign in to comment.