Skip to content

Commit

Permalink
Fix unhandled exceptions (#14)
Browse files Browse the repository at this point in the history
* fix index out of range when not clicking on a mod

* remove not found files from setting file
  • Loading branch information
Terasol committed Jul 16, 2023
1 parent ad1c254 commit 9360db3
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions TrinityModLoader/TrinityMainWindow.cs
Expand Up @@ -98,6 +98,9 @@ public void LoadSettings()
settings = JsonSerializer.Deserialize<Settings>(File.ReadAllText(file));
disableAutoLoad.Checked = !settings.autoloadTrpfd;
}

//clean up missing files
settings.mods = settings.mods.Where(m => File.Exists(m.Path)).ToList();
}

//Populate mods from json
Expand Down Expand Up @@ -648,10 +651,14 @@ private void modList_MouseUp(object sender, MouseEventArgs e)
{
Point ClickPoint = new Point(e.X, e.Y);
modList.SelectedIndex = modList.IndexFromPoint(ClickPoint);
settings.mods[modList.SelectedIndex].IsChecked = modList.GetItemChecked(modList.SelectedIndex);
if (e.Button == MouseButtons.Right && modList.SelectedIndex >= 0) {

basicContext.Show(modList, ClickPoint);
if (modList.SelectedIndex != -1)
{
settings.mods[modList.SelectedIndex].IsChecked = modList.GetItemChecked(modList.SelectedIndex);
if (e.Button == MouseButtons.Right && modList.SelectedIndex >= 0)
{

basicContext.Show(modList, ClickPoint);
}
}
}

Expand Down

0 comments on commit 9360db3

Please sign in to comment.