mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Fix laggy animations, incorrect hiding logic.
This commit is contained in:
@ -1,23 +1,23 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using osu.Framework.Caching;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Transformations;
|
||||
using osu.Game.Database;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Lists;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using OpenTK;
|
||||
using osu.Framework.Caching;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Transformations;
|
||||
using osu.Game.Database;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Lists;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Framework.Input;
|
||||
using OpenTK.Input;
|
||||
using System.Collections;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Framework.MathUtils;
|
||||
|
||||
namespace osu.Game.Screens.Select
|
||||
{
|
||||
@ -97,10 +97,10 @@ namespace osu.Game.Screens.Select
|
||||
computeYPositions();
|
||||
}
|
||||
|
||||
private void movePanel(Panel panel, bool advance, ref float currentY)
|
||||
private void movePanel(Panel panel, bool advance, bool animated, ref float currentY)
|
||||
{
|
||||
yPositions.Add(currentY);
|
||||
panel.MoveToY(currentY, 750, EasingTypes.OutExpo);
|
||||
panel.MoveToY(currentY, animated && (panel.IsOnScreen || panel.State != PanelSelectedState.Hidden) ? 750 : 0, EasingTypes.OutExpo);
|
||||
|
||||
if (advance)
|
||||
currentY += panel.DrawHeight + 5;
|
||||
@ -110,7 +110,7 @@ namespace osu.Game.Screens.Select
|
||||
/// Computes the target Y positions for every panel in the carousel.
|
||||
/// </summary>
|
||||
/// <returns>The Y position of the currently selected panel.</returns>
|
||||
private float computeYPositions()
|
||||
private float computeYPositions(bool animated = true)
|
||||
{
|
||||
yPositions.Clear();
|
||||
|
||||
@ -119,7 +119,7 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
foreach (BeatmapGroup group in groups)
|
||||
{
|
||||
movePanel(group.Header, group.State != BeatmapGroupState.Hidden, ref currentY);
|
||||
movePanel(group.Header, group.State != BeatmapGroupState.Hidden, animated, ref currentY);
|
||||
|
||||
if (group.State == BeatmapGroupState.Expanded)
|
||||
{
|
||||
@ -137,7 +137,7 @@ namespace osu.Game.Screens.Select
|
||||
if (panel.Alpha == 0)
|
||||
panel.MoveToY(headerY);
|
||||
|
||||
movePanel(panel, true, ref currentY);
|
||||
movePanel(panel, true, animated, ref currentY);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -147,7 +147,7 @@ namespace osu.Game.Screens.Select
|
||||
foreach (BeatmapPanel panel in group.BeatmapPanels)
|
||||
{
|
||||
panel.MoveToX(0, 500, EasingTypes.OutExpo);
|
||||
movePanel(panel, false, ref currentY);
|
||||
movePanel(panel, false, animated, ref currentY);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -158,20 +158,20 @@ namespace osu.Game.Screens.Select
|
||||
return selectedY;
|
||||
}
|
||||
|
||||
public void SelectBeatmap(BeatmapInfo beatmap)
|
||||
public void SelectBeatmap(BeatmapInfo beatmap, bool animated = true)
|
||||
{
|
||||
foreach (BeatmapGroup group in groups)
|
||||
{
|
||||
var panel = group.BeatmapPanels.FirstOrDefault(p => p.Beatmap.Equals(beatmap));
|
||||
if (panel != null)
|
||||
{
|
||||
SelectGroup(group, panel);
|
||||
SelectGroup(group, panel, animated);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SelectGroup(BeatmapGroup group, BeatmapPanel panel)
|
||||
public void SelectGroup(BeatmapGroup group, BeatmapPanel panel, bool animated = true)
|
||||
{
|
||||
if (SelectedGroup != null && SelectedGroup != group)
|
||||
SelectedGroup.State = BeatmapGroupState.Collapsed;
|
||||
@ -180,8 +180,8 @@ namespace osu.Game.Screens.Select
|
||||
panel.State = PanelSelectedState.Selected;
|
||||
SelectedPanel = panel;
|
||||
|
||||
float selectedY = computeYPositions();
|
||||
ScrollTo(selectedY);
|
||||
float selectedY = computeYPositions(animated);
|
||||
ScrollTo(selectedY, animated);
|
||||
}
|
||||
|
||||
private static float offsetX(float dist, float halfHeight)
|
||||
@ -246,18 +246,12 @@ namespace osu.Game.Screens.Select
|
||||
for (int i = firstIndex; i < lastIndex; ++i)
|
||||
{
|
||||
Panel p = Lifetime[i];
|
||||
p.IsOnScreen = true;
|
||||
if (p.State != PanelSelectedState.Hidden)
|
||||
p.IsOnScreen = true; //we don't want to update the on-screen state of hidden pannels as they have incorrect (stacked) y values.
|
||||
updatePanel(p, halfHeight);
|
||||
}
|
||||
}
|
||||
|
||||
public void InvalidateVisible()
|
||||
{
|
||||
Lifetime.StartIndex = 0;
|
||||
Lifetime.EndIndex = groups.Count - 1;
|
||||
computeYPositions();
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
int direction = 0;
|
||||
@ -298,17 +292,17 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
|
||||
return base.OnKeyDown(state, args);
|
||||
}
|
||||
|
||||
public void SelectRandom()
|
||||
{
|
||||
if (groups.Count < 1)
|
||||
return;
|
||||
}
|
||||
|
||||
public void SelectRandom()
|
||||
{
|
||||
if (groups.Count < 1)
|
||||
return;
|
||||
BeatmapGroup group = groups[RNG.Next(groups.Count)];
|
||||
BeatmapPanel panel = group?.BeatmapPanels.First();
|
||||
if (panel == null)
|
||||
return;
|
||||
SelectGroup(group, panel);
|
||||
BeatmapPanel panel = group?.BeatmapPanels.First();
|
||||
if (panel == null)
|
||||
return;
|
||||
SelectGroup(group, panel);
|
||||
}
|
||||
|
||||
public IEnumerator<BeatmapGroup> GetEnumerator() => groups.GetEnumerator();
|
||||
|
Reference in New Issue
Block a user