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 Steamworks.Data;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using ToolBar = VPet_Simulator.Core.ToolBar;
|
using ToolBar = VPet_Simulator.Core.ToolBar;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
namespace VPet_Simulator.Windows
|
namespace VPet_Simulator.Windows
|
||||||
{
|
{
|
||||||
@ -286,6 +287,24 @@ namespace VPet_Simulator.Windows
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
SteamMatchmaking.OnLobbyInvite += SteamMatchmaking_OnLobbyInvite;
|
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,6 +313,8 @@ namespace VPet_Simulator.Windows
|
|||||||
{
|
{
|
||||||
if (winMutiPlayer != null)
|
if (winMutiPlayer != null)
|
||||||
return;
|
return;
|
||||||
|
Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
Button btn = new Button();
|
Button btn = new Button();
|
||||||
btn.Content = "加入访客表";
|
btn.Content = "加入访客表";
|
||||||
btn.Style = FindResource("ThemedButtonStyle") as Style;
|
btn.Style = FindResource("ThemedButtonStyle") as Style;
|
||||||
@ -303,6 +324,7 @@ namespace VPet_Simulator.Windows
|
|||||||
winMutiPlayer.Show();
|
winMutiPlayer.Show();
|
||||||
};
|
};
|
||||||
Main.Say("收到来自{0}的访客邀请,是否加入?".Translate(friend.Name), msgcontent: btn);
|
Main.Say("收到来自{0}的访客邀请,是否加入?".Translate(friend.Name), msgcontent: btn);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,16 +4,16 @@
|
|||||||
xmlns:ll="clr-namespace:LinePutScript.Localization.WPF;assembly=LinePutScript.Localization.WPF"
|
xmlns:ll="clr-namespace:LinePutScript.Localization.WPF;assembly=LinePutScript.Localization.WPF"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
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"
|
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}">
|
BorderBrush="{DynamicResource Secondary}">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Image x:Name="uimg" HorizontalAlignment="Left" Source="/Res/TopLogo2019.PNG" Margin="4" />
|
<Image x:Name="uimg" HorizontalAlignment="Left" Source="/Res/TopLogo2019.PNG" Margin="4" />
|
||||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Margin="110,0,0,0"
|
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Margin="110,0,0,0"
|
||||||
Foreground="{DynamicResource DARKPrimaryDarker}" FontSize="16">
|
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 />
|
<LineBreak />
|
||||||
<Run Text="{ll:Str 来自}" />: <Run x:Name="hostName" Text="XXX" 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>
|
</TextBlock>
|
||||||
<Button Style="{DynamicResource ThemedButtonStyle}" HorizontalAlignment="Right" Content="{ll:Str 重置位置}"
|
<Button Style="{DynamicResource ThemedButtonStyle}" HorizontalAlignment="Right" Content="{ll:Str 重置位置}"
|
||||||
VerticalAlignment="Top" Margin="10"/>
|
VerticalAlignment="Top" Margin="10"/>
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:VPet_Simulator.Windows" mc:Ignorable="d"
|
xmlns:local="clr-namespace:VPet_Simulator.Windows" mc:Ignorable="d"
|
||||||
xmlns:pu="https://opensource.panuon.com/wpf-ui"
|
xmlns:pu="https://opensource.panuon.com/wpf-ui"
|
||||||
xmlns:ll="clr-namespace:LinePutScript.Localization.WPF;assembly=LinePutScript.Localization.WPF" Title="{ll:Str 访客表}"
|
xmlns:ll="clr-namespace:LinePutScript.Localization.WPF;assembly=LinePutScript.Localization.WPF"
|
||||||
MinHeight="400" Width="400" Closed="Window_Closed" FontSize="16" SizeToContent="Height" MaxHeight="800"
|
Title="{ll:Str 访客表}" MinHeight="400" Width="400" Closed="Window_Closed" FontSize="16" SizeToContent="Height"
|
||||||
ResizeMode="CanMinimize" Closing="Window_Closing">
|
MaxHeight="800" ResizeMode="CanMinimize" Closing="Window_Closing">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Image x:Name="HostHead" Margin="20" Width="80" Height="80" HorizontalAlignment="Left" VerticalAlignment="Top"
|
<Image x:Name="HostHead" Margin="20" Width="80" Height="80" HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||||
Source="/Res/TopLogo2019.PNG" />
|
Source="/Res/TopLogo2019.PNG" />
|
||||||
@ -26,7 +26,8 @@
|
|||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="{ll:Str 消息日志}">
|
<TabItem Header="{ll:Str 消息日志}">
|
||||||
<TextBox x:Name="tbLog" Margin="0" BorderThickness="0" Background="{DynamicResource DARKPrimaryTrans4}"
|
<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>
|
</TabItem>
|
||||||
|
|
||||||
</TabControl>
|
</TabControl>
|
||||||
|
@ -42,10 +42,11 @@ public partial class winMutiPlayer : Window
|
|||||||
if (lobbyid == null)
|
if (lobbyid == null)
|
||||||
CreateLobby();
|
CreateLobby();
|
||||||
else
|
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));
|
var lbt = (await SteamMatchmaking.JoinLobbyAsync((SteamId)lobbyid));
|
||||||
if (!lbt.HasValue || lbt.Value.Owner.Id.Value == 0)
|
if (!lbt.HasValue || lbt.Value.Owner.Id.Value == 0)
|
||||||
{
|
{
|
||||||
@ -151,7 +152,6 @@ public partial class winMutiPlayer : Window
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Main_GraphDisplayHandler(GraphInfo info)
|
private void Main_GraphDisplayHandler(GraphInfo info)
|
||||||
{
|
{
|
||||||
lb.SendChatString(MPMessage.ConverTo(new MPMessage() { Type = MPMessage.MSGType.DispayGraph, Content = LPSConvert.SerializeObject(info).ToString() }));
|
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 (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.OnLobbyDataChanged -= SteamMatchmaking_OnLobbyDataChanged;
|
||||||
SteamMatchmaking.OnLobbyMemberDataChanged -= SteamMatchmaking_OnLobbyMemberDataChanged;
|
SteamMatchmaking.OnLobbyMemberDataChanged -= SteamMatchmaking_OnLobbyMemberDataChanged;
|
||||||
mw.Main.GraphDisplayHandler -= Main_GraphDisplayHandler;
|
mw.Main.GraphDisplayHandler -= Main_GraphDisplayHandler;
|
||||||
|
if (lb.Owner.Id == SteamClient.SteamId)
|
||||||
|
lb.SetData("leave", "true");
|
||||||
lb.Leave();
|
lb.Leave();
|
||||||
for (int i = 0; i < MPFriends.Count; i++)
|
for (int i = 0; i < MPFriends.Count; i++)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user