From 969d52c2f7ba962e1b2d085028c40343245aaf7d Mon Sep 17 00:00:00 2001 From: ZouJin Date: Thu, 21 Mar 2024 16:24:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=B8=B8=E6=88=8F=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet-Simulator.Core/Display/ToolBar.xaml | 4 +- VPet-Simulator.Core/Display/ToolBar.xaml.cs | 10 ++- VPet-Simulator.Windows/MainWindow.cs | 4 ++ .../MutiPlayer/MPFriends.xaml.cs | 67 ++++++++++++------- .../MutiPlayer/MPUserControl.xaml | 4 +- .../MutiPlayer/winMPBetterBuy.xaml.cs | 4 +- .../MutiPlayer/winMutiPlayer.xaml.cs | 20 ++++-- 7 files changed, 74 insertions(+), 39 deletions(-) diff --git a/VPet-Simulator.Core/Display/ToolBar.xaml b/VPet-Simulator.Core/Display/ToolBar.xaml index 7b40c8b..0c60992 100644 --- a/VPet-Simulator.Core/Display/ToolBar.xaml +++ b/VPet-Simulator.Core/Display/ToolBar.xaml @@ -49,9 +49,9 @@ + Text="{ll:Str 宠物已经生病\, 通过服用药物可以恢复}" TextWrapping="Wrap" x:FieldModifier="public" /> + Text="{ll:Str 已关闭数据计算\, 可放心挂机}" TextWrapping="Wrap" x:FieldModifier="public" /> diff --git a/VPet-Simulator.Core/Display/ToolBar.xaml.cs b/VPet-Simulator.Core/Display/ToolBar.xaml.cs index 26d511a..b1b10f8 100644 --- a/VPet-Simulator.Core/Display/ToolBar.xaml.cs +++ b/VPet-Simulator.Core/Display/ToolBar.xaml.cs @@ -63,7 +63,9 @@ namespace VPet_Simulator.Core if (m.StartWork(w)) Visibility = Visibility.Collapsed; } - + /// + /// 加载默认工作 + /// public void LoadWork() { LoadClean(); @@ -156,8 +158,10 @@ namespace VPet_Simulator.Core { StartWork(wplay); } - - private void M_TimeUIHandle(Main m) + /// + /// 刷新显示UI + /// + public void M_TimeUIHandle(Main m) { if (BdrPanel.Visibility == Visibility.Visible) { diff --git a/VPet-Simulator.Windows/MainWindow.cs b/VPet-Simulator.Windows/MainWindow.cs index 6c08727..ba60fb2 100644 --- a/VPet-Simulator.Windows/MainWindow.cs +++ b/VPet-Simulator.Windows/MainWindow.cs @@ -867,6 +867,10 @@ namespace VPet_Simulator.Windows SteamFriends.SetRichPresence("steam_player_group", winMutiPlayer.LobbyID.ToString("x")); SteamFriends.SetRichPresence("steam_player_group_size", winMutiPlayer.lb.MemberCount.ToString()); } + else + { + SteamFriends.SetRichPresence("steam_player_group_size", "0"); + } if (App.MainWindows.Count > 1) { if (App.MainWindows.FirstOrDefault() != this) diff --git a/VPet-Simulator.Windows/MutiPlayer/MPFriends.xaml.cs b/VPet-Simulator.Windows/MutiPlayer/MPFriends.xaml.cs index 56f1608..be2a143 100644 --- a/VPet-Simulator.Windows/MutiPlayer/MPFriends.xaml.cs +++ b/VPet-Simulator.Windows/MutiPlayer/MPFriends.xaml.cs @@ -167,20 +167,35 @@ public partial class MPFriends : WindowX, IMPFriend Main.Event_TouchHead += Main_Event_TouchHead; Main.Event_TouchBody += Main_Event_TouchBody; + SteamMatchmaking.OnLobbyMemberDataChanged += SteamMatchmaking_OnLobbyMemberDataChanged; }); } + private void SteamMatchmaking_OnLobbyMemberDataChanged(Lobby lobby, Friend friend) + { + if (lobby.Id == lb.Id && friend.Id == this.friend.Id) + { + string tmp = lb.GetMemberData(friend, "save"); + if (!string.IsNullOrEmpty(tmp)) + { + Core.Save = GameSave_VPet.Load(new Line(tmp)); + Main.ToolBar.M_TimeUIHandle(Main); + Main.ToolBar.tfun.Visibility = Visibility.Collapsed; + } + } + } + private void Main_Event_TouchHead() { - Main.LabelDisplayShow("{0}在摸{1}的头".Translate(SteamClient.Name, Core.Save.Name)); + Main.LabelDisplayShow("{0}在摸{1}的头".Translate(SteamClient.Name, Core.Save.Name), 5000); var msg = new MPMessage() { Type = (int)MSGType.Interact, To = friend.Id }; msg.SetContent(Interact.TouchHead); wmp.SendMessageALL(msg); } private void Main_Event_TouchBody() { - Main.LabelDisplayShow("{0}在摸{1}的头".Translate(SteamClient.Name, Core.Save.Name)); + Main.LabelDisplayShow("{0}在摸{1}的头".Translate(SteamClient.Name, Core.Save.Name), 5000); var msg = new MPMessage() { Type = (int)MSGType.Interact, To = friend.Id }; msg.SetContent(Interact.TouchBody); wmp.SendMessageALL(msg); @@ -253,15 +268,15 @@ public partial class MPFriends : WindowX, IMPFriend petloader ??= Pets[0]; - ////加载数据合理化:食物 - //foreach (Food f in Foods) - //{ - // if (f.IsOverLoad()) - // { - // f.Price = Math.Max((int)f.RealPrice, 1); - // f.isoverload = false; - // } - //} + //加载数据合理化:食物 + foreach (Food f in Foods) + { + if (f.IsOverLoad()) + { + f.Price = Math.Max((int)f.RealPrice, 1); + f.isoverload = false; + } + } await Dispatcher.InvokeAsync(new Action(() => { LoadingText.Content = "尝试加载动画和生成缓存\n该步骤可能会耗时比较长\n请耐心等待".Translate(); @@ -277,6 +292,14 @@ public partial class MPFriends : WindowX, IMPFriend Main.Load_2_TouchEvent(); Task.Run(Main.Load_24_WaitAndStart); + Main.ToolBar.MenuInteract.Items.Clear(); + Main.ToolBar.AddMenuButton(ToolBar.MenuType.Interact, "摸头".Translate(), Main.DisplayTouchHead); + Main.ToolBar.AddMenuButton(ToolBar.MenuType.Interact, "摸身体".Translate(), Main.DisplayTouchBody); + Main.ToolBar.AddMenuButton(ToolBar.MenuType.Interact, "捏脸".Translate(), () => DisplayPinch()); + + Main.ToolBar.AddMenuButton(ToolBar.MenuType.Setting, "退出访客表".Translate(), wmp.Close); + Main.ToolBar.tfun.Visibility = Visibility.Collapsed; + Main.EventTimer.AutoReset = false; Main.EventTimer.Enabled = false; @@ -373,7 +396,7 @@ public partial class MPFriends : WindowX, IMPFriend return false; } Main.CountNomal = 0; - + Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(SteamClient.Name, Core.Save.Name), 5000); if (Main.DisplayType.Name == "pinch") { if (Main.DisplayType.Animat == AnimatType.A_Start) @@ -396,19 +419,12 @@ public partial class MPFriends : WindowX, IMPFriend } private void DisplayPinch_loop() { - Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(SteamClient.Name, Core.Save.Name)); + Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(SteamClient.Name, Core.Save.Name), 5000); var msg = new MPMessage() { Type = (int)MSGType.Interact, To = friend.Id }; msg.SetContent(Interact.TouchPinch); wmp.SendMessageALL(msg); if (Main.isPress && Main.DisplayType.Name == "pinch" && Main.DisplayType.Animat == AnimatType.B_Loop) - { - if (Core.Controller.EnableFunction && Core.Save.Strength >= 10 && Core.Save.Feeling < 100) - { - Core.Save.StrengthChange(-2); - Core.Save.FeelingChange(1); - Core.Save.Mode = Core.Save.CalMode(); - Main.LabelDisplayShowChangeNumber(LocalizeCore.Translate("体力-{0:f0} 心情+{1:f0}"), 2, 1); - } + { Main.Display("pinch", AnimatType.B_Loop, DisplayPinch_loop); } else @@ -509,7 +525,7 @@ public partial class MPFriends : WindowX, IMPFriend { case Interact.TouchHead: case Interact.TouchBody: - Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name)); + Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name), 5000); break; case Interact.TouchPinch: Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(byname, Core.Save.Name)); @@ -521,15 +537,15 @@ public partial class MPFriends : WindowX, IMPFriend { case Interact.TouchHead: DisplayNOCALTouchHead(); - Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name)); + Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name), 5000); break; case Interact.TouchBody: DisplayNOCALTouchBody(); - Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name)); + Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name), 5000); break; case Interact.TouchPinch: DisplayNOCALTouchPinch(); - Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(byname, Core.Save.Name)); + Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(byname, Core.Save.Name), 5000); break; } } @@ -631,6 +647,7 @@ public partial class MPFriends : WindowX, IMPFriend } } } + SteamMatchmaking.OnLobbyMemberDataChanged -= SteamMatchmaking_OnLobbyMemberDataChanged; winMPBetterBuy?.Close(); Main?.Dispose(); mw.Windows.Remove(this); diff --git a/VPet-Simulator.Windows/MutiPlayer/MPUserControl.xaml b/VPet-Simulator.Windows/MutiPlayer/MPUserControl.xaml index 2392520..1f1c4ca 100644 --- a/VPet-Simulator.Windows/MutiPlayer/MPUserControl.xaml +++ b/VPet-Simulator.Windows/MutiPlayer/MPUserControl.xaml @@ -7,10 +7,10 @@ mc:Ignorable="d" Margin="5" Width="340" Height="100" Background="{DynamicResource SecondaryLight}" BorderBrush="{DynamicResource Secondary}"> - + - : diff --git a/VPet-Simulator.Windows/MutiPlayer/winMPBetterBuy.xaml.cs b/VPet-Simulator.Windows/MutiPlayer/winMPBetterBuy.xaml.cs index 8f3c1a4..f771078 100644 --- a/VPet-Simulator.Windows/MutiPlayer/winMPBetterBuy.xaml.cs +++ b/VPet-Simulator.Windows/MutiPlayer/winMPBetterBuy.xaml.cs @@ -201,9 +201,9 @@ namespace VPet_Simulator.Windows mf.DisplayFoodAnimation(item.GetGraph(), item.ImageSource); if (EnableFunction) - mf.Main.LabelDisplayShow("{0}花费${3}\n给{1}买了{2}".Translate(SteamClient.Name, mf.Core.Save.Name, item.TranslateName, item.Price)); + mf.Main.LabelDisplayShow("{0}花费${3}\n给{1}买了{2}".Translate(SteamClient.Name, mf.Core.Save.Name, item.TranslateName, item.Price), 10000); else - mf.Main.LabelDisplayShow("{0}给{1}买了{2}".Translate(SteamClient.Name, mf.Core.Save.Name, item.TranslateName)); + mf.Main.LabelDisplayShow("{0}给{1}买了{2}".Translate(SteamClient.Name, mf.Core.Save.Name, item.TranslateName), 10000); var msg = new MPMessage() { diff --git a/VPet-Simulator.Windows/MutiPlayer/winMutiPlayer.xaml.cs b/VPet-Simulator.Windows/MutiPlayer/winMutiPlayer.xaml.cs index d17f1a5..5adbc6d 100644 --- a/VPet-Simulator.Windows/MutiPlayer/winMutiPlayer.xaml.cs +++ b/VPet-Simulator.Windows/MutiPlayer/winMutiPlayer.xaml.cs @@ -136,6 +136,7 @@ public partial class winMutiPlayer : Window, IMPWindows SteamMatchmaking.OnLobbyMemberJoined += SteamMatchmaking_OnLobbyMemberJoined; SteamMatchmaking.OnLobbyMemberLeave += SteamMatchmaking_OnLobbyMemberLeave; SteamMatchmaking.OnLobbyDataChanged += SteamMatchmaking_OnLobbyDataChanged; + Steamworks.Data.Image? img = await lb.Owner.GetMediumAvatarAsync(); Dispatcher.Invoke(() => @@ -154,6 +155,7 @@ public partial class winMutiPlayer : Window, IMPWindows //给自己动画添加绑定 mw.Main.GraphDisplayHandler += Main_GraphDisplayHandler; + mw.Main.TimeHandle += Main_TimeHandle; if (IsHost) { Dispatcher.Invoke(() => @@ -196,6 +198,11 @@ public partial class winMutiPlayer : Window, IMPWindows }); } + private void Main_TimeHandle(Main obj) + { + lb.SetMemberData("save", mw.GameSavesData.GameSave.ToLine().ToString()); + } + private void SteamMatchmaking_OnLobbyDataChanged(Lobby lobby) { if (lb.Id == lobby.Id) @@ -341,17 +348,17 @@ public partial class winMutiPlayer : Window, IMPWindows switch (interact) { case Interact.TouchHead: - mw.Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, mw.Core.Save.Name)); + mw.Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, mw.Core.Save.Name), 5000); if (isok) DisplayNOCALTouchHead(); break; case Interact.TouchBody: - mw.Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, mw.Core.Save.Name)); + mw.Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, mw.Core.Save.Name), 5000); if (isok) DisplayNOCALTouchBody(); break; case Interact.TouchPinch: - mw.Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(byname, mw.Core.Save.Name)); + mw.Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(byname, mw.Core.Save.Name), 5000); if (isok) DisplayNOCALTouchPinch(); break; @@ -373,7 +380,7 @@ public partial class winMutiPlayer : Window, IMPWindows mw.DisplayFoodAnimation(feed.Item.GetGraph(), feed.Item.ImageSource); if (feed.EnableFunction) { - mw.Main.LabelDisplayShow("{0}花费${3}给{1}买了{2}".Translate(byname, mw.GameSavesData.GameSave.Name, feed.Item.TranslateName, feed.Item.Price)); + mw.Main.LabelDisplayShow("{0}花费${3}给{1}买了{2}".Translate(byname, mw.GameSavesData.GameSave.Name, feed.Item.TranslateName, feed.Item.Price), 10000); //对于要修改数据的物品一定要再次检查,避免联机开挂毁存档 if (item.Price >= 10 && item.Price <= 1000 && item.Health >= 0 && item.Exp >= 0 && item.Likability >= 0 && giveprice < 1000) {//单次联机收礼物上限1000 @@ -382,7 +389,7 @@ public partial class winMutiPlayer : Window, IMPWindows } } else - mw.Main.LabelDisplayShow("{0}给{1}买了{2}".Translate(byname, mw.GameSavesData.GameSave.Name, feed.Item.TranslateName)); + mw.Main.LabelDisplayShow("{0}给{1}买了{2}".Translate(byname, mw.GameSavesData.GameSave.Name, feed.Item.TranslateName), 10000); } else { @@ -406,8 +413,11 @@ public partial class winMutiPlayer : Window, IMPWindows public event Action ReceivedMessage; private void Window_Closed(object sender, EventArgs e) { + mw.Main.TimeHandle -= Main_TimeHandle; mw.Main.GraphDisplayHandler -= Main_GraphDisplayHandler; SteamMatchmaking.OnLobbyMemberJoined -= SteamMatchmaking_OnLobbyMemberJoined; + SteamMatchmaking.OnLobbyMemberLeave -= SteamMatchmaking_OnLobbyMemberLeave; + SteamMatchmaking.OnLobbyDataChanged -= SteamMatchmaking_OnLobbyDataChanged; lb.Leave(); for (int i = 0; i < MPFriends.Count; i++) {