mirror of
https://github.com/ppy/osu.git
synced 2025-01-21 08:12:56 +08:00
Merge pull request #16782 from peppy/revert-invalidation-reductions
Revert "Merge pull request #16716 from peppy/carousel-less-invalidations"
This commit is contained in:
commit
885a285d13
@ -925,8 +925,10 @@ namespace osu.Game.Screens.Select
|
|||||||
// child items (difficulties) are still visible.
|
// child items (difficulties) are still visible.
|
||||||
item.Header.X = offsetX(dist, visibleHalfHeight) - (parent?.X ?? 0);
|
item.Header.X = offsetX(dist, visibleHalfHeight) - (parent?.X ?? 0);
|
||||||
|
|
||||||
// We are applying alpha to the header here such that we can layer alpha transformations on top.
|
// We are applying a multiplicative alpha (which is internally done by nesting an
|
||||||
item.Header.Alpha = Math.Clamp(1.75f - 1.5f * dist, 0, 1);
|
// additional container and setting that container's alpha) such that we can
|
||||||
|
// layer alpha transformations on top.
|
||||||
|
item.SetMultiplicativeAlpha(Math.Clamp(1.75f - 1.5f * dist, 0, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum PendingScrollOperation
|
private enum PendingScrollOperation
|
||||||
|
@ -21,6 +21,8 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
{
|
{
|
||||||
public class CarouselHeader : Container
|
public class CarouselHeader : Container
|
||||||
{
|
{
|
||||||
|
public Container BorderContainer;
|
||||||
|
|
||||||
public readonly Bindable<CarouselItemState> State = new Bindable<CarouselItemState>(CarouselItemState.NotSelected);
|
public readonly Bindable<CarouselItemState> State = new Bindable<CarouselItemState>(CarouselItemState.NotSelected);
|
||||||
|
|
||||||
private readonly HoverLayer hoverLayer;
|
private readonly HoverLayer hoverLayer;
|
||||||
@ -35,14 +37,17 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
Height = DrawableCarouselItem.MAX_HEIGHT;
|
Height = DrawableCarouselItem.MAX_HEIGHT;
|
||||||
|
|
||||||
Masking = true;
|
InternalChild = BorderContainer = new Container
|
||||||
CornerRadius = corner_radius;
|
|
||||||
BorderColour = new Color4(221, 255, 255, 255);
|
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
|
||||||
{
|
{
|
||||||
Content,
|
RelativeSizeAxes = Axes.Both,
|
||||||
hoverLayer = new HoverLayer()
|
Masking = true,
|
||||||
|
CornerRadius = corner_radius,
|
||||||
|
BorderColour = new Color4(221, 255, 255, 255),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
Content,
|
||||||
|
hoverLayer = new HoverLayer()
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,21 +66,21 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
case CarouselItemState.NotSelected:
|
case CarouselItemState.NotSelected:
|
||||||
hoverLayer.InsetForBorder = false;
|
hoverLayer.InsetForBorder = false;
|
||||||
|
|
||||||
BorderThickness = 0;
|
BorderContainer.BorderThickness = 0;
|
||||||
EdgeEffect = new EdgeEffectParameters
|
BorderContainer.EdgeEffect = new EdgeEffectParameters
|
||||||
{
|
{
|
||||||
Type = EdgeEffectType.Shadow,
|
Type = EdgeEffectType.Shadow,
|
||||||
Offset = new Vector2(1),
|
Offset = new Vector2(1),
|
||||||
Radius = 10,
|
Radius = 10,
|
||||||
Colour = Color4.Black.Opacity(0.5f),
|
Colour = Color4.Black.Opacity(100),
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CarouselItemState.Selected:
|
case CarouselItemState.Selected:
|
||||||
hoverLayer.InsetForBorder = true;
|
hoverLayer.InsetForBorder = true;
|
||||||
|
|
||||||
BorderThickness = border_thickness;
|
BorderContainer.BorderThickness = border_thickness;
|
||||||
EdgeEffect = new EdgeEffectParameters
|
BorderContainer.EdgeEffect = new EdgeEffectParameters
|
||||||
{
|
{
|
||||||
Type = EdgeEffectType.Glow,
|
Type = EdgeEffectType.Glow,
|
||||||
Colour = new Color4(130, 204, 255, 150),
|
Colour = new Color4(130, 204, 255, 150),
|
||||||
|
@ -36,9 +36,9 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The height of a carousel beatmap, including vertical spacing.
|
/// The height of a carousel beatmap, including vertical spacing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const float HEIGHT = header_height + CAROUSEL_BEATMAP_SPACING;
|
public const float HEIGHT = height + CAROUSEL_BEATMAP_SPACING;
|
||||||
|
|
||||||
private const float header_height = MAX_HEIGHT * 0.6f;
|
private const float height = MAX_HEIGHT * 0.6f;
|
||||||
|
|
||||||
private readonly BeatmapInfo beatmapInfo;
|
private readonly BeatmapInfo beatmapInfo;
|
||||||
|
|
||||||
@ -67,18 +67,16 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
private CancellationTokenSource starDifficultyCancellationSource;
|
private CancellationTokenSource starDifficultyCancellationSource;
|
||||||
|
|
||||||
public DrawableCarouselBeatmap(CarouselBeatmap panel)
|
public DrawableCarouselBeatmap(CarouselBeatmap panel)
|
||||||
: base(header_height)
|
|
||||||
{
|
{
|
||||||
beatmapInfo = panel.BeatmapInfo;
|
beatmapInfo = panel.BeatmapInfo;
|
||||||
Item = panel;
|
Item = panel;
|
||||||
|
|
||||||
// Difficulty panels should start hidden for a better initial effect.
|
|
||||||
Hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(BeatmapManager manager, SongSelect songSelect)
|
private void load(BeatmapManager manager, SongSelect songSelect)
|
||||||
{
|
{
|
||||||
|
Header.Height = height;
|
||||||
|
|
||||||
if (songSelect != null)
|
if (songSelect != null)
|
||||||
{
|
{
|
||||||
startRequested = b => songSelect.FinaliseSelection(b);
|
startRequested = b => songSelect.FinaliseSelection(b);
|
||||||
|
@ -122,10 +122,12 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
background.DelayedLoadComplete += d => d.FadeInFromZero(750, Easing.OutQuint);
|
background.DelayedLoadComplete += fadeContentIn;
|
||||||
mainFlow.DelayedLoadComplete += d => d.FadeInFromZero(500, Easing.OutQuint);
|
mainFlow.DelayedLoadComplete += fadeContentIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void fadeContentIn(Drawable d) => d.FadeInFromZero(750, Easing.OutQuint);
|
||||||
|
|
||||||
protected override void Deselected()
|
protected override void Deselected()
|
||||||
{
|
{
|
||||||
base.Deselected();
|
base.Deselected();
|
||||||
|
@ -60,10 +60,12 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DrawableCarouselItem(float headerHeight = MAX_HEIGHT)
|
protected DrawableCarouselItem()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
|
|
||||||
|
Alpha = 0;
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
MovementContainer = new Container
|
MovementContainer = new Container
|
||||||
@ -71,20 +73,18 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
Header = new CarouselHeader
|
Header = new CarouselHeader(),
|
||||||
{
|
|
||||||
Height = headerHeight,
|
|
||||||
},
|
|
||||||
Content = new Container
|
Content = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Y = headerHeight,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetMultiplicativeAlpha(float alpha) => Header.BorderContainer.Alpha = alpha;
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
@ -92,6 +92,12 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
UpdateItem();
|
UpdateItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
Content.Y = Header.Height;
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual void UpdateItem()
|
protected virtual void UpdateItem()
|
||||||
{
|
{
|
||||||
if (item == null)
|
if (item == null)
|
||||||
@ -115,56 +121,29 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
|
|
||||||
private void onStateChange(ValueChangedEvent<bool> _) => Scheduler.AddOnce(ApplyState);
|
private void onStateChange(ValueChangedEvent<bool> _) => Scheduler.AddOnce(ApplyState);
|
||||||
|
|
||||||
private CarouselItemState? lastAppliedState;
|
|
||||||
|
|
||||||
protected virtual void ApplyState()
|
protected virtual void ApplyState()
|
||||||
{
|
{
|
||||||
|
// Use the fact that we know the precise height of the item from the model to avoid the need for AutoSize overhead.
|
||||||
|
// Additionally, AutoSize doesn't work well due to content starting off-screen and being masked away.
|
||||||
|
Height = Item.TotalHeight;
|
||||||
|
|
||||||
Debug.Assert(Item != null);
|
Debug.Assert(Item != null);
|
||||||
|
|
||||||
if (lastAppliedState != Item.State.Value)
|
switch (Item.State.Value)
|
||||||
{
|
{
|
||||||
lastAppliedState = Item.State.Value;
|
case CarouselItemState.NotSelected:
|
||||||
|
Deselected();
|
||||||
|
break;
|
||||||
|
|
||||||
// Use the fact that we know the precise height of the item from the model to avoid the need for AutoSize overhead.
|
case CarouselItemState.Selected:
|
||||||
// Additionally, AutoSize doesn't work well due to content starting off-screen and being masked away.
|
Selected();
|
||||||
Height = Item.TotalHeight;
|
break;
|
||||||
|
|
||||||
switch (lastAppliedState)
|
|
||||||
{
|
|
||||||
case CarouselItemState.NotSelected:
|
|
||||||
Deselected();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CarouselItemState.Selected:
|
|
||||||
Selected();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Item.Visible)
|
if (!Item.Visible)
|
||||||
Hide();
|
this.FadeOut(300, Easing.OutQuint);
|
||||||
else
|
else
|
||||||
Show();
|
this.FadeIn(250);
|
||||||
}
|
|
||||||
|
|
||||||
private bool isVisible = true;
|
|
||||||
|
|
||||||
public override void Show()
|
|
||||||
{
|
|
||||||
if (isVisible)
|
|
||||||
return;
|
|
||||||
|
|
||||||
isVisible = true;
|
|
||||||
this.FadeIn(250);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Hide()
|
|
||||||
{
|
|
||||||
if (!isVisible)
|
|
||||||
return;
|
|
||||||
|
|
||||||
isVisible = false;
|
|
||||||
this.FadeOut(300, Easing.OutQuint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Selected()
|
protected virtual void Selected()
|
||||||
|
Loading…
Reference in New Issue
Block a user