1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-16 12:23:06 +08:00

Make the header tabs work

This commit is contained in:
DrabWeb 2017-06-08 06:21:45 -03:00
parent 1162df96be
commit 70e12e5d9b
3 changed files with 22 additions and 7 deletions

View File

@ -103,5 +103,6 @@ namespace osu.Game.Overlays.Direct
Difficulty,
Ranked,
Rating,
Plays,
}
}

View File

@ -30,10 +30,10 @@ namespace osu.Game.Overlays.Direct
{
Search,
[Description("Newest Maps")]
NewestMaps,
NewestMaps = (int)DirectSortCriteria.Ranked,
[Description("Top Rated")]
TopRated,
TopRated = (int)DirectSortCriteria.Rating,
[Description("Most Played")]
MostPlayed
MostPlayed = (int)DirectSortCriteria.Plays,
}
}

View File

@ -114,7 +114,15 @@ namespace osu.Game.Overlays
},
};
Header.Tabs.Current.ValueChanged += tab => { if (tab != DirectTab.Search) Filter.Search.Text = string.Empty; };
Header.Tabs.Current.ValueChanged += tab =>
{
if (tab != DirectTab.Search)
{
Filter.Search.Text = lastQuery = string.Empty;
Filter.Tabs.Current.Value = (DirectSortCriteria)Header.Tabs.Current.Value;
updateSets();
}
};
Filter.Search.Current.ValueChanged += text => { if (text != string.Empty) Header.Tabs.Current.Value = DirectTab.Search; };
Filter.Search.OnCommit = (sender, text) =>
{
@ -122,7 +130,13 @@ namespace osu.Game.Overlays
updateSets();
};
((FilterControl)Filter).Ruleset.ValueChanged += ruleset => updateSets();
Filter.Tabs.Current.ValueChanged += sortCriteria => updateSets();
Filter.Tabs.Current.ValueChanged += sortCriteria =>
{
if (Header.Tabs.Current.Value != DirectTab.Search && sortCriteria != (DirectSortCriteria)Header.Tabs.Current.Value)
Header.Tabs.Current.Value = DirectTab.Search;
updateSets();
};
Filter.DisplayStyleControl.DisplayStyle.ValueChanged += recreatePanels;
Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += rankStatus => updateSets();
@ -159,7 +173,7 @@ namespace osu.Game.Overlays
}
private GetBeatmapSetsRequest getSetsRequest;
private string lastQuery;
private string lastQuery = string.Empty;
private void updateSets()
{
if (!IsLoaded) return;
@ -168,7 +182,7 @@ namespace osu.Game.Overlays
ResultAmounts = null;
getSetsRequest?.Cancel();
if (api == null || Filter.Search.Text == string.Empty) return;
if (api == null || Filter.Search.Text == string.Empty && Header.Tabs.Current.Value == DirectTab.Search) return;
getSetsRequest = new GetBeatmapSetsRequest(lastQuery,
((FilterControl)Filter).Ruleset.Value,