mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
新的文本选择聊天系统
作者提供的API将会逐步下线
This commit is contained in:
parent
e0de4ec6f8
commit
65e4fee2ef
@ -13,7 +13,7 @@ namespace VPet_Simulator.Windows.Interface
|
||||
/// <summary>
|
||||
/// 点击桌宠时触发的乱说话
|
||||
/// </summary>
|
||||
public class ClickText
|
||||
public class ClickText : ICheckText
|
||||
{
|
||||
public ClickText()
|
||||
{
|
||||
@ -24,39 +24,7 @@ namespace VPet_Simulator.Windows.Interface
|
||||
Text = text;
|
||||
}
|
||||
|
||||
[Line(ignoreCase: true)]
|
||||
private int mode { get; set; } = 7;
|
||||
/// <summary>
|
||||
/// 需求状态模式
|
||||
/// </summary>
|
||||
public ModeType Mode
|
||||
{
|
||||
get => (ModeType)mode;
|
||||
set => mode = (int)value;
|
||||
}
|
||||
/// <summary>
|
||||
/// 宠物状态模式
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum ModeType
|
||||
{
|
||||
/// <summary>
|
||||
/// 高兴
|
||||
/// </summary>
|
||||
Happy = 1,
|
||||
/// <summary>
|
||||
/// 普通
|
||||
/// </summary>
|
||||
Nomal = 2,
|
||||
/// <summary>
|
||||
/// 状态不佳
|
||||
/// </summary>
|
||||
PoorCondition = 4,
|
||||
/// <summary>
|
||||
/// 生病(躺床)
|
||||
/// </summary>
|
||||
Ill = 8
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 指定干活时说, 空为任意, sleep 为睡觉时
|
||||
/// </summary>
|
||||
@ -87,52 +55,21 @@ namespace VPet_Simulator.Windows.Interface
|
||||
get => (DayTime)dayTime;
|
||||
set => dayTime = (int)value;
|
||||
}
|
||||
/// <summary>
|
||||
/// 好感度要求:最小值
|
||||
/// </summary>
|
||||
[Line(IgnoreCase = true)]
|
||||
public int LikeMin = 0;
|
||||
/// <summary>
|
||||
/// 好感度要求:最大值
|
||||
/// </summary>
|
||||
[Line(IgnoreCase = true)]
|
||||
public int LikeMax = int.MaxValue;
|
||||
|
||||
/// <summary>
|
||||
/// 工作状态
|
||||
/// </summary>
|
||||
[Line(IgnoreCase = true)]
|
||||
public WorkingState State { get; set; } = WorkingState.Nomal;
|
||||
/// <summary>
|
||||
/// 说话的内容
|
||||
/// </summary>
|
||||
[Line(IgnoreCase = true)] public string Text { get; set; }
|
||||
|
||||
private string transText = null;
|
||||
/// <summary>
|
||||
/// 说话的内容 (翻译)
|
||||
/// </summary>
|
||||
public string TranslateText
|
||||
{
|
||||
get
|
||||
{
|
||||
if (transText == null)
|
||||
{
|
||||
transText = LocalizeCore.Translate(Text);
|
||||
}
|
||||
return transText;
|
||||
}
|
||||
set
|
||||
{
|
||||
transText = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查部分状态是否满足需求
|
||||
/// </summary>之所以不是全部的,是因为挨个取效率太差了
|
||||
public bool CheckState(Main m)
|
||||
public override bool CheckState(Main m)
|
||||
{
|
||||
if (m.Core.Save.Likability < LikeMin || m.Core.Save.Likability > LikeMax)
|
||||
if (!base.CheckState(m))
|
||||
return false;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(Working))
|
||||
{
|
||||
if (State != m.State)
|
||||
|
190
VPet-Simulator.Windows.Interface/Mod/ICheckText.cs
Normal file
190
VPet-Simulator.Windows.Interface/Mod/ICheckText.cs
Normal file
@ -0,0 +1,190 @@
|
||||
using LinePutScript.Converter;
|
||||
using LinePutScript.Localization.WPF;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static VPet_Simulator.Core.Main;
|
||||
using VPet_Simulator.Core;
|
||||
|
||||
namespace VPet_Simulator.Windows.Interface
|
||||
{
|
||||
/// <summary>
|
||||
/// 所有可以检查的文本格式
|
||||
/// </summary>
|
||||
public class ICheckText
|
||||
{
|
||||
[Line(ignoreCase: true)]
|
||||
private int mode { get; set; } = 7;
|
||||
/// <summary>
|
||||
/// 需求状态模式
|
||||
/// </summary>
|
||||
public ModeType Mode
|
||||
{
|
||||
get => (ModeType)mode;
|
||||
set => mode = (int)value;
|
||||
}
|
||||
/// <summary>
|
||||
/// 宠物状态模式
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum ModeType
|
||||
{
|
||||
/// <summary>
|
||||
/// 高兴
|
||||
/// </summary>
|
||||
Happy = 1,
|
||||
/// <summary>
|
||||
/// 普通
|
||||
/// </summary>
|
||||
Nomal = 2,
|
||||
/// <summary>
|
||||
/// 状态不佳
|
||||
/// </summary>
|
||||
PoorCondition = 4,
|
||||
/// <summary>
|
||||
/// 生病(躺床)
|
||||
/// </summary>
|
||||
Ill = 8
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 好感度要求:最小值
|
||||
/// </summary>
|
||||
[Line(IgnoreCase = true)]
|
||||
public double LikeMin { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 好感度要求:最大值
|
||||
/// </summary>
|
||||
[Line(IgnoreCase = true)]
|
||||
public double LikeMax { get; set; } = int.MaxValue;
|
||||
/// <summary>
|
||||
/// 健康度要求:最小值
|
||||
/// </summary>
|
||||
[Line(IgnoreCase = true)]
|
||||
public double HealthMin { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 健康度要求:最大值
|
||||
/// </summary>
|
||||
[Line(IgnoreCase = true)]
|
||||
public double HealthMax { get; set; } = int.MaxValue;
|
||||
/// <summary>
|
||||
/// 等级要求:最小值
|
||||
/// </summary>
|
||||
[Line(IgnoreCase = true)] public double LevelMin { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 等级要求:最大值
|
||||
/// </summary>
|
||||
[Line(IgnoreCase = true)] public double LevelMax { get; set; } = int.MaxValue;
|
||||
/// <summary>
|
||||
/// 金钱要求:最小值
|
||||
/// </summary>
|
||||
[Line(IgnoreCase = true)] public double MoneyMin { get; set; } = int.MinValue;
|
||||
/// <summary>
|
||||
/// 金钱要求:最大值
|
||||
/// </summary>
|
||||
[Line(IgnoreCase = true)] public double MoneyMax { get; set; } = int.MaxValue;
|
||||
/// <summary>
|
||||
/// 食物要求:最小值
|
||||
/// </summary>
|
||||
[Line(IgnoreCase = true)] public double FoodMin { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 食物要求:最大值
|
||||
/// </summary>
|
||||
[Line(IgnoreCase = true)] public double FoodMax { get; set; } = int.MaxValue;
|
||||
/// <summary>
|
||||
/// 口渴要求:最小值
|
||||
/// </summary>
|
||||
[Line(IgnoreCase = true)] public double DrinkMin { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 口渴要求:最大值
|
||||
/// </summary>
|
||||
[Line(IgnoreCase = true)] public double DrinkMax { get; set; } = int.MaxValue;
|
||||
/// <summary>
|
||||
/// 心情要求:最小值
|
||||
/// </summary>
|
||||
[Line(IgnoreCase = true)] public double FeelMin { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 心情要求:最大值
|
||||
/// </summary>
|
||||
[Line(IgnoreCase = true)] public double FeelMax { get; set; } = int.MaxValue;
|
||||
/// <summary>
|
||||
/// 体力要求:最小值
|
||||
/// </summary>
|
||||
[Line(IgnoreCase = true)] public double StrengthMin { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// 体力要求:最大值
|
||||
/// </summary>
|
||||
[Line(IgnoreCase = true)] public double StrengthMax { get; set; } = int.MaxValue;
|
||||
|
||||
/// <summary>
|
||||
/// 说话的内容
|
||||
/// </summary>
|
||||
[Line(IgnoreCase = true)] public string Text { get; set; }
|
||||
|
||||
private string transText = null;
|
||||
/// <summary>
|
||||
/// 说话的内容 (翻译)
|
||||
/// </summary>
|
||||
public string TranslateText
|
||||
{
|
||||
get
|
||||
{
|
||||
if (transText == null)
|
||||
{
|
||||
transText = LocalizeCore.Translate(Text);
|
||||
}
|
||||
return transText;
|
||||
}
|
||||
set
|
||||
{
|
||||
transText = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查部分状态是否满足需求
|
||||
/// </summary>之所以不是全部的,是因为挨个取效率太差了
|
||||
public virtual bool CheckState(Main m)
|
||||
{
|
||||
if (m.Core.Save.Likability < LikeMin || m.Core.Save.Likability > LikeMax)
|
||||
return false;
|
||||
if (m.Core.Save.Health < HealthMin || m.Core.Save.Health > HealthMax)
|
||||
return false;
|
||||
if (m.Core.Save.Level < LevelMin || m.Core.Save.Level > LevelMax)
|
||||
return false;
|
||||
if (m.Core.Save.Money < MoneyMin || m.Core.Save.Money > MoneyMax)
|
||||
return false;
|
||||
if (m.Core.Save.StrengthFood < FoodMin || m.Core.Save.StrengthFood > FoodMax)
|
||||
return false;
|
||||
if (m.Core.Save.StrengthDrink < DrinkMin || m.Core.Save.StrengthDrink > DrinkMax)
|
||||
return false;
|
||||
if (m.Core.Save.Feeling < FeelMin || m.Core.Save.Feeling > FeelMax)
|
||||
return false;
|
||||
if (m.Core.Save.Strength < StrengthMin || m.Core.Save.Strength > StrengthMax)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将文本转换成实际值
|
||||
/// </summary>
|
||||
public string ConverText(Main m) => ConverText(TranslateText, m);
|
||||
/// <summary>
|
||||
/// 将文本转换成实际值
|
||||
/// </summary>
|
||||
public static string ConverText(string text, Main m)
|
||||
{
|
||||
if (text.Contains('{') && text.Contains('}'))
|
||||
{
|
||||
return text.Replace("{name}", m.Core.Save.Name).Replace("{food}", m.Core.Save.StrengthFood.ToString("f0"))
|
||||
.Replace("{drink}", m.Core.Save.StrengthDrink.ToString("f0")).Replace("{feel}", m.Core.Save.Feeling.ToString("f0")).
|
||||
Replace("{strength}", m.Core.Save.Strength.ToString("f0")).Replace("{money}", m.Core.Save.Money.ToString("f0"))
|
||||
.Replace("{level}", m.Core.Save.Level.ToString("f0")).Replace("{health}", m.Core.Save.Health.ToString("f0"));
|
||||
}
|
||||
else
|
||||
return text;
|
||||
}
|
||||
}
|
||||
}
|
51
VPet-Simulator.Windows.Interface/Mod/SelectText.cs
Normal file
51
VPet-Simulator.Windows.Interface/Mod/SelectText.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using LinePutScript.Converter;
|
||||
using LinePutScript.Localization.WPF;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VPet_Simulator.Windows.Interface
|
||||
{
|
||||
/// <summary>
|
||||
/// 供玩家选择说话的文本
|
||||
/// </summary>
|
||||
public class SelectText : ICheckText
|
||||
{
|
||||
/// <summary>
|
||||
/// 玩家选项名称
|
||||
/// </summary>
|
||||
[Line(IgnoreCase = true)]
|
||||
public string Choose { get; set; } = null;
|
||||
|
||||
private string transChoose = null;
|
||||
/// <summary>
|
||||
/// 玩家选项名称 (翻译)
|
||||
/// </summary>
|
||||
public string TranslateChoose
|
||||
{
|
||||
get
|
||||
{
|
||||
if (transChoose == null)
|
||||
{
|
||||
transChoose = LocalizeCore.Translate(Text);
|
||||
}
|
||||
return transChoose;
|
||||
}
|
||||
set
|
||||
{
|
||||
transChoose = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 标签
|
||||
/// </summary>
|
||||
[Line(IgnoreCase = true)]
|
||||
public List<string> Tags { get; set; } = new List<string>();
|
||||
/// <summary>
|
||||
/// 跳转到标签
|
||||
/// </summary>
|
||||
public List<string> ToTags { get; set; } = new List<string>();
|
||||
}
|
||||
}
|
@ -117,9 +117,11 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="IMainWindow.cs" />
|
||||
<Compile Include="Mod\ClickText.cs" />
|
||||
<Compile Include="Mod\ICheckText.cs" />
|
||||
<Compile Include="Mod\LowText.cs" />
|
||||
<Compile Include="Mod\Food.cs" />
|
||||
<Compile Include="MainPlugin.cs" />
|
||||
<Compile Include="Mod\SelectText.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Setting.cs" />
|
||||
<Compile Include="Source.cs" />
|
||||
|
@ -407,7 +407,7 @@ namespace VPet_Simulator.Windows
|
||||
case "LB":
|
||||
if (IsSteamUser)
|
||||
{
|
||||
TalkBox = new TalkBox(this);
|
||||
TalkBox = new TalkSelect(this);
|
||||
Main.ToolBar.MainGrid.Children.Add(TalkBox);
|
||||
}
|
||||
break;
|
||||
|
@ -142,6 +142,9 @@
|
||||
<Compile Include="PetHelper.xaml.cs">
|
||||
<DependentUpon>PetHelper.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="WinDesign\TalkSelect.xaml.cs">
|
||||
<DependentUpon>TalkSelect.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="WinDesign\winBetterBuy.xaml.cs">
|
||||
<DependentUpon>winBetterBuy.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -178,6 +181,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="WinDesign\TalkSelect.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="WinDesign\winBetterBuy.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
25
VPet-Simulator.Windows/WinDesign/TalkSelect.xaml
Normal file
25
VPet-Simulator.Windows/WinDesign/TalkSelect.xaml
Normal file
@ -0,0 +1,25 @@
|
||||
<UserControl x:Class="VPet_Simulator.Windows.TalkSelect"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ll="clr-namespace:LinePutScript.Localization.WPF;assembly=LinePutScript.Localization.WPF"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI" Height="500" Width="500" VerticalAlignment="Top">
|
||||
<Grid>
|
||||
<Border Background="{DynamicResource SecondaryLighter}" BorderBrush="{DynamicResource Secondary}"
|
||||
BorderThickness="5" VerticalAlignment="Top" Margin="5,50,5,5" CornerRadius="5" Padding="5">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="4*" />
|
||||
<ColumnDefinition Width="5" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ComboBox x:Name="tbTalk" Style="{DynamicResource StandardComboBoxStyle}" Height="Auto"
|
||||
pu:ComboBoxHelper.Watermark="{ll:Str 和桌宠说}" FontSize="30" />
|
||||
<Button pu:ButtonHelper.CornerRadius="4" Content="{ll:Str 发送}" BorderThickness="2"
|
||||
Background="{DynamicResource PrimaryLight}" Grid.Column="2"
|
||||
BorderBrush="{DynamicResource DARKPrimaryDarker}" FontSize="30" />
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</UserControl>
|
30
VPet-Simulator.Windows/WinDesign/TalkSelect.xaml.cs
Normal file
30
VPet-Simulator.Windows/WinDesign/TalkSelect.xaml.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace VPet_Simulator.Windows
|
||||
{
|
||||
/// <summary>
|
||||
/// TalkSelect.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class TalkSelect : UserControl
|
||||
{// 使用新的选项方式的聊天框
|
||||
MainWindow mw;
|
||||
public TalkSelect(MainWindow mw)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.mw = mw;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user