mirror of
https://github.com/osukey/osukey.git
synced 2025-06-10 05:48:05 +09:00
Merge pull request #419 from peppy/song-selection-improvements
Fix selection on entry to song select.
This commit is contained in:
commit
ed26d87170
@ -55,7 +55,10 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
},
|
},
|
||||||
modeSelector = new ToolbarModeSelector
|
modeSelector = new ToolbarModeSelector
|
||||||
{
|
{
|
||||||
OnPlayModeChange = OnPlayModeChange
|
OnPlayModeChange = (PlayMode mode) =>
|
||||||
|
{
|
||||||
|
OnPlayModeChange?.Invoke(mode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -192,8 +192,10 @@ namespace osu.Game.Screens.Select
|
|||||||
ScrollTo(selectedY, animated);
|
ScrollTo(selectedY, animated);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Sort(FilterControl.SortMode mode) {
|
public void Sort(FilterControl.SortMode mode)
|
||||||
switch (mode) {
|
{
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
case FilterControl.SortMode.Artist:
|
case FilterControl.SortMode.Artist:
|
||||||
groups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Artist, y.BeatmapSet.Metadata.Artist));
|
groups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Artist, y.BeatmapSet.Metadata.Artist));
|
||||||
break;
|
break;
|
||||||
@ -206,15 +208,17 @@ namespace osu.Game.Screens.Select
|
|||||||
case FilterControl.SortMode.Difficulty:
|
case FilterControl.SortMode.Difficulty:
|
||||||
groups.Sort((x, y) =>
|
groups.Sort((x, y) =>
|
||||||
{
|
{
|
||||||
float xAverage=0, yAverage=0;
|
float xAverage = 0, yAverage = 0;
|
||||||
int counter=0;
|
int counter = 0;
|
||||||
foreach (BeatmapInfo set in x.BeatmapSet.Beatmaps) {
|
foreach (BeatmapInfo set in x.BeatmapSet.Beatmaps)
|
||||||
|
{
|
||||||
xAverage += set.StarDifficulty;
|
xAverage += set.StarDifficulty;
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
xAverage /= counter;
|
xAverage /= counter;
|
||||||
counter = 0;
|
counter = 0;
|
||||||
foreach (BeatmapInfo set in y.BeatmapSet.Beatmaps) {
|
foreach (BeatmapInfo set in y.BeatmapSet.Beatmaps)
|
||||||
|
{
|
||||||
yAverage += set.StarDifficulty;
|
yAverage += set.StarDifficulty;
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
@ -241,7 +245,7 @@ namespace osu.Game.Screens.Select
|
|||||||
scrollableContent.Add(panel);
|
scrollableContent.Add(panel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SelectGroup(groups.FirstOrDefault(), groups.First().BeatmapPanels.FirstOrDefault());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float offsetX(float dist, float halfHeight)
|
private static float offsetX(float dist, float halfHeight)
|
||||||
@ -344,7 +348,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
public void SelectNext(int direction = 1, bool skipDifficulties = true)
|
public void SelectNext(int direction = 1, bool skipDifficulties = true)
|
||||||
{
|
{
|
||||||
if (!skipDifficulties)
|
if (!skipDifficulties && SelectedGroup != null)
|
||||||
{
|
{
|
||||||
int i = SelectedGroup.BeatmapPanels.IndexOf(SelectedPanel) + direction;
|
int i = SelectedGroup.BeatmapPanels.IndexOf(SelectedPanel) + direction;
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
public class PlaySongSelect : OsuScreen
|
public class PlaySongSelect : OsuScreen
|
||||||
{
|
{
|
||||||
private Bindable<PlayMode> playMode;
|
private Bindable<PlayMode> playMode = new Bindable<PlayMode>();
|
||||||
private BeatmapDatabase database;
|
private BeatmapDatabase database;
|
||||||
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
|
protected override BackgroundScreen CreateBackground() => new BackgroundScreenBeatmap(Beatmap);
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
[BackgroundDependencyLoader(permitNulls: true)]
|
[BackgroundDependencyLoader(permitNulls: true)]
|
||||||
private void load(BeatmapDatabase beatmaps, AudioManager audio, DialogOverlay dialog, Framework.Game game,
|
private void load(BeatmapDatabase beatmaps, AudioManager audio, DialogOverlay dialog, Framework.Game game,
|
||||||
OsuGame osuGame, OsuColour colours)
|
OsuGame osu, OsuColour colours)
|
||||||
{
|
{
|
||||||
const float carousel_width = 640;
|
const float carousel_width = 640;
|
||||||
const float filter_height = 100;
|
const float filter_height = 100;
|
||||||
@ -111,7 +111,7 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = filter_height,
|
Height = filter_height,
|
||||||
FilterChanged = filterChanged,
|
FilterChanged = () => filterChanged(),
|
||||||
Exit = Exit,
|
Exit = Exit,
|
||||||
},
|
},
|
||||||
beatmapInfoWedge = new BeatmapInfoWedge
|
beatmapInfoWedge = new BeatmapInfoWedge
|
||||||
@ -146,11 +146,9 @@ namespace osu.Game.Screens.Select
|
|||||||
footer.AddButton(@"random", colours.Green, carousel.SelectRandom);
|
footer.AddButton(@"random", colours.Green, carousel.SelectRandom);
|
||||||
footer.AddButton(@"options", colours.Blue, null);
|
footer.AddButton(@"options", colours.Blue, null);
|
||||||
|
|
||||||
if (osuGame != null)
|
if (osu != null)
|
||||||
{
|
playMode.BindTo(osu.PlayMode);
|
||||||
playMode = osuGame.PlayMode;
|
playMode.ValueChanged += playMode_ValueChanged;
|
||||||
playMode.ValueChanged += playMode_ValueChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (database == null)
|
if (database == null)
|
||||||
database = beatmaps;
|
database = beatmaps;
|
||||||
@ -171,7 +169,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private ScheduledDelegate filterTask;
|
private ScheduledDelegate filterTask;
|
||||||
|
|
||||||
private void filterChanged()
|
private void filterChanged(bool debounce = true, bool eagerSelection = true)
|
||||||
{
|
{
|
||||||
filterTask?.Cancel();
|
filterTask?.Cancel();
|
||||||
filterTask = Scheduler.AddDelayed(() =>
|
filterTask = Scheduler.AddDelayed(() =>
|
||||||
@ -183,25 +181,42 @@ namespace osu.Game.Screens.Select
|
|||||||
foreach (var beatmapGroup in carousel)
|
foreach (var beatmapGroup in carousel)
|
||||||
{
|
{
|
||||||
var set = beatmapGroup.BeatmapSet;
|
var set = beatmapGroup.BeatmapSet;
|
||||||
bool match = string.IsNullOrEmpty(search)
|
|
||||||
|
bool hasCurrentMode = set.Beatmaps.Any(bm => bm.Mode == playMode);
|
||||||
|
|
||||||
|
bool match = hasCurrentMode;
|
||||||
|
|
||||||
|
match &= string.IsNullOrEmpty(search)
|
||||||
|| (set.Metadata.Artist ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1
|
|| (set.Metadata.Artist ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1
|
||||||
|| (set.Metadata.ArtistUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1
|
|| (set.Metadata.ArtistUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1
|
||||||
|| (set.Metadata.Title ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1
|
|| (set.Metadata.Title ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1
|
||||||
|| (set.Metadata.TitleUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1;
|
|| (set.Metadata.TitleUnicode ?? "").IndexOf(search, StringComparison.InvariantCultureIgnoreCase) != -1;
|
||||||
|
|
||||||
if (match)
|
if (match)
|
||||||
{
|
{
|
||||||
beatmapGroup.State = BeatmapGroupState.Collapsed;
|
|
||||||
if (newSelection == null || beatmapGroup.BeatmapSet.OnlineBeatmapSetID == Beatmap.BeatmapSetInfo.OnlineBeatmapSetID)
|
if (newSelection == null || beatmapGroup.BeatmapSet.OnlineBeatmapSetID == Beatmap.BeatmapSetInfo.OnlineBeatmapSetID)
|
||||||
|
{
|
||||||
|
if (newSelection != null)
|
||||||
|
newSelection.State = BeatmapGroupState.Collapsed;
|
||||||
newSelection = beatmapGroup;
|
newSelection = beatmapGroup;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
beatmapGroup.State = BeatmapGroupState.Collapsed;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
beatmapGroup.State = BeatmapGroupState.Hidden;
|
beatmapGroup.State = BeatmapGroupState.Hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newSelection != null)
|
if (newSelection != null)
|
||||||
carousel.SelectBeatmap(newSelection.BeatmapSet.Beatmaps[0], false);
|
{
|
||||||
}, 250);
|
if (newSelection.BeatmapPanels.Any(b => b.Beatmap.ID == Beatmap.BeatmapInfo.ID))
|
||||||
|
carousel.SelectBeatmap(Beatmap.BeatmapInfo, false);
|
||||||
|
else if (eagerSelection)
|
||||||
|
carousel.SelectBeatmap(newSelection.BeatmapSet.Beatmaps[0], false);
|
||||||
|
}
|
||||||
|
}, debounce ? 250 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onBeatmapSetAdded(BeatmapSetInfo s) => Schedule(() => addBeatmapSet(s, Game, true));
|
private void onBeatmapSetAdded(BeatmapSetInfo s) => Schedule(() => addBeatmapSet(s, Game, true));
|
||||||
@ -262,8 +277,6 @@ namespace osu.Game.Screens.Select
|
|||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
if (playMode != null)
|
|
||||||
playMode.ValueChanged -= playMode_ValueChanged;
|
|
||||||
|
|
||||||
database.BeatmapSetAdded -= onBeatmapSetAdded;
|
database.BeatmapSetAdded -= onBeatmapSetAdded;
|
||||||
database.BeatmapSetRemoved -= onBeatmapSetRemoved;
|
database.BeatmapSetRemoved -= onBeatmapSetRemoved;
|
||||||
@ -273,6 +286,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private void playMode_ValueChanged(object sender, EventArgs e)
|
private void playMode_ValueChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
filterChanged(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeBackground(WorkingBeatmap beatmap)
|
private void changeBackground(WorkingBeatmap beatmap)
|
||||||
@ -358,6 +372,8 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
carousel.AddGroup(group);
|
carousel.AddGroup(group);
|
||||||
|
|
||||||
|
filterChanged(false, false);
|
||||||
|
|
||||||
if (Beatmap == null || select)
|
if (Beatmap == null || select)
|
||||||
carousel.SelectBeatmap(beatmapSet.Beatmaps.First());
|
carousel.SelectBeatmap(beatmapSet.Beatmaps.First());
|
||||||
else
|
else
|
||||||
@ -391,7 +407,6 @@ namespace osu.Game.Screens.Select
|
|||||||
if (token.IsCancellationRequested) return;
|
if (token.IsCancellationRequested) return;
|
||||||
addBeatmapSet(beatmapSet, game);
|
addBeatmapSet(beatmapSet, game);
|
||||||
}
|
}
|
||||||
filterChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user