修复UI报错问题

This commit is contained in:
ZouJin
2024-03-19 01:55:25 +08:00
parent ea785811da
commit 7ebf90bb22
4 changed files with 49 additions and 36 deletions

View File

@ -82,6 +82,9 @@ namespace VPet_Simulator.Core
PetGrid2.Visibility = Visibility.Collapsed;
Task.Run(() =>
{
EventTimer.Elapsed += (s, e) => EventTimer_Elapsed();
MoveTimer.Elapsed += MoveTimer_Elapsed;
SmartMoveTimer.Elapsed += SmartMoveTimer_Elapsed;
//while (!ig.IsReady)
//{
// Thread.Sleep(100);
@ -111,10 +114,6 @@ namespace VPet_Simulator.Core
DisplayNomal();
});
});
EventTimer.Elapsed += (s, e) => EventTimer_Elapsed();
MoveTimer.Elapsed += MoveTimer_Elapsed;
SmartMoveTimer.Elapsed += SmartMoveTimer_Elapsed;
}
private void Labledisplaytimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)

View File

@ -43,7 +43,7 @@ namespace VPet_Simulator.Core
closePanelTimer = new Timer();
closePanelTimer.Elapsed += ClosePanelTimer_Tick;
m.TimeUIHandle += M_TimeUIHandle;
LoadWork();
//LoadWork();
}
public void LoadClean()
{

View File

@ -313,6 +313,8 @@ public partial class MPFriends : WindowX
/// 播放关闭动画并关闭,如果10秒后还未关闭则强制关闭
/// </summary>
public void Quit()
{
try
{
Main.Display(GraphType.Shutdown, AnimatType.Single, () => Dispatcher.Invoke(Close));
Task.Run(() =>
@ -322,6 +324,11 @@ public partial class MPFriends : WindowX
Dispatcher.Invoke(Close);
});
}
catch
{
Close();
}
}
/// <summary>
/// 智能化显示后续过度动画
@ -420,16 +427,20 @@ public partial class MPFriends : WindowX
msg.Type = MSGType.Chat;
msg.SetContent(new Chat() { Content = cont, ChatType = (Chat.Type)talktype, SendName = SteamClient.Name });
msg.To = SteamClient.SteamId;
switch (talktype)
{
case 0:
wmp.SendMessage(friend.Id, msg);
mw.Main.Say("{0} 悄悄地对你说: {1}".Translate(SteamClient.Name, cont));
break;
case 1:
wmp.SendMessageALL(msg);
mw.Main.Say("{0} 对你说: {1}".Translate(SteamClient.Name, cont));
break;
case 2:
wmp.SendMessageALL(msg);
mw.Main.Say("{0} 对大家说: {1}".Translate(SteamClient.Name, cont));
break;
}
});

View File

@ -199,14 +199,18 @@ public partial class winMutiPlayer : Window
}
}
}
GraphInfo lastgraph = new GraphInfo() { Type = GraphType.Common };
private void Main_GraphDisplayHandler(GraphInfo info)
{
if (info.Type == GraphType.Shutdown || info.Type == GraphType.Common || info.Type == GraphType.Move
|| info.Type == GraphType.Raised_Dynamic || info.Type == GraphType.Raised_Static || info.Type == GraphType.Default)
|| info.Type == GraphType.Raised_Dynamic || info.Type == GraphType.Raised_Static)
{
return;
}
//如果是同一个动画就不发送
if (lastgraph.Type == info.Type && lastgraph.Animat == info.Animat && info.Name == lastgraph.Name)
return;
lastgraph = info;
MPMessage msg = new MPMessage();
msg.Type = MSGType.DispayGraph;
msg.SetContent(info);
@ -260,6 +264,7 @@ public partial class winMutiPlayer : Window
}
private void LoopP2PPacket()
{
while (isOPEN)
try
{
while (SteamNetworking.IsP2PPacketAvailable())
@ -283,8 +288,6 @@ public partial class winMutiPlayer : Window
Thread.Sleep(100);
}
Thread.Sleep(1000);
if (isOPEN)
LoopP2PPacket();
}
catch
{