VPet/VPet-Simulator.Windows/MutiPlayer/MPUserControl.xaml.cs

55 lines
1.4 KiB
C#
Raw Normal View History

2024-03-16 16:41:20 +00:00
using Steamworks;
using Steamworks.Data;
using System.Threading;
2024-03-11 07:22:23 +00:00
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace VPet_Simulator.Windows;
/// <summary>
2024-03-15 17:33:56 +00:00
/// MPUserControl.xaml 的交互逻辑
2024-03-11 07:22:23 +00:00
/// </summary>
2024-03-16 16:41:20 +00:00
public partial class MPUserControl : Border
2024-03-11 07:22:23 +00:00
{
public Friend friend => mpf.friend;
2024-03-16 16:41:20 +00:00
winMutiPlayer wmp;
public MPFriends mpf;
2024-03-16 16:41:20 +00:00
Lobby lb => mpf.lb;
public MPUserControl(winMutiPlayer wmp, MPFriends mpf)
2024-03-11 07:22:23 +00:00
{
InitializeComponent();
2024-03-16 16:41:20 +00:00
this.wmp = wmp;
this.mpf = mpf;
Task.Run(LoadInfo);
}
public void LoadInfo()
{
//加载lobby传过来的数据
while (!mpf.Loaded)
{
Thread.Sleep(500);
}
Dispatcher.Invoke(async () =>
{
rPetName.Text = mpf.Core.Save.Name;
hostName.Text = friend.Name;
var img = await friend.GetMediumAvatarAsync();
uimg.Source = winMutiPlayer.ConvertToImageSource(img);
info.Text = "Lv " + mpf.Core.Save.Level;
2024-03-20 05:17:14 +00:00
if (lb.Owner.IsMe)
Kick.Visibility = Visibility.Visible;
2024-03-16 16:41:20 +00:00
});
2024-03-11 07:22:23 +00:00
}
2024-03-20 05:17:14 +00:00
private void btn_ReSetLocal(object sender, RoutedEventArgs e)
{
mpf.ReSetLocal();
}
private void Kick_Click(object sender, RoutedEventArgs e)
{
lb.SetData("kick", friend.Id.Value.ToString());
}
2024-03-11 07:22:23 +00:00
}