当其他人邀请时显示聊天

This commit is contained in:
ZouJin 2024-03-16 19:22:07 +08:00
parent 54d3470dea
commit 58649dc7c8
2 changed files with 98 additions and 70 deletions

View File

@ -6,7 +6,6 @@ using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using VPet_Simulator.Core;
using System.Windows.Forms;
using System.Timers;
using LinePutScript;
using Panuon.WPF.UI;
@ -21,6 +20,8 @@ using static VPet_Simulator.Core.GraphInfo;
using System.Globalization;
using LinePutScript.Dictionary;
using Steamworks.Data;
using System.Windows.Controls;
using ToolBar = VPet_Simulator.Core.ToolBar;
namespace VPet_Simulator.Windows
{
@ -29,7 +30,7 @@ namespace VPet_Simulator.Windows
/// </summary>
public partial class MainWindow : WindowX
{
private NotifyIcon notifyIcon;
private System.Windows.Forms.NotifyIcon notifyIcon;
public PetHelper petHelper;
public System.Timers.Timer AutoSaveTimer = new System.Timers.Timer();
@ -218,6 +219,7 @@ namespace VPet_Simulator.Windows
await GameLoad(Path);
if (IsSteamUser)
{
Dispatcher.Invoke(() =>
{
Main.ToolBar.AddMenuButton(ToolBar.MenuType.Interact, "访客表".Translate(), () =>
@ -242,9 +244,27 @@ namespace VPet_Simulator.Windows
}
}
});
SteamMatchmaking.OnLobbyInvite += SteamMatchmaking_OnLobbyInvite;
}
});
}
private void SteamMatchmaking_OnLobbyInvite(Friend friend, Lobby lobby)
{
if (winMutiPlayer != null)
return;
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);
}
internal winMutiPlayer winMutiPlayer;
public new void Close()
@ -529,7 +549,7 @@ namespace VPet_Simulator.Windows
//uint extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
//SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);
HitThrough = !HitThrough;
(notifyIcon.ContextMenuStrip.Items.Find("NotifyIcon_HitThrough", false).First() as ToolStripMenuItem).Checked = HitThrough;
(notifyIcon.ContextMenuStrip.Items.Find("NotifyIcon_HitThrough", false).First() as System.Windows.Forms.ToolStripMenuItem).Checked = HitThrough;
if (HitThrough)
{
Win32.User32.SetWindowLongPtr(_hwnd, Win32.GetWindowLongFields.GWL_EXSTYLE,

View File

@ -43,87 +43,95 @@ public class MPMOD
public MPMOD(DirectoryInfo directory, MPFriends mw)
{
#if !DEBUG
try
{
try
{
#endif
var Path = directory;
LpsDocument modlps = new LpsDocument(File.ReadAllText(directory.FullName + @"\info.lps"));
Name = modlps.FindLine("vupmod").Info;
var Path = directory;
LpsDocument modlps = new LpsDocument(File.ReadAllText(directory.FullName + @"\info.lps"));
Name = modlps.FindLine("vupmod").Info;
//MOD未加载时支持翻译
foreach (var line in modlps.FindAllLine("lang"))
{
List<ILine> ls = new List<ILine>();
foreach (var sub in line)
//MOD未加载时支持翻译
foreach (var line in modlps.FindAllLine("lang"))
{
ls.Add(new Line(sub.Name, sub.info));
List<ILine> ls = new List<ILine>();
foreach (var sub in line)
{
ls.Add(new Line(sub.Name, sub.info));
}
LocalizeCore.AddCulture(line.info, ls);
}
if (!IsOnMOD(mw))
{
return;
}
LocalizeCore.AddCulture(line.info, ls);
}
if (!IsOnMOD(mw))
{
return;
}
foreach (DirectoryInfo di in Path.EnumerateDirectories())
{
switch (di.Name.ToLower())
{
case "pet":
//宠物模型
foreach (FileInfo fi in di.EnumerateFiles("*.lps"))
{
LpsDocument lps = new LpsDocument(File.ReadAllText(fi.FullName));
if (lps.First().Name.ToLower() == "pet")
foreach (DirectoryInfo di in Path.EnumerateDirectories())
{
switch (di.Name.ToLower())
{
case "pet":
//宠物模型
foreach (FileInfo fi in di.EnumerateFiles("*.lps"))
{
var name = lps.First().Info;
var p = mw.Pets.FirstOrDefault(x => x.Name == name);
if (p == null)
LpsDocument lps = new LpsDocument(File.ReadAllText(fi.FullName));
if (lps.First().Name.ToLower() == "pet")
{
p = new PetLoader(lps, di);
mw.Pets.Add(p);
}
else
{
var dis = new DirectoryInfo(di.FullName + "\\" + lps.First()["path"].Info);
p.path.Add(di.FullName + "\\" + lps.First()["path"].Info);
p.Config.Set(lps);
var name = lps.First().Info;
var p = mw.Pets.FirstOrDefault(x => x.Name == name);
if (p == null)
{
p = new PetLoader(lps, di);
mw.Pets.Add(p);
}
else
{
var dis = new DirectoryInfo(di.FullName + "\\" + lps.First()["path"].Info);
p.path.Add(di.FullName + "\\" + lps.First()["path"].Info);
p.Config.Set(lps);
}
}
}
}
break;
case "food":
foreach (FileInfo fi in di.EnumerateFiles("*.lps"))
{
var tmp = new LpsDocument(File.ReadAllText(fi.FullName));
foreach (ILine li in tmp)
break;
case "food":
foreach (FileInfo fi in di.EnumerateFiles("*.lps"))
{
if (li.Name != "food")
continue;
string tmps = li.Find("name").info;
mw.Foods.RemoveAll(x => x.Name == tmps);
mw.Foods.Add(LPSConvert.DeserializeObject<Food>(li));
var tmp = new LpsDocument(File.ReadAllText(fi.FullName));
foreach (ILine li in tmp)
{
if (li.Name != "food")
continue;
string tmps = li.Find("name").info;
mw.Foods.RemoveAll(x => x.Name == tmps);
mw.Foods.Add(LPSConvert.DeserializeObject<Food>(li));
}
}
}
break;
case "image":
LoadImage(mw, di);
break;
case "lang":
foreach (FileInfo fi in di.EnumerateFiles("*.lps"))
{
LocalizeCore.AddCulture(fi.Name.Substring(0, fi.Name.Length - fi.Extension.Length), new LPS_D(File.ReadAllText(fi.FullName)));
}
foreach (DirectoryInfo dis in di.EnumerateDirectories())
{
foreach (FileInfo fi in dis.EnumerateFiles("*.lps"))
break;
case "image":
LoadImage(mw, di);
break;
case "lang":
foreach (FileInfo fi in di.EnumerateFiles("*.lps"))
{
LocalizeCore.AddCulture(dis.Name, new LPS_D(File.ReadAllText(fi.FullName)));
LocalizeCore.AddCulture(fi.Name.Substring(0, fi.Name.Length - fi.Extension.Length), new LPS_D(File.ReadAllText(fi.FullName)));
}
}
break;
foreach (DirectoryInfo dis in di.EnumerateDirectories())
{
foreach (FileInfo fi in dis.EnumerateFiles("*.lps"))
{
LocalizeCore.AddCulture(dis.Name, new LPS_D(File.ReadAllText(fi.FullName)));
}
}
break;
}
}
#if !DEBUG
}
catch
{
}
#endif
}
public bool IsOnMOD(MPFriends mw) => mw.IsOnMod(Name);
}