Skip to content

Commit

Permalink
[HaCreator] prevent Initialisation button from being clicked twice co…
Browse files Browse the repository at this point in the history
…nsecutively while loading
  • Loading branch information
lastbattle committed Jun 11, 2024
1 parent 6ef359d commit acda3b6
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions HaCreator/GUI/Initialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,35 +55,42 @@ private bool IsPathCommon(string path)
return false;
}

private bool _bIsInitialising = false;
/// <summary>
/// Initialise
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button_initialise_Click(object sender, EventArgs e)
{
ApplicationSettings.MapleVersionIndex = versionBox.SelectedIndex;
ApplicationSettings.MapleFolderIndex = pathBox.SelectedIndex;
string wzPath = pathBox.Text;

if (wzPath == "Select MapleStory Folder")
{
MessageBox.Show("Please select the MapleStory folder.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
if (_bIsInitialising) {
return;
}
if (!ApplicationSettings.MapleFoldersList.Contains(wzPath) && !IsPathCommon(wzPath))
{
ApplicationSettings.MapleFoldersList = ApplicationSettings.MapleFoldersList == "" ? wzPath : (ApplicationSettings.MapleFoldersList + "," + wzPath);
}
WzMapleVersion fileVersion = (WzMapleVersion)versionBox.SelectedIndex;
if (InitializeWzFiles(wzPath, fileVersion))
{
Hide();
Application.DoEvents();
editor = new HaEditor();
editor.ShowDialog();
_bIsInitialising = true;

Application.Exit();
try {
ApplicationSettings.MapleVersionIndex = versionBox.SelectedIndex;
ApplicationSettings.MapleFolderIndex = pathBox.SelectedIndex;
string wzPath = pathBox.Text;

if (wzPath == "Select MapleStory Folder") {
MessageBox.Show("Please select the MapleStory folder.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (!ApplicationSettings.MapleFoldersList.Contains(wzPath) && !IsPathCommon(wzPath)) {
ApplicationSettings.MapleFoldersList = ApplicationSettings.MapleFoldersList == "" ? wzPath : (ApplicationSettings.MapleFoldersList + "," + wzPath);
}
WzMapleVersion fileVersion = (WzMapleVersion)versionBox.SelectedIndex;
if (InitializeWzFiles(wzPath, fileVersion)) {
Hide();
Application.DoEvents();
editor = new HaEditor();
editor.ShowDialog();

Application.Exit();
}
} finally {
_bIsInitialising = false;
}
}

Expand Down

0 comments on commit acda3b6

Please sign in to comment.