diff --git a/Download.Designer.cs b/Download.Designer.cs index a835dcd..11ad008 100644 --- a/Download.Designer.cs +++ b/Download.Designer.cs @@ -38,24 +38,27 @@ private void InitializeComponent() // // DLBar // - this.DLBar.Location = new System.Drawing.Point(12, 12); + this.DLBar.Location = new System.Drawing.Point(20, 70); this.DLBar.Name = "DLBar"; - this.DLBar.Size = new System.Drawing.Size(532, 28); + this.DLBar.Size = new System.Drawing.Size(460, 8); + this.DLBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous; this.DLBar.TabIndex = 0; // // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(12, 43); + this.label1.Font = new System.Drawing.Font("Segoe UI", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.label1.Location = new System.Drawing.Point(20, 20); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(67, 15); + this.label1.Size = new System.Drawing.Size(200, 25); this.label1.TabIndex = 1; - this.label1.Text = "Download: "; + this.label1.Text = "Updating YuukiPS..."; // // GetNameDownload // this.GetNameDownload.AutoSize = true; - this.GetNameDownload.Location = new System.Drawing.Point(75, 43); + this.GetNameDownload.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.GetNameDownload.Location = new System.Drawing.Point(20, 50); this.GetNameDownload.Name = "GetNameDownload"; this.GetNameDownload.Size = new System.Drawing.Size(19, 15); this.GetNameDownload.TabIndex = 2; @@ -64,47 +67,59 @@ private void InitializeComponent() // GetNumDownload // this.GetNumDownload.AutoSize = true; - this.GetNumDownload.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.GetNumDownload.Location = new System.Drawing.Point(12, 87); + this.GetNumDownload.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.GetNumDownload.Location = new System.Drawing.Point(20, 85); this.GetNumDownload.Name = "GetNumDownload"; - this.GetNumDownload.Size = new System.Drawing.Size(16, 20); + this.GetNumDownload.Size = new System.Drawing.Size(16, 15); this.GetNumDownload.TabIndex = 3; this.GetNumDownload.Text = "?"; // // btDownload // - this.btDownload.Location = new System.Drawing.Point(12, 61); + this.btDownload.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(122)))), ((int)(((byte)(204))))); + this.btDownload.FlatAppearance.BorderSize = 0; + this.btDownload.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btDownload.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.btDownload.ForeColor = System.Drawing.Color.White; + this.btDownload.Location = new System.Drawing.Point(320, 110); this.btDownload.Name = "btDownload"; - this.btDownload.Size = new System.Drawing.Size(75, 23); + this.btDownload.Size = new System.Drawing.Size(75, 30); this.btDownload.TabIndex = 4; this.btDownload.Text = "Start"; - this.btDownload.UseVisualStyleBackColor = true; + this.btDownload.UseVisualStyleBackColor = false; this.btDownload.Click += new System.EventHandler(this.btDownload_Click); // // btCancel // - this.btCancel.Location = new System.Drawing.Point(93, 61); + this.btCancel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(231)))), ((int)(((byte)(76)))), ((int)(((byte)(60))))); + this.btCancel.FlatAppearance.BorderSize = 0; + this.btCancel.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btCancel.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.btCancel.ForeColor = System.Drawing.Color.White; + this.btCancel.Location = new System.Drawing.Point(405, 110); this.btCancel.Name = "btCancel"; - this.btCancel.Size = new System.Drawing.Size(75, 23); + this.btCancel.Size = new System.Drawing.Size(75, 30); this.btCancel.TabIndex = 5; this.btCancel.Text = "Cancel"; - this.btCancel.UseVisualStyleBackColor = true; - this.btCancel.Click += new System.EventHandler(this.btCancel_Click); + this.btCancel.UseVisualStyleBackColor = false; + this.btCancel.Click += new System.EventHandler(this.BTCancel_Click); // // Download // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(556, 111); + this.BackColor = System.Drawing.Color.White; + this.ClientSize = new System.Drawing.Size(500, 160); this.Controls.Add(this.btCancel); this.Controls.Add(this.btDownload); this.Controls.Add(this.GetNumDownload); this.Controls.Add(this.GetNameDownload); this.Controls.Add(this.label1); this.Controls.Add(this.DLBar); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Name = "Download"; - this.Text = "Download"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "YuukiPS Updater"; this.Load += new System.EventHandler(this.Download_Load); this.ResumeLayout(false); this.PerformLayout(); diff --git a/Download.cs b/Download.cs index 9c6efe4..dc1fec8 100644 --- a/Download.cs +++ b/Download.cs @@ -7,41 +7,43 @@ namespace YuukiPS_Launcher { public partial class Download : Form { - private string set_download = ""; - private string set_folder = ""; + private readonly string setDownload = ""; + private readonly string setFolder = ""; private DownloadService? dl = null; - public Download(string url_download = "", string folder_download = "") + public Download(string urlDownload = "", string folderDownload = "") { - set_download = url_download; - set_folder = folder_download; + setDownload = urlDownload; + setFolder = folderDownload; InitializeComponent(); } private void btDownload_Click(object sender, EventArgs e) { - if (string.IsNullOrEmpty(set_download)) + if (string.IsNullOrEmpty(setDownload)) { - MessageBox.Show("Download failed because no url was found"); + Logger.Error("Download", "Download failed: No URL provided"); + MessageBox.Show("Download failed because no URL was found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (Directory.Exists(set_folder)) + if (!Directory.Exists(Path.GetDirectoryName(setFolder))) { - MessageBox.Show("Can't save file because folder can't be found or can't be accessed"); + Logger.Error("Download", $"Download failed: Folder not found or inaccessible - {setFolder}"); + MessageBox.Show("Can't save file because the destination folder can't be found or accessed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - if (File.Exists(set_folder)) + if (File.Exists(setFolder)) { - Logger.Info("Download", $"File old found {set_folder} remove for redownload?"); - File.Delete(set_folder); + Logger.Info("Download", $"File old found {setFolder} remove for redownload?"); + File.Delete(setFolder); } btDownload.Enabled = false; - GetNameDownload.Text = set_download; + GetNameDownload.Text = setDownload; if (dl == null) { @@ -58,7 +60,7 @@ private void btDownload_Click(object sender, EventArgs e) dl.ChunkDownloadProgressChanged += Dl_ChunkDownloadProgressChanged; try { - dl.DownloadFileTaskAsync(set_download, set_folder); + dl.DownloadFileTaskAsync(setDownload, setFolder); } catch (Exception ek) { @@ -74,11 +76,11 @@ private void btDownload_Click(object sender, EventArgs e) private void Dl_DownloadFileCompleted(object? sender, AsyncCompletedEventArgs e) { - btDownload.Invoke((Action)delegate + btDownload.Invoke(delegate { btDownload.Enabled = true; }); - GetNumDownload.Invoke((Action)delegate + GetNumDownload.Invoke(delegate { GetNumDownload.Text = "Done"; }); @@ -92,6 +94,7 @@ private void Dl_ChunkDownloadProgressChanged(object? sender, DownloadProgressCha private void Dl_DownloadProgressChanged(object? sender, DownloadProgressChangedEventArgs e) { + if (dl == null || dl.IsCancelled) return; double nonZeroSpeed = e.BytesPerSecondSpeed + 0.0001; int estimateTime = (int)((e.TotalBytesToReceive - e.ReceivedBytesSize) / nonZeroSpeed); bool isMinutes = estimateTime >= 60; @@ -110,7 +113,7 @@ private void Dl_DownloadProgressChanged(object? sender, DownloadProgressChangedE } else { - DLBar.Invoke((Action)delegate + DLBar.Invoke(delegate { DLBar.Value = (int)e.ProgressPercentage; }); @@ -119,7 +122,7 @@ private void Dl_DownloadProgressChanged(object? sender, DownloadProgressChangedE string bytesReceived = Tool.CalcMemoryMensurableUnit(e.ReceivedBytesSize); string totalBytesToReceive = Tool.CalcMemoryMensurableUnit(e.TotalBytesToReceive); - GetNumDownload.Invoke((Action)delegate + GetNumDownload.Invoke(delegate { GetNumDownload.Text = $"{bytesReceived} of {totalBytesToReceive} | {estimateTime} {timeLeftUnit} left | Speed: {Tool.CalcMemoryMensurableUnit(e.BytesPerSecondSpeed)}/s"; }); @@ -127,15 +130,40 @@ private void Dl_DownloadProgressChanged(object? sender, DownloadProgressChangedE private void Dl_DownloadStarted(object? sender, DownloadStartedEventArgs e) { - Console.WriteLine("Start Download: " + set_download); + Logger.Info("Download", $"Starting download - URL: {setDownload}, Destination: {setFolder}"); } - private void btCancel_Click(object sender, EventArgs e) + private async void BTCancel_Click(object sender, EventArgs e) { if (dl != null) { - dl.CancelAsync(); - dl.Dispose(); + // dl.CancelAsync(); + // dl.Dispose(); + try + { + btCancel.Enabled = false; + btDownload.Enabled = false; + GetNumDownload.Text = "Canceling..."; + + dl.CancelAsync(); + await Task.Delay(1000); // give some time to cancel + + dl.Dispose(); + dl = null; + + GetNumDownload.Text = "Canceled"; + DLBar.Value = 0; + } + catch (Exception ex) + { + Logger.Error("Download", $"Error during canceling download: {ex.Message}"); + MessageBox.Show($"Error during canceling download: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + finally + { + btCancel.Enabled = true; + btDownload.Enabled = true; + } } DialogResult = DialogResult.Cancel; } diff --git a/Extra/Discord.cs b/Extra/Discord.cs index 70254b5..99679d8 100644 --- a/Extra/Discord.cs +++ b/Extra/Discord.cs @@ -14,8 +14,10 @@ public void Ready(string appid = "1023479009335582830") { if (client == null) { - client = new DiscordRpcClient(appid); - client.Logger = new ConsoleLogger() { Level = LogLevel.None }; + client = new DiscordRpcClient(appid) + { + Logger = new ConsoleLogger() { Level = LogLevel.None } + }; client.RegisterUriScheme(); //Subscribe to events @@ -71,7 +73,7 @@ public void UpdateStatus(string details, string state, string iconkey = "", int { Editor.Buttons = new Button[] { - new Button() { Label = "Join", Url = API.WEB_LINK } + new() { Label = "Join", Url = API.WebLink } }; } diff --git a/Game/Genshin/Patch/HexUtility.cs b/Game/Genshin/Patch/HexUtility.cs index f368700..2999a94 100644 --- a/Game/Genshin/Patch/HexUtility.cs +++ b/Game/Genshin/Patch/HexUtility.cs @@ -1,62 +1,72 @@ -public class HexUtility + +namespace YuukiPS_Launcher.Game.Genshin.Patch { - public static bool EqualsBytes(byte[] b1, params byte[] b2) + public class HexUtility { - if (b1.Length != b2.Length) - return false; - for (int i = 0; i < b1.Length; i++) + public static bool EqualsBytes(byte[] b1, params byte[] b2) { - if (b1[i] != b2[i]) + if (b1.Length != b2.Length) return false; - } - return true; - } - - public static byte[] Replace(byte[] sourceByteArray, List replaces) - { - byte[] newByteArray = new byte[sourceByteArray.Length]; - Buffer.BlockCopy(sourceByteArray, 0, newByteArray, 0, sourceByteArray.Length); - int offset = 0; - foreach (HexReplaceEntity rep in replaces) - { - if (EqualsBytes(rep.oldValue, rep.newValue)) + for (int i = 0; i < b1.Length; i++) { - continue; + if (b1[i] != b2[i]) + return false; } + return true; + } - for (; offset < sourceByteArray.Length; offset++) + public static byte[] Replace(byte[] sourceByteArray, List replaces) + { + byte[] newByteArray = new byte[sourceByteArray.Length]; + Buffer.BlockCopy(sourceByteArray, 0, newByteArray, 0, sourceByteArray.Length); + int offset = 0; + foreach (HexReplaceEntity rep in replaces) { - if (sourceByteArray[offset] == rep.oldValue[0]) + if (EqualsBytes(rep.OldValue, rep.NewValue)) { - if (sourceByteArray.Length - offset < rep.oldValue.Length) - break; + continue; + } - bool find = true; - for (int i = 1; i < rep.oldValue.Length - 1; i++) + for (; offset < sourceByteArray.Length; offset++) + { + if (sourceByteArray[offset] == rep.OldValue[0]) { - if (sourceByteArray[offset + i] != rep.oldValue[i]) + if (sourceByteArray.Length - offset < rep.OldValue.Length) + break; + + bool find = true; + for (int i = 1; i < rep.OldValue.Length - 1; i++) { - find = false; + if (sourceByteArray[offset + i] != rep.OldValue[i]) + { + find = false; + break; + } + } + if (find) + { + Buffer.BlockCopy(rep.NewValue, 0, newByteArray, offset, rep.NewValue.Length); + offset += rep.NewValue.Length - 1; break; } } - if (find) - { - Buffer.BlockCopy(rep.newValue, 0, newByteArray, offset, rep.newValue.Length); - offset += (rep.newValue.Length - 1); - break; - } } } + return newByteArray; } - return newByteArray; } -} -public class HexReplaceEntity -{ - public byte[] oldValue { get; set; } + public class HexReplaceEntity + { + public byte[] OldValue { get; set; } = null!; + public byte[] NewValue { get; set; } = null!; - public byte[] newValue { get; set; } + public HexReplaceEntity() { } -} \ No newline at end of file + public HexReplaceEntity(byte[] oldValue, byte[] newValue) + { + OldValue = oldValue; + NewValue = newValue; + } + } +} diff --git a/Game/Genshin/Patch/Metadata.cs b/Game/Genshin/Patch/Metadata.cs deleted file mode 100644 index 0f98e29..0000000 --- a/Game/Genshin/Patch/Metadata.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System.Text; -using YuukiPS_Launcher.patch; - -namespace YuukiPS_Launcher.Game.Genshin.Patch -{ - public static class Metadata - { - public static byte[] bytes = { 0x0D, 0x0A, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }; - - public static string Do(string original_file, string patch_file, string key1nopatch, string key1patch, string key2nopatch, string key2patch) - { - if (!File.Exists(original_file)) - { - return "Metadata file not found"; - } - byte[] filebytes = File.ReadAllBytes(original_file); - byte[] data = decrypt(filebytes); - - Array.Resize(ref data, data.Length - 16384); - - int count = 0; - string str; - - data = Methods.ReplaceBytes(data, ToFixBytesP1(key1nopatch), ToFixBytesP1(key1patch), ref count); - if (count == 0) - { - return "Key1 can't be patched"; - } - - data = Methods.ReplaceBytes(data, Encoding.UTF8.GetBytes(key2nopatch), Encoding.UTF8.GetBytes(key2patch), ref count); - - if (count != 0) - { - Array.Resize(ref data, data.Length + 16384); - filebytes = encrypt(data); - - str = ""; - FileStream stream = File.Create(patch_file); - stream.Write(data, 0, data.Length); - stream.Close(); - } - else - { - str = "Key2 can't be patched"; - } - - return str; - } - - public static string Decrypt(string original_file, string patch_file) - { - if (!File.Exists(original_file)) - { - return "Metadata file not found"; - } - byte[] filebytes = File.ReadAllBytes(original_file); - byte[] data = decrypt(filebytes); - Array.Resize(ref data, data.Length - 16384); - FileStream stream = File.Create(patch_file); - stream.Write(data, 0, data.Length); - stream.Close(); - - var str = ""; - return str; - } - - public static byte[] ToFixBytesP1(string key) - { - byte[] bp1 = Encoding.UTF8.GetBytes(key.Substring(0, 48)); - byte[] bp2 = Encoding.UTF8.GetBytes(key.Substring(48, 57)); - byte[] bp3 = Encoding.UTF8.GetBytes(key.Substring(105, 57)); - byte[] bp4 = Encoding.UTF8.GetBytes(key.Substring(162)); - byte[] ret = bp1.Concat(bytes).Concat(bp2).Concat(bytes).Concat(bp3).Concat(bytes).Concat(bp4).ToArray(); - return ret; - - } - - unsafe static public byte[] decrypt(byte[] bytes) - { - fixed (byte* d1 = bytes) - { - Patch_Meta patch_Meta = new Patch_Meta(); - patch_Meta.decrypt_global_metadata(d1, Convert.ToUInt64(bytes.Length)); - return bytes; - } - } - unsafe static public byte[] encrypt(byte[] bytes) - { - fixed (byte* d1 = bytes) - { - Patch_Meta patch_Meta = new Patch_Meta(); - patch_Meta.encrypt_global_metadata(d1, Convert.ToUInt64(bytes.Length)); - return bytes; - } - } - - } -} diff --git a/Game/Genshin/Patch/Methods.cs b/Game/Genshin/Patch/Methods.cs deleted file mode 100644 index 6c8bed3..0000000 --- a/Game/Genshin/Patch/Methods.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System.Diagnostics; - -namespace YuukiPS_Launcher.patch -{ - public static class Methods - { - public static byte[] ReplaceBytes(byte[] src, byte[] search, byte[] repl, ref int i) - { - byte[] dst = src; - int index = FindBytes(src, search); - if (index == -1) - { - return src; - } - if (index >= 0) - { - dst = new byte[src.Length - search.Length + repl.Length]; - - Buffer.BlockCopy(src, 0, dst, 0, index); - - Buffer.BlockCopy(repl, 0, dst, index, repl.Length); - - Buffer.BlockCopy( - src, - index + search.Length, - dst, - index + repl.Length, - src.Length - (index + search.Length)); - } - i++; - return dst; - } - - public static int FindBytes(byte[] src, byte[] find) - { - int index = -1; - int matchIndex = 0; - - for (int i = 0; i < src.Length; i++) - { - if (src[i] == find[matchIndex]) - { - if (matchIndex == (find.Length - 1)) - { - index = i - matchIndex; - break; - } - matchIndex++; - } - else - { - matchIndex = 0; - } - - } - - Debug.Print("FindIndex:" + index); - return index; - } - } -} diff --git a/Game/Genshin/Patch/UserAssembly.cs b/Game/Genshin/Patch/UserAssembly.cs deleted file mode 100644 index 4211740..0000000 --- a/Game/Genshin/Patch/UserAssembly.cs +++ /dev/null @@ -1,112 +0,0 @@ -using System.Text; - -namespace YuukiPS_Launcher.Game.Genshin.Patch -{ - public static class UserAssembly - { - public static readonly long Pas = 0x4889501048BA; - public static readonly long Pbs = 0x908000000048BA; - public static readonly byte[] Pbb = { 0x48, 0x89 }; - - public static string Do(string original_file, string patch_file, string keynopatch, string keypatch) - { - //Console.WriteLine("KeyNopatch" + "\n" + keynopatch); - //Console.WriteLine("KeyPatch" + "\n" + keypatch); - - if (!File.Exists(original_file)) - { - return "UserAssembly file not found"; - } - - byte[] UA_Original = Encoding.ASCII.GetBytes(keynopatch); - byte[] UA_key = Encoding.ASCII.GetBytes(keypatch); - - // Get Byte file original - byte[] UA = File.ReadAllBytes(original_file); - - int Offset = 0; - int DataLength; - - List UA_list = new List(); - - while ((DataLength = UA_Original.Length - Offset) > 0) - { - if (DataLength > 8) - DataLength = 8; - - HexReplaceEntity hexReplaceEntity = new HexReplaceEntity(); - - hexReplaceEntity.oldValue = new byte[8]; - Buffer.BlockCopy(UA_Original, Offset, hexReplaceEntity.oldValue, 0, DataLength); - - hexReplaceEntity.newValue = new byte[8]; - Buffer.BlockCopy(UA_key, Offset, hexReplaceEntity.newValue, 0, DataLength); - - UA_list.Add(hexReplaceEntity); - Offset += DataLength; - } - - byte[] UA_OS_patched = HexUtility.Replace(UA, UA_list); - - if (!HexUtility.EqualsBytes(UA, UA_OS_patched)) - { - try - { - File.WriteAllBytes(patch_file, UA_OS_patched); - return ""; - } - catch (IOException e) - { - return e.Message + "\n Cannot write to file."; - } - } - return "Patch UserAssembly Failed, Send console logs don't just screenshot this message."; - } - - public static byte[] ToUABytes(string key) - { - int count = key.Length + 2; - List uabytes = Encoding.UTF8.GetBytes(key).ToList(); - for (int i = 1; i < 44; i++) - { - if (i <= 29) - { - byte[] k = GetBytesPb(29 - i); - for (int j = 0; j < k.Length; j++) - { - uabytes.Insert(count - 8 * i, k[k.Length - 1 - j]); - } - } - else - { - byte[] k = GetBytesPa(14 - (i - 29)); - for (int j = 0; j < k.Length; j++) - { - uabytes.Insert(count - 8 * i, k[k.Length - 1 - j]); - } - } - } - return uabytes.ToArray(); - } - - public static byte[] GetBytesPa(int count)//0-13 - { - byte[] pa = BitConverter.GetBytes(Pas + (0x80000 * count)); - Array.Resize(ref pa, 6); - pa = pa.Reverse().ToArray(); - return pa; - } - public static byte[] GetBytesPb(int count)//0-28 - { - byte[] pb = BitConverter.GetBytes(Pbs + (0x80000000000 * count)); - Array.Resize(ref pb, 7); - byte[] pb2 = Pbb.Concat(pb.Reverse()).ToArray(); - if (count >= 16) - { - pb2[2] = 0x90; - pb2[4] = 0x01; - } - return pb2; - } - } -} diff --git a/Game/Genshin/ServerRegionID.cs b/Game/Genshin/ServerRegionID.cs index 1d393a4..6ed1a6d 100644 --- a/Game/Genshin/ServerRegionID.cs +++ b/Game/Genshin/ServerRegionID.cs @@ -3,23 +3,27 @@ using System; using static YuukiPS_Launcher.Game.Genshin.Settings; -public class ServerRegionIDConverter : StringEnumConverter +namespace YuukiPS_Launcher.Game.Genshin { - public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) + public class ServerRegionIDConverter : StringEnumConverter { - if (reader.TokenType == JsonToken.String) + public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) { - string enumText = reader.Value.ToString(); - foreach (ServerRegionID enumValue in Enum.GetValues(typeof(ServerRegionID))) + if (reader.TokenType == JsonToken.String) { - if (enumValue.ToString().Equals(enumText, StringComparison.OrdinalIgnoreCase)) + string? enumText = reader.Value?.ToString(); + foreach (ServerRegionID enumValue in Enum.GetValues(typeof(ServerRegionID))) { - return enumValue; + if (enumValue.ToString().Equals(enumText, StringComparison.OrdinalIgnoreCase)) + { + return enumValue; + } } + // Handle unknown value here + return ServerRegionID.os_usa; // Default value } - // Handle unknown value here - return ServerRegionID.os_usa; // Default value + return base.ReadJson(reader, objectType, existingValue, serializer); } - return base.ReadJson(reader, objectType, existingValue, serializer); } } + diff --git a/Game/Genshin/Settings.cs b/Game/Genshin/Settings.cs index 1e0a08c..620643e 100644 --- a/Game/Genshin/Settings.cs +++ b/Game/Genshin/Settings.cs @@ -8,21 +8,16 @@ namespace YuukiPS_Launcher.Game.Genshin public class Settings { // Source Code: https://github.com/neon-nyan/CollapseLauncher - private static string OsPathKey = @"Software\miHoYo\Genshin Impact"; - private static string CnPathKey = @"Software\miHoYo\原神"; + private static readonly string OsPathKey = @"Software\miHoYo\Genshin Impact"; + private static readonly string CnPathKey = @"Software\miHoYo\原神"; - private int ch = 1; + private readonly int ch = 1; public Settings(int ch) { this.ch = ch; } - public int GetChannel() - { - return ch; - } - public string GetReg() { return ch == 1 ? OsPathKey : CnPathKey; @@ -34,36 +29,6 @@ public string GetReg() return (byte[]?)keys?.GetValue("GENERAL_DATA_h2389025596", "{}", RegistryValueOptions.None); } - public string GetDataGeneralString() - { - RegistryKey? keys = Registry.CurrentUser.OpenSubKey(GetReg()); - var data = (byte[]?)keys?.GetValue("GENERAL_DATA_h2389025596", "{}", RegistryValueOptions.None); - if (data != null) - { - return Encoding.UTF8.GetString(data); - } - else - { - return ""; - } - } - - public GeneralDataProp? GetDataGeneralJson() - { - RegistryKey? keys = Registry.CurrentUser.OpenSubKey(GetReg()); - var data = (byte[]?)keys?.GetValue("GENERAL_DATA_h2389025596", "{}", RegistryValueOptions.None); - if (data != null) - { - var tesss = Encoding.UTF8.GetString(data); - if (tesss != null) - { - return JsonConvert.DeserializeObject(tesss); - } - } - return null; - - } - public string? GetGameLanguage() { ReadOnlySpan value; @@ -90,7 +55,7 @@ public int GetVoiceLanguageID() return 2; } ReadOnlySpan regValue = Encoding.UTF8.GetString(value).AsSpan().Trim('\0'); - return JsonConvert.DeserializeObject(new string(regValue))?.deviceVoiceLanguageType ?? 2; + return JsonConvert.DeserializeObject(new string(regValue))?.DeviceVoiceLanguageType ?? 2; } public int GetRegServerNameID() @@ -102,74 +67,23 @@ public int GetRegServerNameID() return 0; } string regValue = new string(Encoding.UTF8.GetString(value).AsSpan().Trim('\0')); - return (int)(JsonConvert.DeserializeObject(regValue)?.selectedServerName ?? ServerRegionID.os_usa); + return (int)(JsonConvert.DeserializeObject(regValue)?.SelectedServerName ?? ServerRegionID.os_usa); } public enum ServerRegionID { os_usa = 0, - os_euro = 1, - os_asia = 2, - os_cht = 3 + // os_euro = 1, + // os_asia = 2, + // os_cht = 3 } public class GeneralDataProp { - public string deviceUUID { get; set; } = ""; - public string userLocalDataVersionId { get; set; } = "0.0.1"; - public int deviceLanguageType { get; set; } = 1; - public int deviceVoiceLanguageType { get; set; } = 2; - [JsonConverter(typeof(ServerRegionIDConverter))] - public ServerRegionID? selectedServerName { get; set; } - public int localLevelIndex { get; set; } = 0; - public string deviceID { get; set; } = ""; - public string targetUID { get; set; } = ""; - public string curAccountName { get; set; } = ""; - public string uiSaveData { get; set; } = ""; - public string inputData { get; set; } = ""; - // Initialize 60 fps limit if it's blank - public string graphicsData { get; set; } = "{\"customVolatileGrades\":[{\"key\":1,\"value\":2}]"; - public string globalPerfData { get; set; } = ""; - public int miniMapConfig { get; set; } = 1; - public bool enableCameraSlope { get; set; } = true; - public bool enableCameraCombatLock { get; set; } = true; - public bool completionPkg { get; set; } = false; - public bool completionPlayGoPkg { get; set; } = false; - public bool onlyPlayWithPSPlayer { get; set; } = false; - public bool needPlayGoFullPkgPatch { get; set; } = false; - public bool resinNotification { get; set; } = true; - public bool exploreNotification { get; set; } = true; - public int volumeGlobal { get; set; } = 10; - public int volumeSFX { get; set; } = 10; - public int volumeMusic { get; set; } = 10; - public int volumeVoice { get; set; } = 10; - public int audioAPI { get; set; } = -1; - public int audioDynamicRange { get; set; } = 0; - // Use Surround by default if it's blank - public int audioOutput { get; set; } = 1; - public bool _audioSuccessInit { get; set; } = true; - public bool enableAudioChangeAndroidMinimumBufferCapacity { get; set; } = true; - public int audioAndroidMiniumBufferCapacity { get; set; } = 2 << 10; - public bool motionBlur { get; set; } = true; - public bool gyroAiming { get; set; } = false; - public bool firstHDRSetting { get; set; } = true; - public double maxLuminosity { get; set; } = 0.0f; - public double uiPaperWhite { get; set; } = 0.0f; - public double scenePaperWhite { get; set; } = 0.0f; - public double gammaValue { get; set; } = 2.200000047683716f; - public IEnumerable _overrideControllerMapKeyList { get; set; } = new List(); - public IEnumerable _overrideControllerMapValueList { get; set; } = new List(); - public int lastSeenPreDownloadTime { get; set; } = 0; - public bool mtrCached { get; set; } = false; - public bool mtrIsOpen { get; set; } = false; - public int mtrMaxTTL { get; set; } = 0x20; - public int mtrTimeOut { get; set; } = 0x1388; - public int mtrTraceCount { get; set; } = 5; - public int mtrAbortTimeOutCount { get; set; } = 3; - public int mtrAutoTraceInterval { get; set; } = 0; - public int mtrTraceCDEachReason { get; set; } = 0x258; - public IEnumerable _customDataKeyList { get; set; } = new List(); - public IEnumerable _customDataValueList { get; set; } = new List(); + [JsonProperty("deviceVoiceLanguageType")] + public int DeviceVoiceLanguageType { get; set; } = 2; + [JsonConverter(typeof(ServerRegionIDConverter)), JsonProperty("selectedServerName")] + public ServerRegionID? SelectedServerName { get; set; } } } diff --git a/Json/Config.cs b/Json/Config.cs index b5c2060..e57601d 100644 --- a/Json/Config.cs +++ b/Json/Config.cs @@ -1,57 +1,58 @@ using Newtonsoft.Json; +using YuukiPS_Launcher.Utils; namespace YuukiPS_Launcher.Json { public class Config { // Folder - public static string CurrentlyPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ""); - public static string DataConfig = Path.Combine(CurrentlyPath, "data"); - public static string Modfolder = Path.Combine(CurrentlyPath, "mod"); + public static string CurrentlyPath { get; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ""); + public static string DataConfig { get; } = Path.Combine(CurrentlyPath, "data"); + public static string Modfolder { get; } = Path.Combine(CurrentlyPath, "mod"); // File Config - public static string ConfigPath = Path.Combine(DataConfig, "config.json"); + public static string ConfigPath { get; } = Path.Combine(DataConfig, "config.json"); public string profile_default = "Default"; - public List profile { get; set; } = new List(); + public List Profile { get; set; } = new List(); - public static Config LoadConfig(string load_file = "") + public static Config LoadConfig(string loadFile = "") { // Create missing folder - Directory.CreateDirectory(Config.DataConfig); - Directory.CreateDirectory(Config.Modfolder); + Directory.CreateDirectory(DataConfig); + Directory.CreateDirectory(Modfolder); - Config config = new Config(); + Config config = new(); - if (string.IsNullOrEmpty(load_file)) + if (string.IsNullOrEmpty(loadFile)) { - load_file = ConfigPath; + loadFile = ConfigPath; } - if (File.Exists(load_file)) + if (File.Exists(loadFile)) { - string data = File.ReadAllText(load_file); + string data = File.ReadAllText(loadFile); try { - var tmp_configdata = JsonConvert.DeserializeObject(data); - if (tmp_configdata != null) + var tmpConfigData = JsonConvert.DeserializeObject(data); + if (tmpConfigData != null) { - config = tmp_configdata; + config = tmpConfigData; } } catch (Exception ex) { - Console.WriteLine("Error load config: " + ex.Message + ", so make new profile"); + Logger.Error("Config", "Error load config: " + ex.Message); } } else { - Console.WriteLine("No config file found, so make new profile"); + Logger.Warning("Config", "No config file found. Creating a new default profile."); } - if (config.profile.Count == 0) + if (config.Profile.Count == 0) { - config.profile.Add(new Profile() { name = "Default" }); + config.Profile.Add(new Profile() { name = "Default" }); } return config; diff --git a/Json/GameClient/Client.cs b/Json/GameClient/Client.cs deleted file mode 100644 index 7f372a2..0000000 --- a/Json/GameClient/Client.cs +++ /dev/null @@ -1,91 +0,0 @@ -namespace YuukiPS_Launcher.Json.GameClient -{ - public class Data - { - public Game game { get; set; } - public Plugin plugin { get; set; } - public string web_url { get; set; } - public object force_update { get; set; } - public object pre_download_game { get; set; } - public List deprecated_packages { get; set; } - public object sdk { get; set; } - public List deprecated_files { get; set; } - } - - public class DeprecatedFile - { - public string name { get; set; } - public string md5 { get; set; } - } - - public class DeprecatedPackage - { - public string name { get; set; } - public string md5 { get; set; } - } - - public class Diff - { - public string name { get; set; } - public string version { get; set; } = "0.0.0"; - public string path { get; set; } - public string size { get; set; } - public string md5 { get; set; } - public bool is_recommended_update { get; set; } - public List voice_packs { get; set; } - public string package_size { get; set; } - } - - public class Game - { - public Latest latest { get; set; } - public List diffs { get; set; } - } - - public class Latest - { - public string name { get; set; } - public string version { get; set; } - public string path { get; set; } - public string size { get; set; } - public string md5 { get; set; } - public string entry { get; set; } - public List voice_packs { get; set; } - public string decompressed_path { get; set; } - public List segments { get; set; } - public string package_size { get; set; } - } - - public class Plugin - { - public List plugins { get; set; } - public string version { get; set; } - } - - public class Plugin2 - { - public string name { get; set; } - public string version { get; set; } - public string path { get; set; } - public string size { get; set; } - public string md5 { get; set; } - public string entry { get; set; } - } - - public class Client - { - public int retcode { get; set; } - public string message { get; set; } - public Data data { get; set; } - } - - public class VoicePack - { - public string language { get; set; } - public string name { get; set; } - public string path { get; set; } - public string size { get; set; } - public string md5 { get; set; } - public string package_size { get; set; } - } -} diff --git a/Json/GameClient/Patch.cs b/Json/GameClient/Patch.cs index 40516c4..a67ac95 100644 --- a/Json/GameClient/Patch.cs +++ b/Json/GameClient/Patch.cs @@ -1,27 +1,40 @@ -namespace YuukiPS_Launcher.Json.GameClient +using System.Text.Json.Serialization; + +namespace YuukiPS_Launcher.Json.GameClient { public class Original { - public string file { get; set; } - public string location { get; set; } - public string md5 { get; set; } + [JsonPropertyName("file")] + public required string File { get; set; } + [JsonPropertyName("location")] + public required string Location { get; set; } + [JsonPropertyName("md5")] + public required string MD5 { get; set; } } public class Patched { - public string file { get; set; } - public string location { get; set; } - public string md5 { get; set; } + [JsonPropertyName("file")] + public required string File { get; set; } + [JsonPropertyName("location")] + public required string Location { get; set; } + [JsonPropertyName("md5")] + public required string MD5 { get; set; } } public class Patch { - public string version { get; set; } = "0.0.0"; - public string channel { get; set; } = "Global"; - public string release { get; set; } = "Official"; - public string method { get; set; } = "copy"; // rare use - public string nosupport { get; set; } = ""; - public List patched { get; set; } - public List original { get; set; } + [JsonPropertyName("version")] + public string Version { get; set; } = "0.0.0"; + [JsonPropertyName("channel")] + public string Channel { get; set; } = "Global"; + [JsonPropertyName("release")] + public string Release { get; set; } = "Official"; + [JsonPropertyName("nosupport")] + public string NoSupport { get; set; } = ""; + [JsonPropertyName("patched")] + public List Patched { get; set; } = new(); + [JsonPropertyName("original")] + public List Original { get; set; } = new(); } } diff --git a/Json/GameType.cs b/Json/GameType.cs index 199fa20..6c0e434 100644 --- a/Json/GameType.cs +++ b/Json/GameType.cs @@ -1,41 +1,52 @@ using System.Reflection; using System.Text.RegularExpressions; -public enum GameType +namespace YuukiPS_Launcher.Json { - [StringValue("Genshin Impact")] - GenshinImpact = 1, - - [StringValue("Star Rail")] - StarRail = 2 -} + public enum GameType + { + [StringValue("Genshin Impact")] + GenshinImpact = 1, -public class StringValueAttribute : Attribute -{ - public string Value { get; } + [StringValue("Star Rail")] + StarRail = 2 + } - public StringValueAttribute(string value) + [AttributeUsage(AttributeTargets.Field)] + public class StringValueAttribute : Attribute { - Value = value; + public string Value { get; } + + public StringValueAttribute(string value) + { + Value = value; + } } -} -public static class EnumExtensions -{ - public static string GetStringValue(this Enum value) + public static class EnumExtensions { - Type type = value.GetType(); - string name = Enum.GetName(type, value); + public static string GetStringValue(this Enum value) + { + Type type = value.GetType(); + string? name = Enum.GetName(type, value); - MemberInfo member = type.GetField(name); - StringValueAttribute attribute = member.GetCustomAttribute(); + if (name == null) + return value.ToString(); - return attribute != null ? attribute.Value : value.ToString(); - } - public static string SEOUrl(this GameType gameType) - { - string gameTypeName = gameType.ToString(); - string kebabCase = Regex.Replace(gameTypeName, "([a-z])([A-Z])", "$1-$2").ToLower(); - return kebabCase; + FieldInfo? field = type.GetField(name); + if (field == null) + return value.ToString(); + + StringValueAttribute? attribute = field.GetCustomAttribute(); + return attribute?.Value ?? value.ToString(); + } + + public static string SEOUrl(this GameType gameType) + { + string gameTypeName = gameType.ToString(); + string kebabCase = Regex.Replace(gameTypeName, "([a-z])([A-Z])", "$1-$2").ToLower(); + return kebabCase; + } } -} \ No newline at end of file +} + diff --git a/Json/Mod/Cheat.cs b/Json/Mod/Cheat.cs index 5471e0b..6bc8bd5 100644 --- a/Json/Mod/Cheat.cs +++ b/Json/Mod/Cheat.cs @@ -1,31 +1,41 @@ -namespace YuukiPS_Launcher.Json.Mod +using System.Text.Json.Serialization; + +namespace YuukiPS_Launcher.Json.Mod { public class Archive { - public string url { get; set; } - public string md5 { get; set; } - public string version { get; set; } - public string support { get; set; } - public List channel { get; set; } - public Config config { get; set; } - public string comment { get; set; } + [JsonPropertyName("url")] + public required string Url { get; set; } + [JsonPropertyName("md5")] + public required string Md5 { get; set; } + [JsonPropertyName("support")] + public required string Support { get; set; } + [JsonPropertyName("channel")] + public required List Channel { get; set; } + [JsonPropertyName("config")] + public required Config Config { get; set; } + [JsonPropertyName("comment")] + public required string Comment { get; set; } } public class Config { - public string injection { get; set; } - public string launcher { get; set; } - public string save { get; set; } - public int format { get; set; } // 1-cfg,2-json + [JsonPropertyName("launcher")] + public required string Launcher { get; set; } + [JsonPropertyName("save")] + public required string Save { get; set; } + [JsonPropertyName("format")] + public int Format { get; set; } // 1-cfg,2-json } public class Cheat { - public string nama { get; set; } - public string link { get; set; } - public string comment { get; set; } - public int game { get; set; } - public List archives { get; set; } + [JsonPropertyName("nama")] + public required string Nama { get; set; } + [JsonPropertyName("game")] + public int Game { get; set; } + [JsonPropertyName("archives")] + public required List Archives { get; set; } } } diff --git a/Json/Nightly.cs b/Json/Nightly.cs deleted file mode 100644 index ead25b8..0000000 --- a/Json/Nightly.cs +++ /dev/null @@ -1,32 +0,0 @@ -namespace YuukiPS_Launcher.Json -{ - public class Artifact - { - public int id { get; set; } - public string node_id { get; set; } - public string name { get; set; } - public int size_in_bytes { get; set; } - public string url { get; set; } - public string archive_download_url { get; set; } - public bool expired { get; set; } - public DateTime created_at { get; set; } - public DateTime updated_at { get; set; } - public DateTime expires_at { get; set; } - public WorkflowRun workflow_run { get; set; } - } - - public class Nightly - { - public int total_count { get; set; } - public List artifacts { get; set; } - } - - public class WorkflowRun - { - public long id { get; set; } - public int repository_id { get; set; } - public int head_repository_id { get; set; } - public string head_branch { get; set; } - public string head_sha { get; set; } - } -} diff --git a/Json/Profile.cs b/Json/Profile.cs index 8479265..4d35f0b 100644 --- a/Json/Profile.cs +++ b/Json/Profile.cs @@ -13,7 +13,7 @@ public override string ToString() public class Server { - public string url = API.WEB_LINK; + public string url = API.WebLink; public Proxy proxy = new(); public class Proxy { @@ -39,8 +39,8 @@ public class Extra //public int patch_metode = 1; // 1=NO PATCH, 2=RSA ()this should not be necessary because it is controlled by game server } - public Server server = new(); + public Server ServerConfig { get; set; } = new(); - public Game game = new(); + public Game GameConfig { get; set; } = new(); } } diff --git a/Json/Update.cs b/Json/Update.cs index 7dbf504..b72a41b 100644 --- a/Json/Update.cs +++ b/Json/Update.cs @@ -1,87 +1,28 @@ -namespace YuukiPS_Launcher.Json +using System.Text.Json.Serialization; + +namespace YuukiPS_Launcher.Json { - public class Asset + public class Assets { - public string url { get; set; } - public int id { get; set; } - public string node_id { get; set; } - public string name { get; set; } - public object label { get; set; } - public Uploader uploader { get; set; } - public string content_type { get; set; } - public string state { get; set; } - public int size { get; set; } - public int download_count { get; set; } - public DateTime created_at { get; set; } - public DateTime updated_at { get; set; } - public string browser_download_url { get; set; } - } + [JsonPropertyName("name")] + public required string Name { get; set; } - public class Author - { - public string login { get; set; } - public int id { get; set; } - public string node_id { get; set; } - public string avatar_url { get; set; } - public string gravatar_id { get; set; } - public string url { get; set; } - public string html_url { get; set; } - public string followers_url { get; set; } - public string following_url { get; set; } - public string gists_url { get; set; } - public string starred_url { get; set; } - public string subscriptions_url { get; set; } - public string organizations_url { get; set; } - public string repos_url { get; set; } - public string events_url { get; set; } - public string received_events_url { get; set; } - public string type { get; set; } - public bool site_admin { get; set; } + [JsonPropertyName("browser_download_url")] + public required string BrowserDownloadUrl { get; set; } } public class Update { - public string url { get; set; } - public string assets_url { get; set; } - public string upload_url { get; set; } - public string html_url { get; set; } - public int id { get; set; } - public Author author { get; set; } - public string node_id { get; set; } - public string tag_name { get; set; } - public string target_commitish { get; set; } - public string name { get; set; } - public bool draft { get; set; } - public bool prerelease { get; set; } - public DateTime created_at { get; set; } - public DateTime published_at { get; set; } - public List assets { get; set; } - public string tarball_url { get; set; } - public string zipball_url { get; set; } - public string body { get; set; } - } + [JsonPropertyName("tag_name")] + public required string TagName { get; set; } - public class Uploader - { - public string login { get; set; } - public int id { get; set; } - public string node_id { get; set; } - public string avatar_url { get; set; } - public string gravatar_id { get; set; } - public string url { get; set; } - public string html_url { get; set; } - public string followers_url { get; set; } - public string following_url { get; set; } - public string gists_url { get; set; } - public string starred_url { get; set; } - public string subscriptions_url { get; set; } - public string organizations_url { get; set; } - public string repos_url { get; set; } - public string events_url { get; set; } - public string received_events_url { get; set; } - public string type { get; set; } - public bool site_admin { get; set; } - } + [JsonPropertyName("name")] + public required string Name { get; set; } + [JsonPropertyName("assets")] + public required List Assets { get; set; } + [JsonPropertyName("body")] + public required string Body { get; set; } + } } diff --git a/Main.Designer.cs b/Main.Designer.cs index 4478487..e90ad8f 100644 --- a/Main.Designer.cs +++ b/Main.Designer.cs @@ -51,8 +51,8 @@ private void InitializeComponent() label8 = new Label(); grExtra = new GroupBox(); Enable_WipeLoginCache = new CheckBox(); - Enable_SendLog = new CheckBox(); - Extra_Cheat = new CheckBox(); + EnableSendLog = new CheckBox(); + ExtraCheat = new CheckBox(); Enable_RPC = new CheckBox(); grProxy = new GroupBox(); CheckProxyEnable = new CheckBox(); @@ -64,17 +64,16 @@ private void InitializeComponent() tabPage2 = new TabPage(); tabControl2 = new TabControl(); tabPage10 = new TabPage(); - groupBox4 = new GroupBox(); - Server_DL_DB = new Button(); - Server_DL_JAVA = new Button(); - groupBox6 = new GroupBox(); - Server_DL_RES = new Button(); - comboBox2 = new ComboBox(); Server_Start = new Button(); groupBox5 = new GroupBox(); Server_DL_GC = new Button(); comboBox1 = new ComboBox(); - Server_Config_OpenFolder = new Button(); + groupBox6 = new GroupBox(); + Server_DL_RES = new Button(); + comboBox2 = new ComboBox(); + groupBox4 = new GroupBox(); + Server_DL_DB = new Button(); + Server_DL_JAVA = new Button(); tabPage11 = new TabPage(); textBox4 = new TextBox(); label17 = new Label(); @@ -85,7 +84,8 @@ private void InitializeComponent() label15 = new Label(); textBox1 = new TextBox(); label14 = new Label(); - Set_Version = new Label(); + SetVersion = new Label(); + Server_Config_OpenFolder = new Button(); linkDiscord = new LinkLabel(); linkGithub = new LinkLabel(); linkWeb = new LinkLabel(); @@ -102,47 +102,62 @@ private void InitializeComponent() tabPage2.SuspendLayout(); tabControl2.SuspendLayout(); tabPage10.SuspendLayout(); - groupBox4.SuspendLayout(); - groupBox6.SuspendLayout(); groupBox5.SuspendLayout(); + groupBox6.SuspendLayout(); + groupBox4.SuspendLayout(); tabPage11.SuspendLayout(); SuspendLayout(); // // btStartNormal // - btStartNormal.Font = new Font("Segoe UI", 18F, FontStyle.Regular, GraphicsUnit.Point); - btStartNormal.Location = new Point(6, 61); + btStartNormal.BackColor = Color.FromArgb(52, 152, 219); + btStartNormal.Cursor = Cursors.Hand; + btStartNormal.FlatAppearance.BorderSize = 0; + btStartNormal.FlatStyle = FlatStyle.Flat; + btStartNormal.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + btStartNormal.ForeColor = Color.White; + btStartNormal.Location = new Point(10, 64); btStartNormal.Name = "btStartNormal"; - btStartNormal.Size = new Size(105, 38); + btStartNormal.Size = new Size(123, 36); btStartNormal.TabIndex = 0; btStartNormal.Text = "Launch"; - btStartNormal.UseVisualStyleBackColor = true; - btStartNormal.Click += btStartNormal_Click; + btStartNormal.UseVisualStyleBackColor = false; + btStartNormal.Click += BTStartNormal_Click; // // GetServerHost // - GetServerHost.Font = new Font("Segoe UI", 15.75F, FontStyle.Regular, GraphicsUnit.Point); - GetServerHost.Location = new Point(6, 20); + GetServerHost.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + GetServerHost.BackColor = Color.FromArgb(240, 240, 240); + GetServerHost.BorderStyle = BorderStyle.FixedSingle; + GetServerHost.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + GetServerHost.Location = new Point(10, 28); GetServerHost.Name = "GetServerHost"; - GetServerHost.Size = new Size(232, 35); + GetServerHost.PlaceholderText = "https://ps.yuuki.me"; + GetServerHost.ScrollBars = ScrollBars.Horizontal; + GetServerHost.Size = new Size(250, 29); GetServerHost.TabIndex = 2; // // label2 // + label2.Anchor = AnchorStyles.Top | AnchorStyles.Right; label2.AutoSize = true; - label2.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); - label2.Location = new Point(111, 14); + label2.Font = new Font("Segoe UI", 11F, FontStyle.Regular, GraphicsUnit.Point); + label2.ForeColor = Color.FromArgb(60, 60, 60); + label2.Location = new Point(270, 22); label2.Name = "label2"; - label2.Size = new Size(41, 21); + label2.Size = new Size(38, 20); label2.TabIndex = 4; label2.Text = "Port:"; // // GetProxyPort // - GetProxyPort.Font = new Font("Segoe UI", 9.75F, FontStyle.Regular, GraphicsUnit.Point); - GetProxyPort.Location = new Point(158, 12); + GetProxyPort.Anchor = AnchorStyles.Top | AnchorStyles.Right; + GetProxyPort.BackColor = Color.FromArgb(240, 240, 240); + GetProxyPort.BorderStyle = BorderStyle.None; + GetProxyPort.Font = new Font("Segoe UI", 11F, FontStyle.Regular, GraphicsUnit.Point); + GetProxyPort.Location = new Point(315, 22); GetProxyPort.Name = "GetProxyPort"; - GetProxyPort.Size = new Size(51, 25); + GetProxyPort.Size = new Size(55, 20); GetProxyPort.TabIndex = 5; GetProxyPort.Text = "2242"; // @@ -150,15 +165,17 @@ private void InitializeComponent() // TabMain.Controls.Add(tabPage1); TabMain.Controls.Add(tabPage2); - TabMain.Dock = DockStyle.Top; + TabMain.Dock = DockStyle.Fill; + TabMain.Font = new Font("Segoe UI", 11F, FontStyle.Regular, GraphicsUnit.Point); TabMain.Location = new Point(0, 0); TabMain.Name = "TabMain"; TabMain.SelectedIndex = 0; - TabMain.Size = new Size(662, 411); + TabMain.Size = new Size(710, 396); TabMain.TabIndex = 7; // // tabPage1 // + tabPage1.BackColor = Color.FromArgb(245, 245, 245); tabPage1.Controls.Add(grConfigGameLite); tabPage1.Controls.Add(stIsRunProxy); tabPage1.Controls.Add(groupBox8); @@ -166,177 +183,238 @@ private void InitializeComponent() tabPage1.Controls.Add(grExtra); tabPage1.Controls.Add(grProxy); tabPage1.Controls.Add(groupBox3); - tabPage1.Location = new Point(4, 24); + tabPage1.Location = new Point(4, 29); tabPage1.Name = "tabPage1"; - tabPage1.Padding = new Padding(3); - tabPage1.Size = new Size(654, 383); + tabPage1.Padding = new Padding(15); + tabPage1.Size = new Size(702, 363); tabPage1.TabIndex = 0; tabPage1.Text = "Connect"; - tabPage1.UseVisualStyleBackColor = true; // // grConfigGameLite // + grConfigGameLite.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; grConfigGameLite.Controls.Add(Set_LA_Select); grConfigGameLite.Controls.Add(Set_LA_GameFolder); grConfigGameLite.Controls.Add(label5); - grConfigGameLite.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); - grConfigGameLite.Location = new Point(8, 111); + grConfigGameLite.Font = new Font("Segoe UI", 11F, FontStyle.Regular, GraphicsUnit.Point); + grConfigGameLite.ForeColor = Color.FromArgb(60, 60, 60); + grConfigGameLite.Location = new Point(15, 147); + grConfigGameLite.MaximumSize = new Size(672, 128); grConfigGameLite.Name = "grConfigGameLite"; - grConfigGameLite.Size = new Size(420, 59); + grConfigGameLite.Size = new Size(457, 60); grConfigGameLite.TabIndex = 19; grConfigGameLite.TabStop = false; grConfigGameLite.Text = "Game Config"; // // Set_LA_Select // - Set_LA_Select.Location = new Point(331, 16); + Set_LA_Select.Anchor = AnchorStyles.Top | AnchorStyles.Right; + Set_LA_Select.BackColor = Color.FromArgb(46, 204, 113); + Set_LA_Select.Cursor = Cursors.Hand; + Set_LA_Select.FlatAppearance.BorderSize = 0; + Set_LA_Select.FlatStyle = FlatStyle.Flat; + Set_LA_Select.ForeColor = Color.White; + Set_LA_Select.Location = new Point(376, 18); Set_LA_Select.Name = "Set_LA_Select"; - Set_LA_Select.Size = new Size(76, 30); + Set_LA_Select.Size = new Size(75, 33); Set_LA_Select.TabIndex = 9; Set_LA_Select.Text = "Choose"; - Set_LA_Select.UseVisualStyleBackColor = true; + Set_LA_Select.UseVisualStyleBackColor = false; Set_LA_Select.Click += Set_LA_Select_Click; // // Set_LA_GameFolder // - Set_LA_GameFolder.Location = new Point(117, 17); + Set_LA_GameFolder.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + Set_LA_GameFolder.BackColor = Color.FromArgb(240, 240, 240); + Set_LA_GameFolder.BorderStyle = BorderStyle.FixedSingle; + Set_LA_GameFolder.Location = new Point(113, 22); Set_LA_GameFolder.Name = "Set_LA_GameFolder"; Set_LA_GameFolder.ReadOnly = true; - Set_LA_GameFolder.Size = new Size(208, 29); + Set_LA_GameFolder.Size = new Size(249, 27); Set_LA_GameFolder.TabIndex = 1; // // label5 // label5.AutoSize = true; - label5.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); - label5.Location = new Point(9, 25); + label5.Font = new Font("Segoe UI", 11F, FontStyle.Regular, GraphicsUnit.Point); + label5.ForeColor = Color.FromArgb(60, 60, 60); + label5.Location = new Point(10, 24); label5.Name = "label5"; - label5.Size = new Size(102, 21); + label5.Size = new Size(97, 20); label5.TabIndex = 0; label5.Text = "Game Folder:"; // // stIsRunProxy // + stIsRunProxy.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; stIsRunProxy.AutoSize = true; - stIsRunProxy.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); - stIsRunProxy.Location = new Point(3, 359); + stIsRunProxy.Font = new Font("Segoe UI", 11F, FontStyle.Regular, GraphicsUnit.Point); + stIsRunProxy.ForeColor = Color.FromArgb(60, 60, 60); + stIsRunProxy.Location = new Point(15, 330); stIsRunProxy.Name = "stIsRunProxy"; - stIsRunProxy.Size = new Size(87, 21); + stIsRunProxy.Size = new Size(81, 20); stIsRunProxy.TabIndex = 8; stIsRunProxy.Text = "Status: OFF"; + stIsRunProxy.TextAlign = ContentAlignment.MiddleLeft; // // groupBox8 // + groupBox8.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + groupBox8.BackColor = Color.Transparent; groupBox8.Controls.Add(btStartYuukiServer); groupBox8.Controls.Add(GetServerHost); groupBox8.Controls.Add(btStartNormal); groupBox8.Controls.Add(GetTypeGame); groupBox8.Controls.Add(btStartOfficialServer); groupBox8.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); - groupBox8.Location = new Point(8, 6); + groupBox8.ForeColor = Color.FromArgb(60, 60, 60); + groupBox8.Location = new Point(15, 15); + groupBox8.MaximumSize = new Size(672, 128); groupBox8.Name = "groupBox8"; - groupBox8.Size = new Size(420, 106); + groupBox8.Size = new Size(457, 128); groupBox8.TabIndex = 18; groupBox8.TabStop = false; groupBox8.Text = "Connect to server"; // // btStartYuukiServer // - btStartYuukiServer.Font = new Font("Segoe UI", 14.25F, FontStyle.Regular, GraphicsUnit.Point); - btStartYuukiServer.Location = new Point(326, 20); + btStartYuukiServer.Anchor = AnchorStyles.Top | AnchorStyles.Right; + btStartYuukiServer.AutoSize = true; + btStartYuukiServer.AutoSizeMode = AutoSizeMode.GrowAndShrink; + btStartYuukiServer.BackColor = Color.FromArgb(52, 152, 219); + btStartYuukiServer.Cursor = Cursors.Hand; + btStartYuukiServer.FlatAppearance.BorderSize = 0; + btStartYuukiServer.FlatStyle = FlatStyle.Flat; + btStartYuukiServer.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + btStartYuukiServer.ForeColor = Color.White; + btStartYuukiServer.Location = new Point(374, 26); btStartYuukiServer.Name = "btStartYuukiServer"; - btStartYuukiServer.Size = new Size(91, 35); + btStartYuukiServer.Size = new Size(77, 31); btStartYuukiServer.TabIndex = 20; btStartYuukiServer.Text = "YuukiPS"; - btStartYuukiServer.UseVisualStyleBackColor = true; - btStartYuukiServer.Click += btStartYuukiServer_Click; + btStartYuukiServer.UseVisualStyleBackColor = false; + btStartYuukiServer.Click += BTStartYuukiServer_Click; // // GetTypeGame // - GetTypeGame.Font = new Font("Segoe UI", 15.75F, FontStyle.Regular, GraphicsUnit.Point); + GetTypeGame.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + GetTypeGame.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); GetTypeGame.FormattingEnabled = true; - GetTypeGame.Location = new Point(117, 61); + GetTypeGame.ImeMode = ImeMode.NoControl; + GetTypeGame.Location = new Point(151, 69); GetTypeGame.Name = "GetTypeGame"; - GetTypeGame.Size = new Size(300, 38); + GetTypeGame.Size = new Size(300, 29); GetTypeGame.TabIndex = 14; GetTypeGame.SelectedIndexChanged += GetTypeGame_SelectedIndexChanged; // // btStartOfficialServer // - btStartOfficialServer.Font = new Font("Segoe UI", 14.25F, FontStyle.Regular, GraphicsUnit.Point); - btStartOfficialServer.Location = new Point(244, 20); + btStartOfficialServer.Anchor = AnchorStyles.Top | AnchorStyles.Right; + btStartOfficialServer.AutoSize = true; + btStartOfficialServer.AutoSizeMode = AutoSizeMode.GrowAndShrink; + btStartOfficialServer.BackColor = Color.FromArgb(46, 204, 113); + btStartOfficialServer.Cursor = Cursors.Hand; + btStartOfficialServer.FlatAppearance.BorderSize = 0; + btStartOfficialServer.FlatStyle = FlatStyle.Flat; + btStartOfficialServer.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + btStartOfficialServer.ForeColor = Color.White; + btStartOfficialServer.Location = new Point(299, 26); btStartOfficialServer.Name = "btStartOfficialServer"; - btStartOfficialServer.Size = new Size(81, 35); + btStartOfficialServer.Size = new Size(69, 31); btStartOfficialServer.TabIndex = 13; btStartOfficialServer.Text = "Official"; - btStartOfficialServer.UseVisualStyleBackColor = true; - btStartOfficialServer.Click += btStartOfficialServer_Click; + btStartOfficialServer.UseVisualStyleBackColor = false; + btStartOfficialServer.Click += BTStartOfficialServer_Click; // // grProfile // + grProfile.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + grProfile.BackColor = Color.FromArgb(245, 245, 245); grProfile.Controls.Add(GetProfileServer); grProfile.Controls.Add(btload); grProfile.Controls.Add(btsave); grProfile.Controls.Add(label8); - grProfile.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); - grProfile.Location = new Point(6, 176); + grProfile.Font = new Font("Segoe UI", 11F, FontStyle.Regular, GraphicsUnit.Point); + grProfile.ForeColor = Color.FromArgb(60, 60, 60); + grProfile.Location = new Point(15, 213); + grProfile.MaximumSize = new Size(672, 128); grProfile.Name = "grProfile"; - grProfile.Size = new Size(420, 108); + grProfile.Size = new Size(457, 96); grProfile.TabIndex = 17; grProfile.TabStop = false; grProfile.Text = "Profile"; // // GetProfileServer // - GetProfileServer.Font = new Font("Segoe UI", 15.75F, FontStyle.Regular, GraphicsUnit.Point); + GetProfileServer.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + GetProfileServer.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); GetProfileServer.FormattingEnabled = true; - GetProfileServer.Location = new Point(6, 28); + GetProfileServer.Location = new Point(14, 33); GetProfileServer.Name = "GetProfileServer"; - GetProfileServer.Size = new Size(234, 38); + GetProfileServer.Size = new Size(234, 29); GetProfileServer.TabIndex = 15; GetProfileServer.SelectedIndexChanged += GetProfileServer_SelectedIndexChanged; // // btload // - btload.Font = new Font("Segoe UI", 14.25F, FontStyle.Regular, GraphicsUnit.Point); - btload.Location = new Point(332, 28); + btload.Anchor = AnchorStyles.Top | AnchorStyles.Right; + btload.BackColor = Color.FromArgb(52, 152, 219); + btload.Cursor = Cursors.Hand; + btload.FlatAppearance.BorderSize = 0; + btload.FlatStyle = FlatStyle.Flat; + btload.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + btload.ForeColor = Color.White; + btload.Location = new Point(376, 28); btload.Name = "btload"; - btload.Size = new Size(75, 38); + btload.Size = new Size(75, 34); btload.TabIndex = 16; btload.Text = "Load"; - btload.UseVisualStyleBackColor = true; - btload.Click += btload_Click; + btload.UseVisualStyleBackColor = false; + btload.Click += BTLoadClick; // // btsave // - btsave.Font = new Font("Segoe UI", 14.25F, FontStyle.Regular, GraphicsUnit.Point); - btsave.Location = new Point(246, 28); + btsave.Anchor = AnchorStyles.Top | AnchorStyles.Right; + btsave.BackColor = Color.FromArgb(46, 204, 113); + btsave.Cursor = Cursors.Hand; + btsave.FlatAppearance.BorderSize = 0; + btsave.FlatStyle = FlatStyle.Flat; + btsave.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + btsave.ForeColor = Color.White; + btsave.Location = new Point(290, 28); btsave.Name = "btsave"; - btsave.Size = new Size(80, 38); + btsave.Size = new Size(80, 34); btsave.TabIndex = 2; btsave.Text = "Save"; - btsave.UseVisualStyleBackColor = true; - btsave.Click += Set_LA_Save_Click; + btsave.UseVisualStyleBackColor = false; + btsave.Click += SetLASaveClick; // // label8 // + label8.Anchor = AnchorStyles.Right; label8.AutoSize = true; - label8.Font = new Font("Segoe UI", 11.25F, FontStyle.Regular, GraphicsUnit.Point); - label8.Location = new Point(176, 78); + label8.Font = new Font("Segoe UI", 10F, FontStyle.Regular, GraphicsUnit.Point); + label8.ForeColor = Color.FromArgb(60, 60, 60); + label8.Location = new Point(186, 69); label8.Name = "label8"; - label8.Size = new Size(231, 20); + label8.Size = new Size(269, 19); label8.TabIndex = 13; - label8.Text = "Click Save to save current settings"; + label8.Text = "Click 'Save' to store current profile settings"; + label8.TextAlign = ContentAlignment.MiddleCenter; // // grExtra // + grExtra.Anchor = AnchorStyles.Top | AnchorStyles.Right; + grExtra.BackColor = SystemColors.ButtonFace; grExtra.Controls.Add(Enable_WipeLoginCache); - grExtra.Controls.Add(Enable_SendLog); - grExtra.Controls.Add(Extra_Cheat); + grExtra.Controls.Add(EnableSendLog); + grExtra.Controls.Add(ExtraCheat); grExtra.Controls.Add(Enable_RPC); - grExtra.Location = new Point(431, 183); + grExtra.Font = new Font("Segoe UI", 11F, FontStyle.Regular, GraphicsUnit.Point); + grExtra.ForeColor = Color.FromArgb(60, 60, 60); + grExtra.Location = new Point(477, 149); grExtra.Name = "grExtra"; - grExtra.Size = new Size(217, 101); + grExtra.Size = new Size(217, 122); grExtra.TabIndex = 12; grExtra.TabStop = false; grExtra.Text = "Extra"; @@ -344,52 +422,68 @@ private void InitializeComponent() // Enable_WipeLoginCache // Enable_WipeLoginCache.AutoSize = true; - Enable_WipeLoginCache.Location = new Point(7, 80); + Enable_WipeLoginCache.Cursor = Cursors.Hand; + Enable_WipeLoginCache.Dock = DockStyle.Top; + Enable_WipeLoginCache.ForeColor = Color.FromArgb(60, 60, 60); + Enable_WipeLoginCache.Location = new Point(3, 95); Enable_WipeLoginCache.Name = "Enable_WipeLoginCache"; - Enable_WipeLoginCache.Size = new Size(91, 19); + Enable_WipeLoginCache.Size = new Size(211, 24); Enable_WipeLoginCache.TabIndex = 20; - Enable_WipeLoginCache.Text = "WIPE LOGIN"; + Enable_WipeLoginCache.Text = "Wipe Login"; Enable_WipeLoginCache.UseVisualStyleBackColor = true; // - // Enable_SendLog - // - Enable_SendLog.AutoSize = true; - Enable_SendLog.Checked = true; - Enable_SendLog.CheckState = CheckState.Checked; - Enable_SendLog.Location = new Point(7, 61); - Enable_SendLog.Name = "Enable_SendLog"; - Enable_SendLog.Size = new Size(80, 19); - Enable_SendLog.TabIndex = 2; - Enable_SendLog.Text = "Send Logs"; - Enable_SendLog.UseVisualStyleBackColor = true; - // - // Extra_Cheat - // - Extra_Cheat.AutoSize = true; - Extra_Cheat.Location = new Point(7, 22); - Extra_Cheat.Name = "Extra_Cheat"; - Extra_Cheat.Size = new Size(57, 19); - Extra_Cheat.TabIndex = 0; - Extra_Cheat.Text = "Cheat"; - Extra_Cheat.UseVisualStyleBackColor = true; + // EnableSendLog + // + EnableSendLog.AutoSize = true; + EnableSendLog.Checked = true; + EnableSendLog.CheckState = CheckState.Checked; + EnableSendLog.Cursor = Cursors.Hand; + EnableSendLog.Dock = DockStyle.Top; + EnableSendLog.ForeColor = Color.FromArgb(60, 60, 60); + EnableSendLog.Location = new Point(3, 71); + EnableSendLog.Name = "EnableSendLog"; + EnableSendLog.Size = new Size(211, 24); + EnableSendLog.TabIndex = 2; + EnableSendLog.Text = "Send Logs"; + EnableSendLog.UseVisualStyleBackColor = true; + // + // ExtraCheat + // + ExtraCheat.AutoSize = true; + ExtraCheat.Cursor = Cursors.Hand; + ExtraCheat.Dock = DockStyle.Top; + ExtraCheat.ForeColor = Color.FromArgb(60, 60, 60); + ExtraCheat.Location = new Point(3, 47); + ExtraCheat.Name = "ExtraCheat"; + ExtraCheat.Size = new Size(211, 24); + ExtraCheat.TabIndex = 0; + ExtraCheat.Text = "Cheat"; + ExtraCheat.UseVisualStyleBackColor = true; // // Enable_RPC // Enable_RPC.AutoSize = true; - Enable_RPC.Location = new Point(7, 41); + Enable_RPC.Cursor = Cursors.Hand; + Enable_RPC.Dock = DockStyle.Top; + Enable_RPC.ForeColor = Color.FromArgb(60, 60, 60); + Enable_RPC.Location = new Point(3, 23); Enable_RPC.Name = "Enable_RPC"; - Enable_RPC.Size = new Size(150, 19); + Enable_RPC.Size = new Size(211, 24); Enable_RPC.TabIndex = 1; Enable_RPC.Text = "Rich Presence (Discord)"; Enable_RPC.UseVisualStyleBackColor = true; - Enable_RPC.CheckedChanged += Extra_Enable_RPC_CheckedChanged; + Enable_RPC.CheckedChanged += ExtraEnableRPCCheckedChanged; // // grProxy // + grProxy.Anchor = AnchorStyles.Top | AnchorStyles.Right; + grProxy.BackColor = Color.FromArgb(240, 240, 240); grProxy.Controls.Add(GetProxyPort); grProxy.Controls.Add(CheckProxyEnable); grProxy.Controls.Add(label2); - grProxy.Location = new Point(431, 127); + grProxy.Font = new Font("Segoe UI", 10F, FontStyle.Regular, GraphicsUnit.Point); + grProxy.ForeColor = Color.FromArgb(60, 60, 60); + grProxy.Location = new Point(477, 274); grProxy.Name = "grProxy"; grProxy.Size = new Size(217, 51); grProxy.TabIndex = 11; @@ -401,218 +495,254 @@ private void InitializeComponent() CheckProxyEnable.AutoSize = true; CheckProxyEnable.Checked = true; CheckProxyEnable.CheckState = CheckState.Checked; - CheckProxyEnable.Location = new Point(6, 18); + CheckProxyEnable.Cursor = Cursors.Hand; + CheckProxyEnable.Dock = DockStyle.Left; + CheckProxyEnable.ForeColor = Color.FromArgb(60, 60, 60); + CheckProxyEnable.Location = new Point(3, 21); CheckProxyEnable.Name = "CheckProxyEnable"; - CheckProxyEnable.Size = new Size(61, 19); + CheckProxyEnable.Size = new Size(68, 27); CheckProxyEnable.TabIndex = 7; CheckProxyEnable.Text = "Enable"; CheckProxyEnable.UseVisualStyleBackColor = true; // // groupBox3 // + groupBox3.Anchor = AnchorStyles.Top | AnchorStyles.Right; + groupBox3.BackColor = Color.FromArgb(240, 240, 240); groupBox3.Controls.Add(Get_LA_Version); groupBox3.Controls.Add(Get_LA_MD5); groupBox3.Controls.Add(Get_LA_CH); groupBox3.Controls.Add(Get_LA_REL); - groupBox3.Location = new Point(431, 8); + groupBox3.Font = new Font("Segoe UI", 10F, FontStyle.Regular, GraphicsUnit.Point); + groupBox3.ForeColor = Color.FromArgb(60, 60, 60); + groupBox3.Location = new Point(477, 8); groupBox3.Name = "groupBox3"; - groupBox3.Size = new Size(217, 114); + groupBox3.Padding = new Padding(1, 1, 10, 10); + groupBox3.Size = new Size(217, 135); groupBox3.TabIndex = 8; groupBox3.TabStop = false; - groupBox3.Text = "Game"; + groupBox3.Text = "Game Info"; // // Get_LA_Version // + Get_LA_Version.Anchor = AnchorStyles.Left | AnchorStyles.Right; Get_LA_Version.AutoSize = true; - Get_LA_Version.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); - Get_LA_Version.Location = new Point(6, 19); + Get_LA_Version.Font = new Font("Segoe UI", 10F, FontStyle.Regular, GraphicsUnit.Point); + Get_LA_Version.ForeColor = Color.FromArgb(60, 60, 60); + Get_LA_Version.Location = new Point(8, 24); Get_LA_Version.Name = "Get_LA_Version"; - Get_LA_Version.Size = new Size(136, 21); + Get_LA_Version.Size = new Size(120, 19); Get_LA_Version.TabIndex = 3; Get_LA_Version.Text = "Version: Unknown"; + Get_LA_Version.TextAlign = ContentAlignment.MiddleLeft; // // Get_LA_MD5 // + Get_LA_MD5.Anchor = AnchorStyles.Left | AnchorStyles.Right; Get_LA_MD5.AutoSize = true; - Get_LA_MD5.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); - Get_LA_MD5.Location = new Point(6, 82); + Get_LA_MD5.Cursor = Cursors.Hand; + Get_LA_MD5.Font = new Font("Segoe UI", 10F, FontStyle.Regular, GraphicsUnit.Point); + Get_LA_MD5.ForeColor = Color.FromArgb(60, 60, 60); + Get_LA_MD5.Location = new Point(8, 104); Get_LA_MD5.Name = "Get_LA_MD5"; - Get_LA_MD5.Size = new Size(118, 21); + Get_LA_MD5.Size = new Size(106, 19); Get_LA_MD5.TabIndex = 7; Get_LA_MD5.Text = "MD5: Unknown"; + Get_LA_MD5.TextAlign = ContentAlignment.MiddleLeft; + Get_LA_MD5.Click += GetLAMD5Click; // // Get_LA_CH // + Get_LA_CH.Anchor = AnchorStyles.Left | AnchorStyles.Right; Get_LA_CH.AutoSize = true; - Get_LA_CH.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); - Get_LA_CH.Location = new Point(6, 40); + Get_LA_CH.Font = new Font("Segoe UI", 10F, FontStyle.Regular, GraphicsUnit.Point); + Get_LA_CH.ForeColor = Color.FromArgb(60, 60, 60); + Get_LA_CH.Location = new Point(8, 49); Get_LA_CH.Name = "Get_LA_CH"; - Get_LA_CH.Size = new Size(141, 21); + Get_LA_CH.Size = new Size(125, 19); Get_LA_CH.TabIndex = 4; Get_LA_CH.Text = "Channel: Unknown"; + Get_LA_CH.TextAlign = ContentAlignment.MiddleLeft; // // Get_LA_REL // + Get_LA_REL.Anchor = AnchorStyles.Left | AnchorStyles.Right; Get_LA_REL.AutoSize = true; - Get_LA_REL.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); - Get_LA_REL.Location = new Point(6, 61); + Get_LA_REL.Font = new Font("Segoe UI", 11F, FontStyle.Regular, GraphicsUnit.Point); + Get_LA_REL.ForeColor = Color.FromArgb(50, 50, 50); + Get_LA_REL.Location = new Point(8, 74); Get_LA_REL.Name = "Get_LA_REL"; - Get_LA_REL.Size = new Size(137, 21); + Get_LA_REL.Size = new Size(128, 20); Get_LA_REL.TabIndex = 5; Get_LA_REL.Text = "Release: Unknown"; + Get_LA_REL.TextAlign = ContentAlignment.MiddleLeft; // // tabPage2 // + tabPage2.BackColor = Color.White; tabPage2.Controls.Add(tabControl2); - tabPage2.Location = new Point(4, 24); + tabPage2.Dock = DockStyle.Fill; + tabPage2.Location = new Point(4, 29); tabPage2.Name = "tabPage2"; tabPage2.Padding = new Padding(3); - tabPage2.Size = new Size(654, 383); + tabPage2.Size = new Size(873, 363); tabPage2.TabIndex = 1; tabPage2.Text = "Server"; - tabPage2.UseVisualStyleBackColor = true; // // tabControl2 // tabControl2.Controls.Add(tabPage10); tabControl2.Controls.Add(tabPage11); tabControl2.Dock = DockStyle.Fill; + tabControl2.Font = new Font("Segoe UI", 11F, FontStyle.Regular, GraphicsUnit.Point); tabControl2.Location = new Point(3, 3); tabControl2.Name = "tabControl2"; tabControl2.SelectedIndex = 0; - tabControl2.Size = new Size(648, 377); + tabControl2.Size = new Size(867, 357); tabControl2.TabIndex = 8; // // tabPage10 // - tabPage10.Controls.Add(groupBox4); - tabPage10.Controls.Add(groupBox6); + tabPage10.BackColor = Color.White; tabPage10.Controls.Add(Server_Start); tabPage10.Controls.Add(groupBox5); - tabPage10.Controls.Add(Server_Config_OpenFolder); - tabPage10.Location = new Point(4, 24); + tabPage10.Controls.Add(groupBox6); + tabPage10.Controls.Add(groupBox4); + tabPage10.Dock = DockStyle.Fill; + tabPage10.Location = new Point(4, 29); tabPage10.Name = "tabPage10"; tabPage10.Padding = new Padding(3); - tabPage10.Size = new Size(640, 349); + tabPage10.Size = new Size(859, 324); tabPage10.TabIndex = 0; tabPage10.Text = "Home"; - tabPage10.UseVisualStyleBackColor = true; // - // groupBox4 + // Server_Start // - groupBox4.Controls.Add(Server_DL_DB); - groupBox4.Controls.Add(Server_DL_JAVA); - groupBox4.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); - groupBox4.Location = new Point(6, 6); - groupBox4.Name = "groupBox4"; - groupBox4.Size = new Size(155, 100); - groupBox4.TabIndex = 5; - groupBox4.TabStop = false; - groupBox4.Text = "Download Package"; + Server_Start.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + Server_Start.BackColor = Color.FromArgb(52, 152, 219); + Server_Start.Cursor = Cursors.Hand; + Server_Start.FlatStyle = FlatStyle.Flat; + Server_Start.Font = new Font("Segoe UI", 12F, FontStyle.Bold, GraphicsUnit.Point); + Server_Start.ForeColor = Color.White; + Server_Start.Location = new Point(3, 150); + Server_Start.Name = "Server_Start"; + Server_Start.Size = new Size(853, 40); + Server_Start.TabIndex = 0; + Server_Start.Text = "Start Server"; + Server_Start.UseVisualStyleBackColor = false; + Server_Start.Click += ServerStartClick; // - // Server_DL_DB + // groupBox5 // - Server_DL_DB.Location = new Point(6, 63); - Server_DL_DB.Name = "Server_DL_DB"; - Server_DL_DB.Size = new Size(143, 29); - Server_DL_DB.TabIndex = 1; - Server_DL_DB.Text = "MongoDB"; - Server_DL_DB.UseVisualStyleBackColor = true; + groupBox5.Anchor = AnchorStyles.Top | AnchorStyles.Right; + groupBox5.Controls.Add(Server_DL_GC); + groupBox5.Controls.Add(comboBox1); + groupBox5.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + groupBox5.Location = new Point(631, 6); + groupBox5.Name = "groupBox5"; + groupBox5.Size = new Size(222, 138); + groupBox5.TabIndex = 6; + groupBox5.TabStop = false; + groupBox5.Text = "Grasscutter Version"; // - // Server_DL_JAVA + // Server_DL_GC // - Server_DL_JAVA.Location = new Point(6, 28); - Server_DL_JAVA.Name = "Server_DL_JAVA"; - Server_DL_JAVA.Size = new Size(143, 29); - Server_DL_JAVA.TabIndex = 0; - Server_DL_JAVA.Text = "Java"; - Server_DL_JAVA.UseVisualStyleBackColor = true; - Server_DL_JAVA.Click += Server_DL_JAVA_Click; + Server_DL_GC.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + Server_DL_GC.BackColor = Color.FromArgb(46, 204, 113); + Server_DL_GC.Cursor = Cursors.Hand; + Server_DL_GC.FlatStyle = FlatStyle.Flat; + Server_DL_GC.Font = new Font("Segoe UI", 12F, FontStyle.Bold, GraphicsUnit.Point); + Server_DL_GC.ForeColor = Color.White; + Server_DL_GC.Location = new Point(10, 70); + Server_DL_GC.Name = "Server_DL_GC"; + Server_DL_GC.Size = new Size(202, 40); + Server_DL_GC.TabIndex = 3; + Server_DL_GC.Text = "Download"; + Server_DL_GC.UseVisualStyleBackColor = false; + // + // comboBox1 + // + comboBox1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + comboBox1.FlatStyle = FlatStyle.Flat; + comboBox1.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + comboBox1.FormattingEnabled = true; + comboBox1.Items.AddRange(new object[] { "DockerGS 2.6", "DockerGS 2.7", "DockerGS 2.8", "DockerGS 3.0", "DockerGS 3.1" }); + comboBox1.Location = new Point(10, 28); + comboBox1.Name = "comboBox1"; + comboBox1.Size = new Size(202, 29); + comboBox1.TabIndex = 2; + comboBox1.Text = "DockerGC 3.1"; // // groupBox6 // + groupBox6.Anchor = AnchorStyles.Top; groupBox6.Controls.Add(Server_DL_RES); groupBox6.Controls.Add(comboBox2); - groupBox6.Font = new Font("Segoe UI", 14.25F, FontStyle.Regular, GraphicsUnit.Point); - groupBox6.Location = new Point(367, 6); + groupBox6.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + groupBox6.Location = new Point(318, 6); groupBox6.Name = "groupBox6"; - groupBox6.Size = new Size(200, 100); + groupBox6.Size = new Size(221, 138); groupBox6.TabIndex = 7; groupBox6.TabStop = false; - groupBox6.Text = "Version Resources:"; + groupBox6.Text = "Version Resources"; // // Server_DL_RES // - Server_DL_RES.Location = new Point(6, 56); + Server_DL_RES.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + Server_DL_RES.Location = new Point(10, 73); Server_DL_RES.Name = "Server_DL_RES"; - Server_DL_RES.Size = new Size(188, 38); + Server_DL_RES.Size = new Size(201, 35); Server_DL_RES.TabIndex = 8; Server_DL_RES.Text = "Download"; Server_DL_RES.UseVisualStyleBackColor = true; // // comboBox2 // + comboBox2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; comboBox2.FormattingEnabled = true; comboBox2.Items.AddRange(new object[] { "Yuuki Gitlab 3.1", "Yuuki Gitlab 3.0", "Yuuki Gitlab 2.8", "Yuuki Gitlab 2.7", "Yuuki Gitlab 2.6" }); - comboBox2.Location = new Point(6, 23); + comboBox2.Location = new Point(10, 29); comboBox2.Name = "comboBox2"; - comboBox2.Size = new Size(188, 33); + comboBox2.Size = new Size(201, 29); comboBox2.TabIndex = 3; comboBox2.Text = "Yuuki Gitlab 3.1"; // - // Server_Start - // - Server_Start.Location = new Point(107, 218); - Server_Start.Name = "Server_Start"; - Server_Start.Size = new Size(93, 23); - Server_Start.TabIndex = 0; - Server_Start.Text = "Start"; - Server_Start.UseVisualStyleBackColor = true; - Server_Start.Click += Server_Start_Click; - // - // groupBox5 - // - groupBox5.Controls.Add(Server_DL_GC); - groupBox5.Controls.Add(comboBox1); - groupBox5.Font = new Font("Segoe UI", 14.25F, FontStyle.Regular, GraphicsUnit.Point); - groupBox5.Location = new Point(167, 6); - groupBox5.Name = "groupBox5"; - groupBox5.Size = new Size(200, 100); - groupBox5.TabIndex = 6; - groupBox5.TabStop = false; - groupBox5.Text = "Version Grasscutter:"; - // - // Server_DL_GC + // groupBox4 // - Server_DL_GC.Location = new Point(6, 57); - Server_DL_GC.Name = "Server_DL_GC"; - Server_DL_GC.Size = new Size(188, 38); - Server_DL_GC.TabIndex = 3; - Server_DL_GC.Text = "Download"; - Server_DL_GC.UseVisualStyleBackColor = true; + groupBox4.Controls.Add(Server_DL_DB); + groupBox4.Controls.Add(Server_DL_JAVA); + groupBox4.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + groupBox4.Location = new Point(6, 6); + groupBox4.Name = "groupBox4"; + groupBox4.Size = new Size(221, 138); + groupBox4.TabIndex = 5; + groupBox4.TabStop = false; + groupBox4.Text = "Download Package"; // - // comboBox1 + // Server_DL_DB // - comboBox1.FormattingEnabled = true; - comboBox1.Items.AddRange(new object[] { "DockerGS 2.6", "DockerGS 2.7", "DockerGS 2.8", "DockerGS 3.0", "DockerGS 3.1" }); - comboBox1.Location = new Point(6, 23); - comboBox1.Name = "comboBox1"; - comboBox1.Size = new Size(188, 33); - comboBox1.TabIndex = 2; - comboBox1.Text = "DockerGC 3.1"; + Server_DL_DB.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + Server_DL_DB.Location = new Point(10, 73); + Server_DL_DB.Name = "Server_DL_DB"; + Server_DL_DB.Size = new Size(201, 35); + Server_DL_DB.TabIndex = 1; + Server_DL_DB.Text = "MongoDB"; + Server_DL_DB.UseVisualStyleBackColor = true; // - // Server_Config_OpenFolder + // Server_DL_JAVA // - Server_Config_OpenFolder.Location = new Point(12, 218); - Server_Config_OpenFolder.Name = "Server_Config_OpenFolder"; - Server_Config_OpenFolder.Size = new Size(89, 23); - Server_Config_OpenFolder.TabIndex = 1; - Server_Config_OpenFolder.Text = "Folder Server"; - Server_Config_OpenFolder.UseVisualStyleBackColor = true; - Server_Config_OpenFolder.Click += Server_Config_OpenFolder_Click; + Server_DL_JAVA.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + Server_DL_JAVA.Location = new Point(10, 29); + Server_DL_JAVA.Name = "Server_DL_JAVA"; + Server_DL_JAVA.Size = new Size(201, 35); + Server_DL_JAVA.TabIndex = 0; + Server_DL_JAVA.Text = "Java"; + Server_DL_JAVA.UseVisualStyleBackColor = true; + Server_DL_JAVA.Click += ServerDLJAVAClick; // // tabPage11 // + tabPage11.BackColor = Color.FromArgb(236, 240, 241); tabPage11.Controls.Add(textBox4); tabPage11.Controls.Add(label17); tabPage11.Controls.Add(textBox3); @@ -622,136 +752,174 @@ private void InitializeComponent() tabPage11.Controls.Add(label15); tabPage11.Controls.Add(textBox1); tabPage11.Controls.Add(label14); - tabPage11.Location = new Point(4, 24); + tabPage11.Dock = DockStyle.Fill; + tabPage11.Location = new Point(4, 29); tabPage11.Name = "tabPage11"; - tabPage11.Padding = new Padding(3); - tabPage11.Size = new Size(640, 349); + tabPage11.Padding = new Padding(10); + tabPage11.Size = new Size(688, 324); tabPage11.TabIndex = 1; - tabPage11.Text = "Custom"; - tabPage11.UseVisualStyleBackColor = true; + tabPage11.Text = "Custom Settings"; // // textBox4 // - textBox4.Location = new Point(6, 192); + textBox4.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBox4.BackColor = Color.White; + textBox4.BorderStyle = BorderStyle.None; + textBox4.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + textBox4.Location = new Point(10, 220); textBox4.Name = "textBox4"; - textBox4.Size = new Size(626, 23); + textBox4.Size = new Size(668, 22); textBox4.TabIndex = 8; // // label17 // label17.AutoSize = true; - label17.Font = new Font("Segoe UI", 14.25F, FontStyle.Regular, GraphicsUnit.Point); - label17.Location = new Point(6, 165); + label17.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + label17.Location = new Point(10, 195); label17.Name = "label17"; - label17.Size = new Size(206, 25); + label17.Size = new Size(170, 21); label17.TabIndex = 7; - label17.Text = "Folder MongoDB (BIN):"; + label17.Text = "MongoDB Folder (BIN):"; // // textBox3 // - textBox3.Location = new Point(6, 139); + textBox3.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBox3.BackColor = Color.White; + textBox3.BorderStyle = BorderStyle.None; + textBox3.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + textBox3.Location = new Point(10, 165); textBox3.Name = "textBox3"; - textBox3.Size = new Size(626, 23); + textBox3.Size = new Size(668, 22); textBox3.TabIndex = 6; // // label16 // label16.AutoSize = true; - label16.Font = new Font("Segoe UI", 14.25F, FontStyle.Regular, GraphicsUnit.Point); - label16.Location = new Point(6, 111); + label16.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + label16.Location = new Point(10, 140); label16.Name = "label16"; - label16.Size = new Size(157, 25); + label16.Size = new Size(130, 21); label16.TabIndex = 5; - label16.Text = "Folder Java (BIN):"; + label16.Text = "Java Folder (BIN):"; // // button1 // - button1.Location = new Point(557, 221); + button1.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + button1.BackColor = Color.FromArgb(52, 152, 219); + button1.Cursor = Cursors.Hand; + button1.FlatStyle = FlatStyle.Flat; + button1.Font = new Font("Segoe UI", 12F, FontStyle.Bold, GraphicsUnit.Point); + button1.ForeColor = Color.White; + button1.Location = new Point(578, 274); button1.Name = "button1"; - button1.Size = new Size(75, 23); + button1.Size = new Size(100, 40); button1.TabIndex = 4; button1.Text = "Save"; - button1.UseVisualStyleBackColor = true; + button1.UseVisualStyleBackColor = false; // // textBox2 // - textBox2.Location = new Point(6, 85); + textBox2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBox2.BackColor = Color.White; + textBox2.BorderStyle = BorderStyle.None; + textBox2.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + textBox2.Location = new Point(10, 110); textBox2.Name = "textBox2"; - textBox2.Size = new Size(626, 23); + textBox2.Size = new Size(668, 22); textBox2.TabIndex = 3; // // label15 // label15.AutoSize = true; - label15.Font = new Font("Segoe UI", 14.25F, FontStyle.Regular, GraphicsUnit.Point); - label15.Location = new Point(6, 57); + label15.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + label15.Location = new Point(10, 85); label15.Name = "label15"; - label15.Size = new Size(258, 25); + label15.Size = new Size(215, 21); label15.TabIndex = 2; label15.Text = "Grasscutter Resources Folder:"; // // textBox1 // - textBox1.Location = new Point(6, 31); + textBox1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + textBox1.BackColor = Color.White; + textBox1.BorderStyle = BorderStyle.None; + textBox1.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + textBox1.Location = new Point(10, 55); textBox1.Name = "textBox1"; - textBox1.Size = new Size(626, 23); + textBox1.Size = new Size(668, 22); textBox1.TabIndex = 1; // // label14 // label14.AutoSize = true; - label14.Font = new Font("Segoe UI", 14.25F, FontStyle.Regular, GraphicsUnit.Point); - label14.Location = new Point(3, 3); + label14.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + label14.Location = new Point(10, 30); label14.Name = "label14"; - label14.Size = new Size(169, 25); + label14.Size = new Size(140, 21); label14.TabIndex = 0; label14.Text = "Grasscutter Folder:"; // - // Set_Version + // SetVersion + // + SetVersion.Anchor = AnchorStyles.Left | AnchorStyles.Right; + SetVersion.Location = new Point(3, 288); + SetVersion.Name = "SetVersion"; + SetVersion.Size = new Size(221, 15); + SetVersion.TabIndex = 12; + SetVersion.Text = "Version: 0.0.0"; // - Set_Version.AutoSize = true; - Set_Version.Dock = DockStyle.Left; - Set_Version.Location = new Point(0, 411); - Set_Version.Name = "Set_Version"; - Set_Version.Size = new Size(75, 15); - Set_Version.TabIndex = 12; - Set_Version.Text = "Version: 0.0.0"; + // Server_Config_OpenFolder + // + Server_Config_OpenFolder.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + Server_Config_OpenFolder.BackColor = Color.FromArgb(52, 152, 219); + Server_Config_OpenFolder.Cursor = Cursors.Hand; + Server_Config_OpenFolder.Enabled = false; + Server_Config_OpenFolder.FlatStyle = FlatStyle.Flat; + Server_Config_OpenFolder.Font = new Font("Segoe UI", 10F, FontStyle.Regular, GraphicsUnit.Point); + Server_Config_OpenFolder.ForeColor = Color.White; + Server_Config_OpenFolder.Location = new Point(10, 141); + Server_Config_OpenFolder.Name = "Server_Config_OpenFolder"; + Server_Config_OpenFolder.Size = new Size(202, 35); + Server_Config_OpenFolder.TabIndex = 1; + Server_Config_OpenFolder.Text = "Open Server Folder"; + Server_Config_OpenFolder.UseVisualStyleBackColor = false; // // linkDiscord // + linkDiscord.Anchor = AnchorStyles.Top | AnchorStyles.Right; linkDiscord.AutoSize = true; - linkDiscord.Dock = DockStyle.Right; - linkDiscord.Location = new Point(615, 411); + linkDiscord.Location = new Point(663, 0); linkDiscord.Name = "linkDiscord"; linkDiscord.Size = new Size(47, 15); linkDiscord.TabIndex = 13; linkDiscord.TabStop = true; linkDiscord.Text = "Discord"; - linkDiscord.LinkClicked += linkDiscord_LinkClicked; + linkDiscord.LinkClicked += LinkDiscordLinkClicked; // // linkGithub // + linkGithub.Anchor = AnchorStyles.Top | AnchorStyles.Right; linkGithub.AutoSize = true; - linkGithub.Dock = DockStyle.Right; - linkGithub.Location = new Point(572, 411); + linkGithub.Location = new Point(597, 0); + linkGithub.Margin = new Padding(0, 0, 5, 0); linkGithub.Name = "linkGithub"; linkGithub.Size = new Size(43, 15); linkGithub.TabIndex = 14; linkGithub.TabStop = true; linkGithub.Text = "Github"; - linkGithub.LinkClicked += linkGithub_LinkClicked; + linkGithub.LinkClicked += LinkGithubLinkClicked; // // linkWeb // - linkWeb.AutoSize = true; - linkWeb.Dock = DockStyle.Right; - linkWeb.Location = new Point(541, 411); + linkWeb.Anchor = AnchorStyles.Top | AnchorStyles.Right; + linkWeb.Location = new Point(636, 0); + linkWeb.Margin = new Padding(0, 0, 5, 0); linkWeb.Name = "linkWeb"; linkWeb.Size = new Size(31, 15); linkWeb.TabIndex = 15; linkWeb.TabStop = true; linkWeb.Text = "Web"; - linkWeb.LinkClicked += linkWeb_LinkClicked; + linkWeb.LinkClicked += LinkWebLinkClicked; // // CheckGameRun // @@ -763,23 +931,23 @@ private void InitializeComponent() // CheckProxyRun.Enabled = true; CheckProxyRun.Interval = 1000; - CheckProxyRun.Tick += CheckProxyRun_Tick; + CheckProxyRun.Tick += CheckProxyRunTick; // // Main // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(662, 431); + AutoScaleMode = AutoScaleMode.None; + ClientSize = new Size(710, 396); Controls.Add(linkWeb); Controls.Add(linkGithub); Controls.Add(linkDiscord); - Controls.Add(Set_Version); Controls.Add(TabMain); - FormBorderStyle = FormBorderStyle.FixedSingle; MaximizeBox = false; + MaximumSize = new Size(1096, 645); + MinimumSize = new Size(726, 435); Name = "Main"; + StartPosition = FormStartPosition.CenterScreen; Text = "YuukiPS Launcher"; - FormClosing += Main_FormClosing; + FormClosing += MainFormClosing; Load += Main_Load; TabMain.ResumeLayout(false); tabPage1.ResumeLayout(false); @@ -799,9 +967,9 @@ private void InitializeComponent() tabPage2.ResumeLayout(false); tabControl2.ResumeLayout(false); tabPage10.ResumeLayout(false); - groupBox4.ResumeLayout(false); - groupBox6.ResumeLayout(false); groupBox5.ResumeLayout(false); + groupBox6.ResumeLayout(false); + groupBox4.ResumeLayout(false); tabPage11.ResumeLayout(false); tabPage11.PerformLayout(); ResumeLayout(false); @@ -817,16 +985,15 @@ private void InitializeComponent() private TabControl TabMain; private TabPage tabPage1; private TabPage tabPage2; - private Button Server_Start; private GroupBox grProxy; private CheckBox CheckProxyEnable; - private Label Set_Version; + private Label SetVersion; private Label stIsRunProxy; private LinkLabel linkDiscord; private LinkLabel linkGithub; private LinkLabel linkWeb; private GroupBox grExtra; - private CheckBox Extra_Cheat; + private CheckBox ExtraCheat; private CheckBox Enable_RPC; private TextBox Set_LA_GameFolder; private Label label5; @@ -841,17 +1008,7 @@ private void InitializeComponent() private System.Windows.Forms.Timer CheckProxyRun; private Label label8; private Button Server_Config_OpenFolder; - private ComboBox comboBox1; - private GroupBox groupBox4; - private Button Server_DL_JAVA; - private Button Server_DL_DB; - private GroupBox groupBox5; - private Button Server_DL_GC; - private GroupBox groupBox6; - private Button Server_DL_RES; - private ComboBox comboBox2; private TabControl tabControl2; - private TabPage tabPage10; private TabPage tabPage11; private TextBox textBox4; private Label label17; @@ -870,7 +1027,18 @@ private void InitializeComponent() private GroupBox groupBox8; private GroupBox grConfigGameLite; private Button btStartYuukiServer; - private CheckBox Enable_SendLog; + private CheckBox EnableSendLog; private CheckBox Enable_WipeLoginCache; + private TabPage tabPage10; + private GroupBox groupBox5; + private Button Server_DL_GC; + private ComboBox comboBox1; + private GroupBox groupBox6; + private Button Server_DL_RES; + private ComboBox comboBox2; + private GroupBox groupBox4; + private Button Server_DL_DB; + private Button Server_DL_JAVA; + private Button Server_Start; } } \ No newline at end of file diff --git a/Main.cs b/Main.cs index 3f5e851..38ed3b7 100644 --- a/Main.cs +++ b/Main.cs @@ -7,24 +7,23 @@ using YuukiPS_Launcher.Yuuki; using YuukiPS_Launcher.Utils; using System.Security.Cryptography.X509Certificates; -using System.IO; namespace YuukiPS_Launcher { public partial class Main : Form - { + { // Main Function private Proxy? proxy; private Process? progress; - Json.Config configdata = new Json.Config(); - Profile default_profile = new Profile(); + Config ConfigData = new(); + Profile DefaultProfile = new(); // Stats default public string WatchFile = ""; public string WatchCheat = "melon123"; public string HostName = "YuukiPS"; // host name - public bool IsGameRun = false; + public bool isGameRunning = false; public bool DoneCheck = true; // Config basic game @@ -33,15 +32,13 @@ public partial class Main : Form public string PathfileGame = ""; // Extra - Extra.Discord discord = new Extra.Discord(); + readonly Extra.Discord discord = new(); // Game - public Game.Genshin.Settings? settings_genshin = null; + public Game.Genshin.Settings? settingsGenshin = null; // Patch - Patch? get_patch = null; - - Logger logger = new Logger(); + Patch? getPatch = null; public Main() { @@ -58,7 +55,7 @@ private void Main_Load(object sender, EventArgs e) Directory.CreateDirectory(logsFolderPath); - logger.initLogging($"Platform: {os.Platform}\nPlatform Version: {os.Version}\nService pack: {os.ServicePack}\n\n", logFilePath); + Logger.InitLogging($"Platform: {os.Platform}\nPlatform Version: {os.Version}\nService pack: {os.ServicePack}\n\n", logFilePath); Logger.Info("Boot", "Loading...."); @@ -71,56 +68,56 @@ private void Main_Load(object sender, EventArgs e) LoadConfig("Boot"); // if found config // Load Profile by profile_default - LoadProfile(configdata.profile_default); + LoadProfile(ConfigData.profile_default); // Extra if (Enable_RPC.Checked) { - Logger.Info("Boot", "Discord RPC enable"); + Logger.Info("Boot", "Discord RPC enabled"); discord.Ready(); } else { - Logger.Info("Boot", "Discord RPC disable"); + Logger.Info("Boot", "Discord RPC disabled"); } } - private void btload_Click(object? sender, EventArgs e) + private void BTLoadClick(object? sender, EventArgs e) { - var get_select_profile = GetProfileServer.Text; - LoadProfile(get_select_profile); + var getSelectProfile = GetProfileServer.Text; + LoadProfile(getSelectProfile); } - private void Set_LA_Save_Click(object? sender, EventArgs e) + private void SetLASaveClick(object? sender, EventArgs e) { - var get_select_profile = GetProfileServer.Text; - SaveProfile(get_select_profile); + var getSelectProfile = GetProfileServer.Text; + SaveProfile(getSelectProfile); } private void GetProfileServer_SelectedIndexChanged(object? sender, EventArgs e) { - var get_select_profile = GetProfileServer.Text; - Logger.Info("Profiles", "GetProfileServer_SelectedIndexChanged " + get_select_profile); - LoadProfile(get_select_profile); + var getSelectProfile = GetProfileServer.Text; + Logger.Info("Profiles", "GetProfileServer_SelectedIndexChanged " + getSelectProfile); + LoadProfile(getSelectProfile); } private void GetTypeGame_SelectedIndexChanged(object? sender, EventArgs e) { - default_profile.game.type = (GameType)GetTypeGame.SelectedItem; + DefaultProfile.GameConfig.type = (GameType)GetTypeGame.SelectedItem; } - public void LoadConfig(string load_by) + public void LoadConfig(string LoadBy) { - configdata = Json.Config.LoadConfig(); + ConfigData = Config.LoadConfig(); - Logger.Info("Config", "load config by " + load_by); + Logger.Info("Config", $"Configuration loaded by: {LoadBy}"); // Unsubscribe from SelectedIndexChanged event GetProfileServer.SelectedIndexChanged -= GetProfileServer_SelectedIndexChanged; // Profile GetProfileServer.DisplayMember = "name"; - GetProfileServer.DataSource = configdata.profile; + GetProfileServer.DataSource = ConfigData.Profile; // GameType GetTypeGame.DataSource = Enum.GetValues(typeof(GameType)); @@ -129,9 +126,9 @@ public void LoadConfig(string load_by) for (int i = 0; i < GetProfileServer.Items.Count; i++) { Profile profile = (Profile)GetProfileServer.Items[i]; - if (profile.name == configdata.profile_default) + if (profile.name == ConfigData.profile_default) { - Logger.Info("Profiles", "Set index " + i + " name profile " + configdata.profile_default); + Logger.Info("Profiles", $"Setting selected profile: '{ConfigData.profile_default}' at index {i}"); GetProfileServer.SelectedIndex = i; break; } @@ -141,132 +138,133 @@ public void LoadConfig(string load_by) GetProfileServer.SelectedIndexChanged += GetProfileServer_SelectedIndexChanged; } - public void LoadProfile(string load_profile = "") + public void LoadProfile(string loadProfile = "") { - if (string.IsNullOrEmpty(load_profile)) + if (string.IsNullOrEmpty(loadProfile)) { - Logger.Info("Profiles", "No profile"); + Logger.Info("Profiles", "No profile specified. Using default settings."); return; } - Logger.Info("Profiles", "Profile: " + load_profile); + Logger.Info("Profiles", $"Loading profile: '{loadProfile}'"); try { - var tmp_profile = configdata.profile.Find(p => p.name == load_profile); - if (tmp_profile != null) + var tmpProfile = ConfigData.Profile.Find(p => p.name == loadProfile); + if (tmpProfile != null) { - default_profile = tmp_profile; + DefaultProfile = tmpProfile; } else { // use default data } - Logger.Info("Profiles", "Server: " + default_profile.server.url); + Logger.Info("Profiles", $"Server URL: {DefaultProfile.ServerConfig.url}"); } catch (Exception e) { - Logger.Error("Profiles", "Profile error (" + e.Message + "), use default data"); + Logger.Error("Profiles", $"Failed to load profile: {e.Message}. Using default data."); } // Data Set // Game - Set_LA_GameFolder.Text = default_profile.game.path; - GetTypeGame.SelectedIndex = Array.IndexOf(Enum.GetValues(typeof(GameType)), default_profile.game.type); + Set_LA_GameFolder.Text = DefaultProfile.GameConfig.path; + GetTypeGame.SelectedIndex = Array.IndexOf(Enum.GetValues(typeof(GameType)), DefaultProfile.GameConfig.type); // Server - CheckProxyEnable.Checked = default_profile.server.proxy.enable; - GetServerHost.Text = default_profile.server.url; + CheckProxyEnable.Checked = DefaultProfile.ServerConfig.proxy.enable; + GetServerHost.Text = DefaultProfile.ServerConfig.url; // Extra - Extra_Cheat.Checked = default_profile.game.extra.Akebi; - Enable_RPC.Checked = default_profile.game.extra.RPC; + ExtraCheat.Checked = DefaultProfile.GameConfig.extra.Akebi; + Enable_RPC.Checked = DefaultProfile.GameConfig.extra.RPC; // Get Data Game - if (!CheckVersionGame(default_profile.game.type)) + if (!CheckVersionGame(DefaultProfile.GameConfig.type)) { - MessageBox.Show("No game folder detected, please manually input game folder then play"); + var message = "No game folder detected. Please manually input the game folder before playing."; + Logger.Warning("Game", message); + MessageBox.Show(message, "Game Folder Not Found", MessageBoxButtons.OK, MessageBoxIcon.Information); } } - public void SaveProfile(string name_save = "Default") + public void SaveProfile(string NameSave = "Default") { try { - var tmp_profile = new Profile(); + var tmpProfile = new Profile(); // Game - tmp_profile.game.path = Set_LA_GameFolder.Text; - tmp_profile.game.type = (GameType)GetTypeGame.SelectedItem; - tmp_profile.game.wipeLogin = Enable_WipeLoginCache.Checked; + tmpProfile.GameConfig.path = Set_LA_GameFolder.Text; + tmpProfile.GameConfig.type = (GameType)GetTypeGame.SelectedItem; + tmpProfile.GameConfig.wipeLogin = Enable_WipeLoginCache.Checked; // Server - tmp_profile.server.url = GetServerHost.Text; - int myInt; - bool isValid = int.TryParse(GetProxyPort.Text, out myInt); + tmpProfile.ServerConfig.url = GetServerHost.Text; + bool isValid = int.TryParse(GetProxyPort.Text, out int myInt); if (isValid) { - tmp_profile.server.proxy.port = myInt; + tmpProfile.ServerConfig.proxy.port = myInt; } // Extra - tmp_profile.game.extra.Akebi = Extra_Cheat.Checked; - tmp_profile.game.extra.RPC = Enable_RPC.Checked; + tmpProfile.GameConfig.extra.Akebi = ExtraCheat.Checked; + tmpProfile.GameConfig.extra.RPC = Enable_RPC.Checked; // Nama Profile - tmp_profile.name = name_save; + tmpProfile.name = NameSave; try { - int indexToUpdate = configdata.profile.FindIndex(profile => profile.name == name_save); + int indexToUpdate = ConfigData.Profile.FindIndex(profile => profile.name == NameSave); if (indexToUpdate != -1) { - Logger.Info("Profiles", "Profile save: " + name_save); - configdata.profile[indexToUpdate] = tmp_profile; + Logger.Info("Profiles", $"Updating existing profile: {NameSave}"); + ConfigData.Profile[indexToUpdate] = tmpProfile; } else { - Logger.Info("Profiles", "Add new profile: " + name_save); - configdata.profile.Add(tmp_profile); + Logger.Info("Profiles", $"Creating new profile: {NameSave}"); + ConfigData.Profile.Add(tmpProfile); } } catch (Exception ex) { - Logger.Info("Profiles", "Error save config (" + ex.Message + "), so reload it"); - configdata = new Json.Config() { profile = new List() { tmp_profile } }; + Logger.Error("Profiles", $"Failed to save profile '{NameSave}'. Error: {ex.Message}. Reinitializing configuration."); + ConfigData = new Config() { Profile = new List() { tmpProfile } }; } - configdata.profile_default = name_save; + ConfigData.profile_default = NameSave; - File.WriteAllText(Json.Config.ConfigPath, JsonConvert.SerializeObject(configdata)); + File.WriteAllText(Config.ConfigPath, JsonConvert.SerializeObject(ConfigData)); - Logger.Info("Config", "Done save config..."); + Logger.Info("Config", "Configuration saved successfully."); LoadConfig("SaveProfile"); } catch (Exception ex) { - Console.WriteLine(ex); + Logger.Error("Profiles", $"Failed to save profile: {ex.Message}. Reverting to default configuration."); } } - private void btStartOfficialServer_Click(object sender, EventArgs e) + private void BTStartOfficialServer_Click(object sender, EventArgs e) { GetServerHost.Text = "official"; CheckProxyEnable.Checked = false; DoStart(); } - private void btStartYuukiServer_Click(object sender, EventArgs e) + private void BTStartYuukiServer_Click(object sender, EventArgs e) { - GetServerHost.Text = API.WEB_LINK; + GetServerHost.Text = API.WebLink; CheckProxyEnable.Checked = true; DoStart(); } - private void btStartNormal_Click(object sender, EventArgs e) + private void BTStartNormal_Click(object sender, EventArgs e) { DoStart(); } @@ -274,38 +272,38 @@ private void btStartNormal_Click(object sender, EventArgs e) public void DoStart() { // Jika game berjalan... - if (IsGameRun) + if (isGameRunning) { AllStop(); return; } // Setup - bool isCheat = Extra_Cheat.Checked; + bool isCheat = ExtraCheat.Checked; bool isProxyNeed = CheckProxyEnable.Checked; - bool isSendLog = Enable_SendLog.Checked; + bool isSendLog = EnableSendLog.Checked; GameType selectedGame = (GameType)GetTypeGame.SelectedItem; // Get Host - string set_server_host = GetServerHost.Text; - if (string.IsNullOrEmpty(set_server_host)) + string setServerHost = GetServerHost.Text; + if (string.IsNullOrEmpty(setServerHost)) { MessageBox.Show("Please select a server first, you can click on one in server list"); return; } // Get Proxy - int set_proxy_port = int.Parse(GetProxyPort.Text); + int setProxyPort = int.Parse(GetProxyPort.Text); // Get Game - var cst_gamefile = PathfileGame; - if (String.IsNullOrEmpty(cst_gamefile)) + var cstGameFile = PathfileGame; + if (string.IsNullOrEmpty(cstGameFile)) { MessageBox.Show("No game file config found"); return; } - if (!File.Exists(cst_gamefile)) + if (!File.Exists(cstGameFile)) { MessageBox.Show("Please find game install folder!"); return; @@ -314,7 +312,7 @@ public void DoStart() bool patch = true; // Check progress - if (!IsGameRun) + if (!isGameRunning) { // if game is not running if (progress != null) @@ -323,61 +321,72 @@ public void DoStart() } // if server is official - if (set_server_host == "official") + if (setServerHost == "official") { patch = false; } else { - if (get_patch != null && get_patch.nosupport != "") + if (getPatch != null && getPatch.NoSupport != "") { - MessageBox.Show(get_patch.nosupport, "Game version not supported"); - Process.Start(new ProcessStartInfo(API.WEB_LINK) { UseShellExecute = true }); + MessageBox.Show(getPatch.NoSupport, "Game version not supported"); + Process.Start(new ProcessStartInfo(API.WebLink) { UseShellExecute = true }); return; } } // run patch var startPatch = PatchGame(patch); - if (!string.IsNullOrEmpty(startPatch)) + if (!startPatch) { - MessageBox.Show(startPatch, "Error Patch"); + MessageBox.Show("Failed to patch a game file. See console for more details."); return; } + + } // For Proxy if (proxy == null) { // skip proxy if official server - if (set_server_host != "official") + if (setServerHost != "official") { if (isProxyNeed) { - proxy = new Proxy(set_proxy_port, set_server_host, isSendLog); + proxy = new Proxy(setProxyPort, setServerHost, isSendLog); if (!proxy.Start()) { - MessageBox.Show("Maybe port is already use or Windows Firewall does not allow using port " + set_proxy_port + " or Windows Update sometimes takes that range, or try again it might magically work again.", "Proxy port cannot be used"); + MessageBox.Show($"Unable to start proxy on port {setProxyPort}. Possible reasons:\n\n" + + "1. The port is already in use by another application.\n" + + "2. Windows Firewall is blocking access to this port.\n" + + "3. Windows Update may be using ports in this range.\n\n" + + "Please try the following:\n" + + "- Close any applications that might be using this port.\n" + + "- Check your firewall settings.\n" + + "- Try restarting the application.\n" + + "- If the issue persists, consider using a different port.", + "Proxy Port Error"); try { Process.Start(new ProcessStartInfo("cmd", $"/c net stop winnat") { CreateNoWindow = true, UseShellExecute = false }); } - catch + catch (Exception ex) { - // skip + Logger.Error("Proxy", $"Error stopping WinNAT service: {ex.Message}"); } - StopProxy(); + proxy.Stop(); return; } else { - if (set_server_host.Contains("yuuki.me")) + if (setServerHost.Contains("yuuki.me")) { - if (!API.isYuuki(set_proxy_port)) + if (!API.IsYuuki(setProxyPort)) { - StopProxy(); + proxy.Stop(); InstallCert(); - MessageBox.Show("Try closing this program then opening it again, if there is still an error, please report it to admin with a screenshot console", "Not yet connected to YuukiPS server"); + MessageBox.Show("Unable to connect to YuukiPS server. Please try the following steps:\n\n1. Close this program completely\n2. Reopen the program and try again\n\nIf the issue persists, please report it to an admin and include a screenshot of the console.", "Connection Error"); return; } } @@ -385,17 +394,17 @@ public void DoStart() } else { - Logger.Info("Proxy", "Proxy is ignored, because you turned it off"); + Logger.Info("Proxy", "Proxy is disabled as per user settings"); } } else { - Logger.Info("Proxy", "Proxy is ignored, because use official server"); + Logger.Info("Proxy", "Proxy is bypassed when using the official server"); } } else { - Logger.Info("Proxy", " Proxy is still running..."); + Logger.Info("Proxy", "Proxy is currently active and running"); } // For Cheat (tmp) @@ -404,34 +413,36 @@ public void DoStart() Logger.Info("Cheat", "Cheat enabled"); try { - var get_file_cheat = API.GetCheat(selectedGame, GameChannel, VersionGame, cst_gamefile); - if (get_file_cheat == null) + var getFileCheat = API.GetCheat(selectedGame, GameChannel, VersionGame, cstGameFile); + if (getFileCheat == null) { - MessageBox.Show("No cheats found for this version, please turn off the cheat feature to run the game."); - Extra_Cheat.Checked = false; + MessageBox.Show("No cheats are available for this game version. Please disable the cheat feature in the settings to launch the game.", "Cheat Unavailable", MessageBoxButtons.OK, MessageBoxIcon.Information); + ExtraCheat.Checked = false; return; } - cst_gamefile = get_file_cheat.launcher; - WatchCheat = Path.GetFileNameWithoutExtension(cst_gamefile); - Logger.Info("Cheat", $"RUN: Monitor {WatchCheat} at {cst_gamefile}"); + cstGameFile = getFileCheat.Launcher; + WatchCheat = Path.GetFileNameWithoutExtension(cstGameFile); + Logger.Info("Cheat", $"RUN: Monitor {WatchCheat} at {cstGameFile}"); } catch (Exception x) { - Console.WriteLine(x); + Logger.Error("Cheat", $"Error: {x.Message}"); } } // For Game if (progress == null) { - progress = new Process(); - progress.StartInfo = new ProcessStartInfo + progress = new() { - FileName = cst_gamefile, - //UseShellExecute = true, - Arguments = "-server=" + set_server_host, // TODO: custom mod - WorkingDirectory = Path.GetDirectoryName(cst_gamefile), + StartInfo = new ProcessStartInfo + { + FileName = cstGameFile, + //UseShellExecute = true, + Arguments = "-server=" + setServerHost, // TODO: custom mod + WorkingDirectory = Path.GetDirectoryName(cstGameFile), + } }; try { @@ -445,11 +456,11 @@ public void DoStart() } else { - Logger.Info("Game", "Progress is still running..."); + Logger.Info("Game", "Game process is already running. Skipping launch."); } } - public void InstallCert() + public static void InstallCert() { bool installationSucceeded = false; while (!installationSucceeded) @@ -460,7 +471,7 @@ public void InstallCert() X509Certificate2 certificate = new X509Certificate2("rootCert.pfx"); // Open the Root certificate store for the current user - X509Store store = new X509Store(StoreName.Root, StoreLocation.CurrentUser); + X509Store store = new(StoreName.Root, StoreLocation.CurrentUser); store.Open(OpenFlags.ReadWrite); // Add the certificate to the store @@ -469,28 +480,28 @@ public void InstallCert() // Close the store store.Close(); - Console.WriteLine("Certificate installed successfully."); + Logger.Info("Certificate", "Certificate installed successfully."); installationSucceeded = true; // Set flag to true to exit the loop } catch (Exception ex) { - Console.WriteLine("Error: " + ex.Message); + Logger.Error("Certificate", "Error: " + ex.Message); } } } - public bool CheckVersionGame(GameType game_type) + public bool CheckVersionGame(GameType gameType) { - var cst_folder_game = Set_LA_GameFolder.Text; + var cstFolderGame = Set_LA_GameFolder.Text; // If user doesn't have a game config folder, try searching for it automatically - if (String.IsNullOrEmpty(cst_folder_game)) + if (string.IsNullOrEmpty(cstFolderGame)) { - var Get_Launcher = GetLauncherPath(game_type); - Logger.Info("Launcher", "Folder Launcher: " + Get_Launcher); + var getLauncher = GetLauncherPath(gameType); + Logger.Info("Launcher", "Folder Launcher: " + (getLauncher == "" ? "Not Found" : getLauncher)); - if (string.IsNullOrEmpty(Get_Launcher)) + if (string.IsNullOrEmpty(getLauncher)) { // If there is no launcher Logger.Info("Game", "Please find game install folder!"); @@ -499,34 +510,34 @@ public bool CheckVersionGame(GameType game_type) else { // If there is no launcher, try searching the game folder - cst_folder_game = GetGamePath(Get_Launcher); + cstFolderGame = GetGamePath(getLauncher); } } // Check one more time - if (string.IsNullOrEmpty(cst_folder_game)) + if (string.IsNullOrEmpty(cstFolderGame)) { Logger.Info("Game", "Please find game install folder!"); return false; } - if (!Directory.Exists(cst_folder_game)) + if (!Directory.Exists(cstFolderGame)) { Logger.Info("Game", "Please find game install folder! (2)"); // TODO return false; } - Logger.Info("Game", "Folder Game: " + cst_folder_game); + Logger.Info("Game", "Folder Game: " + cstFolderGame); - string cn = Path.Combine(cst_folder_game, "YuanShen.exe"); - string os = Path.Combine(cst_folder_game, "GenshinImpact.exe"); - if (game_type == GameType.StarRail) + string cn = Path.Combine(cstFolderGame, "YuanShen.exe"); + string os = Path.Combine(cstFolderGame, "GenshinImpact.exe"); + if (gameType == GameType.StarRail) { - cn = Path.Combine(cst_folder_game, "StarRail.exe"); // todo - os = Path.Combine(cst_folder_game, "StarRail.exe"); + cn = Path.Combine(cstFolderGame, "StarRail.exe"); // todo + os = Path.Combine(cstFolderGame, "StarRail.exe"); } // Path - if (game_type == GameType.GenshinImpact) + if (gameType == GameType.GenshinImpact) { // Pilih Channel if (File.Exists(cn)) @@ -546,19 +557,17 @@ public bool CheckVersionGame(GameType game_type) else { // jika game versi tidak di dukung atau tidak ada file - Logger.Error("Game", "No game files found!!!"); + Logger.Error("Game", $"No game executable found in the specified folder: {cstFolderGame}. Please ensure the game is properly installed."); return false; } // Settings try { - settings_genshin = new Game.Genshin.Settings(GameChannel); - if (settings_genshin != null) + settingsGenshin = new Game.Genshin.Settings(GameChannel); + if (settingsGenshin != null) { - Logger.Info("Game", "Game Text Language: " + settings_genshin.GetGameLanguage()); - Logger.Info("Game", "Game Voice Language: " + settings_genshin.GetVoiceLanguageID()); - Logger.Info("Game", "Game Server: " + settings_genshin.GetRegServerNameID()); + Logger.Info("Game", $"Game Settings - Text Language: {settingsGenshin.GetGameLanguage()}, Voice Language: {settingsGenshin.GetVoiceLanguageID()}, Server: {settingsGenshin.GetRegServerNameID()}"); } } catch (Exception ex) @@ -576,21 +585,21 @@ public bool CheckVersionGame(GameType game_type) } // Check MD5 Game - string Game_LOC_Original_MD5 = Tool.CalculateMD5(PathfileGame); + string gameLOCOriginalMD5 = Tool.CalculateMD5(PathfileGame); // Check MD5 in Server API - get_patch = API.GetMD5Game(Game_LOC_Original_MD5, game_type); - if (get_patch == null) + getPatch = API.GetMD5Game(gameLOCOriginalMD5, gameType); + if (getPatch == null) { - Logger.Error("Game", "No Support Game with MD5: " + Game_LOC_Original_MD5 + " (Send this log to admin)"); + Logger.Error("Game", $"Unsupported game version detected. MD5: {gameLOCOriginalMD5}. Please report this to the admin."); return false; } - VersionGame = get_patch.version; + VersionGame = getPatch.Version; if (VersionGame == "0.0.0") { - Logger.Error("Game", "Version not supported: MD5 " + Game_LOC_Original_MD5); + Logger.Error("Game", $"Unsupported game version detected. MD5: {gameLOCOriginalMD5}."); Get_LA_Version.Text = "Version: Unknown"; Get_LA_CH.Text = "Channel: Unknown"; @@ -600,138 +609,160 @@ public bool CheckVersionGame(GameType game_type) return false; } - var get_channel = get_patch.channel; + var get_channel = getPatch.Channel; // IF ALL OK - Set_LA_GameFolder.Text = cst_folder_game; + Set_LA_GameFolder.Text = cstFolderGame; // Set Version - Get_LA_Version.Text = "Version: " + get_patch.version; + Get_LA_Version.Text = "Version: " + getPatch.Version; Get_LA_CH.Text = "Channel: " + get_channel; - Get_LA_REL.Text = "Release: " + get_patch.release; + Get_LA_REL.Text = "Release: " + getPatch.Release; - Logger.Info("Game", "Currently using version game " + VersionGame); - Logger.Info("Game", "File Game: " + PathfileGame); - Logger.Info("Game", "MD5 Game Currently: " + Game_LOC_Original_MD5); + Logger.Info("Game", $"Game version: {VersionGame}"); + Logger.Info("Game", $"Game executable path: {PathfileGame}"); + Logger.Info("Game", $"Game executable MD5 hash: {gameLOCOriginalMD5}"); - Get_LA_MD5.Text = "MD5: " + Game_LOC_Original_MD5; + Get_LA_MD5.Text = "MD5: " + gameLOCOriginalMD5; return true; } - public string PatchGame(bool patchit = true) + public bool PatchGame(bool patchIt = true) { // check folder game (root) - var root_folder = Set_LA_GameFolder.Text; - if (String.IsNullOrEmpty(root_folder)) + var rootFolder = Set_LA_GameFolder.Text; + if (string.IsNullOrEmpty(rootFolder)) { - return "No game folder found (1)"; + Logger.Error("PatchGame", "Game folder path is empty or null"); + return false; } - if (!Directory.Exists(root_folder)) + if (!Directory.Exists(rootFolder)) { - return "No game folder found (2)"; + Logger.Error("PatchGame", $"Game folder not found at path: {rootFolder}"); + return false; } // check version - if (get_patch == null) + if (getPatch == null) { - return "Can't find version, try clicking 'Get Key' in config tab"; - } + Logger.Error("PatchGame", "Unable to determine game version. Please click 'Get Key' in the config tab to retrieve version information."); + return false; + } if (VersionGame == "0.0.0") { - return "This Game Version is not compatible with this method patch"; + Logger.Error("PatchGame", "The current game version is not compatible with this patching method. Please ensure you have a supported game version."); + return false; } - if (patchit) + if (patchIt) { // for patch - if (get_patch.patched != null && get_patch.patched.Any()) + if (getPatch.Patched != null && getPatch.Patched.Any()) { - foreach (var data in get_patch.patched) + foreach (var data in getPatch.Patched) { - var iss = PatchCopy(root_folder, data.file, data.location, data.md5, "patch", get_patch.version); - if (!String.IsNullOrEmpty(iss)) + var iss = PatchCopy(rootFolder, data.File, data.Location, data.MD5, "patch", getPatch.Version); + if (!string.IsNullOrEmpty(iss)) { - return iss; + Logger.Error("PatchGame", $"Failed to patch file: {data.File}. Error: {iss}"); + return false; } } + Logger.Info("PatchGame", "Successfully patched all files"); } else { - Logger.Info("Patch", "no need for any patch"); + Logger.Info("PatchGame", "No files needed patching"); } } else { // for unpatch - if (get_patch.patched != null && get_patch.patched.Any()) + if (getPatch.Patched != null && getPatch.Patched.Any()) { - foreach (var data in get_patch.patched) + foreach (var data in getPatch.Patched) { - var iss = PatchCopy(root_folder, data.file, data.location, data.md5, "unpatch", get_patch.version); - if (!String.IsNullOrEmpty(iss)) + var iss = PatchCopy(rootFolder, data.File, data.Location, data.MD5, "unpatch", getPatch.Version); + if (!string.IsNullOrEmpty(iss)) { - return iss; + Logger.Error("PatchGame", $"Failed to unpatch file: {data.File}. Error: {iss}"); + return false; } } + Logger.Info("PatchGame", "Successfully unpatched all files"); } else { - Logger.Info("Patch", "no files deleted"); + Logger.Info("PatchGame", "No files needed unpatching"); } - if (get_patch.original != null && get_patch.original.Any()) + if (getPatch.Original != null && getPatch.Original.Any()) { - foreach (var data in get_patch.original) + foreach (var data in getPatch.Original) { - var iss = PatchCopy(root_folder, data.file, data.location, data.md5, "original", get_patch.version); - if (!String.IsNullOrEmpty(iss)) + var iss = PatchCopy(rootFolder, data.File, data.Location, data.MD5, "original", getPatch.Version); + if (!string.IsNullOrEmpty(iss)) { - return iss; + Logger.Error("PatchGame", $"Failed to restore original file: {data.File}. Error: {iss}"); + return false; } } + Logger.Info("PatchGame", "Successfully restored all original files"); } else { - Logger.Info("Patch", "no files restored to original"); + Logger.Info("PatchGame", "No original files needed restoring"); } } - return ""; + Logger.Info("PatchGame", $"Game {(patchIt ? "patched" : "unpatched")} successfully"); + return true; } private void Set_LA_Select_Click(object sender, EventArgs e) { - var Folder_Game_Now = SelectGamePath(); - if (!string.IsNullOrEmpty(Folder_Game_Now)) + var selectedGameFolder = SelectGamePath(); + if (!string.IsNullOrEmpty(selectedGameFolder)) { - Set_LA_GameFolder.Text = Folder_Game_Now; - if (!CheckVersionGame(default_profile.game.type)) + Set_LA_GameFolder.Text = selectedGameFolder; + Logger.Info("Game Folder", $"Selected game folder: {selectedGameFolder}"); + if (!CheckVersionGame(DefaultProfile.GameConfig.type)) + { + string message = $"The game version in {selectedGameFolder} may not be supported. Please check the console for more details."; + Logger.Warning("Game Version", message); + MessageBox.Show(message, "Game Version", MessageBoxButtons.OK, MessageBoxIcon.Error); + + string url = API.WebLink + "/game/" + DefaultProfile.GameConfig.type.SEOUrl(); + Logger.Info("Browser", $"Opening URL for game support: {url}"); + Process.Start(new ProcessStartInfo(url) { UseShellExecute = true }); + } + else { - MessageBox.Show("This game version may not be supported please check your console!!!"); - Process.Start(new ProcessStartInfo(API.WEB_LINK + "/game/" + default_profile.game.type.SEOUrl()) { UseShellExecute = true }); + Logger.Info("Game Version", "Game version check passed successfully."); } } else { - MessageBox.Show("No game folder found"); + Logger.Error("Game Folder", "No game folder was selected or found."); + MessageBox.Show("No game folder found. Please select a valid game folder."); } } - public string PatchCopy(string root_folder, string url_file, string file_name, string file_md5, string iscopy, string version) + public static string PatchCopy(string rootFolder, string urlFile, string fileName, string fileMD5, string isCopy, string version) { - string fileSave = Path.Combine(root_folder, file_name); + string fileSave = Path.Combine(rootFolder, fileName); - if (iscopy == "unpatch") + if (isCopy == "unpatch") { try { File.Delete(fileSave); - Logger.Info("Patch", $"File remove {fileSave}"); + Logger.Info("Patch", $"Successfully removed file: {fileSave}"); return ""; } catch (Exception e) { - Logger.Error("Patch", $"File remove error {fileSave} > {e.Message}"); + Logger.Error("Patch", $"Failed to remove file: {fileSave}. Error: {e.Message}"); return e.Message; } } @@ -739,23 +770,23 @@ public string PatchCopy(string root_folder, string url_file, string file_name, s if (File.Exists(fileSave)) { var md5_file_raw = Tool.CalculateMD5(fileSave); - if(md5_file_raw == file_md5) + if (md5_file_raw == fileMD5) { - Logger.Info("Patch", $"File {fileSave} this already exists and md5 is accurate so no action is needed for {iscopy}"); + Logger.Info("Patch", $"File '{fileSave}' already exists with matching MD5. No action needed for '{isCopy}' operation."); return ""; } - } + } - var backupPatch = Path.Combine(Config.Modfolder, "i", version, iscopy, file_name); + var backupPatch = Path.Combine(Config.Modfolder, "i", version, isCopy, fileName); if (File.Exists(backupPatch)) { - var md5_file_raw = Tool.CalculateMD5(backupPatch); - if(md5_file_raw == file_md5) + var backupPatchMd5 = Tool.CalculateMD5(backupPatch); + if (backupPatchMd5 == fileMD5) { - Logger.Info("Patch", $"Found backup {iscopy} > {backupPatch} > {fileSave}"); + Logger.Info("Patch", $"Found backup {isCopy} > {backupPatch} > {fileSave}"); - string saveDir = Path.GetDirectoryName(fileSave); - if (!Directory.Exists(saveDir)) + string saveDir = Path.GetDirectoryName(fileSave) ?? string.Empty; + if (!string.IsNullOrEmpty(saveDir) && !Directory.Exists(saveDir)) { Directory.CreateDirectory(saveDir); } @@ -766,31 +797,31 @@ public string PatchCopy(string root_folder, string url_file, string file_name, s { // skip ? } - } + } - Logger.Info("Patch", $"Start download {url_file} and save to {fileSave} for {iscopy}"); + Logger.Info("Patch", $"Initiating download for {isCopy}: URL: {urlFile}, Destination: {fileSave}"); - var CEKDL1 = new Download(url_file, fileSave); + var CEKDL1 = new Download(urlFile, fileSave); if (CEKDL1.ShowDialog() != DialogResult.OK) { - return $"Error download ${iscopy} file: {url_file} to {fileSave}"; + return $"Error download ${isCopy} file: {urlFile} to {fileSave}"; } else { - var md5_file = Tool.CalculateMD5(fileSave); - if (md5_file == file_md5) + var md5_file = Tool.CalculateMD5(fileSave); + if (md5_file == fileMD5) { - string backupDir = Path.GetDirectoryName(backupPatch); - if (!Directory.Exists(backupDir)) + string backupDir = Path.GetDirectoryName(backupPatch) ?? string.Empty; + if (!string.IsNullOrEmpty(backupDir) && !Directory.Exists(backupDir)) { Directory.CreateDirectory(backupDir); } - Logger.Info("Game", $"MD5 Patch File {url_file}: " + md5_file); + Logger.Info("Game", $"MD5 Patch File {urlFile}: " + md5_file); File.Copy(fileSave, backupPatch, overwrite: true); } else { - return $"Error patch file {url_file}, md5 file mismatch {md5_file}"; + return $"Error patch file {urlFile}, md5 file mismatch {md5_file}"; } } @@ -800,101 +831,101 @@ public string PatchCopy(string root_folder, string url_file, string file_name, s public void CheckUpdate() { - Logger.Info("Game", "Check update..."); - var version = Assembly.GetExecutingAssembly().GetName().Version; - string ver = ""; - if (version != null) - { - ver = version.ToString(); - Set_Version.Text = "Version: " + ver; - var GetDataUpdate = API.GetUpdate(); - if (GetDataUpdate != null) + try + { + Logger.Info("Game", "Checking for launcher updates..."); + var version = Assembly.GetExecutingAssembly().GetName().Version; + var versionLauncher = ""; + if (version == null) { - var judul = "New Update: " + GetDataUpdate.name; // is dev or nightly or name update - var name_version = GetDataUpdate.tag_name; // version name - var infobody = GetDataUpdate.body; // info + Text = "YuukiPS Launcher " + "(Version: Unknown)"; + return; + } - var version1 = new Version(name_version); - var version2 = new Version(ver); - var result = version1.CompareTo(version2); + string ver = version.ToString(); + versionLauncher = "Version: " + ver; + Text = "YuukiPS Launcher " + versionLauncher; + var getDataUpdate = API.GetUpdate(); + if (getDataUpdate == null) return; - if (result > 0) - { - // versi 1 lebih besar - Set_Version.Text = "Version: " + ver + " (New Update: " + name_version + " )"; - var tes = MessageBox.Show(infobody, judul, MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (tes == DialogResult.Yes) - { - var url_dl = ""; - foreach (var file in GetDataUpdate.assets) - { - if (file.name == "YuukiPSLauncherPC.zip" || file.name == "YuukiPS.zip" || file.name == "update.zip") - { - url_dl = file.browser_download_url; - break; - } - } - if (!string.IsNullOrEmpty(url_dl)) - { - var DL1 = new Download(url_dl, Json.Config.CurrentlyPath + @"\update.zip"); - if (DL1.ShowDialog() == DialogResult.OK) - { - // update - var file_update = Json.Config.CurrentlyPath + @"\update.bat"; - try - { - //buat bat - var w = new StreamWriter(file_update); - w.WriteLine("@echo off"); - - //kill all - w.WriteLine("Taskkill /IM YuukiPS.exe /F"); - //w.WriteLine("Taskkill /IM YuukiPS.vshost.exe /F"); - - // Unzip file - w.WriteLine("echo unzip file..."); - w.WriteLine("tar -xf update.zip"); - - //delete file old - w.WriteLine("echo delete file old"); - w.WriteLine("del update.zip"); - - //start bot - w.WriteLine("echo Update done, start back..."); - w.WriteLine("timeout 5 > NUL"); - w.WriteLine("start YuukiPS.exe"); - w.WriteLine("del Update.bat"); - w.Close(); - //open bat - Process.Start(file_update); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - } - } - } - else - { - // update batal - } + var nameVersion = getDataUpdate.TagName; + if (!Version.TryParse(nameVersion, out var version1) || !Version.TryParse(ver, out var version2)) + { + Logger.Error("Update", "Unable to compare version numbers. This might be due to an unexpected version format."); + MessageBox.Show("We encountered an issue while checking for updates. The version numbers couldn't be compared correctly.", "Update Check Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } - } - } - else if (result < 0) - { - Set_Version.Text = "Version: " + ver + " (latest nightly) (Official: " + name_version + ")"; - } - else + var result = version1.CompareTo(version2); + + if (result > 0) + { + versionLauncher = $"Version: {ver} (New Update: {nameVersion})"; + var tes = MessageBox.Show(getDataUpdate.Body, $"New Update: {getDataUpdate.Name}", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (tes == DialogResult.Yes) { - Set_Version.Text = "Version: " + ver + " (latest public)"; + PerformUpdate(getDataUpdate.Assets); } } + else if (result < 0) + { + versionLauncher = $"Version: {ver} (latest nightly) (Official: {nameVersion})"; + } + else + { + versionLauncher = $"Version: {ver} (latest public)"; + } + + Text = "YuukiPS Launcher " + versionLauncher; } - else + catch (Exception ex) { - Set_Version.Text = "Version: Unknown"; + Logger.Error("Update", $"Error checking for updates: {ex.Message}"); + MessageBox.Show($"An error occurred while checking for updates: {ex.Message}", "Update Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private static void PerformUpdate(IEnumerable assets) + { + try + { + var url_dl = assets.FirstOrDefault(file => + file.Name == "YuukiPSLauncherPC.zip" || + file.Name == "YuukiPS.zip" || + file.Name == "update.zip")?.BrowserDownloadUrl; + + if (string.IsNullOrEmpty(url_dl)) + { + MessageBox.Show("Update file not found.", "Update Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + var updateZipPath = Path.Combine(Config.CurrentlyPath, "update.zip"); + var DL1 = new Download(url_dl, updateZipPath); + if (DL1.ShowDialog() != DialogResult.OK) return; + + var fileUpdate = Path.Combine(Config.CurrentlyPath, "update.bat"); + using (var w = new StreamWriter(fileUpdate)) + { + w.WriteLine("@echo off"); + w.WriteLine("Taskkill /IM YuukiPS.exe /F"); + Logger.Info("Update", "Extracting update files..."); + w.WriteLine("tar -xf update.zip"); + Logger.Info("Update", "Removing temporary update file..."); + w.WriteLine("del update.zip"); + Logger.Info("Update", "Update completed. Restarting application..."); + w.WriteLine("timeout 5 > NUL"); + w.WriteLine("start YuukiPS.exe"); + w.WriteLine("del Update.bat"); + } + + Process.Start(fileUpdate); + } + catch (Exception ex) + { + Logger.Error("Update", $"Error performing update: {ex.Message}"); + MessageBox.Show($"An error occurred during the update process: {ex.Message}", "Update Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -906,18 +937,17 @@ private static string GetLauncherPath(GameType version) RegistryKey key = Registry.LocalMachine; if (key != null) { - var tes1 = key.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + version.GetStringValue()); - if (tes1 != null) + var subKey = key.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + version.GetStringValue()); + if (subKey != null) { - var testes1 = tes1.GetValue("InstallPath"); - if (testes1 != null) + var installPathValue = subKey.GetValue("InstallPath"); + if (installPathValue != null) { - var testestestes1 = testes1.ToString(); - if (testestestes1 != null) + var installPathString = installPathValue.ToString(); + if (installPathString != null) { - return testestestes1; + return installPathString; } - } } } @@ -925,42 +955,42 @@ private static string GetLauncherPath(GameType version) } // Check Game Install - private static string GetGamePath(String launcherpath = "") + private static string GetGamePath(string launcherPath = "") { - string startpath = ""; + string startPath = ""; - if (launcherpath == "") + if (launcherPath == "") { return ""; } - string cfgPath = Path.Combine(launcherpath, "config.ini"); - if (File.Exists(launcherpath) || File.Exists(cfgPath)) + string cfgPath = Path.Combine(launcherPath, "config.ini"); + if (File.Exists(launcherPath) || File.Exists(cfgPath)) { // baca file config - using (StreamReader reader = new StreamReader(cfgPath)) + using StreamReader reader = new(cfgPath); + string[] abc = reader.ReadToEnd().Split(new string[] { "\r\n" }, StringSplitOptions.None); + foreach (var item in abc) { - string[] abc = reader.ReadToEnd().Split(new string[] { "\r\n" }, StringSplitOptions.None); - foreach (var item in abc) + // cari line install patch + if (item.Contains("game_install_path", StringComparison.CurrentCulture)) { - // cari line install patch - if (item.IndexOf("game_install_path") != -1) - { - startpath += item.Substring(item.IndexOf("=") + 1); - } + startPath += item[(item.IndexOf("=") + 1)..]; } } } - return startpath; + return startPath; } // Pilih Folder private static string SelectGamePath() { string foldPath = ""; - FolderBrowserDialog dialog = new FolderBrowserDialog(); - dialog.Description = "Select Game Folder"; + FolderBrowserDialog dialog = new() + { + Description = "Select Game Folder" + }; if (dialog.ShowDialog() == DialogResult.OK) { foldPath = dialog.SelectedPath; @@ -968,30 +998,29 @@ private static string SelectGamePath() return foldPath; } - public void IsAcess(bool onoff) + public void IsAccess(bool isEnabled) { - GetTypeGame.Enabled = onoff; - btStartOfficialServer.Enabled = onoff; - btStartYuukiServer.Enabled = onoff; - GetServerHost.Enabled = onoff; - - grProxy.Enabled = onoff; - grExtra.Enabled = onoff; - grConfigGameLite.Enabled = onoff; - grProfile.Enabled = onoff; + GetTypeGame.Enabled = isEnabled; + btStartOfficialServer.Enabled = isEnabled; + btStartYuukiServer.Enabled = isEnabled; + GetServerHost.Enabled = isEnabled; + + grProxy.Enabled = isEnabled; + grExtra.Enabled = isEnabled; + grConfigGameLite.Enabled = isEnabled; + grProfile.Enabled = isEnabled; } private void CheckGameRun_Tick(object sender, EventArgs e) { - var isrun = Process.GetProcesses().Where(pr => pr.ProcessName == WatchFile || pr.ProcessName == WatchCheat); - if (!isrun.Any()) + var isRunning = Process.GetProcesses().Where(pr => pr.ProcessName == WatchFile || pr.ProcessName == WatchCheat); + if (!isRunning.Any()) { // Jika Game tidak berjalan.... - IsGameRun = false; + isGameRunning = false; btStartNormal.Text = "Launch"; - IsAcess(true); - - AllStop(); + IsAccess(true); + // AllStop(); // Revert to original version every game close if (!DoneCheck) @@ -999,16 +1028,13 @@ private void CheckGameRun_Tick(object sender, EventArgs e) Console.WriteLine("Game detected stopped"); DoneCheck = true; StopGame(); // this shouldn't be necessary but just let it be - - var unpatch = PatchGame(false); - if (!string.IsNullOrEmpty(unpatch)) - { - Logger.Info("Game", unpatch); - } + StopProxy(); + + PatchGame(false); if (Enable_WipeLoginCache.Checked) { - Tool.WipeLogin(default_profile.game.type); + Tool.WipeLogin(DefaultProfile.GameConfig.type); } if (Enable_RPC.Checked) @@ -1020,10 +1046,10 @@ private void CheckGameRun_Tick(object sender, EventArgs e) else { // jika game jalan - IsGameRun = true; + isGameRunning = true; btStartNormal.Text = "Stop"; DoneCheck = false; - IsAcess(false); + IsAccess(false); if (Enable_RPC.Checked) { @@ -1035,20 +1061,30 @@ private void CheckGameRun_Tick(object sender, EventArgs e) public void AllStop() { - StopProxy(); - StopGame(); + try + { + StopProxy(); + StopGame(); + } + catch (Exception e) + { + Logger.Error("AllStop", "There was an error occurred when stopping the game and proxy: " + e.Message); + } } + public void StopProxy() { try { + if (proxy == null) return; proxy.Stop(); proxy = null; - Logger.Info("Proxy", "Proxy Stop...."); + Logger.Info("Proxy", "Proxy stopped"); } - catch (Exception ex) { - // skip + catch (Exception e) + { + Logger.Error("Proxy", "There was an error stopping the proxy: " + e.Message); } } @@ -1069,7 +1105,7 @@ public void StopGame() } progress = null; } - if (IsGameRun) + if (isGameRunning) { try { @@ -1091,36 +1127,36 @@ public void StopGame() } } - private void linkDiscord_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + private void LinkDiscordLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { Process.Start(new ProcessStartInfo("http://discord.yuuki.me/") { UseShellExecute = true }); } - private void linkGithub_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + private void LinkGithubLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { Process.Start(new ProcessStartInfo("https://github.com/YuukiPS/") { UseShellExecute = true }); } - private void linkWeb_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + private void LinkWebLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { - Process.Start(new ProcessStartInfo(API.WEB_LINK) { UseShellExecute = true }); + Process.Start(new ProcessStartInfo(API.WebLink) { UseShellExecute = true }); } - private void Main_FormClosing(object sender, FormClosingEventArgs e) + private void MainFormClosing(object sender, FormClosingEventArgs e) { - if (IsGameRun) + if (isGameRunning) { MessageBox.Show("Can't close program while game is still running."); e.Cancel = true; } } - private void CheckProxyRun_Tick(object sender, EventArgs e) + private void CheckProxyRunTick(object sender, EventArgs e) { CheckProxy(false); } - void CheckProxy(bool force_off = false) + void CheckProxy(bool forceDisable = false) { try { @@ -1144,11 +1180,11 @@ void CheckProxy(bool force_off = false) // If external is on and proxy app is enabled, make sure external proxy is off if (CheckProxyEnable.Checked) { - force_off = true; + forceDisable = true; } } - if (force_off) + if (forceDisable) { registry.SetValue("ProxyEnable", 0); } @@ -1170,7 +1206,7 @@ void CheckProxy(bool force_off = false) } } - private void Server_Config_OpenFolder_Click(object sender, EventArgs e) + private void ServerConfigOpenFolderClick(object sender, EventArgs e) { Process.Start(new ProcessStartInfo() { @@ -1180,12 +1216,12 @@ private void Server_Config_OpenFolder_Click(object sender, EventArgs e) }); } - private void Server_Start_Click(object sender, EventArgs e) + private void ServerStartClick(object sender, EventArgs e) { Logger.Warning("Server", "Still PR :)"); } - private void Server_DL_JAVA_Click(object sender, EventArgs e) + private void ServerDLJAVAClick(object sender, EventArgs e) { var dl_java = Server.DLJava(); if (!string.IsNullOrEmpty(dl_java)) @@ -1198,7 +1234,7 @@ private void Server_DL_JAVA_Click(object sender, EventArgs e) } } - private void Extra_Enable_RPC_CheckedChanged(object sender, EventArgs e) + private void ExtraEnableRPCCheckedChanged(object sender, EventArgs e) { if (Enable_RPC.Checked) { @@ -1212,9 +1248,73 @@ private void Extra_Enable_RPC_CheckedChanged(object sender, EventArgs e) } } - private void wipeLoginCacheInfo_Click(object sender, EventArgs e) + private void WipeLoginCacheInfoClick(object sender, EventArgs e) { MessageBox.Show("This deletes the login cache every time the game closes (logs you out).\nThis is useful if you use the guest account on HSR servers, since you don't have to remember to log out.", "Information.", MessageBoxButtons.OK, MessageBoxIcon.Question); } + + private void GetLAMD5Click(object sender, EventArgs e) + { + string md5 = Tool.CalculateMD5(PathfileGame); + if (string.IsNullOrEmpty(md5)) + { + MessageBox.Show("Failed to get MD5 hash. Please try again."); + return; + }; + + using var md5Form = new Form + { + Text = "Game Executable MD5", + Size = new Size(400, 200), + FormBorderStyle = FormBorderStyle.FixedDialog, + StartPosition = FormStartPosition.CenterScreen, + BackColor = Color.FromArgb(45, 45, 48) + }; + + var label = new Label + { + Text = "MD5 Hash", + Font = new Font("Segoe UI", 16, FontStyle.Bold), + ForeColor = Color.White, + AutoSize = true + }; + + var textBox = new TextBox + { + Text = md5, + Font = new Font("Consolas", 12), + ForeColor = Color.LightGreen, + BackColor = Color.FromArgb(30, 30, 30), + BorderStyle = BorderStyle.None, + Size = new Size(360, 30), + ReadOnly = true + }; + + var button = new Button + { + Text = "Copy to Clipboard", + FlatStyle = FlatStyle.Flat, + ForeColor = Color.White, + BackColor = Color.FromArgb(0, 122, 204), + Size = new Size(360, 40), + Cursor = Cursors.Hand + }; + + md5Form.Controls.AddRange(new Control[] { label, textBox, button }); + + // Center the controls + int startY = (md5Form.ClientSize.Height - (label.Height + textBox.Height + button.Height + 20)) / 2; + label.Location = new Point((md5Form.ClientSize.Width - label.Width) / 2, startY); + textBox.Location = new Point((md5Form.ClientSize.Width - textBox.Width) / 2, label.Bottom + 10); + button.Location = new Point((md5Form.ClientSize.Width - button.Width) / 2, textBox.Bottom + 10); + + button.Click += (_, _) => + { + Clipboard.SetText(md5); + MessageBox.Show("MD5 hash copied to clipboard.", "Copied", MessageBoxButtons.OK, MessageBoxIcon.Information); + }; + + md5Form.ShowDialog(); + } } } diff --git a/Main.resx b/Main.resx index ab8a6d3..1385230 100644 --- a/Main.resx +++ b/Main.resx @@ -1,7 +1,7 @@