diff --git a/CTZLauncher/MainWindow.xaml b/CTZLauncher/MainWindow.xaml
index 8eaa597..95b69a8 100644
--- a/CTZLauncher/MainWindow.xaml
+++ b/CTZLauncher/MainWindow.xaml
@@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
ResizeMode = "NoResize"
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">
@@ -16,7 +16,7 @@
-
+
@@ -26,7 +26,7 @@
-
+
@@ -80,12 +80,15 @@
-
-
-
+
+
+
+
+
+
-
-
+
+
diff --git a/CTZLauncher/MainWindow.xaml.cs b/CTZLauncher/MainWindow.xaml.cs
index 7548570..520fac3 100644
--- a/CTZLauncher/MainWindow.xaml.cs
+++ b/CTZLauncher/MainWindow.xaml.cs
@@ -17,6 +17,7 @@ using KMCCC.Tools;
using KMCCC.Modules;
using KMCCC.Modules.JVersion;
using CityCraft;
+using System.IO;
namespace CTZLauncher
{
@@ -33,8 +34,33 @@ namespace CTZLauncher
private void Window_Initialized(object sender, EventArgs e)
{
-
- launcher = LauncherCore.Create(".minecraft");
+ if (Directory.Exists(".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)
@@ -81,45 +107,22 @@ namespace CTZLauncher
Console.WriteLine("服务器返回结果" + result);
}
- private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ private void outline_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
this.DragMove();
}
- private void StartGame_MouseDown(object sender, MouseButtonEventArgs e)
- {
-
- }
-
private void StartGame_Click(object sender, RoutedEventArgs e)
{
Console.WriteLine("StartGame");
-
- foreach (var item in SystemTools.FindJava())
- {
- Console.WriteLine("addjava");
- javacombo.Items.Add(item);
- }
- 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)(x => { })); // optional ( modify arguments before launching
- //Console.WriteLine(result.ErrorMessage);
+ LaunchOptions option = new LaunchOptions();
+ option.Mode = LaunchMode.MCLauncher;
+ option.MaxMemory = 2048;
+ option.Authenticator = new OfflineAuthenticator(username.Text); // offline
+ option.Version = launcher.GetVersion(gamecombo.Text);
+ launcher.JavaPath = javacombo.Text;
+
}
void launcher_GameLog(LaunchHandle arg1, string arg2)
@@ -127,5 +130,11 @@ namespace CTZLauncher
Console.WriteLine(arg2);
}
+
+
+
+
+
+
}
}