From dd9c5317dbc71b4e2f55bfcee2e165846ddda42a Mon Sep 17 00:00:00 2001
From: ZouJin <zoujin.dev@exlb.org>
Date: Wed, 5 Jul 2023 13:22:34 +1000
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=80=80=E5=87=BA=E6=96=B9?=
 =?UTF-8?q?=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 VPet-Simulator.Windows/Function/CoreMOD.cs    |  6 ++---
 VPet-Simulator.Windows/MainWindow.xaml.cs     | 27 ++++++++++++-------
 .../WinDesign/winGameSetting.xaml.cs          |  4 ++-
 3 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/VPet-Simulator.Windows/Function/CoreMOD.cs b/VPet-Simulator.Windows/Function/CoreMOD.cs
index cb229de..b1288fb 100644
--- a/VPet-Simulator.Windows/Function/CoreMOD.cs
+++ b/VPet-Simulator.Windows/Function/CoreMOD.cs
@@ -176,16 +176,16 @@ namespace VPet_Simulator.Windows
                                         && certificate.Issuer == "CN=DigiCert Trusted G4 Code Signing RSA4096 SHA384 2021 CA1, O=\"DigiCert, Inc.\", C=US")
                                     {//LBGame 信任的证书
                                         if (!Author.Contains("["))
-                                            Author += "[认证]";
+                                            Author += "[认证]".Translate();
                                     }
-                                    else if (!IsPassMOD(mw))
+                                    else if (certificate.Subject != "CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" && !IsPassMOD(mw))
                                     {//不是通过模组,不加载
                                         SuccessLoad = false;
                                         continue;
                                     }
                                     else if (!Author.Contains("["))
                                     {
-                                        Author += "[签名]";
+                                        Author += "[签名]".Translate();
                                         Intro += $"Subject:{certificate.Subject}\nIssuer:{certificate.Subject}";
                                     }
                                 }
diff --git a/VPet-Simulator.Windows/MainWindow.xaml.cs b/VPet-Simulator.Windows/MainWindow.xaml.cs
index f0dd617..9c30e02 100644
--- a/VPet-Simulator.Windows/MainWindow.xaml.cs
+++ b/VPet-Simulator.Windows/MainWindow.xaml.cs
@@ -217,14 +217,6 @@ namespace VPet_Simulator.Windows
 
             Dispatcher.BeginInvoke(new Action(() => LoadingText.Content = "尝试加载游戏MOD".Translate()));
 
-            //MOD报错
-            foreach (CoreMOD cm in CoreMODs)
-                if (!cm.SuccessLoad)
-                    if (Set.IsPassMOD(cm.Name))
-                        MessageBoxX.Show("模组 {0} 的代码插件损坏\n虚拟桌宠模拟器未能成功加载该插件\n请联系作者修复该问题".Translate(cm.Name), "{0} 未加载代码插件".Translate(cm.Name));
-                    else if (Set.IsMSGMOD(cm.Name))
-                        MessageBoxX.Show("由于 {0} 包含代码插件\n虚拟桌宠模拟器已自动停止加载该插件\n请手动前往设置允许启用该mod 代码插件".Translate(cm.Name), "{0} 未加载代码插件".Translate(cm.Name));
-
             //加载游戏内容
             Core.Controller = new MWController(this);
             if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\Save.lps"))
@@ -439,7 +431,14 @@ namespace VPet_Simulator.Windows
                     "现已支持数据计算,桌宠现在需要进行吃饭喝水等\n更新了新的状态动画文件\n新增自动备份存档功能\n数据计算数据相关优化", ToolTipIcon.Info);
                     Set["SingleTips"].SetDateTime("update", DateTime.Now);
                 }
-                Save();
+                //MOD报错
+                foreach (CoreMOD cm in CoreMODs)
+                    if (!cm.SuccessLoad)
+                        if (Set.IsPassMOD(cm.Name))
+                            MessageBoxX.Show("模组 {0} 的代码插件损坏\n虚拟桌宠模拟器未能成功加载该插件\n请联系作者修复该问题".Translate(cm.Name), "{0} 未加载代码插件".Translate(cm.Name));
+                        else if (Set.IsMSGMOD(cm.Name))
+                            MessageBoxX.Show("由于 {0} 包含代码插件\n虚拟桌宠模拟器已自动停止加载该插件\n请手动前往设置允许启用该mod 代码插件".Translate(cm.Name), "{0} 未加载代码插件".Translate(cm.Name));
+
             }));
 
 
@@ -453,7 +452,6 @@ namespace VPet_Simulator.Windows
 
         private void Window_Closed(object sender, EventArgs e)
         {
-            Save();
             try
             {
                 //关闭所有插件
@@ -461,7 +459,16 @@ namespace VPet_Simulator.Windows
                     mp.EndGame();
             }
             catch { }
+            Save();
+            if (winSetting != null)
+            {
+                winSetting.Shutdown = true;
+                winSetting.Close();
+            }
+            petHelper?.Close();
+
             Main?.Dispose();
+            notifyIcon.Visible = false;
             notifyIcon?.Dispose();
             System.Environment.Exit(0);
         }
diff --git a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs
index 271cb81..2f78802 100644
--- a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs
+++ b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs
@@ -511,9 +511,11 @@ namespace VPet_Simulator.Windows
         {
             Process.Start("https://www.exlb.net/Diagnosis");
         }
-
+        public bool Shutdown = false;
         private void WindowX_Closing(object sender, System.ComponentModel.CancelEventArgs e)
         {
+            if (Shutdown)
+                return;
             mw.Topmost = mw.Set.TopMost;
             e.Cancel = true;
             Hide();