Skip to content

Commit

Permalink
Rework MessageBox to have a Window Handle
Browse files Browse the repository at this point in the history
Fixed:
- MessageBox should no longer appear behind the main form.
-- May work on Unix, debugging required

Added:
- Added missing support for Account Manager
  • Loading branch information
DavidCarbon committed Jun 23, 2024
1 parent df906fc commit c2e9aff
Show file tree
Hide file tree
Showing 50 changed files with 1,794 additions and 931 deletions.
8 changes: 4 additions & 4 deletions SBRW.Concepts/Form2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private void Button_Add_Click(object sender, EventArgs e)

if (!New_Credential.Save())
{
MessageBox.Show($"Failed to save credential for SBRW.Concepts.{Auto_ID}");
$"Failed to save credential for SBRW.Concepts.{Auto_ID}".Message_Box();
}
else
{
Expand All @@ -139,7 +139,7 @@ private void Button_Add_Click(object sender, EventArgs e)
}
else
{
MessageBox.Show("Enter Account Info");
"Enter Account Info".Message_Box();
}
}

Expand All @@ -156,7 +156,7 @@ private void button_Delete_Click(object sender, EventArgs e)

if (!new Credential() { Target = Account_Information.Target }.Delete())
{
MessageBox.Show($"Failed to Remove credential: SBRW.Concepts.{Account_Information.Target}");
$"Failed to Remove credential: SBRW.Concepts.{Account_Information.Target}".Message_Box();
}
else
{
Expand Down Expand Up @@ -196,7 +196,7 @@ private void button_Update_Click(object sender, EventArgs e)

if (!Updated_Credential.Save())
{
MessageBox.Show($"Failed to Update credential: SBRW.Concepts.{Account_Information.Target}");
$"Failed to Update credential: SBRW.Concepts.{Account_Information.Target}".Message_Box();
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ private void PatchNotes_Shown(object sender, EventArgs e)
catch
{
PatchContainerPanel.Visible = false;
MessageBox.Show("The launcher was unable to retrieve 'About' info from the server!");
"The launcher was unable to retrieve 'About' info from the server!".Message_Box();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,21 @@ private void Button_Update_Click(object sender, EventArgs e)
{
bool Update_Info_Tag = false;

if (!TextBox_Password.Text.Encrypt_AES().Equals(Accounts_Cache[Account_Index.Item_Index].Password))
if (!(TextBox_Password.Text.Encrypt_AES() == Accounts_Cache[Account_Index.Item_Index].Password))
{
Accounts_Cache[Account_Index.Item_Index].Password = TextBox_Password.Text.Encrypt_AES();
Update_Info_Tag = true;
}

if (!TextBox_Email.Text.Encrypt_AES().Equals(Accounts_Cache[Account_Index.Item_Index].Email))
if (!(TextBox_Email.Text.Encrypt_AES() == Accounts_Cache[Account_Index.Item_Index].Email))
{
Accounts_Cache[Account_Index.Item_Index].Email = TextBox_Email.Text.Encrypt_AES();
Update_Info_Tag = true;
}

if (!TextBox_Nickname.Text.Equals(Accounts_Cache[Account_Index.Item_Index].Nickname))
if (!(TextBox_Nickname.Text == Accounts_Cache[Account_Index.Item_Index].Nickname))
{
if (!Accounts_Cache.Any(Nickname_Exists => Nickname_Exists.Nickname == TextBox_Nickname.Text))
if (!Accounts_Cache.Any(Accounts_Cache_DB => Accounts_Cache_DB.Nickname == TextBox_Nickname.Text))
{
Accounts_Cache[Account_Index.Item_Index].Nickname = TextBox_Nickname.Text;
Update_Info_Tag = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using SBRW.Launcher.Core.Reference.Json_.Newtonsoft_;
using SBRW.Launcher.RunTime.LauncherCore.Global;
using SBRW.Launcher.RunTime.LauncherCore.Logger;
using SBRW.Launcher.RunTime.LauncherCore.Support;
using System;
using System.ComponentModel;
using System.IO;
Expand Down Expand Up @@ -85,26 +86,20 @@ public static void Credentials_Load()
Accounts_Cache.Add(Queried_Account);
}

if (Screen_Instance != default)
if (!Screen_Instance.DisposedForm())
{
if (Screen_Instance.DataGridView_Account_List.Visible)
{
Screen_Instance.DataGridView_Account_List.DataSource = Accounts_Cache;
Screen_Instance.DataGridView_Account_List.Refresh();
Screen_Instance.DataGridView_Account_List.ClearSelection();
}
Screen_Instance.DataGridView_Account_List.DataSource = Accounts_Cache;
Screen_Instance.DataGridView_Account_List.Refresh();
Screen_Instance.DataGridView_Account_List.ClearSelection();
}

if (Screen_Main.Screen_Instance != default)
if (!Screen_Main.Screen_Instance.DisposedForm())
{
if (Screen_Main.Screen_Instance.ComboBox_Accounts.Visible)
{
/* Accounts Display List */
Screen_Main.Screen_Instance.ComboBox_Accounts.DisplayMember = "Nickname";
Log.Core("LAUNCHER: Setting Account list");
Screen_Main.Screen_Instance.ComboBox_Accounts.DataSource = Accounts_Cache;
Screen_Main.Screen_Instance.ComboBox_Accounts.Refresh();
}
/* Accounts Display List */
Screen_Main.Screen_Instance.ComboBox_Accounts.DisplayMember = "Nickname";
Log.Core("LAUNCHER: Setting Account list");
Screen_Main.Screen_Instance.ComboBox_Accounts.DataSource = Accounts_Cache;
Screen_Main.Screen_Instance.ComboBox_Accounts.Refresh();
}
}
catch (Exception Error)
Expand Down
29 changes: 15 additions & 14 deletions SBRW.Launcher.Net/App/UI_Forms/CDN_Screen/Screen_CDN_Selection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,16 +370,16 @@ private void SelectedGameServerToRemember()
switch (Screen_Mode_Update)
{
case 1:
MessageBox.Show(Screen_Welcome.Screen_Instance, "Selected CDN does not have a Valid URL. Please Choose Another CDN.",
"GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Information);
("Selected CDN does not have a Valid URL. " +
"Please Choose Another CDN.").Message_Box(MessageBoxButtons.OK, MessageBoxIcon.Information);
break;
case 2:
MessageBox.Show(Screen_Settings.Screen_Instance, "Selected CDN does not have a Valid URL. Please Choose Another CDN.",
"GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Information);
("Selected CDN does not have a Valid URL. " +
"Please Choose Another CDN.").Message_Box(MessageBoxButtons.OK, MessageBoxIcon.Information);
break;
default:
MessageBox.Show(null, "Selected CDN does not have a Valid URL. Please Choose Another CDN.",
"GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Information);
("Selected CDN does not have a Valid URL. " +
"Please Choose Another CDN.").Message_Box(MessageBoxButtons.OK, MessageBoxIcon.Information);
break;
}
}
Expand Down Expand Up @@ -414,16 +414,16 @@ private void SelectedGameServerToRemember()
switch (Screen_Mode_Update)
{
case 1:
MessageBox.Show(Screen_Welcome.Screen_Instance, "Selected CDN does not have a Valid URL. Please Choose Another CDN.",
"GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Information);
("Selected CDN does not have a Valid URL. " +
"Please Choose Another CDN.").Message_Box(MessageBoxButtons.OK, MessageBoxIcon.Information);
break;
case 2:
MessageBox.Show(Screen_Settings.Screen_Instance, "Selected CDN does not have a Valid URL. Please Choose Another CDN.",
"GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Information);
("Selected CDN does not have a Valid URL. " +
"Please Choose Another CDN.").Message_Box(MessageBoxButtons.OK, MessageBoxIcon.Information);
break;
default:
MessageBox.Show(null, "Selected CDN does not have a Valid URL. Please Choose Another CDN.",
"GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Information);
("Selected CDN does not have a Valid URL. " +
"Please Choose Another CDN.").Message_Box(MessageBoxButtons.OK, MessageBoxIcon.Information);
break;
}
}
Expand All @@ -438,8 +438,9 @@ private void SelectedGameServerToRemove()
{
if (ServerListUpdater.NoCategoryList_CSO.Count > 0)
{
if (MessageBox.Show(null, "Confirm to Remove " + ServerListBook[ListView_Server_List.SelectedIndices[0] + 1].Name + " from Saved Custom Servers",
"GameLauncher", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
if (("Confirm to Remove " +
ServerListBook[ListView_Server_List.SelectedIndices[0] + 1].Name +
" from Saved Custom Servers").Message_Box(MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
{
ServerListUpdater.NoCategoryList_CSO.RemoveAt(ListView_Server_List.SelectedIndices[0]);
ListView_Server_List.Items.Remove(ListView_Server_List.SelectedItems[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ await Task.Run(() =>

File.WriteAllText(Locations.LauncherCustomServers, JsonConvert.SerializeObject(Servers));

MessageBox.Show(null, "The New server will be added on the next start of the Launcher.", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Information);
"The New server will be added on the next start of the Launcher.".Message_Box(MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception Error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,7 @@ private void Button_Server_Select_Click(object sender, EventArgs e)
}
else
{
MessageBox.Show(null, "Click on a Server to Remove it from Your Custom Saved List",
"GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Information);
("Click on a Server to Remove it from Your Custom Saved List").Message_Box(MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}

Expand All @@ -456,8 +455,7 @@ private void Button_Server_Remove_Click(object sender, EventArgs e)
}
else
{
MessageBox.Show(null, "This feature will Unlocked After This Screen",
"GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Information);
"This feature will Unlocked After This Screen".Message_Box(MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}

Expand All @@ -483,8 +481,9 @@ private void SelectedGameServerToRemove()
{
if (ServerListUpdater.NoCategoryList_CSO.Count > 0)
{
if (MessageBox.Show(null, "Confirm to Remove " + ServerListBook[ListView_Server_List.SelectedIndices[0] + 1].Name + " from Saved Custom Servers",
"GameLauncher", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
if (("Confirm to Remove " +
ServerListBook[ListView_Server_List.SelectedIndices[0] + 1].Name +
" from Saved Custom Servers").Message_Box(MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
{
ServerListUpdater.NoCategoryList_CSO.RemoveAt(ListView_Server_List.SelectedIndices[0]);
ListView_Server_List.Items.Remove(ListView_Server_List.SelectedItems[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ private void OnDownloadFailed(Exception Error)
}

string LogMessage = "CDN Downloader Encountered an Error:";
LogToFileAddons.OpenLog("Game Download", LogMessage, Error, "Error", false, Screen_Instance);
LogToFileAddons.OpenLog("Game Download", LogMessage, Error, "Error", false);

if (!string.IsNullOrWhiteSpace(TempEmailCache))
{
Expand Down Expand Up @@ -502,8 +502,8 @@ private void Game_Pack_Downloader()
long Game_Folder_Size = File_and_Folder_Extention.GetDirectorySize_GameFiles(new DirectoryInfo(Save_Settings.Live_Data.Game_Path));
/* TODO: Check for other files and Folder Size */
if ((Game_Folder_Size == -1) &&
(MessageBox.Show(this, "Seems like we are unable to determine the Games Folder Size" +
"\nDo you have the Game Files Already Downloaded?", "GameLauncher", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes))
(("Seems like we are unable to determine the Games Folder Size" +
"\nDo you have the Game Files Already Downloaded?").Message_Box(MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes))
{
Game_Folder_Size = 3296810469;
}
Expand Down Expand Up @@ -612,7 +612,7 @@ private void Game_Pack_Downloader()
break;
}

DialogResult User_Prompt_Box = MessageBox.Show(this, Status_Code_Explaination, "GameLauncher",
DialogResult User_Prompt_Box = Status_Code_Explaination.Message_Box(
Allow_Restart ? MessageBoxButtons.RetryCancel : MessageBoxButtons.OK, MessageBoxIcon.Warning);
if (User_Prompt_Box == DialogResult.Retry)
{
Expand Down Expand Up @@ -654,9 +654,9 @@ private void Game_Pack_Downloader()
break;
case APIStatus.Forbidden:
case APIStatus.NotFound:
if (MessageBox.Show(Screen_Instance, "Game Archive is Not Present on Current Saved CDN." +
if (("Game Archive is Not Present on Current Saved CDN." +
"\nWould you like to check for LZMA Support? This would switch to the old LZMA Downloader." +
"\nOtherwise, please switch to another CDN.", "GameLauncher",
"\nOtherwise, please switch to another CDN.").Message_Box(
MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning) == DialogResult.Retry)
{
switch (API_Core.StatusCheck(Save_Settings.Live_Data.Launcher_CDN + "/en/index.xml", 10))
Expand Down
Loading

0 comments on commit c2e9aff

Please sign in to comment.