联机支持关闭互动功能

This commit is contained in:
ZouJin 2024-03-22 23:13:27 +08:00
parent faf789c139
commit 2d9c4d89d8
8 changed files with 37 additions and 31 deletions

View File

@ -44,7 +44,7 @@ public interface IMPWindows
/// </summary> /// </summary>
/// <param name="friendid">好友id</param> /// <param name="friendid">好友id</param>
/// <param name="msg">消息内容(数据包)</param> /// <param name="msg">消息内容(数据包)</param>
void SendMessage(ulong friendid, MPMessage msg); bool SendMessage(ulong friendid, MPMessage msg);
/// <summary> /// <summary>
/// 给所有人发送消息 /// 给所有人发送消息

View File

@ -190,7 +190,7 @@ public partial class MPFriends : WindowX, IMPFriend
Main.ToolBar.M_TimeUIHandle(Main); Main.ToolBar.M_TimeUIHandle(Main);
Main.ToolBar.tfun.Visibility = Visibility.Collapsed; Main.ToolBar.tfun.Visibility = Visibility.Collapsed;
} }
if (lb.GetMemberData(friend, "onmod") == "true") if (lb.GetMemberData(friend, "notouch") == "true")
{ {
NoTouchTrue(); NoTouchTrue();
} }
@ -214,14 +214,14 @@ public partial class MPFriends : WindowX, IMPFriend
private void Main_Event_TouchHead() private void Main_Event_TouchHead()
{ {
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(SteamClient.Name, Core.Save.Name), 5000); Main.LabelDisplayShow("{0}在摸{1}的头".Translate(SteamClient.Name, Core.Save.Name), 3000);
var msg = new MPMessage() { Type = (int)MSGType.Interact, To = friend.Id }; var msg = new MPMessage() { Type = (int)MSGType.Interact, To = friend.Id };
msg.SetContent(Interact.TouchHead); msg.SetContent(Interact.TouchHead);
wmp.SendMessageALL(msg); wmp.SendMessageALL(msg);
} }
private void Main_Event_TouchBody() private void Main_Event_TouchBody()
{ {
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(SteamClient.Name, Core.Save.Name), 5000); Main.LabelDisplayShow("{0}在摸{1}的头".Translate(SteamClient.Name, Core.Save.Name), 3000);
var msg = new MPMessage() { Type = (int)MSGType.Interact, To = friend.Id }; var msg = new MPMessage() { Type = (int)MSGType.Interact, To = friend.Id };
msg.SetContent(Interact.TouchBody); msg.SetContent(Interact.TouchBody);
wmp.SendMessageALL(msg); wmp.SendMessageALL(msg);
@ -371,7 +371,7 @@ public partial class MPFriends : WindowX, IMPFriend
HideForDesign.Children.Remove(MPTalkBox); HideForDesign.Children.Remove(MPTalkBox);
Main.ToolBar.MainGrid.Children.Add(MPTalkBox); Main.ToolBar.MainGrid.Children.Add(MPTalkBox);
if (lb.GetMemberData(friend, "onmod") == "true") if (lb.GetMemberData(friend, "notouch") == "true")
{ {
NoTouchTrue(); NoTouchTrue();
} }
@ -441,6 +441,8 @@ public partial class MPFriends : WindowX, IMPFriend
Loaded = true; Loaded = true;
})); }));
} }
public winMPBetterBuy winMPBetterBuy; public winMPBetterBuy winMPBetterBuy;
public void ShowBetterBuy(Food.FoodType foodType) public void ShowBetterBuy(Food.FoodType foodType)
@ -478,7 +480,7 @@ public partial class MPFriends : WindowX, IMPFriend
return false; return false;
} }
Main.CountNomal = 0; Main.CountNomal = 0;
Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(SteamClient.Name, Core.Save.Name), 5000); Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(SteamClient.Name, Core.Save.Name), 3000);
if (Main.DisplayType.Name == "pinch") if (Main.DisplayType.Name == "pinch")
{ {
if (Main.DisplayType.Animat == AnimatType.A_Start) if (Main.DisplayType.Animat == AnimatType.A_Start)
@ -501,7 +503,7 @@ public partial class MPFriends : WindowX, IMPFriend
} }
private void DisplayPinch_loop() private void DisplayPinch_loop()
{ {
Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(SteamClient.Name, Core.Save.Name), 5000); Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(SteamClient.Name, Core.Save.Name), 3000);
var msg = new MPMessage() { Type = (int)MSGType.Interact, To = friend.Id }; var msg = new MPMessage() { Type = (int)MSGType.Interact, To = friend.Id };
msg.SetContent(Interact.TouchPinch); msg.SetContent(Interact.TouchPinch);
wmp.SendMessageALL(msg); wmp.SendMessageALL(msg);
@ -607,7 +609,7 @@ public partial class MPFriends : WindowX, IMPFriend
{ {
case Interact.TouchHead: case Interact.TouchHead:
case Interact.TouchBody: case Interact.TouchBody:
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name), 5000); Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name), 3000);
break; break;
case Interact.TouchPinch: case Interact.TouchPinch:
Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(byname, Core.Save.Name)); Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(byname, Core.Save.Name));
@ -619,15 +621,15 @@ public partial class MPFriends : WindowX, IMPFriend
{ {
case Interact.TouchHead: case Interact.TouchHead:
DisplayNOCALTouchHead(); DisplayNOCALTouchHead();
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name), 5000); Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name), 3000);
break; break;
case Interact.TouchBody: case Interact.TouchBody:
DisplayNOCALTouchBody(); DisplayNOCALTouchBody();
Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name), 5000); Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, Core.Save.Name), 3000);
break; break;
case Interact.TouchPinch: case Interact.TouchPinch:
DisplayNOCALTouchPinch(); DisplayNOCALTouchPinch();
Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(byname, Core.Save.Name), 5000); Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(byname, Core.Save.Name), 3000);
break; break;
} }
} }
@ -643,7 +645,7 @@ public partial class MPFriends : WindowX, IMPFriend
Main.Display(GraphType.Shutdown, AnimatType.Single, () => Dispatcher.Invoke(Close)); Main.Display(GraphType.Shutdown, AnimatType.Single, () => Dispatcher.Invoke(Close));
Task.Run(() => Task.Run(() =>
{ {
Thread.Sleep(5000); Thread.Sleep(3000);
if (Loaded) if (Loaded)
Dispatcher.Invoke(Close); Dispatcher.Invoke(Close);
}); });
@ -811,8 +813,8 @@ public partial class MPFriends : WindowX, IMPFriend
public void ReSetLocal() public void ReSetLocal()
{ {
Main.CleanState(); Main?.CleanState();
Main.DisplayToNomal(); Main?.DisplayToNomal();
Left = (SystemParameters.PrimaryScreenWidth - Width) / 2; Left = (SystemParameters.PrimaryScreenWidth - Width) / 2;
Top = (SystemParameters.PrimaryScreenHeight - Height) / 2; Top = (SystemParameters.PrimaryScreenHeight - Height) / 2;
} }

View File

@ -202,9 +202,9 @@ namespace VPet_Simulator.Windows
mf.DisplayFoodAnimation(item.GetGraph(), item.ImageSource); mf.DisplayFoodAnimation(item.GetGraph(), item.ImageSource);
if (EnableFunction) if (EnableFunction)
mf.Main.LabelDisplayShow("{0}花费${3}\n给{1}买了{2}".Translate(SteamClient.Name, mf.Core.Save.Name, item.TranslateName, item.Price), 10000); mf.Main.LabelDisplayShow("{0}花费${3}给{1}买了{2}".Translate(SteamClient.Name, mf.Core.Save.Name, item.TranslateName, item.Price), 6000);
else else
mf.Main.LabelDisplayShow("{0}给{1}买了{2}".Translate(SteamClient.Name, mf.Core.Save.Name, item.TranslateName), 10000); mf.Main.LabelDisplayShow("{0}给{1}买了{2}".Translate(SteamClient.Name, mf.Core.Save.Name, item.TranslateName), 6000);
var msg = new MPMessage() var msg = new MPMessage()
{ {

View File

@ -43,6 +43,7 @@ public partial class winMutiPlayer : Window, IMPWindows
public winMutiPlayer(MainWindow mw, ulong? lobbyid = null) public winMutiPlayer(MainWindow mw, ulong? lobbyid = null)
{ {
InitializeComponent(); InitializeComponent();
swAllowTouch.IsChecked = !mw.Set.MPNOTouch;
this.mw = mw; this.mw = mw;
if (lobbyid == null) if (lobbyid == null)
CreateLobby(); CreateLobby();
@ -276,10 +277,10 @@ public partial class winMutiPlayer : Window, IMPWindows
/// <summary> /// <summary>
/// 给指定好友发送消息 /// 给指定好友发送消息
/// </summary> /// </summary>
public void SendMessage(ulong friendid, MPMessage msg) public bool SendMessage(ulong friendid, MPMessage msg)
{ {
byte[] data = ConverTo(msg); byte[] data = ConverTo(msg);
SteamNetworking.SendP2PPacket(friendid, data); return SteamNetworking.SendP2PPacket(friendid, data);
} }
/// <summary> /// <summary>
/// 给所有人发送消息 /// 给所有人发送消息
@ -309,8 +310,8 @@ public partial class winMutiPlayer : Window, IMPWindows
public event Action<ulong> OnMemberJoined; public event Action<ulong> OnMemberJoined;
private void SteamMatchmaking_OnLobbyMemberJoined(Lobby lobby, Friend friend) private void SteamMatchmaking_OnLobbyMemberJoined(Lobby lobby, Friend friend)
{ {
if (lobby.Id == lb.Id) if (lobby.Id == lb.Id && MPFriends.Find(x => x.friend.Id == friend.Id) == null)
{ { //如果有未处理的退出,不管
Log("好友{0}已加入访客表".Translate(friend.Name)); Log("好友{0}已加入访客表".Translate(friend.Name));
var mpf = new MPFriends(this, mw, lb, friend); var mpf = new MPFriends(this, mw, lb, friend);
MPFriends.Add(mpf); MPFriends.Add(mpf);
@ -349,21 +350,22 @@ public partial class winMutiPlayer : Window, IMPWindows
var interact = MSG.GetContent<Interact>(); var interact = MSG.GetContent<Interact>();
if (MSG.To == SteamClient.SteamId.Value) if (MSG.To == SteamClient.SteamId.Value)
{ {
if (mw.Set.MPNOTouch) return;
bool isok = !IMPFriend.InConvenience(mw.Main); bool isok = !IMPFriend.InConvenience(mw.Main);
switch (interact) switch (interact)
{ {
case Interact.TouchHead: case Interact.TouchHead:
mw.Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, mw.Core.Save.Name), 5000); mw.Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, mw.Core.Save.Name), 3000);
if (isok) if (isok)
DisplayNOCALTouchHead(); DisplayNOCALTouchHead();
break; break;
case Interact.TouchBody: case Interact.TouchBody:
mw.Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, mw.Core.Save.Name), 5000); mw.Main.LabelDisplayShow("{0}在摸{1}的头".Translate(byname, mw.Core.Save.Name), 3000);
if (isok) if (isok)
DisplayNOCALTouchBody(); DisplayNOCALTouchBody();
break; break;
case Interact.TouchPinch: case Interact.TouchPinch:
mw.Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(byname, mw.Core.Save.Name), 5000); mw.Main.LabelDisplayShow("{0}在捏{1}的脸".Translate(byname, mw.Core.Save.Name), 3000);
if (isok) if (isok)
DisplayNOCALTouchPinch(); DisplayNOCALTouchPinch();
break; break;
@ -385,7 +387,7 @@ public partial class winMutiPlayer : Window, IMPWindows
mw.DisplayFoodAnimation(feed.Item.GetGraph(), feed.Item.ImageSource); mw.DisplayFoodAnimation(feed.Item.GetGraph(), feed.Item.ImageSource);
if (feed.EnableFunction) if (feed.EnableFunction)
{ {
mw.Main.LabelDisplayShow("{0}花费${3}给{1}买了{2}".Translate(byname, mw.GameSavesData.GameSave.Name, feed.Item.TranslateName, feed.Item.Price), 10000); mw.Main.LabelDisplayShow("{0}花费${3}给{1}买了{2}".Translate(byname, mw.GameSavesData.GameSave.Name, feed.Item.TranslateName, feed.Item.Price), 6000);
Log("{0}花费${3}给{1}买了{2}".Translate(byname, mw.GameSavesData.GameSave.Name, feed.Item.TranslateName, feed.Item.Price)); Log("{0}花费${3}给{1}买了{2}".Translate(byname, mw.GameSavesData.GameSave.Name, feed.Item.TranslateName, feed.Item.Price));
//对于要修改数据的物品一定要再次检查,避免联机开挂毁存档 //对于要修改数据的物品一定要再次检查,避免联机开挂毁存档
if (item.Price >= 10 && item.Price <= 1000 && item.Health >= 0 && item.Exp >= 0 && item.Likability >= 0 && giveprice < 1000 if (item.Price >= 10 && item.Price <= 1000 && item.Health >= 0 && item.Exp >= 0 && item.Likability >= 0 && giveprice < 1000
@ -397,7 +399,7 @@ public partial class winMutiPlayer : Window, IMPWindows
} }
else else
{ {
mw.Main.LabelDisplayShow("{0}给{1}买了{2}".Translate(byname, mw.GameSavesData.GameSave.Name, feed.Item.TranslateName), 10000); mw.Main.LabelDisplayShow("{0}给{1}买了{2}".Translate(byname, mw.GameSavesData.GameSave.Name, feed.Item.TranslateName), 6000);
Log("{0}给{1}买了{2}".Translate(byname, mw.GameSavesData.GameSave.Name, feed.Item.TranslateName)); Log("{0}给{1}买了{2}".Translate(byname, mw.GameSavesData.GameSave.Name, feed.Item.TranslateName));
} }
} }
@ -545,13 +547,14 @@ public partial class winMutiPlayer : Window, IMPWindows
private void swAllowTouch_Checked(object sender, RoutedEventArgs e) private void swAllowTouch_Checked(object sender, RoutedEventArgs e)
{ {
if (mw == null) return; if (mw == null) return;
lb.SetMemberData("notouch", "true"); lb.SetMemberData("notouch", "false");
mw.Set.MPNOTouch = false; mw.Set.MPNOTouch = false;
} }
private void swAllowTouch_Unchecked(object sender, RoutedEventArgs e) private void swAllowTouch_Unchecked(object sender, RoutedEventArgs e)
{ {
lb.SetMemberData("notouch", "false"); if (mw == null) return;
mw.Set.MPNOTouch = false; lb.SetMemberData("notouch", "true");
mw.Set.MPNOTouch = true;
} }
} }

View File

@ -63,9 +63,13 @@
</AssemblyAttribute> </AssemblyAttribute>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Remove="GameAssets\**" />
<Compile Remove="mod\**" /> <Compile Remove="mod\**" />
<EmbeddedResource Remove="GameAssets\**" />
<EmbeddedResource Remove="mod\**" /> <EmbeddedResource Remove="mod\**" />
<None Remove="GameAssets\**" />
<None Remove="mod\**" /> <None Remove="mod\**" />
<Page Remove="GameAssets\**" />
<Page Remove="mod\**" /> <Page Remove="mod\**" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -24,7 +24,6 @@
和{0}悄悄说#Whisper to {0}:| 和{0}悄悄说#Whisper to {0}:|
和{0}说#Say it with {0}:| 和{0}说#Say it with {0}:|
给更好的{0}买#Buy for Better {0}:| 给更好的{0}买#Buy for Better {0}:|
{0}花费${3}\n给{1}买了{2}#{0} spends ${3}\n to buy {1} for {2}:|
加入/创建访客表失败,请检查网络连接或重启游戏#Failed to join/create Guest List, please check your internet connection or restart the game!:| 加入/创建访客表失败,请检查网络连接或重启游戏#Failed to join/create Guest List, please check your internet connection or restart the game!:|
{0}的访客表#The Guest List for {0}:| {0}的访客表#The Guest List for {0}:|
访客表已被房主{0}关闭#Guest List has been closed by Host {0}:| 访客表已被房主{0}关闭#Guest List has been closed by Host {0}:|

View File

@ -24,7 +24,6 @@
和{0}悄悄说#和{0}悄悄说:| 和{0}悄悄说#和{0}悄悄说:|
和{0}说#和{0}说:| 和{0}说#和{0}说:|
给更好的{0}买#给更好的{0}买:| 给更好的{0}买#给更好的{0}买:|
{0}花费${3}\n给{1}买了{2}#{0}花费${3}\n给{1}买了{2}:|
加入/创建访客表失败,请检查网络连接或重启游戏#加入/创建访客表失败,请检查网络连接或重启游戏:| 加入/创建访客表失败,请检查网络连接或重启游戏#加入/创建访客表失败,请检查网络连接或重启游戏:|
{0}的访客表#{0}的访客表:| {0}的访客表#{0}的访客表:|
访客表已被房主{0}关闭#访客表已被房主{0}关闭:| 访客表已被房主{0}关闭#访客表已被房主{0}关闭:|

View File

@ -24,7 +24,6 @@
和{0}悄悄说#和{0}悄悄說:| 和{0}悄悄说#和{0}悄悄說:|
和{0}说#和{0}說:| 和{0}说#和{0}說:|
给更好的{0}买#給更好的{0}買:| 给更好的{0}买#給更好的{0}買:|
{0}花费${3}\n给{1}买了{2}#{0}花費${3}\n給{1}買了{2}:|
加入/创建访客表失败,请检查网络连接或重启游戏#加入/建立訪客表失敗,請檢查網路連線或重新啟動遊戲:| 加入/创建访客表失败,请检查网络连接或重启游戏#加入/建立訪客表失敗,請檢查網路連線或重新啟動遊戲:|
{0}的访客表#{0}的訪客表:| {0}的访客表#{0}的訪客表:|
访客表已被房主{0}关闭#訪客表已被屋主{0}關閉:| 访客表已被房主{0}关闭#訪客表已被屋主{0}關閉:|