添加项目文件。

This commit is contained in:
WMR-821 2025-03-20 21:51:32 +08:00
parent 276d1496ed
commit 0102e771c5
18 changed files with 600 additions and 0 deletions

Binary file not shown.

Binary file not shown.

34
ServerLauncher.sln Normal file
View file

@ -0,0 +1,34 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35707.178 d17.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerLauncher", "ServerLauncher\ServerLauncher.csproj", "{D8519CE3-2A8B-4B58-A689-EA3B7CB8DA9B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D8519CE3-2A8B-4B58-A689-EA3B7CB8DA9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D8519CE3-2A8B-4B58-A689-EA3B7CB8DA9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D8519CE3-2A8B-4B58-A689-EA3B7CB8DA9B}.Debug|x64.ActiveCfg = Release|x64
{D8519CE3-2A8B-4B58-A689-EA3B7CB8DA9B}.Debug|x64.Build.0 = Release|x64
{D8519CE3-2A8B-4B58-A689-EA3B7CB8DA9B}.Debug|x86.ActiveCfg = Debug|x86
{D8519CE3-2A8B-4B58-A689-EA3B7CB8DA9B}.Debug|x86.Build.0 = Debug|x86
{D8519CE3-2A8B-4B58-A689-EA3B7CB8DA9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D8519CE3-2A8B-4B58-A689-EA3B7CB8DA9B}.Release|Any CPU.Build.0 = Release|Any CPU
{D8519CE3-2A8B-4B58-A689-EA3B7CB8DA9B}.Release|x64.ActiveCfg = Release|x64
{D8519CE3-2A8B-4B58-A689-EA3B7CB8DA9B}.Release|x64.Build.0 = Release|x64
{D8519CE3-2A8B-4B58-A689-EA3B7CB8DA9B}.Release|x86.ActiveCfg = Release|x86
{D8519CE3-2A8B-4B58-A689-EA3B7CB8DA9B}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,56 @@
<Window x:Class="ServerLauncher.Window2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ServerLauncher"
mc:Ignorable="d"
Title="TslGame Server Launcher - About US"
Icon="pack://application:,,,/Resource/Image/MWIcon.ico"
Height="450"
Width="800"
WindowStartupLocation="CenterScreen"
ResizeMode="NoResize">
<!-- <Window.Background>
<ImageBrush ImageSource="pack://application:,,,/Resource/Image/TslGameServerBack1.jpg"/>
</Window.Background> -->
<Grid Margin="10,10,10,-5">
<TextBlock
Foreground="Black"
HorizontalAlignment="Center"
FontSize="20"
FontFamily="Alimama FangYuanTi VF SemiBold"
Margin="0,10,0,359"><Run Text="S"/><Run Text="ocial "/><Run Language="zh-cn" Text="M"/><Run Text="edia"/></TextBlock>
<TextBlock
Foreground="Black"
HorizontalAlignment="Center"
FontSize="14"
FontFamily="Alimama FangYuanTi VF SemiBold"
Margin="0,34,0,289"><Run Text="Don't be deceived! This project and other related contents are completely open source"/><Run Language="zh-cn" Text="."/></TextBlock>
<Image Margin="392,-680,360,-458" Source="/Resource/Image/Line1.png" Stretch="Fill" RenderTransformOrigin="2.111,0.505">
<Image.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="90.021"/>
<TranslateTransform/>
</TransformGroup>
</Image.RenderTransform>
</Image>
<TextBlock
Foreground="Black"
FontSize="14"
FontFamily="Alimama FangYuanTi VF SemiBold"
Margin="209,369,0,-350" Width="388" ScrollViewer.HorizontalScrollBarVisibility="Visible" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left">
<TextBlock.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform AngleX="0"/>
<RotateTransform/>
<TranslateTransform X="0"/>
</TransformGroup>
</TextBlock.RenderTransform><Run Text="Copyright © 2025 "/><Run Text=" DEV"/><Run Text="Land "/><Run Text="Please do not sell!"/></TextBlock>
<Button Content="Join Discord" FontFamily="Alimama FangYuanTi VF SemiBold" Background="Yellow" Padding="9,0" HorizontalAlignment="Center" Click="Button_JoinDC_Click" RenderTransformOrigin="0.368,0.386" Width="136" VerticalAlignment="Top" Height="27" Margin="0,164,0,0"/>
<Button Content="Join QQ Group" FontFamily="Alimama FangYuanTi VF SemiBold" Padding="9,0" HorizontalAlignment="Center" Click="Button_JoinQQ_Click" RenderTransformOrigin="0.368,0.386" Width="136" Background="Yellow" VerticalAlignment="Top" Height="27" Margin="0,215,0,0"/>
</Grid>
</Window>

View file

@ -0,0 +1,56 @@
using System.Diagnostics;
using System.Windows;
namespace ServerLauncher
{
/// <summary>
/// Window2.xaml 的交互逻辑
/// </summary>
public partial class Window2 : Window
{
public Window2()
{
InitializeComponent();
}
//加入 Discord 按钮
private void Button_JoinDC_Click(object sender, RoutedEventArgs e)
{
string url = "https://discord.gg/yrcaukyEcw";
try
{
// 使用默认浏览器打开链接
Process.Start(new ProcessStartInfo
{
FileName = url,
UseShellExecute = true
});
}
catch (System.ComponentModel.Win32Exception ex)
{
// 如果系统中没有默认浏览器,会抛出异常
MessageBox.Show($"An error was encountered while opening the link: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
//加入 QQ 群 按钮
private void Button_JoinQQ_Click(object sender, RoutedEventArgs e)
{
string url = "https://qm.qq.com/q/q8dzw0E8Xm";
try
{
// 使用默认浏览器打开链接
Process.Start(new ProcessStartInfo
{
FileName = url,
UseShellExecute = true
});
}
catch (System.ComponentModel.Win32Exception ex)
{
// 如果系统中没有默认浏览器,会抛出异常
MessageBox.Show($"An error was encountered while opening the link: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
}
}

9
ServerLauncher/App.xaml Normal file
View file

@ -0,0 +1,9 @@
<Application x:Class="ServerLauncher.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ServerLauncher"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

View file

@ -0,0 +1,14 @@
using System.Configuration;
using System.Data;
using System.Windows;
namespace ServerLauncher
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

View file

@ -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)
)]

BIN
ServerLauncher/MWIcon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View file

@ -0,0 +1,68 @@
<Window x:Class="ServerLauncher.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ServerLauncher"
mc:Ignorable="d"
Title="TslGame Server Launcher"
Icon="pack://application:,,,/Resource/Image/MWIcon.ico"
Height="450"
Width="800"
WindowStartupLocation="CenterScreen"
ResizeMode="NoResize">
<Window.Background>
<ImageBrush ImageSource="pack://application:,,,/Resource/Image/TslGameServerBack1.jpg"/>
</Window.Background>
<Grid Margin="10,10,0,-5">
<!-- 定义行和列 -->
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="45.96"/>
<RowDefinition Height="104.44"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<!-- 添加一个额外的行用于状态显示 -->
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<!-- 添加一列用于状态文字 -->
</Grid.ColumnDefinitions>
<!-- 按钮 -->
<Button Content="Start Server" FontFamily="Alimama FangYuanTi VF SemiBold" Background="Yellow" Padding="9,4" HorizontalAlignment="Center" Grid.Row="0" Margin="0,5,0,5" Click="Button_StartTSLServer_Click"/>
<Button Content="End Server" FontFamily="Alimama FangYuanTi VF SemiBold" Background="Yellow" Padding="9,4" HorizontalAlignment="Center" Grid.Row="1" Margin="0,1,0,9" Click="Button_KillTSLServer_Click"/>
<Button Content="Start Game" FontFamily="Alimama FangYuanTi VF SemiBold" Background="Yellow" Padding="9,4" HorizontalAlignment="Center" Grid.Row="2" Margin="0,23,0,103" Click="Button_Start_TslGame" Grid.RowSpan="2"/>
<Button Content="Exit" FontFamily="Alimama FangYuanTi VF SemiBold" Background="Yellow" Padding="9,0" HorizontalAlignment="Center" Grid.Row="3" Margin="0,6,0,71" Click="Button_Exit_Click" RenderTransformOrigin="0.368,0.386"/>
<!-- 状态文字 -->
<TextBlock x:Name="StatusText"
Text="Not running"
FontSize="20"
FontFamily="Alimama FangYuanTi VF SemiBold"
Foreground="Red"
Margin="178,23,-178,21"
Grid.Column="1" Grid.RowSpan="2"/>
<TextBlock Text="Server Status"
Foreground="White"
HorizontalAlignment="Left"
FontSize="20"
FontFamily="Alimama FangYuanTi VF SemiBold"
Margin="20,23,0,21" Grid.Column="1" Grid.RowSpan="2"/>
<Button Content="About US" FontFamily="Alimama FangYuanTi VF SemiBold" Background="Yellow" Padding="9,0" HorizontalAlignment="Center" Grid.Row="3" Margin="0,65,0,12" Click="Button_OpenNewWindow_Click" RenderTransformOrigin="0.368,0.386"/>
<TextBlock
Foreground="White"
FontSize="14"
FontFamily="Alimama FangYuanTi VF SemiBold"
Margin="120,164,0,0" Width="367" ScrollViewer.HorizontalScrollBarVisibility="Visible" Grid.Row="5" RenderTransformOrigin="0.5,0.5" VerticalAlignment="Top" HorizontalAlignment="Left" Height="17" Grid.Column="1" Background="Black">
<TextBlock.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform AngleX="0"/>
<RotateTransform/>
<TranslateTransform X="0"/>
</TransformGroup>
</TextBlock.RenderTransform><Run Text="Copyright © 2025 "/><Run Text=" DEV"/><Run Text="Land "/><Run Language="zh-cn" Text="Please do not sell!"/></TextBlock>
</Grid>
</Window>

View file

@ -0,0 +1,206 @@
using System.Diagnostics;
using System.Windows;
using System.Windows.Media;
using System.Windows.Threading;
namespace ServerLauncher
{
public partial class MainWindow : Window
{
private DispatcherTimer timer;
public MainWindow()
{
InitializeComponent();
// 初始化定时器
timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(5); // 每 5 秒检测一次
timer.Tick += Timer_Tick;
timer.Start();
// 初始检测
CheckTslGameProcess();
}
//启动服务器进程
private static void StartTSLServer()
{
try
{
Process.Start(new ProcessStartInfo
{
FileName = "TslGame.exe",
Arguments = "/Game/Maps/Erangel/Erangel_Main?listen?game=/Game/Blueprints/TSLGameMode.TSLGameMode_C -nullrhi -nosound -AllowJoinAnyMatchState -Server -port=8888 -NoVerifyGC -NoEAC -NoBattleEye",
UseShellExecute = true,
});
}
catch (Exception ex)
{
MessageBox.Show($"An error was encountered while starting TslGame Server{ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
//结束服务器进程
private static void KillTSLProcess()
{
try
{
// 获取所有名为 "TslGame" 的进程
Process[] processes = Process.GetProcessesByName("TslGame");
if (processes.Length > 0)
{
foreach (var process in processes)
{
process.Kill(); // 强制结束进程
process.WaitForExit(); // 等待进程完全退出
}
MessageBox.Show("TslGame Server was successfully closed.", "Message", MessageBoxButton.OK, MessageBoxImage.Information);
}
else
{
MessageBox.Show("TslGame Server Not running", "Message", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
catch (Exception ex)
{
MessageBox.Show($"Failed to end process TslGame Server: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
//启动游戏进程
private static void StartTSLGame()
{
try
{
Process.Start(new ProcessStartInfo
{
FileName = "TslGame.exe",
Arguments = "127.0.0.1:8888 -NoVerifyGC -NoEAC -NoBattleEye",
UseShellExecute = true,
});
}
catch (Exception ex)
{
MessageBox.Show($"An error was encountered while starting TslGame{ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
//监测 TslGame Server 是否正在运行(自动逻辑)
private void Timer_Tick(object sender, EventArgs e)
{
// 定时检测进程状态
CheckTslGameProcess();
}
private void CheckTslGameProcess()
{
// 获取所有名为 "TslGame" 的进程
Process[] processes = Process.GetProcessesByName("TslGame");
if (processes.Length > 0)
{
// 如果进程存在,更新界面为“运行”
StatusText.Text = "Running";
StatusText.Foreground = new SolidColorBrush(Colors.Green);
}
else
{
// 如果进程不存在,更新界面为“未运行”
StatusText.Text = "Not running";
StatusText.Foreground = new SolidColorBrush(Colors.Red);
}
}
//界面上的按钮事件
//启动 TslGame 服务器
private async void Button_StartTSLServer_Click(object sender, RoutedEventArgs e)
{
try
{
// 启动TslGame.exe
MessageBoxResult result = MessageBox.Show(
"Are you sure",
"Message",
MessageBoxButton.YesNo,
MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
await Task.Delay(3000);
StartTSLServer();
}
}
catch (Exception ex)
{
MessageBox.Show($"An error was encountered while starting TslGame Server: {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
//结束 TslGame 服务器
private void Button_KillTSLServer_Click(object sender, RoutedEventArgs e)
{
try
{
MessageBoxResult result = MessageBox.Show(
"Are you sure",
"Message",
MessageBoxButton.YesNo,
MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
KillTSLProcess();
}
}
catch (Exception ex)
{
MessageBox.Show($"Failed to end process TslGame Server: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
//启动 TslGame
private void Button_Start_TslGame(object sender, RoutedEventArgs e)
{
try
{
MessageBoxResult result = MessageBox.Show(
"Are you sure",
"Message",
MessageBoxButton.YesNo,
MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
StartTSLGame();
}
}
catch (Exception ex)
{
MessageBox.Show($"An error was encountered while starting TslGame {ex.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
//退出应用
private void Button_Exit_Click(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
//关于我们
private void Button_OpenNewWindow_Click(object sender, RoutedEventArgs e)
{
// 创建新窗口的实例
Window2 newWindow = new Window2();
// 显示新窗口
newWindow.Show();
}
}
}

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 821 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 KiB

View file

@ -0,0 +1,75 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
<Platforms>AnyCPU;x64;x86</Platforms>
<UseWindowsForms>False</UseWindowsForms>
<ApplicationIcon>MWIcon.ico</ApplicationIcon>
<NuGetAudit>False</NuGetAudit>
<StartupObject></StartupObject>
<PlatformTarget>x86</PlatformTarget>
<Title>TslGame 服务器启动器</Title>
<Authors>在下王某人</Authors>
<NeutralLanguage>zh-CN</NeutralLanguage>
<Description>服务器启动器。</Description>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
<SignAssembly>False</SignAssembly>
<DelaySign>False</DelaySign>
<ErrorReport>none</ErrorReport>
<Copyright>Copyright © 2025 在下王某人 版权所有.</Copyright>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>none</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<DebugType>none</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
<DebugType>none</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>none</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<DebugType>none</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
<DebugType>none</DebugType>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Window1.xaml.cs" />
</ItemGroup>
<ItemGroup>
<None Remove="Resource\Fonts\Alimama FYT VF.ttf" />
<None Remove="Resource\Image\Line1.png" />
<None Remove="Resource\Image\MWIcon.ico" />
</ItemGroup>
<ItemGroup>
<Page Remove="Window1.xaml" />
</ItemGroup>
<ItemGroup>
<Content Include="MWIcon.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resource\Fonts\Alimama FYT VF.ttf" />
<Resource Include="Resource\Image\Line1.png" />
<Resource Include="Resource\Image\TslGameServerBack1.jpg" />
<Resource Include="Resource\Image\MWIcon.ico" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,21 @@
<Window x:Class="ServerLauncher.NewWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ServerLauncher"
mc:Ignorable="d"
Title="Window1" Height="450" Width="800">
<Grid Margin="10">
<!-- 状态显示 -->
<TextBlock Text="服务器状态:" Foreground="Black" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="20" Margin="0,0,10,0"/>
<TextBlock x:Name="StatusText"
Text="未运行"
HorizontalAlignment="Right"
VerticalAlignment="Center"
FontSize="20"
FontWeight="Bold"
Foreground="Red"
Margin="0,0,590,0"/>
</Grid>
</Window>

View file

@ -0,0 +1,51 @@
using System.Diagnostics;
using System.Windows;
using System.Windows.Media;
using System.Windows.Threading;
namespace ServerLauncher
{
public partial class NewWindow : Window
{
private DispatcherTimer timer;
public NewWindow()
{
InitializeComponent();
// 初始化定时器
timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(5); // 每 5 秒检测一次
timer.Tick += Timer_Tick;
timer.Start();
// 初始检测
CheckTslGameProcess();
}
private void Timer_Tick(object sender, EventArgs e)
{
// 定时检测进程状态
CheckTslGameProcess();
}
private void CheckTslGameProcess()
{
// 获取所有名为 "TslGame" 的进程
Process[] processes = Process.GetProcessesByName("TslGame");
if (processes.Length > 0)
{
// 如果进程存在,更新界面为“运行”,并设置为绿色
StatusText.Text = "运行";
StatusText.Foreground = new SolidColorBrush(Colors.Green);
}
else
{
// 如果进程不存在,更新界面为“未运行”,并设置为红色
StatusText.Text = "未运行";
StatusText.Foreground = new SolidColorBrush(Colors.Red);
}
}
}
}