diff --git a/TslGameLauncher/AssemblyInfo.cs b/TslGameLauncher/AssemblyInfo.cs new file mode 100644 index 0000000..372e037 --- /dev/null +++ b/TslGameLauncher/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/TslGameLauncher/MainWindow.xaml b/TslGameLauncher/MainWindow.xaml new file mode 100644 index 0000000..0dd62f4 --- /dev/null +++ b/TslGameLauncher/MainWindow.xaml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/TslGameLauncher/MainWindow.xaml.cs b/TslGameLauncher/MainWindow.xaml.cs new file mode 100644 index 0000000..b0f8dfd --- /dev/null +++ b/TslGameLauncher/MainWindow.xaml.cs @@ -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); + } + } +} \ No newline at end of file diff --git a/TslGameLauncher/TslLauncher.csproj b/TslGameLauncher/TslLauncher.csproj new file mode 100644 index 0000000..95e962f --- /dev/null +++ b/TslGameLauncher/TslLauncher.csproj @@ -0,0 +1,27 @@ + + + + WinExe + net8.0-windows + enable + enable + true + Resource\Image\icon.ico + + + + + + + + + + + + + + + + + + diff --git a/TslGameLauncher/TslLauncher.csproj.user b/TslGameLauncher/TslLauncher.csproj.user new file mode 100644 index 0000000..c33b103 --- /dev/null +++ b/TslGameLauncher/TslLauncher.csproj.user @@ -0,0 +1,6 @@ + + + + <_LastSelectedProfileId>C:\Users\WMR-821\source\repos\TslGameLauncher\TslGameLauncher\Properties\PublishProfiles\FolderProfile.pubxml + + \ No newline at end of file