修复乱飘&控制台添加距离查看器

This commit is contained in:
ZouJin 2023-02-04 13:12:06 +08:00
parent e2512cbc62
commit 44700b1943
7 changed files with 143 additions and 60 deletions

View File

@ -187,7 +187,7 @@ namespace VPet_Simulator.Core
/// </summary>
public void CleanState()
{
MoveTimer.Stop();
MoveTimer.Enabled = false;
MainGrid.MouseMove -= MainGrid_MouseMove;
}
}

View File

@ -327,19 +327,19 @@ namespace VPet_Simulator.Core
case 0:
DisplayFall_Left(() =>
{
MoveTimer.Stop();
MoveTimer.Enabled = false;
Display(GraphCore.GraphType.Walk_Left_C_End, DisplayNomal);
});
return;
case 1:
DisplayFall_Right(() =>
{
MoveTimer.Stop();
MoveTimer.Enabled = false;
Display(GraphCore.GraphType.Walk_Left_C_End, DisplayNomal);
});
return;
default:
MoveTimer.Stop();
MoveTimer.Enabled = false;
Display(GraphCore.GraphType.Walk_Left_C_End, DisplayNomal);
return;
}
@ -357,19 +357,19 @@ namespace VPet_Simulator.Core
case 0:
DisplayFall_Left(() =>
{
MoveTimer.Stop();
MoveTimer.Enabled = false;
Display(GraphCore.GraphType.Walk_Left_C_End, DisplayNomal);
});
break;
case 1:
DisplayFall_Right(() =>
{
MoveTimer.Stop();
MoveTimer.Enabled = false;
Display(GraphCore.GraphType.Walk_Left_C_End, DisplayNomal);
});
break;
default:
MoveTimer.Stop();
MoveTimer.Enabled = false;
Display(GraphCore.GraphType.Walk_Left_C_End, DisplayNomal);
break;
@ -407,19 +407,19 @@ namespace VPet_Simulator.Core
case 0:
DisplayClimb_Right_UP(() =>
{
MoveTimer.Stop();
MoveTimer.Enabled = false;
Display(GraphCore.GraphType.Walk_Right_C_End, DisplayNomal);
});
return;
case 1:
DisplayClimb_Right_DOWN(() =>
{
MoveTimer.Stop();
MoveTimer.Enabled = false;
Display(GraphCore.GraphType.Walk_Right_C_End, DisplayNomal);
});
return;
default:
MoveTimer.Stop();
MoveTimer.Enabled = false;
Display(GraphCore.GraphType.Walk_Right_C_End, DisplayNomal);
return;
}
@ -437,19 +437,19 @@ namespace VPet_Simulator.Core
case 0:
DisplayFall_Left(() =>
{
MoveTimer.Stop();
MoveTimer.Enabled = false;
Display(GraphCore.GraphType.Walk_Left_C_End, DisplayNomal);
});
break;
case 1:
DisplayFall_Right(() =>
{
MoveTimer.Stop();
MoveTimer.Enabled = false;
Display(GraphCore.GraphType.Walk_Left_C_End, DisplayNomal);
});
break;
default:
MoveTimer.Stop();
MoveTimer.Enabled = false;
Display(GraphCore.GraphType.Walk_Left_C_End, DisplayNomal);
break;
@ -486,19 +486,19 @@ namespace VPet_Simulator.Core
case 0:
DisplayClimb_Left_UP(() =>
{
MoveTimer.Stop();
MoveTimer.Enabled = false;
Display(GraphCore.GraphType.Crawl_Left_C_End, DisplayNomal);
});
return;
case 1:
DisplayClimb_Left_DOWN(() =>
{
MoveTimer.Stop();
MoveTimer.Enabled = false;
Display(GraphCore.GraphType.Crawl_Left_C_End, DisplayNomal);
});
return;
default:
MoveTimer.Stop();
MoveTimer.Enabled = false;
Display(GraphCore.GraphType.Crawl_Left_C_End, DisplayNomal);
return;
}
@ -510,7 +510,7 @@ namespace VPet_Simulator.Core
}
else
{//停下来
MoveTimer.Stop();
MoveTimer.Enabled = false;
Display(GraphCore.GraphType.Crawl_Left_C_End, DisplayNomal);
}
}
@ -544,19 +544,19 @@ namespace VPet_Simulator.Core
case 0:
DisplayClimb_Right_UP(() =>
{
MoveTimer.Stop();
MoveTimer.Enabled = false;
Display(GraphCore.GraphType.Crawl_Right_C_End, DisplayNomal);
});
return;
case 1:
DisplayClimb_Right_DOWN(() =>
{
MoveTimer.Stop();
MoveTimer.Enabled = false;
Display(GraphCore.GraphType.Crawl_Right_C_End, DisplayNomal);
});
return;
default:
MoveTimer.Stop();
MoveTimer.Enabled = false;
Display(GraphCore.GraphType.Crawl_Right_C_End, DisplayNomal);
return;
}
@ -568,7 +568,7 @@ namespace VPet_Simulator.Core
}
else
{//停下来
MoveTimer.Stop();
MoveTimer.Enabled = false;
Display(GraphCore.GraphType.Crawl_Right_C_End, DisplayNomal);
}
}
@ -610,7 +610,7 @@ namespace VPet_Simulator.Core
DisplayFall_Right();
return;
default:
MoveTimer.Stop();
MoveTimer.Enabled = false;
DisplayNomal();
return;
}
@ -628,7 +628,7 @@ namespace VPet_Simulator.Core
DisplayFall_Right();
break;
default:
MoveTimer.Stop();
MoveTimer.Enabled = false;
DisplayNomal();
break;
}
@ -664,7 +664,7 @@ namespace VPet_Simulator.Core
//看看距离是不是不足
if (Core.Controller.GetWindowsDistanceDown() < DistanceMin * Core.Controller.ZoomRatio)
{//是,停下恢复默认
MoveTimer.Stop();
MoveTimer.Enabled = false;
DisplayNomal();
}
//不是:继续or停下
@ -674,7 +674,7 @@ namespace VPet_Simulator.Core
}
else
{//停下来
MoveTimer.Stop();
MoveTimer.Enabled = false;
DisplayNomal();
}
}
@ -717,7 +717,7 @@ namespace VPet_Simulator.Core
DisplayFall_Left();
return;
default:
MoveTimer.Stop();
MoveTimer.Enabled = false;
DisplayNomal();
return;
}
@ -735,7 +735,7 @@ namespace VPet_Simulator.Core
DisplayFall_Left();
break;
default:
MoveTimer.Stop();
MoveTimer.Enabled = false;
DisplayNomal();
break;
}
@ -771,7 +771,7 @@ namespace VPet_Simulator.Core
//看看距离是不是不足
if (Core.Controller.GetWindowsDistanceDown() < DistanceMin * Core.Controller.ZoomRatio)
{//是,停下恢复默认
MoveTimer.Stop();
MoveTimer.Enabled = false;
DisplayNomal();
}
//不是:继续or停下
@ -781,7 +781,7 @@ namespace VPet_Simulator.Core
}
else
{//停下来
MoveTimer.Stop();
MoveTimer.Enabled = false;
DisplayNomal();
}
}
@ -820,7 +820,7 @@ namespace VPet_Simulator.Core
return;
default:
Core.Controller.MoveWindows(0, -Core.Controller.GetWindowsDistanceUp() / Core.Controller.ZoomRatio);
MoveTimer.Stop();
MoveTimer.Enabled = false;
DisplayFalled_Right();
return;
}
@ -833,7 +833,7 @@ namespace VPet_Simulator.Core
else
{//停下来
Core.Controller.MoveWindows(0, -Core.Controller.GetWindowsDistanceUp() / Core.Controller.ZoomRatio);
MoveTimer.Stop();
MoveTimer.Enabled = false;
DisplayFalled_Right();
}
}
@ -872,7 +872,7 @@ namespace VPet_Simulator.Core
return;
default:
Core.Controller.MoveWindows(0, -Core.Controller.GetWindowsDistanceUp() / Core.Controller.ZoomRatio);
MoveTimer.Stop();
MoveTimer.Enabled = false;
DisplayFalled_Right();
return;
}
@ -885,7 +885,7 @@ namespace VPet_Simulator.Core
else
{//停下来
Core.Controller.MoveWindows(0, -Core.Controller.GetWindowsDistanceUp() / Core.Controller.ZoomRatio);
MoveTimer.Stop();
MoveTimer.Enabled = false;
DisplayFalled_Right();
}
}
@ -920,20 +920,20 @@ namespace VPet_Simulator.Core
case 0:
DisplayClimb_Left_UP(() =>
{
MoveTimer.Stop();
MoveTimer.Enabled = false;
DisplayFalled_Left();
});
return;
case 1:
DisplayClimb_Left_DOWN(() =>
{
MoveTimer.Stop();
MoveTimer.Enabled = false;
DisplayFalled_Left();
});
return;
default:
//Core.Controller.MoveWindows(0, -Core.Controller.GetWindowsDistanceUp() / Core.Controller.ZoomRatio);
MoveTimer.Stop();
MoveTimer.Enabled = false;
DisplayFalled_Left();
return;
}
@ -946,7 +946,7 @@ namespace VPet_Simulator.Core
else
{//停下来
//Core.Controller.MoveWindows(0, -Core.Controller.GetWindowsDistanceUp() / Core.Controller.ZoomRatio);
MoveTimer.Stop();
MoveTimer.Enabled = false;
DisplayFalled_Left();
//DisplayNomal();
}
@ -983,20 +983,20 @@ namespace VPet_Simulator.Core
case 0:
DisplayClimb_Right_UP(() =>
{
MoveTimer.Stop();
MoveTimer.Enabled = false;
DisplayFalled_Right();
});
return;
case 1:
DisplayClimb_Right_DOWN(() =>
{
MoveTimer.Stop();
MoveTimer.Enabled = false;
DisplayFalled_Right();
});
return;
default:
//Core.Controller.MoveWindows(0, -Core.Controller.GetWindowsDistanceUp() / Core.Controller.ZoomRatio);
MoveTimer.Stop();
MoveTimer.Enabled = false;
DisplayFalled_Right();
return;
}
@ -1009,7 +1009,7 @@ namespace VPet_Simulator.Core
else
{//停下来
//Core.Controller.MoveWindows(0, -Core.Controller.GetWindowsDistanceUp() / Core.Controller.ZoomRatio);
MoveTimer.Stop();
MoveTimer.Enabled = false;
DisplayFalled_Right();
//DisplayNomal();
}

View File

@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VPet_Simulator.Core" mc:Ignorable="d" Height="500"
xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI" xmlns:local="clr-namespace:VPet_Simulator.Core" mc:Ignorable="d" Height="500"
Width="500" MouseDoubleClick="UserControl_MouseDoubleClick">
<UserControl.Resources>
<ResourceDictionary Source="Theme.xaml" />

View File

@ -56,7 +56,15 @@ namespace VPet_Simulator.Windows
{
IsSteamUser = false;
}
//给正在玩这个游戏的主播/游戏up主做个小功能
if (IsSteamUser)
{
rndtext.Add($"关注 {Steamworks.SteamClient.Name} 谢谢喵");
}
else
{
rndtext.Add($"关注 {Environment.UserName} 谢谢喵");
}
//加载游戏设置
if (new FileInfo(AppDomain.CurrentDomain.BaseDirectory + @"\Setting.lps").Exists)
{
@ -82,7 +90,7 @@ namespace VPet_Simulator.Windows
}
Task.Run(GameLoad);
}
private string[] rndtext = new string[]
private List<string> rndtext = new List<string>
{
"你知道吗? 鼠标右键可以打开菜单栏",
"如果你觉得目前功能太少,那就多挂会机. 宠物会自己动的",
@ -93,7 +101,7 @@ namespace VPet_Simulator.Windows
"你添加了虚拟主播模拟器和虚拟桌宠模拟器到愿望单了吗? 快去加吧",
"这游戏开发这么慢,都怪画师太咕了.\n记得多催催画师(@叶书天)画桌宠, 催的越快更新越快!",
"长按脑袋拖动桌宠到你喜欢的任意位置",
"欢迎加入 虚拟主播模拟器群 430081239",
"欢迎加入 虚拟主播模拟器群 430081239",
};
private long lastclicktime;
public void GameLoad()
@ -156,7 +164,7 @@ namespace VPet_Simulator.Windows
if (new TimeSpan(DateTime.Now.Ticks - lastclicktime).TotalSeconds > 20)
{
lastclicktime = DateTime.Now.Ticks;
Dispatcher.Invoke(() => Main.Say(rndtext[Function.Rnd.Next(rndtext.Length)]));
Dispatcher.Invoke(() => Main.Say(rndtext[Function.Rnd.Next(rndtext.Count)]));
}
};
DisplayGrid.Child = Main;

View File

@ -1,21 +1,30 @@
<Window x:Class="VPet_Simulator.Windows.winConsole" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:VPet_Simulator.Windows" mc:Ignorable="d" Title="桌宠管理控制台" Height="450" Width="450">
<TabControl>
xmlns:local="clr-namespace:VPet_Simulator.Windows" mc:Ignorable="d" Title="桌宠管理控制台" Height="450" Width="450"
FontSize="16">
<TabControl pu:TabControlHelper.ItemsSelectedBackground="White"
pu:TabControlHelper.HeaderPanelBackground="{DynamicResource PrimaryLight}">
<TabItem Header="动画列表">
<Grid>
<Label Background="{x:Null}" Content="双击查看动画效果" />
<Label Background="{x:Null}" Content="双击查看动画效果&#13;选择状态模式:" />
<ComboBox x:Name="ComboxMode" VerticalAlignment="Top" Margin="110,25,5,0">
<ComboBoxItem Content="Happy" />
<ComboBoxItem Content="Nomal" />
<ComboBoxItem Content="PoorCondition" />
<ComboBoxItem Content="Ill" />
</ComboBox>
<Label x:Name="LabelNowPlay" Background="{x:Null}" Content="" HorizontalAlignment="Right" />
<ListBox x:Name="GraphListBox" Margin="0,20,0,0" MouseDoubleClick="GraphListBox_MouseDoubleClick" />
<ListBox x:Name="GraphListBox" Margin="0,49,0,0" MouseDoubleClick="GraphListBox_MouseDoubleClick" />
</Grid>
</TabItem>
<TabItem Header="显示逻辑">
<Grid>
<Label Background="{x:Null}" Content="双击运行显示效果" />
<Label x:Name="LabelSuccess" Background="{x:Null}" Content="" HorizontalAlignment="Right" />
<ListBox x:Name="DisplayListBox" Margin="0,20,0,0" MouseDoubleClick="DisplayListBox_MouseDoubleClick">
<ListBox x:Name="DisplayListBox" Margin="0,30,0,0" MouseDoubleClick="DisplayListBox_MouseDoubleClick">
<ListBoxItem Content="DisplayNomal" />
<ListBoxItem Content="DisplayTouchHead" />
<ListBoxItem Content="DisplayBoring" />
@ -43,10 +52,24 @@
</TabItem>
<TabItem Header="说话">
<Grid>
<Label Background="{x:Null}" Content="输入要说的话,按说话键发送" />
<TextBox x:Name="SayTextBox" TextWrapping="Wrap" Text="在这里输入要说话的内容" VerticalAlignment="Top"
Margin="5,25,5,0" Height="60" AcceptsReturn="True" VerticalContentAlignment="Top" />
<Button VerticalAlignment="Bottom" Content="说话" Click="Say_Click" />
<Label Background="{x:Null}" Content="输入要说的话,按说话键发送:&#13;选择说话类型:" />
<ComboBox VerticalAlignment="Top" Margin="110,26,5,0" />
<TextBox x:Name="SayTextBox" TextWrapping="Wrap" pu:TextBoxHelper.Watermark="在这里输入要说话的内容" VerticalAlignment="Top"
Margin="5,54,5,0" Height="200" AcceptsReturn="True" VerticalContentAlignment="Top" />
<Button VerticalAlignment="Bottom" Content="说话" Click="Say_Click" FontSize="24" />
</Grid>
</TabItem>
<TabItem Header="距离查看器">
<Grid>
<CheckBox HorizontalAlignment="Left" VerticalAlignment="Top" Content="启动距离查看器" Margin="10,5,5,5"
Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked" />
<TextBlock Margin="10,24,0,0" FontSize="24">
<Run>屏幕边缘距离:</Run><LineBreak />
<Run>左侧:</Run><Run x:Name="RLeft" /><LineBreak />
<Run>右侧:</Run><Run x:Name="RRight" /><LineBreak />
<Run>上侧:</Run><Run x:Name="RTop" /><LineBreak />
<Run>下侧:</Run><Run x:Name="RDown" /><LineBreak />
</TextBlock>
</Grid>
</TabItem>
</TabControl>

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
@ -11,6 +12,7 @@ using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using VPet_Simulator.Core;
using static VPet_Simulator.Core.GraphCore;
namespace VPet_Simulator.Windows
@ -29,18 +31,37 @@ namespace VPet_Simulator.Windows
{
GraphListBox.Items.Add(v);
}
DestanceTimer.Elapsed += DestanceTimer_Elapsed;
}
public void DisplayLoop(GraphType graphType)
private void DestanceTimer_Elapsed(object sender, ElapsedEventArgs e)
{
mw.Main.Display(graphType, () => DisplayLoop(graphType));
Dispatcher.Invoke(() =>
{
RLeft.Text = mw.Core.Controller.GetWindowsDistanceLeft().ToString("f2");
RRight.Text = mw.Core.Controller.GetWindowsDistanceRight().ToString("f2");
RTop.Text = mw.Core.Controller.GetWindowsDistanceUp().ToString("f2");
RDown.Text = mw.Core.Controller.GetWindowsDistanceDown().ToString("f2");
});
}
public void DisplayLoop(IGraph graph)
{
mw.Main.Display(graph, () => DisplayLoop(graph));
}
private void GraphListBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (GraphListBox.SelectedItem == null)
return;
var graph = mw.Main.Core.Graph.FindGraph((GraphType)Enum.Parse(typeof(GraphType), (string)GraphListBox.SelectedItem),
(Save.ModeType)Enum.Parse(typeof(Save.ModeType), (string)(((ComboBoxItem)ComboxMode.SelectedItem).Content)));
if (graph == null)
{
LabelNowPlay.Content = "未找到对应类型图像资源";
return;
}
LabelNowPlay.Content = $"当前正在播放: {GraphListBox.SelectedItem}";
DisplayLoop((GraphType)Enum.Parse(typeof(GraphType), (string)GraphListBox.SelectedItem));
DisplayLoop(graph);
}
private void DisplayListBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
@ -123,5 +144,36 @@ namespace VPet_Simulator.Windows
{
mw.Main.Say(SayTextBox.Text);
}
Timer DestanceTimer = new Timer()
{
AutoReset = true,
Interval = 100,
};
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
DestanceTimer.Start();
}
private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
{
DestanceTimer.Stop();
}
//private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
//{
// switch(((TabControl)sender).SelectedIndex)
// {
// case 0:
// case 1:
// case 2:
// ComboxMode.Visibility = Visibility.Visible;
// break;
// default:
// ComboxMode.Visibility = Visibility.Collapsed;
// break;
// }
//}
}
}

View File

@ -1,4 +1,4 @@
pet#火柴人:|intor#来试试这个极简手残画风的单帧宠物吧:|path#vup:|
pet#火柴人:|intor#来试试这个极简手残画风的单帧宠物吧:|path#matchmen:|
touchhead:|px#159:|py#16:|sw#189:|sh#178:|
touchraised:|px#0:|py#50:|sw#500:|sh#200:|
raisepoint:|x#290:|y#128:|