1
0
mirror of https://e.coding.net/circlecloud/CTZLauncher.git synced 2024-11-22 02:08:49 +00:00

更新界面...

Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
j502647092 2015-07-29 20:38:01 +08:00
parent 6e0fa413d2
commit 5718c1ceb6
2 changed files with 53 additions and 41 deletions

View File

@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
ResizeMode = "NoResize" ResizeMode = "NoResize"
MouseMove="Window_MouseMove" MouseMove="Window_MouseMove"
Title="MainWindow" Height="768" Width="1024" Background="#FF3A3A3A" AllowsTransparency="True" WindowStyle="None" Visibility="Visible" HorizontalContentAlignment="Center" HorizontalAlignment="Center" Icon="E:\JTB\Project\CTZLauncher\CTZLauncher\ico.ico" VerticalAlignment="Center" VerticalContentAlignment="Center" WindowStartupLocation="CenterScreen"> Title="MainWindow" Height="768" Width="1024" Background="#FF3A3A3A" AllowsTransparency="True" WindowStyle="None" Visibility="Visible" HorizontalContentAlignment="Center" HorizontalAlignment="Center" Icon="E:\JTB\Project\CTZLauncher\CTZLauncher\ico.ico" VerticalAlignment="Center" VerticalContentAlignment="Center" WindowStartupLocation="CenterScreen" Initialized="Window_Initialized" Loaded="Window_Loaded">
<Window.Resources> <Window.Resources>
<ControlTemplate x:Key="CornerButton" TargetType="{x:Type Button}"> <ControlTemplate x:Key="CornerButton" TargetType="{x:Type Button}">
<Border BorderBrush="#FFA1A1A1" BorderThickness="1" CornerRadius="10" Background="{TemplateBinding Background}"> <Border BorderBrush="#FFA1A1A1" BorderThickness="1" CornerRadius="10" Background="{TemplateBinding Background}">
@ -16,7 +16,7 @@
</Border> </Border>
</ControlTemplate> </ControlTemplate>
</Window.Resources> </Window.Resources>
<Grid Background="#FF3A3A3A" Height="768" Width="1024" VerticalAlignment="Top"> <Grid Name="outline" Background="#FF3A3A3A" Height="768" Width="1024" VerticalAlignment="Top" MouseLeftButtonDown="outline_MouseLeftButtonDown">
<Grid Margin="20,0" Background="#FF3A3A3A" Height="60" VerticalAlignment="Top"> <Grid Margin="20,0" Background="#FF3A3A3A" Height="60" VerticalAlignment="Top">
<Label x:Name="barl1" Content="主导航" HorizontalAlignment="Left" Margin="15,15,0,0" VerticalAlignment="Top" Width="100" Height="30" FontSize="20" Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="STXingkai" Foreground="White" MouseDown="barclick_MouseDown"/> <Label x:Name="barl1" Content="主导航" HorizontalAlignment="Left" Margin="15,15,0,0" VerticalAlignment="Top" Width="100" Height="30" FontSize="20" Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="STXingkai" Foreground="White" MouseDown="barclick_MouseDown"/>
<Label x:Name="barl2" Content="主导航" HorizontalAlignment="Left" Margin="120,15,0,0" VerticalAlignment="Top" Width="100" Height="30" FontSize="20" Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="STXingkai" Foreground="White" MouseDown="barclick_MouseDown"/> <Label x:Name="barl2" Content="主导航" HorizontalAlignment="Left" Margin="120,15,0,0" VerticalAlignment="Top" Width="100" Height="30" FontSize="20" Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="STXingkai" Foreground="White" MouseDown="barclick_MouseDown"/>
@ -26,7 +26,7 @@
<Label x:Name="barr3" Content="主导航" HorizontalAlignment="Right" Margin="0,15,120,0" VerticalAlignment="Top" Width="100" Height="30" FontSize="20" Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="STXingkai" Foreground="White" MouseDown="barclick_MouseDown"/> <Label x:Name="barr3" Content="主导航" HorizontalAlignment="Right" Margin="0,15,120,0" VerticalAlignment="Top" Width="100" Height="30" FontSize="20" Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="STXingkai" Foreground="White" MouseDown="barclick_MouseDown"/>
<Label x:Name="barr2" Content="主导航" HorizontalAlignment="Right" Margin="0,15,220,0" VerticalAlignment="Top" Width="100" Height="30" FontSize="20" Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="STXingkai" Foreground="White" MouseDown="barclick_MouseDown"/> <Label x:Name="barr2" Content="主导航" HorizontalAlignment="Right" Margin="0,15,220,0" VerticalAlignment="Top" Width="100" Height="30" FontSize="20" Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="STXingkai" Foreground="White" MouseDown="barclick_MouseDown"/>
<Label x:Name="barr1" Content="主导航" HorizontalAlignment="Right" Margin="0,15,325,0" VerticalAlignment="Top" Width="100" Height="30" FontSize="20" Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="STXingkai" Foreground="White" MouseDown="barclick_MouseDown"/> <Label x:Name="barr1" Content="主导航" HorizontalAlignment="Right" Margin="0,15,325,0" VerticalAlignment="Top" Width="100" Height="30" FontSize="20" Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="STXingkai" Foreground="White" MouseDown="barclick_MouseDown"/>
<Image HorizontalAlignment="Left" Height="50" Margin="430,5,0,0" VerticalAlignment="Top" Width="50" Source="IZ.ico" MouseLeftButtonDown="Image_MouseLeftButtonDown" RenderTransformOrigin="0.56,0.24"/> <Image HorizontalAlignment="Left" Height="50" Margin="430,5,0,0" VerticalAlignment="Top" Width="50" Source="IZ.ico" RenderTransformOrigin="0.56,0.24"/>
<Label Content="IZ" HorizontalAlignment="Left" Height="50" Margin="480,7,0,0" VerticalAlignment="Top" Width="74" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="Sui Generis" Foreground="White" FontSize="35" /> <Label Content="IZ" HorizontalAlignment="Left" Height="50" Margin="480,7,0,0" VerticalAlignment="Top" Width="74" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="Sui Generis" Foreground="White" FontSize="35" />
</Grid> </Grid>
<Grid Margin="20,60,20,20" Background="White"> <Grid Margin="20,60,20,20" Background="White">
@ -80,12 +80,15 @@
</TabControl> </TabControl>
</Grid> </Grid>
<Grid Margin="0,20,30,20" HorizontalAlignment="Right" Width="350" Grid.ShowGridLines="True"> <Grid Margin="0,20,30,20" HorizontalAlignment="Right" Width="350" Grid.ShowGridLines="True">
<Border BorderBrush="Black" BorderThickness="2" CornerRadius="5"/> <Border BorderBrush="Black" BorderThickness="2" CornerRadius="5">
<Button Name="StartGame" Content="启动游戏" Template="{StaticResource CornerButton}" Background="Gray" HorizontalAlignment="Right" Margin="0,0,30,30" Width="120" Height="70" VerticalAlignment="Bottom" FontSize="20" MouseDown="StartGame_MouseDown" Click="StartGame_Click"/> </Border>
<ComboBox Name="javacombo" Height="30" Width="200" Margin="120,65,30,0" VerticalAlignment="Top"/> <Label Margin="0,30,240,0" Content="最大内存" HorizontalAlignment="Right" VerticalAlignment="Top" Width="100" Height="30" FontSize="20" Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="STXingkai" Foreground="Black"/>
<TextBox Text="" Height="30" Width="200" TextWrapping="Wrap" Margin="120,30,30,188" FontSize="20" />
<Button Name="StartGame" Content="启动游戏" Template="{StaticResource CornerButton}" Background="Gray" HorizontalAlignment="Right" Margin="0,0,30,30" Width="120" Height="70" VerticalAlignment="Bottom" FontSize="20" Click="StartGame_Click"/>
<ComboBox Name="javacombo" Height="30" Width="200" FontSize="20" Margin="120,65,30,0" VerticalAlignment="Top"/>
<Label Margin="0,65,240,0" Content="JAVA版本" HorizontalAlignment="Right" VerticalAlignment="Top" Width="100" Height="30" FontSize="20" Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="STXingkai" Foreground="Black"/> <Label Margin="0,65,240,0" Content="JAVA版本" HorizontalAlignment="Right" VerticalAlignment="Top" Width="100" Height="30" FontSize="20" Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="STXingkai" Foreground="Black"/>
<ComboBox Name="gamecombo" Height="30" Width="200" Margin="120,100,30,0" VerticalAlignment="Top"/> <ComboBox Name="gamecombo" Height="30" Width="200" FontSize="20" Margin="120,100,30,0" VerticalAlignment="Top"/>
<Label Margin="0,100,240,0" Content="游戏版本" HorizontalAlignment="Right" VerticalAlignment="Top" Width="100" Height="30" FontSize="20" Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="STXingkai" Foreground="Black"/> <Label Margin="0,100,240,0" Content="游戏版本" HorizontalAlignment="Right" VerticalAlignment="Top" Width="100" Height="30" FontSize="20" Background="{x:Null}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="STXingkai" Foreground="Black"/>
</Grid> </Grid>
</Grid> </Grid>
</Grid> </Grid>

View File

@ -17,6 +17,7 @@ using KMCCC.Tools;
using KMCCC.Modules; using KMCCC.Modules;
using KMCCC.Modules.JVersion; using KMCCC.Modules.JVersion;
using CityCraft; using CityCraft;
using System.IO;
namespace CTZLauncher namespace CTZLauncher
{ {
@ -33,8 +34,33 @@ namespace CTZLauncher
private void Window_Initialized(object sender, EventArgs e) private void Window_Initialized(object sender, EventArgs e)
{ {
if (Directory.Exists(".minecraft"))
launcher = LauncherCore.Create(".minecraft"); {
launcher = LauncherCore.Create(".minecraft");
launcher.GameLog += launcher_GameLog;
}
else
{
MessageBox.Show("请将启动器放置于.minecraft同级目录...");
this.Close();
}
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
foreach (var item in SystemTools.FindJava())
{
javacombo.Items.Add(item);
}
if (!javacombo.Items.IsEmpty)
javacombo.SelectedIndex = 0;
foreach (var item in launcher.GetVersions())
{
gamecombo.Items.Add(item.Id);
}
if (!gamecombo.Items.IsEmpty)
gamecombo.SelectedIndex = 0;
} }
private void Window_MouseMove(object sender, MouseEventArgs e) private void Window_MouseMove(object sender, MouseEventArgs e)
@ -81,45 +107,22 @@ namespace CTZLauncher
Console.WriteLine("服务器返回结果" + result); Console.WriteLine("服务器返回结果" + result);
} }
private void Image_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_MouseDown(object sender, MouseButtonEventArgs e)
{
}
private void StartGame_Click(object sender, RoutedEventArgs e) private void StartGame_Click(object sender, RoutedEventArgs e)
{ {
Console.WriteLine("StartGame"); Console.WriteLine("StartGame");
LaunchOptions option = new LaunchOptions();
foreach (var item in SystemTools.FindJava()) option.Mode = LaunchMode.MCLauncher;
{ option.MaxMemory = 2048;
Console.WriteLine("addjava"); option.Authenticator = new OfflineAuthenticator(username.Text); // offline
javacombo.Items.Add(item); option.Version = launcher.GetVersion(gamecombo.Text);
} launcher.JavaPath = javacombo.Text;
foreach (var item in launcher.GetVersions())
{
Console.WriteLine("addgame");
gamecombo.Items.Add(item.Id);
}
//LauncherCoreCreationOption option = new LauncherCoreCreationOption("E:\\JTB\\Project\\CTZLauncher\\CTZLauncher\\bin\\Debug\\.minecraft",SystemTools.FindJava().First());
//LauncherCore launcher = LauncherCore.Create(option);
//launcher.GameLog += launcher_GameLog;
//var result = launcher.Launch(new LaunchOptions
// {
// Version = option.VersionLocator.GetAllVersions().First(),
// Authenticator = new OfflineAuthenticator("Mr_jtb"), // offline
// //Authenticator = new YggdrasilLogin("*@*.*", "***", true), // online
// MaxMemory = 2048, // optional
// MinMemory = 2048, // optional
// Mode = LaunchMode.MCLauncher, // optional
// Size = new WindowSize { Height = 768, Width = 1280 } //optional
// }, (Action<MinecraftLaunchArguments>)(x => { })); // optional ( modify arguments before launching
//Console.WriteLine(result.ErrorMessage);
} }
void launcher_GameLog(LaunchHandle arg1, string arg2) void launcher_GameLog(LaunchHandle arg1, string arg2)
@ -127,5 +130,11 @@ namespace CTZLauncher
Console.WriteLine(arg2); Console.WriteLine(arg2);
} }
} }
} }