上传文件至 TslGameLauncher
This commit is contained in:
parent
9ea64886a7
commit
c6b76dcc4f
5 changed files with 130 additions and 0 deletions
70
TslGameLauncher/MainWindow.xaml.cs
Normal file
70
TslGameLauncher/MainWindow.xaml.cs
Normal file
|
@ -0,0 +1,70 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace TslLauncher
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private const string TargetDirectory = @"TslGame\Binaries\Win64";
|
||||
private const string TargetExecutable = "TslGame.exe";
|
||||
private const string Arguments = "-LobbyUrl=https://lobby.ogbattlegrounds.com/ -NoVerifyGC -NoEAC -NoBattleEye";
|
||||
|
||||
private DispatcherTimer _timer;
|
||||
private int _dotCount = 0;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
Loaded += MainWindow_Loaded;
|
||||
InitializeStatusTextAnimation();
|
||||
}
|
||||
|
||||
private async void MainWindow_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await Task.Delay(5000);
|
||||
LaunchGame();
|
||||
}
|
||||
|
||||
private void LaunchGame()
|
||||
{
|
||||
string targetPath = Path.Combine(Environment.CurrentDirectory, TargetDirectory, TargetExecutable);
|
||||
|
||||
if (File.Exists(targetPath))
|
||||
{
|
||||
ProcessStartInfo startInfo = new ProcessStartInfo(targetPath)
|
||||
{
|
||||
Arguments = Arguments,
|
||||
UseShellExecute = false
|
||||
};
|
||||
|
||||
Process.Start(startInfo);
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(this,"游戏文件不完整,请尝试重新下载!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeStatusTextAnimation()
|
||||
{
|
||||
_timer = new DispatcherTimer
|
||||
{
|
||||
Interval = TimeSpan.FromMilliseconds(500)
|
||||
};
|
||||
_timer.Tick += Timer_Tick;
|
||||
_timer.Start();
|
||||
}
|
||||
|
||||
private void Timer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
_dotCount = (_dotCount + 1) % 5;
|
||||
StatusText.Text = "游戏启动中" + new string('.', _dotCount);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue