Skip to content

Commit

Permalink
Optimize showing forms
Browse files Browse the repository at this point in the history
- Each forms will be only open 1 instance.
- Save size of add new game dropping form
- Show only installed games or all games
- Changed to include language resources in one exec binary
  • Loading branch information
anon5r committed Dec 25, 2021
1 parent 8a019a7 commit 3967fec
Show file tree
Hide file tree
Showing 18 changed files with 257 additions and 96 deletions.
6 changes: 6 additions & 0 deletions KsGameLauncher/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@
<setting name="AppInfo_selector_default" serializeAs="String">
<value>#login&gt;div&gt;a.link-btn</value>
</setting>
<setting name="ShowOnlyInstalledGames" serializeAs="String">
<value>True</value>
</setting>
<setting name="NewGameFormSize" serializeAs="String">
<value>400, 300</value>
</setting>
</KsGameLauncher.Properties.Settings>
<KonaStaGameLauncher.Properties.Settings>
<setting name="appInfoURL" serializeAs="String">
Expand Down
2 changes: 1 addition & 1 deletion KsGameLauncher/Forms/AboutForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private void About_Load(object sender, EventArgs e)
label_Version.Text = "ver. " + Application.ProductVersion;
label_Develop.Text = Resources.LabelDeveloper;
AppDeveloper.Text = Properties.Resources.Developers;
textBox_SpecialThanks.Text =
textBox_SpecialThanks.Text =
//string.Format("AppIcon: {0}", Properties.Resources.AppIconDesigner) +
Properties.Resources.SpecialThanks;
linkLabel_Support.Text = Properties.Resources.SupportLabelText;
Expand Down
65 changes: 45 additions & 20 deletions KsGameLauncher/Forms/AccountForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,36 +35,49 @@ private void AccountForm_Load(object sender, EventArgs e)
button_Remove.Enabled = false;
if (!RefreshRegisteredAccounts())
{
// There are no account registered
// Display credential input prompt
bool save = true;
credential = CredentialManager.PromptForCredentials(CredentialName, ref save,
Resources.EnterYourAccountPasswordPrompt, Resources.AppName, "");
if (credential != null)
try
{

// There are no account registered
// Display credential input prompt
bool save = true;
credential = CredentialManager.PromptForCredentials(CredentialName, ref save,
Resources.EnterYourAccountPasswordPrompt, Resources.AppName, "");
if (credential != null)
{
credential.Domain = Properties.Resources.AuthorizeDomain;
CredentialManager.SaveCredentials(CredentialName, credential);
}

}
catch (ArgumentNullException)
{
credential.Domain = Properties.Resources.AuthorizeDomain;
CredentialManager.SaveCredentials(CredentialName, credential);
}
RefreshRegisteredAccounts();
}
}

async private void Button_Remove_Click(object sender, EventArgs e)
private async void Button_Remove_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show(Resources.ConfirmToRemoveAccountFromList, Resources.ConfirmToRemove, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
DialogResult result = MessageBox.Show(Resources.ConfirmToRemoveAccountFromList, Resources.ConfirmToRemove,
MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
if (result == DialogResult.Yes)
{
try
{
if (CredentialManager.RemoveCredentials(CredentialName))
{
await Launcher.Logout();
credential = CredentialManager.GetCredentials(CredentialName);
RefreshRegisteredAccounts();
MessageBox.Show(Resources.AccountRemoveSucceeded);
}
else
{
result = MessageBox.Show(Resources.AccountRemoveFailed, Resources.AppName, MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
result = MessageBox.Show(Resources.AccountRemoveFailed, Resources.AppName,
MessageBoxButtons.RetryCancel, MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
if (result == DialogResult.Retry)
{
Utils.Common.OpenControlPanel("keymgr.dll,KRShowKeyMgr");
Expand All @@ -73,7 +86,9 @@ async private void Button_Remove_Click(object sender, EventArgs e)
}
catch (CredentialAPIException)
{
result = MessageBox.Show(Resources.AccountRemoveFailed, Resources.AppName, MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
result = MessageBox.Show(Resources.AccountRemoveFailed, Resources.AppName,
MessageBoxButtons.RetryCancel, MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
if (result == DialogResult.Retry)
{
Utils.Common.OpenControlPanel("keymgr.dll,KRShowKeyMgr");
Expand All @@ -82,22 +97,32 @@ async private void Button_Remove_Click(object sender, EventArgs e)
}
}

private void Button_Update_Click(object sender, EventArgs e)
private async void Button_Update_Click(object sender, EventArgs e)
{
bool save = true;
string defaultUserName = "";
if (credential != null)
defaultUserName = credential.UserName;

credential = CredentialManager.PromptForCredentials(CredentialName, ref save, Resources.EnterYourAccountPasswordPrompt, Resources.AppName, defaultUserName);
if (credential != null)
try
{
credential.Domain = Properties.Resources.AuthorizeDomain;
CredentialManager.SaveCredentials(CredentialName, credential);

credential = CredentialManager.PromptForCredentials(CredentialName, ref save,
Resources.EnterYourAccountPasswordPrompt, Resources.AppName, defaultUserName);
if (credential != null)
{
credential.Domain = Properties.Resources.AuthorizeDomain;
CredentialManager.SaveCredentials(CredentialName, credential);
}

if (save)
{
await Launcher.Logout();
RefreshRegisteredAccounts();
}
}
if (save)
catch (ArgumentNullException)
{
RefreshRegisteredAccounts();

}
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
using System.IO;
using System.Windows.Forms;

namespace KsGameLauncher.Forms
namespace KsGameLauncher
{
public partial class AddNewGame : Form
public partial class AddNewGameForm : Form
{
public AddNewGame()
public AddNewGameForm()
{
InitializeComponent();
}
Expand Down Expand Up @@ -66,14 +66,14 @@ private void AddNewGame_DragDrop(object sender, DragEventArgs e)
if (AppInfo.ContainID(appInfo.ID))
{
MessageBox.Show(string.Format(Resources.AlreadyGameExists, appInfo.Name), Resources.AppName,
MessageBoxButtons.OK,
MessageBoxIcon.Error);
MessageBoxButtons.OK, MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
return;
}

var result = MessageBox.Show(String.Format(Resources.ConfirmAddNewGame, appInfo.Name),
Resources.AppName, MessageBoxButtons.YesNo,
MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
Resources.AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button2, MessageBoxOptions.DefaultDesktopOnly);
if (result == DialogResult.Yes)
{
// TODO AppInfoリストに追加し、JSON化して保存する
Expand All @@ -88,7 +88,9 @@ private void AddNewGame_DragDrop(object sender, DragEventArgs e)
}
catch (FileFormatException ex)
{
MessageBox.Show(ex.Message, Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(ex.Message, Resources.AppName,
MessageBoxButtons.OK, MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
}

// Save loaded games to local file
Expand All @@ -113,6 +115,13 @@ private void AddNewGame_Load(object sender, EventArgs e)
Icon = Properties.Resources.app;
Text = Resources.AddNewGameWindowTitle;
groupBox_DragHere.Text = Resources.DropHere;
Size = Properties.Settings.Default.NewGameFormSize;
}

private void AddNewGameForm_FormClosed(object sender, FormClosedEventArgs e)
{
Properties.Settings.Default.NewGameFormSize = Size;
Properties.Settings.Default.Save();
}
}
}
File renamed without changes.
1 change: 0 additions & 1 deletion KsGameLauncher/Forms/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3967fec

Please sign in to comment.