Skip to content

Commit

Permalink
Version 1.5.4
Browse files Browse the repository at this point in the history
Fixed issue 86Box#61
Reworked the settings code a bit again to fix issue 86Box#62
Change the error dialog for VM configure when 86Box.exe can't be found from issue 86Box#60
Resetting the settings to default values no longer automatically saves them
  • Loading branch information
daviunic committed Aug 24, 2019
1 parent 5bb4b20 commit f40a50f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 14 deletions.
4 changes: 2 additions & 2 deletions 86BoxManager/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:

[assembly: AssemblyVersion("1.5.3.0")]
[assembly: AssemblyFileVersion("1.5.3.0")]
[assembly: AssemblyVersion("1.5.4.0")]
[assembly: AssemblyFileVersion("1.5.4.0")]
2 changes: 1 addition & 1 deletion 86BoxManager/dlgAddVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private void btnBrowse_Click(object sender, EventArgs e)

private void cbxImport_CheckedChanged(object sender, EventArgs e)
{
existingVM = true;
existingVM = !existingVM;
txtImportPath.Enabled = cbxImport.Checked;
btnBrowse.Enabled = cbxImport.Checked;
}
Expand Down
4 changes: 2 additions & 2 deletions 86BoxManager/dlgSettings.Designer.cs

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

35 changes: 26 additions & 9 deletions 86BoxManager/dlgSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ private void btnCancel_Click(object sender, EventArgs e)

private void btnApply_Click(object sender, EventArgs e)
{
SaveSettings();
bool success = SaveSettings();
if (!success)
{
return;
}
settingsChanged = CheckForChanges();
btnApply.Enabled = settingsChanged;
}
Expand All @@ -64,7 +68,7 @@ private void btnOK_Click(object sender, EventArgs e)
private void txt_TextChanged(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(txtEXEdir.Text) || string.IsNullOrWhiteSpace(txtCFGdir.Text) ||
string.IsNullOrWhiteSpace(txtLaunchTimeout.Text) || string.IsNullOrWhiteSpace(txtLogPath.Text))
string.IsNullOrWhiteSpace(txtLaunchTimeout.Text))
{
btnApply.Enabled = false;
}
Expand Down Expand Up @@ -106,11 +110,23 @@ private void Get86BoxVersion()

//TODO: Rewrite
//Save the settings to the registry
private void SaveSettings()
private bool SaveSettings()
{
if (cbxLogging.Checked && string.IsNullOrWhiteSpace(txtLogPath.Text))
{
DialogResult result = MessageBox.Show("Using an empty or whitespace string for the log path will prevent 86Box from logging anything. Are you sure you want to use this path?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (result == DialogResult.No)
{
return false;
}
}
if (!File.Exists(txtEXEdir.Text + "86Box.exe") && !File.Exists(txtEXEdir.Text + @"\86Box.exe"))
{
MessageBox.Show("86Box.exe could not be found in the directory you specified. Make sure the path is correct or you won't be able to use any virtual machines.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
DialogResult result = MessageBox.Show("86Box.exe could not be found in the directory you specified, so you won't be able to use any virtual machines. Are you sure you want to use this path?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (result == DialogResult.No)
{
return false;
}
}
try
{
Expand Down Expand Up @@ -142,11 +158,13 @@ private void SaveSettings()
catch (Exception ex)
{
MessageBox.Show("An error has occurred. Please provide the following information to the developer:\n" + ex.Message + "\n" + ex.StackTrace, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
finally
{
Get86BoxVersion(); //Get the new exe version in any case
}
return true;
}

//TODO: Rewrite
Expand Down Expand Up @@ -266,13 +284,13 @@ private void btnDefaults_Click(object sender, EventArgs e)
private void ResetSettings()
{
RegistryKey regkey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\86Box", true);

if (regkey == null)
{
Registry.CurrentUser.CreateSubKey(@"SOFTWARE\86Box");
regkey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\86Box", true);
regkey.CreateSubKey("Virtual Machines");
}
regkey.Close();

txtCFGdir.Text = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\86Box VMs\";
txtEXEdir.Text = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) + @"\86Box\";
Expand All @@ -287,8 +305,7 @@ private void ResetSettings()
txtLogPath.Enabled = false;
btnBrowse3.Enabled = false;

SaveSettings();
regkey.Close();
settingsChanged = CheckForChanges();
}

//Checks if all controls match the currently saved settings to determine if any changes were made
Expand All @@ -301,13 +318,13 @@ private bool CheckForChanges()
btnApply.Enabled = (
txtEXEdir.Text != regkey.GetValue("EXEdir").ToString() ||
txtCFGdir.Text != regkey.GetValue("CFGdir").ToString() ||
txtLogPath.Text != regkey.GetValue("LogPath").ToString() ||
txtLaunchTimeout.Text != regkey.GetValue("LaunchTimeout").ToString() ||
cbxMinimize.Checked != Convert.ToBoolean(regkey.GetValue("MinimizeOnVMStart")) ||
cbxShowConsole.Checked != Convert.ToBoolean(regkey.GetValue("ShowConsole")) ||
cbxMinimizeTray.Checked != Convert.ToBoolean(regkey.GetValue("MinimizeToTray")) ||
cbxCloseTray.Checked != Convert.ToBoolean(regkey.GetValue("CloseToTray")) ||
txtLaunchTimeout.Text != regkey.GetValue("LaunchTimeout").ToString() ||
cbxLogging.Checked != Convert.ToBoolean(regkey.GetValue("EnableLogging")) ||
txtLogPath.Text != regkey.GetValue("LogPath").ToString() ||
cbxGrid.Checked != Convert.ToBoolean(regkey.GetValue("EnableGridLines")));

return btnApply.Enabled;
Expand Down
4 changes: 4 additions & 0 deletions 86BoxManager/frmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,10 @@ private void VMConfigure()
btnPause.Text = "Pause";
btnCtrlAltDel.Enabled = false;
}
catch (Win32Exception ex)
{
MessageBox.Show("Cannot find 86Box.exe. Make sure your settings are correct and try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (Exception ex)
{
//Revert to stopped status and alert the user
Expand Down

0 comments on commit f40a50f

Please sign in to comment.