mirror of
https://github.com/osukey/osukey.git
synced 2025-04-29 02:37:25 +09:00
Merge remote-tracking branch 'origin/master' into tgi74-rightclickscrolling
This commit is contained in:
commit
81f0649e44
40
.gitattributes
vendored
40
.gitattributes
vendored
@ -1,19 +1,23 @@
|
||||
# This won't normalise line endings, but it will ensure that merge drivers use CRLF
|
||||
* -text eol=crlf
|
||||
# Autodetect text files and ensure that we normalise their
|
||||
# line endings to lf internally. When checked out they may
|
||||
# use different line endings.
|
||||
* text=auto
|
||||
|
||||
# Currently in-use binary file extensions
|
||||
*.blend binary
|
||||
*.bmp binary
|
||||
*.dll binary
|
||||
*.exe binary
|
||||
*.icns binary
|
||||
*.ico binary
|
||||
*.jpg binary
|
||||
*.osz2 binary
|
||||
*.pdn binary
|
||||
*.psd binary
|
||||
*.PSD binary
|
||||
*.tga binary
|
||||
*.ttf binary
|
||||
*.wav binary
|
||||
*.xnb binary
|
||||
# Check out with crlf (Windows) line endings
|
||||
*.sln text eol=crlf
|
||||
*.csproj text eol=crlf
|
||||
*.cs text diff=csharp eol=crlf
|
||||
*.resx text eol=crlf
|
||||
*.vsixmanifest text eol=crlf
|
||||
packages.config text eol=crlf
|
||||
App.config text eol=crlf
|
||||
*.bat text eol=crlf
|
||||
*.cmd text eol=crlf
|
||||
*.snippet text eol=crlf
|
||||
|
||||
# Check out with lf (UNIX) line endings
|
||||
*.sh text eol=lf
|
||||
.gitignore text eol=lf
|
||||
.gitattributes text eol=lf
|
||||
*.md text eol=lf
|
||||
.travis.yml text eol=lf
|
@ -42,6 +42,7 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
|
||||
private readonly Stack<BeatmapSetInfo> selectedSets = new Stack<BeatmapSetInfo>();
|
||||
private readonly HashSet<int> eagerSelectedIDs = new HashSet<int>();
|
||||
|
||||
private BeatmapInfo currentSelection;
|
||||
|
||||
@ -80,6 +81,7 @@ namespace osu.Game.Tests.Visual
|
||||
testEmptyTraversal();
|
||||
testHiding();
|
||||
testSelectingFilteredRuleset();
|
||||
testCarouselRootIsRandom();
|
||||
}
|
||||
|
||||
private void ensureRandomFetchSuccess() =>
|
||||
@ -151,6 +153,17 @@ namespace osu.Game.Tests.Visual
|
||||
AddAssert("Selection is visible", selectedBeatmapVisible);
|
||||
}
|
||||
|
||||
private void checkNonmatchingFilter()
|
||||
{
|
||||
AddStep("Toggle non-matching filter", () =>
|
||||
{
|
||||
carousel.Filter(new FilterCriteria { SearchText = "Dingo" }, false);
|
||||
carousel.Filter(new FilterCriteria(), false);
|
||||
eagerSelectedIDs.Add(carousel.SelectedBeatmapSet.ID);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test keyboard traversal
|
||||
/// </summary>
|
||||
@ -403,6 +416,23 @@ namespace osu.Game.Tests.Visual
|
||||
AddStep("remove single ruleset set", () => carousel.RemoveBeatmapSet(testSingle));
|
||||
}
|
||||
|
||||
private void testCarouselRootIsRandom()
|
||||
{
|
||||
List<BeatmapSetInfo> beatmapSets = new List<BeatmapSetInfo>();
|
||||
|
||||
for (int i = 1; i <= 50; i++)
|
||||
beatmapSets.Add(createTestBeatmapSet(i));
|
||||
|
||||
AddStep("Load 50 Beatmaps", () => { carousel.BeatmapSets = beatmapSets; });
|
||||
advanceSelection(direction: 1, diff: false);
|
||||
checkNonmatchingFilter();
|
||||
checkNonmatchingFilter();
|
||||
checkNonmatchingFilter();
|
||||
checkNonmatchingFilter();
|
||||
checkNonmatchingFilter();
|
||||
AddAssert("Selection was random", () => eagerSelectedIDs.Count > 1);
|
||||
}
|
||||
|
||||
private BeatmapSetInfo createTestBeatmapSet(int id)
|
||||
{
|
||||
return new BeatmapSetInfo
|
||||
|
@ -66,7 +66,7 @@ namespace osu.Game.Screens.Select
|
||||
get { return beatmapSets.Select(g => g.BeatmapSet); }
|
||||
set
|
||||
{
|
||||
CarouselGroup newRoot = new CarouselGroupEagerSelect();
|
||||
CarouselRoot newRoot = new CarouselRoot(this);
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
@ -105,10 +105,11 @@ namespace osu.Game.Screens.Select
|
||||
private readonly Stack<CarouselBeatmap> randomSelectedBeatmaps = new Stack<CarouselBeatmap>();
|
||||
|
||||
protected List<DrawableCarouselItem> Items = new List<DrawableCarouselItem>();
|
||||
private CarouselGroup root = new CarouselGroupEagerSelect();
|
||||
private CarouselRoot root;
|
||||
|
||||
public BeatmapCarousel()
|
||||
{
|
||||
root = new CarouselRoot(this);
|
||||
Child = new OsuContextMenuContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
@ -634,5 +635,23 @@ namespace osu.Game.Screens.Select
|
||||
// layer transformations on top, with a similar reasoning to the previous comment.
|
||||
p.SetMultiplicativeAlpha(MathHelper.Clamp(1.75f - 1.5f * dist, 0, 1));
|
||||
}
|
||||
|
||||
private class CarouselRoot : CarouselGroupEagerSelect
|
||||
{
|
||||
private readonly BeatmapCarousel carousel;
|
||||
|
||||
public CarouselRoot(BeatmapCarousel carousel)
|
||||
{
|
||||
this.carousel = carousel;
|
||||
}
|
||||
|
||||
protected override void PerformSelection()
|
||||
{
|
||||
if (LastSelected == null)
|
||||
carousel.SelectNextRandom();
|
||||
else
|
||||
base.PerformSelection();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,13 +20,16 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The last selected item.
|
||||
/// </summary>
|
||||
protected CarouselItem LastSelected { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// We need to keep track of the index for cases where the selection is removed but we want to select a new item based on its old location.
|
||||
/// </summary>
|
||||
private int lastSelectedIndex;
|
||||
|
||||
private CarouselItem lastSelected;
|
||||
|
||||
/// <summary>
|
||||
/// To avoid overhead during filter operations, we don't attempt any selections until after all
|
||||
/// children have been filtered. This bool will be true during the base <see cref="Filter(FilterCriteria)"/>
|
||||
@ -47,7 +50,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
base.RemoveChild(i);
|
||||
|
||||
if (i != lastSelected)
|
||||
if (i != LastSelected)
|
||||
updateSelectedIndex();
|
||||
}
|
||||
|
||||
@ -83,6 +86,11 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
// we only perform eager selection if none of our children are in a selected state already.
|
||||
if (Children.Any(i => i.State == CarouselItemState.Selected)) return;
|
||||
|
||||
PerformSelection();
|
||||
}
|
||||
|
||||
protected virtual void PerformSelection()
|
||||
{
|
||||
CarouselItem nextToSelect =
|
||||
Children.Skip(lastSelectedIndex).FirstOrDefault(i => !i.Filtered) ??
|
||||
Children.Reverse().Skip(InternalChildren.Count - lastSelectedIndex).FirstOrDefault(i => !i.Filtered);
|
||||
@ -95,10 +103,10 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
private void updateSelected(CarouselItem newSelection)
|
||||
{
|
||||
lastSelected = newSelection;
|
||||
LastSelected = newSelection;
|
||||
updateSelectedIndex();
|
||||
}
|
||||
|
||||
private void updateSelectedIndex() => lastSelectedIndex = lastSelected == null ? 0 : Math.Max(0, InternalChildren.IndexOf(lastSelected));
|
||||
private void updateSelectedIndex() => lastSelectedIndex = LastSelected == null ? 0 : Math.Max(0, InternalChildren.IndexOf(LastSelected));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user