Skip to content

Commit

Permalink
ErrorHandling for Loading Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
TheXorog committed Jan 10, 2022
1 parent ce780fa commit 1a40e57
Showing 1 changed file with 36 additions and 26 deletions.
62 changes: 36 additions & 26 deletions BeatRecorderUI/SettingsUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,32 +45,42 @@ private void SettingsUI_Shown(object sender, EventArgs e)
return;
}

ModSelectionBox.SelectedIndex = ModSelectionBox.Items.IndexOf(_loadedSettings.Mod);
OBSPasswordBox.Text = _loadedSettings.OBSPassword;
FileFormatBox.Text = _loadedSettings.FileFormat;
StopRecordingDelay.Value = _loadedSettings.StopRecordingDelay;

DeleteIfShorterThan.Value = _loadedSettings.DeleteIfShorterThan;
DeleteIfQuit.Checked = _loadedSettings.DeleteQuit;
DeleteIfQuitAfterSoftFailCheck.Checked = _loadedSettings.DeleteIfQuitAfterSoftFailed;
DeleteIfSoftFailedCheck.Checked = _loadedSettings.DeleteSoftFailed;
DeleteIfFailedCheck.Checked = _loadedSettings.DeleteFailed;

IngameSceneBox.Text = _loadedSettings.OBSIngameScene;
MenuSceneBox.Text = _loadedSettings.OBSMenuScene;
PauseSceneBox.Text = _loadedSettings.OBSPauseScene;

DisplaySteamNotificationsCheck.Checked = _loadedSettings.DisplaySteamNotifications;
AlwaysTopMostCheck.Checked = _loadedSettings.DisplayUITopmost;

BeatSaberIpBox.Text = _loadedSettings.BeatSaberUrl;
BeatSaberPortBox.Text = _loadedSettings.BeatSaberPort;
OBSIpBox.Text = _loadedSettings.OBSUrl;
OBSPortBox.Text = _loadedSettings.OBSPort;
DisplayUserInterfaceCheck.Checked = _loadedSettings.DisplayUI;
AutomaticRecordingCheck.Checked = _loadedSettings.AutomaticRecording;
PauseOnIngamePauseCheck.Checked = _loadedSettings.PauseRecordingOnIngamePause;
EntirelyHideConsoleCheck.Checked = _loadedSettings.HideConsole;
try
{
ModSelectionBox.SelectedIndex = ModSelectionBox.Items.IndexOf(_loadedSettings.Mod);
OBSPasswordBox.Text = _loadedSettings.OBSPassword;
FileFormatBox.Text = _loadedSettings.FileFormat;
StopRecordingDelay.Value = _loadedSettings.StopRecordingDelay;

DeleteIfShorterThan.Value = _loadedSettings.DeleteIfShorterThan;
DeleteIfQuit.Checked = _loadedSettings.DeleteQuit;
DeleteIfQuitAfterSoftFailCheck.Checked = _loadedSettings.DeleteIfQuitAfterSoftFailed;
DeleteIfSoftFailedCheck.Checked = _loadedSettings.DeleteSoftFailed;
DeleteIfFailedCheck.Checked = _loadedSettings.DeleteFailed;

IngameSceneBox.Text = _loadedSettings.OBSIngameScene;
MenuSceneBox.Text = _loadedSettings.OBSMenuScene;
PauseSceneBox.Text = _loadedSettings.OBSPauseScene;

DisplaySteamNotificationsCheck.Checked = _loadedSettings.DisplaySteamNotifications;
AlwaysTopMostCheck.Checked = _loadedSettings.DisplayUITopmost;

BeatSaberIpBox.Text = _loadedSettings.BeatSaberUrl;
BeatSaberPortBox.Text = _loadedSettings.BeatSaberPort;
OBSIpBox.Text = _loadedSettings.OBSUrl;
OBSPortBox.Text = _loadedSettings.OBSPort;
DisplayUserInterfaceCheck.Checked = _loadedSettings.DisplayUI;
AutomaticRecordingCheck.Checked = _loadedSettings.AutomaticRecording;
PauseOnIngamePauseCheck.Checked = _loadedSettings.PauseRecordingOnIngamePause;
EntirelyHideConsoleCheck.Checked = _loadedSettings.HideConsole;
}
catch (Exception)
{
this.Hide();
MessageBox.Show($"Failed to load settings, please avoid manually editing the config file from now on.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.Close();
return;
}
}

private void ShowAdvancedSettings_Click(object sender, EventArgs e)
Expand Down

0 comments on commit 1a40e57

Please sign in to comment.