From 3c30895d4dc179f8fe08f4a3a97331b76634d19c Mon Sep 17 00:00:00 2001 From: ZouJin Date: Fri, 11 Aug 2023 12:47:09 +1000 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E9=81=A5=E6=B5=8B=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VPet-Simulator.Core/Graph/GraphInfo.cs | 3 + VPet-Simulator.Windows.Interface/Setting.cs | 7 +- VPet-Simulator.Windows/MainWindow.cs | 87 +++++++++++++++++-- .../WinDesign/winGameSetting.xaml | 2 +- .../WinDesign/winGameSetting.xaml.cs | 23 ++++- .../WinDesign/winReport.xaml.cs | 6 +- 6 files changed, 109 insertions(+), 19 deletions(-) diff --git a/VPet-Simulator.Core/Graph/GraphInfo.cs b/VPet-Simulator.Core/Graph/GraphInfo.cs index e4f3db7..c68c741 100644 --- a/VPet-Simulator.Core/Graph/GraphInfo.cs +++ b/VPet-Simulator.Core/Graph/GraphInfo.cs @@ -109,6 +109,9 @@ namespace VPet_Simulator.Core else if (path_name.Remove("c") || path_name.Remove("end")) { animatType = AnimatType.C_End; + }else if (path_name.Remove("single")) + { + animatType = AnimatType.Single; } else { diff --git a/VPet-Simulator.Windows.Interface/Setting.cs b/VPet-Simulator.Windows.Interface/Setting.cs index a2dd345..0149722 100644 --- a/VPet-Simulator.Windows.Interface/Setting.cs +++ b/VPet-Simulator.Windows.Interface/Setting.cs @@ -97,12 +97,12 @@ namespace VPet_Simulator.Windows.Interface set => SetBool("bigscreen", value); } /// - /// 是否启用数据收集 //TODO:判断游戏是否是原版的 + /// 是否启用数据收集 /// public bool Diagnosis { - get => !this["diagnosis"].GetBool("disable"); - set => this["diagnosis"].SetBool("disable", !value); + get => this["diagnosis"].GetBool("enable"); + set => this["diagnosis"].SetBool("enable", value); } ///// //经过测试,储存到内存好处多多,不储存也要占用很多内存,干脆存了吧 ///// 是将图片储存到内存 @@ -128,6 +128,7 @@ namespace VPet_Simulator.Windows.Interface get => Math.Max(this["diagnosis"].GetInt("interval", 500), 20000); set => this["diagnosis"].SetInt("interval", value); } + /// /// 自动保存频率 (min) /// diff --git a/VPet-Simulator.Windows/MainWindow.cs b/VPet-Simulator.Windows/MainWindow.cs index deef4a7..abd7c02 100644 --- a/VPet-Simulator.Windows/MainWindow.cs +++ b/VPet-Simulator.Windows/MainWindow.cs @@ -6,9 +6,12 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; +using System.Net; +using System.Text; using System.Threading; using System.Threading.Tasks; using System.Timers; +using System.Web; using System.Windows; using VPet_Simulator.Core; using VPet_Simulator.Windows.Interface; @@ -413,7 +416,7 @@ namespace VPet_Simulator.Windows /// private void Handle_Music(Main obj) { - if (MusicTimer.Enabled == false && Core.Graph.FindGraphs("Music", AnimatType.A_Start, Core.Save.Mode) != null && + if (MusicTimer.Enabled == false && Core.Graph.FindGraphs("music", AnimatType.B_Loop, Core.Save.Mode) != null && Main.IsIdel && AudioPlayingVolume() > Set.MusicCatch) { catch_MusicVolSum = 0; @@ -426,7 +429,7 @@ namespace VPet_Simulator.Windows if (CurrMusicType != null && Main.IsIdel) {//识别通过,开始跑跳舞动画 - Main.Display(Core.Graph.FindGraph("Music", AnimatType.A_Start, Core.Save.Mode), Display_Music); + Main.Display(Core.Graph.FindGraph("music", AnimatType.A_Start, Core.Save.Mode), Display_Music); } else { //失败或有东西阻塞,停止检测 @@ -441,22 +444,24 @@ namespace VPet_Simulator.Windows { if (CurrMusicType.Value) {//播放更刺激的 - var mg = Core.Graph.FindGraph("Music", AnimatType.Single, Core.Save.Mode); - mg ??= Core.Graph.FindGraph("Music", AnimatType.B_Loop, Core.Save.Mode); + var mg = Core.Graph.FindGraph("music", AnimatType.Single, Core.Save.Mode); + mg ??= Core.Graph.FindGraph("music", AnimatType.B_Loop, Core.Save.Mode); Main.Display(mg, Display_Music); } else { - Main.Display(Core.Graph.FindGraph("Music", AnimatType.B_Loop, Core.Save.Mode), Display_Music); + Main.Display(Core.Graph.FindGraph("music", AnimatType.B_Loop, Core.Save.Mode), Display_Music); } } else { - Main.Display("Music", AnimatType.C_End); + Main.Display("music", AnimatType.C_End, Main.DisplayToNomal); } } private void MusicTimer_Elapsed(object sender, ElapsedEventArgs e) { + if (!(Main.IsIdel || Main.DisplayType.Name == "music"))//不是音乐,被掐断 + return; catch_MusicVolSum += AudioPlayingVolume(); catch_MusicVolCount++; if (catch_MusicVolCount >= 20) @@ -468,22 +473,86 @@ namespace VPet_Simulator.Windows { var bef = CurrMusicType; CurrMusicType = ans > Set.MusicMax; - if (bef != CurrMusicType) + if (bef != null && bef != CurrMusicType) Display_Music(); MusicTimer.Start(); } else { CurrMusicType = null; - if (Main.DisplayType.Name == "Music") - Main.Display("Music", AnimatType.C_End); + if (Main.DisplayType.Name == "music") + Main.Display("music", AnimatType.C_End, Main.DisplayToNomal); } } + else + { + MusicTimer.Start(); + } } public Timer MusicTimer; private double catch_MusicVolSum; private int catch_MusicVolCount; + /// + /// 当前音乐播放状态 + /// public bool? CurrMusicType { get; private set; } + + int LastDiagnosisTime = 0; + /// + /// 上传遥测文件 + /// + public void DiagnosisUPLoad() + { + if (!IsSteamUser) + return;//不遥测非Steam用户 + if (!Set.DiagnosisDayEnable) + return;//不遥测不参加遥测的用户 + if (!Set.Diagnosis) + return;//不遥测不参加遥测的用户 + if (!HashCheck) + return;//不遥测数据修改过的用户 + if (LastDiagnosisTime++ < Set.DiagnosisInterval) + return;//等待间隔 + LastDiagnosisTime = 0; + string _url = "http://cn.exlb.org:5810/Report"; + //参数 + StringBuilder sb = new StringBuilder(); + sb.Append("action=data"); + sb.Append($"&steamid={Steamworks.SteamClient.SteamId.Value}"); + sb.Append($"&ver={verison}"); + sb.Append("&save="); + sb.AppendLine(HttpUtility.UrlEncode(Core.Save.ToLine().ToString() + Set.ToString())); + //游戏设置比存档更重要,桌宠大部分内容存设置里了,所以一起上传 + var request = (HttpWebRequest)WebRequest.Create(_url); + request.Method = "POST"; + request.ContentType = "application/x-www-form-urlencoded";//ContentType + byte[] byteData = Encoding.UTF8.GetBytes(sb.ToString()); + int length = byteData.Length; + request.ContentLength = length; + using (Stream writer = request.GetRequestStream()) + { + writer.Write(byteData, 0, length); + writer.Close(); + writer.Dispose(); + } + string responseString; + using (var response = (HttpWebResponse)request.GetResponse()) + { + responseString = new StreamReader(response.GetResponseStream(), Encoding.UTF8).ReadToEnd(); + response.Dispose(); + } + if (responseString == "IP times Max") + { + Set.DiagnosisDayEnable = false; + } +#if DEBUG + else + { + throw new Exception("诊断上传失败"); + } +#endif + + } } } diff --git a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml index fcc8ccb..202aa32 100644 --- a/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml +++ b/VPet-Simulator.Windows/WinDesign/winGameSetting.xaml @@ -606,7 +606,7 @@ + Checked="RBDiagnosisYES_Checked" /> cbDiagnosis = new List { 200, 500, 1000, 2000, 5000, 10000, 20000 } + int ds = cbDiagnosis.IndexOf(mw.Set.DiagnosisInterval); + if (ds == -1) + ds = 1; + CBDiagnosis.SelectedIndex = ds; + foreach (ComboBoxItem v in CBAutoSave.Items) { if ((int)v.Tag == mw.Set.AutoSaveInterval) @@ -375,17 +385,24 @@ namespace VPet_Simulator.Windows private void RBDiagnosisYES_Checked(object sender, RoutedEventArgs e) { - + if (!AllowChange) + return; + mw.Set.Diagnosis = true; } private void RBDiagnosisNO_Checked(object sender, RoutedEventArgs e) { - + if (!AllowChange) + return; + mw.Set.Diagnosis = false; } private void CBDiagnosis_SelectionChanged(object sender, SelectionChangedEventArgs e) { - + if (!AllowChange) + return; + List cbDiagnosis = new List { 200, 500, 1000, 2000, 5000, 10000, 20000 }; + mw.Set.DiagnosisInterval = cbDiagnosis[CBDiagnosis.SelectedIndex]; } private void ListMod_SelectionChanged(object sender, SelectionChangedEventArgs e) diff --git a/VPet-Simulator.Windows/WinDesign/winReport.xaml.cs b/VPet-Simulator.Windows/WinDesign/winReport.xaml.cs index 5d3f625..d4cd4fa 100644 --- a/VPet-Simulator.Windows/WinDesign/winReport.xaml.cs +++ b/VPet-Simulator.Windows/WinDesign/winReport.xaml.cs @@ -22,7 +22,7 @@ namespace VPet_Simulator.Windows { InitializeComponent(); mw = mainw; - save = mw.Core.Save.ToLine().ToString(); + save = mw.Core.Save.ToLine().ToString() + mw.Set.ToString(); if (errmsg != null) { tType.SelectedIndex = 0; @@ -38,9 +38,9 @@ namespace VPet_Simulator.Windows } private void tUpload_Click(object sender, RoutedEventArgs e) - { + {//游戏设置比存档更重要,桌宠大部分内容存设置里了,所以一起上传 if (tUpload.IsChecked == true) - save = mw.Core.Save.ToLine().ToString(); + save = mw.Core.Save.ToLine().ToString() + mw.Set.ToString(); else save = "玩家取消上传存档".Translate(); }