mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 19:12:56 +08:00
move constants, combine local vars into properties
This commit is contained in:
parent
a9f0dda9d7
commit
c89830f3d8
@ -26,6 +26,9 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
public class BeatmapCarousel : OsuScrollContainer
|
public class BeatmapCarousel : OsuScrollContainer
|
||||||
{
|
{
|
||||||
|
private const float bleed_top = FilterControl.HEIGHT;
|
||||||
|
private const float bleed_bottom = Footer.HEIGHT;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Triggered when the <see cref="BeatmapSets"/> loaded change and are completely loaded.
|
/// Triggered when the <see cref="BeatmapSets"/> loaded change and are completely loaded.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -110,12 +113,10 @@ namespace osu.Game.Screens.Select
|
|||||||
root = new CarouselRoot(this);
|
root = new CarouselRoot(this);
|
||||||
Child = new OsuContextMenuContainer
|
Child = new OsuContextMenuContainer
|
||||||
{
|
{
|
||||||
Masking = false,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Child = scrollableContent = new Container<DrawableCarouselItem>
|
Child = scrollableContent = new Container<DrawableCarouselItem>
|
||||||
{
|
{
|
||||||
Masking = false,
|
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -342,6 +343,12 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
public bool AllowSelection = true;
|
public bool AllowSelection = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The total bounds of what is displayable in the beatmap carousel.
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
private float visibleHeight => DrawHeight + bleed_bottom + bleed_top;
|
||||||
|
|
||||||
public void FlushPendingFilterOperations()
|
public void FlushPendingFilterOperations()
|
||||||
{
|
{
|
||||||
if (PendingFilter?.Completed == false)
|
if (PendingFilter?.Completed == false)
|
||||||
@ -428,18 +435,15 @@ namespace osu.Game.Screens.Select
|
|||||||
if (!scrollPositionCache.IsValid)
|
if (!scrollPositionCache.IsValid)
|
||||||
updateScrollPosition();
|
updateScrollPosition();
|
||||||
|
|
||||||
// The draw positions of individual sets extend beyond the size of the carousel and into the footer and header.
|
|
||||||
float visibleHeight = DrawHeight + SongSelect.FOOTER_HEIGHT + SongSelect.FILTER_CONTROL_HEIGHT;
|
|
||||||
|
|
||||||
// Remove all items that should no longer be on-screen
|
// Remove all items that should no longer be on-screen
|
||||||
scrollableContent.RemoveAll(p => p.Y < Current - p.DrawHeight || p.Y > Current + visibleHeight || !p.IsPresent);
|
scrollableContent.RemoveAll(p => p.Y < Current - p.DrawHeight || p.Y > Current + visibleHeight || !p.IsPresent);
|
||||||
|
|
||||||
// Find index range of all items that should be on-screen
|
// Find index range of all items that should be on-screen
|
||||||
Trace.Assert(Items.Count == yPositions.Count);
|
Trace.Assert(Items.Count == yPositions.Count);
|
||||||
|
|
||||||
int firstIndex = yPositions.BinarySearch(Current - DrawableCarouselItem.MAX_HEIGHT - SongSelect.FILTER_CONTROL_HEIGHT);
|
int firstIndex = yPositions.BinarySearch(Current - DrawableCarouselItem.MAX_HEIGHT - bleed_top);
|
||||||
if (firstIndex < 0) firstIndex = ~firstIndex;
|
if (firstIndex < 0) firstIndex = ~firstIndex;
|
||||||
int lastIndex = yPositions.BinarySearch(Current + visibleHeight + SongSelect.FOOTER_HEIGHT);
|
int lastIndex = yPositions.BinarySearch(Current + visibleHeight + bleed_bottom);
|
||||||
if (lastIndex < 0) lastIndex = ~lastIndex;
|
if (lastIndex < 0) lastIndex = ~lastIndex;
|
||||||
|
|
||||||
int notVisibleCount = 0;
|
int notVisibleCount = 0;
|
||||||
@ -547,7 +551,6 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
yPositions.Clear();
|
yPositions.Clear();
|
||||||
|
|
||||||
float visibleHeight = DrawHeight + SongSelect.FOOTER_HEIGHT + SongSelect.FILTER_CONTROL_HEIGHT;
|
|
||||||
float currentY = visibleHeight / 2;
|
float currentY = visibleHeight / 2;
|
||||||
DrawableCarouselBeatmapSet lastSet = null;
|
DrawableCarouselBeatmapSet lastSet = null;
|
||||||
|
|
||||||
@ -648,8 +651,7 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
var height = p.IsPresent ? p.DrawHeight : 0;
|
var height = p.IsPresent ? p.DrawHeight : 0;
|
||||||
|
|
||||||
// The actual Y position of the item needs to be offset by any potential padding set by the container's parent.
|
float itemDrawY = p.Position.Y + bleed_top - Current + height / 2;
|
||||||
float itemDrawY = p.Position.Y + SongSelect.FILTER_CONTROL_HEIGHT - Current + height / 2;
|
|
||||||
float dist = Math.Abs(1f - itemDrawY / halfHeight);
|
float dist = Math.Abs(1f - itemDrawY / halfHeight);
|
||||||
|
|
||||||
// Setting the origin position serves as an additive position on top of potential
|
// Setting the origin position serves as an additive position on top of potential
|
||||||
|
@ -21,6 +21,8 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
public class FilterControl : Container
|
public class FilterControl : Container
|
||||||
{
|
{
|
||||||
|
public const float HEIGHT = 100;
|
||||||
|
|
||||||
public Action<FilterCriteria> FilterChanged;
|
public Action<FilterCriteria> FilterChanged;
|
||||||
|
|
||||||
private readonly OsuTabControl<SortMode> sortTabs;
|
private readonly OsuTabControl<SortMode> sortTabs;
|
||||||
|
@ -62,6 +62,10 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
public Footer()
|
public Footer()
|
||||||
{
|
{
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
Height = HEIGHT;
|
||||||
|
Anchor = Anchor.BottomCentre;
|
||||||
|
Origin = Anchor.BottomCentre;
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
new Box
|
||||||
|
@ -43,8 +43,6 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245);
|
private static readonly Vector2 wedged_container_size = new Vector2(0.5f, 245);
|
||||||
|
|
||||||
public const float FILTER_CONTROL_HEIGHT = 100;
|
|
||||||
public const float FOOTER_HEIGHT = 50;
|
|
||||||
protected const float BACKGROUND_BLUR = 20;
|
protected const float BACKGROUND_BLUR = 20;
|
||||||
private const float left_area_padding = 20;
|
private const float left_area_padding = 20;
|
||||||
|
|
||||||
@ -123,7 +121,7 @@ namespace osu.Game.Screens.Select
|
|||||||
Size = new Vector2(wedged_container_size.X, 1),
|
Size = new Vector2(wedged_container_size.X, 1),
|
||||||
Padding = new MarginPadding
|
Padding = new MarginPadding
|
||||||
{
|
{
|
||||||
Bottom = FOOTER_HEIGHT,
|
Bottom = Footer.HEIGHT,
|
||||||
Top = wedged_container_size.Y + left_area_padding,
|
Top = wedged_container_size.Y + left_area_padding,
|
||||||
Left = left_area_padding,
|
Left = left_area_padding,
|
||||||
Right = left_area_padding * 2,
|
Right = left_area_padding * 2,
|
||||||
@ -154,8 +152,8 @@ namespace osu.Game.Screens.Select
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Padding = new MarginPadding
|
Padding = new MarginPadding
|
||||||
{
|
{
|
||||||
Top = FILTER_CONTROL_HEIGHT,
|
Top = FilterControl.HEIGHT,
|
||||||
Bottom = FOOTER_HEIGHT
|
Bottom = Footer.HEIGHT
|
||||||
},
|
},
|
||||||
Child = Carousel = new BeatmapCarousel
|
Child = Carousel = new BeatmapCarousel
|
||||||
{
|
{
|
||||||
@ -171,7 +169,7 @@ namespace osu.Game.Screens.Select
|
|||||||
FilterControl = new FilterControl
|
FilterControl = new FilterControl
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = FILTER_CONTROL_HEIGHT,
|
Height = FilterControl.HEIGHT,
|
||||||
FilterChanged = c => Carousel.Filter(c),
|
FilterChanged = c => Carousel.Filter(c),
|
||||||
Background = { Width = 2 },
|
Background = { Width = 2 },
|
||||||
Exit = () =>
|
Exit = () =>
|
||||||
@ -210,7 +208,7 @@ namespace osu.Game.Screens.Select
|
|||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Margin = new MarginPadding { Bottom = FOOTER_HEIGHT },
|
Margin = new MarginPadding { Bottom = Footer.HEIGHT },
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
BeatmapOptions = new BeatmapOptionsOverlay(),
|
BeatmapOptions = new BeatmapOptionsOverlay(),
|
||||||
@ -222,13 +220,7 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Footer = new Footer
|
Footer = new Footer()
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.X,
|
|
||||||
Height = FOOTER_HEIGHT,
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user