diff --git a/Assets/Scenes/MenuScene.unity b/Assets/Scenes/MenuScene.unity index 8dd67c7c9..1584af3c1 100644 --- a/Assets/Scenes/MenuScene.unity +++ b/Assets/Scenes/MenuScene.unity @@ -3296,9 +3296,9 @@ MonoBehaviour: m_OnClick: m_PersistentCalls: m_Calls: - - m_Target: {fileID: 874813134} - m_TargetAssemblyTypeName: YARG.UI.MainMenu, Assembly-CSharp - m_MethodName: ShowMainMenu + - m_Target: {fileID: 1458336824} + m_TargetAssemblyTypeName: YARG.UI.SongSelect, Assembly-CSharp + m_MethodName: Back m_Mode: 1 m_Arguments: m_ObjectArgument: {fileID: 0} @@ -13279,7 +13279,7 @@ MonoBehaviour: m_enableAutoSizing: 0 m_fontSizeMin: 18 m_fontSizeMax: 72 - m_fontStyle: 0 + m_fontStyle: 4 m_HorizontalAlignment: 1 m_VerticalAlignment: 256 m_textAlignment: 65535 @@ -18413,6 +18413,7 @@ GameObject: - component: {fileID: 1886399723} - component: {fileID: 1886399726} - component: {fileID: 1886399725} + - component: {fileID: 1886399727} - component: {fileID: 1886399724} m_Layer: 5 m_Name: Support Text @@ -18515,7 +18516,7 @@ MonoBehaviour: m_enableAutoSizing: 0 m_fontSizeMin: 18 m_fontSizeMax: 72 - m_fontStyle: 1 + m_fontStyle: 5 m_HorizontalAlignment: 4 m_VerticalAlignment: 256 m_textAlignment: 65535 @@ -18559,6 +18560,62 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1886399722} m_CullTransparentMesh: 1 +--- !u!114 &1886399727 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1886399722} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 0 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1290299072} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 2044165076} + m_TargetAssemblyTypeName: YARG.UI.SelectedSongView, Assembly-CSharp + m_MethodName: SearchSource + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 --- !u!1 &1887177691 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Script/Input/FiveFretInputStrategy.cs b/Assets/Script/Input/FiveFretInputStrategy.cs index 4f3f44eb4..b44bec9d2 100644 --- a/Assets/Script/Input/FiveFretInputStrategy.cs +++ b/Assets/Script/Input/FiveFretInputStrategy.cs @@ -99,6 +99,10 @@ public override void UpdateNavigationMode() { if (MappingAsButton("red")?.wasPressedThisFrame ?? false) { CallGenericNavigationEvent(NavigationType.SECONDARY, true); } + + if (MappingAsButton("yellow")?.wasPressedThisFrame ?? false) { + CallGenericNavigationEvent(NavigationType.TERTIARY, true); + } } public override string[] GetAllowedInstruments() { diff --git a/Assets/Script/Input/NavigationType.cs b/Assets/Script/Input/NavigationType.cs index 83f9c4363..8eb544be8 100644 --- a/Assets/Script/Input/NavigationType.cs +++ b/Assets/Script/Input/NavigationType.cs @@ -3,6 +3,7 @@ public enum NavigationType { UP, DOWN, PRIMARY, - SECONDARY + SECONDARY, + TERTIARY } } \ No newline at end of file diff --git a/Assets/Script/UI/DifficultySelect.cs b/Assets/Script/UI/DifficultySelect.cs index 5f1135286..9e6604774 100644 --- a/Assets/Script/UI/DifficultySelect.cs +++ b/Assets/Script/UI/DifficultySelect.cs @@ -115,6 +115,8 @@ private void OnGenericNavigation(NavigationType navigationType, bool firstPresse MoveOption(1); } else if (navigationType == NavigationType.PRIMARY) { Next(); + } else if (navigationType == NavigationType.SECONDARY) { + MainMenu.Instance.ShowSongSelect(); } } diff --git a/Assets/Script/UI/SelectedSongView.cs b/Assets/Script/UI/SelectedSongView.cs index 856c249ce..112c44f34 100644 --- a/Assets/Script/UI/SelectedSongView.cs +++ b/Assets/Script/UI/SelectedSongView.cs @@ -178,5 +178,9 @@ public void PlaySong() { public void SearchArtist() { SongSelect.Instance.searchField.text = $"artist:{songInfo.ArtistName}"; } + + public void SearchSource() { + SongSelect.Instance.searchField.text = $"source:{songInfo.source}"; + } } } \ No newline at end of file diff --git a/Assets/Script/UI/SongSelect.cs b/Assets/Script/UI/SongSelect.cs index a55259842..4b259f67b 100644 --- a/Assets/Script/UI/SongSelect.cs +++ b/Assets/Script/UI/SongSelect.cs @@ -213,8 +213,18 @@ private void OnGenericNavigation(NavigationType navigationType, bool firstPresse } } + if (!firstPressed) { + return; + } + if (navigationType == NavigationType.PRIMARY) { selectedSongView.PlaySong(); + } else if (navigationType == NavigationType.SECONDARY) { + Back(); + } else if (navigationType == NavigationType.TERTIARY) { + if (songs.Count > 0) { + searchField.text = $"artist:{songs[selectedSongIndex].song.ArtistName}"; + } } } @@ -247,11 +257,11 @@ private void MoveView(int amount) { UpdateSongViews(); } - private int FuzzySearch(SongInfo song) { + private int FuzzySearch(string text, SongInfo song) { if (dropdown.value == 0) { - return Fuzz.Ratio(song.SongName, searchField.text); + return Fuzz.PartialRatio(song.SongName, text); } else { - return Fuzz.Ratio(song.ArtistName, searchField.text); + return Fuzz.PartialRatio(song.ArtistName, text); } } @@ -339,26 +349,43 @@ public void UpdateSearch() { songs.Insert(0, new SongOrHeader { header = ("Recommended Songs", $"{recommendedSongs.Count} random songs") }); - } else if (searchField.text.StartsWith("artist:")) { - // Search by artist - var artist = searchField.text[7..]; - songs = SongLibrary.Songs - .Where(i => i.ArtistName.ToLower() == artist.ToLower()) - .OrderBy(song => song.SongNameNoParen) - .Select(i => new SongOrHeader { song = i }) - .ToList(); - songs.Insert(0, new SongOrHeader { header = ($"{artist}'s Songs", $"{songs.Count} songs") }); } else { - // Fuzzy search! - var text = searchField.text.ToLower(); - songs = SongLibrary.Songs - .Select(i => new { score = FuzzySearch(i), songInfo = i }) - .Where(i => i.score > 55) - .OrderByDescending(i => i.score) - .Select(i => i.songInfo) - .Select(i => new SongOrHeader { song = i }) - .ToList(); - songs.Insert(0, new SongOrHeader { header = ("Searched Songs", $"{songs.Count} songs") }); + // Split up args + var split = searchField.text.Split(';'); + IEnumerable songsOut = SongLibrary.Songs; + + // Go through them all + bool fuzzySearched = false; + foreach (var arg in split) { + if (arg.StartsWith("artist:")) { + // Artist filter + var artist = arg[7..]; + songsOut = SongLibrary.Songs + .Where(i => i.ArtistName.ToLower() == artist.ToLower()); + } else if (arg.StartsWith("source:")) { + // Source filter + var source = arg[7..]; + songsOut = SongLibrary.Songs + .Where(i => i.source.ToLower() == source.ToLower()); + } else if (!fuzzySearched) { + // Fuzzy search + fuzzySearched = true; + songsOut = songsOut + .Select(i => new { score = FuzzySearch(arg, i), songInfo = i }) + .Where(i => i.score > 55) + .OrderByDescending(i => i.score) + .Select(i => i.songInfo); + } + } + + // Sort + if (!fuzzySearched) { + songsOut = songsOut.OrderBy(song => song.SongNameNoParen); + } + + // Add header + songs = songsOut.Select(i => new SongOrHeader { song = i }).ToList(); + songs.Insert(0, new SongOrHeader { header = ($"Filtered Songs", $"{songs.Count} songs") }); } // Count songs @@ -377,5 +404,14 @@ public void UpdateSearch() { selectedSongIndex = 1; UpdateSongViews(); } + + public void Back() { + if (string.IsNullOrEmpty(searchField.text)) { + MainMenu.Instance.ShowMainMenu(); + } else { + searchField.text = ""; + UpdateSearch(); + } + } } } \ No newline at end of file