From 1a69c84f048529d05854b351a3640355f6383ab1 Mon Sep 17 00:00:00 2001 From: ZouJin Date: Tue, 4 Jul 2023 09:17:17 +1000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=80=E6=9C=89=E5=8F=8D?= =?UTF-8?q?=E9=A6=88=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet-Simulator.Core/VPet-Simulator.Core.csproj | 2 +- .../VPet-Simulator.Windows.Interface.csproj | 2 +- VPet-Simulator.Windows/Function/CoreMOD.cs | 2 +- VPet-Simulator.Windows/MainWindow.xaml.cs | 2 +- .../WinDesign/winCGPTSetting.xaml.cs | 4 +++- .../WinDesign/winConsole.xaml.cs | 16 ++++++++++++++-- .../WinDesign/winGameSetting.xaml.cs | 13 ++++++++++--- 7 files changed, 31 insertions(+), 10 deletions(-) diff --git a/VPet-Simulator.Core/VPet-Simulator.Core.csproj b/VPet-Simulator.Core/VPet-Simulator.Core.csproj index 1dba205..c42dcf0 100644 --- a/VPet-Simulator.Core/VPet-Simulator.Core.csproj +++ b/VPet-Simulator.Core/VPet-Simulator.Core.csproj @@ -25,7 +25,7 @@ 4 - full + portable true bin\Release\ TRACE diff --git a/VPet-Simulator.Windows.Interface/VPet-Simulator.Windows.Interface.csproj b/VPet-Simulator.Windows.Interface/VPet-Simulator.Windows.Interface.csproj index 36a2db3..4aab599 100644 --- a/VPet-Simulator.Windows.Interface/VPet-Simulator.Windows.Interface.csproj +++ b/VPet-Simulator.Windows.Interface/VPet-Simulator.Windows.Interface.csproj @@ -24,7 +24,7 @@ AnyCPU - full + portable true bin\Release\ TRACE diff --git a/VPet-Simulator.Windows/Function/CoreMOD.cs b/VPet-Simulator.Windows/Function/CoreMOD.cs index aaeacc2..cb229de 100644 --- a/VPet-Simulator.Windows/Function/CoreMOD.cs +++ b/VPet-Simulator.Windows/Function/CoreMOD.cs @@ -18,7 +18,7 @@ namespace VPet_Simulator.Windows { "ChatGPT.API.Framework.dll","Panuon.WPF.dll","steam_api.dll","Panuon.WPF.UI.dll","steam_api64.dll", "LinePutScript.dll","Newtonsoft.Json.dll","Facepunch.Steamworks.Win32.dll", "Facepunch.Steamworks.Win64.dll", - "VPet-Simulator.Core.dll","VPet-Simulator.Windows.Interface.dll" + "VPet-Simulator.Core.dll","VPet-Simulator.Windows.Interface.dll","LinePutScript.Localization.WPF.dll" }; public static string NowLoading = null; public string Name; diff --git a/VPet-Simulator.Windows/MainWindow.xaml.cs b/VPet-Simulator.Windows/MainWindow.xaml.cs index 6dcbde6..f0dd617 100644 --- a/VPet-Simulator.Windows/MainWindow.xaml.cs +++ b/VPet-Simulator.Windows/MainWindow.xaml.cs @@ -528,7 +528,7 @@ namespace VPet_Simulator.Windows } private void WindowX_LocationChanged(object sender, EventArgs e) { - petHelper.SetLocation(); + petHelper?.SetLocation(); } //public void DEBUGValue() //{ diff --git a/VPet-Simulator.Windows/WinDesign/winCGPTSetting.xaml.cs b/VPet-Simulator.Windows/WinDesign/winCGPTSetting.xaml.cs index 4f367d2..cbba08b 100644 --- a/VPet-Simulator.Windows/WinDesign/winCGPTSetting.xaml.cs +++ b/VPet-Simulator.Windows/WinDesign/winCGPTSetting.xaml.cs @@ -48,7 +48,9 @@ namespace VPet_Simulator.Windows mw.CGPTClient.Completions["vpet"].presence_penalty = 1; mw.CGPTClient.Completions["vpet"].max_tokens = Math.Min(Math.Max(int.Parse(tbMaxToken.Text), 10), 4000); mw.CGPTClient.Completions["vpet"].temperature = Math.Min(Math.Max(double.Parse(tbTemp.Text), 0.1), 2); - mw.CGPTClient.Completions["vpet"].messages.AddRange(JsonConvert.DeserializeObject>(tbHistory.Text)); + var l = JsonConvert.DeserializeObject>(tbHistory.Text); + if (l != null) + mw.CGPTClient.Completions["vpet"].messages.AddRange(l); mw.Save(); this.Close(); } diff --git a/VPet-Simulator.Windows/WinDesign/winConsole.xaml.cs b/VPet-Simulator.Windows/WinDesign/winConsole.xaml.cs index 3b5e022..196553a 100644 --- a/VPet-Simulator.Windows/WinDesign/winConsole.xaml.cs +++ b/VPet-Simulator.Windows/WinDesign/winConsole.xaml.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text; using System.Timers; using System.Windows; using System.Windows.Controls; @@ -73,7 +74,13 @@ namespace VPet_Simulator.Windows private void Say_Click(object sender, RoutedEventArgs e) { - mw.Main.Say(SayTextBox.Text, (Helper.SayType)Enum.Parse(typeof(Helper.SayType), CombSay.Text)); + if (Enum.TryParse(CombSay.Text, out var sayType)) + { + mw.Main.Say(SayTextBox.Text, sayType); + } + else + mw.Main.Say("暂无该说话方法".Translate() + CombSay.Text, Helper.SayType.Serious); + } Timer DestanceTimer = new Timer() { @@ -137,7 +144,12 @@ namespace VPet_Simulator.Windows private void Output_No_Local(object sender, RoutedEventArgs e) { - LocalTextBox.Text = string.Join("\n", LocalizeCore.StoreTranslationList); + StringBuilder sb = new StringBuilder(); + foreach (var v in LocalizeCore.StoreTranslationList) + { + sb.AppendLine(v.Replace("\n", @"\n").Replace("\r", @"\r")); + } + LocalTextBox.Text = sb.ToString(); } //private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) //{ diff --git a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs index 4fe87ba..271cb81 100644 --- a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs +++ b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml.cs @@ -379,7 +379,7 @@ namespace VPet_Simulator.Windows return; } mw.Set.OnModRemove(mod.Name); - ShowMod((string)((ListBoxItem)ListMod.SelectedItem).Content); + ShowMod(mod.Name); ButtonRestart.Visibility = System.Windows.Visibility.Visible; ShowModList(); } @@ -663,7 +663,14 @@ namespace VPet_Simulator.Windows shortcut.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory; shortcut.TargetPath = shortcutAddress; shortcut.IconLocation = AppDomain.CurrentDomain.BaseDirectory + @"vpeticon.ico"; - shortcut.Save(); + try + { + shortcut.Save(); + } + catch + { + MessageBox.Show("创建快捷方式失败,权限不足\n请以管理员身份运行后重试".Translate(), "权限不足".Translate()); + } } else { @@ -929,7 +936,7 @@ namespace VPet_Simulator.Windows { if (!AllowChange) return; - if(PetHelperBox.IsChecked == true) + if (PetHelperBox.IsChecked == true) { mw.Set.PetHelper = true; mw.LoadPetHelper();