mirror of
https://e.coding.net/circlecloud/CTZLauncher.git
synced 2024-11-22 02:08:49 +00:00
完成服务器列表获取模块 添加启动标题修改 修复HttpHelper获取到空数组...
This commit is contained in:
parent
282d195955
commit
f739a359bf
@ -69,12 +69,17 @@ namespace KMCCC.Authentication
|
|||||||
public string getServerList()
|
public string getServerList()
|
||||||
{
|
{
|
||||||
string sl = http.Send(HttpMethod.GET, Address + ":" + Port + "/serverlist");
|
string sl = http.Send(HttpMethod.GET, Address + ":" + Port + "/serverlist");
|
||||||
return sl.Replace("\0","");
|
if (string.IsNullOrEmpty(sl))
|
||||||
|
throw new ArgumentNullException("服务器返回了空的字符串或网络连接异常!");
|
||||||
|
return sl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool getResult(string url)
|
public bool getResult(string url)
|
||||||
{
|
{
|
||||||
return http.Send(HttpMethod.GET, url).Contains("true") ? true : false;
|
string result = http.Send(HttpMethod.GET, url);
|
||||||
|
if (string.IsNullOrEmpty(result))
|
||||||
|
throw new ArgumentNullException("服务器返回了空的字符串或网络连接异常!");
|
||||||
|
return result.Contains("true") ? true : false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,6 +187,13 @@ namespace CityCraft
|
|||||||
int iNumber = socket.Receive(buffer, buffer.Length, SocketFlags.None);
|
int iNumber = socket.Receive(buffer, buffer.Length, SocketFlags.None);
|
||||||
while (iNumber > 0)//使用了Connection: Close 所以判断长度为0 时停止接受
|
while (iNumber > 0)//使用了Connection: Close 所以判断长度为0 时停止接受
|
||||||
{
|
{
|
||||||
|
if (iNumber < 1024)
|
||||||
|
{
|
||||||
|
byte[] shotbuffer = new byte[iNumber];
|
||||||
|
Array.Copy(buffer, shotbuffer, iNumber);
|
||||||
|
responseBytes.AddRange(new List<byte>(shotbuffer));//添加数据到List
|
||||||
|
}
|
||||||
|
else
|
||||||
responseBytes.AddRange(new List<byte>(buffer));//添加数据到List
|
responseBytes.AddRange(new List<byte>(buffer));//添加数据到List
|
||||||
iNumber = socket.Receive(buffer, buffer.Length, SocketFlags.None);//继续接收数据
|
iNumber = socket.Receive(buffer, buffer.Length, SocketFlags.None);//继续接收数据
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
{
|
{
|
||||||
public override bool Operate(LauncherCore core, MinecraftLaunchArguments args)
|
public override bool Operate(LauncherCore core, MinecraftLaunchArguments args)
|
||||||
{
|
{
|
||||||
args.Tokens["game_directory"] = String.Format(@".\versions\{0}\", args.Version.Id);
|
args.Tokens["game_directory"] = String.Format(@".minecraft\versions\{0}\", args.Version.Id);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,6 +117,11 @@
|
|||||||
/// 游戏Log事件
|
/// 游戏Log事件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action<LaunchHandle, string> GameLog;
|
public event Action<LaunchHandle, string> GameLog;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 游戏启动事件
|
||||||
|
/// </summary>
|
||||||
|
public event Action<LaunchHandle, string> GameStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
args.Tokens.Add("user_properties", authentication.Properties);
|
args.Tokens.Add("user_properties", authentication.Properties);
|
||||||
args.Tokens.Add("user_type", authentication.UserType);
|
args.Tokens.Add("user_type", authentication.UserType);
|
||||||
|
|
||||||
args.AdvencedArguments = new List<string> { "-Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true" };
|
args.AdvencedArguments = new List<string> { "-Dfml.ignoreInvalidMinecraftCertificates=true", "-Dfml.ignorePatchDiscrepancies=true" };
|
||||||
|
|
||||||
args.Authentication = authentication;
|
args.Authentication = authentication;
|
||||||
args.Version = options.Version;
|
args.Version = options.Version;
|
||||||
@ -139,6 +139,7 @@
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
handle.Work();
|
handle.Work();
|
||||||
|
Start(handle, handle.GetTile());
|
||||||
Task.Factory.StartNew(handle.Process.WaitForExit).ContinueWith(t => Exit(handle, handle.Process.ExitCode));
|
Task.Factory.StartNew(handle.Process.WaitForExit).ContinueWith(t => Exit(handle, handle.Process.ExitCode));
|
||||||
return new LaunchResult { Success = true, Handle = handle };
|
return new LaunchResult { Success = true, Handle = handle };
|
||||||
}
|
}
|
||||||
@ -212,6 +213,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void Start(LaunchHandle handle, string title)
|
||||||
|
{
|
||||||
|
if (GameStart != null)
|
||||||
|
{
|
||||||
|
GameStart(handle, title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -116,36 +116,36 @@
|
|||||||
<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" Name="GameArea">
|
<Grid Height="100" VerticalAlignment="Top" Margin="0,80,0,0" Name="GameArea">
|
||||||
<RadioButton Name="a0" Content="X X大区" Margin="30,30,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70" Visibility="Hidden" Checked="area_Checked"/>
|
<Button Name="a0" BorderBrush="#FF3299CC" Content="X X大区" Template="{StaticResource CornerButton}" HorizontalAlignment="Left" Margin="30,30,0,0" VerticalAlignment="Top" Width="75" Visibility="Hidden" Click="area_Click"/>
|
||||||
<RadioButton Name="a1" Content="X X大区" Margin="120,30,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70" Visibility="Hidden" Checked="area_Checked"/>
|
<Button Name="a1" BorderBrush="#FF3299CC" Content="X X大区" Template="{StaticResource CornerButton}" HorizontalAlignment="Left" Margin="120,30,0,0" VerticalAlignment="Top" Width="75" Visibility="Hidden" Click="area_Click"/>
|
||||||
<RadioButton Name="a2" Content="X X大区" Margin="215,30,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70" Visibility="Hidden" Checked="area_Checked"/>
|
<Button Name="a2" BorderBrush="#FF3299CC" Content="X X大区" Template="{StaticResource CornerButton}" HorizontalAlignment="Left" Margin="215,30,0,0" VerticalAlignment="Top" Width="75" Visibility="Hidden" Click="area_Click"/>
|
||||||
<RadioButton Name="a3" Content="X X大区" Margin="305,30,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70" Visibility="Hidden" Checked="area_Checked"/>
|
<Button Name="a3" BorderBrush="#FF3299CC" Content="X X大区" Template="{StaticResource CornerButton}" HorizontalAlignment="Left" Margin="305,30,0,0" VerticalAlignment="Top" Width="75" Visibility="Hidden" Click="area_Click"/>
|
||||||
|
|
||||||
<RadioButton Name="a4" Content="X X大区" Margin="30,60,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70" Visibility="Hidden" Checked="area_Checked"/>
|
<Button Name="a4" BorderBrush="#FF3299CC" Content="X X大区" Template="{StaticResource CornerButton}" HorizontalAlignment="Left" Margin="30,60,0,0" VerticalAlignment="Top" Width="75" Visibility="Hidden" Click="area_Click"/>
|
||||||
<RadioButton Name="a5" Content="X X大区" Margin="120,60,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70" Visibility="Hidden" Checked="area_Checked"/>
|
<Button Name="a5" BorderBrush="#FF3299CC" Content="X X大区" Template="{StaticResource CornerButton}" HorizontalAlignment="Left" Margin="120,60,0,0" VerticalAlignment="Top" Width="75" Visibility="Hidden" Click="area_Click"/>
|
||||||
<RadioButton Name="a6" Content="X X大区" Margin="215,60,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70" Visibility="Hidden" Checked="area_Checked"/>
|
<Button Name="a6" BorderBrush="#FF3299CC" Content="X X大区" Template="{StaticResource CornerButton}" HorizontalAlignment="Left" Margin="215,60,0,0" VerticalAlignment="Top" Width="75" Visibility="Hidden" Click="area_Click"/>
|
||||||
<RadioButton Name="a7" Content="X X大区" Margin="305,60,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="70" Visibility="Hidden" Checked="area_Checked"/>
|
<Button Name="a7" BorderBrush="#FF3299CC" Content="X X大区" Template="{StaticResource CornerButton}" HorizontalAlignment="Left" Margin="305,60,0,0" VerticalAlignment="Top" Width="75" Visibility="Hidden" Click="area_Click"/>
|
||||||
</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" Name="GameServer">
|
<Grid Margin="10,55,10,10" Name="GameServer">
|
||||||
<RadioButton Name="s0" Content="服务器1" Margin="50,40,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked"/>
|
<Button Name="s0" Content="服务器1" Template="{StaticResource CornerButton}" BorderBrush="#FF3299CC" Margin="50,40,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Click="server_Click"/>
|
||||||
<RadioButton Name="s1" Content="服务器2" Margin="150,40,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked"/>
|
<Button Name="s1" Content="服务器2" Template="{StaticResource CornerButton}" BorderBrush="#FF3299CC" Margin="150,40,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Click="server_Click"/>
|
||||||
<RadioButton Name="s2" Content="服务器3" Margin="252,40,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked"/>
|
<Button Name="s2" Content="服务器3" Template="{StaticResource CornerButton}" BorderBrush="#FF3299CC" Margin="252,40,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Click="server_Click"/>
|
||||||
|
|
||||||
<RadioButton Name="s3" Content="服务器4" Margin="50,80,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked"/>
|
<Button Name="s3" Content="服务器4" Template="{StaticResource CornerButton}" BorderBrush="#FF3299CC" Margin="50,80,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Click="server_Click"/>
|
||||||
<RadioButton Name="s4" Content="服务器5" Margin="150,80,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked" />
|
<Button Name="s4" Content="服务器5" Template="{StaticResource CornerButton}" BorderBrush="#FF3299CC" Margin="150,80,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Click="server_Click"/>
|
||||||
<RadioButton Name="s5" Content="服务器6" Margin="252,80,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked"/>
|
<Button Name="s5" Content="服务器6" Template="{StaticResource CornerButton}" BorderBrush="#FF3299CC" Margin="252,80,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Click="server_Click"/>
|
||||||
|
|
||||||
<RadioButton Name="s6" Content="服务器7" Margin="50,120,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked"/>
|
<Button Name="s6" Content="服务器7" Template="{StaticResource CornerButton}" BorderBrush="#FF3299CC" Margin="50,120,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Click="server_Click"/>
|
||||||
<RadioButton Name="s7" Content="服务器8" Margin="150,120,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked"/>
|
<Button Name="s7" Content="服务器8" Template="{StaticResource CornerButton}" BorderBrush="#FF3299CC" Margin="150,120,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Click="server_Click"/>
|
||||||
<RadioButton Name="s8" Content="服务器9" Margin="252,120,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked"/>
|
<Button Name="s8" Content="服务器9" Template="{StaticResource CornerButton}" BorderBrush="#FF3299CC" Margin="252,120,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Click="server_Click"/>
|
||||||
|
|
||||||
<RadioButton Name="s9" Content="服务器10" Margin="50,160,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked"/>
|
<Button Name="s9" Content="服务器10" Template="{StaticResource CornerButton}" BorderBrush="#FF3299CC" Margin="50,160,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Click="server_Click"/>
|
||||||
<RadioButton Name="s10" Content="服务器11" Margin="150,160,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked"/>
|
<Button Name="s10" Content="服务器11" Template="{StaticResource CornerButton}" BorderBrush="#FF3299CC" Margin="150,160,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Click="server_Click"/>
|
||||||
<RadioButton Name="s11" Content="服务器12" Margin="252,160,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Checked="server_Checked"/>
|
<Button Name="s11" Content="服务器12" Template="{StaticResource CornerButton}" BorderBrush="#FF3299CC" Margin="252,160,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="80" Visibility="Hidden" Click="server_Click"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
@ -155,10 +155,16 @@
|
|||||||
<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="" Margin="50,35,50,35"/>
|
<Label Name="serverinfo" Content="" Margin="50,35,50,35" FontSize="15"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid HorizontalAlignment="Right" Width="300" ShowGridLines="True" Height="206" VerticalAlignment="Bottom">
|
<Grid ShowGridLines="True" Height="200" VerticalAlignment="Bottom">
|
||||||
|
<Label Content="服务器名称:" Margin="40,20,160,0" FontSize="15" HorizontalContentAlignment="Center" Height="30" VerticalAlignment="Top" />
|
||||||
|
<Label Name="selserver" Content="" Margin="145,20,40,0" FontSize="15" HorizontalContentAlignment="Center" Height="30" VerticalAlignment="Top" />
|
||||||
|
<Label Content="客户端版本:" Margin="40,50,160,0" FontSize="15" HorizontalContentAlignment="Center" Height="30" VerticalAlignment="Top" />
|
||||||
|
<Label Name="needclient" Content="" Margin="145,50,40,0" FontSize="15" HorizontalContentAlignment="Center" Height="30" VerticalAlignment="Top" />
|
||||||
|
<Label Content="在线人数:" Margin="40,80,160,0" FontSize="15" HorizontalContentAlignment="Center" Height="30" VerticalAlignment="Top" />
|
||||||
|
<Label Name="online" Content="" Margin="145,80,40,0" FontSize="15" HorizontalContentAlignment="Center" Height="30" VerticalAlignment="Top" />
|
||||||
<Button x:Name="StartGame" BorderBrush="#FF3299CC" Content="启动游戏" Template="{StaticResource CornerButton}" Margin="10,0,10,10" Height="64" VerticalAlignment="Bottom" FontSize="16" Click="StartGame_Click"/>
|
<Button x:Name="StartGame" BorderBrush="#FF3299CC" Content="启动游戏" Template="{StaticResource CornerButton}" Margin="10,0,10,10" Height="64" VerticalAlignment="Bottom" FontSize="16" Click="StartGame_Click"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@ -32,7 +32,7 @@ namespace CTZLauncher
|
|||||||
{
|
{
|
||||||
LauncherCore launcher = null;
|
LauncherCore launcher = null;
|
||||||
LaunchOptions option = new LaunchOptions();
|
LaunchOptions option = new LaunchOptions();
|
||||||
string serveraddress = "CityCraft.cn";
|
string serveraddress = "127.0.0.1";
|
||||||
int serverport = 25580;
|
int serverport = 25580;
|
||||||
|
|
||||||
#region 初始化部分
|
#region 初始化部分
|
||||||
@ -86,6 +86,8 @@ namespace CTZLauncher
|
|||||||
}
|
}
|
||||||
Login.IsEnabled = false;
|
Login.IsEnabled = false;
|
||||||
CTZAuthenticator auth = new CTZAuthenticator(username.Text, password.Text, serveraddress, serverport);
|
CTZAuthenticator auth = new CTZAuthenticator(username.Text, password.Text, serveraddress, serverport);
|
||||||
|
try
|
||||||
|
{
|
||||||
if (auth.isLogin())
|
if (auth.isLogin())
|
||||||
{
|
{
|
||||||
MessageBox.Show("当前玩家已登录服务器!");
|
MessageBox.Show("当前玩家已登录服务器!");
|
||||||
@ -112,8 +114,16 @@ namespace CTZLauncher
|
|||||||
LoadAreas(areas);
|
LoadAreas(areas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (ArgumentNullException ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
Login.IsEnabled = true;
|
Login.IsEnabled = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void outline_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
private void outline_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
@ -147,12 +157,15 @@ namespace CTZLauncher
|
|||||||
|
|
||||||
private void register_Click(object sender, RoutedEventArgs e)
|
private void register_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
register.IsEnabled = false;
|
||||||
if (username.Text.Length == 0 || password.Text.Length == 0)
|
if (username.Text.Length == 0 || password.Text.Length == 0)
|
||||||
{
|
{
|
||||||
MessageBox.Show("请输入账号密码!");
|
MessageBox.Show("请输入账号密码!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CTZAuthenticator auth = new CTZAuthenticator(username.Text, password.Text, "citycraft.cn", serverport);
|
CTZAuthenticator auth = new CTZAuthenticator(username.Text, password.Text, "citycraft.cn", serverport);
|
||||||
|
try
|
||||||
|
{
|
||||||
if (auth.isRegistered())
|
if (auth.isRegistered())
|
||||||
{
|
{
|
||||||
MessageBox.Show("该用户名已注册 请更换用户名!");
|
MessageBox.Show("该用户名已注册 请更换用户名!");
|
||||||
@ -167,6 +180,16 @@ namespace CTZLauncher
|
|||||||
else
|
else
|
||||||
MessageBox.Show("注册失败!");
|
MessageBox.Show("注册失败!");
|
||||||
}
|
}
|
||||||
|
catch (ArgumentNullException ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
register.IsEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 服务器选择与启动
|
#region 服务器选择与启动
|
||||||
@ -175,11 +198,16 @@ namespace CTZLauncher
|
|||||||
for (int i = 0; i < areas.Areas.Count; i++)
|
for (int i = 0; i < areas.Areas.Count; i++)
|
||||||
{
|
{
|
||||||
Area area = areas.Areas[i];
|
Area area = areas.Areas[i];
|
||||||
RadioButton arearb = GameArea.FindName("a" + i) as RadioButton;
|
Button arearb = GameArea.FindName("a" + i) as Button;
|
||||||
arearb.Content = area.Name;
|
arearb.Content = area.Name;
|
||||||
arearb.Visibility = Visibility.Visible;
|
arearb.Visibility = Visibility.Visible;
|
||||||
arearb.Tag = area.Servers;
|
arearb.Tag = area.Servers;
|
||||||
}
|
}
|
||||||
|
for (int i = areas.Areas.Count; i < 8; i++)
|
||||||
|
{
|
||||||
|
Button arearb = GameArea.FindName("a" + i) as Button;
|
||||||
|
arearb.Visibility = Visibility.Hidden;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadServers(List<Server> servers)
|
private void LoadServers(List<Server> servers)
|
||||||
@ -187,43 +215,57 @@ namespace CTZLauncher
|
|||||||
for (int i = 0; i < servers.Count; i++)
|
for (int i = 0; i < servers.Count; i++)
|
||||||
{
|
{
|
||||||
Server server = servers[i];
|
Server server = servers[i];
|
||||||
RadioButton serverrb = GameArea.FindName("s" + i) as RadioButton;
|
Button serverrb = GameArea.FindName("s" + i) as Button;
|
||||||
serverrb.Content = server.Name;
|
serverrb.Content = server.Name;
|
||||||
serverrb.Visibility = Visibility.Visible;
|
serverrb.Visibility = Visibility.Visible;
|
||||||
serverrb.Tag = server;
|
serverrb.Tag = server;
|
||||||
}
|
}
|
||||||
|
for (int i = servers.Count; i < 12; i++)
|
||||||
|
{
|
||||||
|
Button serverrb = GameArea.FindName("s" + i) as Button;
|
||||||
|
serverrb.Visibility = Visibility.Hidden;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void area_Checked(object sender, RoutedEventArgs e)
|
private void area_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
RadioButton rb = (RadioButton)sender;
|
Button arb = (Button)sender;
|
||||||
LoadServers((List<Server>)rb.Tag);
|
LoadServers((List<Server>)arb.Tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void server_Checked(object sender, RoutedEventArgs e)
|
private void server_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
RadioButton rb = (RadioButton)sender;
|
Button srb = (Button)sender;
|
||||||
Server server = (Server)rb.Tag;
|
Server server = (Server)srb.Tag;
|
||||||
option.Server = new ServerInfo
|
option.Server = new ServerInfo
|
||||||
{
|
{
|
||||||
Address = server.Address,
|
Address = server.Address,
|
||||||
Port = server.Port
|
Port = server.Port
|
||||||
};
|
};
|
||||||
option.Version = launcher.GetVersion(server.Version);
|
option.Version = launcher.GetVersion(server.Version);
|
||||||
|
serverinfo.Content = server.Info;
|
||||||
|
selserver.Content = server.Name;
|
||||||
|
needclient.Content = server.Version;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StartGame_Click(object sender, RoutedEventArgs e)
|
private void StartGame_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Console.WriteLine("StartGame");
|
Console.WriteLine("启动游戏");
|
||||||
option.Mode = LaunchMode.MCLauncher;
|
option.Mode = LaunchMode.MCLauncher;
|
||||||
option.MaxMemory = 2048;
|
option.MaxMemory = 2048;
|
||||||
option.Authenticator = new OfflineAuthenticator(username.Text); // offline
|
option.Authenticator = new OfflineAuthenticator(username.Text); // 离线模式
|
||||||
option.Version = launcher.GetVersion("1.8");
|
|
||||||
launcher.JavaPath = SystemTools.FindJava().First();
|
launcher.JavaPath = SystemTools.FindJava().First();
|
||||||
launcher.GameLog += launcher_GameLog;
|
launcher.GameLog += launcher_GameLog;
|
||||||
|
launcher.GameStart += Launcher_GameStart;
|
||||||
launcher.Launch(option);
|
launcher.Launch(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Launcher_GameStart(LaunchHandle arg1, string arg2)
|
||||||
|
{
|
||||||
|
string title = selserver.Content.ToString() + " - " + username.Text;
|
||||||
|
arg1.SetTitle(title);
|
||||||
|
}
|
||||||
|
|
||||||
void launcher_GameLog(LaunchHandle arg1, string log)
|
void launcher_GameLog(LaunchHandle arg1, string log)
|
||||||
{
|
{
|
||||||
Console.WriteLine(log);
|
Console.WriteLine(log);
|
||||||
|
@ -74,6 +74,12 @@ namespace CTZLauncher.Modules.CTZServer
|
|||||||
[JsonPropertyName("url")]
|
[JsonPropertyName("url")]
|
||||||
public string Url { get; set; }
|
public string Url { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 客户端依赖项
|
||||||
|
/// </summary>
|
||||||
|
[JsonPropertyName("depend")]
|
||||||
|
public string Depend { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得服务器链接
|
/// 获得服务器链接
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -91,10 +91,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
version = new Version();
|
version = new Version();
|
||||||
if (string.IsNullOrWhiteSpace(jver.Id))
|
//if (string.IsNullOrWhiteSpace(jver.Id))
|
||||||
{
|
//{
|
||||||
|
// jver.Id = id;
|
||||||
|
//}
|
||||||
jver.Id = id;
|
jver.Id = id;
|
||||||
}
|
|
||||||
if (string.IsNullOrWhiteSpace(jver.MinecraftArguments))
|
if (string.IsNullOrWhiteSpace(jver.MinecraftArguments))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@ -158,7 +159,7 @@
|
|||||||
version.Natives.Add(native);
|
version.Natives.Add(native);
|
||||||
if (lib.Extract != null)
|
if (lib.Extract != null)
|
||||||
{
|
{
|
||||||
native.Options = new UnzipOptions {Exclude = lib.Extract.Exculde};
|
native.Options = new UnzipOptions { Exclude = lib.Extract.Exculde };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user