Skip to content

Commit

Permalink
call game filter GetCheckedStates() only once above loops
Browse files Browse the repository at this point in the history
  • Loading branch information
FenPhoenix committed Sep 3, 2023
1 parent 2163536 commit e41e517
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions AngelLoader/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2313,6 +2313,8 @@ private async void GamesTabControl_SelectedIndexChanged(object sender, EventArgs
// controls properly) but keep the rest of the work before load
private void ChangeFilterControlsForGameType()
{
bool[] checkedStates = GameFilterControlsLLMenu.GetCheckedStates();

if (Config.GameOrganization == GameOrganization.ByTab)
{
#region Select target tab in advance
Expand All @@ -2321,8 +2323,6 @@ private void ChangeFilterControlsForGameType()
// cause a chain reaction where one tab gets hidden and the next gets selected, triggering a refresh,
// and then that tab gets hidden and the next gets selected, triggering a refresh, etc.

bool[] checkedStates = GameFilterControlsLLMenu.GetCheckedStates();

int selectedTabOrderIndex = 0;
TabPage? selectedTab = GamesTabControl.SelectedTab;
for (int i = 0; i < SupportedGameCount; i++)
Expand Down Expand Up @@ -2353,12 +2353,12 @@ private void ChangeFilterControlsForGameType()
// tabs in the list, thus setting selection to none and screwing us up
for (int i = 0; i < SupportedGameCount; i++)
{
bool visible = GameFilterControlsLLMenu.GetCheckedStates()[i];
bool visible = checkedStates[i];
if (visible) GamesTabControl.ShowTab(_gameTabs[i], true);
}
for (int i = 0; i < SupportedGameCount; i++)
{
bool visible = GameFilterControlsLLMenu.GetCheckedStates()[i];
bool visible = checkedStates[i];
if (!visible) GamesTabControl.ShowTab(_gameTabs[i], false);
}

Expand All @@ -2373,7 +2373,7 @@ private void ChangeFilterControlsForGameType()
{
for (int i = 0; i < SupportedGameCount; i++)
{
bool visible = GameFilterControlsLLMenu.GetCheckedStates()[i];
bool visible = checkedStates[i];
ToolStripButtonCustom button = _filterByGameButtons[i];
button.Visible = visible;
if (button.Checked && !visible) button.Checked = false;
Expand Down

0 comments on commit e41e517

Please sign in to comment.