Merge branch 'master' into use-pattern-matching

This commit is contained in:
Dean Herbert
2019-02-28 14:53:07 +09:00
committed by GitHub
306 changed files with 1009 additions and 623 deletions

View File

@ -86,7 +86,7 @@ namespace osu.Game.Graphics.Backgrounds
public float TriangleScale
{
get { return triangleScale; }
get => triangleScale;
set
{
float change = value / triangleScale;
@ -110,10 +110,10 @@ namespace osu.Game.Graphics.Backgrounds
if (CreateNewTriangles)
addTriangles(false);
float adjustedAlpha = HideAlphaDiscrepancies ?
float adjustedAlpha = HideAlphaDiscrepancies
// Cubically scale alpha to make it drop off more sharply.
(float)Math.Pow(DrawColourInfo.Colour.AverageColour.Linear.A, 3) :
1;
? (float)Math.Pow(DrawColourInfo.Colour.AverageColour.Linear.A, 3)
: 1;
float elapsedSeconds = (float)Time.Elapsed / 1000;
// Since position is relative, the velocity needs to scale inversely with DrawHeight.
@ -181,6 +181,7 @@ namespace osu.Game.Graphics.Backgrounds
protected override DrawNode CreateDrawNode() => new TrianglesDrawNode();
private readonly TrianglesDrawNodeSharedData sharedData = new TrianglesDrawNodeSharedData();
protected override void ApplyDrawNode(DrawNode node)
{
base.ApplyDrawNode(node);

View File

@ -15,15 +15,9 @@ namespace osu.Game.Graphics.Containers
{
public Drawable Icon
{
get
{
return InternalChild;
}
get => InternalChild;
set
{
InternalChild = value;
}
set => InternalChild = value;
}
/// <summary>
@ -33,8 +27,8 @@ namespace osu.Game.Graphics.Containers
/// </summary>
public new EdgeEffectParameters EdgeEffect
{
get { return base.EdgeEffect; }
set { base.EdgeEffect = value; }
get => base.EdgeEffect;
set => base.EdgeEffect = value;
}
protected override void Update()

View File

@ -96,6 +96,7 @@ namespace osu.Game.Graphics.Containers
}
else
State = Visibility.Hidden;
break;
case Visibility.Hidden:
if (PlaySamplesOnStateChange) samplePopOut?.Play();

View File

@ -12,7 +12,8 @@ namespace osu.Game.Graphics.Containers
{
public class OsuTextFlowContainer : TextFlowContainer
{
public OsuTextFlowContainer(Action<SpriteText> defaultCreationParameters = null) : base(defaultCreationParameters)
public OsuTextFlowContainer(Action<SpriteText> defaultCreationParameters = null)
: base(defaultCreationParameters)
{
}

View File

@ -24,7 +24,7 @@ namespace osu.Game.Graphics.Containers
public Drawable ExpandableHeader
{
get { return expandableHeader; }
get => expandableHeader;
set
{
if (value == expandableHeader) return;
@ -40,7 +40,7 @@ namespace osu.Game.Graphics.Containers
public Drawable FixedHeader
{
get { return fixedHeader; }
get => fixedHeader;
set
{
if (value == fixedHeader) return;
@ -56,7 +56,7 @@ namespace osu.Game.Graphics.Containers
public Drawable Footer
{
get { return footer; }
get => footer;
set
{
if (value == footer) return;
@ -75,7 +75,7 @@ namespace osu.Game.Graphics.Containers
public Drawable HeaderBackground
{
get { return headerBackground; }
get => headerBackground;
set
{
if (value == headerBackground) return;
@ -110,6 +110,7 @@ namespace osu.Game.Graphics.Containers
private float headerHeight, footerHeight;
private readonly MarginPadding originalSectionsMargin;
private void updateSectionsMargin()
{
if (!Children.Any()) return;
@ -142,6 +143,7 @@ namespace osu.Game.Graphics.Containers
public void ScrollToTop() => scrollContainer.ScrollTo(0);
private float lastKnownScroll;
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();

View File

@ -85,6 +85,7 @@ namespace osu.Game.Graphics.Cursor
dragRotationState = DragRotationState.DragStarted;
positionMouseDown = e.MousePosition;
}
return base.OnMouseDown(e);
}
@ -102,6 +103,7 @@ namespace osu.Game.Graphics.Cursor
activeCursor.RotateTo(0, 600 * (1 + Math.Abs(activeCursor.Rotation / 720)), Easing.OutElasticHalf);
dragRotationState = DragRotationState.NotDragging;
}
return base.OnMouseUp(e);
}

View File

@ -43,6 +43,7 @@ namespace osu.Game.Graphics.Cursor
}
private IProvideCursor currentTarget;
protected override void Update()
{
base.Update();

View File

@ -17,7 +17,8 @@ namespace osu.Game.Graphics.Cursor
{
protected override ITooltip CreateTooltip() => new OsuTooltip();
public OsuTooltipContainer(CursorContainer cursor) : base(cursor)
public OsuTooltipContainer(CursorContainer cursor)
: base(cursor)
{
}

View File

@ -21,6 +21,7 @@ namespace osu.Game.Graphics
{
if (date == value)
return;
date = value.ToLocalTime();
if (LoadState >= LoadState.Ready)

View File

@ -65,6 +65,7 @@ namespace osu.Game.Graphics
}
private FontAwesome loadedIcon;
private void updateTexture()
{
var loadableIcon = icon;
@ -104,9 +105,10 @@ namespace osu.Game.Graphics
}
private bool shadow;
public bool Shadow
{
get { return shadow; }
get => shadow;
set
{
shadow = value;
@ -119,11 +121,7 @@ namespace osu.Game.Graphics
public FontAwesome Icon
{
get
{
return icon;
}
get => icon;
set
{
if (icon == value) return;

View File

@ -26,10 +26,7 @@ namespace osu.Game.Graphics.UserInterface
/// </summary>
public float Length
{
get
{
return length;
}
get => length;
set
{
length = MathHelper.Clamp(value, 0, 1);
@ -39,35 +36,21 @@ namespace osu.Game.Graphics.UserInterface
public Color4 BackgroundColour
{
get
{
return background.Colour;
}
set
{
background.Colour = value;
}
get => background.Colour;
set => background.Colour = value;
}
public Color4 AccentColour
{
get
{
return bar.Colour;
}
set
{
bar.Colour = value;
}
get => bar.Colour;
set => bar.Colour = value;
}
private BarDirection direction = BarDirection.LeftToRight;
public BarDirection Direction
{
get
{
return direction;
}
get => direction;
set
{
direction = value;

View File

@ -17,12 +17,10 @@ namespace osu.Game.Graphics.UserInterface
public float? MaxValue { get; set; }
private BarDirection direction = BarDirection.BottomToTop;
public new BarDirection Direction
{
get
{
return direction;
}
get => direction;
set
{
direction = value;
@ -69,6 +67,7 @@ namespace osu.Game.Graphics.UserInterface
});
}
}
//I'm using ToList() here because Where() returns an Enumerable which can change it's elements afterwards
RemoveRange(Children.Where((bar, index) => index >= value.Count()).ToList());
}

View File

@ -57,10 +57,11 @@ namespace osu.Game.Graphics.UserInterface
public Visibility State
{
get { return state; }
get => state;
set
{
if (value == state) return;
state = value;
const float transition_duration = 500;
@ -80,7 +81,8 @@ namespace osu.Game.Graphics.UserInterface
}
}
public BreadcrumbTabItem(T value) : base(value)
public BreadcrumbTabItem(T value)
: base(value)
{
Text.Font = Text.Font.With(size: 18);
Text.Margin = new MarginPadding { Vertical = 8 };

View File

@ -154,12 +154,10 @@ namespace osu.Game.Graphics.UserInterface
}
private Color4 buttonColour;
public Color4 ButtonColour
{
get
{
return buttonColour;
}
get => buttonColour;
set
{
buttonColour = value;
@ -169,12 +167,10 @@ namespace osu.Game.Graphics.UserInterface
}
private Color4 backgroundColour = OsuColour.Gray(34);
public Color4 BackgroundColour
{
get
{
return backgroundColour;
}
get => backgroundColour;
set
{
backgroundColour = value;
@ -183,12 +179,10 @@ namespace osu.Game.Graphics.UserInterface
}
private string text;
public string Text
{
get
{
return text;
}
get => text;
set
{
text = value;

View File

@ -51,7 +51,7 @@ namespace osu.Game.Graphics.UserInterface
protected override bool OnClick(ClickEvent e)
{
if(Link != null)
if (Link != null)
host.OpenUrlExternally(Link);
return true;
}

View File

@ -17,7 +17,8 @@ namespace osu.Game.Graphics.UserInterface
{
private SampleChannel sampleClick;
public HoverClickSounds(HoverSampleSet sampleSet = HoverSampleSet.Normal) : base(sampleSet)
public HoverClickSounds(HoverSampleSet sampleSet = HoverSampleSet.Normal)
: base(sampleSet)
{
}

View File

@ -45,8 +45,10 @@ namespace osu.Game.Graphics.UserInterface
{
[Description("")]
Loud,
[Description("-soft")]
Normal,
[Description("-softer")]
Soft
}

View File

@ -19,7 +19,7 @@ namespace osu.Game.Graphics.UserInterface
/// </summary>
public Color4 IconColour
{
get { return iconColour ?? Color4.White; }
get => iconColour ?? Color4.White;
set
{
iconColour = value;
@ -34,8 +34,8 @@ namespace osu.Game.Graphics.UserInterface
/// </summary>
public Color4 IconHoverColour
{
get { return iconHoverColour ?? IconColour; }
set { iconHoverColour = value; }
get => iconHoverColour ?? IconColour;
set => iconHoverColour = value;
}
/// <summary>
@ -43,8 +43,8 @@ namespace osu.Game.Graphics.UserInterface
/// </summary>
public FontAwesome Icon
{
get { return icon.Icon; }
set { icon.Icon = value; }
get => icon.Icon;
set => icon.Icon = value;
}
/// <summary>
@ -52,8 +52,8 @@ namespace osu.Game.Graphics.UserInterface
/// </summary>
public Vector2 IconScale
{
get { return icon.Scale; }
set { icon.Scale = value; }
get => icon.Scale;
set => icon.Scale = value;
}
/// <summary>

View File

@ -44,7 +44,7 @@ namespace osu.Game.Graphics.UserInterface
/// </summary>
public IEnumerable<float> Values
{
get { return values; }
get => values;
set
{
values = value.ToArray();
@ -112,6 +112,7 @@ namespace osu.Game.Graphics.UserInterface
protected float GetYPosition(float value)
{
if (ActualMaxValue == ActualMinValue) return 0;
return (ActualMaxValue - value) / (ActualMaxValue - ActualMinValue);
}
}

View File

@ -72,9 +72,10 @@ namespace osu.Game.Graphics.UserInterface
}
private bool glowing;
public bool Glowing
{
get { return glowing; }
get => glowing;
set
{
glowing = value;
@ -94,10 +95,7 @@ namespace osu.Game.Graphics.UserInterface
public bool Expanded
{
set
{
this.ResizeTo(new Vector2(value ? EXPANDED_SIZE : COLLAPSED_SIZE, 12), 500, Easing.OutQuint);
}
set => this.ResizeTo(new Vector2(value ? EXPANDED_SIZE : COLLAPSED_SIZE, 12), 500, Easing.OutQuint);
}
private readonly Bindable<bool> current = new Bindable<bool>();
@ -116,9 +114,10 @@ namespace osu.Game.Graphics.UserInterface
}
private Color4 accentColour;
public Color4 AccentColour
{
get { return accentColour; }
get => accentColour;
set
{
accentColour = value;
@ -128,9 +127,10 @@ namespace osu.Game.Graphics.UserInterface
}
private Color4 glowingAccentColour;
public Color4 GlowingAccentColour
{
get { return glowingAccentColour; }
get => glowingAccentColour;
set
{
glowingAccentColour = value;
@ -140,9 +140,10 @@ namespace osu.Game.Graphics.UserInterface
}
private Color4 glowColour;
public Color4 GlowColour
{
get { return glowColour; }
get => glowColour;
set
{
glowColour = value;

View File

@ -33,7 +33,7 @@ namespace osu.Game.Graphics.UserInterface
public string LabelText
{
get { return labelSpriteText?.Text; }
get => labelSpriteText?.Text;
set
{
if (labelSpriteText != null)
@ -43,7 +43,7 @@ namespace osu.Game.Graphics.UserInterface
public MarginPadding LabelPadding
{
get { return labelSpriteText?.Padding ?? new MarginPadding(); }
get => labelSpriteText?.Padding ?? new MarginPadding();
set
{
if (labelSpriteText != null)

View File

@ -17,9 +17,10 @@ namespace osu.Game.Graphics.UserInterface
public class OsuDropdown<T> : Dropdown<T>, IHasAccentColour
{
private Color4 accentColour;
public Color4 AccentColour
{
get { return accentColour; }
get => accentColour;
set
{
accentColour = value;
@ -47,6 +48,7 @@ namespace osu.Game.Graphics.UserInterface
protected override DropdownMenu CreateMenu() => new OsuDropdownMenu();
#region OsuDropdownMenu
protected class OsuDropdownMenu : DropdownMenu, IHasAccentColour
{
public override bool HandleNonPositionalInput => State == MenuState.Open;
@ -81,9 +83,10 @@ namespace osu.Game.Graphics.UserInterface
}
private Color4 accentColour;
public Color4 AccentColour
{
get { return accentColour; }
get => accentColour;
set
{
accentColour = value;
@ -95,15 +98,17 @@ namespace osu.Game.Graphics.UserInterface
protected override DrawableMenuItem CreateDrawableMenuItem(MenuItem item) => new DrawableOsuDropdownMenuItem(item) { AccentColour = accentColour };
#region DrawableOsuDropdownMenuItem
public class DrawableOsuDropdownMenuItem : DrawableDropdownMenuItem, IHasAccentColour
{
// IsHovered is used
public override bool HandlePositionalInput => true;
private Color4? accentColour;
public Color4 AccentColour
{
get { return accentColour ?? nonAccentSelectedColour; }
get => accentColour ?? nonAccentSelectedColour;
set
{
accentColour = value;
@ -156,8 +161,8 @@ namespace osu.Game.Graphics.UserInterface
{
public string Text
{
get { return Label.Text; }
set { Label.Text = value; }
get => Label.Text;
set => Label.Text = value;
}
public readonly OsuSpriteText Label;
@ -191,25 +196,29 @@ namespace osu.Game.Graphics.UserInterface
}
}
}
#endregion
}
#endregion
public class OsuDropdownHeader : DropdownHeader, IHasAccentColour
{
protected readonly SpriteText Text;
protected override string Label
{
get { return Text.Text; }
set { Text.Text = value; }
get => Text.Text;
set => Text.Text = value;
}
protected readonly SpriteIcon Icon;
private Color4 accentColour;
public virtual Color4 AccentColour
{
get { return accentColour; }
get => accentColour;
set
{
accentColour = value;

View File

@ -125,7 +125,7 @@ namespace osu.Game.Graphics.UserInterface
{
public string Text
{
get { return NormalText.Text; }
get => NormalText.Text;
set
{
NormalText.Text = value;

View File

@ -35,9 +35,10 @@ namespace osu.Game.Graphics.UserInterface
public virtual string TooltipText { get; private set; }
private Color4 accentColour;
public Color4 AccentColour
{
get { return accentColour; }
get => accentColour;
set
{
accentColour = value;
@ -79,10 +80,7 @@ namespace osu.Game.Graphics.UserInterface
new HoverClickSounds()
};
Current.DisabledChanged += disabled =>
{
Alpha = disabled ? 0.3f : 1;
};
Current.DisabledChanged += disabled => { Alpha = disabled ? 0.3f : 1; };
}
[BackgroundDependencyLoader]

View File

@ -58,9 +58,10 @@ namespace osu.Game.Graphics.UserInterface
}
private Color4 accentColour;
public Color4 AccentColour
{
get { return accentColour; }
get => accentColour;
set
{
accentColour = value;
@ -100,9 +101,10 @@ namespace osu.Game.Graphics.UserInterface
protected readonly Box Bar;
private Color4 accentColour;
public Color4 AccentColour
{
get { return accentColour; }
get => accentColour;
set
{
accentColour = value;
@ -145,7 +147,8 @@ namespace osu.Game.Graphics.UserInterface
AccentColour = colours.Blue;
}
public OsuTabItem(T value) : base(value)
public OsuTabItem(T value)
: base(value)
{
AutoSizeAxes = Axes.X;
RelativeSizeAxes = Axes.Y;
@ -223,11 +226,7 @@ namespace osu.Game.Graphics.UserInterface
{
public override Color4 AccentColour
{
get
{
return base.AccentColour;
}
get => base.AccentColour;
set
{
base.AccentColour = value;

View File

@ -24,9 +24,10 @@ namespace osu.Game.Graphics.UserInterface
private readonly SpriteIcon icon;
private Color4? accentColour;
public Color4 AccentColour
{
get { return accentColour.GetValueOrDefault(); }
get => accentColour.GetValueOrDefault();
set
{
accentColour = value;
@ -41,8 +42,8 @@ namespace osu.Game.Graphics.UserInterface
public string Text
{
get { return text.Text; }
set { text.Text = value; }
get => text.Text;
set => text.Text = value;
}
private const float transition_length = 500;

View File

@ -32,7 +32,8 @@ namespace osu.Game.Graphics.UserInterface
protected readonly SpriteText Text;
public PageTabItem(T value) : base(value)
public PageTabItem(T value)
: base(value)
{
AutoSizeAxes = Axes.X;
RelativeSizeAxes = Axes.Y;

View File

@ -18,7 +18,7 @@ namespace osu.Game.Graphics.UserInterface
public Color4 FillColour
{
set { fill.FadeColour(value, 150, Easing.OutQuint); }
set => fill.FadeColour(value, 150, Easing.OutQuint);
}
public Color4 BackgroundColour
@ -32,12 +32,12 @@ namespace osu.Game.Graphics.UserInterface
public double EndTime
{
set { CurrentNumber.MaxValue = value; }
set => CurrentNumber.MaxValue = value;
}
public double CurrentTime
{
set { CurrentNumber.Value = value; }
set => CurrentNumber.Value = value;
}
public ProgressBar()

View File

@ -45,15 +45,13 @@ namespace osu.Game.Graphics.UserInterface
/// </summary>
public virtual T DisplayedCount
{
get
{
return displayedCount;
}
get => displayedCount;
set
{
if (EqualityComparer<T>.Default.Equals(displayedCount, value))
return;
displayedCount = value;
DisplayedCountSpriteText.Text = FormatCount(value);
}
@ -70,8 +68,8 @@ namespace osu.Game.Graphics.UserInterface
public Color4 AccentColour
{
get { return DisplayedCountSpriteText.Colour; }
set { DisplayedCountSpriteText.Colour = value; }
get => DisplayedCountSpriteText.Colour;
set => DisplayedCountSpriteText.Colour = value;
}
/// <summary>

View File

@ -41,10 +41,7 @@ namespace osu.Game.Graphics.UserInterface
/// </summary>
public float CountStars
{
get
{
return countStars;
}
get => countStars;
set
{
@ -137,6 +134,7 @@ namespace osu.Game.Graphics.UserInterface
private class Star : Container
{
public readonly SpriteIcon Icon;
public Star()
{
Size = new Vector2(star_size);

View File

@ -31,10 +31,7 @@ namespace osu.Game.Graphics.UserInterface
public bool MatchingFilter
{
set
{
this.FadeTo(value ? 1 : 0);
}
set => this.FadeTo(value ? 1 : 0);
}
}
}

View File

@ -48,11 +48,7 @@ namespace osu.Game.Graphics.UserInterface
public override Anchor Origin
{
get
{
return base.Origin;
}
get => base.Origin;
set
{
base.Origin = value;
@ -155,18 +151,12 @@ namespace osu.Game.Graphics.UserInterface
public FontAwesome Icon
{
set
{
bouncingIcon.Icon = value;
}
set => bouncingIcon.Icon = value;
}
public string Text
{
set
{
text.Text = value;
}
set => text.Text = value;
}
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => IconLayer.ReceivePositionalInputAt(screenSpacePos) || TextLayer.ReceivePositionalInputAt(screenSpacePos);
@ -217,7 +207,10 @@ namespace osu.Game.Graphics.UserInterface
private readonly SpriteIcon icon;
public FontAwesome Icon { set { icon.Icon = value; } }
public FontAwesome Icon
{
set => icon.Icon = value;
}
public BouncingIcon()
{