From 90526521225bace2fc6d264fcecba4a743cc3e4d Mon Sep 17 00:00:00 2001 From: Crudelis Date: Sun, 9 Oct 2022 12:27:47 +0900 Subject: [PATCH] - Recovery --- CommonLibrary/DataModel.cs | 19 +- CommonLibrary/Extensions.cs | 4 + CommonLibrary/XMLSystem.cs | 2 +- Mitria_Argument_Creater/App.config | 6 + Mitria_Argument_Creater/MainForm.Designer.cs | 107 +++++++ Mitria_Argument_Creater/MainForm.cs | 31 +++ Mitria_Argument_Creater/MainForm.resx | 120 ++++++++ .../Mitria_Argument_Creater.csproj | 83 ++++++ Mitria_Argument_Creater/Program.cs | 22 ++ .../Properties/AssemblyInfo.cs | 36 +++ .../Properties/Resources.Designer.cs | 71 +++++ .../Properties/Resources.resx | 117 ++++++++ .../Properties/Settings.Designer.cs | 30 ++ .../Properties/Settings.settings | 7 + Mitria_Minecraft_Launcher/AuditFile.cs | 4 +- Mitria_Minecraft_Launcher/DataModel.cs | 13 +- .../LauncherForm.Designer.cs | 39 ++- Mitria_Minecraft_Launcher/LauncherForm.cs | 43 ++- .../LauncherSetupForm.Designer.cs | 16 +- .../LauncherSetupForm.cs | 12 +- .../Mitria_Minecraft_Launcher.csproj | 1 + Mitria_Minecraft_Launcher/Program.cs | 78 +++++- Mitria_Minecraft_Launcher/Settings.cs | 93 +++++-- .../Updater/GameUpdateManager.cs | 61 ++-- .../Updater/LauncherUpdate.cs | 2 +- Mitria_Minecraft_Project.sln | 6 + Mitria_Minecraft_Updater/Extensions.cs | 2 +- .../Mitria_Minecraft_Updater.csproj | 1 + Mitria_Minecraft_Updater/Program.cs | 260 +++++++++++------- Mitria_Minecraft_Updater/Settings.cs | 45 +-- 30 files changed, 1112 insertions(+), 219 deletions(-) create mode 100644 Mitria_Argument_Creater/App.config create mode 100644 Mitria_Argument_Creater/MainForm.Designer.cs create mode 100644 Mitria_Argument_Creater/MainForm.cs create mode 100644 Mitria_Argument_Creater/MainForm.resx create mode 100644 Mitria_Argument_Creater/Mitria_Argument_Creater.csproj create mode 100644 Mitria_Argument_Creater/Program.cs create mode 100644 Mitria_Argument_Creater/Properties/AssemblyInfo.cs create mode 100644 Mitria_Argument_Creater/Properties/Resources.Designer.cs create mode 100644 Mitria_Argument_Creater/Properties/Resources.resx create mode 100644 Mitria_Argument_Creater/Properties/Settings.Designer.cs create mode 100644 Mitria_Argument_Creater/Properties/Settings.settings diff --git a/CommonLibrary/DataModel.cs b/CommonLibrary/DataModel.cs index 3d336c5..8a692d5 100644 --- a/CommonLibrary/DataModel.cs +++ b/CommonLibrary/DataModel.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace CommonLibrary { @@ -14,6 +11,20 @@ namespace CommonLibrary public string LauncherFileName { get; set; } // 런처 파일명 } + [Serializable] + public struct ServerInformation // 서버데이터 정보 + { + public List Servers { get; set; } + + public struct Server + { + public string ServerName { get; set; } // Majesty + public string ServerFullName { get; set; } // Mitria Minecraft Majesty Server + public string Explain { get; set; } // 서버설명 + public string BaseArgument { get; set; } // 기본 Argument + } + } + [Serializable] public struct DataPatchInformation // 패치데이터 정보 { @@ -40,4 +51,4 @@ namespace CommonLibrary public long FileSize { get; set; } public string HashCode { get; set; } } -} +} \ No newline at end of file diff --git a/CommonLibrary/Extensions.cs b/CommonLibrary/Extensions.cs index cf30a0c..fbb99d4 100644 --- a/CommonLibrary/Extensions.cs +++ b/CommonLibrary/Extensions.cs @@ -53,5 +53,9 @@ namespace CommonLibrary } return path.ToString(); } + public static bool IsDefault(ref this T data) where T : struct + { + return default(T).Equals(data); + } } } \ No newline at end of file diff --git a/CommonLibrary/XMLSystem.cs b/CommonLibrary/XMLSystem.cs index 92f22be..fce0d71 100644 --- a/CommonLibrary/XMLSystem.cs +++ b/CommonLibrary/XMLSystem.cs @@ -4,7 +4,7 @@ using System.Xml.Serialization; namespace CommonLibrary { - public static class XMLSystem + public static class XmlSystem { public static bool Save(string path, T data) where T : struct { diff --git a/Mitria_Argument_Creater/App.config b/Mitria_Argument_Creater/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/Mitria_Argument_Creater/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Mitria_Argument_Creater/MainForm.Designer.cs b/Mitria_Argument_Creater/MainForm.Designer.cs new file mode 100644 index 0000000..d9cf915 --- /dev/null +++ b/Mitria_Argument_Creater/MainForm.Designer.cs @@ -0,0 +1,107 @@ +namespace Mitria_Argument_Creater +{ + partial class MainForm + { + /// + /// 필수 디자이너 변수입니다. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 사용 중인 모든 리소스를 정리합니다. + /// + /// 관리되는 리소스를 삭제해야 하면 true이고, 그렇지 않으면 false입니다. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form 디자이너에서 생성한 코드 + + /// + /// 디자이너 지원에 필요한 메서드입니다. + /// 이 메서드의 내용을 코드 편집기로 수정하지 마세요. + /// + private void InitializeComponent() + { + this.textBox1 = new System.Windows.Forms.TextBox(); + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.listView_Version = new System.Windows.Forms.ListView(); + this.textBox_ResultArgument = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(50, 50); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(450, 21); + this.textBox1.TabIndex = 0; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(520, 50); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(100, 23); + this.button1.TabIndex = 1; + this.button1.Text = "button1"; + this.button1.UseVisualStyleBackColor = true; + // + // button2 + // + this.button2.Location = new System.Drawing.Point(520, 100); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(100, 97); + this.button2.TabIndex = 3; + this.button2.Text = "button2"; + this.button2.UseVisualStyleBackColor = true; + // + // listView_Version + // + this.listView_Version.HideSelection = false; + this.listView_Version.Location = new System.Drawing.Point(50, 100); + this.listView_Version.Name = "listView_Version"; + this.listView_Version.Size = new System.Drawing.Size(450, 97); + this.listView_Version.TabIndex = 4; + this.listView_Version.UseCompatibleStateImageBehavior = false; + this.listView_Version.View = System.Windows.Forms.View.List; + // + // textBox_ResultArgument + // + this.textBox_ResultArgument.Location = new System.Drawing.Point(50, 231); + this.textBox_ResultArgument.Name = "textBox_ResultArgument"; + this.textBox_ResultArgument.Size = new System.Drawing.Size(100, 21); + this.textBox_ResultArgument.TabIndex = 5; + // + // MainForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.textBox_ResultArgument); + this.Controls.Add(this.listView_Version); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); + this.Controls.Add(this.textBox1); + this.Name = "MainForm"; + this.Text = "Form1"; + this.Load += new System.EventHandler(this.MainForm_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.ListView listView_Version; + private System.Windows.Forms.TextBox textBox_ResultArgument; + } +} + diff --git a/Mitria_Argument_Creater/MainForm.cs b/Mitria_Argument_Creater/MainForm.cs new file mode 100644 index 0000000..d1faaf7 --- /dev/null +++ b/Mitria_Argument_Creater/MainForm.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Mitria_Argument_Creater +{ + public partial class MainForm : Form + { + public MainForm() + { + InitializeComponent(); + } + + private void MainForm_Load(object sender, EventArgs e) + { + textBox1.Text = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),".minecraft"); + listView_Version.Items.Add("1"); + listView_Version.Items.Add("1"); + listView_Version.Items.Add("1"); + listView_Version.Items.Add("1"); + listView_Version.Items.Add("1"); + + } + } +} diff --git a/Mitria_Argument_Creater/MainForm.resx b/Mitria_Argument_Creater/MainForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Mitria_Argument_Creater/MainForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Mitria_Argument_Creater/Mitria_Argument_Creater.csproj b/Mitria_Argument_Creater/Mitria_Argument_Creater.csproj new file mode 100644 index 0000000..fea12b8 --- /dev/null +++ b/Mitria_Argument_Creater/Mitria_Argument_Creater.csproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + {52250463-A90A-4DF7-B17D-A08940858305} + WinExe + Mitria_Argument_Creater + Mitria_Argument_Creater + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + MainForm.cs + + + + + MainForm.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + \ No newline at end of file diff --git a/Mitria_Argument_Creater/Program.cs b/Mitria_Argument_Creater/Program.cs new file mode 100644 index 0000000..3f4c96d --- /dev/null +++ b/Mitria_Argument_Creater/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Mitria_Argument_Creater +{ + internal static class Program + { + /// + /// 해당 애플리케이션의 주 진입점입니다. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new MainForm()); + } + } +} diff --git a/Mitria_Argument_Creater/Properties/AssemblyInfo.cs b/Mitria_Argument_Creater/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..bc04086 --- /dev/null +++ b/Mitria_Argument_Creater/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("Mitria_Argument_Creater")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Mitria_Argument_Creater")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("52250463-a90a-4df7-b17d-a08940858305")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를 +// 기본값으로 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Mitria_Argument_Creater/Properties/Resources.Designer.cs b/Mitria_Argument_Creater/Properties/Resources.Designer.cs new file mode 100644 index 0000000..8585ba1 --- /dev/null +++ b/Mitria_Argument_Creater/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 도구를 사용하여 생성되었습니다. +// 런타임 버전:4.0.30319.42000 +// +// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면 +// 이러한 변경 내용이 손실됩니다. +// +//------------------------------------------------------------------------------ + +namespace Mitria_Argument_Creater.Properties +{ + + + /// + /// 지역화된 문자열 등을 찾기 위한 강력한 형식의 리소스 클래스입니다. + /// + // 이 클래스는 ResGen 또는 Visual Studio와 같은 도구를 통해 StronglyTypedResourceBuilder + // 클래스에서 자동으로 생성되었습니다. + // 멤버를 추가하거나 제거하려면 .ResX 파일을 편집한 다음 /str 옵션을 사용하여 + // ResGen을 다시 실행하거나 VS 프로젝트를 다시 빌드하십시오. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// 이 클래스에서 사용하는 캐시된 ResourceManager 인스턴스를 반환합니다. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Mitria_Argument_Creater.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 이 강력한 형식의 리소스 클래스를 사용하여 모든 리소스 조회에 대해 현재 스레드의 CurrentUICulture 속성을 + /// 재정의합니다. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/Mitria_Argument_Creater/Properties/Resources.resx b/Mitria_Argument_Creater/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/Mitria_Argument_Creater/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Mitria_Argument_Creater/Properties/Settings.Designer.cs b/Mitria_Argument_Creater/Properties/Settings.Designer.cs new file mode 100644 index 0000000..07dea68 --- /dev/null +++ b/Mitria_Argument_Creater/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Mitria_Argument_Creater.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Mitria_Argument_Creater/Properties/Settings.settings b/Mitria_Argument_Creater/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/Mitria_Argument_Creater/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Mitria_Minecraft_Launcher/AuditFile.cs b/Mitria_Minecraft_Launcher/AuditFile.cs index 63a905f..7db9106 100644 --- a/Mitria_Minecraft_Launcher/AuditFile.cs +++ b/Mitria_Minecraft_Launcher/AuditFile.cs @@ -31,7 +31,7 @@ namespace Mitria_Minecraft_Launcher List directoryInfos = new List(); foreach (string directory in directorys) { - System.IO.DirectoryInfo directoryInfo = new DirectoryInfo(CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, directory)); + System.IO.DirectoryInfo directoryInfo = new DirectoryInfo(CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory,Settings.NowProfile.ServerName, directory)); directoryInfos.Add(directoryInfo); } return GetLocalFileList(directoryInfos); @@ -52,7 +52,7 @@ namespace Mitria_Minecraft_Launcher foreach (var file in files) { FileDetail fileDetail = new FileDetail(); - fileDetail.Directory = file.DirectoryName.Replace(Settings.UserLauncherConfig.GameDirectory + "\\", "").Replace("\\", "/"); + fileDetail.Directory = file.DirectoryName.Replace(CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, Settings.NowProfile.ServerName) + "\\", "").Replace("\\", "/"); fileDetail.FileName = file.Name; fileDetail.FileSize = file.Length; fileDetail.HashCode = GetFileHash(file); diff --git a/Mitria_Minecraft_Launcher/DataModel.cs b/Mitria_Minecraft_Launcher/DataModel.cs index 0ba6c29..0b21c29 100644 --- a/Mitria_Minecraft_Launcher/DataModel.cs +++ b/Mitria_Minecraft_Launcher/DataModel.cs @@ -9,11 +9,18 @@ namespace Mitria_Minecraft_Launcher public struct LauncherConfig { public string MinecraftPlayerName { get; set; } - public string Argument { get; set; } public string GameDirectory { get; set; } public bool ShellView { get; set; } - public string RuntimeVersion { get; set; } - public List CustomData { get; set; } + public string LastServerName { get; set; } + public List Profiles { get; set; } + public struct Profile + { + public string ServerName { get; set; } + public string Argument { get; set; } + public string OriginalArgument { get; set; } + public string RuntimeVersion { get; set; } + public List CustomData { get; set; } + } } [Serializable] diff --git a/Mitria_Minecraft_Launcher/LauncherForm.Designer.cs b/Mitria_Minecraft_Launcher/LauncherForm.Designer.cs index d390ecc..10802a2 100644 --- a/Mitria_Minecraft_Launcher/LauncherForm.Designer.cs +++ b/Mitria_Minecraft_Launcher/LauncherForm.Designer.cs @@ -47,6 +47,8 @@ namespace Mitria_Minecraft_Launcher this.button_Report = new System.Windows.Forms.Button(); this.button_Open_LauncherDirectory = new System.Windows.Forms.Button(); this.button_Setup = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.comboBox_selectServer = new System.Windows.Forms.ComboBox(); this.groupBox_MinecraftRun.SuspendLayout(); this.groupBox_Progress.SuspendLayout(); this.groupBox_LauncherSettings.SuspendLayout(); @@ -107,7 +109,7 @@ namespace Mitria_Minecraft_Launcher this.groupBox_MinecraftRun.Controls.Add(this.textBox_MinecraftPlayerName); this.groupBox_MinecraftRun.Controls.Add(this.button_Run); this.groupBox_MinecraftRun.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); - this.groupBox_MinecraftRun.Location = new System.Drawing.Point(262, 260); + this.groupBox_MinecraftRun.Location = new System.Drawing.Point(262, 280); this.groupBox_MinecraftRun.Name = "groupBox_MinecraftRun"; this.groupBox_MinecraftRun.Size = new System.Drawing.Size(300, 90); this.groupBox_MinecraftRun.TabIndex = 0; @@ -126,7 +128,7 @@ namespace Mitria_Minecraft_Launcher this.groupBox_Progress.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); this.groupBox_Progress.Location = new System.Drawing.Point(12, 12); this.groupBox_Progress.Name = "groupBox_Progress"; - this.groupBox_Progress.Size = new System.Drawing.Size(550, 240); + this.groupBox_Progress.Size = new System.Drawing.Size(550, 220); this.groupBox_Progress.TabIndex = 0; this.groupBox_Progress.TabStop = false; this.groupBox_Progress.Text = "Progress"; @@ -186,7 +188,7 @@ namespace Mitria_Minecraft_Launcher this.groupBox_LauncherSettings.Controls.Add(this.button_Open_LauncherDirectory); this.groupBox_LauncherSettings.Controls.Add(this.button_Setup); this.groupBox_LauncherSettings.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); - this.groupBox_LauncherSettings.Location = new System.Drawing.Point(12, 260); + this.groupBox_LauncherSettings.Location = new System.Drawing.Point(12, 280); this.groupBox_LauncherSettings.Name = "groupBox_LauncherSettings"; this.groupBox_LauncherSettings.Size = new System.Drawing.Size(244, 90); this.groupBox_LauncherSettings.TabIndex = 0; @@ -245,12 +247,38 @@ namespace Mitria_Minecraft_Launcher this.button_Setup.UseVisualStyleBackColor = false; this.button_Setup.Click += new System.EventHandler(this.button_Setup_Click); // + // label1 + // + this.label1.AutoSize = true; + this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + this.label1.Location = new System.Drawing.Point(220, 250); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(41, 12); + this.label1.TabIndex = 3; + this.label1.Text = "Server"; + // + // comboBox_selectServer + // + this.comboBox_selectServer.DropDownHeight = 150; + this.comboBox_selectServer.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBox_selectServer.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.comboBox_selectServer.Font = new System.Drawing.Font("맑은 고딕", 9F); + this.comboBox_selectServer.FormattingEnabled = true; + this.comboBox_selectServer.IntegralHeight = false; + this.comboBox_selectServer.Location = new System.Drawing.Point(270, 247); + this.comboBox_selectServer.Name = "comboBox_selectServer"; + this.comboBox_selectServer.Size = new System.Drawing.Size(292, 23); + this.comboBox_selectServer.TabIndex = 4; + this.comboBox_selectServer.SelectedIndexChanged += new System.EventHandler(this.comboBox_selectServer_SelectedIndexChanged); + // // LauncherForm // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(54)))), ((int)(((byte)(57)))), ((int)(((byte)(63))))); - this.ClientSize = new System.Drawing.Size(574, 360); + this.ClientSize = new System.Drawing.Size(574, 381); + this.Controls.Add(this.comboBox_selectServer); + this.Controls.Add(this.label1); this.Controls.Add(this.groupBox_LauncherSettings); this.Controls.Add(this.groupBox_Progress); this.Controls.Add(this.groupBox_MinecraftRun); @@ -267,6 +295,7 @@ namespace Mitria_Minecraft_Launcher this.groupBox_Progress.PerformLayout(); this.groupBox_LauncherSettings.ResumeLayout(false); this.ResumeLayout(false); + this.PerformLayout(); } @@ -289,6 +318,8 @@ namespace Mitria_Minecraft_Launcher private System.Windows.Forms.Button button_Report; private System.Windows.Forms.Button button_Open_LauncherDirectory; private System.Windows.Forms.Button button_Open_GameDirectory; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox comboBox_selectServer; } } diff --git a/Mitria_Minecraft_Launcher/LauncherForm.cs b/Mitria_Minecraft_Launcher/LauncherForm.cs index f91fd45..fe37789 100644 --- a/Mitria_Minecraft_Launcher/LauncherForm.cs +++ b/Mitria_Minecraft_Launcher/LauncherForm.cs @@ -6,13 +6,13 @@ using System.Drawing; using System.IO; using System.Threading.Tasks; using System.Windows.Forms; +using System.Linq; namespace Mitria_Minecraft_Launcher { public partial class LauncherForm : Form { private LoadingScreen _loadingScreen; - public LauncherForm() { InitializeComponent(); @@ -23,6 +23,14 @@ namespace Mitria_Minecraft_Launcher this.Text = ProductName + " v" + ProductVersion; LoadingScreenInitialize(); this.textBox_MinecraftPlayerName.Text = Settings.UserLauncherConfig.MinecraftPlayerName; + int index = 0; + foreach (var server in Settings.ServerInformation.Servers) + { + comboBox_selectServer.Items.Add(server.ServerFullName); + if (server.ServerName == Settings.UserLauncherConfig.LastServerName) + index = comboBox_selectServer.Items.Count - 1; + } + comboBox_selectServer.SelectedIndex = index; } private void LoadingScreenInitialize() @@ -157,26 +165,28 @@ namespace Mitria_Minecraft_Launcher private void MinecraftRun() { - CommonLibrary.XMLSystem.Save(System.IO.Path.GetFullPath(Settings.UserLauncherConfigPath), Settings.UserLauncherConfig); - CommonLibrary.XMLSystem.Save(System.IO.Path.GetFullPath(CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, Settings.UserClientVersionPath)), Settings.UserClientVersion); - string runtime = System.IO.Path.GetFullPath(Settings.RuntimeLocation + "\\bin\\javaw.exe"); + Settings.UserLauncherConfig.LastServerName = Settings.NowProfile.ServerName; + Settings.SaveUserLauncherConfig(); + Settings.SaveUserClientVersion(); + + string runtime = System.IO.Path.GetFullPath(CommonLibrary.Extensions.PathCombineW(Settings.RuntimeLocation , Settings.NowProfile.ServerName, "\\bin\\javaw.exe")); if (!System.IO.File.Exists(runtime)) { CommonLibrary.Log.FATAL("not found java"); MessageBox.Show("the java could not be found.", "FATAL Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Loading(false); - Settings.UserLauncherConfig.RuntimeVersion = "0.0.0.0"; // 버전초기화 + Settings.NowProfile.RuntimeVersion = "0.0.0.0"; // 버전초기화 return; } - string excuteArgumentXml = Settings.UserLauncherConfig.GameDirectory + @"\Mitria\ExcuteArgument.xml"; - ExcuteArgument excuteArgument = CommonLibrary.XMLSystem.LoadFromPath(excuteArgumentXml); + string excuteArgumentXml = CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, Settings.NowProfile.ServerName, @"\Mitria\ExcuteArgument.xml"); + ExcuteArgument excuteArgument = CommonLibrary.XmlSystem.LoadFromPath(excuteArgumentXml); List launcherParameters = new List(); - launcherParameters.Add(new Parameter("GameDirectory", "\"" + Settings.UserLauncherConfig.GameDirectory + "\"")); - launcherParameters.Add(new Parameter("argument", Settings.UserLauncherConfig.Argument)); + launcherParameters.Add(new Parameter("GameDirectory", "\"" + CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, Settings.NowProfile.ServerName) + "\"")); + launcherParameters.Add(new Parameter("argument", Settings.NowProfile.Argument)); launcherParameters.Add(new Parameter("userName", Settings.UserLauncherConfig.MinecraftPlayerName)); - launcherParameters.Add(new Parameter("uuid", Settings.UserLauncherConfig.MinecraftPlayerName + "uuid")); - launcherParameters.Add(new Parameter("accessToken", Settings.UserLauncherConfig.MinecraftPlayerName + "accessToken")); + launcherParameters.Add(new Parameter("uuid", "uuid")); + launcherParameters.Add(new Parameter("accessToken", "accessToken")); excuteArgument.Parameters.AddRange(launcherParameters); @@ -189,7 +199,7 @@ namespace Mitria_Minecraft_Launcher CreateNoWindow = true, Arguments = argumentsCommand, UseShellExecute = Settings.UserLauncherConfig.ShellView, - WorkingDirectory = Settings.UserLauncherConfig.GameDirectory + WorkingDirectory = CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory , Settings.NowProfile.ServerName), }; process.StartInfo = processStartInfo; @@ -221,6 +231,10 @@ namespace Mitria_Minecraft_Launcher private void button_Report_Click(object sender, EventArgs e) { + // 개발중..? 뭐 만들려고 했지...? + + return; + } private string ReportCheck(DateTime criteriaDateTime) @@ -262,5 +276,10 @@ namespace Mitria_Minecraft_Launcher } System.Diagnostics.Process.Start(Settings.UserLauncherConfig.GameDirectory); } + + private void comboBox_selectServer_SelectedIndexChanged(object sender, EventArgs e) + { + Settings.ChangeProfile(Settings.ServerInformation.Servers[comboBox_selectServer.SelectedIndex].ServerName); + } } } \ No newline at end of file diff --git a/Mitria_Minecraft_Launcher/LauncherSetupForm.Designer.cs b/Mitria_Minecraft_Launcher/LauncherSetupForm.Designer.cs index 1bcf5a8..aad5911 100644 --- a/Mitria_Minecraft_Launcher/LauncherSetupForm.Designer.cs +++ b/Mitria_Minecraft_Launcher/LauncherSetupForm.Designer.cs @@ -52,7 +52,7 @@ namespace Mitria_Minecraft_Launcher this.groupBox1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); this.groupBox1.Location = new System.Drawing.Point(10, 10); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(480, 100); + this.groupBox1.Size = new System.Drawing.Size(566, 100); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; this.groupBox1.Text = "Game Directory"; @@ -61,7 +61,7 @@ namespace Mitria_Minecraft_Launcher // this.button_GameDirectory_Open.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button_GameDirectory_Open.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); - this.button_GameDirectory_Open.Location = new System.Drawing.Point(370, 47); + this.button_GameDirectory_Open.Location = new System.Drawing.Point(460, 50); this.button_GameDirectory_Open.Name = "button_GameDirectory_Open"; this.button_GameDirectory_Open.Size = new System.Drawing.Size(90, 30); this.button_GameDirectory_Open.TabIndex = 1; @@ -77,7 +77,7 @@ namespace Mitria_Minecraft_Launcher this.textBox_GameDirectory.Location = new System.Drawing.Point(20, 20); this.textBox_GameDirectory.Name = "textBox_GameDirectory"; this.textBox_GameDirectory.ReadOnly = true; - this.textBox_GameDirectory.Size = new System.Drawing.Size(440, 21); + this.textBox_GameDirectory.Size = new System.Drawing.Size(530, 21); this.textBox_GameDirectory.TabIndex = 0; this.textBox_GameDirectory.TabStop = false; // @@ -119,8 +119,7 @@ namespace Mitria_Minecraft_Launcher // // button_Save // - this.button_Save.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.button_Save.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + this.button_Save.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(54)))), ((int)(((byte)(57)))), ((int)(((byte)(63))))); this.button_Save.Location = new System.Drawing.Point(496, 275); this.button_Save.Name = "button_Save"; this.button_Save.Size = new System.Drawing.Size(80, 50); @@ -131,8 +130,7 @@ namespace Mitria_Minecraft_Launcher // // button_Cancel // - this.button_Cancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.button_Cancel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + this.button_Cancel.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(54)))), ((int)(((byte)(57)))), ((int)(((byte)(63))))); this.button_Cancel.Location = new System.Drawing.Point(496, 339); this.button_Cancel.Name = "button_Cancel"; this.button_Cancel.Size = new System.Drawing.Size(80, 50); @@ -156,7 +154,7 @@ namespace Mitria_Minecraft_Launcher // this.button_Package_Initialize.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button_Package_Initialize.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); - this.button_Package_Initialize.Location = new System.Drawing.Point(496, 30); + this.button_Package_Initialize.Location = new System.Drawing.Point(496, 150); this.button_Package_Initialize.Name = "button_Package_Initialize"; this.button_Package_Initialize.Size = new System.Drawing.Size(80, 50); this.button_Package_Initialize.TabIndex = 5; @@ -169,7 +167,7 @@ namespace Mitria_Minecraft_Launcher // this.button_Component_Initialize.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.button_Component_Initialize.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(242)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); - this.button_Component_Initialize.Location = new System.Drawing.Point(496, 86); + this.button_Component_Initialize.Location = new System.Drawing.Point(496, 210); this.button_Component_Initialize.Name = "button_Component_Initialize"; this.button_Component_Initialize.Size = new System.Drawing.Size(80, 50); this.button_Component_Initialize.TabIndex = 6; diff --git a/Mitria_Minecraft_Launcher/LauncherSetupForm.cs b/Mitria_Minecraft_Launcher/LauncherSetupForm.cs index 5ee64ef..3c13390 100644 --- a/Mitria_Minecraft_Launcher/LauncherSetupForm.cs +++ b/Mitria_Minecraft_Launcher/LauncherSetupForm.cs @@ -11,9 +11,12 @@ namespace Mitria_Minecraft_Launcher } private void LauncherSetupForm_Load(object sender, EventArgs e) { + + Text = "Base Setup For " + Settings.NowProfile.ServerName; textBox_GameDirectory.Text = Settings.UserLauncherConfig.GameDirectory; - textBox_Argument.Text = Settings.UserLauncherConfig.Argument; checkBox_ShellView.Checked = Settings.UserLauncherConfig.ShellView; + + textBox_Argument.Text = Settings.NowProfile.Argument; } private void button_GameDirectory_Open_Click(object sender, EventArgs e) { @@ -27,7 +30,7 @@ namespace Mitria_Minecraft_Launcher private void button_Argument_Initialize_Click(object sender, EventArgs e) { - textBox_Argument.Text = Settings.BaseArgument; + textBox_Argument.Text = Settings.NowProfile.OriginalArgument; } private void button_Save_Click(object sender, EventArgs e) @@ -44,12 +47,9 @@ namespace Mitria_Minecraft_Launcher } } Settings.UserLauncherConfig.GameDirectory = textBox_GameDirectory.Text; - Settings.UserLauncherConfig.Argument = textBox_Argument.Text; Settings.UserLauncherConfig.ShellView = checkBox_ShellView.Checked; + Settings.NowProfile.Argument = textBox_Argument.Text; Settings.SaveUserLauncherConfig(); - Settings.LoadUserClientVersion(); - - this.Close(); } diff --git a/Mitria_Minecraft_Launcher/Mitria_Minecraft_Launcher.csproj b/Mitria_Minecraft_Launcher/Mitria_Minecraft_Launcher.csproj index 4d039a0..d5e85ca 100644 --- a/Mitria_Minecraft_Launcher/Mitria_Minecraft_Launcher.csproj +++ b/Mitria_Minecraft_Launcher/Mitria_Minecraft_Launcher.csproj @@ -231,6 +231,7 @@ LauncherForm.cs + Designer LauncherSetupForm.cs diff --git a/Mitria_Minecraft_Launcher/Program.cs b/Mitria_Minecraft_Launcher/Program.cs index ce762df..db0778a 100644 --- a/Mitria_Minecraft_Launcher/Program.cs +++ b/Mitria_Minecraft_Launcher/Program.cs @@ -36,15 +36,9 @@ namespace Mitria_Minecraft_Launcher #region Crate CustomDirectory - string customDataDirectory = CommonLibrary.Extensions.PathCombineW(Settings.CustomDataDirectory, "config"); - if (!System.IO.Directory.Exists(customDataDirectory)) + if (!System.IO.Directory.Exists(Settings.CustomDataDirectory)) { - System.IO.Directory.CreateDirectory(customDataDirectory); - } - customDataDirectory = CommonLibrary.Extensions.PathCombineW(Settings.CustomDataDirectory, "mods"); - if (!System.IO.Directory.Exists(customDataDirectory)) - { - System.IO.Directory.CreateDirectory(customDataDirectory); + System.IO.Directory.CreateDirectory(Settings.CustomDataDirectory); } #endregion Crate CustomDirectory @@ -62,9 +56,61 @@ namespace Mitria_Minecraft_Launcher case Updater.LauncherUpdateStatus.Same: Settings.LoadUserLauncherConfig(); - Settings.LoadUserClientVersion(); + bool result = DownloadServerList(); + if (result) + { + if (Settings.UserLauncherConfig.Profiles != null) + { + var newList = Settings.UserLauncherConfig.Profiles; - ProgramRun(); + for (int i = 0; i < Settings.UserLauncherConfig.Profiles.Count; i++) + { + bool existence = false; + for (int j = 0; j < Settings.ServerInformation.Servers.Count; j++) + { + if (Settings.UserLauncherConfig.Profiles[i].ServerName == Settings.ServerInformation.Servers[j].ServerName) + { + existence = true; + if (Settings.UserLauncherConfig.Profiles[i].OriginalArgument != Settings.ServerInformation.Servers[j].BaseArgument) + { + Settings.UserLauncherConfig.Profiles[i] = new LauncherConfig.Profile() + { + ServerName = Settings.UserLauncherConfig.Profiles[i].ServerName, + Argument = Settings.ServerInformation.Servers[j].BaseArgument, + OriginalArgument = Settings.ServerInformation.Servers[j].BaseArgument, + RuntimeVersion = Settings.UserLauncherConfig.Profiles[i].RuntimeVersion, + CustomData = Settings.UserLauncherConfig.Profiles[i].CustomData + }; + } + } + } + + if (!existence) + { + newList.Remove(Settings.UserLauncherConfig.Profiles[i]); + string path = CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, Settings.UserLauncherConfig.Profiles[i].ServerName); + if (File.Exists(path)) + { + Directory.Delete(path, true); + } + path = CommonLibrary.Extensions.PathCombineW(Settings.CustomDataDirectory, Settings.UserLauncherConfig.Profiles[i].ServerName); + if (System.IO.Directory.Exists(path)) + { + System.IO.Directory.Delete(path, true); + } + } + } + Settings.UserLauncherConfig.Profiles = newList; + } + + + ProgramRun(); + } + else + { + CommonLibrary.Log.FATAL("ServerList Get Failed"); + MessageBox.Show("ServerList get failed. \r\nPlease provide a log to the administrator and solve it.", "FATAL Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } break; default: @@ -78,6 +124,18 @@ namespace Mitria_Minecraft_Launcher } } + private static bool DownloadServerList() + { + Downloader downloader = new Downloader(); + string data = downloader.DownloadString(Settings.ServerBaseUrl + Settings.ServerInformationFile); + if (data == string.Empty) + { + return false; + } + Settings.ServerInformation = CommonLibrary.XmlSystem.LoadFromData(data); + return true; + } + private static void ProgramRun() { Application.EnableVisualStyles(); diff --git a/Mitria_Minecraft_Launcher/Settings.cs b/Mitria_Minecraft_Launcher/Settings.cs index d1e1d8d..a98f6c0 100644 --- a/Mitria_Minecraft_Launcher/Settings.cs +++ b/Mitria_Minecraft_Launcher/Settings.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; namespace Mitria_Minecraft_Launcher { @@ -9,55 +8,119 @@ namespace Mitria_Minecraft_Launcher #pragma warning disable S2223 // Non-constant static fields should not be visible public static LauncherConfig UserLauncherConfig; public static ClientVersion UserClientVersion; + public static LauncherConfig.Profile NowProfile; + public static CommonLibrary.ServerInformation ServerInformation; public static readonly string UserLauncherConfigPath = "config.xml"; public static readonly string UserClientVersionPath = "version.xml"; // 위치 // 게임 디렉토리 + public static readonly string CustomDataDirectory = "CustomData"; public static readonly string RuntimeLocation = "runtime"; #pragma warning disable S1075 // URIs should not be hardcoded + public static readonly string ServerBaseUrl = "http://mitria.kr/Patchdata"; + + #pragma warning restore S1075 // URIs should not be hardcoded - public static readonly string ServerLauncherPatchInformationFile = "/Launcher.xml"; - public static readonly string ServerDataPatchInformationFile = "/Data.xml"; - public static readonly string BaseArgument = @"-XX:+UseG1GC -Xmx8G -Xms8G -Dsun.rmi.dgc.server.gcInterval=2147483646 -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M"; + public static readonly string ServerLauncherPatchInformationFile = "/launcher.xml"; + public static readonly string ServerInformationFile = "/server.xml"; + public static readonly string ServerDataPatchInformationFile = "/data.xml"; + //public static readonly string BaseArgument = @"-XX:+UseG1GC -Xmx8G -Xms8G -Dsun.rmi.dgc.server.gcInterval=2147483646 -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M"; public static void LoadUserLauncherConfig() { string path = System.IO.Path.GetFullPath(UserLauncherConfigPath); if (System.IO.File.Exists(path)) { - UserLauncherConfig = CommonLibrary.XMLSystem.LoadFromPath(path); + UserLauncherConfig = CommonLibrary.XmlSystem.LoadFromPath(path); } else { UserLauncherConfig = new LauncherConfig(); UserLauncherConfig.MinecraftPlayerName = string.Empty; - UserLauncherConfig.Argument = Settings.BaseArgument; UserLauncherConfig.GameDirectory = @"C:\Games\Mitria"; UserLauncherConfig.ShellView = false; - UserLauncherConfig.RuntimeVersion = "0.0.0.0"; - UserLauncherConfig.CustomData = new List(); } } public static void SaveUserLauncherConfig() { + SaveProfile(); string path = System.IO.Path.GetFullPath(UserLauncherConfigPath); string pathDirectory = System.IO.Path.GetDirectoryName(path); if (!System.IO.Directory.Exists(pathDirectory)) { System.IO.Directory.CreateDirectory(pathDirectory); } - CommonLibrary.XMLSystem.Save(path, UserLauncherConfig); + CommonLibrary.XmlSystem.Save(path, UserLauncherConfig); } + public static void ChangeProfile(string serverName) + { + LauncherConfig.Profile myProfile = new LauncherConfig.Profile(); + bool exists = false; + if (Settings.UserLauncherConfig.Profiles != null) + { + foreach (var profile in Settings.UserLauncherConfig.Profiles) + { + if (profile.ServerName == serverName) + { + myProfile = profile; + exists = true; + } + } + } + if (!exists) + { + foreach (var server in Settings.ServerInformation.Servers) + { + if (server.ServerName == serverName) + { + myProfile.ServerName = server.ServerName; + myProfile.Argument = server.BaseArgument; + myProfile.OriginalArgument = server.BaseArgument; + myProfile.RuntimeVersion = "0.0.0.0"; + myProfile.CustomData = new List(); + } + } + } + NowProfile = myProfile; + LoadUserClientVersion(); + } + private static void SaveProfile() + { + + if(NowProfile.ServerName == string.Empty) + { + return; + } + bool isSave = false; + if(Settings.UserLauncherConfig.Profiles == null) + { + Settings.UserLauncherConfig.Profiles = new List(); + Settings.UserLauncherConfig.Profiles.Add(NowProfile); + return; + } + for (int i = 0; i < Settings.UserLauncherConfig.Profiles.Count; i++) + { + if (NowProfile.ServerName == Settings.UserLauncherConfig.Profiles[i].ServerName) + { + Settings.UserLauncherConfig.Profiles[i] = NowProfile; + isSave = true; + } + } + if(!isSave) + { + Settings.UserLauncherConfig.Profiles.Add(NowProfile); + } + + } public static void LoadUserClientVersion() { - string path = CommonLibrary.Extensions.PathCombineW(UserLauncherConfig.GameDirectory, UserClientVersionPath); + string path = CommonLibrary.Extensions.PathCombineW(UserLauncherConfig.GameDirectory, NowProfile.ServerName, UserClientVersionPath); if (System.IO.File.Exists(path)) { - UserClientVersion = CommonLibrary.XMLSystem.LoadFromPath(path); + UserClientVersion = CommonLibrary.XmlSystem.LoadFromPath(path); } else { @@ -72,15 +135,13 @@ namespace Mitria_Minecraft_Launcher public static void SaveUserClientVersion() { - string path = CommonLibrary.Extensions.PathCombineW(UserLauncherConfig.GameDirectory, UserClientVersionPath); + string path = CommonLibrary.Extensions.PathCombineW(UserLauncherConfig.GameDirectory, NowProfile.ServerName, UserClientVersionPath); string pathDirectory = System.IO.Path.GetDirectoryName(path); if (!System.IO.Directory.Exists(pathDirectory)) { System.IO.Directory.CreateDirectory(pathDirectory); } - CommonLibrary.XMLSystem.Save(path, UserClientVersion); + CommonLibrary.XmlSystem.Save(path, UserClientVersion); } } - - } \ No newline at end of file diff --git a/Mitria_Minecraft_Launcher/Updater/GameUpdateManager.cs b/Mitria_Minecraft_Launcher/Updater/GameUpdateManager.cs index 5e6f43d..3c2a62b 100644 --- a/Mitria_Minecraft_Launcher/Updater/GameUpdateManager.cs +++ b/Mitria_Minecraft_Launcher/Updater/GameUpdateManager.cs @@ -25,7 +25,7 @@ namespace Mitria_Minecraft_Launcher.Updater // Version File Download CommonLibrary.Log.INFO("download version file."); - var verionData = downloader.DownloadString(Settings.ServerBaseUrl + Settings.ServerDataPatchInformationFile); + var verionData = downloader.DownloadString(CommonLibrary.Extensions.PathCombineL(Settings.ServerBaseUrl,"Servers", Settings.NowProfile.ServerName, Settings.ServerDataPatchInformationFile)); // Versoin File 받기에 실패하였을때 업데이트 전체 실패처리 if (verionData == string.Empty) @@ -36,7 +36,7 @@ namespace Mitria_Minecraft_Launcher.Updater } // Version File Xml 형태로 변환 - var dataPatchInformation = CommonLibrary.XMLSystem.LoadFromData(verionData); + var dataPatchInformation = CommonLibrary.XmlSystem.LoadFromData(verionData); // 임시 폴더 생성 var tempDirectory = System.IO.Path.GetFullPath("temp"); @@ -54,7 +54,7 @@ namespace Mitria_Minecraft_Launcher.Updater Log.INFO("[Runtime] Version Check"); // 버전 비교 - var thisVersion = Version.Parse(Settings.UserLauncherConfig.RuntimeVersion); + var thisVersion = Version.Parse(Settings.NowProfile.RuntimeVersion); var remoteVersion = Version.Parse(dataPatchInformation.RuntimeVersion); CommonLibrary.Log.INFO("[Runtime] LocalVersion : " + thisVersion); CommonLibrary.Log.INFO("[Runtime] RemoteVersion : " + remoteVersion); @@ -72,7 +72,7 @@ namespace Mitria_Minecraft_Launcher.Updater CommonLibrary.Log.INFO("Runtime delete it for update."); // 런타임 폴더 경로 가져오기 - var rootDirectoryInfo = new System.IO.DirectoryInfo(System.IO.Path.GetFullPath(Settings.RuntimeLocation)); + var rootDirectoryInfo = new System.IO.DirectoryInfo(System.IO.Path.GetFullPath(CommonLibrary.Extensions.PathCombineW(Settings.RuntimeLocation,Settings.NowProfile.ServerName))); // 런타임 폴더 삭제후 새로만들기 if (!rootDirectoryInfo.Exists) @@ -91,7 +91,7 @@ namespace Mitria_Minecraft_Launcher.Updater // 런타임 다운로드 시작 GameUpdateManagerMessage(this, new GameUpdateManagerMessageEventArgs(GameUpdateManagerMessageType.First, 2, 9, "[2/9] Runtime Download")); Log.INFO("[Runtime] Data Download Start"); - var downloadUrl = CommonLibrary.Extensions.PathCombineL(Settings.ServerBaseUrl, dataPatchInformation.RuntimeUrl, dataPatchInformation.RuntimeFileName); + var downloadUrl = CommonLibrary.Extensions.PathCombineL(Settings.ServerBaseUrl, "Servers", Settings.NowProfile.ServerName, dataPatchInformation.RuntimeUrl, dataPatchInformation.RuntimeFileName); var targetPath = System.IO.Path.Combine(tempDirectory, dataPatchInformation.RuntimeFileName); // 임시폴더에 다운로드 downloader.DownloadFile(downloadUrl, targetPath); Log.INFO("[Runtime] Data Download End"); @@ -99,11 +99,11 @@ namespace Mitria_Minecraft_Launcher.Updater // 런타임 언패킹 작업 var progressPacker = new ProgressPacker(); - var unpackPath = System.IO.Path.GetFullPath(Settings.RuntimeLocation); + var unpackPath = rootDirectoryInfo.FullName; GameUpdateManagerMessage(this, new GameUpdateManagerMessageEventArgs(GameUpdateManagerMessageType.First, 3, 9, "[3/9] Runtime Unpack")); Log.INFO("[Runtime] Unpack Start"); progressPacker.UnPack(targetPath, unpackPath, new BasicProgress(p => Change(p))); - Settings.UserLauncherConfig.RuntimeVersion = remoteVersion.ToString(); + Settings.NowProfile.RuntimeVersion = remoteVersion.ToString(); //임시폴더 삭제 System.IO.File.Delete(targetPath); @@ -134,7 +134,7 @@ namespace Mitria_Minecraft_Launcher.Updater .INFO(string.Format("{0}", result == 1 ? "remote is the upper version" : "remote is the lower version")); CommonLibrary.Log.INFO("[Package] delete it for update."); - var rootDirectoryInfo = new System.IO.DirectoryInfo(System.IO.Path.GetFullPath(Settings.UserLauncherConfig.GameDirectory)); + var rootDirectoryInfo = new System.IO.DirectoryInfo(System.IO.Path.GetFullPath(CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory,Settings.NowProfile.ServerName))); if (!rootDirectoryInfo.Exists) { @@ -144,11 +144,15 @@ namespace Mitria_Minecraft_Launcher.Updater else { // 비우기 전에 스크린샷폴더 보존 /screenshots - string oldScreenshotsDirectory = CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, "screenshots"); + string oldScreenshotsDirectory = CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, Settings.NowProfile.ServerName, "screenshots"); string newScreenshotsDirectory = CommonLibrary.Extensions.PathCombineW("screenshots " + DateTime.Now.ToString()); if (System.IO.Directory.Exists(oldScreenshotsDirectory) && System.IO.Directory.GetFiles(oldScreenshotsDirectory, "*", System.IO.SearchOption.AllDirectories).Length > 0) { Log.INFO("[Package] Screenshots Directory Backup : " + newScreenshotsDirectory); + if(!System.IO.Directory.Exists(newScreenshotsDirectory)) + { + System.IO.Directory.CreateDirectory(newScreenshotsDirectory); + } System.IO.Directory.Move(oldScreenshotsDirectory, newScreenshotsDirectory); } @@ -156,7 +160,7 @@ namespace Mitria_Minecraft_Launcher.Updater Log.INFO("[Package] Empty GameDirectory"); } - var downloadUrl = CommonLibrary.Extensions.PathCombineL(Settings.ServerBaseUrl, dataPatchInformation.PackageUrl, dataPatchInformation.PackageFileName); + var downloadUrl = CommonLibrary.Extensions.PathCombineL(Settings.ServerBaseUrl, "Servers", Settings.NowProfile.ServerName, dataPatchInformation.PackageUrl, dataPatchInformation.PackageFileName); var targetPath = System.IO.Path.Combine(tempDirectory, dataPatchInformation.PackageFileName); GameUpdateManagerMessage(this, new GameUpdateManagerMessageEventArgs(GameUpdateManagerMessageType.First, 5, 9, "[5/9] Package Download")); Log.INFO("[Package] Download Start"); @@ -203,6 +207,7 @@ namespace Mitria_Minecraft_Launcher.Updater System.IO.File.Delete(targetPath); Log.INFO("[Package] -[F] " + targetPath); Log.INFO("[Package] Unpack End"); + Settings.UserClientVersion.ComponentVersion = "0.0.0.0"; } #endregion Package Update @@ -236,7 +241,7 @@ namespace Mitria_Minecraft_Launcher.Updater foreach (var directory in resultDirectorys) { - var directoryPath = System.IO.Path.GetFullPath(CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, directory)); + var directoryPath = System.IO.Path.GetFullPath(CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory,Settings.NowProfile.ServerName, directory)); if (System.IO.Directory.Exists(directoryPath)) { @@ -247,7 +252,7 @@ namespace Mitria_Minecraft_Launcher.Updater foreach (var directory in dataPatchInformation.ComponentDirectorys) { - var directoryPath = System.IO.Path.GetFullPath(CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, directory)); + var directoryPath = System.IO.Path.GetFullPath(CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, Settings.NowProfile.ServerName, directory)); if (!System.IO.Directory.Exists(directoryPath)) { @@ -265,7 +270,7 @@ namespace Mitria_Minecraft_Launcher.Updater foreach (var fileDetail in removeFiles) { - var filePath = CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, fileDetail.Directory, fileDetail.FileName); + var filePath = CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory,Settings.NowProfile.ServerName, fileDetail.Directory, fileDetail.FileName); if (System.IO.File.Exists(filePath)) { Log.INFO("[Component] -[F] " + filePath); @@ -277,8 +282,8 @@ namespace Mitria_Minecraft_Launcher.Updater Log.INFO("[Component] Download Start"); for (int i = 0; i < needFiles.Count; i++) { - var url = CommonLibrary.Extensions.PathCombineL(Settings.ServerBaseUrl, dataPatchInformation.ComponentUrl, needFiles[i].Directory, needFiles[i].FileName); - var path = CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, needFiles[i].Directory, needFiles[i].FileName); + var url = CommonLibrary.Extensions.PathCombineL(Settings.ServerBaseUrl, "Servers", Settings.NowProfile.ServerName, dataPatchInformation.ComponentUrl, needFiles[i].Directory, needFiles[i].FileName); + var path = CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory,Settings.NowProfile.ServerName, needFiles[i].Directory, needFiles[i].FileName); downloader.DownloadFile(url, path); Log.INFO("[Component] +[F] " + path); } @@ -293,7 +298,15 @@ namespace Mitria_Minecraft_Launcher.Updater #region CustomData // 삭제된 파일 찾기 - string rootCustomPath = System.IO.Path.GetFullPath(Settings.CustomDataDirectory); + string rootCustomPath = System.IO.Path.GetFullPath(CommonLibrary.Extensions.PathCombineW(Settings.CustomDataDirectory, Settings.NowProfile.ServerName)); + if(!System.IO.Directory.Exists(CommonLibrary.Extensions.PathCombineW(rootCustomPath, "config"))) + { + System.IO.Directory.CreateDirectory(CommonLibrary.Extensions.PathCombineW(rootCustomPath, "config")); + } + if (!System.IO.Directory.Exists(CommonLibrary.Extensions.PathCombineW(rootCustomPath, "mods"))) + { + System.IO.Directory.CreateDirectory(CommonLibrary.Extensions.PathCombineW(rootCustomPath, "mods")); + } List files = new List(); files.AddRange(System.IO.Directory.GetFiles(CommonLibrary.Extensions.PathCombineW(rootCustomPath, "config"))); files.AddRange(System.IO.Directory.GetFiles(CommonLibrary.Extensions.PathCombineW(rootCustomPath, "mods"))); @@ -302,21 +315,11 @@ namespace Mitria_Minecraft_Launcher.Updater files[i] = files[i].Replace(rootCustomPath + '\\', string.Empty); } - - for (int i = 0; i < Settings.UserLauncherConfig.CustomData.Count; i++) - { - if (!files.Contains(Settings.UserLauncherConfig.CustomData[i])) - { - - string filePath = CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, Settings.UserLauncherConfig.CustomData[i]); - System.IO.File.Delete(filePath); - Log.INFO("[CustomData] -[F] " + filePath); - } - } + foreach (var file in files) { string sourcePath = CommonLibrary.Extensions.PathCombineW(rootCustomPath, file); - string targetPath = CommonLibrary.Extensions.PathCombineW(Settings.UserLauncherConfig.GameDirectory, file); + string targetPath = CommonLibrary.Extensions.PathCombineW( Settings.UserLauncherConfig.GameDirectory, Settings.NowProfile.ServerName,file); if (System.IO.File.Exists(targetPath)) @@ -335,7 +338,7 @@ namespace Mitria_Minecraft_Launcher.Updater System.IO.File.Copy(sourcePath, targetPath); Log.INFO("[CustomData] +[F] " + targetPath); } - Settings.UserLauncherConfig.CustomData = files; + //Settings.UserLauncherConfig.CustomData = files; Settings.SaveUserLauncherConfig(); } diff --git a/Mitria_Minecraft_Launcher/Updater/LauncherUpdate.cs b/Mitria_Minecraft_Launcher/Updater/LauncherUpdate.cs index b5cef61..d5e4ee4 100644 --- a/Mitria_Minecraft_Launcher/Updater/LauncherUpdate.cs +++ b/Mitria_Minecraft_Launcher/Updater/LauncherUpdate.cs @@ -16,7 +16,7 @@ namespace Mitria_Minecraft_Launcher.Updater return LauncherUpdateStatus.Fail; } - LauncherPatchInformation launcherPatchInformation = CommonLibrary.XMLSystem.LoadFromData(verionData); + LauncherPatchInformation launcherPatchInformation = CommonLibrary.XmlSystem.LoadFromData(verionData); Version thisVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; Version remoteVersion = Version.Parse(launcherPatchInformation.Version); CommonLibrary.Log.INFO("Launcher Version : " + thisVersion); diff --git a/Mitria_Minecraft_Project.sln b/Mitria_Minecraft_Project.sln index 036a9cb..17f87b0 100644 --- a/Mitria_Minecraft_Project.sln +++ b/Mitria_Minecraft_Project.sln @@ -9,6 +9,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mitria_Minecraft_Updater", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommonLibrary", "CommonLibrary\CommonLibrary.csproj", "{57098662-9A1B-45E7-B932-5299343629F2}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mitria_Argument_Creater", "Mitria_Argument_Creater\Mitria_Argument_Creater.csproj", "{52250463-A90A-4DF7-B17D-A08940858305}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -27,6 +29,10 @@ Global {57098662-9A1B-45E7-B932-5299343629F2}.Debug|Any CPU.Build.0 = Debug|Any CPU {57098662-9A1B-45E7-B932-5299343629F2}.Release|Any CPU.ActiveCfg = Release|Any CPU {57098662-9A1B-45E7-B932-5299343629F2}.Release|Any CPU.Build.0 = Release|Any CPU + {52250463-A90A-4DF7-B17D-A08940858305}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {52250463-A90A-4DF7-B17D-A08940858305}.Debug|Any CPU.Build.0 = Debug|Any CPU + {52250463-A90A-4DF7-B17D-A08940858305}.Release|Any CPU.ActiveCfg = Release|Any CPU + {52250463-A90A-4DF7-B17D-A08940858305}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Mitria_Minecraft_Updater/Extensions.cs b/Mitria_Minecraft_Updater/Extensions.cs index 6632e6f..6d3a2e3 100644 --- a/Mitria_Minecraft_Updater/Extensions.cs +++ b/Mitria_Minecraft_Updater/Extensions.cs @@ -27,7 +27,7 @@ namespace Mitria_Minecraft_Updater int countFiles = System.IO.Directory.GetFiles(directorys[i - 1], "*", System.IO.SearchOption.AllDirectories).Length; if (countDirectory + countFiles == 0) { - System.IO.Directory.Delete(directorys[i - 1]); + System.IO.Directory.Delete(directorys[i - 1],true); } } } diff --git a/Mitria_Minecraft_Updater/Mitria_Minecraft_Updater.csproj b/Mitria_Minecraft_Updater/Mitria_Minecraft_Updater.csproj index 7ce4ea6..fb54fca 100644 --- a/Mitria_Minecraft_Updater/Mitria_Minecraft_Updater.csproj +++ b/Mitria_Minecraft_Updater/Mitria_Minecraft_Updater.csproj @@ -5,6 +5,7 @@ net6.0 Mitria_Minecraft_Updater.Program mmu + embedded diff --git a/Mitria_Minecraft_Updater/Program.cs b/Mitria_Minecraft_Updater/Program.cs index d14c175..ef7918f 100644 --- a/Mitria_Minecraft_Updater/Program.cs +++ b/Mitria_Minecraft_Updater/Program.cs @@ -6,89 +6,86 @@ namespace Mitria_Minecraft_Updater { internal static class Program { - static int nowPosTop; - static int nowPosLeft; + private static int nowPosTop; + private static int nowPosLeft; - static void Main(string[] args) + private static void Main(string[] args) { + Settings.LoadConfig(); if (args.Length < 1) { HelpMessage(); return; } - var versionType = VersionType.Major; - var checkArg = false; - - if (args.Length >= 2) + UpdateType? updateType = GetUpdateType(args[0]); + + if( updateType == null) { - switch (args[1].ToUpper()) + HelpMessage(); + return; + } + if(updateType == UpdateType.Launcher) + { + LauncherUpdate(); + return; + } + if (args.Length < 3) + { + HelpMessage(); + return; + } + VersionType? versionType = GetVersionType(args[1]); + if (versionType == null) + { + HelpMessage(); + return; + } + CommonLibrary.ServerInformation serverInformation = Settings.LoadServerInformation(); + if(CommonLibrary.Extensions.IsDefault(ref serverInformation)) + { + Console.WriteLine("not found ServerData Location : " + Settings.config.Target + Settings.config.InformationToServer); + return; + } + + bool serverIs = false; + string serverOriginalName = string.Empty; + string serverList = string.Empty; + foreach (var item in serverInformation.Servers) + { + serverList += item.ServerName + ", "; + if( item.ServerName.ToUpper() == args[2].ToUpper()) { - case "MAJOR": - versionType = VersionType.Major; - break; - - case "MINOR": - versionType = VersionType.Minor; - break; - - case "BUILD": - versionType = VersionType.Build; - break; - - case "REVISION": - versionType = VersionType.Revision; - break; - - default: - HelpMessage(); - return; + serverIs = true; + serverOriginalName = item.ServerName; } - - checkArg = true; } - - switch (args[0].ToUpper()) + if(!serverIs) { - case "LAUNCHER": - LauncherUpdate(); - break; - - case "RUNTIME": - if (!checkArg) - { - HelpMessage(); - return; - } - - RuntimeUpdate(versionType); - - break; - - case "PACKAGE": - if (!checkArg) - { - HelpMessage(); - return; - } - - PackageUpdate(versionType); - break; - - case "COMPONENT": - if (!checkArg) - { - HelpMessage(); - return; - } - - ComponentUpdate(versionType); - break; - - default: - HelpMessage(); + HelpMessage(); + if (serverList.Length > 1) + { + serverList = serverList.Substring(0, serverList.Length - 2); + Console.WriteLine(" [ServerList] " + serverList); return; + } } + + switch(updateType) + { + case UpdateType.Runtime: + RuntimeUpdate(serverOriginalName, (VersionType)versionType); + break; + case UpdateType.Package: + PackageUpdate(serverOriginalName, (VersionType)versionType); + break; + case UpdateType.Component: + ComponentUpdate(serverOriginalName, (VersionType)versionType); + break; + + } + + } public static void HelpMessage() @@ -96,15 +93,15 @@ namespace Mitria_Minecraft_Updater Console.WriteLine("dotnet mmu.dll [option1] [option2]"); Console.WriteLine(" [option1] Launcher, Runtime, Package, Component"); Console.WriteLine(" [option2] Major, Minor, Build, Revision"); + Console.WriteLine(" [option3] ServerName"); } public static void LauncherUpdate() { - Settings.LoadConfig(); var launcherPatchInformation = Settings.LoadLauncherPatchInformation(); // 런처 패치정보 Load Console.WriteLine("Start Launcher Update"); - - var launcherSourceDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Source , Settings.config.LauncherSource); + + var launcherSourceDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Source, Settings.config.LauncherSource); var launcherTargetDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Target, Settings.config.LauncherUrl); var launcherSourceFile = CommonLibrary.Extensions.PathCombineL(launcherSourceDirectory, Settings.config.LauncherFileName); var launcherTargetFile = CommonLibrary.Extensions.PathCombineL(launcherTargetDirectory, Settings.config.LauncherFileName); @@ -113,13 +110,13 @@ namespace Mitria_Minecraft_Updater if (!System.IO.File.Exists(launcherSourceFile)) { - Console.WriteLine("The source file could not be found."); + Console.WriteLine("The source file could not be found. Location : " + launcherSourceFile); return; } - + System.Diagnostics.FileVersionInfo fileVersionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(launcherSourceFile); - var sourceVersion = new Version(fileVersionInfo.ProductVersion); + var sourceVersion = new Version(fileVersionInfo.ProductVersion); Version oldVersoin; @@ -144,7 +141,7 @@ namespace Mitria_Minecraft_Updater Console.WriteLine("The existing version is higher."); return; } - + if (System.IO.File.Exists(launcherTargetFile)) { System.IO.File.Delete(launcherTargetFile); @@ -157,24 +154,21 @@ namespace Mitria_Minecraft_Updater Console.WriteLine("Update Complete"); } - public static void RuntimeUpdate(VersionType versionType) + public static void RuntimeUpdate(string serverName, VersionType versionType) { - Settings.LoadConfig(); - var dataPatchInformation = Settings.LoadDataPatchInformation(); + var dataPatchInformation = Settings.LoadDataPatchInformation(serverName); Console.WriteLine("Start Runtime Update - version " + versionType.ToString()); - - var runtimeSourceDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Source, Settings.config.RuntimeSource); - var runtimeTargetDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Target, Settings.config.RuntimeUrl); + var runtimeSourceDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Source,"Servers" , serverName, Settings.config.RuntimeSource); + var runtimeTargetDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Target,"Servers", serverName, Settings.config.RuntimeUrl); Extensions.DirectoryCheckCrate(runtimeSourceDirectory); Extensions.DirectoryCheckCrate(runtimeTargetDirectory); - // 파일이 하나도 없을경우 조회실패 if (System.IO.Directory.GetFiles(runtimeSourceDirectory, "*.*", System.IO.SearchOption.AllDirectories).Length == 0) { - Console.WriteLine("The source file could not be found."); + Console.WriteLine("The source file could not be found. Location : " + runtimeSourceDirectory ); return; } @@ -198,19 +192,18 @@ namespace Mitria_Minecraft_Updater var newVersion = VersionChange(dataPatchInformation.RuntimeVersion, versionType); Console.WriteLine("update Version : " + dataPatchInformation.RuntimeVersion + " → " + newVersion); dataPatchInformation.RuntimeVersion = newVersion; - Settings.SaveDataPatchInformation(dataPatchInformation); + Settings.SaveDataPatchInformation(serverName,dataPatchInformation); Console.WriteLine("Update Complete"); } - public static void PackageUpdate(VersionType versionType) + public static void PackageUpdate(string serverName, VersionType versionType) { - Settings.LoadConfig(); - var dataPatchInformation = Settings.LoadDataPatchInformation(); + var dataPatchInformation = Settings.LoadDataPatchInformation(serverName); Console.WriteLine("Start Package Update - version " + versionType.ToString()); - var packageSourceDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Source, Settings.config.PackageSource); - var packageTargetDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Target, Settings.config.PackageUrl); + var packageSourceDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Source, "Servers", serverName, Settings.config.PackageSource); + var packageTargetDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Target, "Servers", serverName, Settings.config.PackageUrl); Extensions.DirectoryCheckCrate(packageSourceDirectory); Extensions.DirectoryCheckCrate(packageTargetDirectory); @@ -218,7 +211,7 @@ namespace Mitria_Minecraft_Updater // 파일이 하나도 없을경우 조회실패 if (System.IO.Directory.GetFiles(packageSourceDirectory, "*.*", System.IO.SearchOption.AllDirectories).Length == 0) { - Console.WriteLine("The source file could not be found."); + Console.WriteLine("The source file could not be found. Location : " + packageSourceDirectory ); return; } @@ -229,7 +222,7 @@ namespace Mitria_Minecraft_Updater Packing(packageSourceDirectory, tempFile); // 최종 저장 경로 할당 - var finalTarget = CommonLibrary.Extensions.PathCombineL(packageTargetDirectory , Settings.config.PackageFilename); + var finalTarget = CommonLibrary.Extensions.PathCombineL(packageTargetDirectory, Settings.config.PackageFilename); // 최종 저장 경로에 이미 파일이 있다면 삭제 if (System.IO.File.Exists(finalTarget)) @@ -242,7 +235,6 @@ namespace Mitria_Minecraft_Updater for (int i = 0; i < directories.Length; i++) { - directories[i] = System.IO.Path.GetRelativePath(Settings.config.Source, directories[i]); } @@ -250,26 +242,25 @@ namespace Mitria_Minecraft_Updater var newVersion = VersionChange(dataPatchInformation.PackageVersion, versionType); Console.WriteLine("Update Version : " + dataPatchInformation.PackageVersion + " → " + newVersion); dataPatchInformation.PackageVersion = newVersion; - Settings.SaveDataPatchInformation(dataPatchInformation); + Settings.SaveDataPatchInformation(serverName,dataPatchInformation); Console.WriteLine("Update Complete"); } - public static void ComponentUpdate(VersionType versionType) + public static void ComponentUpdate(string serverName, VersionType versionType) { - Settings.LoadConfig(); - CommonLibrary.DataPatchInformation dataPatchInformation = Settings.LoadDataPatchInformation(); + CommonLibrary.DataPatchInformation dataPatchInformation = Settings.LoadDataPatchInformation(serverName); Console.WriteLine("Start Component Update - version " + versionType.ToString()); - var componentSourceDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Source, Settings.config.ComponentSource); - var componentTargetDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Target, Settings.config.ComponentUrl); + var componentSourceDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Source, "Servers", serverName, Settings.config.ComponentSource); + var componentTargetDirectory = CommonLibrary.Extensions.PathCombineL(Settings.config.Target, "Servers", serverName, Settings.config.ComponentUrl); Extensions.DirectoryCheckCrate(componentSourceDirectory); Extensions.DirectoryCheckCrate(componentTargetDirectory); if (System.IO.Directory.GetFiles(componentSourceDirectory, "*.*", System.IO.SearchOption.AllDirectories).Length == 0) { - Console.WriteLine("The source file could not be found."); + Console.WriteLine("The source file could not be found. Location : " + componentSourceDirectory); return; } @@ -338,7 +329,7 @@ namespace Mitria_Minecraft_Updater { System.IO.File.Delete(targetFileFullPath); System.IO.File.Copy(sourceFileFullPath, targetFileFullPath); - Console.Write("Update File : " + oFile); + Console.WriteLine("Update File : " + oFile); } } @@ -359,16 +350,15 @@ namespace Mitria_Minecraft_Updater dataPatchInformation.ComponentDirectorys = sourceDirectorys.ToList(); // 파일 디테일 - var newVersion = VersionChange(dataPatchInformation.ComponentVersion, versionType); Console.WriteLine("Update Version : " + dataPatchInformation.ComponentVersion + " → " + newVersion); dataPatchInformation.ComponentVersion = newVersion; - Settings.SaveDataPatchInformation(dataPatchInformation); + Settings.SaveDataPatchInformation(serverName,dataPatchInformation); Console.WriteLine("Update Complete"); // 무결성 검사후 업데이트 } - static void Packing(string source, string target) + private static void Packing(string source, string target) { if (System.IO.File.Exists(target)) { @@ -393,7 +383,7 @@ namespace Mitria_Minecraft_Updater Console.WriteLine("Packing Complite"); } - static string VersionChange(string version, VersionType versionType) + private static string VersionChange(string version, VersionType versionType) { var v = Version.Parse(version); @@ -419,7 +409,7 @@ namespace Mitria_Minecraft_Updater return v.ToString(); } - static void ProgressChange(double obj) + private static void ProgressChange(double obj) { Console.SetCursorPosition(nowPosLeft, nowPosTop); var Progress = (int)(obj * 10); @@ -432,6 +422,66 @@ namespace Mitria_Minecraft_Updater Console.Write(" " + $"{obj:P2}"); } + + private static UpdateType? GetUpdateType(string data) + { + UpdateType? updateType; + switch (data.ToUpper()) + { + case "LAUNCHER": + updateType = UpdateType.Launcher; + break; + + case "RUNTIME": + updateType = UpdateType.Runtime; + break; + + case "PACKAGE": + updateType = UpdateType.Package; + break; + + case "COMPONENT": + updateType = UpdateType.Component; + break; + + default: + updateType = null; + break; + } + return updateType; + + } + private static VersionType? GetVersionType(string data) + { + + VersionType? versionType; + switch (data.ToUpper()) + { + case "MAJOR": + versionType = VersionType.Major; + break; + + case "MINOR": + versionType = VersionType.Minor; + break; + + case "BUILD": + versionType = VersionType.Build; + break; + + case "REVISION": + versionType = VersionType.Revision; + break; + + default: + versionType = null; + break; + } + return versionType; + + + + } } internal enum UpdateType diff --git a/Mitria_Minecraft_Updater/Settings.cs b/Mitria_Minecraft_Updater/Settings.cs index 33104ca..8eb06e5 100644 --- a/Mitria_Minecraft_Updater/Settings.cs +++ b/Mitria_Minecraft_Updater/Settings.cs @@ -14,14 +14,15 @@ namespace Mitria_Minecraft_Updater private static void InitializationConfig() { // 줄여야함 - config.Source = "./Source"; - config.Target = "./Target"; + config.Source = "../Source"; + config.Target = "../Target"; - config.InformationToLauncher = "/Launcher.xml"; - config.InformationToData = "/Data.xml"; + config.InformationToLauncher = "/launcher.xml"; + config.InformationToData = "/data.xml"; + config.InformationToServer = "/server.xml"; config.LauncherSource = "/Launcher"; - config.LauncherUrl = "/Data/Launcher"; + config.LauncherUrl = "/Launcher"; config.LauncherFileName = "MitriaMLauncher.exe"; config.RuntimeSource = "/Runtime"; config.RuntimeUrl = "/Data/Runtime"; @@ -37,7 +38,7 @@ namespace Mitria_Minecraft_Updater { if (System.IO.File.Exists(configPath)) { - config = CommonLibrary.XMLSystem.LoadFromPath(configPath); + config = CommonLibrary.XmlSystem.LoadFromPath(configPath); } else { @@ -48,7 +49,7 @@ namespace Mitria_Minecraft_Updater public static void SaveConfig() { - CommonLibrary.XMLSystem.Save(configPath, config); + CommonLibrary.XmlSystem.Save(configPath, config); } public static CommonLibrary.LauncherPatchInformation LoadLauncherPatchInformation() @@ -57,7 +58,7 @@ namespace Mitria_Minecraft_Updater string fullPath = CommonLibrary.Extensions.PathCombineL(config.Target, config.InformationToLauncher); if (System.IO.File.Exists(fullPath)) { - launcherPatchInformation = CommonLibrary.XMLSystem.LoadFromPath(fullPath); + launcherPatchInformation = CommonLibrary.XmlSystem.LoadFromPath(fullPath); } else { @@ -69,6 +70,18 @@ namespace Mitria_Minecraft_Updater return launcherPatchInformation; } + public static CommonLibrary.ServerInformation LoadServerInformation() + { + CommonLibrary.ServerInformation serverInformation = new CommonLibrary.ServerInformation(); + string fullPath = CommonLibrary.Extensions.PathCombineL(config.Target, config.InformationToServer); + if(System.IO.File.Exists(fullPath)) + { + serverInformation = CommonLibrary.XmlSystem.LoadFromPath(fullPath); + } + + return serverInformation; + } + public static void SaveLauncherPatchInformation(CommonLibrary.LauncherPatchInformation launcherPatchInformation) { @@ -77,16 +90,16 @@ namespace Mitria_Minecraft_Updater { System.IO.Directory.CreateDirectory(config.Target); } - CommonLibrary.XMLSystem.Save(fullPath, launcherPatchInformation); + CommonLibrary.XmlSystem.Save(fullPath, launcherPatchInformation); } - public static CommonLibrary.DataPatchInformation LoadDataPatchInformation() + public static CommonLibrary.DataPatchInformation LoadDataPatchInformation(string serverName) { CommonLibrary.DataPatchInformation dataPatchInformation = new CommonLibrary.DataPatchInformation(); - string fullPath = config.Target + config.InformationToData; + string fullPath = CommonLibrary.Extensions.PathCombineL(config.Target, "Servers", serverName, config.InformationToData); if (System.IO.File.Exists(fullPath)) { - dataPatchInformation = CommonLibrary.XMLSystem.LoadFromPath(fullPath); + dataPatchInformation = CommonLibrary.XmlSystem.LoadFromPath(fullPath); } else { @@ -106,14 +119,14 @@ namespace Mitria_Minecraft_Updater return dataPatchInformation; } - public static void SaveDataPatchInformation(CommonLibrary.DataPatchInformation dataPatchInformation) + public static void SaveDataPatchInformation(string serverName, CommonLibrary.DataPatchInformation dataPatchInformation) { - string fullPath = CommonLibrary.Extensions.PathCombineL(config.Target , config.InformationToData); + string fullPath = CommonLibrary.Extensions.PathCombineL(config.Target, "Servers", serverName, config.InformationToData); if (!System.IO.Directory.Exists(config.Target)) { System.IO.Directory.CreateDirectory(config.Target); } - CommonLibrary.XMLSystem.Save(fullPath, dataPatchInformation); + CommonLibrary.XmlSystem.Save(fullPath, dataPatchInformation); } } @@ -126,7 +139,7 @@ namespace Mitria_Minecraft_Updater public string InformationToLauncher { get; set; } //{InformationDirectory}/Launcher.xml public string InformationToData { get; set; } // {InformationDirectory}/Data.xml - + public string InformationToServer { get; set; } public string LauncherSource { get; set; } // {Source}/Launcher public string LauncherUrl { get; set; } // {Target}/Launcher public string LauncherFileName { get; set; } // 런처 파일이름