支持反馈功能

This commit is contained in:
ZouJin 2023-01-24 15:55:02 +08:00
parent 67ed01399d
commit bf91728284
5 changed files with 196 additions and 6 deletions

View File

@ -28,8 +28,11 @@ namespace VPet_Simulator.Windows
MessageBox.Show(errstr, "游戏致命性错误");
return;
}
MainWindow mw = ((MainWindow)MainWindow);
else
{
new winReport(((MainWindow)MainWindow), errstr).Show();
return;
}
}
}
}

View File

@ -134,11 +134,12 @@ namespace VPet_Simulator.Windows
Main.DefaultClickAction = () => { Dispatcher.Invoke(() => { Main.Say("你知道吗? 鼠标右键可以打开菜单栏"); }); };
DisplayGrid.Child = Main;
Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Setting, "退出桌宠", () => { Close(); });
Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Setting, "反馈中心", () => { new winReport(this).Show(); });
Main.ToolBar.AddMenuButton(VPet_Simulator.Core.ToolBar.MenuType.Setting, "设置面板", () =>
{
Topmost = false;
winSetting.Show();
});
{
Topmost = false;
winSetting.Show();
});
Main.SetMoveMode(Set.AllowMove, Set.SmartMove, Set.SmartMoveInterval * 1000);
Main.SetLogicInterval((int)(Set.LogicInterval * 1000));
@ -157,6 +158,8 @@ namespace VPet_Simulator.Windows
Left = (SystemParameters.PrimaryScreenWidth - Width) / 2;
Top = (SystemParameters.PrimaryScreenHeight - Height) / 2;
}));
m_menu.MenuItems.Add(new MenuItem("反馈中心", (x, y) => { new winReport(this).Show(); }));
m_menu.MenuItems.Add(new MenuItem("设置面板", (x, y) =>
{
Topmost = false;

View File

@ -92,6 +92,7 @@
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
@ -120,6 +121,9 @@
<Compile Include="WinDesign\winGameSetting.xaml.cs">
<DependentUpon>winGameSetting.xaml</DependentUpon>
</Compile>
<Compile Include="WinDesign\winReport.xaml.cs">
<DependentUpon>winReport.xaml</DependentUpon>
</Compile>
<Page Include="Design\Theme\basestyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -145,6 +149,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="WinDesign\winReport.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup Condition="'$(Platform)' == 'x86'">
<Reference Include="Facepunch.Steamworks.Win32, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">

View File

@ -0,0 +1,45 @@
<pu:WindowX x:Class="VPet_Simulator.Windows.winReport" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:VPet_Simulator.Windows"
xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI"
xmlns:system="clr-namespace:System;assembly=mscorlib" mc:Ignorable="d" Title="反馈中心"
Style="{DynamicResource BaseWindowXStyle}" WindowStartupLocation="CenterScreen" Width="500" MinHeight="250"
Height="Auto" ResizeMode="NoResize" WindowState="Normal"
Icon="../vpeticon.ico">
<StackPanel x:Name="MainGrid" Margin="10,10,15,10" VerticalAlignment="Top" SizeChanged="MainGrid_SizeChanged">
<Label Background="{x:Null}" VerticalAlignment="Top" HorizontalAlignment="Left" Content="反馈与错误提交" FontSize="24"
Margin="10,0,0,0" />
<pu:FormGroup Header="类型:" HeaderPadding="10,0,10,0" HeaderHeight="20" Orientation="Horizontal" Margin="0,2,0,0"
Padding="1" FontSize="16" ToolTip="需要反馈的类型" HeaderWidth="Auto">
<ComboBox x:Name="tType" SelectedIndex="3">
<ComboBoxItem>游戏内报错</ComboBoxItem>
<ComboBoxItem>逻辑计算错误</ComboBoxItem>
<ComboBoxItem>数值设计不合理</ComboBoxItem>
<ComboBoxItem>玩法与功能建议</ComboBoxItem>
</ComboBox>
</pu:FormGroup>
<pu:FormGroup Header="描述:" HeaderPadding="10,0,10,0" HeaderHeight="20" Orientation="Horizontal" Margin="0,2,0,0"
Padding="1" FontSize="16" ToolTip="对于反馈的详细描述">
<TextBox x:Name="tDescription" pu:TextBoxHelper.Watermark="详细描述&#13;eg:如何触发这个报错" AcceptsReturn="True"
MaxHeight="172" />
</pu:FormGroup>
<pu:FormGroup Header="内容:" HeaderPadding="10,0,10,0" HeaderHeight="20" Orientation="Horizontal" Margin="0,2,0,0"
Padding="1" FontSize="16" ToolTip="详细内容信息">
<TextBox x:Name="tContent" pu:TextBoxHelper.Watermark="详细描述&#13;eg:如何触发这个报错" AcceptsReturn="True"
MaxHeight="172" HorizontalScrollBarVisibility="Auto" />
</pu:FormGroup>
<pu:FormGroup Header="提交:" HeaderPadding="10,0,10,0" HeaderHeight="20" Orientation="Horizontal" Margin="0,2,0,0"
Padding="1" FontSize="16" ToolTip="是否上传的确游戏存档">
<CheckBox x:Name="tUpload" Content="上传游戏存档" Margin="5,0,0,0" IsChecked="True" Click="tUpload_Click" />
</pu:FormGroup>
<pu:FormGroup Header="联系:" HeaderPadding="10,0,10,0" HeaderHeight="20" Orientation="Horizontal" Margin="0,2,0,0"
Padding="1" FontSize="16" ToolTip="提供联系方式以获得反馈,可不填">
<TextBox x:Name="tContact" pu:TextBoxHelper.Watermark="提供联系方式以获得反馈,可不填&#13;eg:QQ430081239"
AcceptsReturn="True" MaxHeight="44" />
</pu:FormGroup>
<Button Content="提交" Margin="10,10,0,10" FontSize="16" Background="{DynamicResource DARKPrimary}"
BorderThickness="1" pu:ButtonHelper.CornerRadius="5" BorderBrush="{DynamicResource DARKPrimaryDarker}"
Foreground="{DynamicResource DARKPrimaryText}" Padding="2" Click="btn_upload" />
</StackPanel>
</pu:WindowX>

View File

@ -0,0 +1,131 @@
using Panuon.WPF.UI;
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.IO;
using System.Linq;
using System.Net;
using System.Runtime.Remoting.Contexts;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using VPet_Simulator.Core;
using System.Web;
namespace VPet_Simulator.Windows
{
/// <summary>
/// winReport.xaml 的交互逻辑
/// </summary>
public partial class winReport : WindowX
{
MainWindow mw;
string save;
public bool IsUniformSizeChanged => false;
public bool StoreSize => false;
public winReport(MainWindow mainw, string errmsg = null)
{
InitializeComponent();
mw = mainw;
save = mw.Core.Save.ToLine().ToString();
if (errmsg != null)
{
tType.SelectedIndex = 0;
tContent.Text = errmsg;
tContent.IsEnabled = false;
tContent.Height = 44;
}
if (!mw.IsSteamUser)
{
IsEnabled = false;
MessageBoxX.Show("您不是Steam用户无法使用反馈中心\n欢迎加入虚拟主播模拟器群430081239反馈问题", "非Steam用户无法使用反馈中心", MessageBoxButton.OK, MessageBoxIcon.Info);
}
}
private void tUpload_Click(object sender, RoutedEventArgs e)
{
if (tUpload.IsChecked == true)
save = mw.Core.Save.ToLine().ToString();
else
save = "玩家取消上传存档";
}
private void btn_upload(object sender, RoutedEventArgs e)
{
if (tDescription.Text == "" && tType.SelectedIndex != 0)
{
MessageBoxX.Show("请填写问题描述", "问题详细描述是反馈具体问题\n例如如何触发这个报错,游戏有什么地方不合理等");
return;
}
if (!mw.IsSteamUser)
return;//不遥测非Steam用户
try
{
string _url = "http://cn.exlb.org:5810/VPET/Report";
//参数
StringBuilder sb = new StringBuilder();
sb.Append("action=error");
sb.Append("&type=" + HttpUtility.UrlEncode(tType.Text));
sb.Append("&description=" + HttpUtility.UrlEncode(tDescription.Text));
sb.Append("&content=" + HttpUtility.UrlEncode(tContent.Text));
sb.Append("&contact=" + HttpUtility.UrlEncode(tContact.Text));
sb.Append($"&steamid={Steamworks.SteamClient.SteamId.Value}");
sb.Append($"&ver={mw.verison}");
sb.Append("&save=");
sb.AppendLine(HttpUtility.UrlEncode(save));
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 == "Report Error Success")
{
MessageBoxX.Show("您的反馈已提交成功,感谢您的反馈与提交\nVOS将会尽快处理您的反馈并做的更好", "感谢您的反馈和提交");
Close();
}
else if (responseString == "IP times Max")
{
mw.Set.DiagnosisDayEnable = false;
MessageBoxX.Show( "您今天的反馈次数已达上限,请明天再来反馈.\n或欢迎加入虚拟主播模拟器群430081239反馈问题", "您今天的反馈次数已达上限", MessageBoxButton.OK, MessageBoxIcon.Error);
}
else
{
MessageBoxX.Show( "反馈上传失败\n欢迎加入虚拟主播模拟器群430081239手动反馈问题\n服务器消息:" + responseString, "反馈提交失败,遇到错误", MessageBoxButton.OK, MessageBoxIcon.Error);
}
}
catch (Exception exp)
{
MessageBoxX.Show( "反馈上传失败,可能是网络或其他问题导致无法上传\n欢迎加入虚拟主播模拟器群430081239手动反馈问题\n" + exp.ToString(), "反馈提交失败,遇到错误", MessageBoxButton.OK, MessageBoxIcon.Error);
}
}
private void MainGrid_SizeChanged(object sender, SizeChangedEventArgs e)
{
Height = MainGrid.ActualHeight + 50;
}
}
}