Skip to content

Commit

Permalink
IsAnyInEnableListValid short circuit evaluation.
Browse files Browse the repository at this point in the history
  • Loading branch information
num0005 committed Jun 25, 2024
1 parent 1cb4a9a commit 7017e64
Showing 1 changed file with 14 additions and 40 deletions.
54 changes: 14 additions & 40 deletions Launcher/UIHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,68 +216,42 @@ static public bool IsAnyInEnableListValid(IEnumerable<TogglesUI> enable_for)

foreach (TogglesUI toggle in enable_for)
{
bool valid_toggle = true;

if (toggle.HasFlag(TogglesUI.H1) && !MainWindow.halo_ce)
{
valid_toggle = false;
}
continue;

if (toggle.HasFlag(TogglesUI.H2) && !MainWindow.halo_2)
{
valid_toggle = false;
}
continue;

if (toggle.HasFlag(TogglesUI.H3) && !MainWindow.halo_3)
{
valid_toggle = false;
}
continue;

if (toggle.HasFlag(TogglesUI.HR) && !MainWindow.halo_reach)
{
valid_toggle = false;
}
continue;

if (toggle.HasFlag(TogglesUI.H4) && !MainWindow.halo_4)
{
valid_toggle = false;
}
continue;

if (toggle.HasFlag(TogglesUI.CommunityBuild) && !MainWindow.halo_community)
{
valid_toggle = false;
}
continue;

if (toggle.HasFlag(TogglesUI.LegacyStock) && (MainWindow.halo_mcc || MainWindow.halo_community))
{
valid_toggle = false;
}
continue;

if (toggle.HasFlag(TogglesUI.HasTool) && string.IsNullOrEmpty(MainWindow.toolkit_profile.ToolPath))
{
valid_toggle = false;
}
continue;

if (toggle.HasFlag(TogglesUI.HasGuerilla) && string.IsNullOrEmpty(MainWindow.toolkit_profile.GuerillaPath))
{
valid_toggle = false;
}
continue;

if (toggle.HasFlag(TogglesUI.HasSapien) && string.IsNullOrEmpty(MainWindow.toolkit_profile.SapienPath))
{
valid_toggle = false;
}
continue;

if (toggle.HasFlag(TogglesUI.HasStandalone) && string.IsNullOrEmpty(MainWindow.toolkit_profile.GameExePath))
{
valid_toggle = false;
}
continue;

if (valid_toggle)
{
enable = true;
break;
}
// everything checks out, exit early
enable = true;
break;
}
}
else
Expand Down

0 comments on commit 7017e64

Please sign in to comment.