diff --git a/CTZLauncher.sln b/CTZLauncher.sln index 0c23154..aa6b21b 100644 --- a/CTZLauncher.sln +++ b/CTZLauncher.sln @@ -1,10 +1,8 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KMCCC", "KMCCC.Shared\KMCCC.csproj", "{52E292BB-FC7A-46E6-A8E8-B71E46FAF54E}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CTZLauncher", "CTZLauncher\CTZLauncher.csproj", "{EC25362D-5BA7-4CB3-BDA2-C575B9318086}" EndProject Global @@ -13,10 +11,6 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {52E292BB-FC7A-46E6-A8E8-B71E46FAF54E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {52E292BB-FC7A-46E6-A8E8-B71E46FAF54E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {52E292BB-FC7A-46E6-A8E8-B71E46FAF54E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {52E292BB-FC7A-46E6-A8E8-B71E46FAF54E}.Release|Any CPU.Build.0 = Release|Any CPU {EC25362D-5BA7-4CB3-BDA2-C575B9318086}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EC25362D-5BA7-4CB3-BDA2-C575B9318086}.Debug|Any CPU.Build.0 = Debug|Any CPU {EC25362D-5BA7-4CB3-BDA2-C575B9318086}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/KMCCC.Shared/Authentication/AuthenticationInfo.cs b/CTZLauncher/Authentication/AuthenticationInfo.cs similarity index 100% rename from KMCCC.Shared/Authentication/AuthenticationInfo.cs rename to CTZLauncher/Authentication/AuthenticationInfo.cs diff --git a/KMCCC.Shared/Authentication/IAuthenticator.cs b/CTZLauncher/Authentication/IAuthenticator.cs similarity index 100% rename from KMCCC.Shared/Authentication/IAuthenticator.cs rename to CTZLauncher/Authentication/IAuthenticator.cs diff --git a/KMCCC.Shared/Authentication/OfflineAuthenticator.cs b/CTZLauncher/Authentication/OfflineAuthenticator.cs similarity index 96% rename from KMCCC.Shared/Authentication/OfflineAuthenticator.cs rename to CTZLauncher/Authentication/OfflineAuthenticator.cs index d20cc92..0e546dd 100644 --- a/KMCCC.Shared/Authentication/OfflineAuthenticator.cs +++ b/CTZLauncher/Authentication/OfflineAuthenticator.cs @@ -1,70 +1,70 @@ -namespace KMCCC.Authentication -{ - #region - - using System; - using System.Linq; - using System.Threading; - using System.Threading.Tasks; - - #endregion - - /// - /// 离线验证器 - /// - public class OfflineAuthenticator : IAuthenticator - { - /// - /// 玩家的名字 - /// - public readonly string DisplayName; - - /// - /// 构造离线验证器 - /// - /// 玩家的名字 - public OfflineAuthenticator(string displayName) - { - DisplayName = displayName; - } - - /// - /// 标注离线验证器 - /// - public string Type - { - get { return "KMCCC.Offline"; } - } - - public AuthenticationInfo Do() - { - if (String.IsNullOrWhiteSpace(DisplayName)) - { - return new AuthenticationInfo - { - Error = "DisplayName不符合规范" - }; - } - if (DisplayName.Count(char.IsWhiteSpace) > 0) - { - return new AuthenticationInfo - { - Error = "DisplayName不符合规范" - }; - } - return new AuthenticationInfo - { - AccessToken = null, - DisplayName = DisplayName, - UUID = null, - Properties = "{}", - UserType = "Mojang" - }; - } - - public Task DoAsync(CancellationToken token) - { - return Task.Factory.StartNew((Func)Do, token); - } - } +namespace KMCCC.Authentication +{ + #region + + using System; + using System.Linq; + using System.Threading; + using System.Threading.Tasks; + + #endregion + + /// + /// 离线验证器 + /// + public class OfflineAuthenticator : IAuthenticator + { + /// + /// 玩家的名字 + /// + public readonly string DisplayName; + + /// + /// 构造离线验证器 + /// + /// 玩家的名字 + public OfflineAuthenticator(string displayName) + { + DisplayName = displayName; + } + + /// + /// 标注离线验证器 + /// + public string Type + { + get { return "KMCCC.Offline"; } + } + + public AuthenticationInfo Do() + { + if (String.IsNullOrWhiteSpace(DisplayName)) + { + return new AuthenticationInfo + { + Error = "DisplayName不符合规范" + }; + } + if (DisplayName.Count(char.IsWhiteSpace) > 0) + { + return new AuthenticationInfo + { + Error = "DisplayName不符合规范" + }; + } + return new AuthenticationInfo + { + AccessToken = null, + DisplayName = DisplayName, + UUID = null, + Properties = "{}", + UserType = "Mojang" + }; + } + + public Task DoAsync(CancellationToken token) + { + return Task.Factory.StartNew((Func)Do, token); + } + } } \ No newline at end of file diff --git a/KMCCC.Shared/Authentication/WarpedAuhenticator.cs b/CTZLauncher/Authentication/WarpedAuhenticator.cs similarity index 100% rename from KMCCC.Shared/Authentication/WarpedAuhenticator.cs rename to CTZLauncher/Authentication/WarpedAuhenticator.cs diff --git a/KMCCC.Shared/Authentication/Yggdrasil.cs b/CTZLauncher/Authentication/Yggdrasil.cs similarity index 100% rename from KMCCC.Shared/Authentication/Yggdrasil.cs rename to CTZLauncher/Authentication/Yggdrasil.cs diff --git a/CTZLauncher/CTZLauncher.csproj b/CTZLauncher/CTZLauncher.csproj index c749904..1b49e8b 100644 --- a/CTZLauncher/CTZLauncher.csproj +++ b/CTZLauncher/CTZLauncher.csproj @@ -41,6 +41,7 @@ + @@ -57,6 +58,9 @@ MSBuild:Compile Designer + + + MSBuild:Compile Designer @@ -65,15 +69,40 @@ App.xaml Code + + + + + + + + + + + + + + + + + + + + + + MainWindow.xaml Code + + + Code @@ -101,12 +130,6 @@ - - - {52e292bb-fc7a-46e6-a8e8-b71e46faf54e} - KMCCC - - diff --git a/KMCCC.Shared/Launcher/LaunchArguments.cs b/CTZLauncher/Launcher/LaunchArguments.cs similarity index 100% rename from KMCCC.Shared/Launcher/LaunchArguments.cs rename to CTZLauncher/Launcher/LaunchArguments.cs diff --git a/KMCCC.Shared/Launcher/LaunchHandle.cs b/CTZLauncher/Launcher/LaunchHandle.cs similarity index 100% rename from KMCCC.Shared/Launcher/LaunchHandle.cs rename to CTZLauncher/Launcher/LaunchHandle.cs diff --git a/KMCCC.Shared/Launcher/LaunchHandleExtensions.cs b/CTZLauncher/Launcher/LaunchHandleExtensions.cs similarity index 100% rename from KMCCC.Shared/Launcher/LaunchHandleExtensions.cs rename to CTZLauncher/Launcher/LaunchHandleExtensions.cs diff --git a/KMCCC.Shared/Launcher/LaunchMode.cs b/CTZLauncher/Launcher/LaunchMode.cs similarity index 100% rename from KMCCC.Shared/Launcher/LaunchMode.cs rename to CTZLauncher/Launcher/LaunchMode.cs diff --git a/KMCCC.Shared/Launcher/LauncherCore.cs b/CTZLauncher/Launcher/LauncherCore.cs similarity index 100% rename from KMCCC.Shared/Launcher/LauncherCore.cs rename to CTZLauncher/Launcher/LauncherCore.cs diff --git a/KMCCC.Shared/Launcher/LauncherCoreInternal.cs b/CTZLauncher/Launcher/LauncherCoreInternal.cs similarity index 97% rename from KMCCC.Shared/Launcher/LauncherCoreInternal.cs rename to CTZLauncher/Launcher/LauncherCoreInternal.cs index 5187fa4..2dbcce1 100644 --- a/KMCCC.Shared/Launcher/LauncherCoreInternal.cs +++ b/CTZLauncher/Launcher/LauncherCoreInternal.cs @@ -1,217 +1,217 @@ -namespace KMCCC.Launcher -{ - #region - - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.IO; - using System.Linq; - using System.Threading.Tasks; - using Tools; - - #endregion - - partial class LauncherCore - { - internal object Locker = new object(); - - private LaunchResult GenerateArguments(LaunchOptions options, ref MinecraftLaunchArguments args) - { - try - { - var authentication = options.Authenticator.Do(); - if (!string.IsNullOrWhiteSpace(authentication.Error)) - return new LaunchResult - { - Success = false, - ErrorType = ErrorType.AuthenticationFailed, - ErrorMessage = "验证错误: " + authentication.Error - }; - args.CGCEnabled = true; - args.MainClass = options.Version.MainClass; - args.MaxMemory = options.MaxMemory; - args.MinMemory = options.MinMemory; - args.NativePath = GameRootPath + options.Version.Id + @"\\" + options.Version.Id + @"-natives"; - foreach (var native in options.Version.Natives) - { - var exp = ZipTools.UnzipFile(this.GetNativePath(native), args.NativePath, native.Options); - if (exp == null) - { - continue; - } - return new LaunchResult - { - Success = false, - ErrorType = ErrorType.UncompressingFailed, - ErrorMessage = string.Format("解压错误: {0}:{1}:{2}", native.NS, native.Name, native.Version), - Exception = exp - }; - } - args.Server = options.Server; - args.Size = options.Size; - args.Libraries = options.Version.Libraries.Select(this.GetLibPath).ToList(); - args.Libraries.Add(this.GetVersionJarPath(options.Version.JarId)); - args.MinecraftArguments = options.Version.MinecraftArguments; - - args.Tokens.Add("auth_access_token", authentication.AccessToken.GoString()); - args.Tokens.Add("auth_session", authentication.AccessToken.GoString()); - args.Tokens.Add("auth_player_name", authentication.DisplayName); - args.Tokens.Add("version_name", options.Version.Id); - args.Tokens.Add("game_directory", "."); - args.Tokens.Add("game_assets", "assets"); - args.Tokens.Add("assets_root", "assets"); - args.Tokens.Add("assets_index_name", options.Version.Assets); - args.Tokens.Add("auth_uuid", authentication.UUID.GoString()); - args.Tokens.Add("user_properties", authentication.Properties); - args.Tokens.Add("user_type", authentication.UserType); - - args.AdvencedArguments = new List { "-Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true" }; - - args.Authentication = authentication; - args.Version = options.Version; - if (options.Mode != null) - { - options.Mode.Operate(this, args); - } - return null; - } - catch (Exception exp) - { - Console.WriteLine(exp.Message); - Console.WriteLine(exp.Source); - Console.WriteLine(exp.StackTrace); - return new LaunchResult { Success = false, ErrorType = ErrorType.Unknown, ErrorMessage = "在生成参数时发生了意外的错误", Exception = exp }; - } - } - - internal LaunchResult LaunchInternal(LaunchOptions options, params Action[] argumentsOperators) - { - lock (Locker) - { - if (!File.Exists(JavaPath)) - { - return new LaunchResult { Success = false, ErrorType = ErrorType.NoJAVA, ErrorMessage = "指定的JAVA位置不存在" }; - } - CurrentCode = Random.Next(); - var args = new MinecraftLaunchArguments(); - var result = GenerateArguments(options, ref args); - if (result != null) - { - return result; - } - if (argumentsOperators == null) return LaunchGame(args); - foreach (var opt in argumentsOperators) - { - try - { - if (opt != null) - { - opt(args); - } - } - catch (Exception exp) - { - return new LaunchResult { Success = false, ErrorType = ErrorType.OperatorException, ErrorMessage = "指定的操作器引发了异常", Exception = exp }; - } - } - return LaunchGame(args); - } - } - - private LaunchResult LaunchGame(MinecraftLaunchArguments args) - { - Console.WriteLine(args.ToArguments()); - try - { - var handle = new LaunchHandle(args.Authentication) - { - Code = CurrentCode, - Core = this, - Arguments = args, - Process = Process.Start(new ProcessStartInfo(JavaPath) - { - Arguments = args.ToArguments(), - UseShellExecute = false, - WorkingDirectory = GameRootPath, - RedirectStandardError = true, - RedirectStandardOutput = true - }) - }; - handle.Work(); - Task.Factory.StartNew(handle.Process.WaitForExit).ContinueWith(t => Exit(handle, handle.Process.ExitCode)); - return new LaunchResult { Success = true, Handle = handle }; - } - catch (Exception exp) - { - return new LaunchResult { Success = false, ErrorType = ErrorType.Unknown, ErrorMessage = "启动时出现了异常", Exception = exp }; - } - } - - #region 复制文件夹 - - public void CopyVersionDirectory(string directoryName, string versionId) - { - CopyDirectory(string.Format(@"{0}\versions\{2}\{1}", GameRootPath, directoryName, versionId), - string.Format(@"{0}\{1}", GameRootPath, directoryName)); - } - - public void CopyDirectory(string source, string target) - { - var code = CurrentCode; - if (!Directory.Exists(source)) return; - if (Directory.Exists(target)) - { - Directory.Delete(target, true); - } - UsefulTools.Dircopy(source, target); - Action handler = null; - handler = (handle, c) => - { - if (handle.Code == code) - { - Directory.Delete(source, true); - UsefulTools.Dircopy(target, source); - Directory.Delete(target, true); - } - GameExit -= handler; - }; - GameExit += handler; - } - - public void CopyVersionDirectories(string ver) - { - var root = string.Format(@"{0}\versions\{1}\moddir", GameRootPath, ver); - if (!Directory.Exists(root)) - { - return; - } - foreach (var dir in new DirectoryInfo(root).EnumerateDirectories()) - { - CopyDirectory(dir.FullName, string.Format(@"{0}\{1}", GameRootPath, dir.Name)); - } - } - - #endregion - - #region 事件 - - internal void Log(LaunchHandle handle, string line) - { - if (GameLog != null) - { - GameLog(handle, line); - } - } - - internal void Exit(LaunchHandle handle, int code) - { - if (GameExit != null) - { - GameExit(handle, code); - } - } - - #endregion - } +namespace KMCCC.Launcher +{ + #region + + using System; + using System.Collections.Generic; + using System.Diagnostics; + using System.IO; + using System.Linq; + using System.Threading.Tasks; + using Tools; + + #endregion + + partial class LauncherCore + { + internal object Locker = new object(); + + private LaunchResult GenerateArguments(LaunchOptions options, ref MinecraftLaunchArguments args) + { + try + { + var authentication = options.Authenticator.Do(); + if (!string.IsNullOrWhiteSpace(authentication.Error)) + return new LaunchResult + { + Success = false, + ErrorType = ErrorType.AuthenticationFailed, + ErrorMessage = "验证错误: " + authentication.Error + }; + args.CGCEnabled = true; + args.MainClass = options.Version.MainClass; + args.MaxMemory = options.MaxMemory; + args.MinMemory = options.MinMemory; + args.NativePath = GameRootPath + options.Version.Id + @"\\" + options.Version.Id + @"-natives"; + foreach (var native in options.Version.Natives) + { + var exp = ZipTools.UnzipFile(this.GetNativePath(native), args.NativePath, native.Options); + if (exp == null) + { + continue; + } + return new LaunchResult + { + Success = false, + ErrorType = ErrorType.UncompressingFailed, + ErrorMessage = string.Format("解压错误: {0}:{1}:{2}", native.NS, native.Name, native.Version), + Exception = exp + }; + } + args.Server = options.Server; + args.Size = options.Size; + args.Libraries = options.Version.Libraries.Select(this.GetLibPath).ToList(); + args.Libraries.Add(this.GetVersionJarPath(options.Version.JarId)); + args.MinecraftArguments = options.Version.MinecraftArguments; + + args.Tokens.Add("auth_access_token", authentication.AccessToken.GoString()); + args.Tokens.Add("auth_session", authentication.AccessToken.GoString()); + args.Tokens.Add("auth_player_name", authentication.DisplayName); + args.Tokens.Add("version_name", options.Version.Id); + args.Tokens.Add("game_directory", "."); + args.Tokens.Add("game_assets", "assets"); + args.Tokens.Add("assets_root", "assets"); + args.Tokens.Add("assets_index_name", options.Version.Assets); + args.Tokens.Add("auth_uuid", authentication.UUID.GoString()); + args.Tokens.Add("user_properties", authentication.Properties); + args.Tokens.Add("user_type", authentication.UserType); + + args.AdvencedArguments = new List { "-Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true" }; + + args.Authentication = authentication; + args.Version = options.Version; + if (options.Mode != null) + { + options.Mode.Operate(this, args); + } + return null; + } + catch (Exception exp) + { + Console.WriteLine(exp.Message); + Console.WriteLine(exp.Source); + Console.WriteLine(exp.StackTrace); + return new LaunchResult { Success = false, ErrorType = ErrorType.Unknown, ErrorMessage = "在生成参数时发生了意外的错误", Exception = exp }; + } + } + + internal LaunchResult LaunchInternal(LaunchOptions options, params Action[] argumentsOperators) + { + lock (Locker) + { + if (!File.Exists(JavaPath)) + { + return new LaunchResult { Success = false, ErrorType = ErrorType.NoJAVA, ErrorMessage = "指定的JAVA位置不存在" }; + } + CurrentCode = Random.Next(); + var args = new MinecraftLaunchArguments(); + var result = GenerateArguments(options, ref args); + if (result != null) + { + return result; + } + if (argumentsOperators == null) return LaunchGame(args); + foreach (var opt in argumentsOperators) + { + try + { + if (opt != null) + { + opt(args); + } + } + catch (Exception exp) + { + return new LaunchResult { Success = false, ErrorType = ErrorType.OperatorException, ErrorMessage = "指定的操作器引发了异常", Exception = exp }; + } + } + return LaunchGame(args); + } + } + + private LaunchResult LaunchGame(MinecraftLaunchArguments args) + { + Console.WriteLine(args.ToArguments()); + try + { + var handle = new LaunchHandle(args.Authentication) + { + Code = CurrentCode, + Core = this, + Arguments = args, + Process = Process.Start(new ProcessStartInfo(JavaPath) + { + Arguments = args.ToArguments(), + UseShellExecute = false, + WorkingDirectory = GameRootPath, + RedirectStandardError = true, + RedirectStandardOutput = true + }) + }; + handle.Work(); + Task.Factory.StartNew(handle.Process.WaitForExit).ContinueWith(t => Exit(handle, handle.Process.ExitCode)); + return new LaunchResult { Success = true, Handle = handle }; + } + catch (Exception exp) + { + return new LaunchResult { Success = false, ErrorType = ErrorType.Unknown, ErrorMessage = "启动时出现了异常", Exception = exp }; + } + } + + #region 复制文件夹 + + public void CopyVersionDirectory(string directoryName, string versionId) + { + CopyDirectory(string.Format(@"{0}\versions\{2}\{1}", GameRootPath, directoryName, versionId), + string.Format(@"{0}\{1}", GameRootPath, directoryName)); + } + + public void CopyDirectory(string source, string target) + { + var code = CurrentCode; + if (!Directory.Exists(source)) return; + if (Directory.Exists(target)) + { + Directory.Delete(target, true); + } + UsefulTools.Dircopy(source, target); + Action handler = null; + handler = (handle, c) => + { + if (handle.Code == code) + { + Directory.Delete(source, true); + UsefulTools.Dircopy(target, source); + Directory.Delete(target, true); + } + GameExit -= handler; + }; + GameExit += handler; + } + + public void CopyVersionDirectories(string ver) + { + var root = string.Format(@"{0}\versions\{1}\moddir", GameRootPath, ver); + if (!Directory.Exists(root)) + { + return; + } + foreach (var dir in new DirectoryInfo(root).EnumerateDirectories()) + { + CopyDirectory(dir.FullName, string.Format(@"{0}\{1}", GameRootPath, dir.Name)); + } + } + + #endregion + + #region 事件 + + internal void Log(LaunchHandle handle, string line) + { + if (GameLog != null) + { + GameLog(handle, line); + } + } + + internal void Exit(LaunchHandle handle, int code) + { + if (GameExit != null) + { + GameExit(handle, code); + } + } + + #endregion + } } \ No newline at end of file diff --git a/KMCCC.Shared/Launcher/Version.cs b/CTZLauncher/Launcher/Version.cs similarity index 100% rename from KMCCC.Shared/Launcher/Version.cs rename to CTZLauncher/Launcher/Version.cs diff --git a/KMCCC.Shared/LitJson/IJsonWrapper.cs b/CTZLauncher/LitJson/IJsonWrapper.cs similarity index 100% rename from KMCCC.Shared/LitJson/IJsonWrapper.cs rename to CTZLauncher/LitJson/IJsonWrapper.cs diff --git a/KMCCC.Shared/LitJson/JsonData.cs b/CTZLauncher/LitJson/JsonData.cs similarity index 100% rename from KMCCC.Shared/LitJson/JsonData.cs rename to CTZLauncher/LitJson/JsonData.cs diff --git a/KMCCC.Shared/LitJson/JsonException.cs b/CTZLauncher/LitJson/JsonException.cs similarity index 100% rename from KMCCC.Shared/LitJson/JsonException.cs rename to CTZLauncher/LitJson/JsonException.cs diff --git a/KMCCC.Shared/LitJson/JsonMapper.cs b/CTZLauncher/LitJson/JsonMapper.cs similarity index 100% rename from KMCCC.Shared/LitJson/JsonMapper.cs rename to CTZLauncher/LitJson/JsonMapper.cs diff --git a/KMCCC.Shared/LitJson/JsonMockWrapper.cs b/CTZLauncher/LitJson/JsonMockWrapper.cs similarity index 100% rename from KMCCC.Shared/LitJson/JsonMockWrapper.cs rename to CTZLauncher/LitJson/JsonMockWrapper.cs diff --git a/KMCCC.Shared/LitJson/JsonPropertyName.cs b/CTZLauncher/LitJson/JsonPropertyName.cs similarity index 100% rename from KMCCC.Shared/LitJson/JsonPropertyName.cs rename to CTZLauncher/LitJson/JsonPropertyName.cs diff --git a/KMCCC.Shared/LitJson/JsonReader.cs b/CTZLauncher/LitJson/JsonReader.cs similarity index 100% rename from KMCCC.Shared/LitJson/JsonReader.cs rename to CTZLauncher/LitJson/JsonReader.cs diff --git a/KMCCC.Shared/LitJson/JsonWriter.cs b/CTZLauncher/LitJson/JsonWriter.cs similarity index 100% rename from KMCCC.Shared/LitJson/JsonWriter.cs rename to CTZLauncher/LitJson/JsonWriter.cs diff --git a/KMCCC.Shared/LitJson/Lexer.cs b/CTZLauncher/LitJson/Lexer.cs similarity index 100% rename from KMCCC.Shared/LitJson/Lexer.cs rename to CTZLauncher/LitJson/Lexer.cs diff --git a/KMCCC.Shared/LitJson/ParserToken.cs b/CTZLauncher/LitJson/ParserToken.cs similarity index 100% rename from KMCCC.Shared/LitJson/ParserToken.cs rename to CTZLauncher/LitJson/ParserToken.cs diff --git a/CTZLauncher/MainWindow.xaml.cs b/CTZLauncher/MainWindow.xaml.cs index ec2bc9f..265c3c0 100644 --- a/CTZLauncher/MainWindow.xaml.cs +++ b/CTZLauncher/MainWindow.xaml.cs @@ -1,190 +1,190 @@ -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; -using System.Windows.Threading; - -namespace CTZLauncher -{ - /// - /// MainWindow.xaml 的交互逻辑 - /// - 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 - { - Directory.CreateDirectory(".minecraft"); - } - - } - - 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; - maxmem.Text = "2048"; - } - - 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(); - http.Send(HttpMethod.GET, "http://127.0.0.1:2000/isregistered?username=" + username.Text); - while (http.readyState != HttpReadyState.完成) - { - DoEvent(); - } - String result = http.responseBody; - Console.WriteLine("服务器返回结果" + result); - } - - - /// - /// 模仿C#的Application.Doevent函数。可以适当添加try catch 模块 - /// - 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) - { - 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 = int.Parse(maxmem.Text); - option.Authenticator = new OfflineAuthenticator(username.Text); // offline - option.Version = launcher.GetVersion(gamecombo.Text); - launcher.JavaPath = javacombo.Text; - launcher.Launch(option); - } - - void launcher_GameLog(LaunchHandle arg1, string arg2) - { - Console.WriteLine(arg2); - } - - private void close_Click(object sender, RoutedEventArgs e) - { - - this.Close(); - } - - private void maxmem_TextChanged(object sender, TextChangedEventArgs e) - { - //屏蔽中文输入和非法字符粘贴输入 - TextBox textBox = sender as TextBox; - TextChange[] change = new TextChange[e.Changes.Count]; - e.Changes.CopyTo(change, 0); - - int offset = change[0].Offset; - if (change[0].AddedLength > 0) - { - double num = 0; - if (!Double.TryParse(textBox.Text, out num)) - { - textBox.Text = textBox.Text.Remove(offset, change[0].AddedLength); - textBox.Select(offset, 0); - } - } - } - - private void register_Click(object sender, RoutedEventArgs e) - { - if (username.Text.Length == 0 || password.Text.Length == 0) - { - MessageBox.Show("请输入账号密码!"); - return; - } - - } - } -} +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; +using System.Windows.Threading; + +namespace CTZLauncher +{ + /// + /// MainWindow.xaml 的交互逻辑 + /// + 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 + { + Directory.CreateDirectory(".minecraft"); + } + + } + + 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; + maxmem.Text = "2048"; + } + + 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(); + http.Send(HttpMethod.GET, "http://127.0.0.1:2000/isregistered?username=" + username.Text); + while (http.readyState != HttpReadyState.完成) + { + DoEvent(); + } + String result = http.responseBody; + Console.WriteLine("服务器返回结果" + result); + } + + + /// + /// 模仿C#的Application.Doevent函数。可以适当添加try catch 模块 + /// + 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) + { + 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 = int.Parse(maxmem.Text); + option.Authenticator = new OfflineAuthenticator(username.Text); // offline + option.Version = launcher.GetVersion(gamecombo.Text); + launcher.JavaPath = javacombo.Text; + launcher.Launch(option); + } + + void launcher_GameLog(LaunchHandle arg1, string arg2) + { + Console.WriteLine(arg2); + } + + private void close_Click(object sender, RoutedEventArgs e) + { + + this.Close(); + } + + private void maxmem_TextChanged(object sender, TextChangedEventArgs e) + { + //屏蔽中文输入和非法字符粘贴输入 + TextBox textBox = sender as TextBox; + TextChange[] change = new TextChange[e.Changes.Count]; + e.Changes.CopyTo(change, 0); + + int offset = change[0].Offset; + if (change[0].AddedLength > 0) + { + double num = 0; + if (!Double.TryParse(textBox.Text, out num)) + { + textBox.Text = textBox.Text.Remove(offset, change[0].AddedLength); + textBox.Select(offset, 0); + } + } + } + + private void register_Click(object sender, RoutedEventArgs e) + { + if (username.Text.Length == 0 || password.Text.Length == 0) + { + MessageBox.Show("请输入账号密码!"); + return; + } + + } + } +} diff --git a/KMCCC.Shared/Modules/JVersion/JVersion.cs b/CTZLauncher/Modules/JVersion/JVersion.cs similarity index 100% rename from KMCCC.Shared/Modules/JVersion/JVersion.cs rename to CTZLauncher/Modules/JVersion/JVersion.cs diff --git a/KMCCC.Shared/Modules/JVersion/JVersionLocator.cs b/CTZLauncher/Modules/JVersion/JVersionLocator.cs similarity index 100% rename from KMCCC.Shared/Modules/JVersion/JVersionLocator.cs rename to CTZLauncher/Modules/JVersion/JVersionLocator.cs diff --git a/KMCCC.Shared/Modules/Yggdrasil/YggdrasilClient.cs b/CTZLauncher/Modules/Yggdrasil/YggdrasilClient.cs similarity index 100% rename from KMCCC.Shared/Modules/Yggdrasil/YggdrasilClient.cs rename to CTZLauncher/Modules/Yggdrasil/YggdrasilClient.cs diff --git a/KMCCC.Shared/Tools/SystemTools.cs b/CTZLauncher/Tools/SystemTools.cs similarity index 100% rename from KMCCC.Shared/Tools/SystemTools.cs rename to CTZLauncher/Tools/SystemTools.cs diff --git a/KMCCC.Shared/Tools/UsefulTools.cs b/CTZLauncher/Tools/UsefulTools.cs similarity index 100% rename from KMCCC.Shared/Tools/UsefulTools.cs rename to CTZLauncher/Tools/UsefulTools.cs diff --git a/KMCCC.Shared/Tools/ZipTools.cs b/CTZLauncher/Tools/ZipTools.cs similarity index 100% rename from KMCCC.Shared/Tools/ZipTools.cs rename to CTZLauncher/Tools/ZipTools.cs