mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
支持主动加入 & 退出解散
This commit is contained in:
parent
ec31238fba
commit
abcd507ec4
@ -22,6 +22,7 @@ using LinePutScript.Dictionary;
|
||||
using Steamworks.Data;
|
||||
using System.Windows.Controls;
|
||||
using ToolBar = VPet_Simulator.Core.ToolBar;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace VPet_Simulator.Windows
|
||||
{
|
||||
@ -286,6 +287,24 @@ namespace VPet_Simulator.Windows
|
||||
}
|
||||
});
|
||||
SteamMatchmaking.OnLobbyInvite += SteamMatchmaking_OnLobbyInvite;
|
||||
SteamFriends.OnGameLobbyJoinRequested += SteamFriends_OnGameLobbyJoinRequested;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void SteamFriends_OnGameLobbyJoinRequested(Lobby lobby, SteamId id)
|
||||
{
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
if (winMutiPlayer == null)
|
||||
{
|
||||
winMutiPlayer = new winMutiPlayer(this, lobby.Id.Value);
|
||||
winMutiPlayer.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBoxX.Show("已经有加入了一个访客表,无法再创建更多".Translate());
|
||||
winMutiPlayer.Focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -294,15 +313,18 @@ namespace VPet_Simulator.Windows
|
||||
{
|
||||
if (winMutiPlayer != null)
|
||||
return;
|
||||
Button btn = new Button();
|
||||
btn.Content = "加入访客表";
|
||||
btn.Style = FindResource("ThemedButtonStyle") as Style;
|
||||
btn.Click += (_, _) =>
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
winMutiPlayer = new winMutiPlayer(this, lobby.Id);
|
||||
winMutiPlayer.Show();
|
||||
};
|
||||
Main.Say("收到来自{0}的访客邀请,是否加入?".Translate(friend.Name), msgcontent: btn);
|
||||
Button btn = new Button();
|
||||
btn.Content = "加入访客表";
|
||||
btn.Style = FindResource("ThemedButtonStyle") as Style;
|
||||
btn.Click += (_, _) =>
|
||||
{
|
||||
winMutiPlayer = new winMutiPlayer(this, lobby.Id);
|
||||
winMutiPlayer.Show();
|
||||
};
|
||||
Main.Say("收到来自{0}的访客邀请,是否加入?".Translate(friend.Name), msgcontent: btn);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -4,16 +4,16 @@
|
||||
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:local="clr-namespace:VPet_Simulator.Windows"
|
||||
mc:Ignorable="d" Margin="5" Width="360" Height="100" Background="{DynamicResource SecondaryLight}"
|
||||
mc:Ignorable="d" Margin="5" Width="340" Height="100" Background="{DynamicResource SecondaryLight}"
|
||||
BorderBrush="{DynamicResource Secondary}">
|
||||
<Grid>
|
||||
<Image x:Name="uimg" HorizontalAlignment="Left" Source="/Res/TopLogo2019.PNG" Margin="4" />
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Margin="110,0,0,0"
|
||||
Foreground="{DynamicResource DARKPrimaryDarker}" FontSize="16">
|
||||
<Run Text="{ll:Str 访客}" />: <Run x:Name="rPetName" Text="萝莉斯" FontSize="20" FontWeight="Bold" />
|
||||
<Run Text="{ll:Str 访客}" />: <Run x:Name="rPetName" Text="{ll:Str 萝莉斯}" FontSize="20" FontWeight="Bold" />
|
||||
<LineBreak />
|
||||
<Run Text="{ll:Str 来自}" />: <Run x:Name="hostName" Text="XXX" FontWeight="Bold" /><LineBreak />
|
||||
<Run x:Name="info" Text="Lv 15" />
|
||||
<Run x:Name="info" Text="Lv ??" />
|
||||
</TextBlock>
|
||||
<Button Style="{DynamicResource ThemedButtonStyle}" HorizontalAlignment="Right" Content="{ll:Str 重置位置}"
|
||||
VerticalAlignment="Top" Margin="10"/>
|
||||
|
@ -4,9 +4,9 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:VPet_Simulator.Windows" mc:Ignorable="d"
|
||||
xmlns:pu="https://opensource.panuon.com/wpf-ui"
|
||||
xmlns:ll="clr-namespace:LinePutScript.Localization.WPF;assembly=LinePutScript.Localization.WPF" Title="{ll:Str 访客表}"
|
||||
MinHeight="400" Width="400" Closed="Window_Closed" FontSize="16" SizeToContent="Height" MaxHeight="800"
|
||||
ResizeMode="CanMinimize" Closing="Window_Closing">
|
||||
xmlns:ll="clr-namespace:LinePutScript.Localization.WPF;assembly=LinePutScript.Localization.WPF"
|
||||
Title="{ll:Str 访客表}" MinHeight="400" Width="400" Closed="Window_Closed" FontSize="16" SizeToContent="Height"
|
||||
MaxHeight="800" ResizeMode="CanMinimize" Closing="Window_Closing">
|
||||
<Grid>
|
||||
<Image x:Name="HostHead" Margin="20" Width="80" Height="80" HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||
Source="/Res/TopLogo2019.PNG" />
|
||||
@ -26,7 +26,8 @@
|
||||
</TabItem>
|
||||
<TabItem Header="{ll:Str 消息日志}">
|
||||
<TextBox x:Name="tbLog" Margin="0" BorderThickness="0" Background="{DynamicResource DARKPrimaryTrans4}"
|
||||
Foreground="{DynamicResource DARKPrimaryDarker}" IsReadOnly="True" VerticalScrollBarVisibility="Visible" />
|
||||
Foreground="{DynamicResource DARKPrimaryDarker}" IsReadOnly="True"
|
||||
VerticalScrollBarVisibility="Visible" />
|
||||
</TabItem>
|
||||
|
||||
</TabControl>
|
||||
|
@ -42,10 +42,11 @@ public partial class winMutiPlayer : Window
|
||||
if (lobbyid == null)
|
||||
CreateLobby();
|
||||
else
|
||||
JoinLobby(lobbyid);
|
||||
JoinLobby(lobbyid.Value);
|
||||
}
|
||||
public async void JoinLobby(ulong? lobbyid)
|
||||
public async void JoinLobby(ulong lobbyid)
|
||||
{
|
||||
MessageBoxX.Show(lobbyid.ToString("x"));
|
||||
var lbt = (await SteamMatchmaking.JoinLobbyAsync((SteamId)lobbyid));
|
||||
if (!lbt.HasValue || lbt.Value.Owner.Id.Value == 0)
|
||||
{
|
||||
@ -151,7 +152,6 @@ public partial class winMutiPlayer : Window
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void Main_GraphDisplayHandler(GraphInfo info)
|
||||
{
|
||||
lb.SendChatString(MPMessage.ConverTo(new MPMessage() { Type = MPMessage.MSGType.DispayGraph, Content = LPSConvert.SerializeObject(info).ToString() }));
|
||||
@ -177,7 +177,12 @@ public partial class winMutiPlayer : Window
|
||||
{
|
||||
if (lobby.Id == lb.Id)
|
||||
{
|
||||
|
||||
if (lb.GetData("leave") == "true")
|
||||
{
|
||||
MessageBoxX.Show("访客表已被房主{0}关闭".Translate(lb.Owner.Name));
|
||||
lb = default(Lobby);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,6 +191,8 @@ public partial class winMutiPlayer : Window
|
||||
SteamMatchmaking.OnLobbyDataChanged -= SteamMatchmaking_OnLobbyDataChanged;
|
||||
SteamMatchmaking.OnLobbyMemberDataChanged -= SteamMatchmaking_OnLobbyMemberDataChanged;
|
||||
mw.Main.GraphDisplayHandler -= Main_GraphDisplayHandler;
|
||||
if (lb.Owner.Id == SteamClient.SteamId)
|
||||
lb.SetData("leave", "true");
|
||||
lb.Leave();
|
||||
for (int i = 0; i < MPFriends.Count; i++)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user