Skip to content

Commit

Permalink
Fix cringe bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
slotthhy committed Oct 21, 2023
1 parent 10f5d20 commit 4cc5e1f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private void DrawReplacementList()
foreach (var replacement in Configuration.Instance.SongReplacements.Values)
{
if (!SongList.Instance.TryGetSong(replacement.TargetSongId, out var targetSong)) continue;
if (!SongList.Instance.TryGetSong(replacement.ReplacementId, out var replacementSong)) continue;
if (!SongList.Instance.TryGetSong(replacement.ReplacementId, out var replacementSong) && replacement.ReplacementId != SongReplacementEntry.NoChangeId) continue;
if (!Util.SearchMatches(_searchText, targetSong) && !Util.SearchMatches(_searchText, replacementSong)) continue;

ImGui.Spacing();
Expand Down
33 changes: 20 additions & 13 deletions Orchestrion/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,28 @@ public static bool SearchMatches(string searchText, Song song)

var matchesSearch = false;

foreach (var titleLang in AvailableTitleLanguages)
try
{
matchesSearch |= song.Strings[titleLang].Name.ToLower().Contains(searchText.ToLower());
matchesSearch |= song.Strings[titleLang].AlternateName.ToLower().Contains(searchText.ToLower());
matchesSearch |= song.Strings[titleLang].SpecialModeName.ToLower().Contains(searchText.ToLower());
foreach (var titleLang in AvailableTitleLanguages)
{
matchesSearch |= song.Strings[titleLang].Name.ToLower().Contains(searchText.ToLower());
matchesSearch |= song.Strings[titleLang].AlternateName.ToLower().Contains(searchText.ToLower());
matchesSearch |= song.Strings[titleLang].SpecialModeName.ToLower().Contains(searchText.ToLower());
}

// Id check
matchesSearch |= song.Id.ToString().Contains(searchText);

// Localized addtl info check
var strings = song.Strings["en"];
song.Strings.TryGetValue(lang, out strings);
matchesSearch |= strings.Locations.ToLower().Contains(searchText.ToLower());
matchesSearch |= strings.AdditionalInfo.ToLower().Contains(searchText.ToLower());
}
catch (Exception ignore)

Check warning on line 61 in Orchestrion/Util.cs

View workflow job for this annotation

GitHub Actions / build

The variable 'ignore' is declared but never used

Check warning on line 61 in Orchestrion/Util.cs

View workflow job for this annotation

GitHub Actions / build

The variable 'ignore' is declared but never used
{

}

// Id check
matchesSearch |= song.Id.ToString().Contains(searchText);

// Localized addtl info check
var strings = song.Strings["en"];
song.Strings.TryGetValue(lang, out strings);
matchesSearch |= strings.Locations.ToLower().Contains(searchText.ToLower());
matchesSearch |= strings.AdditionalInfo.ToLower().Contains(searchText.ToLower());

return matchesSearch;
}
Expand Down

0 comments on commit 4cc5e1f

Please sign in to comment.