mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
支持加入访客表功能
This commit is contained in:
@ -119,7 +119,7 @@
|
|||||||
<MenuItem x:Name="MenuFeed" Padding="0" x:FieldModifier="public" Header="{ll:Str 投喂}" />
|
<MenuItem x:Name="MenuFeed" Padding="0" x:FieldModifier="public" Header="{ll:Str 投喂}" />
|
||||||
<MenuItem x:Name="MenuPanel" Padding="0" Header="{ll:Str 面板}" MouseEnter="MenuPanel_MouseEnter"
|
<MenuItem x:Name="MenuPanel" Padding="0" Header="{ll:Str 面板}" MouseEnter="MenuPanel_MouseEnter"
|
||||||
MouseLeave="MenuPanel_MouseLeave" />
|
MouseLeave="MenuPanel_MouseLeave" />
|
||||||
<MenuItem x:Name="MenuInteract" Width="99" Padding="0" Header="{ll:Str 互动}">
|
<MenuItem x:Name="MenuInteract" Width="99" Padding="0" Header="{ll:Str 互动}" x:FieldModifier="public">
|
||||||
<MenuItem Click="Sleep_Click" Header="{ll:Str 睡觉}" />
|
<MenuItem Click="Sleep_Click" Header="{ll:Str 睡觉}" />
|
||||||
<MenuItem x:Name="MenuStudy" Header="{ll:Str 学习}" ScrollViewer.VerticalScrollBarVisibility="Auto"
|
<MenuItem x:Name="MenuStudy" Header="{ll:Str 学习}" ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||||
pu:DropDownHelper.MaxHeight="100" x:FieldModifier="public"/>
|
pu:DropDownHelper.MaxHeight="100" x:FieldModifier="public"/>
|
||||||
|
@ -222,7 +222,19 @@ namespace VPet_Simulator.Windows
|
|||||||
{
|
{
|
||||||
Dispatcher.Invoke(() =>
|
Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
Main.ToolBar.AddMenuButton(ToolBar.MenuType.Interact, "访客表".Translate(), () =>
|
var menuItem = new MenuItem()
|
||||||
|
{
|
||||||
|
Header = "访客表".Translate(),
|
||||||
|
HorizontalContentAlignment = HorizontalAlignment.Center
|
||||||
|
};
|
||||||
|
Main.ToolBar.MenuInteract.Items.Add(menuItem);
|
||||||
|
|
||||||
|
var menuCreate = new MenuItem()
|
||||||
|
{
|
||||||
|
Header = "创建".Translate(),
|
||||||
|
HorizontalContentAlignment = HorizontalAlignment.Center
|
||||||
|
};
|
||||||
|
menuCreate.Click += (_, _) =>
|
||||||
{
|
{
|
||||||
if (winMutiPlayer == null)
|
if (winMutiPlayer == null)
|
||||||
{
|
{
|
||||||
@ -231,9 +243,38 @@ namespace VPet_Simulator.Windows
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
MessageBoxX.Show("已经有加入了一个访客表,无法再创建更多".Translate());
|
||||||
winMutiPlayer.Focus();
|
winMutiPlayer.Focus();
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
menuItem.Items.Add(menuCreate);
|
||||||
|
|
||||||
|
var menuJoin = new MenuItem()
|
||||||
|
{
|
||||||
|
Header = "加入".Translate(),
|
||||||
|
HorizontalContentAlignment = HorizontalAlignment.Center
|
||||||
|
};
|
||||||
|
menuJoin.Click += (_, _) =>
|
||||||
|
{
|
||||||
|
if (winMutiPlayer == null)
|
||||||
|
{
|
||||||
|
winInputBox.Show(this, "请输入访客表ID".Translate(), "加入访客表".Translate(), "", (id) =>
|
||||||
|
{
|
||||||
|
if (ulong.TryParse(id, NumberStyles.HexNumber, null, out ulong lid))
|
||||||
|
{
|
||||||
|
winMutiPlayer = new winMutiPlayer(this, lid);
|
||||||
|
winMutiPlayer.Show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBoxX.Show("已经有加入了一个访客表,无法再创建更多".Translate());
|
||||||
|
winMutiPlayer.Focus();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
menuItem.Items.Add(menuJoin);
|
||||||
|
|
||||||
int clid = Array.IndexOf(App.Args, "connect_lobby");
|
int clid = Array.IndexOf(App.Args, "connect_lobby");
|
||||||
if (clid != -1)
|
if (clid != -1)
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
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="xxx的访客表"
|
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"
|
MinHeight="400" Width="400" Closed="Window_Closed" FontSize="16" SizeToContent="Height" MaxHeight="800"
|
||||||
ResizeMode="CanMinimize" Closing="Window_Closing">
|
ResizeMode="CanMinimize" Closing="Window_Closing">
|
||||||
<Grid>
|
<Grid>
|
||||||
|
@ -42,7 +42,7 @@ public partial class winMutiPlayer : Window
|
|||||||
public async void JoinLobby(ulong? lobbyid)
|
public async void JoinLobby(ulong? lobbyid)
|
||||||
{
|
{
|
||||||
var lbt = (await SteamMatchmaking.JoinLobbyAsync((SteamId)lobbyid));
|
var lbt = (await SteamMatchmaking.JoinLobbyAsync((SteamId)lobbyid));
|
||||||
if (!lbt.HasValue)
|
if (!lbt.HasValue || lbt.Value.Owner.Id.Value == 0)
|
||||||
{
|
{
|
||||||
MessageBoxX.Show("加入/创建访客表失败,请检查网络连接或重启游戏".Translate());
|
MessageBoxX.Show("加入/创建访客表失败,请检查网络连接或重启游戏".Translate());
|
||||||
Close();
|
Close();
|
||||||
@ -98,7 +98,6 @@ public partial class winMutiPlayer : Window
|
|||||||
}
|
}
|
||||||
public async void ShowLobbyInfo()
|
public async void ShowLobbyInfo()
|
||||||
{
|
{
|
||||||
|
|
||||||
lb.SetMemberData("save", mw.GameSavesData.GameSave.ToLine().ToString());
|
lb.SetMemberData("save", mw.GameSavesData.GameSave.ToLine().ToString());
|
||||||
lb.SetMemberData("onmod", mw.Set.FindLine("onmod")?.ToString() ?? "onmod");
|
lb.SetMemberData("onmod", mw.Set.FindLine("onmod")?.ToString() ?? "onmod");
|
||||||
lb.SetMemberData("petgraph", mw.Set.PetGraph);
|
lb.SetMemberData("petgraph", mw.Set.PetGraph);
|
||||||
@ -158,10 +157,11 @@ public partial class winMutiPlayer : Window
|
|||||||
|
|
||||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||||
{
|
{
|
||||||
if (MessageBoxX.Show("确定要关闭访客表吗?".Translate(), "离开游戏", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
|
if (!lb.Equals(default(Lobby)))
|
||||||
{
|
if (MessageBoxX.Show("确定要关闭访客表吗?".Translate(), "离开游戏", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
|
||||||
e.Cancel = true;
|
{
|
||||||
}
|
e.Cancel = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void swAllowJoin_Checked(object sender, RoutedEventArgs e)
|
private void swAllowJoin_Checked(object sender, RoutedEventArgs e)
|
||||||
|
25
VPet-Simulator.Windows/WinDesign/winInputBox.xaml
Normal file
25
VPet-Simulator.Windows/WinDesign/winInputBox.xaml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<Window x:Class="VPet_Simulator.Windows.winInputBox"
|
||||||
|
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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:VPet_Simulator.Windows" mc:Ignorable="d" MinWidth="300"
|
||||||
|
xmlns:pu="https://opensource.panuon.com/wpf-ui" Title="winInputBox" ResizeMode="NoResize"
|
||||||
|
WindowStartupLocation="CenterScreen" Topmost="True" Background="{DynamicResource SecondaryLighter}"
|
||||||
|
Closing="Window_Closing" Closed="Window_Closed" SizeToContent="WidthAndHeight">
|
||||||
|
<Grid Margin="10">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<TextBlock x:Name="Text" Text="文本消息内容就显示在这里,无论你是否接受,你也没法接受这样的弹窗?" Margin="20,5,20,5" VerticalAlignment="Top"
|
||||||
|
HorizontalAlignment="Center" TextWrapping="Wrap" TextAlignment="Center" />
|
||||||
|
<TextBox x:Name="TextBoxInput" Grid.Row="1" Margin="20,5,20,10" FontSize="14"
|
||||||
|
PreviewKeyDown="TextBoxInput_PreviewKeyDown" />
|
||||||
|
<Button Grid.Row="2" x:Name="ButtonOK" Content="确定" HorizontalAlignment="Right" Margin="5,0,0,0"
|
||||||
|
VerticalAlignment="Bottom" Height="26" Width="75" Foreground="{DynamicResource DARKPrimaryText}"
|
||||||
|
Background="{DynamicResource PrimaryDarker}" Click="ButtonYes_Click" FontSize="12"
|
||||||
|
pu:ButtonHelper.CornerRadius="5" />
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
72
VPet-Simulator.Windows/WinDesign/winInputBox.xaml.cs
Normal file
72
VPet-Simulator.Windows/WinDesign/winInputBox.xaml.cs
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using static System.Net.Mime.MediaTypeNames;
|
||||||
|
using VPet_Simulator.Core;
|
||||||
|
|
||||||
|
namespace VPet_Simulator.Windows;
|
||||||
|
/// <summary>
|
||||||
|
/// winInputBox.xaml 的交互逻辑
|
||||||
|
/// </summary>
|
||||||
|
public partial class winInputBox : Window
|
||||||
|
{
|
||||||
|
MainWindow mw;
|
||||||
|
public winInputBox(MainWindow mainw, string title, string text, string defaulttext, bool AllowMutiLine = false, bool CanHide = false, bool TextCenter = true)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
mw = mainw;
|
||||||
|
Text.Text = text;
|
||||||
|
Title = title;
|
||||||
|
TextBoxInput.AcceptsReturn = AllowMutiLine;
|
||||||
|
TextBoxInput.Text = defaulttext;
|
||||||
|
|
||||||
|
if (!TextCenter)
|
||||||
|
{
|
||||||
|
Text.TextAlignment = TextAlignment.Left;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void TextBoxInput_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (!TextBoxInput.AcceptsReturn && e.Key == Key.Enter)
|
||||||
|
{
|
||||||
|
ReturnYes = true;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public bool ReturnYes = false;
|
||||||
|
private void ButtonYes_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
ReturnYes = true;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
Action<string> ENDAction;
|
||||||
|
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||||
|
{
|
||||||
|
if (!ReturnYes)
|
||||||
|
TextBoxInput.Text = "";
|
||||||
|
}
|
||||||
|
public static winInputBox Show(MainWindow mainw, string title, string text, string defaulttext, Action<string> ENDAction, bool AllowMutiLine = false, bool TextCenter = true, bool CanHide = false)
|
||||||
|
{
|
||||||
|
winInputBox msgbox = new winInputBox(mainw, title, text, defaulttext, AllowMutiLine, CanHide, TextCenter);
|
||||||
|
msgbox.ENDAction = ENDAction;
|
||||||
|
mainw.Windows.Add(msgbox);
|
||||||
|
msgbox.ShowDialog();
|
||||||
|
return msgbox;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Window_Closed(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
ENDAction?.Invoke(TextBoxInput.Text);
|
||||||
|
mw.Windows.Remove(this);
|
||||||
|
}
|
||||||
|
}
|
@ -176,6 +176,9 @@ public partial class winWorkMenu : Window
|
|||||||
private void btnStart_Click(object sender, RoutedEventArgs e)
|
private void btnStart_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (nowworkdisplay != null)
|
if (nowworkdisplay != null)
|
||||||
|
{
|
||||||
mw.Main.StartWork(nowworkdisplay);
|
mw.Main.StartWork(nowworkdisplay);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user