1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 16:27:26 +08:00

Merge remote-tracking branch 'upstream/master' into update-flow

This commit is contained in:
Dean Herbert 2017-03-04 23:28:39 +09:00
commit e12d89529c
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
7 changed files with 99 additions and 109 deletions

View File

@ -12,6 +12,7 @@ namespace osu.Game.Modes.Osu
: base(hitObjectCount)
{
Health.Value = 1;
Accuracy.Value = 1;
}
protected override void UpdateCalculations(JudgementInfo judgement)

View File

@ -18,10 +18,6 @@ namespace osu.Game.Beatmaps.Drawables
public override bool RemoveWhenNotAlive => false;
public bool IsOnScreen;
public override bool IsAlive => IsOnScreen && base.IsAlive;
private Container nestedContainer;
protected override Container<Drawable> Content => nestedContainer;

View File

@ -26,7 +26,7 @@ namespace osu.Game.Graphics.UserInterface
public PercentageCounter()
{
DisplayedCountSpriteText.FixedWidth = true;
Count = 1.0f;
Count = DisplayedCount = 1.0f;
}
protected override string FormatCount(float count)

View File

@ -33,7 +33,7 @@ namespace osu.Game.Overlays.Mods
private FillFlowContainer<ModSection> modSectionsContainer;
public Bindable<Mod[]> SelectedMods = new Bindable<Mod[]>();
public readonly Bindable<Mod[]> SelectedMods = new Bindable<Mod[]>();
public readonly Bindable<PlayMode> PlayMode = new Bindable<PlayMode>();
@ -95,8 +95,6 @@ namespace osu.Game.Overlays.Mods
section.ButtonsContainer.MoveToX(100f, APPEAR_DURATION, EasingTypes.InSine);
section.ButtonsContainer.FadeOut(APPEAR_DURATION, EasingTypes.InSine);
}
TriggerFocusLost();
}
protected override void PopIn()
@ -112,8 +110,6 @@ namespace osu.Game.Overlays.Mods
section.ButtonsContainer.MoveToX(0, button_duration, EasingTypes.OutQuint);
section.ButtonsContainer.FadeIn(button_duration, EasingTypes.OutQuint);
}
Schedule(TriggerFocusContention);
}
public void DeselectAll()

View File

@ -9,6 +9,8 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using OpenTK;
using osu.Framework.Graphics.Transforms;
using osu.Framework.Graphics.Primitives;
using System;
namespace osu.Game.Overlays
{
@ -86,9 +88,10 @@ namespace osu.Game.Overlays
AddInternal(wavesContainer = new Container<Wave>
{
RelativeSizeAxes = Axes.Both,
RelativeSizeAxes = Axes.X,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Masking = true,
Children = new[]
{
firstWave = new Wave
@ -123,19 +126,13 @@ namespace osu.Game.Overlays
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White.Opacity(50),
},
},
});
}
protected override void PopIn()
{
base.PopIn();
foreach (var w in wavesContainer.Children)
w.State = Visibility.Visible;
@ -145,6 +142,8 @@ namespace osu.Game.Overlays
protected override void PopOut()
{
base.PopOut();
contentContainer.FadeOut(DISAPPEAR_DURATION, EasingTypes.In);
contentContainer.MoveToY(DrawHeight * 2f, DISAPPEAR_DURATION, EasingTypes.In);
@ -152,14 +151,23 @@ namespace osu.Game.Overlays
w.State = Visibility.Hidden;
}
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
// This is done as an optimization, such that invisible parts of the waves
// are masked away, and thus do not consume fill rate.
wavesContainer.Height = Math.Max(0, DrawHeight - (contentContainer.DrawHeight - contentContainer.Y));
}
private class Wave : Container, IStateful<Visibility>
{
public float FinalPosition;
public Wave()
{
RelativeSizeAxes = Axes.Both;
Size = new Vector2(1.5f);
RelativeSizeAxes = Axes.X;
Width = 1.5f;
Masking = true;
EdgeEffect = new EdgeEffect
{
@ -177,6 +185,15 @@ namespace osu.Game.Overlays
};
}
protected override void Update()
{
base.Update();
// We can not use RelativeSizeAxes for Height, because the height
// of our parent diminishes as the content moves up.
Height = Parent.Parent.DrawSize.Y * 1.5f;
}
private Visibility state;
public Visibility State
{
@ -188,7 +205,7 @@ namespace osu.Game.Overlays
switch (value)
{
case Visibility.Hidden:
MoveToY(DrawHeight / Height, DISAPPEAR_DURATION, easing_hide);
MoveToY(Parent.Parent.DrawSize.Y, DISAPPEAR_DURATION, easing_hide);
break;
case Visibility.Visible:
MoveToY(FinalPosition, APPEAR_DURATION, easing_show);

View File

@ -16,6 +16,7 @@ using osu.Framework.Input;
using OpenTK.Input;
using System.Collections;
using osu.Framework.MathUtils;
using System.Diagnostics;
namespace osu.Game.Screens.Select
{
@ -23,73 +24,33 @@ namespace osu.Game.Screens.Select
{
private Container<Panel> scrollableContent;
private List<BeatmapGroup> groups = new List<BeatmapGroup>();
private List<Panel> panels = new List<Panel>();
public BeatmapGroup SelectedGroup { get; private set; }
public BeatmapPanel SelectedPanel { get; private set; }
private List<float> yPositions = new List<float>();
private CarouselLifetimeList<Panel> lifetime;
public CarouselContainer()
{
DistanceDecayJump = 0.01;
Add(scrollableContent = new Container<Panel>(lifetime = new CarouselLifetimeList<Panel>(DepthComparer))
Add(scrollableContent = new Container<Panel>
{
RelativeSizeAxes = Axes.X,
});
}
internal class CarouselLifetimeList<T> : LifetimeList<Panel>
{
public CarouselLifetimeList(IComparer<Panel> comparer)
: base(comparer)
{
}
public int StartIndex;
public int EndIndex;
public override bool Update(FrameTimeInfo time)
{
bool anyAliveChanged = false;
//check existing items to make sure they haven't died.
foreach (var item in AliveItems.ToArray())
{
item.UpdateTime(time);
if (!item.IsAlive)
{
//todo: make this more efficient
int i = IndexOf(item);
anyAliveChanged |= CheckItem(item, ref i);
}
}
//handle custom range
for (int i = StartIndex; i < EndIndex; i++)
{
var item = this[i];
item.UpdateTime(time);
anyAliveChanged |= CheckItem(item, ref i);
}
return anyAliveChanged;
}
}
public void AddGroup(BeatmapGroup group)
{
group.State = BeatmapGroupState.Collapsed;
groups.Add(group);
group.Header.Depth = -scrollableContent.Children.Count();
scrollableContent.Add(group.Header);
panels.Add(group.Header);
group.Header.UpdateClock(Clock);
foreach (BeatmapPanel panel in group.BeatmapPanels)
{
panel.Depth = -scrollableContent.Children.Count();
scrollableContent.Add(panel);
panels.Add(panel);
panel.UpdateClock(Clock);
}
computeYPositions();
@ -98,6 +59,9 @@ namespace osu.Game.Screens.Select
public void RemoveGroup(BeatmapGroup group)
{
groups.Remove(group);
foreach (var p in group.BeatmapPanels)
panels.Remove(p);
scrollableContent.Remove(group.Header);
scrollableContent.Remove(group.BeatmapPanels);
@ -107,7 +71,7 @@ namespace osu.Game.Screens.Select
private void movePanel(Panel panel, bool advance, bool animated, ref float currentY)
{
yPositions.Add(currentY);
panel.MoveToY(currentY, animated && (panel.IsOnScreen || panel.State != PanelSelectedState.Hidden) ? 750 : 0, EasingTypes.OutExpo);
panel.MoveToY(currentY, animated ? 750 : 0, EasingTypes.OutExpo);
if (advance)
currentY += panel.DrawHeight + 5;
@ -172,14 +136,16 @@ namespace osu.Game.Screens.Select
var panel = group.BeatmapPanels.FirstOrDefault(p => p.Beatmap.Equals(beatmap));
if (panel != null)
{
SelectGroup(group, panel, animated);
selectGroup(group, panel, animated);
return;
}
}
}
public void SelectGroup(BeatmapGroup group, BeatmapPanel panel, bool animated = true)
private void selectGroup(BeatmapGroup group, BeatmapPanel panel, bool animated = true)
{
Trace.Assert(group.BeatmapPanels.Contains(panel), @"Selected panel must be in provided group");
if (SelectedGroup != null && SelectedGroup != group && SelectedGroup.State != BeatmapGroupState.Hidden)
SelectedGroup.State = BeatmapGroupState.Collapsed;
@ -194,19 +160,20 @@ namespace osu.Game.Screens.Select
public void Sort(FilterControl.SortMode mode)
{
List<BeatmapGroup> sortedGroups = new List<BeatmapGroup>(groups);
switch (mode)
{
case FilterControl.SortMode.Artist:
groups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Artist, y.BeatmapSet.Metadata.Artist));
sortedGroups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Artist, y.BeatmapSet.Metadata.Artist));
break;
case FilterControl.SortMode.Title:
groups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Title, y.BeatmapSet.Metadata.Title));
sortedGroups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Title, y.BeatmapSet.Metadata.Title));
break;
case FilterControl.SortMode.Author:
groups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Author, y.BeatmapSet.Metadata.Author));
sortedGroups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Author, y.BeatmapSet.Metadata.Author));
break;
case FilterControl.SortMode.Difficulty:
groups.Sort((x, y) =>
sortedGroups.Sort((x, y) =>
{
float xAverage = 0, yAverage = 0;
int counter = 0;
@ -232,22 +199,23 @@ namespace osu.Game.Screens.Select
default:
throw new NotImplementedException();
}
scrollableContent.Clear(false);
lifetime.Clear();
foreach (BeatmapGroup group in groups)
{
group.Header.Depth = -scrollableContent.Children.Count();
scrollableContent.Add(group.Header);
foreach (BeatmapPanel panel in group.BeatmapPanels)
{
panel.Depth = -scrollableContent.Children.Count();
scrollableContent.Add(panel);
}
}
panels.Clear();
groups.Clear();
foreach (BeatmapGroup group in sortedGroups)
AddGroup(group);
}
/// <summary>
/// Computes the x-offset of currently visible panels. Makes the carousel appear round.
/// </summary>
/// <param name="dist">
/// Vertical distance from the center of the carousel container
/// ranging from -1 to 1.
/// </param>
/// <param name="halfHeight">Half the height of the carousel container.</param>
private static float offsetX(float dist, float halfHeight)
{
// The radius of the circle the carousel moves on.
@ -286,34 +254,46 @@ namespace osu.Game.Screens.Select
{
base.Update();
// Determine which items stopped being on screen for future removal from the lifetimelist.
float drawHeight = DrawHeight;
float halfHeight = drawHeight / 2;
foreach (Panel p in lifetime.AliveItems)
// Remove all panels that should no longer be on-screen
scrollableContent.RemoveAll(delegate (Panel p)
{
float panelPosY = p.Position.Y;
p.IsOnScreen = panelPosY >= Current - p.DrawHeight && panelPosY <= Current + drawHeight;
updatePanel(p, halfHeight);
}
bool remove = panelPosY < Current - p.DrawHeight || panelPosY > Current + drawHeight || !p.IsPresent;
return remove;
});
// Find index range of all panels that should be on-screen
Trace.Assert(panels.Count == yPositions.Count);
// Determine range of indices for items that are now definitely on screen to be added
// to the lifetimelist in the future.
int firstIndex = yPositions.BinarySearch(Current - Panel.MAX_HEIGHT);
if (firstIndex < 0) firstIndex = ~firstIndex;
int lastIndex = yPositions.BinarySearch(Current + drawHeight);
if (lastIndex < 0) lastIndex = ~lastIndex;
lifetime.StartIndex = firstIndex;
lifetime.EndIndex = lastIndex;
// Add those panels within the previously found index range that should be displayed.
for (int i = firstIndex; i < lastIndex; ++i)
{
Panel p = lifetime[i];
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);
Panel panel = panels[i];
if (panel.State == PanelSelectedState.Hidden)
continue;
// Only add if we're not already part of the content.
if (!scrollableContent.Contains(panel))
{
// Makes sure headers are always _below_ panels,
// and depth flows downward.
panel.Depth = i + (panel is BeatmapSetHeader ? panels.Count : 0);
scrollableContent.Add(panel);
}
}
// Update externally controlled state of currently visible panels
// (e.g. x-offset and opacity).
float halfHeight = drawHeight / 2;
foreach (Panel p in scrollableContent.Children)
updatePanel(p, halfHeight);
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
@ -355,7 +335,7 @@ namespace osu.Game.Screens.Select
if (i >= 0 && i < SelectedGroup.BeatmapPanels.Count)
{
//changing difficulty panel, not set.
SelectGroup(SelectedGroup, SelectedGroup.BeatmapPanels[i]);
selectGroup(SelectedGroup, SelectedGroup.BeatmapPanels[i]);
return;
}
}
@ -378,11 +358,14 @@ namespace osu.Game.Screens.Select
{
if (groups.Count < 1)
return;
BeatmapGroup group = groups[RNG.Next(groups.Count)];
BeatmapPanel panel = group?.BeatmapPanels.First();
if (panel == null)
return;
SelectGroup(group, panel);
selectGroup(group, panel);
}
public IEnumerator<BeatmapGroup> GetEnumerator() => groups.GetEnumerator();

View File

@ -396,6 +396,7 @@ namespace osu.Game.Screens.Select
{
beatmapGroups.Add(group);
group.State = BeatmapGroupState.Collapsed;
carousel.AddGroup(group);
filterChanged(false, false);
@ -403,11 +404,7 @@ namespace osu.Game.Screens.Select
if (Beatmap == null || select)
carousel.SelectBeatmap(beatmapSet.Beatmaps.First());
else
{
var panel = group.BeatmapPanels.FirstOrDefault(p => p.Beatmap.Equals(Beatmap.BeatmapInfo));
if (panel != null)
carousel.SelectGroup(group, panel);
}
carousel.SelectBeatmap(Beatmap.BeatmapInfo);
}));
}