mirror of
https://e.coding.net/circlecloud/CTZLauncher.git
synced 2024-11-22 02:08:49 +00:00
添加服务器数据类 客户端从服务器获取大区数据...
This commit is contained in:
parent
8ccf09c1dd
commit
b21b606132
@ -66,6 +66,11 @@ namespace KMCCC.Authentication
|
|||||||
return getResult(Address + ":" + Port + "/login?username=" + Username + "&password=" + Password);
|
return getResult(Address + ":" + Port + "/login?username=" + Username + "&password=" + Password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string getServerList()
|
||||||
|
{
|
||||||
|
return http.Send(HttpMethod.GET, Address + ":" + Port + "/serverlist");
|
||||||
|
}
|
||||||
|
|
||||||
public bool getResult(string url)
|
public bool getResult(string url)
|
||||||
{
|
{
|
||||||
return http.Send(HttpMethod.GET, url).Contains("true") ? true : false;
|
return http.Send(HttpMethod.GET, url).Contains("true") ? true : false;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<ProjectGuid>{EC25362D-5BA7-4CB3-BDA2-C575B9318086}</ProjectGuid>
|
<ProjectGuid>{EC25362D-5BA7-4CB3-BDA2-C575B9318086}</ProjectGuid>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>CTZLauncher</RootNamespace>
|
<RootNamespace>CTZLauncher</RootNamespace>
|
||||||
<AssemblyName>CTZLauncher</AssemblyName>
|
<AssemblyName>CTZLauncher</AssemblyName>
|
||||||
@ -94,6 +94,7 @@
|
|||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
|
<Compile Include="Modules\CTZServer\CTZServer.cs" />
|
||||||
<Compile Include="Tools\SystemTools.cs" />
|
<Compile Include="Tools\SystemTools.cs" />
|
||||||
<Compile Include="Tools\UsefulTools.cs" />
|
<Compile Include="Tools\UsefulTools.cs" />
|
||||||
<Compile Include="Tools\ZipTools.cs" />
|
<Compile Include="Tools\ZipTools.cs" />
|
||||||
@ -171,7 +172,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="image\" />
|
<Folder Include="image\" />
|
||||||
<Folder Include="Modules\CTZServer\" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
|
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
xmlns:s="clr-namespace:System;assembly=mscorlib"
|
xmlns:s="clr-namespace:System;assembly=mscorlib"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="CTZLauncher.MainWindow"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="CTZLauncher.MainWindow"
|
||||||
ResizeMode = "NoResize"
|
ResizeMode = "NoResize"
|
||||||
Title="MainWindow" Height="600" Width="800" Background="#FF3A3A3A" AllowsTransparency="True" WindowStyle="None" Visibility="Visible" HorizontalContentAlignment="Center" HorizontalAlignment="Center" Icon="ico.ico" VerticalAlignment="Center" VerticalContentAlignment="Center" WindowStartupLocation="CenterScreen" Initialized="Window_Initialized" FontFamily="Microsoft YaHei" Loaded="s">
|
Title="MainWindow" Height="600" Width="800" Background="#FF3A3A3A" AllowsTransparency="True" WindowStyle="None" Visibility="Visible" HorizontalContentAlignment="Center" HorizontalAlignment="Center" Icon="ico.ico" VerticalAlignment="Center" VerticalContentAlignment="Center" WindowStartupLocation="CenterScreen" Initialized="Window_Initialized" FontFamily="Microsoft YaHei">
|
||||||
|
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
<!-- s:Double表示了变量类型 x:key表示了变量名 -->
|
<!-- s:Double表示了变量类型 x:key表示了变量名 -->
|
||||||
@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<Grid Name="LoginWindow" Margin="20,60,20,20" Background="White">
|
<Grid Name="LoginWindow" Margin="20,60,20,20" Background="White">
|
||||||
<Grid Height="269" VerticalAlignment="Top">
|
<Grid Height="270" VerticalAlignment="Top">
|
||||||
<Grid Margin="20,20,0,0" HorizontalAlignment="Left" Width="400" >
|
<Grid Margin="20,20,0,0" HorizontalAlignment="Left" Width="400" >
|
||||||
<Image />
|
<Image />
|
||||||
</Grid>
|
</Grid>
|
||||||
@ -58,7 +58,7 @@
|
|||||||
<TextBox x:Name="username" Template="{StaticResource CornerTextBox}" Height="34" TextWrapping="Wrap" Text="" VerticalAlignment="Top" HorizontalContentAlignment="Center" FontFamily="微软雅黑" FontSize="20" Margin="30,30,30,0" />
|
<TextBox x:Name="username" Template="{StaticResource CornerTextBox}" Height="34" TextWrapping="Wrap" Text="" VerticalAlignment="Top" HorizontalContentAlignment="Center" FontFamily="微软雅黑" FontSize="20" Margin="30,30,30,0" />
|
||||||
<Label Content="————— 游 戏 密 码 —————" VerticalAlignment="Top" Margin="10,69,10,0" HorizontalContentAlignment="Center" FontSize="15"/>
|
<Label Content="————— 游 戏 密 码 —————" VerticalAlignment="Top" Margin="10,69,10,0" HorizontalContentAlignment="Center" FontSize="15"/>
|
||||||
<TextBox x:Name="password" Template="{StaticResource CornerTextBox}" TextWrapping="Wrap" HorizontalContentAlignment="Center" FontFamily="微软雅黑" FontSize="20" Margin="30,104,30,0" Height="34" VerticalAlignment="Top" />
|
<TextBox x:Name="password" Template="{StaticResource CornerTextBox}" TextWrapping="Wrap" HorizontalContentAlignment="Center" FontFamily="微软雅黑" FontSize="20" Margin="30,104,30,0" Height="34" VerticalAlignment="Top" />
|
||||||
<Button Margin="217,106,33,0" Template="{StaticResource CornerButton}" Height="30" Content="?" VerticalAlignment="Top" />
|
<Button x:Name="forget" Margin="217,106,33,0" Template="{StaticResource CornerButton}" Height="30" Content="?" VerticalAlignment="Top" Click="forget_Click" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid Margin="10,0,10,10" Height="50" VerticalAlignment="Bottom">
|
<Grid Margin="10,0,10,10" Height="50" VerticalAlignment="Bottom">
|
||||||
<Button x:Name="Login" Margin="30,10,160,10" Template="{StaticResource CornerButton}" BorderBrush="#FF3299CC" Content="登录" Click="Login_Click"/>
|
<Button x:Name="Login" Margin="30,10,160,10" Template="{StaticResource CornerButton}" BorderBrush="#FF3299CC" Content="登录" Click="Login_Click"/>
|
||||||
@ -109,43 +109,43 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<Grid Margin="20,60,20,20" Background="White" x:Name="ServerWindow" >
|
<Grid Margin="20,60,20,20" Background="White" x:Name="ServerWindow" Visibility="Hidden">
|
||||||
<!--Visibility="Hidden"-->
|
<!--Visibility="Hidden"-->
|
||||||
<Grid HorizontalAlignment="Left" Width="400" Margin="20,20,0,20">
|
<Grid HorizontalAlignment="Left" Width="400" Margin="20,20,0,20">
|
||||||
<Grid Height="80" VerticalAlignment="Top" Margin="0,0,0,0">
|
<Grid Height="80" VerticalAlignment="Top" Margin="0,0,0,0">
|
||||||
<Label Content="选择大区" Margin="155,20" FontSize="20" VerticalAlignment="Center" VerticalContentAlignment="Center"/>
|
<Label Content="选择大区" Margin="155,20" FontSize="20" VerticalAlignment="Center" VerticalContentAlignment="Center"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid Height="100" VerticalAlignment="Top" Margin="0,80,0,0">
|
<Grid Height="100" VerticalAlignment="Top" Margin="0,80,0,0" Name="GameArea">
|
||||||
<RadioButton Content="纯净大区" Margin="30,30,0,0" VerticalAlignment="Top" IsChecked="True" HorizontalAlignment="Left" Width="70"/>
|
<RadioButton Name="a1" Content="X X大区" Margin="30,30,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70" Visibility="Hidden" Checked="area_Checked"/>
|
||||||
<RadioButton Content="模组大区" Margin="120,30,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70"/>
|
<RadioButton Name="a2" Content="X X大区" Margin="120,30,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70" Visibility="Hidden" Checked="area_Checked"/>
|
||||||
<RadioButton Content="X X大区" Margin="215,30,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70"/>
|
<RadioButton Name="a3" Content="X X大区" Margin="215,30,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70" Visibility="Hidden" Checked="area_Checked"/>
|
||||||
<RadioButton Content="X X大区" Margin="305,30,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70"/>
|
<RadioButton Name="a4" Content="X X大区" Margin="305,30,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70" Visibility="Hidden" Checked="area_Checked"/>
|
||||||
|
|
||||||
<RadioButton Content="X X大区" Margin="30,60,0,0" VerticalAlignment="Top" IsChecked="True" HorizontalAlignment="Left" Width="70"/>
|
<RadioButton Name="a5" Content="X X大区" Margin="30,60,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70" Visibility="Hidden" Checked="area_Checked"/>
|
||||||
<RadioButton Content="X X大区" Margin="120,60,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70"/>
|
<RadioButton Name="a6" Content="X X大区" Margin="120,60,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70" Visibility="Hidden" Checked="area_Checked"/>
|
||||||
<RadioButton Content="X X大区" Margin="215,60,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70"/>
|
<RadioButton Name="a7" Content="X X大区" Margin="215,60,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70" Visibility="Hidden" Checked="area_Checked"/>
|
||||||
<RadioButton Content="X X大区" Margin="305,60,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70"/>
|
<RadioButton Name="a8" Content="X X大区" Margin="305,60,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70" Visibility="Hidden" Checked="area_Checked"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid Height="285" VerticalAlignment="Top" Margin="10,185,10,0">
|
<Grid Height="285" VerticalAlignment="Top" Margin="10,185,10,0">
|
||||||
<Grid Height="50" VerticalAlignment="Top" Margin="10,0,10,0">
|
<Grid Height="50" VerticalAlignment="Top" Margin="10,0,10,0">
|
||||||
<Label Content="选择服务器" Margin="125,8" FontSize="20" VerticalContentAlignment="Center" VerticalAlignment="Center"/>
|
<Label Content="选择服务器" Margin="125,8" FontSize="20" VerticalContentAlignment="Center" VerticalAlignment="Center"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid Margin="10,55,10,10">
|
<Grid Margin="10,55,10,10" Name="GameServer">
|
||||||
<RadioButton Name="server1" Content="光坂小镇" Margin="50,40,0,0" VerticalAlignment="Top" IsChecked="True" HorizontalAlignment="Left" Width="80"/>
|
<RadioButton Name="s1" Content="服务器1" Margin="50,40,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked"/>
|
||||||
<RadioButton Content="服务器2" Margin="150,40,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80"/>
|
<RadioButton Name="s2" Content="服务器2" Margin="150,40,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked"/>
|
||||||
<RadioButton Content="服务器3" Margin="252,40,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80"/>
|
<RadioButton Name="s3" Content="服务器3" Margin="252,40,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked"/>
|
||||||
|
|
||||||
<RadioButton Content="服务器4" Margin="50,80,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80"/>
|
<RadioButton Name="s4" Content="服务器4" Margin="50,80,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked"/>
|
||||||
<RadioButton Content="服务器5" Margin="150,80,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80"/>
|
<RadioButton Name="s5" Content="服务器5" Margin="150,80,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked" />
|
||||||
<RadioButton Content="服务器6" Margin="252,80,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80"/>
|
<RadioButton Name="s6" Content="服务器6" Margin="252,80,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked"/>
|
||||||
|
|
||||||
<RadioButton Content="服务器7" Margin="50,120,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80"/>
|
<RadioButton Name="s7" Content="服务器7" Margin="50,120,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked"/>
|
||||||
<RadioButton Content="服务器8" Margin="150,120,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80"/>
|
<RadioButton Name="s8" Content="服务器8" Margin="150,120,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked"/>
|
||||||
<RadioButton Content="服务器9" Margin="252,120,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80"/>
|
<RadioButton Name="s9" Content="服务器9" Margin="252,120,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked"/>
|
||||||
|
|
||||||
<RadioButton Content="服务器10" Margin="50,160,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80"/>
|
<RadioButton Name="s10" Content="服务器10" Margin="50,160,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked"/>
|
||||||
<RadioButton Content="服务器11" Margin="150,160,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80"/>
|
<RadioButton Name="s11" Content="服务器11" Margin="150,160,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked"/>
|
||||||
<RadioButton Content="服务器12" Margin="252,160,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80"/>
|
<RadioButton Name="s12" Content="服务器12" Margin="252,160,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
@ -155,9 +155,7 @@
|
|||||||
<Label Content="服务器介绍" Margin="85,2" FontSize="20" VerticalContentAlignment="Center" VerticalAlignment="Center"/>
|
<Label Content="服务器介绍" Margin="85,2" FontSize="20" VerticalContentAlignment="Center" VerticalAlignment="Center"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid Height="200" VerticalAlignment="Bottom" Margin="10,0,10,10">
|
<Grid Height="200" VerticalAlignment="Bottom" Margin="10,0,10,10">
|
||||||
<Label Content="友爱" HorizontalAlignment="Left" Margin="190,30,0,0" VerticalAlignment="Top"/>
|
<Label Content="友爱" Margin="50,35,50,35"/>
|
||||||
<Label Content="友爱" HorizontalAlignment="Left" Margin="50,30,0,0" VerticalAlignment="Top"/>
|
|
||||||
<Label Content="友爱个篮子" HorizontalAlignment="Left" Margin="103,30,0,0" VerticalAlignment="Top"/>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid HorizontalAlignment="Right" Width="300" ShowGridLines="True" Height="206" VerticalAlignment="Bottom">
|
<Grid HorizontalAlignment="Right" Width="300" ShowGridLines="True" Height="206" VerticalAlignment="Bottom">
|
||||||
|
@ -20,6 +20,8 @@ using CityCraft;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using System.Windows.Media.Animation;
|
using System.Windows.Media.Animation;
|
||||||
|
using LitJson;
|
||||||
|
using CTZLauncher.Modules.CTZServer;
|
||||||
|
|
||||||
namespace CTZLauncher
|
namespace CTZLauncher
|
||||||
{
|
{
|
||||||
@ -29,7 +31,11 @@ namespace CTZLauncher
|
|||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
LauncherCore launcher = null;
|
LauncherCore launcher = null;
|
||||||
|
LaunchOptions option = new LaunchOptions();
|
||||||
|
string serveraddress = "";
|
||||||
int serverport = 25580;
|
int serverport = 25580;
|
||||||
|
|
||||||
|
#region 初始化部分
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -43,7 +49,9 @@ namespace CTZLauncher
|
|||||||
}
|
}
|
||||||
launcher = LauncherCore.Create(".minecraft");
|
launcher = LauncherCore.Create(".minecraft");
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 登录界面
|
||||||
private void barclick_MouseDown(object sender, MouseButtonEventArgs e)
|
private void barclick_MouseDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
Label bar = (Label)sender;
|
Label bar = (Label)sender;
|
||||||
@ -77,7 +85,7 @@ namespace CTZLauncher
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Login.IsEnabled = false;
|
Login.IsEnabled = false;
|
||||||
CTZAuthenticator auth = new CTZAuthenticator(username.Text, password.Text, "citycraft.cn", serverport);
|
CTZAuthenticator auth = new CTZAuthenticator(username.Text, password.Text, serveraddress, serverport);
|
||||||
if (auth.isLogin())
|
if (auth.isLogin())
|
||||||
{
|
{
|
||||||
MessageBox.Show("当前玩家已登录服务器!");
|
MessageBox.Show("当前玩家已登录服务器!");
|
||||||
@ -100,50 +108,19 @@ namespace CTZLauncher
|
|||||||
DoubleAnimation dbAscending = new DoubleAnimation(0, 360, new Duration(TimeSpan.FromSeconds(0.75)));
|
DoubleAnimation dbAscending = new DoubleAnimation(0, 360, new Duration(TimeSpan.FromSeconds(0.75)));
|
||||||
dbAscending.RepeatBehavior = new RepeatBehavior(1);
|
dbAscending.RepeatBehavior = new RepeatBehavior(1);
|
||||||
rtf.BeginAnimation(RotateTransform.AngleProperty, dbAscending);
|
rtf.BeginAnimation(RotateTransform.AngleProperty, dbAscending);
|
||||||
|
CTZServer areas = JsonMapper.ToObject<CTZServer>(auth.getServerList());
|
||||||
|
LoadAreas(areas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Login.IsEnabled = true;
|
Login.IsEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 模仿C#的Application.Doevent函数。可以适当添加try catch 模块
|
|
||||||
/// </summary>
|
|
||||||
public void DoEvent()
|
|
||||||
{
|
|
||||||
DispatcherFrame frame = new DispatcherFrame();
|
|
||||||
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(ExitFrame), frame);
|
|
||||||
Dispatcher.PushFrame(frame);
|
|
||||||
}
|
|
||||||
public object ExitFrame(object f)
|
|
||||||
{
|
|
||||||
((DispatcherFrame)f).Continue = false;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void outline_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
private void outline_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.LeftButton == MouseButtonState.Pressed)
|
if (e.LeftButton == MouseButtonState.Pressed)
|
||||||
this.DragMove();
|
this.DragMove();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StartGame_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
Console.WriteLine("StartGame");
|
|
||||||
LaunchOptions option = new LaunchOptions();
|
|
||||||
option.Mode = LaunchMode.MCLauncher;
|
|
||||||
option.MaxMemory = 2048;
|
|
||||||
option.Authenticator = new OfflineAuthenticator(username.Text); // offline
|
|
||||||
option.Version = launcher.GetVersion("1.8");
|
|
||||||
launcher.JavaPath = SystemTools.FindJava().First();
|
|
||||||
launcher.GameLog += launcher_GameLog;
|
|
||||||
launcher.Launch(option);
|
|
||||||
}
|
|
||||||
|
|
||||||
void launcher_GameLog(LaunchHandle arg1, string log)
|
|
||||||
{
|
|
||||||
Console.WriteLine(log);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void close_Click(object sender, RoutedEventArgs e)
|
private void close_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
this.Close();
|
this.Close();
|
||||||
@ -191,9 +168,71 @@ namespace CTZLauncher
|
|||||||
MessageBox.Show("注册失败!");
|
MessageBox.Show("注册失败!");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void s(object sender, RoutedEventArgs e)
|
private void forget_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 服务器选择与启动
|
||||||
|
private void LoadAreas(CTZServer areas)
|
||||||
|
{
|
||||||
|
for (int i = 1; i <= areas.Areas.Count; i++)
|
||||||
|
{
|
||||||
|
Area area = areas.Areas[i];
|
||||||
|
RadioButton arearb = GameArea.FindName("a" + i) as RadioButton;
|
||||||
|
arearb.Content = area.Name;
|
||||||
|
arearb.Visibility = Visibility.Visible;
|
||||||
|
arearb.Tag = area.Servers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadServers(List<Server> servers)
|
||||||
|
{
|
||||||
|
for (int i = 1; i <= servers.Count; i++)
|
||||||
|
{
|
||||||
|
Server server = servers[i];
|
||||||
|
RadioButton serverrb = GameArea.FindName("s" + i) as RadioButton;
|
||||||
|
serverrb.Content = server.Name;
|
||||||
|
serverrb.Visibility = Visibility.Visible;
|
||||||
|
serverrb.Tag = server;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void area_Checked(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
RadioButton rb = (RadioButton)sender;
|
||||||
|
LoadServers((List<Server>)rb.Tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void server_Checked(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
RadioButton rb = (RadioButton)sender;
|
||||||
|
Server server = (Server)rb.Tag;
|
||||||
|
option.Server = new ServerInfo
|
||||||
|
{
|
||||||
|
Address = server.Address,
|
||||||
|
Port = server.Port
|
||||||
|
};
|
||||||
|
option.Version = launcher.GetVersion(server.Version);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StartGame_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Console.WriteLine("StartGame");
|
||||||
|
option.Mode = LaunchMode.MCLauncher;
|
||||||
|
option.MaxMemory = 2048;
|
||||||
|
option.Authenticator = new OfflineAuthenticator(username.Text); // offline
|
||||||
|
option.Version = launcher.GetVersion("1.8");
|
||||||
|
launcher.JavaPath = SystemTools.FindJava().First();
|
||||||
|
launcher.GameLog += launcher_GameLog;
|
||||||
|
launcher.Launch(option);
|
||||||
|
}
|
||||||
|
|
||||||
|
void launcher_GameLog(LaunchHandle arg1, string log)
|
||||||
|
{
|
||||||
|
Console.WriteLine(log);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
87
CTZLauncher/Modules/CTZServer/CTZServer.cs
Normal file
87
CTZLauncher/Modules/CTZServer/CTZServer.cs
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
using LitJson;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace CTZLauncher.Modules.CTZServer
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 实例化服务器信息
|
||||||
|
/// </summary>
|
||||||
|
public class CTZServer
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 大区列表
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("areas")]
|
||||||
|
public List<Area> Areas { get; set; }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 服务器大区信息
|
||||||
|
/// </summary>
|
||||||
|
public class Area
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 大区名称
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("name")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 大区服务器列表
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("servers")]
|
||||||
|
public List<Server> Servers { get; set; }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 服务器信息
|
||||||
|
/// </summary>
|
||||||
|
public class Server
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 服务器名称
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("name")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 服务器地址
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("address")]
|
||||||
|
public string Address { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 服务器端口
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("port")]
|
||||||
|
public ushort Port { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 服务器简介
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("info")]
|
||||||
|
public string Info { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 客户端版本
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("version")]
|
||||||
|
public string Version { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 客户端下载地址
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("url")]
|
||||||
|
public string Url { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得服务器链接
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>服务器链接</returns>
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return string.Format("{0}:{1}", Address, Port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user