mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
启动时错误提示
This commit is contained in:
parent
b6bb099baf
commit
d9d4151045
@ -64,64 +64,75 @@ namespace VPet_Simulator.Windows
|
||||
{
|
||||
IsSteamUser = false;
|
||||
}
|
||||
|
||||
//加载游戏设置
|
||||
if (new FileInfo(AppDomain.CurrentDomain.BaseDirectory + @"\Setting.lps").Exists)
|
||||
try
|
||||
{
|
||||
Set = new Setting(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + @"\Setting.lps"));
|
||||
}
|
||||
else
|
||||
Set = new Setting("Setting#VPET:|\n");
|
||||
|
||||
var visualTree = new FrameworkElementFactory(typeof(Border));
|
||||
visualTree.SetValue(Border.BackgroundProperty, new TemplateBindingExtension(Window.BackgroundProperty));
|
||||
var childVisualTree = new FrameworkElementFactory(typeof(ContentPresenter));
|
||||
childVisualTree.SetValue(UIElement.ClipToBoundsProperty, true);
|
||||
visualTree.AppendChild(childVisualTree);
|
||||
|
||||
Template = new ControlTemplate
|
||||
{
|
||||
TargetType = typeof(Window),
|
||||
VisualTree = visualTree,
|
||||
};
|
||||
|
||||
_dwmEnabled = Win32.Dwmapi.DwmIsCompositionEnabled();
|
||||
_hwnd = new WindowInteropHelper(this).EnsureHandle();
|
||||
|
||||
if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\ChatGPTSetting.json"))
|
||||
CGPTClient = ChatGPTClient.Load(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + @"\ChatGPTSetting.json"));
|
||||
//this.Width = 400 * ZoomSlider.Value;
|
||||
//this.Height = 450 * ZoomSlider.Value;
|
||||
InitializeComponent();
|
||||
|
||||
//this.Height = 500 * Set.ZoomLevel;
|
||||
this.Width = 500 * Set.ZoomLevel;
|
||||
|
||||
if (Set.StartRecordLast)
|
||||
{
|
||||
var point = Set.StartRecordLastPoint;
|
||||
if (point.X != 0 || point.Y != 0)
|
||||
//加载游戏设置
|
||||
if (new FileInfo(AppDomain.CurrentDomain.BaseDirectory + @"\Setting.lps").Exists)
|
||||
{
|
||||
this.Left = point.X;
|
||||
this.Top = point.Y;
|
||||
Set = new Setting(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + @"\Setting.lps"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var point = Set.StartRecordPoint;
|
||||
Left = point.X; Top = point.Y;
|
||||
}
|
||||
else
|
||||
Set = new Setting("Setting#VPET:|\n");
|
||||
|
||||
//不存在就关掉
|
||||
var modpath = new DirectoryInfo(ModPath + @"\0000_core\pet\vup");
|
||||
if (!modpath.Exists)
|
||||
{
|
||||
MessageBox.Show("缺少模组Core,无法启动桌宠".Translate(), "启动错误".Translate(), MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Close();
|
||||
return;
|
||||
var visualTree = new FrameworkElementFactory(typeof(Border));
|
||||
visualTree.SetValue(Border.BackgroundProperty, new TemplateBindingExtension(Window.BackgroundProperty));
|
||||
var childVisualTree = new FrameworkElementFactory(typeof(ContentPresenter));
|
||||
childVisualTree.SetValue(UIElement.ClipToBoundsProperty, true);
|
||||
visualTree.AppendChild(childVisualTree);
|
||||
|
||||
Template = new ControlTemplate
|
||||
{
|
||||
TargetType = typeof(Window),
|
||||
VisualTree = visualTree,
|
||||
};
|
||||
|
||||
_dwmEnabled = Win32.Dwmapi.DwmIsCompositionEnabled();
|
||||
_hwnd = new WindowInteropHelper(this).EnsureHandle();
|
||||
|
||||
if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\ChatGPTSetting.json"))
|
||||
CGPTClient = ChatGPTClient.Load(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + @"\ChatGPTSetting.json"));
|
||||
//this.Width = 400 * ZoomSlider.Value;
|
||||
//this.Height = 450 * ZoomSlider.Value;
|
||||
InitializeComponent();
|
||||
|
||||
//this.Height = 500 * Set.ZoomLevel;
|
||||
this.Width = 500 * Set.ZoomLevel;
|
||||
|
||||
if (Set.StartRecordLast)
|
||||
{
|
||||
var point = Set.StartRecordLastPoint;
|
||||
if (point.X != 0 || point.Y != 0)
|
||||
{
|
||||
this.Left = point.X;
|
||||
this.Top = point.Y;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var point = Set.StartRecordPoint;
|
||||
Left = point.X; Top = point.Y;
|
||||
}
|
||||
|
||||
//不存在就关掉
|
||||
var modpath = new DirectoryInfo(ModPath + @"\0000_core\pet\vup");
|
||||
if (!modpath.Exists)
|
||||
{
|
||||
MessageBox.Show("缺少模组Core,无法启动桌宠".Translate(), "启动错误".Translate(), MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Environment.Exit(0);
|
||||
return;
|
||||
}
|
||||
Closed += ForceClose;
|
||||
Task.Run(GameLoad);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
string errstr = "游戏发生错误,可能是".Translate() + (string.IsNullOrWhiteSpace(CoreMOD.NowLoading) ?
|
||||
"游戏或者MOD".Translate() : $"MOD({CoreMOD.NowLoading})") +
|
||||
"导致的\n如有可能请发送 错误信息截图和引发错误之前的操作 给开发者:service@exlb.net\n感谢您对游戏开发的支持\n".Translate()
|
||||
+ e.ToString();
|
||||
MessageBox.Show(errstr, "游戏致命性错误".Translate() + ' ' + "启动错误".Translate(), MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
Closed += ForceClose;
|
||||
Task.Run(GameLoad);
|
||||
}
|
||||
public new void Close()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user