Try-catched some exceptions

This commit is contained in:
strongleong 2022-02-15 22:50:56 +11:00
parent 75333e8f68
commit ca870eb66b
1 changed files with 17 additions and 5 deletions

View File

@ -37,11 +37,18 @@ namespace ScrapModLoader
// TODO: Refactor it to separate window with pretty loading animation // TODO: Refactor it to separate window with pretty loading animation
if (modsLauncher.ScraplandPath == String.Empty && modsLauncher.ScraplandRemasteredPath == String.Empty) if (modsLauncher.ScraplandPath == String.Empty && modsLauncher.ScraplandRemasteredPath == String.Empty)
{ {
Boolean isFoundScrapland = modsLauncher.SearchForScrapland(); try
if (!isFoundScrapland)
{ {
ButtonRunScrapland.IsEnabled = false; Boolean isFoundScrapland = modsLauncher.SearchForScrapland();
MessageBox.Show("Error: unable to find Scrapland instalation. Please, specify yours game installation folder in settings."); if (!isFoundScrapland)
{
ButtonRunScrapland.IsEnabled = false;
MessageBox.Show("Error: unable to find Scrapland instalation. Please, specify yours game installation folder in settings.");
}
}
catch (KeyNotFoundException ex)
{
MessageBox.Show(ex.Message);
} }
} }
@ -148,11 +155,16 @@ namespace ScrapModLoader
private void ButtonSettings_Click(Object sender, RoutedEventArgs e) private void ButtonSettings_Click(Object sender, RoutedEventArgs e)
{ {
SettingsWindow settingsWindow = new SettingsWindow(); SettingsWindow settingsWindow = new SettingsWindow(modsLauncher);
settingsWindow.ShowDialog(); settingsWindow.ShowDialog();
if (settingsWindow.Save) if (settingsWindow.Save)
modsLauncher.ScanMods(); modsLauncher.ScanMods();
ModsList.Items.Refresh(); ModsList.Items.Refresh();
((ComboBoxItem)ScraplandVersion.Items[0]).IsEnabled = modsLauncher.ScraplandPath != String.Empty;
((ComboBoxItem)ScraplandVersion.Items[1]).IsEnabled = modsLauncher.ScraplandRemasteredPath != String.Empty;
ScraplandVersion.SelectedIndex = modsLauncher.ScraplandRemasteredPath != String.Empty ? 1 : 0;
} }
private void ButtonRunScrapland_Click(Object sender, RoutedEventArgs e) private void ButtonRunScrapland_Click(Object sender, RoutedEventArgs e)