mirror of
https://github.com/JuniorDark/RustyHearts-Launcher.git
synced 2026-05-07 05:21:44 -04:00
Changes for RustyHearts-API 1.3.0
This commit is contained in:
parent
558761943e
commit
1692923e18
14 changed files with 500 additions and 226 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using RHLauncher.RHLauncher.Helper;
|
||||
using Newtonsoft.Json;
|
||||
using RHLauncher.RHLauncher.Helper;
|
||||
using RHLauncher.RHLauncher.i8n;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
|
|
@ -8,10 +9,10 @@ namespace RHLauncher
|
|||
{
|
||||
private RegistryHandler registryHandler = new();
|
||||
|
||||
public string SendPasswordCodeUrl = Configuration.Default.SendPasswordCodeUrl;
|
||||
public string VerifyCodeUrl = Configuration.Default.VerifyCodeUrl;
|
||||
public string ChangePasswordUrl = Configuration.Default.ChangePasswordUrl;
|
||||
public string Lang = Configuration.Default.Lang;
|
||||
private readonly string SendPasswordCodeUrl = Configuration.Default.SendPasswordCodeUrl;
|
||||
private readonly string VerifyCodeUrl = Configuration.Default.VerifyCodeUrl;
|
||||
private readonly string ChangePasswordUrl = Configuration.Default.ChangePasswordUrl;
|
||||
private readonly string Lang = Configuration.Default.Lang;
|
||||
private List<Button>? buttons;
|
||||
private List<ImageList>? imageLists;
|
||||
private Dictionary<string, List<ImageList>>? languageImageLists;
|
||||
|
|
@ -54,16 +55,16 @@ namespace RHLauncher
|
|||
private void LoadLocalizedStrings()
|
||||
{
|
||||
// Initialize buttons and image lists
|
||||
buttons = new List<Button> { ContinueButtonS1, SendEmailButton, OkButtonS2 };
|
||||
imageLists = new List<ImageList> { imageListContinueBtn, imageListSendEmailBtn, imageListOKBtn };
|
||||
buttons = [ContinueButtonS1, SendEmailButton, OkButtonS2];
|
||||
imageLists = [imageListContinueBtn, imageListSendEmailBtn, imageListOKBtn];
|
||||
|
||||
// Initialize language-specific image lists
|
||||
languageImageLists = new Dictionary<string, List<ImageList>>
|
||||
{
|
||||
{ "en", new List<ImageList> { imageListContinueBtn, imageListSendEmailBtn, imageListOKBtn } }, // English image lists
|
||||
{ "ko", new List<ImageList> { imageListContinueBtn_ko, imageListSendEmailBtn_ko, imageListOKBtn_ko } }, // Korean image lists
|
||||
// Add other languages and their respective image lists here
|
||||
};
|
||||
{
|
||||
{ "en", new List<ImageList> { imageListContinueBtn, imageListSendEmailBtn, imageListOKBtn } }, // English image lists
|
||||
{ "ko", new List<ImageList> { imageListContinueBtn_ko, imageListSendEmailBtn_ko, imageListOKBtn_ko } }, // Korean image lists
|
||||
// Add other languages and their respective image lists here
|
||||
};
|
||||
|
||||
// Load the appropriate resource file based on the selected language
|
||||
LocalizationHelper.LoadLocalizedStrings(Lang, buttons, imageLists, languageImageLists);
|
||||
|
|
@ -91,12 +92,12 @@ namespace RHLauncher
|
|||
private async Task<string> SendEmailRequestAsync()
|
||||
{
|
||||
using HttpClient client = new();
|
||||
using HttpResponseMessage response = await client.PostAsync(SendPasswordCodeUrl, new FormUrlEncodedContent(new[]
|
||||
{
|
||||
using HttpResponseMessage response = await client.PostAsync(SendPasswordCodeUrl, new FormUrlEncodedContent(
|
||||
[
|
||||
new KeyValuePair<string, string>("email", EmailTextBox.Text),
|
||||
|
||||
}));
|
||||
|
||||
]));
|
||||
response.EnsureSuccessStatusCode();
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
|
|
@ -104,45 +105,59 @@ namespace RHLauncher
|
|||
{
|
||||
Invoke((MethodInvoker)(() =>
|
||||
{
|
||||
switch (response)
|
||||
try
|
||||
{
|
||||
case "EmailSent":
|
||||
SendEmailButton.Enabled = false;
|
||||
resendTimer.Start();
|
||||
break;
|
||||
case "ValidVerificationCode":
|
||||
// Hide the firs panel and show the second panel
|
||||
Stage1Panel.Visible = false;
|
||||
Stage2Panel.Visible = true;
|
||||
EmailLabelS2.Text = EmailTextBox.Text;
|
||||
CodeDescLabel.Text = "";
|
||||
CodePictureBox.Image = imageListTips.Images[1];
|
||||
break;
|
||||
case "PasswordChanged":
|
||||
MsgBoxForm.Show(LocalizedStrings.PasswordChanged, LocalizedStrings.Success);
|
||||
OnPasswordChanged();
|
||||
break;
|
||||
case "SamePassword":
|
||||
MsgBoxForm.Show(LocalizedStrings.SamePassword, LocalizedStrings.Failed);
|
||||
break;
|
||||
case "AccountNotFound":
|
||||
EmailDescLabel.Text = LocalizedStrings.AccountNotFound;
|
||||
EmailDescLabel.ForeColor = Color.Red;
|
||||
EmailPictureBox.Image = imageListTips.Images[0];
|
||||
HttpResponse? httpResponse = JsonConvert.DeserializeObject<HttpResponse>(response);
|
||||
|
||||
if (httpResponse == null)
|
||||
{
|
||||
MsgBoxForm.Show(LocalizedStrings.Error + $": {LocalizedStrings.HttpResponseNull}", LocalizedStrings.Error);
|
||||
return;
|
||||
case "InvalidVerificationCode":
|
||||
CodeDescLabel.Text = LocalizedStrings.InvalidVerificationCode;
|
||||
CodeDescLabel.ForeColor = Color.Red;
|
||||
CodePictureBox.Image = imageListTips.Images[0];
|
||||
return;
|
||||
case "ExpiredVerificationCode":
|
||||
CodeDescLabel.Text = LocalizedStrings.ExpiredVerificationCode;
|
||||
CodeDescLabel.ForeColor = Color.Red;
|
||||
CodePictureBox.Image = imageListTips.Images[0];
|
||||
return;
|
||||
default:
|
||||
MsgBoxForm.Show("Error:" + response, LocalizedStrings.Error);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (httpResponse.Result)
|
||||
{
|
||||
case "EmailSent":
|
||||
SendEmailButton.Enabled = false;
|
||||
resendTimer.Start();
|
||||
break;
|
||||
case "ValidVerificationCode":
|
||||
Stage1Panel.Visible = false;
|
||||
Stage2Panel.Visible = true;
|
||||
EmailLabelS2.Text = EmailTextBox.Text;
|
||||
CodeDescLabel.Text = "";
|
||||
CodePictureBox.Image = imageListTips.Images[1];
|
||||
break;
|
||||
case "PasswordChanged":
|
||||
MsgBoxForm.Show(LocalizedStrings.PasswordChanged, LocalizedStrings.Success);
|
||||
OnPasswordChanged();
|
||||
break;
|
||||
case "SamePassword":
|
||||
MsgBoxForm.Show(LocalizedStrings.SamePassword, LocalizedStrings.Failed);
|
||||
break;
|
||||
case "AccountNotFound":
|
||||
EmailDescLabel.Text = LocalizedStrings.AccountNotFound;
|
||||
EmailDescLabel.ForeColor = Color.Red;
|
||||
EmailPictureBox.Image = imageListTips.Images[0];
|
||||
break;
|
||||
case "InvalidVerificationCode":
|
||||
CodeDescLabel.Text = LocalizedStrings.InvalidVerificationCode;
|
||||
CodeDescLabel.ForeColor = Color.Red;
|
||||
CodePictureBox.Image = imageListTips.Images[0];
|
||||
break;
|
||||
case "ExpiredVerificationCode":
|
||||
CodeDescLabel.Text = LocalizedStrings.ExpiredVerificationCode;
|
||||
CodeDescLabel.ForeColor = Color.Red;
|
||||
CodePictureBox.Image = imageListTips.Images[0];
|
||||
break;
|
||||
default:
|
||||
MsgBoxForm.Show($"{LocalizedStrings.Error}: " + httpResponse.Message, LocalizedStrings.Error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
MsgBoxForm.Show(LocalizedStrings.Error + $": {LocalizedStrings.HttpResponseParseError}", LocalizedStrings.Error);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
|
@ -167,28 +182,28 @@ namespace RHLauncher
|
|||
private async Task<string> VerifyCodeSendRequestAsync()
|
||||
{
|
||||
using HttpClient client = new();
|
||||
using HttpResponseMessage response = await client.PostAsync(VerifyCodeUrl, new FormUrlEncodedContent(new[]
|
||||
{
|
||||
using HttpResponseMessage response = await client.PostAsync(VerifyCodeUrl, new FormUrlEncodedContent(
|
||||
[
|
||||
new KeyValuePair<string, string>("email", EmailTextBox.Text),
|
||||
new KeyValuePair<string, string>("verification_code", CodeTextBox.Text),
|
||||
new KeyValuePair<string, string>("verification_code_type", "Password"),
|
||||
|
||||
}));
|
||||
new KeyValuePair<string, string>("verificationCode", CodeTextBox.Text),
|
||||
new KeyValuePair<string, string>("verificationCodeType", "Password"),
|
||||
|
||||
]));
|
||||
response.EnsureSuccessStatusCode();
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
private async Task<string> ChangePasswordSendRequestAsync()
|
||||
{
|
||||
using HttpClient client = new();
|
||||
using HttpResponseMessage response = await client.PostAsync(ChangePasswordUrl, new FormUrlEncodedContent(new[]
|
||||
{
|
||||
using HttpResponseMessage response = await client.PostAsync(ChangePasswordUrl, new FormUrlEncodedContent(
|
||||
[
|
||||
new KeyValuePair<string, string>("email", EmailTextBox.Text),
|
||||
new KeyValuePair<string, string>("password", PasswordTextBox.Text),
|
||||
new KeyValuePair<string, string>("verification_code", CodeTextBox.Text),
|
||||
|
||||
}));
|
||||
new KeyValuePair<string, string>("verificationCode", CodeTextBox.Text),
|
||||
|
||||
]));
|
||||
response.EnsureSuccessStatusCode();
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
|
|
@ -325,7 +340,7 @@ namespace RHLauncher
|
|||
string password = PasswordTextBox.Text;
|
||||
|
||||
// Check for minimum length and maximum length
|
||||
if (password.Length < 6 || password.Length > 16)
|
||||
if (password.Length < 8 || password.Length > 16)
|
||||
{
|
||||
PwdDescLabel.Text = LocalizedStrings.PwdDescLabelSize;
|
||||
PwdDescLabel.ForeColor = Color.Red;
|
||||
|
|
|
|||
40
RHLauncher.Forms/ConfigForm.Designer.cs
generated
40
RHLauncher.Forms/ConfigForm.Designer.cs
generated
|
|
@ -40,6 +40,8 @@
|
|||
OkButton = new Button();
|
||||
VersionLabel = new Label();
|
||||
toolTip = new ToolTip(components);
|
||||
ServiceLabel = new Label();
|
||||
cbLauncherService = new ComboBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// CloseButton
|
||||
|
|
@ -88,7 +90,7 @@
|
|||
TitleLabel.AutoEllipsis = true;
|
||||
TitleLabel.AutoSize = true;
|
||||
TitleLabel.BackColor = Color.Transparent;
|
||||
TitleLabel.Font = new Font("Segoe UI", 11F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
TitleLabel.Font = new Font("Segoe UI", 11F, FontStyle.Bold);
|
||||
TitleLabel.ForeColor = Color.White;
|
||||
TitleLabel.ImageAlign = ContentAlignment.TopRight;
|
||||
TitleLabel.ImeMode = ImeMode.NoControl;
|
||||
|
|
@ -125,7 +127,7 @@
|
|||
LanguageLabel.AutoEllipsis = true;
|
||||
LanguageLabel.AutoSize = true;
|
||||
LanguageLabel.BackColor = Color.Transparent;
|
||||
LanguageLabel.Font = new Font("Segoe UI", 11F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
LanguageLabel.Font = new Font("Segoe UI", 11F, FontStyle.Bold);
|
||||
LanguageLabel.ForeColor = Color.White;
|
||||
LanguageLabel.ImageAlign = ContentAlignment.TopRight;
|
||||
LanguageLabel.ImeMode = ImeMode.NoControl;
|
||||
|
|
@ -161,7 +163,7 @@
|
|||
VersionLabel.AutoSize = true;
|
||||
VersionLabel.BackColor = Color.Transparent;
|
||||
VersionLabel.Cursor = Cursors.Hand;
|
||||
VersionLabel.Font = new Font("Segoe UI", 10F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
VersionLabel.Font = new Font("Segoe UI", 10F, FontStyle.Bold);
|
||||
VersionLabel.ForeColor = Color.White;
|
||||
VersionLabel.Location = new Point(5, 248);
|
||||
VersionLabel.Name = "VersionLabel";
|
||||
|
|
@ -171,6 +173,34 @@
|
|||
toolTip.SetToolTip(VersionLabel, "Click to open github repository");
|
||||
VersionLabel.Click += VersionLabel_Click;
|
||||
//
|
||||
// ServiceLabel
|
||||
//
|
||||
ServiceLabel.Anchor = AnchorStyles.None;
|
||||
ServiceLabel.AutoEllipsis = true;
|
||||
ServiceLabel.AutoSize = true;
|
||||
ServiceLabel.BackColor = Color.Transparent;
|
||||
ServiceLabel.Font = new Font("Segoe UI", 11F, FontStyle.Bold);
|
||||
ServiceLabel.ForeColor = Color.White;
|
||||
ServiceLabel.ImageAlign = ContentAlignment.TopRight;
|
||||
ServiceLabel.ImeMode = ImeMode.NoControl;
|
||||
ServiceLabel.Location = new Point(294, 119);
|
||||
ServiceLabel.Name = "ServiceLabel";
|
||||
ServiceLabel.Size = new Size(59, 20);
|
||||
ServiceLabel.TabIndex = 18;
|
||||
ServiceLabel.Text = "Service";
|
||||
ServiceLabel.TextAlign = ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// cbLauncherService
|
||||
//
|
||||
cbLauncherService.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
cbLauncherService.FormattingEnabled = true;
|
||||
cbLauncherService.Items.AddRange(new object[] { "JPN", "USA", "CHN", "JPN_BETA", "USA_BETA", "CHN_BETA" });
|
||||
cbLauncherService.Location = new Point(254, 142);
|
||||
cbLauncherService.Name = "cbLauncherService";
|
||||
cbLauncherService.Size = new Size(145, 23);
|
||||
cbLauncherService.TabIndex = 17;
|
||||
cbLauncherService.SelectedIndexChanged += CbLauncherService_SelectedIndexChanged;
|
||||
//
|
||||
// ConfigForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
|
|
@ -178,6 +208,8 @@
|
|||
BackColor = Color.Magenta;
|
||||
BackgroundImage = (Image)resources.GetObject("$this.BackgroundImage");
|
||||
ClientSize = new Size(646, 272);
|
||||
Controls.Add(ServiceLabel);
|
||||
Controls.Add(cbLauncherService);
|
||||
Controls.Add(VersionLabel);
|
||||
Controls.Add(OkButton);
|
||||
Controls.Add(LanguageLabel);
|
||||
|
|
@ -210,5 +242,7 @@
|
|||
private Button OkButton;
|
||||
private Label VersionLabel;
|
||||
private ToolTip toolTip;
|
||||
private Label ServiceLabel;
|
||||
private ComboBox cbLauncherService;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +1,36 @@
|
|||
using RHLauncher.RHLauncher.i8n;
|
||||
using RHLauncher.RHLauncher.Helper;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
namespace RHLauncher
|
||||
{
|
||||
public partial class ConfigForm : Form
|
||||
{
|
||||
public string Url = "https://github.com/JuniorDark/RustyHearts-Launcher";
|
||||
private readonly RegistryHandler registryHandler = new();
|
||||
private readonly string? installDirectory;
|
||||
|
||||
private readonly string Url = "https://github.com/JuniorDark/RustyHearts-Launcher";
|
||||
|
||||
private bool languageChanged = false;
|
||||
readonly string currentLanguageCode = Configuration.Default.Lang;
|
||||
|
||||
private bool serviceChanged = false;
|
||||
readonly string currentService = Configuration.Default.Service;
|
||||
|
||||
public ConfigForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
installDirectory = registryHandler.GetInstallDirectory();
|
||||
string currentVersion = GetLauncherVersion.GetVersion();
|
||||
cbLauncherLanguage.SelectedItem = GetLanguageName(currentLanguageCode);
|
||||
cbLauncherService.SelectedItem = GetServiceName(currentService);
|
||||
|
||||
VersionLabel.Text = $"{LocalizedStrings.Version}: {currentVersion}";
|
||||
Text = LocalizedStrings.ConfigFormTitle;
|
||||
TitleLabel.Text = LocalizedStrings.Settings;
|
||||
LanguageLabel.Text = LocalizedStrings.LauncherLanguage;
|
||||
ServiceLabel.Text = LocalizedStrings.Service;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -61,7 +70,7 @@ namespace RHLauncher
|
|||
{
|
||||
"English" => "en",
|
||||
"한국어" => "ko",
|
||||
_ => "en", // default to English if not found
|
||||
_ => "en",
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -71,40 +80,140 @@ namespace RHLauncher
|
|||
{
|
||||
"en" => "English",
|
||||
"ko" => "한국어",
|
||||
_ => "English", // default to English if not found
|
||||
_ => "English",
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Service Methods
|
||||
|
||||
private void CbLauncherService_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (cbLauncherService.SelectedItem is string selectedItem)
|
||||
{
|
||||
string selectedServiceCode = GetServiceCode(selectedItem);
|
||||
if (selectedServiceCode != currentService)
|
||||
{
|
||||
serviceChanged = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
serviceChanged = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetServiceCode(string? service)
|
||||
{
|
||||
return service switch
|
||||
{
|
||||
"USA" => "usa",
|
||||
"JPN" => "jpn",
|
||||
"CHN" => "chn",
|
||||
"USA_BETA" => "usa_beta",
|
||||
"JPN_BETA" => "jpn_beta",
|
||||
"CHN_BETA" => "chn_beta",
|
||||
_ => "jpn",
|
||||
};
|
||||
}
|
||||
|
||||
private static string GetServiceName(string service)
|
||||
{
|
||||
return service switch
|
||||
{
|
||||
"usa" => "USA",
|
||||
"jpn" => "JPN",
|
||||
"chn" => "CHN",
|
||||
"usa_beta" => "USA_BETA",
|
||||
"jpn_beta" => "JPN_BETA",
|
||||
"chn_beta" => "CHN_BETA",
|
||||
_ => "JPN",
|
||||
};
|
||||
}
|
||||
|
||||
private void UpdateServiceDatFile(string serviceCode)
|
||||
{
|
||||
if (string.IsNullOrEmpty(installDirectory))
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
// Compute MD5 hash
|
||||
byte[] inputBytes = Encoding.UTF8.GetBytes(serviceCode);
|
||||
byte[] hashBytes = System.Security.Cryptography.MD5.HashData(inputBytes);
|
||||
|
||||
StringBuilder sb = new();
|
||||
foreach (byte b in hashBytes)
|
||||
{
|
||||
sb.Append(b.ToString("x2")); // Lowercase hex
|
||||
}
|
||||
string hashString = sb.ToString();
|
||||
|
||||
string fileContent = $"{hashString}\r\n\r\nSTAIRWAY GAMES";
|
||||
|
||||
// Write to Service.dat
|
||||
string filePath = Path.Combine(installDirectory, "Service.dat");
|
||||
File.WriteAllText(filePath, fileContent);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Failed to update Service.dat: {ex.Message}", LocalizedStrings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Button Click Events
|
||||
private void OkButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (languageChanged)
|
||||
try
|
||||
{
|
||||
string? selectedLanguage = cbLauncherLanguage.SelectedItem?.ToString();
|
||||
string languageCode = GetLanguageCode(selectedLanguage);
|
||||
|
||||
if (languageCode != null)
|
||||
if (languageChanged || serviceChanged)
|
||||
{
|
||||
// Update the language in the INI file
|
||||
Configuration.Default.Lang = languageCode;
|
||||
Configuration.Default.iniFile.WriteValue("Launcher", "Lang", languageCode);
|
||||
|
||||
DialogResult result = MsgBoxForm.ShowYN(LocalizedStrings.ChangeLanguageMessage, LocalizedStrings.Confirmation);
|
||||
|
||||
if (result == DialogResult.Yes)
|
||||
string? selectedService = cbLauncherService.SelectedItem?.ToString();
|
||||
string serviceCode = GetServiceCode(selectedService);
|
||||
if (serviceCode != null)
|
||||
{
|
||||
Invoke((MethodInvoker)(() => Close()));
|
||||
Task.Delay(1000).ContinueWith(_ =>
|
||||
{
|
||||
Application.Restart();
|
||||
});
|
||||
// Update the service in the INI file
|
||||
Configuration.Default.Service = serviceCode;
|
||||
Configuration.Default.iniFile.WriteValue("Info", "Service", serviceCode);
|
||||
|
||||
UpdateServiceDatFile(serviceCode);
|
||||
}
|
||||
|
||||
string? selectedLanguage = cbLauncherLanguage.SelectedItem?.ToString();
|
||||
string languageCode = GetLanguageCode(selectedLanguage);
|
||||
|
||||
if (languageCode != null)
|
||||
{
|
||||
// Update the language in the INI file
|
||||
Configuration.Default.Lang = languageCode;
|
||||
Configuration.Default.iniFile.WriteValue("Launcher", "Lang", languageCode);
|
||||
|
||||
DialogResult result = MsgBoxForm.ShowYN(LocalizedStrings.ChangeLanguageMessage, LocalizedStrings.Confirmation);
|
||||
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
Invoke((MethodInvoker)(() => Close()));
|
||||
Task.Delay(1000).ContinueWith(_ =>
|
||||
{
|
||||
Application.Restart();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
catch (Exception ex)
|
||||
{
|
||||
Close();
|
||||
MessageBox.Show($"{LocalizedStrings.Error}: {ex.Message}", LocalizedStrings.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
|
|
@ -125,7 +125,7 @@
|
|||
AAEAAAD/////AQAAAAAAAAAMAgAAAEZTeXN0ZW0uV2luZG93cy5Gb3JtcywgQ3VsdHVyZT1uZXV0cmFs
|
||||
LCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAAAmU3lzdGVtLldpbmRvd3MuRm9ybXMu
|
||||
SW1hZ2VMaXN0U3RyZWFtZXIBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAA+jYAAAJNU0Z0AUkBTAIBAQMB
|
||||
AAHQAQEB0AEBARkBAAEZAQAE/wEhAQAI/wFCAU0BNgcAATYDAAEoAwABZAMAARkDAAEBAQABIAUAARAB
|
||||
AAHwAQEB8AEBARkBAAEZAQAE/wEhAQAI/wFCAU0BNgcAATYDAAEoAwABZAMAARkDAAEBAQABIAUAARAB
|
||||
JxIAARUCAAH/ARUCAAH/ARUCAAH/ARUCAAH/ARUCAAH/ARUCAAH/ARUCAAH/ARUCAAH/ARUCAAH/ARUC
|
||||
AAH/ARUCAAH/ARUCAAH/ARUCAAH/ARUCAAH/ARUCAAH/ARUCAAH/ARUCAAH/ARUCAAH/ARUCAAH/ARUC
|
||||
AAH/ARUCAAH/ARUCAAH/ARUCAAH/ARUCAAH/ARUCAAH/ARUCAAH/ARUCAAH/ARUCAAH/ARUCAAH/ARUC
|
||||
|
|
@ -370,7 +370,7 @@
|
|||
AAEAAAD/////AQAAAAAAAAAMAgAAAEZTeXN0ZW0uV2luZG93cy5Gb3JtcywgQ3VsdHVyZT1uZXV0cmFs
|
||||
LCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAAAmU3lzdGVtLldpbmRvd3MuRm9ybXMu
|
||||
SW1hZ2VMaXN0U3RyZWFtZXIBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAkGEBAAJNU0Z0AUkBTAIBAQMB
|
||||
AAHAAQIBwAECAWcBAAElAQAE/wEhAQAI/wFCAU0BNgcAATYDAAEoAwABnAEBAgABJQMAAQEBAAEgBQAB
|
||||
AAHgAQIB4AECAWcBAAElAQAE/wEhAQAI/wFCAU0BNgcAATYDAAEoAwABnAEBAgABJQMAAQEBAAEgBQAB
|
||||
MAHuEgABJwEHAQAB/wEnAQcBAAH/AScBBwEAAf8BJwEHAQAB/wEnAQcBAAH/AScBBwEAAf8BJwEHAQAB
|
||||
/wEnAQcBAAH/AScBBwEAAf8BJwEHAQAB/wEnAQcBAAH/AScBBwEAAf8BJwEHAQAB/wEnAQcBAAH/AScB
|
||||
BwEAAf8BJwEHAQAB/wEnAQcBAAH/AScBBwEAAf8BJwEHAQAB/wEnAQcBAAH/AScBBwEAAf8BJwEHAQAB
|
||||
|
|
@ -1889,7 +1889,7 @@
|
|||
AAEAAAD/////AQAAAAAAAAAMAgAAAEZTeXN0ZW0uV2luZG93cy5Gb3JtcywgQ3VsdHVyZT1uZXV0cmFs
|
||||
LCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAAAmU3lzdGVtLldpbmRvd3MuRm9ybXMu
|
||||
SW1hZ2VMaXN0U3RyZWFtZXIBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAZGYBAAJNU0Z0AUkBTAIBAQMB
|
||||
AAHIAQIByAECAWcBAAElAQAE/wEhAQAI/wFCAU0BNgcAATYDAAEoAwABnAEBAgABJQMAAQEBAAEgBQAB
|
||||
AAHoAQIB6AECAWcBAAElAQAE/wEhAQAI/wFCAU0BNgcAATYDAAEoAwABnAEBAgABJQMAAQEBAAEgBQAB
|
||||
MAHuEgABJwEHAQAB/wEnAQcBAAH/AScBBwEAAf8BJwEHAQAB/wEnAQcBAAH/AScBBwEAAf8BJwEHAQAB
|
||||
/wEnAQcBAAH/AScBBwEAAf8BJwEHAQAB/wEnAQcBAAH/AScBBwEAAf8BJwEHAQAB/wEnAQcBAAH/AScB
|
||||
BwEAAf8BJwEHAQAB/wEnAQcBAAH/AScBBwEAAf8BJwEHAQAB/wEnAQcBAAH/AScBBwEAAf8BJwEHAQAB
|
||||
|
|
@ -3427,7 +3427,7 @@
|
|||
<data name="$this.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAAoYAAAEQCAIAAACiPyLtAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
|
||||
EgAACxIB0t1+/AAAJ5dJREFUeF7t3d2zXOV5pnFVZTCCJJXAluJ4QmypW1Bjhw8JBoT4sqfmOJkgnNRk
|
||||
DgAACw4BQL7hQQAAJ5dJREFUeF7t3d2zXOV5pnFVZTCCJJXAluJ4QmypW1Bjhw8JBoT4sqfmOJkgnNRk
|
||||
bDAIpypnwY4NqTmfkyR/9KzevbV399a1Xt0XYffqg7vqKpX2T0sLzp5aq99Hfe1nH//77Tc++9Frn916
|
||||
7dOXfvKLv/zJP7w09eN/mH7zl3/1f3746qbpNxv/8b5P+NjP8NTPcHCTCQ95k0v/28Ob7P0Xv91NJjzk
|
||||
TSakm5zht73J3sW7N7n0v33VN5nwP3eTMwxvMuEhb3Lpf3t4k73/4re7yYSHvMmEdJMz/LY32bt49yaX
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ namespace RHLauncher
|
|||
public partial class LauncherForm : Form
|
||||
{
|
||||
private RegistryHandler registryHandler = new();
|
||||
public string? installDirectory;
|
||||
public string? tempInstallDirectory;
|
||||
private string? installDirectory;
|
||||
private string? tempInstallDirectory;
|
||||
private static readonly string DefaultIniFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.ini");
|
||||
private readonly IniFile _iniFile = new(DefaultIniFilePath);
|
||||
private readonly string _windyCode;
|
||||
|
|
@ -487,10 +487,6 @@ namespace RHLauncher
|
|||
}
|
||||
}
|
||||
|
||||
public class ServerStatusResponse
|
||||
{
|
||||
public string? Status { get; set; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Button Click Events
|
||||
|
|
@ -666,10 +662,6 @@ namespace RHLauncher
|
|||
{
|
||||
Process.Start("explorer.exe", installDirectory);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -861,9 +853,15 @@ namespace RHLauncher
|
|||
switch (service.ToLower())
|
||||
{
|
||||
case "usa":
|
||||
case "usa_beta":
|
||||
arguments = "server=" + Configuration.Default.GateXMLUrl;
|
||||
break;
|
||||
case "jpn":
|
||||
case "jpn_beta":
|
||||
arguments = $"-serverurl{Configuration.Default.GateInfoUrl}";
|
||||
break;
|
||||
case "chn":
|
||||
case "chn_beta":
|
||||
arguments = $"-serverurl{Configuration.Default.GateInfoUrl} id={_windyCode} password={_password}";
|
||||
break;
|
||||
default:
|
||||
|
|
@ -931,7 +929,7 @@ namespace RHLauncher
|
|||
{
|
||||
foreach (FileInfo file in directoryInfo.GetFiles())
|
||||
{
|
||||
if (file.Name.ToLower() != "launcher.exe" && file.Name.ToLower() != "config.ini")
|
||||
if (!file.Name.Equals("launcher.exe", StringComparison.CurrentCultureIgnoreCase) && !file.Name.Equals("config.ini", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
file.Delete();
|
||||
}
|
||||
|
|
@ -1056,8 +1054,8 @@ namespace RHLauncher
|
|||
|
||||
private static Image[] LoadImages()
|
||||
{
|
||||
return new Image[]
|
||||
{
|
||||
return
|
||||
[
|
||||
Properties.Resources.character_select_cut_angela,
|
||||
Properties.Resources.character_select_cut_edgar,
|
||||
Properties.Resources.character_select_cut_frantz,
|
||||
|
|
@ -1067,7 +1065,7 @@ namespace RHLauncher
|
|||
Properties.Resources.character_select_cut_natasha,
|
||||
Properties.Resources.character_select_cut_roselle,
|
||||
Properties.Resources.character_select_cut_tude
|
||||
};
|
||||
];
|
||||
}
|
||||
|
||||
private static void HidePanel(Panel panel)
|
||||
|
|
@ -1093,6 +1091,7 @@ namespace RHLauncher
|
|||
Exception newLogEx = new(errorLog, ex);
|
||||
ExceptionHandler.HandleException(newEx, newLogEx);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ namespace RHLauncher
|
|||
{
|
||||
private RegistryHandler registryHandler = new();
|
||||
|
||||
public string windyCode = string.Empty;
|
||||
public string password = string.Empty;
|
||||
public string LoginUrl = Configuration.Default.LoginUrl;
|
||||
public string Lang = Configuration.Default.Lang;
|
||||
private string windyCode = string.Empty;
|
||||
private string password = string.Empty;
|
||||
private readonly string LoginUrl = Configuration.Default.LoginUrl;
|
||||
private readonly string Lang = Configuration.Default.Lang;
|
||||
private List<Button>? buttons;
|
||||
private List<ImageList>? imageLists;
|
||||
private Dictionary<string, List<ImageList>>? languageImageLists;
|
||||
|
|
@ -42,8 +42,8 @@ namespace RHLauncher
|
|||
private void LoadLocalizedStrings()
|
||||
{
|
||||
// Initialize buttons and image lists
|
||||
buttons = new List<Button> { LoginButton, RegisterButton };
|
||||
imageLists = new List<ImageList> { imageListLogin, imageListRegister };
|
||||
buttons = [LoginButton, RegisterButton];
|
||||
imageLists = [imageListLogin, imageListRegister];
|
||||
|
||||
// Initialize language-specific image lists
|
||||
languageImageLists = new Dictionary<string, List<ImageList>>
|
||||
|
|
@ -171,12 +171,12 @@ namespace RHLauncher
|
|||
private async Task<string> SendLoginRequestAsync()
|
||||
{
|
||||
using HttpClient client = new();
|
||||
using HttpResponseMessage response = await client.PostAsync(LoginUrl, new FormUrlEncodedContent(new[]
|
||||
{
|
||||
using HttpResponseMessage response = await client.PostAsync(LoginUrl, new FormUrlEncodedContent(
|
||||
[
|
||||
new KeyValuePair<string, string>("account", UsernameTextBox.Text),
|
||||
new KeyValuePair<string, string>("password", PasswordTextBox.Text)
|
||||
}));
|
||||
|
||||
]));
|
||||
response.EnsureSuccessStatusCode();
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
|
|
@ -184,52 +184,63 @@ namespace RHLauncher
|
|||
{
|
||||
try
|
||||
{
|
||||
Dictionary<string, string>? loginResponse = JsonConvert.DeserializeObject<Dictionary<string, string>>(response);
|
||||
var loginResponse = JsonConvert.DeserializeObject<LoginResponse>(response);
|
||||
|
||||
if (loginResponse != null)
|
||||
if (loginResponse == null)
|
||||
{
|
||||
if (loginResponse.TryGetValue("Result", out var result))
|
||||
{
|
||||
switch (result)
|
||||
MsgBoxForm.Show(LocalizedStrings.Error + $": {LocalizedStrings.HttpResponseNull}", LocalizedStrings.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (loginResponse.Result)
|
||||
{
|
||||
case "LoginSuccess":
|
||||
if (!string.IsNullOrEmpty(loginResponse.WindyCode) && !string.IsNullOrEmpty(loginResponse.Token))
|
||||
{
|
||||
case "LoginSuccess":
|
||||
windyCode = loginResponse["WindyCode"];
|
||||
password = loginResponse["Token"];
|
||||
progressBarLogin.Visible = false;
|
||||
Hide();
|
||||
notifyIcon.Visible = false;
|
||||
LauncherForm launcherForm = new(windyCode, password);
|
||||
launcherForm.ShowDialog();
|
||||
break;
|
||||
case "InvalidCredentials":
|
||||
MsgBoxForm.Show(LocalizedStrings.LoginInvalidCredentials, LocalizedStrings.LoginInfoTitle);
|
||||
break;
|
||||
case "InvalidUsernameFormat":
|
||||
MsgBoxForm.Show(LocalizedStrings.LoginInvalidUsernameFormat, LocalizedStrings.LoginInfoTitle);
|
||||
break;
|
||||
case "AccountNotFound":
|
||||
MsgBoxForm.Show(LocalizedStrings.LoginInvalidCredentials, LocalizedStrings.LoginInfoTitle);
|
||||
break;
|
||||
case "Locked":
|
||||
MsgBoxForm.Show(LocalizedStrings.LoginLocked, LocalizedStrings.LoginInfoTitle);
|
||||
break;
|
||||
case "TooManyAttempts":
|
||||
MsgBoxForm.Show(LocalizedStrings.LoginTooManyAttempts, LocalizedStrings.LoginInfoTitle);
|
||||
break;
|
||||
default:
|
||||
MsgBoxForm.Show(LocalizedStrings.Error + result, LocalizedStrings.Error);
|
||||
break;
|
||||
windyCode = loginResponse.WindyCode;
|
||||
password = loginResponse.Token;
|
||||
progressBarLogin.Visible = false;
|
||||
Hide();
|
||||
notifyIcon.Visible = false;
|
||||
LauncherForm launcherForm = new(windyCode, password);
|
||||
launcherForm.ShowDialog();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MsgBoxForm.Show(LocalizedStrings.Error + "Response does not contain a Result field.", LocalizedStrings.Error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MsgBoxForm.Show(LocalizedStrings.Error + "Failed to deserialize the response.", LocalizedStrings.Error);
|
||||
else
|
||||
{
|
||||
MsgBoxForm.Show(LocalizedStrings.Error + " Missing token or windyCode.", LocalizedStrings.Error);
|
||||
}
|
||||
break;
|
||||
|
||||
case "InvalidCredentials":
|
||||
case "AccountNotFound":
|
||||
MsgBoxForm.Show(LocalizedStrings.LoginInvalidCredentials, LocalizedStrings.LoginInfoTitle);
|
||||
break;
|
||||
|
||||
case "Locked":
|
||||
MsgBoxForm.Show(LocalizedStrings.LoginLocked, LocalizedStrings.LoginInfoTitle);
|
||||
break;
|
||||
|
||||
case "TooManyAttempts":
|
||||
MsgBoxForm.Show(LocalizedStrings.LoginTooManyAttempts, LocalizedStrings.LoginInfoTitle);
|
||||
break;
|
||||
|
||||
case "InvalidRequest":
|
||||
case "ServerError":
|
||||
if (!string.IsNullOrEmpty(loginResponse.Message))
|
||||
{
|
||||
MsgBoxForm.Show(loginResponse.Message, LocalizedStrings.Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
MsgBoxForm.Show(LocalizedStrings.Error + ": " + loginResponse.Result, LocalizedStrings.Error);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
MsgBoxForm.Show(LocalizedStrings.Error + ": " + loginResponse.Result, LocalizedStrings.Error);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using RHLauncher.RHLauncher.Helper;
|
||||
using Newtonsoft.Json;
|
||||
using RHLauncher.RHLauncher.Helper;
|
||||
using RHLauncher.RHLauncher.i8n;
|
||||
using System.Diagnostics;
|
||||
using System.Text.RegularExpressions;
|
||||
|
|
@ -7,11 +8,11 @@ namespace RHLauncher
|
|||
{
|
||||
public partial class RegisterForm : Form
|
||||
{
|
||||
public string SendCodeUrl = Configuration.Default.SendCodeUrl;
|
||||
public string AgreementUrl = Configuration.Default.AgreementUrl;
|
||||
public string VerifyCodeUrl = Configuration.Default.VerifyCodeUrl;
|
||||
public string RegisterUrl = Configuration.Default.RegisterUrl;
|
||||
public string Lang = Configuration.Default.Lang;
|
||||
private readonly string SendCodeUrl = Configuration.Default.SendCodeUrl;
|
||||
private readonly string AgreementUrl = Configuration.Default.AgreementUrl;
|
||||
private readonly string VerifyCodeUrl = Configuration.Default.VerifyCodeUrl;
|
||||
private readonly string RegisterUrl = Configuration.Default.RegisterUrl;
|
||||
private readonly string Lang = Configuration.Default.Lang;
|
||||
private List<Button>? buttons;
|
||||
private List<ImageList>? imageLists;
|
||||
private Dictionary<string, List<ImageList>>? languageImageLists;
|
||||
|
|
@ -55,16 +56,16 @@ namespace RHLauncher
|
|||
private void LoadLocalizedStrings()
|
||||
{
|
||||
// Initialize buttons and image lists
|
||||
buttons = new List<Button> { ContinueButtonS1, SendEmailButton, ContinueButtonS2 };
|
||||
imageLists = new List<ImageList> { imageListContinueBtn, imageListSendEmailBtn, imageListContinueBtn };
|
||||
buttons = [ContinueButtonS1, SendEmailButton, ContinueButtonS2];
|
||||
imageLists = [imageListContinueBtn, imageListSendEmailBtn, imageListContinueBtn];
|
||||
|
||||
// Initialize language-specific image lists
|
||||
languageImageLists = new Dictionary<string, List<ImageList>>
|
||||
{
|
||||
{ "en", new List<ImageList> { imageListContinueBtn, imageListSendEmailBtn, imageListContinueBtn } }, // English image lists
|
||||
{ "ko", new List<ImageList> { imageListContinueBtn_ko, imageListSendEmailBtn_ko, imageListContinueBtn_ko } }, // Korean image lists
|
||||
// Add other languages and their respective image lists here
|
||||
};
|
||||
{
|
||||
{ "en", new List<ImageList> { imageListContinueBtn, imageListSendEmailBtn, imageListContinueBtn } }, // English image lists
|
||||
{ "ko", new List<ImageList> { imageListContinueBtn_ko, imageListSendEmailBtn_ko, imageListContinueBtn_ko } }, // Korean image lists
|
||||
// Add other languages and their respective image lists here
|
||||
};
|
||||
|
||||
// Load the appropriate resource file based on the selected language
|
||||
LocalizationHelper.LoadLocalizedStrings(Lang, buttons, imageLists, languageImageLists);
|
||||
|
|
@ -88,18 +89,26 @@ namespace RHLauncher
|
|||
private async Task<string> SendEmailRequestAsync()
|
||||
{
|
||||
using HttpClient client = new();
|
||||
using HttpResponseMessage response = await client.PostAsync(SendCodeUrl, new FormUrlEncodedContent(new[]
|
||||
{
|
||||
using HttpResponseMessage response = await client.PostAsync(SendCodeUrl, new FormUrlEncodedContent(
|
||||
[
|
||||
new KeyValuePair<string, string>("email", EmailTextBox.Text),
|
||||
|
||||
}));
|
||||
|
||||
]));
|
||||
response.EnsureSuccessStatusCode();
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
private void HandleSendEmailResponse(string response)
|
||||
{
|
||||
switch (response)
|
||||
HttpResponse? httpResponse = JsonConvert.DeserializeObject<HttpResponse>(response);
|
||||
|
||||
if (httpResponse == null)
|
||||
{
|
||||
MsgBoxForm.Show(LocalizedStrings.Error + $": {LocalizedStrings.HttpResponseNull}", LocalizedStrings.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (httpResponse.Result)
|
||||
{
|
||||
case "EmailSent":
|
||||
SendEmailButton.Enabled = false;
|
||||
|
|
@ -107,6 +116,7 @@ namespace RHLauncher
|
|||
break;
|
||||
case "AccountExists":
|
||||
MsgBoxForm.Show(LocalizedStrings.AccountEmailExists, LocalizedStrings.Info);
|
||||
ResetSendEmailButton();
|
||||
break;
|
||||
case "ValidVerificationCode":
|
||||
// Hide the first panel and show the second panel
|
||||
|
|
@ -141,51 +151,65 @@ namespace RHLauncher
|
|||
// If the timer has finished counting down, stop the timer and enable the ResendEmailButton
|
||||
if (secondsLeft == 0)
|
||||
{
|
||||
resendTimer.Stop();
|
||||
SendEmailButton.Enabled = true;
|
||||
TimerLabel.Text = "";
|
||||
ResetSendEmailButton();
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetSendEmailButton()
|
||||
{
|
||||
resendTimer.Stop();
|
||||
SendEmailButton.Enabled = true;
|
||||
TimerLabel.Text = "";
|
||||
}
|
||||
|
||||
private async Task<string> VerifyCodeSendRequestAsync()
|
||||
{
|
||||
using HttpClient client = new();
|
||||
using HttpResponseMessage response = await client.PostAsync(VerifyCodeUrl, new FormUrlEncodedContent(new[]
|
||||
{
|
||||
using HttpResponseMessage response = await client.PostAsync(VerifyCodeUrl, new FormUrlEncodedContent(
|
||||
[
|
||||
new KeyValuePair<string, string>("email", EmailTextBox.Text),
|
||||
new KeyValuePair<string, string>("verification_code", CodeTextBox.Text),
|
||||
new KeyValuePair<string, string>("verification_code_type", "Account"),
|
||||
|
||||
}));
|
||||
new KeyValuePair<string, string>("verificationCode", CodeTextBox.Text),
|
||||
new KeyValuePair<string, string>("verificationCodeType", "Account"),
|
||||
|
||||
]));
|
||||
response.EnsureSuccessStatusCode();
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
private async Task<string> SendRequestAsync()
|
||||
{
|
||||
using HttpClient client = new();
|
||||
using HttpResponseMessage response = await client.PostAsync(RegisterUrl, new FormUrlEncodedContent(new[]
|
||||
{
|
||||
new KeyValuePair<string, string>("windyCode", UsernameTextBox.Text),
|
||||
using HttpResponseMessage response = await client.PostAsync(RegisterUrl, new FormUrlEncodedContent(
|
||||
[
|
||||
new KeyValuePair<string, string>("username", UsernameTextBox.Text),
|
||||
new KeyValuePair<string, string>("email", EmailTextBox.Text),
|
||||
new KeyValuePair<string, string>("password", PasswordTextBox.Text)
|
||||
}));
|
||||
|
||||
new KeyValuePair<string, string>("password", PasswordTextBox.Text),
|
||||
new KeyValuePair<string, string>("verificationCode", CodeTextBox.Text)
|
||||
]));
|
||||
response.EnsureSuccessStatusCode();
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
private void HandleResponse(string response)
|
||||
{
|
||||
switch (response)
|
||||
HttpResponse? accounResponse = JsonConvert.DeserializeObject<HttpResponse>(response);
|
||||
|
||||
if (accounResponse == null)
|
||||
{
|
||||
case "Success":
|
||||
MsgBoxForm.Show(LocalizedStrings.Error + $": {LocalizedStrings.HttpResponseNull}", LocalizedStrings.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (accounResponse.Result)
|
||||
{
|
||||
case "AccountCreated":
|
||||
MsgBoxForm.Show(LocalizedStrings.AccountCreateSuccess, LocalizedStrings.RegisterWindow);
|
||||
Close();
|
||||
break;
|
||||
case "AccountExists":
|
||||
MsgBoxForm.Show(LocalizedStrings.AccountExists, LocalizedStrings.Info);
|
||||
case "EmailExists":
|
||||
MsgBoxForm.Show(LocalizedStrings.AccountEmailExists, LocalizedStrings.Info);
|
||||
break;
|
||||
case "WindyCodeExists":
|
||||
case "UsernameExists":
|
||||
MsgBoxForm.Show(LocalizedStrings.WindyCodeExists, LocalizedStrings.Error);
|
||||
break;
|
||||
case "InvalidUserNameFormat":
|
||||
|
|
@ -195,7 +219,7 @@ namespace RHLauncher
|
|||
MsgBoxForm.Show(LocalizedStrings.InvalidEmailFormat, LocalizedStrings.Error);
|
||||
break;
|
||||
default:
|
||||
MsgBoxForm.Show($"{LocalizedStrings.Error}: {response}", LocalizedStrings.Error);
|
||||
MsgBoxForm.Show($"{LocalizedStrings.Error}: " + accounResponse.Message, LocalizedStrings.Error);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -375,7 +399,7 @@ namespace RHLauncher
|
|||
string password = PasswordTextBox.Text;
|
||||
|
||||
// Check for minimum length and maximum length
|
||||
if (password.Length < 6 || password.Length > 16)
|
||||
if (password.Length < 8 || password.Length > 16)
|
||||
{
|
||||
PwdDescLabel.Text = LocalizedStrings.PwdDescLabelSize;
|
||||
PwdDescLabel.ForeColor = Color.Red;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue