mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Merge branch 'master' of git://github.com/ppy/osu into caps-warning
# Conflicts: # osu.Game/Graphics/UserInterface/OsuPasswordTextBox.cs
This commit is contained in:
@ -26,6 +26,7 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
|
||||
Add(Sprite = new Sprite
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Colour = Color4.DarkGray,
|
||||
|
@ -2,12 +2,10 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.MathUtils;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using System;
|
||||
using osu.Framework.Graphics.OpenGL;
|
||||
using osu.Framework.Graphics.Shaders;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using OpenTK.Graphics.ES30;
|
||||
@ -16,6 +14,7 @@ using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Allocation;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics.Batches;
|
||||
using osu.Framework.Graphics.OpenGL.Vertices;
|
||||
using osu.Framework.Lists;
|
||||
|
||||
namespace osu.Game.Graphics.Backgrounds
|
||||
@ -56,7 +55,7 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
/// <summary>
|
||||
/// Whether we should drop-off alpha values of triangles more quickly to improve
|
||||
/// the visual appearance of fading. This defaults to on as it is generally more
|
||||
/// aesthetically pleasing, but should be turned off in <see cref="BufferedContainer{T}"/>s.
|
||||
/// aesthetically pleasing, but should be turned off in buffered containers.
|
||||
/// </summary>
|
||||
public bool HideAlphaDiscrepancies = true;
|
||||
|
||||
|
@ -23,12 +23,24 @@ namespace osu.Game.Graphics.Containers
|
||||
/// </summary>
|
||||
protected double EarlyActivationMilliseconds;
|
||||
|
||||
/// <summary>
|
||||
/// The time in milliseconds until the next beat.
|
||||
/// </summary>
|
||||
public double TimeUntilNextBeat { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The time in milliseconds since the last beat
|
||||
/// </summary>
|
||||
public double TimeSinceLastBeat { get; private set; }
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
if (Beatmap.Value?.Track == null)
|
||||
var track = Beatmap.Value.Track;
|
||||
|
||||
if (track == null)
|
||||
return;
|
||||
|
||||
double currentTrackTime = Beatmap.Value.Track.CurrentTime + EarlyActivationMilliseconds;
|
||||
double currentTrackTime = track.Length > 0 ? track.CurrentTime + EarlyActivationMilliseconds : Clock.CurrentTime;
|
||||
|
||||
TimingControlPoint timingPoint = Beatmap.Value.Beatmap.ControlPointInfo.TimingPointAt(currentTrackTime);
|
||||
EffectControlPoint effectPoint = Beatmap.Value.Beatmap.ControlPointInfo.EffectPointAt(currentTrackTime);
|
||||
@ -42,12 +54,16 @@ namespace osu.Game.Graphics.Containers
|
||||
if (currentTrackTime < timingPoint.Time)
|
||||
beatIndex--;
|
||||
|
||||
if (timingPoint == lastTimingPoint && beatIndex == lastBeat)
|
||||
TimeUntilNextBeat = (timingPoint.Time - currentTrackTime) % timingPoint.BeatLength;
|
||||
if (TimeUntilNextBeat < 0)
|
||||
TimeUntilNextBeat += timingPoint.BeatLength;
|
||||
|
||||
TimeSinceLastBeat = timingPoint.BeatLength - TimeUntilNextBeat;
|
||||
|
||||
if (timingPoint.Equals(lastTimingPoint) && beatIndex == lastBeat)
|
||||
return;
|
||||
|
||||
double offsetFromBeat = (timingPoint.Time - currentTrackTime) % timingPoint.BeatLength;
|
||||
|
||||
using (BeginDelayedSequence(offsetFromBeat, true))
|
||||
using (BeginDelayedSequence(-TimeSinceLastBeat, true))
|
||||
OnNewBeat(beatIndex, timingPoint, effectPoint, Beatmap.Value.Track.CurrentAmplitudes);
|
||||
|
||||
lastBeat = beatIndex;
|
||||
|
62
osu.Game/Graphics/Containers/ConstrainedIconContainer.cs
Normal file
62
osu.Game/Graphics/Containers/ConstrainedIconContainer.cs
Normal file
@ -0,0 +1,62 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Graphics.Containers
|
||||
{
|
||||
/// <summary>
|
||||
/// Display an icon that is forced to scale to the size of this container.
|
||||
/// </summary>
|
||||
public class ConstrainedIconContainer : CompositeDrawable
|
||||
{
|
||||
public Drawable Icon
|
||||
{
|
||||
get
|
||||
{
|
||||
return InternalChild;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
InternalChild = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines an edge effect of this <see cref="Container"/>.
|
||||
/// Edge effects are e.g. glow or a shadow.
|
||||
/// Only has an effect when <see cref="CompositeDrawable.Masking"/> is true.
|
||||
/// </summary>
|
||||
public new EdgeEffectParameters EdgeEffect
|
||||
{
|
||||
get { return base.EdgeEffect; }
|
||||
set { base.EdgeEffect = value; }
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
if (InternalChildren.Count > 0 && InternalChild.DrawSize.X > 0)
|
||||
{
|
||||
// We're modifying scale here for a few reasons
|
||||
// - Guarantees correctness if BorderWidth is being used
|
||||
// - If we were to use RelativeSize/FillMode, we'd need to set the Icon's RelativeSizeAxes directly.
|
||||
// We can't do this because we would need access to AutoSizeAxes to set it to none.
|
||||
// Other issues come up along the way too, so it's not a good solution.
|
||||
var fitScale = Math.Min(DrawSize.X / InternalChild.DrawSize.X, DrawSize.Y / InternalChild.DrawSize.Y);
|
||||
InternalChild.Scale = new Vector2(fitScale);
|
||||
InternalChild.Anchor = Anchor.Centre;
|
||||
InternalChild.Origin = Anchor.Centre;
|
||||
}
|
||||
}
|
||||
|
||||
public ConstrainedIconContainer()
|
||||
{
|
||||
Masking = true;
|
||||
}
|
||||
}
|
||||
}
|
35
osu.Game/Graphics/Containers/OsuClickableContainer.cs
Normal file
35
osu.Game/Graphics/Containers/OsuClickableContainer.cs
Normal file
@ -0,0 +1,35 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input;
|
||||
|
||||
namespace osu.Game.Graphics.Containers
|
||||
{
|
||||
public class OsuClickableContainer : ClickableContainer
|
||||
{
|
||||
protected SampleChannel SampleClick, SampleHover;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
SampleHover = audio.Sample.Get(@"UI/generic-hover");
|
||||
SampleClick = audio.Sample.Get(@"UI/generic-click");
|
||||
}
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
SampleHover?.Play();
|
||||
return base.OnHover(state);
|
||||
}
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
SampleClick?.Play();
|
||||
return base.OnClick(state);
|
||||
}
|
||||
}
|
||||
}
|
38
osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs
Normal file
38
osu.Game/Graphics/Containers/OsuFocusedOverlayContainer.cs
Normal file
@ -0,0 +1,38 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.Graphics.Containers
|
||||
{
|
||||
public class OsuFocusedOverlayContainer : FocusedOverlayContainer
|
||||
{
|
||||
private SampleChannel samplePopIn;
|
||||
private SampleChannel samplePopOut;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
samplePopIn = audio.Sample.Get(@"UI/melodic-5");
|
||||
samplePopOut = audio.Sample.Get(@"UI/melodic-4");
|
||||
|
||||
StateChanged += OsuFocusedOverlayContainer_StateChanged;
|
||||
}
|
||||
|
||||
private void OsuFocusedOverlayContainer_StateChanged(VisibilityContainer arg1, Visibility arg2)
|
||||
{
|
||||
switch (arg2)
|
||||
{
|
||||
case Visibility.Visible:
|
||||
samplePopIn?.Play();
|
||||
break;
|
||||
case Visibility.Hidden:
|
||||
samplePopOut?.Play();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
75
osu.Game/Graphics/Containers/OsuScrollContainer.cs
Normal file
75
osu.Game/Graphics/Containers/OsuScrollContainer.cs
Normal file
@ -0,0 +1,75 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input;
|
||||
using OpenTK.Input;
|
||||
|
||||
namespace osu.Game.Graphics.Containers
|
||||
{
|
||||
internal class OsuScrollContainer : ScrollContainer
|
||||
{
|
||||
/// <summary>
|
||||
/// Allows controlling the scroll bar from any position in the container using the right mouse button.
|
||||
/// Uses the value of <see cref="DistanceDecayOnRightMouseScrollbar"/> to smoothly scroll to the dragged location.
|
||||
/// </summary>
|
||||
public bool RightMouseScrollbar = false;
|
||||
|
||||
/// <summary>
|
||||
/// Controls the rate with which the target position is approached when performing a relative drag. Default is 0.02.
|
||||
/// </summary>
|
||||
public double DistanceDecayOnRightMouseScrollbar = 0.02;
|
||||
|
||||
private bool shouldPerformRightMouseScroll(InputState state) => RightMouseScrollbar && state.Mouse.IsPressed(MouseButton.Right);
|
||||
|
||||
private void scrollToRelative(float value) => ScrollTo(Clamp((value - Scrollbar.DrawSize[ScrollDim] / 2) / Scrollbar.Size[ScrollDim]), true, DistanceDecayOnRightMouseScrollbar);
|
||||
|
||||
private bool mouseScrollBarDragging;
|
||||
|
||||
protected override bool IsDragging => base.IsDragging || mouseScrollBarDragging;
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
{
|
||||
if (shouldPerformRightMouseScroll(state))
|
||||
{
|
||||
scrollToRelative(state.Mouse.Position[ScrollDim]);
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnMouseDown(state, args);
|
||||
}
|
||||
|
||||
protected override bool OnDrag(InputState state)
|
||||
{
|
||||
if (mouseScrollBarDragging)
|
||||
{
|
||||
scrollToRelative(state.Mouse.Position[ScrollDim]);
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnDrag(state);
|
||||
}
|
||||
|
||||
protected override bool OnDragStart(InputState state)
|
||||
{
|
||||
if (shouldPerformRightMouseScroll(state))
|
||||
{
|
||||
mouseScrollBarDragging = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnDragStart(state);
|
||||
}
|
||||
|
||||
protected override bool OnDragEnd(InputState state)
|
||||
{
|
||||
if (mouseScrollBarDragging)
|
||||
{
|
||||
mouseScrollBarDragging = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnDragEnd(state);
|
||||
}
|
||||
}
|
||||
}
|
21
osu.Game/Graphics/Containers/OsuTextFlowContainer.cs
Normal file
21
osu.Game/Graphics/Containers/OsuTextFlowContainer.cs
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Graphics.Containers
|
||||
{
|
||||
public class OsuTextFlowContainer : TextFlowContainer
|
||||
{
|
||||
public OsuTextFlowContainer(Action<SpriteText> defaultCreationParameters = null) : base(defaultCreationParameters)
|
||||
{
|
||||
}
|
||||
|
||||
protected override SpriteText CreateSpriteText() => new OsuSpriteText();
|
||||
|
||||
public void AddIcon(FontAwesome icon, Action<SpriteText> creationParameters = null) => AddText(((char)icon).ToString(), creationParameters);
|
||||
}
|
||||
}
|
@ -19,8 +19,6 @@ namespace osu.Game.Graphics.Containers
|
||||
|
||||
public ParallaxContainer()
|
||||
{
|
||||
AlwaysReceiveInput = true;
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
AddInternal(content = new Container
|
||||
{
|
||||
@ -36,20 +34,25 @@ namespace osu.Game.Graphics.Containers
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(UserInputManager input, OsuConfigManager config)
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
this.input = input;
|
||||
parallaxEnabled = config.GetBindable<bool>(OsuSetting.MenuParallax);
|
||||
parallaxEnabled.ValueChanged += delegate
|
||||
{
|
||||
if (!parallaxEnabled)
|
||||
{
|
||||
content.MoveTo(Vector2.Zero, firstUpdate ? 0 : 1000, EasingTypes.OutQuint);
|
||||
content.MoveTo(Vector2.Zero, firstUpdate ? 0 : 1000, Easing.OutQuint);
|
||||
content.Scale = new Vector2(1 + ParallaxAmount);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
input = GetContainingInputManager();
|
||||
}
|
||||
|
||||
private bool firstUpdate = true;
|
||||
|
||||
protected override void Update()
|
||||
@ -59,7 +62,7 @@ namespace osu.Game.Graphics.Containers
|
||||
if (parallaxEnabled)
|
||||
{
|
||||
Vector2 offset = input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.NativeState.Position) - DrawSize / 2;
|
||||
content.MoveTo(offset * ParallaxAmount, firstUpdate ? 0 : 1000, EasingTypes.OutQuint);
|
||||
content.MoveTo(offset * ParallaxAmount, firstUpdate ? 0 : 1000, Easing.OutQuint);
|
||||
content.Scale = new Vector2(1 + ParallaxAmount);
|
||||
}
|
||||
|
||||
|
@ -8,9 +8,10 @@ using osu.Framework.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.Graphics.Containers
|
||||
{
|
||||
public class ReverseDepthFillFlowContainer<T> : FillFlowContainer<T> where T : Drawable
|
||||
public class ReverseChildIDFillFlowContainer<T> : FillFlowContainer<T> where T : Drawable
|
||||
{
|
||||
protected override IComparer<Drawable> DepthComparer => new ReverseCreationOrderDepthComparer();
|
||||
protected override int Compare(Drawable x, Drawable y) => CompareReverseChildID(x, y);
|
||||
|
||||
protected override IEnumerable<Drawable> FlowingChildren => base.FlowingChildren.Reverse();
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
@ -13,11 +12,15 @@ namespace osu.Game.Graphics.Containers
|
||||
/// <summary>
|
||||
/// A container that can scroll to each section inside it.
|
||||
/// </summary>
|
||||
public class SectionsContainer : Container
|
||||
public class SectionsContainer<T> : Container<T>
|
||||
where T : Drawable
|
||||
{
|
||||
private Drawable expandableHeader, fixedHeader, footer;
|
||||
public readonly ScrollContainer ScrollContainer;
|
||||
private readonly Container<Drawable> sectionsContainer;
|
||||
private Drawable expandableHeader, fixedHeader, footer, headerBackground;
|
||||
private readonly ScrollContainer scrollContainer;
|
||||
private readonly Container headerBackgroundContainer;
|
||||
private readonly FlowContainer<T> scrollContentContainer;
|
||||
|
||||
protected override Container<T> Content => scrollContentContainer;
|
||||
|
||||
public Drawable ExpandableHeader
|
||||
{
|
||||
@ -26,12 +29,11 @@ namespace osu.Game.Graphics.Containers
|
||||
{
|
||||
if (value == expandableHeader) return;
|
||||
|
||||
if (expandableHeader != null)
|
||||
Remove(expandableHeader);
|
||||
expandableHeader?.Expire();
|
||||
expandableHeader = value;
|
||||
if (value == null) return;
|
||||
|
||||
Add(expandableHeader);
|
||||
AddInternal(expandableHeader);
|
||||
lastKnownScroll = float.NaN;
|
||||
}
|
||||
}
|
||||
@ -43,12 +45,11 @@ namespace osu.Game.Graphics.Containers
|
||||
{
|
||||
if (value == fixedHeader) return;
|
||||
|
||||
if (fixedHeader != null)
|
||||
Remove(fixedHeader);
|
||||
fixedHeader?.Expire();
|
||||
fixedHeader = value;
|
||||
if (value == null) return;
|
||||
|
||||
Add(fixedHeader);
|
||||
AddInternal(fixedHeader);
|
||||
lastKnownScroll = float.NaN;
|
||||
}
|
||||
}
|
||||
@ -61,68 +62,83 @@ namespace osu.Game.Graphics.Containers
|
||||
if (value == footer) return;
|
||||
|
||||
if (footer != null)
|
||||
ScrollContainer.Remove(footer);
|
||||
scrollContainer.Remove(footer);
|
||||
footer = value;
|
||||
if (value == null) return;
|
||||
|
||||
footer.Anchor |= Anchor.y2;
|
||||
footer.Origin |= Anchor.y2;
|
||||
ScrollContainer.Add(footer);
|
||||
scrollContainer.Add(footer);
|
||||
lastKnownScroll = float.NaN;
|
||||
}
|
||||
}
|
||||
|
||||
public Bindable<Drawable> SelectedSection { get; } = new Bindable<Drawable>();
|
||||
|
||||
protected virtual Container<Drawable> CreateScrollContentContainer()
|
||||
=> new FillFlowContainer
|
||||
{
|
||||
Direction = FillDirection.Vertical,
|
||||
AutoSizeAxes = Axes.Both
|
||||
};
|
||||
|
||||
private List<Drawable> sections = new List<Drawable>();
|
||||
public IEnumerable<Drawable> Sections
|
||||
public Drawable HeaderBackground
|
||||
{
|
||||
get { return sections; }
|
||||
get { return headerBackground; }
|
||||
set
|
||||
{
|
||||
foreach (var section in sections)
|
||||
sectionsContainer.Remove(section);
|
||||
if (value == headerBackground) return;
|
||||
|
||||
sections = value.ToList();
|
||||
if (sections.Count == 0) return;
|
||||
headerBackgroundContainer.Clear();
|
||||
headerBackground = value;
|
||||
if (value == null) return;
|
||||
|
||||
headerBackgroundContainer.Add(headerBackground);
|
||||
|
||||
sectionsContainer.Add(sections);
|
||||
SelectedSection.Value = sections[0];
|
||||
lastKnownScroll = float.NaN;
|
||||
}
|
||||
}
|
||||
|
||||
public Bindable<T> SelectedSection { get; } = new Bindable<T>();
|
||||
|
||||
protected virtual FlowContainer<T> CreateScrollContentContainer()
|
||||
=> new FillFlowContainer<T>
|
||||
{
|
||||
Direction = FillDirection.Vertical,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
};
|
||||
|
||||
public override void Add(T drawable)
|
||||
{
|
||||
base.Add(drawable);
|
||||
lastKnownScroll = float.NaN;
|
||||
headerHeight = float.NaN;
|
||||
footerHeight = float.NaN;
|
||||
}
|
||||
|
||||
private float headerHeight, footerHeight;
|
||||
private readonly MarginPadding originalSectionsMargin;
|
||||
private void updateSectionsMargin()
|
||||
{
|
||||
if (sections.Count == 0) return;
|
||||
if (!Children.Any()) return;
|
||||
|
||||
var newMargin = originalSectionsMargin;
|
||||
newMargin.Top += headerHeight;
|
||||
newMargin.Bottom += footerHeight;
|
||||
|
||||
sectionsContainer.Margin = newMargin;
|
||||
scrollContentContainer.Margin = newMargin;
|
||||
}
|
||||
|
||||
public SectionsContainer()
|
||||
{
|
||||
Add(ScrollContainer = new ScrollContainer()
|
||||
AddInternal(scrollContainer = new ScrollContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = false,
|
||||
Children = new Drawable[] { sectionsContainer = CreateScrollContentContainer() }
|
||||
Masking = true,
|
||||
ScrollbarVisible = false,
|
||||
Children = new Drawable[] { scrollContentContainer = CreateScrollContentContainer() }
|
||||
});
|
||||
originalSectionsMargin = sectionsContainer.Margin;
|
||||
AddInternal(headerBackgroundContainer = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X
|
||||
});
|
||||
originalSectionsMargin = scrollContentContainer.Margin;
|
||||
}
|
||||
|
||||
public void ScrollTo(Drawable section) => scrollContainer.ScrollTo(scrollContainer.GetChildPosInContent(section) - (FixedHeader?.BoundingBox.Height ?? 0));
|
||||
|
||||
private float lastKnownScroll;
|
||||
protected override void UpdateAfterChildren()
|
||||
{
|
||||
@ -137,25 +153,30 @@ namespace osu.Game.Graphics.Containers
|
||||
updateSectionsMargin();
|
||||
}
|
||||
|
||||
float currentScroll = Math.Max(0, ScrollContainer.Current);
|
||||
float currentScroll = scrollContainer.Current;
|
||||
|
||||
if (currentScroll != lastKnownScroll)
|
||||
{
|
||||
lastKnownScroll = currentScroll;
|
||||
|
||||
if (expandableHeader != null && fixedHeader != null)
|
||||
if (ExpandableHeader != null && FixedHeader != null)
|
||||
{
|
||||
float offset = Math.Min(expandableHeader.LayoutSize.Y, currentScroll);
|
||||
float offset = Math.Min(ExpandableHeader.LayoutSize.Y, currentScroll);
|
||||
|
||||
expandableHeader.Y = -offset;
|
||||
fixedHeader.Y = -offset + expandableHeader.LayoutSize.Y;
|
||||
ExpandableHeader.Y = -offset;
|
||||
FixedHeader.Y = -offset + ExpandableHeader.LayoutSize.Y;
|
||||
}
|
||||
|
||||
Drawable bestMatch = null;
|
||||
float minDiff = float.MaxValue;
|
||||
headerBackgroundContainer.Height = (ExpandableHeader?.LayoutSize.Y ?? 0) + (FixedHeader?.LayoutSize.Y ?? 0);
|
||||
headerBackgroundContainer.Y = ExpandableHeader?.Y ?? 0;
|
||||
|
||||
foreach (var section in sections)
|
||||
T bestMatch = null;
|
||||
float minDiff = float.MaxValue;
|
||||
float scrollOffset = FixedHeader?.LayoutSize.Y ?? 0;
|
||||
|
||||
foreach (var section in Children)
|
||||
{
|
||||
float diff = Math.Abs(ScrollContainer.GetChildPosInContent(section) - currentScroll);
|
||||
float diff = Math.Abs(scrollContainer.GetChildPosInContent(section) - currentScroll - scrollOffset);
|
||||
if (diff < minDiff)
|
||||
{
|
||||
minDiff = diff;
|
||||
|
@ -1,245 +0,0 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shaders;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Input;
|
||||
using OpenTK;
|
||||
using System;
|
||||
using osu.Framework.Graphics.OpenGL;
|
||||
using osu.Framework.Graphics.OpenGL.Buffers;
|
||||
using OpenTK.Graphics.ES30;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Timing;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace osu.Game.Graphics.Cursor
|
||||
{
|
||||
internal class CursorTrail : Drawable
|
||||
{
|
||||
public override bool HandleInput => true;
|
||||
|
||||
private int currentIndex;
|
||||
|
||||
private Shader shader;
|
||||
private Texture texture;
|
||||
|
||||
private Vector2 size => texture.Size * Scale;
|
||||
|
||||
private double timeOffset;
|
||||
|
||||
private float time;
|
||||
|
||||
private readonly TrailDrawNodeSharedData trailDrawNodeSharedData = new TrailDrawNodeSharedData();
|
||||
private const int max_sprites = 2048;
|
||||
|
||||
private readonly TrailPart[] parts = new TrailPart[max_sprites];
|
||||
|
||||
private Vector2? lastPosition;
|
||||
|
||||
private readonly InputResampler resampler = new InputResampler();
|
||||
|
||||
protected override DrawNode CreateDrawNode() => new TrailDrawNode();
|
||||
|
||||
protected override void ApplyDrawNode(DrawNode node)
|
||||
{
|
||||
base.ApplyDrawNode(node);
|
||||
|
||||
TrailDrawNode tNode = (TrailDrawNode)node;
|
||||
tNode.Shader = shader;
|
||||
tNode.Texture = texture;
|
||||
tNode.Size = size;
|
||||
tNode.Time = time;
|
||||
tNode.Shared = trailDrawNodeSharedData;
|
||||
|
||||
for (int i = 0; i < parts.Length; ++i)
|
||||
if (parts[i].InvalidationID > tNode.Parts[i].InvalidationID)
|
||||
tNode.Parts[i] = parts[i];
|
||||
}
|
||||
|
||||
public CursorTrail()
|
||||
{
|
||||
// as we are currently very dependent on having a running clock, let's make our own clock for the time being.
|
||||
Clock = new FramedClock();
|
||||
|
||||
AlwaysReceiveInput = true;
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
for (int i = 0; i < max_sprites; i++)
|
||||
{
|
||||
parts[i].InvalidationID = 0;
|
||||
parts[i].WasUpdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ShaderManager shaders, TextureStore textures)
|
||||
{
|
||||
shader = shaders?.Load(@"CursorTrail", FragmentShaderDescriptor.TEXTURE);
|
||||
texture = textures.Get(@"Cursor/cursortrail");
|
||||
Scale = new Vector2(1 / texture.ScaleAdjust);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
resetTime();
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
Invalidate(Invalidation.DrawNode, shallPropagate: false);
|
||||
|
||||
const int fade_clock_reset_threshold = 1000000;
|
||||
|
||||
time = (float)(Time.Current - timeOffset) / 500f;
|
||||
if (time > fade_clock_reset_threshold)
|
||||
resetTime();
|
||||
}
|
||||
|
||||
private void resetTime()
|
||||
{
|
||||
for (int i = 0; i < parts.Length; ++i)
|
||||
{
|
||||
parts[i].Time -= time;
|
||||
++parts[i].InvalidationID;
|
||||
}
|
||||
|
||||
time = 0;
|
||||
timeOffset = Time.Current;
|
||||
}
|
||||
|
||||
protected override bool OnMouseMove(InputState state)
|
||||
{
|
||||
if (lastPosition == null)
|
||||
{
|
||||
lastPosition = state.Mouse.NativeState.Position;
|
||||
resampler.AddPosition(lastPosition.Value);
|
||||
return base.OnMouseMove(state);
|
||||
}
|
||||
|
||||
foreach (Vector2 pos2 in resampler.AddPosition(state.Mouse.NativeState.Position))
|
||||
{
|
||||
Trace.Assert(lastPosition.HasValue);
|
||||
|
||||
Vector2 pos1 = lastPosition.Value;
|
||||
Vector2 diff = pos2 - pos1;
|
||||
float distance = diff.Length;
|
||||
Vector2 direction = diff / distance;
|
||||
|
||||
float interval = size.X / 2 * 0.9f;
|
||||
|
||||
for (float d = interval; d < distance; d += interval)
|
||||
{
|
||||
lastPosition = pos1 + direction * d;
|
||||
addPosition(lastPosition.Value);
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnMouseMove(state);
|
||||
}
|
||||
|
||||
private void addPosition(Vector2 pos)
|
||||
{
|
||||
parts[currentIndex].Position = pos;
|
||||
parts[currentIndex].Time = time;
|
||||
++parts[currentIndex].InvalidationID;
|
||||
|
||||
currentIndex = (currentIndex + 1) % max_sprites;
|
||||
}
|
||||
|
||||
private struct TrailPart
|
||||
{
|
||||
public Vector2 Position;
|
||||
public float Time;
|
||||
public long InvalidationID;
|
||||
public bool WasUpdated;
|
||||
}
|
||||
|
||||
private class TrailDrawNodeSharedData
|
||||
{
|
||||
public VertexBuffer<TexturedVertex2D> VertexBuffer;
|
||||
}
|
||||
|
||||
private class TrailDrawNode : DrawNode
|
||||
{
|
||||
public Shader Shader;
|
||||
public Texture Texture;
|
||||
|
||||
public float Time;
|
||||
public TrailDrawNodeSharedData Shared;
|
||||
|
||||
public readonly TrailPart[] Parts = new TrailPart[max_sprites];
|
||||
public Vector2 Size;
|
||||
|
||||
public TrailDrawNode()
|
||||
{
|
||||
for (int i = 0; i < max_sprites; i++)
|
||||
{
|
||||
Parts[i].InvalidationID = 0;
|
||||
Parts[i].WasUpdated = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Draw(Action<TexturedVertex2D> vertexAction)
|
||||
{
|
||||
if (Shared.VertexBuffer == null)
|
||||
Shared.VertexBuffer = new QuadVertexBuffer<TexturedVertex2D>(max_sprites, BufferUsageHint.DynamicDraw);
|
||||
|
||||
Shader.GetUniform<float>("g_FadeClock").Value = Time;
|
||||
|
||||
int updateStart = -1, updateEnd = 0;
|
||||
for (int i = 0; i < Parts.Length; ++i)
|
||||
{
|
||||
if (Parts[i].WasUpdated)
|
||||
{
|
||||
if (updateStart == -1)
|
||||
updateStart = i;
|
||||
updateEnd = i + 1;
|
||||
|
||||
int start = i * 4;
|
||||
int end = start;
|
||||
|
||||
Vector2 pos = Parts[i].Position;
|
||||
ColourInfo colour = DrawInfo.Colour;
|
||||
colour.TopLeft.Linear.A = Parts[i].Time + colour.TopLeft.Linear.A;
|
||||
colour.TopRight.Linear.A = Parts[i].Time + colour.TopRight.Linear.A;
|
||||
colour.BottomLeft.Linear.A = Parts[i].Time + colour.BottomLeft.Linear.A;
|
||||
colour.BottomRight.Linear.A = Parts[i].Time + colour.BottomRight.Linear.A;
|
||||
|
||||
Texture.DrawQuad(
|
||||
new Quad(pos.X - Size.X / 2, pos.Y - Size.Y / 2, Size.X, Size.Y),
|
||||
colour,
|
||||
null,
|
||||
v => Shared.VertexBuffer.Vertices[end++] = v);
|
||||
|
||||
Parts[i].WasUpdated = false;
|
||||
}
|
||||
else if (updateStart != -1)
|
||||
{
|
||||
Shared.VertexBuffer.UpdateRange(updateStart * 4, updateEnd * 4);
|
||||
updateStart = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Update all remaining vertices that have been changed.
|
||||
if (updateStart != -1)
|
||||
Shared.VertexBuffer.UpdateRange(updateStart * 4, updateEnd * 4);
|
||||
|
||||
base.Draw(vertexAction);
|
||||
|
||||
Shader.Bind();
|
||||
|
||||
Texture.TextureGL.Bind();
|
||||
Shared.VertexBuffer.Draw();
|
||||
|
||||
Shader.Unbind();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,148 +0,0 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Database;
|
||||
|
||||
namespace osu.Game.Graphics.Cursor
|
||||
{
|
||||
public class GameplayCursor : CursorContainer
|
||||
{
|
||||
protected override Drawable CreateCursor() => new OsuCursor();
|
||||
|
||||
public GameplayCursor()
|
||||
{
|
||||
Add(new CursorTrail { Depth = 1 });
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
{
|
||||
ActiveCursor.Scale = new Vector2(1);
|
||||
ActiveCursor.ScaleTo(1.2f, 100, EasingTypes.OutQuad);
|
||||
return base.OnMouseDown(state, args);
|
||||
}
|
||||
|
||||
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
|
||||
{
|
||||
if (!state.Mouse.HasMainButtonPressed)
|
||||
ActiveCursor.ScaleTo(1, 200, EasingTypes.OutQuad);
|
||||
return base.OnMouseUp(state, args);
|
||||
}
|
||||
|
||||
public class OsuCursor : Container
|
||||
{
|
||||
private Container cursorContainer;
|
||||
|
||||
private Bindable<double> cursorScale;
|
||||
private Bindable<bool> autoCursorScale;
|
||||
private Bindable<WorkingBeatmap> beatmap;
|
||||
|
||||
public OsuCursor()
|
||||
{
|
||||
Origin = Anchor.Centre;
|
||||
Size = new Vector2(42);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config, OsuGameBase game)
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
cursorContainer = new CircularContainer
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
BorderThickness = Size.X / 6,
|
||||
BorderColour = Color4.White,
|
||||
EdgeEffect = new EdgeEffect
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Colour = Color4.Pink.Opacity(0.5f),
|
||||
Radius = 5,
|
||||
},
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0,
|
||||
AlwaysPresent = true,
|
||||
},
|
||||
new CircularContainer
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
BorderThickness = Size.X / 3,
|
||||
BorderColour = Color4.White.Opacity(0.5f),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0,
|
||||
AlwaysPresent = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
new CircularContainer
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Scale = new Vector2(0.1f),
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.White,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
beatmap = game.Beatmap.GetBoundCopy();
|
||||
beatmap.ValueChanged += v => calculateScale();
|
||||
|
||||
cursorScale = config.GetBindable<double>(OsuSetting.GameplayCursorSize);
|
||||
cursorScale.ValueChanged += v => calculateScale();
|
||||
|
||||
autoCursorScale = config.GetBindable<bool>(OsuSetting.AutoCursorSize);
|
||||
autoCursorScale.ValueChanged += v => calculateScale();
|
||||
|
||||
calculateScale();
|
||||
}
|
||||
|
||||
private void calculateScale()
|
||||
{
|
||||
float scale = (float)cursorScale.Value;
|
||||
|
||||
if (autoCursorScale && beatmap.Value != null)
|
||||
{
|
||||
// if we have a beatmap available, let's get its circle size to figure out an automatic cursor scale modifier.
|
||||
scale *= (float)(1 - 0.7 * (1 + beatmap.Value.BeatmapInfo.Difficulty.CircleSize - BeatmapDifficulty.DEFAULT_DIFFICULTY) / BeatmapDifficulty.DEFAULT_DIFFICULTY);
|
||||
}
|
||||
|
||||
cursorContainer.Scale = new Vector2(scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -34,7 +34,7 @@ namespace osu.Game.Graphics.Cursor
|
||||
if (diff > 180) diff -= 360;
|
||||
degrees = ActiveCursor.Rotation + diff;
|
||||
|
||||
ActiveCursor.RotateTo(degrees, 600, EasingTypes.OutQuint);
|
||||
ActiveCursor.RotateTo(degrees, 600, Easing.OutQuint);
|
||||
}
|
||||
|
||||
return base.OnMouseMove(state);
|
||||
@ -49,10 +49,10 @@ namespace osu.Game.Graphics.Cursor
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
{
|
||||
ActiveCursor.Scale = new Vector2(1);
|
||||
ActiveCursor.ScaleTo(0.90f, 800, EasingTypes.OutQuint);
|
||||
ActiveCursor.ScaleTo(0.90f, 800, Easing.OutQuint);
|
||||
|
||||
((Cursor)ActiveCursor).AdditiveLayer.Alpha = 0;
|
||||
((Cursor)ActiveCursor).AdditiveLayer.FadeInFromZero(800, EasingTypes.OutQuint);
|
||||
((Cursor)ActiveCursor).AdditiveLayer.FadeInFromZero(800, Easing.OutQuint);
|
||||
return base.OnMouseDown(state, args);
|
||||
}
|
||||
|
||||
@ -62,9 +62,9 @@ namespace osu.Game.Graphics.Cursor
|
||||
{
|
||||
dragging = false;
|
||||
|
||||
((Cursor)ActiveCursor).AdditiveLayer.FadeOut(500, EasingTypes.OutQuint);
|
||||
ActiveCursor.RotateTo(0, 600 * (1 + Math.Abs(ActiveCursor.Rotation / 720)), EasingTypes.OutElasticHalf);
|
||||
ActiveCursor.ScaleTo(1, 500, EasingTypes.OutElastic);
|
||||
((Cursor)ActiveCursor).AdditiveLayer.FadeOut(500, Easing.OutQuint);
|
||||
ActiveCursor.RotateTo(0, 600 * (1 + Math.Abs(ActiveCursor.Rotation / 720)), Easing.OutElasticHalf);
|
||||
ActiveCursor.ScaleTo(1, 500, Easing.OutElastic);
|
||||
}
|
||||
|
||||
return base.OnMouseUp(state, args);
|
||||
@ -72,21 +72,21 @@ namespace osu.Game.Graphics.Cursor
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
((Cursor)ActiveCursor).AdditiveLayer.FadeOutFromOne(500, EasingTypes.OutQuint);
|
||||
((Cursor)ActiveCursor).AdditiveLayer.FadeOutFromOne(500, Easing.OutQuint);
|
||||
|
||||
return base.OnClick(state);
|
||||
}
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
ActiveCursor.FadeTo(1, 250, EasingTypes.OutQuint);
|
||||
ActiveCursor.ScaleTo(1, 400, EasingTypes.OutQuint);
|
||||
ActiveCursor.FadeTo(1, 250, Easing.OutQuint);
|
||||
ActiveCursor.ScaleTo(1, 400, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
ActiveCursor.FadeTo(0, 900, EasingTypes.OutQuint);
|
||||
ActiveCursor.ScaleTo(0, 500, EasingTypes.In);
|
||||
ActiveCursor.FadeTo(0, 900, Easing.OutQuint);
|
||||
ActiveCursor.ScaleTo(0, 500, Easing.In);
|
||||
}
|
||||
|
||||
public class Cursor : Container
|
||||
|
14
osu.Game/Graphics/Cursor/OsuContextMenuContainer.cs
Normal file
14
osu.Game/Graphics/Cursor/OsuContextMenuContainer.cs
Normal file
@ -0,0 +1,14 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Graphics.Cursor
|
||||
{
|
||||
public class OsuContextMenuContainer : ContextMenuContainer
|
||||
{
|
||||
protected override ContextMenu<ContextMenuItem> CreateContextMenu() => new OsuContextMenu<ContextMenuItem>();
|
||||
}
|
||||
}
|
@ -1,129 +0,0 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Configuration;
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Graphics.Cursor
|
||||
{
|
||||
public class OsuCursorContainer : CursorContainer
|
||||
{
|
||||
protected override Drawable CreateCursor() => new OsuCursor();
|
||||
|
||||
public OsuCursorContainer()
|
||||
{
|
||||
Add(new CursorTrail { Depth = 1 });
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
{
|
||||
ActiveCursor.Scale = new Vector2(1);
|
||||
ActiveCursor.ScaleTo(1.2f, 100, EasingTypes.OutQuad);
|
||||
return base.OnMouseDown(state, args);
|
||||
}
|
||||
|
||||
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
|
||||
{
|
||||
if (!state.Mouse.HasMainButtonPressed)
|
||||
ActiveCursor.ScaleTo(1, 200, EasingTypes.OutQuad);
|
||||
return base.OnMouseUp(state, args);
|
||||
}
|
||||
|
||||
public class OsuCursor : Container
|
||||
{
|
||||
private Container cursorContainer;
|
||||
private Bindable<double> cursorScale;
|
||||
|
||||
public OsuCursor()
|
||||
{
|
||||
Origin = Anchor.Centre;
|
||||
Size = new Vector2(42);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
cursorScale = config.GetBindable<double>(OsuConfig.CursorSize);
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
cursorContainer = new CircularContainer
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Scale = new Vector2((float)cursorScale),
|
||||
Masking = true,
|
||||
BorderThickness = Size.X / 6,
|
||||
BorderColour = Color4.White,
|
||||
EdgeEffect = new EdgeEffect {
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Colour = Color4.Pink.Opacity(0.5f),
|
||||
Radius = 5,
|
||||
},
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0,
|
||||
AlwaysPresent = true,
|
||||
},
|
||||
new CircularContainer
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Masking = true,
|
||||
BorderThickness = Size.X / 3,
|
||||
BorderColour = Color4.White.Opacity(0.5f),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0,
|
||||
AlwaysPresent = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
new CircularContainer
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Scale = new Vector2(0.1f),
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.White,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
cursorScale.ValueChanged += scaleChanged;
|
||||
}
|
||||
|
||||
private void scaleChanged(object sender, EventArgs e)
|
||||
{
|
||||
cursorContainer.Scale = new Vector2((float)cursorScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +1,21 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Graphics.Cursor
|
||||
{
|
||||
public class OsuTooltipContainer : TooltipContainer
|
||||
{
|
||||
protected override Tooltip CreateTooltip() => new OsuTooltip();
|
||||
protected override ITooltip CreateTooltip() => new OsuTooltip();
|
||||
|
||||
public OsuTooltipContainer(CursorContainer cursor) : base(cursor)
|
||||
{
|
||||
@ -24,6 +25,7 @@ namespace osu.Game.Graphics.Cursor
|
||||
{
|
||||
private readonly Box background;
|
||||
private readonly OsuSpriteText text;
|
||||
private bool instantMovement = true;
|
||||
|
||||
public override string TooltipText
|
||||
{
|
||||
@ -32,10 +34,10 @@ namespace osu.Game.Graphics.Cursor
|
||||
if (value == text.Text) return;
|
||||
|
||||
text.Text = value;
|
||||
if (Alpha > 0)
|
||||
if (IsPresent)
|
||||
{
|
||||
AutoSizeDuration = 250;
|
||||
background.FlashColour(OsuColour.Gray(0.4f), 1000, EasingTypes.OutQuint);
|
||||
background.FlashColour(OsuColour.Gray(0.4f), 1000, Easing.OutQuint);
|
||||
}
|
||||
else
|
||||
AutoSizeDuration = 0;
|
||||
@ -46,11 +48,11 @@ namespace osu.Game.Graphics.Cursor
|
||||
|
||||
public OsuTooltip()
|
||||
{
|
||||
AutoSizeEasing = EasingTypes.OutQuint;
|
||||
AutoSizeEasing = Easing.OutQuint;
|
||||
|
||||
CornerRadius = 5;
|
||||
Masking = true;
|
||||
EdgeEffect = new EdgeEffect
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Colour = Color4.Black.Opacity(40),
|
||||
@ -80,13 +82,23 @@ namespace osu.Game.Graphics.Cursor
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
FadeIn(500, EasingTypes.OutQuint);
|
||||
instantMovement |= !IsPresent;
|
||||
this.FadeIn(500, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
protected override void PopOut() => this.Delay(150).FadeOut(500, Easing.OutQuint);
|
||||
|
||||
public override void Move(Vector2 pos)
|
||||
{
|
||||
using (BeginDelayedSequence(150))
|
||||
FadeOut(500, EasingTypes.OutQuint);
|
||||
if (instantMovement)
|
||||
{
|
||||
Position = pos;
|
||||
instantMovement = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.MoveTo(pos, 200, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.Transforms;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
|
||||
namespace osu.Game.Graphics
|
||||
{
|
||||
@ -20,15 +20,19 @@ namespace osu.Game.Graphics
|
||||
public static class AccentedColourExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Tweens the accent colour of a drawable to another colour.
|
||||
/// Smoothly adjusts <see cref="IHasAccentColour.AccentColour"/> over time.
|
||||
/// </summary>
|
||||
/// <param name="accentedDrawable">The drawable to apply the accent colour to.</param>
|
||||
/// <param name="newColour">The new accent colour.</param>
|
||||
/// <param name="duration">The tween duration.</param>
|
||||
/// <param name="easing">The tween easing.</param>
|
||||
public static void FadeAccent(this IHasAccentColour accentedDrawable, Color4 newColour, double duration = 0, EasingTypes easing = EasingTypes.None)
|
||||
{
|
||||
accentedDrawable.TransformTo(() => accentedDrawable.AccentColour, newColour, duration, easing, new TransformAccent());
|
||||
}
|
||||
/// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns>
|
||||
public static TransformSequence<T> FadeAccent<T>(this T accentedDrawable, Color4 newColour, double duration = 0, Easing easing = Easing.None)
|
||||
where T : IHasAccentColour
|
||||
=> accentedDrawable.TransformTo(nameof(accentedDrawable.AccentColour), newColour, duration, easing);
|
||||
|
||||
/// <summary>
|
||||
/// Smoothly adjusts <see cref="IHasAccentColour.AccentColour"/> over time.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns>
|
||||
public static TransformSequence<T> FadeAccent<T>(this TransformSequence<T> t, Color4 newColour, double duration = 0, Easing easing = Easing.None)
|
||||
where T : Drawable, IHasAccentColour
|
||||
=> t.Append(o => o.FadeAccent(newColour, duration, easing));
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,9 @@ namespace osu.Game.Graphics
|
||||
|
||||
public static Color4 FromHex(string hex)
|
||||
{
|
||||
if (hex[0] == '#')
|
||||
hex = hex.Substring(1);
|
||||
|
||||
switch (hex.Length)
|
||||
{
|
||||
default:
|
||||
@ -87,5 +90,7 @@ namespace osu.Game.Graphics
|
||||
public readonly Color4 RedDarker = FromHex(@"870000");
|
||||
|
||||
public readonly Color4 ChatBlue = FromHex(@"17292e");
|
||||
|
||||
public readonly Color4 ContextMenuGray = FromHex(@"223034");
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ namespace osu.Game.Graphics.Processing
|
||||
{
|
||||
public RatioAdjust()
|
||||
{
|
||||
AlwaysReceiveInput = true;
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,105 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.IO.Stores;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Caching;
|
||||
|
||||
namespace osu.Game.Graphics
|
||||
{
|
||||
public class TextAwesome : OsuSpriteText
|
||||
public class SpriteIcon : CompositeDrawable
|
||||
{
|
||||
//public override FontFace FontFace => (int)Icon < 0xf000 ? FontFace.OsuFont : FontFace.FontAwesome;
|
||||
private readonly Sprite spriteShadow;
|
||||
private readonly Sprite spriteMain;
|
||||
|
||||
private Cached layout = new Cached();
|
||||
private readonly Container shadowVisibility;
|
||||
|
||||
public SpriteIcon()
|
||||
{
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
shadowVisibility = new Container
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = spriteShadow = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
FillMode = FillMode.Fit,
|
||||
Y = 2,
|
||||
Colour = new Color4(0f, 0f, 0f, 0.2f),
|
||||
},
|
||||
Alpha = 0,
|
||||
},
|
||||
spriteMain = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
FillMode = FillMode.Fit
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
private FontStore store;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(FontStore store)
|
||||
{
|
||||
this.store = store;
|
||||
updateTexture();
|
||||
}
|
||||
|
||||
private void updateTexture()
|
||||
{
|
||||
var texture = store?.Get(((char)icon).ToString());
|
||||
|
||||
spriteMain.Texture = texture;
|
||||
spriteShadow.Texture = texture;
|
||||
|
||||
if (Size == Vector2.Zero)
|
||||
Size = new Vector2(texture?.DisplayWidth ?? 0, texture?.DisplayHeight ?? 0);
|
||||
}
|
||||
|
||||
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)
|
||||
{
|
||||
if ((invalidation & Invalidation.Colour) > 0 && Shadow)
|
||||
layout.Invalidate();
|
||||
return base.Invalidate(invalidation, source, shallPropagate);
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
if (!layout.IsValid)
|
||||
{
|
||||
//adjust shadow alpha based on highest component intensity to avoid muddy display of darker text.
|
||||
//squared result for quadratic fall-off seems to give the best result.
|
||||
var avgColour = (Color4)DrawInfo.Colour.AverageColour;
|
||||
|
||||
spriteShadow.Alpha = (float)Math.Pow(Math.Max(Math.Max(avgColour.R, avgColour.G), avgColour.B), 2);
|
||||
|
||||
layout.Validate();
|
||||
}
|
||||
}
|
||||
|
||||
public bool Shadow
|
||||
{
|
||||
get { return spriteShadow.IsPresent; }
|
||||
set
|
||||
{
|
||||
shadowVisibility.Alpha = value ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
private FontAwesome icon;
|
||||
|
||||
@ -23,7 +115,8 @@ namespace osu.Game.Graphics
|
||||
if (icon == value) return;
|
||||
|
||||
icon = value;
|
||||
Text = ((char)icon).ToString();
|
||||
if (IsLoaded)
|
||||
updateTexture();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
using osu.Framework.MathUtils;
|
||||
|
||||
namespace osu.Game.Graphics.Transforms
|
||||
{
|
||||
public class TransformAccent : Transform<Color4>
|
||||
{
|
||||
/// <summary>
|
||||
/// Current value of the transformed colour in linear colour space.
|
||||
/// </summary>
|
||||
public override Color4 CurrentValue
|
||||
{
|
||||
get
|
||||
{
|
||||
double time = Time?.Current ?? 0;
|
||||
if (time < StartTime) return StartValue;
|
||||
if (time >= EndTime) return EndValue;
|
||||
|
||||
return Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Apply(Drawable d)
|
||||
{
|
||||
base.Apply(d);
|
||||
|
||||
var accented = d as IHasAccentColour;
|
||||
if (accented != null)
|
||||
accented.AccentColour = CurrentValue;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Graphics;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
@ -18,9 +17,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio, OsuColour colours)
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
ActivationSound = audio.Sample.Get(@"Menu/menuback");
|
||||
BackgroundColour = colours.Pink;
|
||||
HoverColour = colours.PinkDark;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
@ -17,7 +17,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
private const int resize_duration = 250;
|
||||
|
||||
private const EasingTypes easing = EasingTypes.InOutCubic;
|
||||
private const Easing easing = Easing.InOutCubic;
|
||||
|
||||
private float length;
|
||||
/// <summary>
|
||||
@ -81,7 +81,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = new Color4(0,0,0,0)
|
||||
Colour = new Color4(0, 0, 0, 0)
|
||||
},
|
||||
bar = new Box
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
base.Direction = (direction & BarDirection.Horizontal) > 0 ? FillDirection.Vertical : FillDirection.Horizontal;
|
||||
foreach (var bar in Children)
|
||||
{
|
||||
bar.Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / Children.Count()) : new Vector2(1.0f / Children.Count(), 1);
|
||||
bar.Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / Children.Count) : new Vector2(1.0f / Children.Count, 1);
|
||||
bar.Direction = direction;
|
||||
}
|
||||
}
|
||||
@ -44,21 +44,33 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
List<Bar> bars = Children.ToList();
|
||||
foreach (var bar in value.Select((length, index) => new { Value = length, Bar = bars.Count > index ? bars[index] : null }))
|
||||
{
|
||||
float length = MaxValue ?? value.Max();
|
||||
if (length != 0)
|
||||
length = bar.Value / length;
|
||||
|
||||
float size = value.Count();
|
||||
if (size != 0)
|
||||
size = 1.0f / size;
|
||||
|
||||
if (bar.Bar != null)
|
||||
{
|
||||
bar.Bar.Length = bar.Value / (MaxValue ?? value.Max());
|
||||
bar.Bar.Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / value.Count()) : new Vector2(1.0f / value.Count(), 1);
|
||||
bar.Bar.Length = length;
|
||||
bar.Bar.Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, size) : new Vector2(size, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Add(new Bar
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / value.Count()) : new Vector2(1.0f / value.Count(), 1),
|
||||
Length = bar.Value / (MaxValue ?? value.Max()),
|
||||
Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, size) : new Vector2(size, 1),
|
||||
Length = length,
|
||||
Direction = Direction,
|
||||
});
|
||||
}
|
||||
}
|
||||
//I'm using ToList() here because Where() returns an Enumerable which can change it's elements afterwards
|
||||
Remove(Children.Where((bar, index) => index >= value.Count()).ToList());
|
||||
RemoveRange(Children.Where((bar, index) => index >= value.Count()).ToList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,17 +28,17 @@ namespace osu.Game.Graphics.UserInterface
|
||||
var tabIndex = TabContainer.IndexOf(TabMap[tab]);
|
||||
|
||||
t.State = tIndex < tabIndex ? Visibility.Hidden : Visibility.Visible;
|
||||
t.Chevron.FadeTo(tIndex <= tabIndex ? 0f : 1f, 500, EasingTypes.OutQuint);
|
||||
t.Chevron.FadeTo(tIndex <= tabIndex ? 0f : 1f, 500, Easing.OutQuint);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private class BreadcrumbTabItem : OsuTabItem, IStateful<Visibility>
|
||||
{
|
||||
public readonly TextAwesome Chevron;
|
||||
public readonly SpriteIcon Chevron;
|
||||
|
||||
//don't allow clicking between transitions and don't make the chevron clickable
|
||||
protected override bool InternalContains(Vector2 screenSpacePos) => Alpha == 1f && Text.Contains(screenSpacePos);
|
||||
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => Alpha == 1f && Text.ReceiveMouseInputAt(screenSpacePos);
|
||||
public override bool HandleInput => State == Visibility.Visible;
|
||||
|
||||
private Visibility state;
|
||||
@ -54,13 +54,13 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
if (State == Visibility.Visible)
|
||||
{
|
||||
FadeIn(transition_duration, EasingTypes.OutQuint);
|
||||
ScaleTo(new Vector2(1f), transition_duration, EasingTypes.OutQuint);
|
||||
this.FadeIn(transition_duration, Easing.OutQuint);
|
||||
this.ScaleTo(new Vector2(1f), transition_duration, Easing.OutQuint);
|
||||
}
|
||||
else
|
||||
{
|
||||
FadeOut(transition_duration, EasingTypes.OutQuint);
|
||||
ScaleTo(new Vector2(0.8f, 1f), transition_duration, EasingTypes.OutQuint);
|
||||
this.FadeOut(transition_duration, Easing.OutQuint);
|
||||
this.ScaleTo(new Vector2(0.8f, 1f), transition_duration, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -69,11 +69,11 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
Text.TextSize = 16;
|
||||
Padding = new MarginPadding { Right = padding + 8 }; //padding + chevron width
|
||||
Add(Chevron = new TextAwesome
|
||||
Add(Chevron = new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreLeft,
|
||||
TextSize = 12,
|
||||
Size = new Vector2(12),
|
||||
Icon = FontAwesome.fa_chevron_right,
|
||||
Margin = new MarginPadding { Left = padding },
|
||||
Alpha = 0f,
|
||||
|
@ -5,16 +5,17 @@ using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Game.Graphics.Backgrounds;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Game.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class DialogButton : ClickableContainer
|
||||
public class DialogButton : OsuClickableContainer
|
||||
{
|
||||
private const float hover_width = 0.9f;
|
||||
private const float hover_duration = 500;
|
||||
@ -78,8 +79,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
public SampleChannel SampleClick, SampleHover;
|
||||
|
||||
private readonly Container backgroundContainer;
|
||||
private readonly Container colourContainer;
|
||||
private readonly Container glowContainer;
|
||||
@ -92,33 +91,30 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
private bool didClick; // Used for making sure that the OnMouseDown animation can call instead of OnHoverLost's when clicking
|
||||
|
||||
protected override bool InternalContains(Vector2 screenSpacePos) => backgroundContainer.Contains(screenSpacePos);
|
||||
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => backgroundContainer.ReceiveMouseInputAt(screenSpacePos);
|
||||
|
||||
protected override bool OnClick(Framework.Input.InputState state)
|
||||
{
|
||||
didClick = true;
|
||||
colourContainer.ResizeTo(new Vector2(1.5f, 1f), click_duration, EasingTypes.In);
|
||||
colourContainer.ResizeTo(new Vector2(1.5f, 1f), click_duration, Easing.In);
|
||||
flash();
|
||||
SampleClick?.Play();
|
||||
Action?.Invoke();
|
||||
|
||||
Delay(click_duration);
|
||||
Schedule(delegate {
|
||||
this.Delay(click_duration).Schedule(delegate {
|
||||
colourContainer.ResizeTo(new Vector2(0.8f, 1f));
|
||||
spriteText.Spacing = Vector2.Zero;
|
||||
glowContainer.FadeOut();
|
||||
});
|
||||
|
||||
return true;
|
||||
return base.OnClick(state);
|
||||
}
|
||||
|
||||
protected override bool OnHover(Framework.Input.InputState state)
|
||||
{
|
||||
spriteText.TransformSpacingTo(hoverSpacing, hover_duration, EasingTypes.OutElastic);
|
||||
spriteText.TransformSpacingTo(hoverSpacing, hover_duration, Easing.OutElastic);
|
||||
|
||||
colourContainer.ResizeTo(new Vector2(hover_width, 1f), hover_duration, EasingTypes.OutElastic);
|
||||
glowContainer.FadeIn(glow_fade_duration, EasingTypes.Out);
|
||||
SampleHover?.Play();
|
||||
colourContainer.ResizeTo(new Vector2(hover_width, 1f), hover_duration, Easing.OutElastic);
|
||||
glowContainer.FadeIn(glow_fade_duration, Easing.Out);
|
||||
base.OnHover(state);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -126,9 +122,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
if (!didClick)
|
||||
{
|
||||
colourContainer.ResizeTo(new Vector2(0.8f, 1f), hover_duration, EasingTypes.OutElastic);
|
||||
spriteText.TransformSpacingTo(Vector2.Zero, hover_duration, EasingTypes.OutElastic);
|
||||
glowContainer.FadeOut(glow_fade_duration, EasingTypes.Out);
|
||||
colourContainer.ResizeTo(new Vector2(0.8f, 1f), hover_duration, Easing.OutElastic);
|
||||
spriteText.TransformSpacingTo(Vector2.Zero, hover_duration, Easing.OutElastic);
|
||||
glowContainer.FadeOut(glow_fade_duration, Easing.Out);
|
||||
}
|
||||
|
||||
didClick = false;
|
||||
@ -152,9 +148,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
private void updateGlow()
|
||||
{
|
||||
leftGlow.ColourInfo = ColourInfo.GradientHorizontal(new Color4(ButtonColour.R, ButtonColour.G, ButtonColour.B, 0f), ButtonColour);
|
||||
leftGlow.Colour = ColourInfo.GradientHorizontal(new Color4(ButtonColour.R, ButtonColour.G, ButtonColour.B, 0f), ButtonColour);
|
||||
centerGlow.Colour = ButtonColour;
|
||||
rightGlow.ColourInfo = ColourInfo.GradientHorizontal(ButtonColour, new Color4(ButtonColour.R, ButtonColour.G, ButtonColour.B, 0f));
|
||||
rightGlow.Colour = ColourInfo.GradientHorizontal(ButtonColour, new Color4(ButtonColour.R, ButtonColour.G, ButtonColour.B, 0f));
|
||||
}
|
||||
|
||||
public DialogButton()
|
||||
@ -222,7 +218,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Width = 0.8f,
|
||||
Masking = true,
|
||||
MaskingSmoothness = 2,
|
||||
EdgeEffect = new EdgeEffect
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Colour = Color4.Black.Opacity(0.2f),
|
||||
|
@ -3,13 +3,14 @@
|
||||
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Input;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Input;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
/// <summary>
|
||||
/// A textbox which holds focus eagerly.
|
||||
/// </summary>
|
||||
public class FocusedTextBox : OsuTextBox
|
||||
{
|
||||
protected override Color4 BackgroundUnfocused => new Color4(10, 10, 10, 255);
|
||||
@ -25,34 +26,28 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
focus = value;
|
||||
if (!focus && HasFocus)
|
||||
inputManager.ChangeFocus(null);
|
||||
GetContainingInputManager().ChangeFocus(null);
|
||||
}
|
||||
}
|
||||
|
||||
private InputManager inputManager;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(UserInputManager inputManager)
|
||||
{
|
||||
this.inputManager = inputManager;
|
||||
}
|
||||
|
||||
protected override void OnFocus(InputState state)
|
||||
{
|
||||
base.OnFocus(state);
|
||||
BorderThickness = 0;
|
||||
}
|
||||
|
||||
protected override void OnFocusLost(InputState state)
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
if (state.Keyboard.Keys.Any(key => key == Key.Escape))
|
||||
if (args.Key == Key.Escape)
|
||||
{
|
||||
if (Text.Length > 0)
|
||||
Text = string.Empty;
|
||||
else
|
||||
Exit?.Invoke();
|
||||
return true;
|
||||
}
|
||||
base.OnFocusLost(state);
|
||||
|
||||
return base.OnKeyDown(state, args);
|
||||
}
|
||||
|
||||
public override bool RequestsFocus => HoldFocus;
|
||||
|
117
osu.Game/Graphics/UserInterface/IconButton.cs
Normal file
117
osu.Game/Graphics/UserInterface/IconButton.cs
Normal file
@ -0,0 +1,117 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class IconButton : OsuClickableContainer
|
||||
{
|
||||
private readonly SpriteIcon icon;
|
||||
private readonly Box hover;
|
||||
private readonly Container content;
|
||||
|
||||
public FontAwesome Icon
|
||||
{
|
||||
get { return icon.Icon; }
|
||||
set { icon.Icon = value; }
|
||||
}
|
||||
|
||||
private const float button_size = 30;
|
||||
private Color4 flashColour;
|
||||
|
||||
public Vector2 IconScale
|
||||
{
|
||||
get { return icon.Scale; }
|
||||
set { icon.Scale = value; }
|
||||
}
|
||||
|
||||
public IconButton()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
Origin = Anchor.Centre;
|
||||
Anchor = Anchor.Centre;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
content = new Container
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Size = new Vector2(button_size),
|
||||
|
||||
CornerRadius = 5,
|
||||
Masking = true,
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Colour = Color4.Black.Opacity(0.04f),
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Radius = 5,
|
||||
},
|
||||
Children = new Drawable[]
|
||||
{
|
||||
hover = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Alpha = 0,
|
||||
},
|
||||
icon = new SpriteIcon
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Size = new Vector2(18),
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
hover.Colour = colours.Yellow.Opacity(0.6f);
|
||||
flashColour = colours.Yellow;
|
||||
|
||||
Enabled.ValueChanged += enabled => this.FadeColour(enabled ? Color4.White : colours.Gray9, 200, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
hover.FadeIn(500, Easing.OutQuint);
|
||||
return base.OnHover(state);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
hover.FadeOut(500, Easing.OutQuint);
|
||||
base.OnHoverLost(state);
|
||||
}
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
hover.FlashColour(flashColour, 800, Easing.OutQuint);
|
||||
return base.OnClick(state);
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
{
|
||||
content.ScaleTo(0.75f, 2000, Easing.OutQuint);
|
||||
return base.OnMouseDown(state, args);
|
||||
}
|
||||
|
||||
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
|
||||
{
|
||||
content.ScaleTo(1, 1000, Easing.OutElastic);
|
||||
return base.OnMouseUp(state, args);
|
||||
}
|
||||
}
|
||||
}
|
102
osu.Game/Graphics/UserInterface/LineGraph.cs
Normal file
102
osu.Game/Graphics/UserInterface/LineGraph.cs
Normal file
@ -0,0 +1,102 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenTK;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Lines;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class LineGraph : Container
|
||||
{
|
||||
/// <summary>
|
||||
/// Manually set the max value, otherwise <see cref="Enumerable.Max(IEnumerable{float})"/> will be used.
|
||||
/// </summary>
|
||||
public float? MaxValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Manually set the min value, otherwise <see cref="Enumerable.Min(IEnumerable{float})"/> will be used.
|
||||
/// </summary>
|
||||
public float? MinValue { get; set; }
|
||||
|
||||
public float ActualMaxValue { get; private set; } = float.NaN;
|
||||
public float ActualMinValue { get; private set; } = float.NaN;
|
||||
|
||||
private const double transform_duration = 1500;
|
||||
|
||||
/// <summary>
|
||||
/// Hold an empty area if values are less.
|
||||
/// </summary>
|
||||
public int DefaultValueCount;
|
||||
|
||||
private readonly Container<Path> maskingContainer;
|
||||
private readonly Path path;
|
||||
|
||||
private float[] values;
|
||||
|
||||
/// <summary>
|
||||
/// A list of floats decides position of each line node.
|
||||
/// </summary>
|
||||
public IEnumerable<float> Values
|
||||
{
|
||||
get { return values; }
|
||||
set
|
||||
{
|
||||
values = value.ToArray();
|
||||
applyPath();
|
||||
maskingContainer.Width = 0;
|
||||
maskingContainer.ResizeWidthTo(1, transform_duration, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
public LineGraph()
|
||||
{
|
||||
Add(maskingContainer = new Container<Path>
|
||||
{
|
||||
Masking = true,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = path = new Path { RelativeSizeAxes = Axes.Both, PathWidth = 1 }
|
||||
});
|
||||
}
|
||||
|
||||
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true)
|
||||
{
|
||||
if ((invalidation & Invalidation.DrawSize) != 0)
|
||||
applyPath();
|
||||
return base.Invalidate(invalidation, source, shallPropagate);
|
||||
}
|
||||
|
||||
private void applyPath()
|
||||
{
|
||||
path.ClearVertices();
|
||||
if (values == null) return;
|
||||
|
||||
int count = Math.Max(values.Length, DefaultValueCount);
|
||||
|
||||
float max = values.Max(), min = values.Min();
|
||||
if (MaxValue > max) max = MaxValue.Value;
|
||||
if (MinValue < min) min = MinValue.Value;
|
||||
|
||||
ActualMaxValue = max;
|
||||
ActualMinValue = min;
|
||||
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
{
|
||||
float x = (i + count - values.Length) / (float)(count - 1) * DrawWidth - 1;
|
||||
float y = GetYPosition(values[i]) * DrawHeight - 1;
|
||||
// the -1 is for inner offset in path (actually -PathWidth)
|
||||
path.AddVertex(new Vector2(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
protected float GetYPosition(float value)
|
||||
{
|
||||
if (ActualMaxValue == ActualMinValue) return 0;
|
||||
return (ActualMaxValue - value) / (ActualMaxValue - ActualMinValue);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +1,46 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class LoadingAnimation : SpriteText
|
||||
public class LoadingAnimation : VisibilityContainer
|
||||
{
|
||||
private readonly SpriteIcon spinner;
|
||||
|
||||
public LoadingAnimation()
|
||||
{
|
||||
Text = "Loading";
|
||||
Size = new Vector2(20);
|
||||
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
spinner = new SpriteIcon
|
||||
{
|
||||
Size = new Vector2(20),
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Icon = FontAwesome.fa_spinner
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
spinner.Spin(2000, RotationDirection.Clockwise);
|
||||
}
|
||||
|
||||
private const float transition_duration = 500;
|
||||
|
||||
protected override void PopIn() => this.FadeIn(transition_duration * 5, Easing.OutQuint);
|
||||
|
||||
protected override void PopOut() => this.FadeOut(transition_duration, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
12
osu.Game/Graphics/UserInterface/MenuItemType.cs
Normal file
12
osu.Game/Graphics/UserInterface/MenuItemType.cs
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public enum MenuItemType
|
||||
{
|
||||
Standard,
|
||||
Highlighted,
|
||||
Destructive,
|
||||
}
|
||||
}
|
@ -7,18 +7,17 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class Nub : CircularContainer, IHasCurrentValue<bool>
|
||||
public class Nub : CircularContainer, IHasCurrentValue<bool>, IHasAccentColour
|
||||
{
|
||||
public const float COLLAPSED_SIZE = 20;
|
||||
public const float EXPANDED_SIZE = 40;
|
||||
|
||||
private const float border_width = 3;
|
||||
private Color4 glowingColour, idleColour;
|
||||
|
||||
public Nub()
|
||||
{
|
||||
@ -44,42 +43,50 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Current.ValueChanged += newValue =>
|
||||
{
|
||||
if (newValue)
|
||||
fill.FadeIn(200, EasingTypes.OutQuint);
|
||||
fill.FadeIn(200, Easing.OutQuint);
|
||||
else
|
||||
fill.FadeTo(0.01f, 200, EasingTypes.OutQuint); //todo: remove once we figure why containers aren't drawing at all times
|
||||
fill.FadeTo(0.01f, 200, Easing.OutQuint); //todo: remove once we figure why containers aren't drawing at all times
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
Colour = idleColour = colours.Pink;
|
||||
glowingColour = colours.PinkLighter;
|
||||
AccentColour = colours.Pink;
|
||||
GlowingAccentColour = colours.PinkLighter;
|
||||
GlowColour = colours.PinkDarker;
|
||||
|
||||
EdgeEffect = new EdgeEffect
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Colour = colours.PinkDarker,
|
||||
Colour = GlowColour,
|
||||
Type = EdgeEffectType.Glow,
|
||||
Radius = 10,
|
||||
Roundness = 8,
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
FadeEdgeEffectTo(0);
|
||||
}
|
||||
|
||||
private bool glowing;
|
||||
public bool Glowing
|
||||
{
|
||||
get { return glowing; }
|
||||
set
|
||||
{
|
||||
glowing = value;
|
||||
|
||||
if (value)
|
||||
{
|
||||
FadeColour(glowingColour, 500, EasingTypes.OutQuint);
|
||||
FadeEdgeEffectTo(1, 500, EasingTypes.OutQuint);
|
||||
this.FadeColour(GlowingAccentColour, 500, Easing.OutQuint);
|
||||
FadeEdgeEffectTo(1, 500, Easing.OutQuint);
|
||||
}
|
||||
else
|
||||
{
|
||||
FadeEdgeEffectTo(0, 500);
|
||||
FadeColour(idleColour, 500);
|
||||
this.FadeColour(AccentColour, 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -88,10 +95,48 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
set
|
||||
{
|
||||
ResizeTo(new Vector2(value ? EXPANDED_SIZE : COLLAPSED_SIZE, 12), 500, EasingTypes.OutQuint);
|
||||
this.ResizeTo(new Vector2(value ? EXPANDED_SIZE : COLLAPSED_SIZE, 12), 500, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
public Bindable<bool> Current { get; } = new Bindable<bool>();
|
||||
|
||||
private Color4 accentColour;
|
||||
public Color4 AccentColour
|
||||
{
|
||||
get { return accentColour; }
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
if (!Glowing)
|
||||
Colour = value;
|
||||
}
|
||||
}
|
||||
|
||||
private Color4 glowingAccentColour;
|
||||
public Color4 GlowingAccentColour
|
||||
{
|
||||
get { return glowingAccentColour; }
|
||||
set
|
||||
{
|
||||
glowingAccentColour = value;
|
||||
if (Glowing)
|
||||
Colour = value;
|
||||
}
|
||||
}
|
||||
|
||||
private Color4 glowColour;
|
||||
public Color4 GlowColour
|
||||
{
|
||||
get { return glowColour; }
|
||||
set
|
||||
{
|
||||
glowColour = value;
|
||||
|
||||
var effect = EdgeEffect;
|
||||
effect.Colour = value;
|
||||
EdgeEffect = effect;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,12 @@
|
||||
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input;
|
||||
@ -13,10 +17,13 @@ using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class OsuButton : Button
|
||||
public class OsuButton : Button, IFilterable
|
||||
{
|
||||
private Box hover;
|
||||
|
||||
private SampleChannel sampleClick;
|
||||
private SampleChannel sampleHover;
|
||||
|
||||
public OsuButton()
|
||||
{
|
||||
Height = 40;
|
||||
@ -33,7 +40,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
public override bool HandleInput => Action != null;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
private void load(OsuColour colours, AudioManager audio)
|
||||
{
|
||||
if (Action == null)
|
||||
Colour = OsuColour.Gray(0.5f);
|
||||
@ -43,7 +50,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Content.Masking = true;
|
||||
Content.CornerRadius = 5;
|
||||
|
||||
Add(new Drawable[]
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
new Triangles
|
||||
{
|
||||
@ -59,10 +66,28 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Alpha = 0,
|
||||
},
|
||||
});
|
||||
|
||||
sampleClick = audio.Sample.Get(@"UI/generic-click");
|
||||
sampleHover = audio.Sample.Get(@"UI/generic-hover");
|
||||
|
||||
Enabled.ValueChanged += enabled_ValueChanged;
|
||||
Enabled.TriggerChange();
|
||||
}
|
||||
|
||||
private void enabled_ValueChanged(bool enabled)
|
||||
{
|
||||
this.FadeColour(enabled ? Color4.White : Color4.Gray, 200, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
sampleClick?.Play();
|
||||
return base.OnClick(state);
|
||||
}
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
sampleHover?.Play();
|
||||
hover.FadeIn(200);
|
||||
return base.OnHover(state);
|
||||
}
|
||||
@ -75,14 +100,24 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
{
|
||||
Content.ScaleTo(0.9f, 4000, EasingTypes.OutQuint);
|
||||
Content.ScaleTo(0.9f, 4000, Easing.OutQuint);
|
||||
return base.OnMouseDown(state, args);
|
||||
}
|
||||
|
||||
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
|
||||
{
|
||||
Content.ScaleTo(1, 1000, EasingTypes.OutElastic);
|
||||
Content.ScaleTo(1, 1000, Easing.OutElastic);
|
||||
return base.OnMouseUp(state, args);
|
||||
}
|
||||
|
||||
public string[] FilterTerms => new[] { Text };
|
||||
|
||||
public bool MatchingFilter
|
||||
{
|
||||
set
|
||||
{
|
||||
this.FadeTo(value ? 1 : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -51,7 +51,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Nub nub;
|
||||
protected readonly Nub Nub;
|
||||
|
||||
private readonly SpriteText labelSpriteText;
|
||||
private SampleChannel sampleChecked;
|
||||
private SampleChannel sampleUnchecked;
|
||||
@ -64,7 +65,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Children = new Drawable[]
|
||||
{
|
||||
labelSpriteText = new OsuSpriteText(),
|
||||
nub = new Nub
|
||||
Nub = new Nub
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
@ -72,7 +73,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
};
|
||||
|
||||
nub.Current.BindTo(Current);
|
||||
Nub.Current.BindTo(Current);
|
||||
|
||||
Current.ValueChanged += newValue =>
|
||||
{
|
||||
@ -90,23 +91,23 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
nub.Glowing = true;
|
||||
nub.Expanded = true;
|
||||
Nub.Glowing = true;
|
||||
Nub.Expanded = true;
|
||||
return base.OnHover(state);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
nub.Glowing = false;
|
||||
nub.Expanded = false;
|
||||
Nub.Glowing = false;
|
||||
Nub.Expanded = false;
|
||||
base.OnHoverLost(state);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
sampleChecked = audio.Sample.Get(@"Checkbox/check-on");
|
||||
sampleUnchecked = audio.Sample.Get(@"Checkbox/check-off");
|
||||
sampleChecked = audio.Sample.Get(@"UI/check-on");
|
||||
sampleUnchecked = audio.Sample.Get(@"UI/check-off");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
52
osu.Game/Graphics/UserInterface/OsuContextMenu.cs
Normal file
52
osu.Game/Graphics/UserInterface/OsuContextMenu.cs
Normal file
@ -0,0 +1,52 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class OsuContextMenu<TItem> : ContextMenu<TItem>
|
||||
where TItem : ContextMenuItem
|
||||
{
|
||||
protected override Menu<TItem> CreateMenu() => new CustomMenu();
|
||||
|
||||
public class CustomMenu : Menu<TItem>
|
||||
{
|
||||
private const int fade_duration = 250;
|
||||
|
||||
public CustomMenu()
|
||||
{
|
||||
CornerRadius = 5;
|
||||
ItemsContainer.Padding = new MarginPadding { Vertical = OsuContextMenuItem.MARGIN_VERTICAL };
|
||||
Masking = true;
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Colour = Color4.Black.Opacity(0.1f),
|
||||
Radius = 4,
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
Background.Colour = colours.ContextMenuGray;
|
||||
}
|
||||
|
||||
protected override void AnimateOpen() => this.FadeIn(fade_duration, Easing.OutQuint);
|
||||
protected override void AnimateClose() => this.FadeOut(fade_duration, Easing.OutQuint);
|
||||
|
||||
protected override void UpdateContentHeight()
|
||||
{
|
||||
var actualHeight = (RelativeSizeAxes & Axes.Y) > 0 ? 1 : ContentHeight;
|
||||
this.ResizeTo(new Vector2(1, State == MenuState.Opened ? actualHeight : 0), 300, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
114
osu.Game/Graphics/UserInterface/OsuContextMenuItem.cs
Normal file
114
osu.Game/Graphics/UserInterface/OsuContextMenuItem.cs
Normal file
@ -0,0 +1,114 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class OsuContextMenuItem : ContextMenuItem
|
||||
{
|
||||
private const int transition_length = 80;
|
||||
private const int margin_horizontal = 17;
|
||||
public const int MARGIN_VERTICAL = 4;
|
||||
private const int text_size = 17;
|
||||
|
||||
private OsuSpriteText text;
|
||||
private OsuSpriteText textBold;
|
||||
|
||||
private SampleChannel sampleClick;
|
||||
private SampleChannel sampleHover;
|
||||
|
||||
private readonly MenuItemType type;
|
||||
|
||||
protected override Container CreateTextContainer(string title) => new Container
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
text = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
TextSize = text_size,
|
||||
Text = title,
|
||||
Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL },
|
||||
},
|
||||
textBold = new OsuSpriteText
|
||||
{
|
||||
AlwaysPresent = true,
|
||||
Alpha = 0,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
TextSize = text_size,
|
||||
Text = title,
|
||||
Font = @"Exo2.0-Bold",
|
||||
Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL },
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public OsuContextMenuItem(string title, MenuItemType type = MenuItemType.Standard) : base(title)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio)
|
||||
{
|
||||
sampleHover = audio.Sample.Get(@"UI/generic-hover");
|
||||
sampleClick = audio.Sample.Get(@"UI/generic-click");
|
||||
|
||||
BackgroundColour = Color4.Transparent;
|
||||
BackgroundColourHover = OsuColour.FromHex(@"172023");
|
||||
|
||||
updateTextColour();
|
||||
}
|
||||
|
||||
private void updateTextColour()
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case MenuItemType.Standard:
|
||||
textBold.Colour = text.Colour = Color4.White;
|
||||
break;
|
||||
case MenuItemType.Destructive:
|
||||
textBold.Colour = text.Colour = Color4.Red;
|
||||
break;
|
||||
case MenuItemType.Highlighted:
|
||||
textBold.Colour = text.Colour = OsuColour.FromHex(@"ffcc22");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
sampleHover.Play();
|
||||
textBold.FadeIn(transition_length, Easing.OutQuint);
|
||||
text.FadeOut(transition_length, Easing.OutQuint);
|
||||
return base.OnHover(state);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
textBold.FadeOut(transition_length, Easing.OutQuint);
|
||||
text.FadeIn(transition_length, Easing.OutQuint);
|
||||
base.OnHoverLost(state);
|
||||
}
|
||||
|
||||
protected override bool OnClick(InputState state)
|
||||
{
|
||||
sampleClick.Play();
|
||||
return base.OnClick(state);
|
||||
}
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
@ -60,14 +61,13 @@ namespace osu.Game.Graphics.UserInterface
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Chevron = new TextAwesome
|
||||
Chevron = new SpriteIcon
|
||||
{
|
||||
AlwaysPresent = true,
|
||||
Icon = FontAwesome.fa_chevron_right,
|
||||
UseFullGlyphHeight = false,
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.5f,
|
||||
TextSize = 8,
|
||||
Size = new Vector2(8),
|
||||
Margin = new MarginPadding { Left = 3, Right = 3 },
|
||||
Origin = Anchor.CentreLeft,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
@ -84,7 +84,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
private Color4? accentColour;
|
||||
|
||||
protected readonly TextAwesome Chevron;
|
||||
protected readonly SpriteIcon Chevron;
|
||||
protected readonly OsuSpriteText Label;
|
||||
|
||||
protected override void FormatForeground(bool hover = false)
|
||||
@ -123,7 +123,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
set { Text.Text = value; }
|
||||
}
|
||||
|
||||
protected readonly TextAwesome Icon;
|
||||
protected readonly SpriteIcon Icon;
|
||||
|
||||
private Color4? accentColour;
|
||||
public virtual Color4 AccentColour
|
||||
@ -152,13 +152,13 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
},
|
||||
Icon = new TextAwesome
|
||||
Icon = new SpriteIcon
|
||||
{
|
||||
Icon = FontAwesome.fa_chevron_down,
|
||||
Anchor = Anchor.CentreRight,
|
||||
Origin = Anchor.CentreRight,
|
||||
Margin = new MarginPadding { Right = 4 },
|
||||
TextSize = 20
|
||||
Size = new Vector2(20),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
throw new InvalidOperationException("OsuEnumDropdown only supports enums as the generic type argument");
|
||||
|
||||
List<KeyValuePair<string, T>> items = new List<KeyValuePair<string, T>>();
|
||||
foreach(var val in (T[])Enum.GetValues(typeof(T)))
|
||||
foreach (var val in (T[])Enum.GetValues(typeof(T)))
|
||||
{
|
||||
var field = typeof(T).GetField(Enum.GetName(typeof(T), val));
|
||||
items.Add(
|
||||
|
@ -19,14 +19,14 @@ namespace osu.Game.Graphics.UserInterface
|
||||
ItemsContainer.Padding = new MarginPadding(5);
|
||||
}
|
||||
|
||||
protected override void AnimateOpen() => FadeIn(300, EasingTypes.OutQuint);
|
||||
protected override void AnimateOpen() => this.FadeIn(300, Easing.OutQuint);
|
||||
|
||||
protected override void AnimateClose() => FadeOut(300, EasingTypes.OutQuint);
|
||||
protected override void AnimateClose() => this.FadeOut(300, Easing.OutQuint);
|
||||
|
||||
protected override void UpdateContentHeight()
|
||||
{
|
||||
var actualHeight = (RelativeSizeAxes & Axes.Y) > 0 ? 1 : ContentHeight;
|
||||
ResizeTo(new Vector2(1, State == MenuState.Opened ? actualHeight : 0), 300, EasingTypes.OutQuint);
|
||||
this.ResizeTo(new Vector2(1, State == MenuState.Opened ? actualHeight : 0), 300, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,8 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using System;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
@ -58,8 +58,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
circle.FadeIn(500, EasingTypes.OutQuint);
|
||||
circle.ResizeTo(new Vector2(0.8f), 500, EasingTypes.OutQuint);
|
||||
circle.FadeIn(500, Easing.OutQuint);
|
||||
circle.ResizeTo(new Vector2(0.8f), 500, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,26 +3,27 @@
|
||||
|
||||
using System;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class OsuSliderBar<T> : SliderBar<T>, IHasTooltip
|
||||
public class OsuSliderBar<T> : SliderBar<T>, IHasTooltip, IHasAccentColour
|
||||
where T : struct, IEquatable<T>
|
||||
{
|
||||
private SampleChannel sample;
|
||||
private double lastSampleTime;
|
||||
private T lastSampleValue;
|
||||
|
||||
private readonly Nub nub;
|
||||
protected readonly Nub Nub;
|
||||
private readonly Box leftBox;
|
||||
private readonly Box rightBox;
|
||||
|
||||
@ -46,6 +47,18 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
private Color4 accentColour;
|
||||
public Color4 AccentColour
|
||||
{
|
||||
get { return accentColour; }
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
leftBox.Colour = value;
|
||||
rightBox.Colour = value;
|
||||
}
|
||||
}
|
||||
|
||||
public OsuSliderBar()
|
||||
{
|
||||
Height = 12;
|
||||
@ -71,7 +84,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Origin = Anchor.CentreRight,
|
||||
Alpha = 0.5f,
|
||||
},
|
||||
nub = new Nub
|
||||
Nub = new Nub
|
||||
{
|
||||
Origin = Anchor.TopCentre,
|
||||
Expanded = true,
|
||||
@ -87,20 +100,19 @@ namespace osu.Game.Graphics.UserInterface
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(AudioManager audio, OsuColour colours)
|
||||
{
|
||||
sample = audio.Sample.Get(@"Sliderbar/sliderbar");
|
||||
leftBox.Colour = colours.Pink;
|
||||
rightBox.Colour = colours.Pink;
|
||||
sample = audio.Sample.Get(@"UI/sliderbar-notch");
|
||||
AccentColour = colours.Pink;
|
||||
}
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
nub.Glowing = true;
|
||||
Nub.Glowing = true;
|
||||
return base.OnHover(state);
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
nub.Glowing = false;
|
||||
Nub.Glowing = false;
|
||||
base.OnHoverLost(state);
|
||||
}
|
||||
|
||||
@ -133,13 +145,13 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
{
|
||||
nub.Current.Value = true;
|
||||
Nub.Current.Value = true;
|
||||
return base.OnMouseDown(state, args);
|
||||
}
|
||||
|
||||
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
|
||||
{
|
||||
nub.Current.Value = false;
|
||||
Nub.Current.Value = false;
|
||||
return base.OnMouseUp(state, args);
|
||||
}
|
||||
|
||||
@ -147,14 +159,14 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
leftBox.Scale = new Vector2(MathHelper.Clamp(
|
||||
nub.DrawPosition.X - nub.DrawWidth / 2, 0, DrawWidth), 1);
|
||||
Nub.DrawPosition.X - Nub.DrawWidth / 2, 0, DrawWidth), 1);
|
||||
rightBox.Scale = new Vector2(MathHelper.Clamp(
|
||||
DrawWidth - nub.DrawPosition.X - nub.DrawWidth / 2, 0, DrawWidth), 1);
|
||||
DrawWidth - Nub.DrawPosition.X - Nub.DrawWidth / 2, 0, DrawWidth), 1);
|
||||
}
|
||||
|
||||
protected override void UpdateValue(float value)
|
||||
{
|
||||
nub.MoveToX(RangePadding + UsableWidth * value, 250, EasingTypes.OutQuint);
|
||||
Nub.MoveToX(RangePadding + UsableWidth * value, 250, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input;
|
||||
@ -22,9 +23,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem(value);
|
||||
|
||||
protected override bool InternalContains(Vector2 screenSpacePos) => base.InternalContains(screenSpacePos) || Dropdown.Contains(screenSpacePos);
|
||||
|
||||
private bool isEnumType => typeof(T).IsEnum;
|
||||
private static bool isEnumType => typeof(T).IsEnum;
|
||||
|
||||
public OsuTabControl()
|
||||
{
|
||||
@ -74,33 +73,18 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Active
|
||||
{
|
||||
get { return base.Active; }
|
||||
set
|
||||
{
|
||||
if (Active == value) return;
|
||||
|
||||
if (value)
|
||||
fadeActive();
|
||||
else
|
||||
fadeInactive();
|
||||
base.Active = value;
|
||||
}
|
||||
}
|
||||
|
||||
private const float transition_length = 500;
|
||||
|
||||
private void fadeActive()
|
||||
{
|
||||
box.FadeIn(transition_length, EasingTypes.OutQuint);
|
||||
Text.FadeColour(Color4.White, transition_length, EasingTypes.OutQuint);
|
||||
box.FadeIn(transition_length, Easing.OutQuint);
|
||||
Text.FadeColour(Color4.White, transition_length, Easing.OutQuint);
|
||||
}
|
||||
|
||||
private void fadeInactive()
|
||||
{
|
||||
box.FadeOut(transition_length, EasingTypes.OutQuint);
|
||||
Text.FadeColour(AccentColour, transition_length, EasingTypes.OutQuint);
|
||||
box.FadeOut(transition_length, Easing.OutQuint);
|
||||
Text.FadeColour(AccentColour, transition_length, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
@ -150,6 +134,10 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override void OnActivated() => fadeActive();
|
||||
|
||||
protected override void OnDeactivated() => fadeInactive();
|
||||
}
|
||||
|
||||
private class OsuTabDropdown : OsuDropdown<T>
|
||||
@ -221,10 +209,10 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
Foreground.Children = new Drawable[]
|
||||
{
|
||||
new TextAwesome
|
||||
new SpriteIcon
|
||||
{
|
||||
Icon = FontAwesome.fa_ellipsis_h,
|
||||
TextSize = 14,
|
||||
Size = new Vector2(14),
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
}
|
||||
|
@ -6,10 +6,11 @@ using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
@ -20,7 +21,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
private readonly Box box;
|
||||
private readonly SpriteText text;
|
||||
private readonly TextAwesome icon;
|
||||
private readonly SpriteIcon icon;
|
||||
|
||||
private Color4? accentColour;
|
||||
public Color4 AccentColour
|
||||
@ -48,14 +49,14 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
private void fadeIn()
|
||||
{
|
||||
box.FadeIn(transition_length, EasingTypes.OutQuint);
|
||||
text.FadeColour(Color4.White, transition_length, EasingTypes.OutQuint);
|
||||
box.FadeIn(transition_length, Easing.OutQuint);
|
||||
text.FadeColour(Color4.White, transition_length, Easing.OutQuint);
|
||||
}
|
||||
|
||||
private void fadeOut()
|
||||
{
|
||||
box.FadeOut(transition_length, EasingTypes.OutQuint);
|
||||
text.FadeColour(AccentColour, transition_length, EasingTypes.OutQuint);
|
||||
box.FadeOut(transition_length, Easing.OutQuint);
|
||||
text.FadeColour(AccentColour, transition_length, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
@ -98,9 +99,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Bold",
|
||||
},
|
||||
icon = new TextAwesome
|
||||
icon = new SpriteIcon
|
||||
{
|
||||
TextSize = 14,
|
||||
Size = new Vector2(14),
|
||||
Icon = FontAwesome.fa_circle_o,
|
||||
Shadow = true,
|
||||
},
|
||||
|
97
osu.Game/Graphics/UserInterface/PageTabControl.cs
Normal file
97
osu.Game/Graphics/UserInterface/PageTabControl.cs
Normal file
@ -0,0 +1,97 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class PageTabControl<T> : OsuTabControl<T>
|
||||
{
|
||||
protected override TabItem<T> CreateTabItem(T value) => new PageTabItem(value);
|
||||
|
||||
public PageTabControl()
|
||||
{
|
||||
Height = 30;
|
||||
}
|
||||
|
||||
public class PageTabItem : TabItem<T>
|
||||
{
|
||||
private const float transition_duration = 100;
|
||||
|
||||
private readonly Box box;
|
||||
|
||||
protected readonly SpriteText Text;
|
||||
|
||||
public PageTabItem(T value) : base(value)
|
||||
{
|
||||
AutoSizeAxes = Axes.X;
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
Text = new OsuSpriteText
|
||||
{
|
||||
Margin = new MarginPadding { Top = 8, Bottom = 8 },
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Text = (value as Enum)?.GetDescription() ?? value.ToString(),
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Bold",
|
||||
},
|
||||
box = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 5,
|
||||
Scale = new Vector2(1f, 0f),
|
||||
Colour = Color4.White,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
box.Colour = colours.Yellow;
|
||||
}
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
if (!Active)
|
||||
slideActive();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
if (!Active)
|
||||
slideInactive();
|
||||
}
|
||||
|
||||
private void slideActive()
|
||||
{
|
||||
box.ScaleTo(new Vector2(1f), transition_duration);
|
||||
}
|
||||
|
||||
private void slideInactive()
|
||||
{
|
||||
box.ScaleTo(new Vector2(1f, 0f), transition_duration);
|
||||
}
|
||||
|
||||
protected override void OnActivated() => slideActive();
|
||||
|
||||
protected override void OnDeactivated() => slideInactive();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
using osu.Framework.MathUtils;
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
@ -13,8 +10,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
/// </summary>
|
||||
public class PercentageCounter : RollingCounter<double>
|
||||
{
|
||||
protected override Type TransformType => typeof(TransformAccuracy);
|
||||
|
||||
protected override double RollingDuration => 750;
|
||||
|
||||
private float epsilon => 1e-10f;
|
||||
@ -44,26 +39,5 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
Current.Value = Current + amount;
|
||||
}
|
||||
|
||||
protected class TransformAccuracy : Transform<double>
|
||||
{
|
||||
public override double CurrentValue
|
||||
{
|
||||
get
|
||||
{
|
||||
double time = Time?.Current ?? 0;
|
||||
if (time < StartTime) return StartValue;
|
||||
if (time >= EndTime) return EndValue;
|
||||
|
||||
return Interpolation.ValueAt(time, (float)StartValue, (float)EndValue, StartTime, EndTime, Easing);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Apply(Drawable d)
|
||||
{
|
||||
base.Apply(d);
|
||||
((PercentageCounter)d).DisplayedCount = CurrentValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,30 +5,21 @@ using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public abstract class RollingCounter<T> : Container, IHasAccentColour
|
||||
where T : struct, IEquatable<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// The current value.
|
||||
/// </summary>
|
||||
public Bindable<T> Current = new Bindable<T>();
|
||||
|
||||
/// <summary>
|
||||
/// Type of the Transform to use.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Must be a subclass of Transform(T)
|
||||
/// </remarks>
|
||||
protected virtual Type TransformType => typeof(Transform<T>);
|
||||
|
||||
protected SpriteText DisplayedCountSpriteText;
|
||||
|
||||
/// <summary>
|
||||
@ -45,7 +36,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
/// <summary>
|
||||
/// Easing for the counter rollover animation.
|
||||
/// </summary>
|
||||
protected virtual EasingTypes RollingEasing => EasingTypes.OutQuint;
|
||||
protected virtual Easing RollingEasing => Easing.OutQuint;
|
||||
|
||||
private T displayedCount;
|
||||
|
||||
@ -58,7 +49,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
return displayedCount;
|
||||
}
|
||||
protected set
|
||||
|
||||
set
|
||||
{
|
||||
if (EqualityComparer<T>.Default.Equals(displayedCount, value))
|
||||
return;
|
||||
@ -133,7 +125,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
/// </summary>
|
||||
public virtual void StopRolling()
|
||||
{
|
||||
Flush(false, TransformType);
|
||||
FinishTransforms(false, nameof(DisplayedCount));
|
||||
DisplayedCount = Current;
|
||||
}
|
||||
|
||||
@ -176,45 +168,15 @@ namespace osu.Game.Graphics.UserInterface
|
||||
/// implement the rollover animation).
|
||||
/// </summary>
|
||||
/// <param name="currentValue">Count value before modification.</param>
|
||||
/// <param name="newValue">Expected count value after modification-</param>
|
||||
/// <seealso cref="TransformType"/>
|
||||
/// <param name="newValue">Expected count value after modification.</param>
|
||||
protected virtual void TransformCount(T currentValue, T newValue)
|
||||
{
|
||||
Debug.Assert(
|
||||
typeof(Transform<T>).IsAssignableFrom(TransformType),
|
||||
@"transformType should be a subclass of Transform<T>."
|
||||
);
|
||||
|
||||
TransformCount((Transform<T>)Activator.CreateInstance(TransformType), currentValue, newValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intended to be used by TransformCount(T currentValue, T newValue).
|
||||
/// </summary>
|
||||
protected void TransformCount(Transform<T> transform, T currentValue, T newValue)
|
||||
{
|
||||
Type type = transform.GetType();
|
||||
|
||||
Flush(false, type);
|
||||
|
||||
if (RollingDuration < 1)
|
||||
{
|
||||
DisplayedCount = Current;
|
||||
return;
|
||||
}
|
||||
|
||||
double rollingTotalDuration =
|
||||
IsRollingProportional
|
||||
? GetProportionalDuration(currentValue, newValue)
|
||||
: RollingDuration;
|
||||
|
||||
transform.StartTime = TransformStartTime;
|
||||
transform.EndTime = TransformStartTime + rollingTotalDuration;
|
||||
transform.StartValue = currentValue;
|
||||
transform.EndValue = newValue;
|
||||
transform.Easing = RollingEasing;
|
||||
|
||||
Transforms.Add(transform);
|
||||
this.TransformTo(nameof(DisplayedCount), newValue, rollingTotalDuration, RollingEasing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,18 +2,13 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
using osu.Framework.MathUtils;
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class ScoreCounter : RollingCounter<double>
|
||||
{
|
||||
protected override Type TransformType => typeof(TransformScore);
|
||||
|
||||
protected override double RollingDuration => 1000;
|
||||
protected override EasingTypes RollingEasing => EasingTypes.Out;
|
||||
protected override Easing RollingEasing => Easing.Out;
|
||||
|
||||
public bool UseCommaSeparator;
|
||||
|
||||
@ -55,26 +50,5 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
Current.Value = Current + amount;
|
||||
}
|
||||
|
||||
protected class TransformScore : Transform<double>
|
||||
{
|
||||
public override double CurrentValue
|
||||
{
|
||||
get
|
||||
{
|
||||
double time = Time?.Current ?? 0;
|
||||
if (time < StartTime) return StartValue;
|
||||
if (time >= EndTime) return EndValue;
|
||||
|
||||
return Interpolation.ValueAt(time, (float)StartValue, (float)EndValue, StartTime, EndTime, Easing);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Apply(Drawable d)
|
||||
{
|
||||
base.Apply(d);
|
||||
((ScoreCounter)d).DisplayedCount = CurrentValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,13 +3,11 @@
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input;
|
||||
using OpenTK;
|
||||
using OpenTK.Input;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
/// <summary>
|
||||
/// A textbox which holds focus eagerly.
|
||||
/// </summary>
|
||||
public class SearchTextBox : FocusedTextBox
|
||||
{
|
||||
protected virtual bool AllowCommit => false;
|
||||
@ -17,15 +15,15 @@ namespace osu.Game.Graphics.UserInterface
|
||||
public SearchTextBox()
|
||||
{
|
||||
Height = 35;
|
||||
Add(new Drawable[]
|
||||
AddRange(new Drawable[]
|
||||
{
|
||||
new TextAwesome
|
||||
new SpriteIcon
|
||||
{
|
||||
Icon = FontAwesome.fa_search,
|
||||
Origin = Anchor.CentreRight,
|
||||
Anchor = Anchor.CentreRight,
|
||||
Margin = new MarginPadding { Right = 10 },
|
||||
TextSize = 20
|
||||
Size = new Vector2(20),
|
||||
}
|
||||
});
|
||||
|
||||
@ -45,9 +43,16 @@ namespace osu.Game.Graphics.UserInterface
|
||||
case Key.Up:
|
||||
case Key.Down:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!AllowCommit)
|
||||
{
|
||||
switch (args.Key)
|
||||
{
|
||||
case Key.KeypadEnter:
|
||||
case Key.Enter:
|
||||
if (!AllowCommit) return false;
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,6 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Transforms;
|
||||
using osu.Framework.MathUtils;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
@ -13,8 +10,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
/// </summary>
|
||||
public class SimpleComboCounter : RollingCounter<int>
|
||||
{
|
||||
protected override Type TransformType => typeof(TransformCounterCount);
|
||||
|
||||
protected override double RollingDuration => 750;
|
||||
|
||||
public SimpleComboCounter()
|
||||
@ -36,26 +31,5 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
Current.Value = Current + amount;
|
||||
}
|
||||
|
||||
private class TransformCounterCount : Transform<int>
|
||||
{
|
||||
public override int CurrentValue
|
||||
{
|
||||
get
|
||||
{
|
||||
double time = Time?.Current ?? 0;
|
||||
if (time < StartTime) return StartValue;
|
||||
if (time >= EndTime) return EndValue;
|
||||
|
||||
return (int)Interpolation.ValueAt(time, StartValue, EndValue, StartTime, EndTime, Easing);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Apply(Drawable d)
|
||||
{
|
||||
base.Apply(d);
|
||||
((SimpleComboCounter)d).DisplayedCount = CurrentValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
private double animationDelay => 80;
|
||||
|
||||
private double scalingDuration => 1000;
|
||||
private EasingTypes scalingEasing => EasingTypes.OutElasticHalf;
|
||||
private Easing scalingEasing => Easing.OutElasticHalf;
|
||||
private float minStarScale => 0.4f;
|
||||
|
||||
private double fadingDuration => 100;
|
||||
@ -33,25 +33,25 @@ namespace osu.Game.Graphics.UserInterface
|
||||
private const float star_size = 20;
|
||||
private const float star_spacing = 4;
|
||||
|
||||
private float count;
|
||||
private float countStars;
|
||||
|
||||
/// <summary>
|
||||
/// Amount of stars represented.
|
||||
/// </summary>
|
||||
public float Count
|
||||
public float CountStars
|
||||
{
|
||||
get
|
||||
{
|
||||
return count;
|
||||
return countStars;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (count == value) return;
|
||||
if (countStars == value) return;
|
||||
|
||||
if (IsLoaded)
|
||||
transformCount(value);
|
||||
count = value;
|
||||
countStars = value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,15 +94,15 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
public void ResetCount()
|
||||
{
|
||||
count = 0;
|
||||
countStars = 0;
|
||||
StopAnimation();
|
||||
}
|
||||
|
||||
public void ReplayAnimation()
|
||||
{
|
||||
var t = count;
|
||||
var t = countStars;
|
||||
ResetCount();
|
||||
Count = t;
|
||||
CountStars = t;
|
||||
}
|
||||
|
||||
public void StopAnimation()
|
||||
@ -111,8 +111,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
foreach (var star in stars.Children)
|
||||
{
|
||||
star.ClearTransforms(true);
|
||||
star.FadeTo(i < count ? 1.0f : minStarAlpha);
|
||||
star.Icon.ScaleTo(getStarScale(i, count));
|
||||
star.FadeTo(i < countStars ? 1.0f : minStarAlpha);
|
||||
star.Icon.ScaleTo(getStarScale(i, countStars));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@ -122,7 +122,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
if (value <= i)
|
||||
return minStarScale;
|
||||
|
||||
return i + 1 <= value ? 1.0f : (float)Interpolation.ValueAt(value, minStarScale, 1.0f, i, i + 1);
|
||||
return i + 1 <= value ? 1.0f : Interpolation.ValueAt(value, minStarScale, 1.0f, i, i + 1);
|
||||
}
|
||||
|
||||
private void transformCount(float newValue)
|
||||
@ -132,13 +132,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
star.ClearTransforms(true);
|
||||
|
||||
var delay = (count <= newValue ? Math.Max(i - count, 0) : Math.Max(count - 1 - i, 0)) * animationDelay;
|
||||
|
||||
using (BeginDelayedSequence(delay, true))
|
||||
{
|
||||
star.FadeTo(i < newValue ? 1.0f : minStarAlpha, fadingDuration);
|
||||
star.Icon.ScaleTo(getStarScale(i, newValue), scalingDuration, scalingEasing);
|
||||
}
|
||||
var delay = (countStars <= newValue ? Math.Max(i - countStars, 0) : Math.Max(countStars - 1 - i, 0)) * animationDelay;
|
||||
star.Delay(delay).FadeTo(i < newValue ? 1.0f : minStarAlpha, fadingDuration);
|
||||
star.Icon.Delay(delay).ScaleTo(getStarScale(i, newValue), scalingDuration, scalingEasing);
|
||||
|
||||
i++;
|
||||
}
|
||||
@ -146,16 +142,16 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
private class Star : Container
|
||||
{
|
||||
public readonly TextAwesome Icon;
|
||||
public readonly SpriteIcon Icon;
|
||||
public Star()
|
||||
{
|
||||
Size = new Vector2(star_size);
|
||||
|
||||
Children = new[]
|
||||
{
|
||||
Icon = new TextAwesome
|
||||
Icon = new SpriteIcon
|
||||
{
|
||||
TextSize = star_size,
|
||||
Size = new Vector2(star_size),
|
||||
Icon = FontAwesome.fa_star,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
|
@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
@ -14,10 +13,11 @@ using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Framework.Audio.Track;
|
||||
using System;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class TwoLayerButton : ClickableContainer
|
||||
public class TwoLayerButton : OsuClickableContainer
|
||||
{
|
||||
private readonly BouncingIcon bouncingIcon;
|
||||
|
||||
@ -31,7 +31,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
public static readonly Vector2 SIZE_EXTENDED = new Vector2(140, 50);
|
||||
public static readonly Vector2 SIZE_RETRACTED = new Vector2(100, 50);
|
||||
public SampleChannel ActivationSound;
|
||||
private readonly SpriteText text;
|
||||
|
||||
public Color4 HoverColour;
|
||||
@ -62,8 +61,12 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
X = (value & Anchor.x2) > 0 ? SIZE_RETRACTED.X * shear * 0.5f : 0;
|
||||
|
||||
Remove(c1);
|
||||
Remove(c2);
|
||||
c1.Depth = (value & Anchor.x2) > 0 ? 0 : 1;
|
||||
c2.Depth = (value & Anchor.x2) > 0 ? 1 : 0;
|
||||
Add(c1);
|
||||
Add(c2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,18 +82,21 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Width = 0.4f,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container {
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Shear = new Vector2(shear, 0),
|
||||
Masking = true,
|
||||
MaskingSmoothness = 2,
|
||||
EdgeEffect = new EdgeEffect {
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Colour = Color4.Black.Opacity(0.2f),
|
||||
Offset = new Vector2(2, 0),
|
||||
Radius = 2,
|
||||
},
|
||||
Children = new [] {
|
||||
Children = new[]
|
||||
{
|
||||
IconLayer = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
@ -113,18 +119,21 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Width = 0.6f,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container {
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Shear = new Vector2(shear, 0),
|
||||
Masking = true,
|
||||
MaskingSmoothness = 2,
|
||||
EdgeEffect = new EdgeEffect {
|
||||
EdgeEffect = new EdgeEffectParameters
|
||||
{
|
||||
Type = EdgeEffectType.Shadow,
|
||||
Colour = Color4.Black.Opacity(0.2f),
|
||||
Offset = new Vector2(2, 0),
|
||||
Radius = 2,
|
||||
},
|
||||
Children = new [] {
|
||||
Children = new[]
|
||||
{
|
||||
TextLayer = new Box
|
||||
{
|
||||
Origin = Anchor.TopLeft,
|
||||
@ -160,24 +169,24 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool InternalContains(Vector2 screenSpacePos) => IconLayer.Contains(screenSpacePos) || TextLayer.Contains(screenSpacePos);
|
||||
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => IconLayer.ReceiveMouseInputAt(screenSpacePos) || TextLayer.ReceiveMouseInputAt(screenSpacePos);
|
||||
|
||||
protected override bool OnHover(InputState state)
|
||||
{
|
||||
ResizeTo(SIZE_EXTENDED, transform_time, EasingTypes.OutElastic);
|
||||
IconLayer.FadeColour(HoverColour, transform_time, EasingTypes.OutElastic);
|
||||
this.ResizeTo(SIZE_EXTENDED, transform_time, Easing.OutElastic);
|
||||
IconLayer.FadeColour(HoverColour, transform_time, Easing.OutElastic);
|
||||
|
||||
bouncingIcon.ScaleTo(1.1f, transform_time, EasingTypes.OutElastic);
|
||||
bouncingIcon.ScaleTo(1.1f, transform_time, Easing.OutElastic);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(InputState state)
|
||||
{
|
||||
ResizeTo(SIZE_RETRACTED, transform_time, EasingTypes.OutElastic);
|
||||
IconLayer.FadeColour(TextLayer.Colour, transform_time, EasingTypes.OutElastic);
|
||||
this.ResizeTo(SIZE_RETRACTED, transform_time, Easing.OutElastic);
|
||||
IconLayer.FadeColour(TextLayer.Colour, transform_time, Easing.OutElastic);
|
||||
|
||||
bouncingIcon.ScaleTo(1, transform_time, EasingTypes.OutElastic);
|
||||
bouncingIcon.ScaleTo(1, transform_time, Easing.OutElastic);
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
@ -196,11 +205,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Add(flash);
|
||||
|
||||
flash.Alpha = 1;
|
||||
flash.FadeOut(500, EasingTypes.OutQuint);
|
||||
flash.FadeOut(500, Easing.OutQuint);
|
||||
flash.Expire();
|
||||
|
||||
ActivationSound.Play();
|
||||
|
||||
return base.OnClick(state);
|
||||
}
|
||||
|
||||
@ -208,7 +215,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
private const double beat_in_time = 60;
|
||||
|
||||
private readonly TextAwesome icon;
|
||||
private readonly SpriteIcon icon;
|
||||
|
||||
public FontAwesome Icon { set { icon.Icon = value; } }
|
||||
|
||||
@ -219,11 +226,11 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
icon = new TextAwesome
|
||||
icon = new SpriteIcon
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
TextSize = 25
|
||||
Size = new Vector2(25),
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -238,9 +245,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
if (beatIndex < 0) return;
|
||||
|
||||
icon.ScaleTo(1 - 0.1f * amplitudeAdjust, beat_in_time, EasingTypes.Out);
|
||||
using (icon.BeginDelayedSequence(beat_in_time))
|
||||
icon.ScaleTo(1, beatLength * 2, EasingTypes.OutQuint);
|
||||
icon.ScaleTo(1 - 0.1f * amplitudeAdjust, beat_in_time, Easing.Out)
|
||||
.Then()
|
||||
.ScaleTo(1, beatLength * 2, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,11 @@
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Threading;
|
||||
using OpenTK;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Input.Bindings;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface.Volume
|
||||
{
|
||||
@ -15,8 +15,6 @@ namespace osu.Game.Graphics.UserInterface.Volume
|
||||
{
|
||||
private readonly VolumeMeter volumeMeterMaster;
|
||||
|
||||
protected override bool HideOnEscape => false;
|
||||
|
||||
private void volumeChanged(double newVolume)
|
||||
{
|
||||
Show();
|
||||
@ -66,15 +64,25 @@ namespace osu.Game.Graphics.UserInterface.Volume
|
||||
volumeMeterMusic.Bindable.ValueChanged -= volumeChanged;
|
||||
}
|
||||
|
||||
public void Adjust(InputState state)
|
||||
public bool Adjust(GlobalAction action)
|
||||
{
|
||||
if (State == Visibility.Hidden)
|
||||
switch (action)
|
||||
{
|
||||
Show();
|
||||
return;
|
||||
case GlobalAction.DecreaseVolume:
|
||||
if (State == Visibility.Hidden)
|
||||
Show();
|
||||
else
|
||||
volumeMeterMaster.Decrease();
|
||||
return true;
|
||||
case GlobalAction.IncreaseVolume:
|
||||
if (State == Visibility.Hidden)
|
||||
Show();
|
||||
else
|
||||
volumeMeterMaster.Increase();
|
||||
return true;
|
||||
}
|
||||
|
||||
volumeMeterMaster.TriggerOnWheel(state);
|
||||
return false;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -93,21 +101,20 @@ namespace osu.Game.Graphics.UserInterface.Volume
|
||||
protected override void PopIn()
|
||||
{
|
||||
ClearTransforms();
|
||||
FadeIn(100);
|
||||
this.FadeIn(100);
|
||||
|
||||
schedulePopOut();
|
||||
}
|
||||
|
||||
protected override void PopOut()
|
||||
{
|
||||
FadeOut(100);
|
||||
this.FadeOut(100);
|
||||
}
|
||||
|
||||
private void schedulePopOut()
|
||||
{
|
||||
popOutDelegate?.Cancel();
|
||||
Delay(1000);
|
||||
popOutDelegate = Schedule(Hide);
|
||||
this.Delay(1000).Schedule(Hide, out popOutDelegate);
|
||||
}
|
||||
}
|
||||
}
|
@ -3,32 +3,16 @@
|
||||
|
||||
using System;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input;
|
||||
using OpenTK.Input;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Input.Bindings;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface.Volume
|
||||
{
|
||||
internal class VolumeControlReceptor : Container
|
||||
internal class VolumeControlReceptor : Container, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
public Action<InputState> ActionRequested;
|
||||
public Func<GlobalAction, bool> ActionRequested;
|
||||
|
||||
protected override bool OnWheel(InputState state)
|
||||
{
|
||||
ActionRequested?.Invoke(state);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
switch (args.Key)
|
||||
{
|
||||
case Key.Up:
|
||||
case Key.Down:
|
||||
ActionRequested?.Invoke(state);
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnKeyDown(state, args);
|
||||
}
|
||||
public bool OnPressed(GlobalAction action) => ActionRequested?.Invoke(action) ?? false;
|
||||
public bool OnReleased(GlobalAction action) => false;
|
||||
}
|
||||
}
|
||||
|
@ -4,15 +4,16 @@
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Input.Bindings;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface.Volume
|
||||
{
|
||||
internal class VolumeMeter : Container
|
||||
internal class VolumeMeter : Container, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
private readonly Box meterFill;
|
||||
public BindableDouble Bindable { get; } = new BindableDouble();
|
||||
@ -76,12 +77,35 @@ namespace osu.Game.Graphics.UserInterface.Volume
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnWheel(InputState state)
|
||||
public void Increase()
|
||||
{
|
||||
Volume += 0.05f * state.Mouse.WheelDelta;
|
||||
return true;
|
||||
Volume += 0.05f;
|
||||
}
|
||||
|
||||
private void updateFill() => meterFill.ScaleTo(new Vector2(1, (float)Volume), 300, EasingTypes.OutQuint);
|
||||
public void Decrease()
|
||||
{
|
||||
Volume -= 0.05f;
|
||||
}
|
||||
|
||||
private void updateFill() => meterFill.ScaleTo(new Vector2(1, (float)Volume), 300, Easing.OutQuint);
|
||||
|
||||
public bool OnPressed(GlobalAction action)
|
||||
{
|
||||
if (!IsHovered) return false;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case GlobalAction.DecreaseVolume:
|
||||
Decrease();
|
||||
return true;
|
||||
case GlobalAction.IncreaseVolume:
|
||||
Increase();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool OnReleased(GlobalAction action) => false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user