141 lines
3.8 KiB
C#
141 lines
3.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
using KMCCC.Authentication;
|
|
using KMCCC.Launcher;
|
|
using KMCCC.Tools;
|
|
using KMCCC.Modules;
|
|
using KMCCC.Modules.JVersion;
|
|
using CityCraft;
|
|
using System.IO;
|
|
|
|
namespace CTZLauncher
|
|
{
|
|
/// <summary>
|
|
/// MainWindow.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class MainWindow : Window
|
|
{
|
|
LauncherCore launcher = null;
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void Window_Initialized(object sender, EventArgs e)
|
|
{
|
|
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)
|
|
{
|
|
|
|
}
|
|
|
|
private void barclick_MouseDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
Label bar = (Label)sender;
|
|
MessageBox.Show(bar.Name);
|
|
switch (bar.Name.Substring(4))
|
|
{
|
|
case "l1":
|
|
break;
|
|
case "l2":
|
|
break;
|
|
case "l3":
|
|
break;
|
|
case "l4":
|
|
break;
|
|
case "r1":
|
|
break;
|
|
case "r2":
|
|
break;
|
|
case "r3":
|
|
break;
|
|
case "r4":
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
IAuthenticator auth = new YggdrasilLogin("jtb1@163.com", "jtb325325", false);
|
|
AuthenticationInfo result = auth.Do();
|
|
MessageBox.Show(result.UUID.ToString());
|
|
}
|
|
|
|
private void Login_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
HttpHelper http = new HttpHelper();
|
|
String result = http.Get("http://127.0.0.1:2000/isregistered?username=" + username.Text);
|
|
Console.WriteLine("服务器返回结果" + result);
|
|
}
|
|
|
|
private void outline_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
if (e.LeftButton == MouseButtonState.Pressed)
|
|
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(gamecombo.Text);
|
|
launcher.JavaPath = javacombo.Text;
|
|
|
|
}
|
|
|
|
void launcher_GameLog(LaunchHandle arg1, string arg2)
|
|
{
|
|
Console.WriteLine(arg2);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|