mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
支持遥测系统
This commit is contained in:
parent
487d4039d7
commit
3c30895d4d
@ -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
|
||||
{
|
||||
|
@ -97,12 +97,12 @@ namespace VPet_Simulator.Windows.Interface
|
||||
set => SetBool("bigscreen", value);
|
||||
}
|
||||
/// <summary>
|
||||
/// 是否启用数据收集 //TODO:判断游戏是否是原版的
|
||||
/// 是否启用数据收集
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
///// <summary> //经过测试,储存到内存好处多多,不储存也要占用很多内存,干脆存了吧
|
||||
///// 是将图片储存到内存
|
||||
@ -128,6 +128,7 @@ namespace VPet_Simulator.Windows.Interface
|
||||
get => Math.Max(this["diagnosis"].GetInt("interval", 500), 20000);
|
||||
set => this["diagnosis"].SetInt("interval", value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动保存频率 (min)
|
||||
/// </summary>
|
||||
|
@ -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
|
||||
/// </summary>
|
||||
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;
|
||||
/// <summary>
|
||||
/// 当前音乐播放状态
|
||||
/// </summary>
|
||||
public bool? CurrMusicType { get; private set; }
|
||||
|
||||
int LastDiagnosisTime = 0;
|
||||
/// <summary>
|
||||
/// 上传遥测文件
|
||||
/// </summary>
|
||||
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
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -606,7 +606,7 @@
|
||||
<RadioButton x:Name="RBDiagnosisYES" Style="{DynamicResource StandardRadioButtonStyle}"
|
||||
Content="{ll:Str '发送诊断数据: 发送游戏存档, 包括饱腹,状态等各种游戏内\ 数据. 可能会包括该游戏内存和CPU使用情况'}"
|
||||
HorizontalAlignment="Left" Margin="10,10,10,0" VerticalAlignment="Top" GroupName="diagnosis"
|
||||
Checked="RBDiagnosisYES_Checked" IsEnabled="False" />
|
||||
Checked="RBDiagnosisYES_Checked" />
|
||||
<RadioButton x:Name="RBDiagnosisNO" Style="{DynamicResource StandardRadioButtonStyle}"
|
||||
Content="{ll:Str '不发送诊断数据: 适用于启用修改器,修改过游戏数据等不\ 符合分析数据条件. 或不希望提供游戏数据的玩家'}"
|
||||
HorizontalAlignment="Left" Margin="10,10,10,0" VerticalAlignment="Top" GroupName="diagnosis"
|
||||
|
@ -12,6 +12,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
@ -105,6 +106,15 @@ namespace VPet_Simulator.Windows
|
||||
BtnStartUpGet.IsEnabled = true;
|
||||
}
|
||||
|
||||
if (mw.Set.Diagnosis)
|
||||
RBDiagnosisYES.IsChecked = true;
|
||||
|
||||
List<int> cbDiagnosis = new List<int> { 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<int> cbDiagnosis = new List<int> { 200, 500, 1000, 2000, 5000, 10000, 20000 };
|
||||
mw.Set.DiagnosisInterval = cbDiagnosis[CBDiagnosis.SelectedIndex];
|
||||
}
|
||||
|
||||
private void ListMod_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user