mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 14:46:38 +09:00
Merge branch 'master' into video-offset
This commit is contained in:
@ -1,8 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Game.Beatmaps;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -13,45 +12,6 @@ namespace osu.Game.Graphics
|
||||
public static Color4 Gray(float amt) => new Color4(amt, amt, amt, 1f);
|
||||
public static Color4 Gray(byte amt) => new Color4(amt, amt, amt, 255);
|
||||
|
||||
public static Color4 FromHex(string hex)
|
||||
{
|
||||
var hexSpan = hex[0] == '#' ? hex.AsSpan().Slice(1) : hex.AsSpan();
|
||||
|
||||
switch (hexSpan.Length)
|
||||
{
|
||||
default:
|
||||
throw new ArgumentException(@"Invalid hex string length!");
|
||||
|
||||
case 3:
|
||||
return new Color4(
|
||||
(byte)(byte.Parse(hexSpan.Slice(0, 1), NumberStyles.HexNumber) * 17),
|
||||
(byte)(byte.Parse(hexSpan.Slice(1, 1), NumberStyles.HexNumber) * 17),
|
||||
(byte)(byte.Parse(hexSpan.Slice(2, 1), NumberStyles.HexNumber) * 17),
|
||||
255);
|
||||
|
||||
case 6:
|
||||
return new Color4(
|
||||
byte.Parse(hexSpan.Slice(0, 2), NumberStyles.HexNumber),
|
||||
byte.Parse(hexSpan.Slice(2, 2), NumberStyles.HexNumber),
|
||||
byte.Parse(hexSpan.Slice(4, 2), NumberStyles.HexNumber),
|
||||
255);
|
||||
|
||||
case 4:
|
||||
return new Color4(
|
||||
(byte)(byte.Parse(hexSpan.Slice(0, 1), NumberStyles.HexNumber) * 17),
|
||||
(byte)(byte.Parse(hexSpan.Slice(1, 1), NumberStyles.HexNumber) * 17),
|
||||
(byte)(byte.Parse(hexSpan.Slice(0, 1), NumberStyles.HexNumber) * 17),
|
||||
(byte)(byte.Parse(hexSpan.Slice(0, 1), NumberStyles.HexNumber) * 17));
|
||||
|
||||
case 8:
|
||||
return new Color4(
|
||||
byte.Parse(hexSpan.Slice(0, 2), NumberStyles.HexNumber),
|
||||
byte.Parse(hexSpan.Slice(2, 2), NumberStyles.HexNumber),
|
||||
byte.Parse(hexSpan.Slice(4, 2), NumberStyles.HexNumber),
|
||||
byte.Parse(hexSpan.Slice(6, 2), NumberStyles.HexNumber));
|
||||
}
|
||||
}
|
||||
|
||||
public Color4 ForDifficultyRating(DifficultyRating difficulty, bool useLighterColour = false)
|
||||
{
|
||||
switch (difficulty)
|
||||
@ -78,105 +38,105 @@ namespace osu.Game.Graphics
|
||||
}
|
||||
|
||||
// See https://github.com/ppy/osu-web/blob/master/resources/assets/less/colors.less
|
||||
public readonly Color4 PurpleLighter = FromHex(@"eeeeff");
|
||||
public readonly Color4 PurpleLight = FromHex(@"aa88ff");
|
||||
public readonly Color4 PurpleLightAlternative = FromHex(@"cba4da");
|
||||
public readonly Color4 Purple = FromHex(@"8866ee");
|
||||
public readonly Color4 PurpleDark = FromHex(@"6644cc");
|
||||
public readonly Color4 PurpleDarkAlternative = FromHex(@"312436");
|
||||
public readonly Color4 PurpleDarker = FromHex(@"441188");
|
||||
public readonly Color4 PurpleLighter = Color4Extensions.FromHex(@"eeeeff");
|
||||
public readonly Color4 PurpleLight = Color4Extensions.FromHex(@"aa88ff");
|
||||
public readonly Color4 PurpleLightAlternative = Color4Extensions.FromHex(@"cba4da");
|
||||
public readonly Color4 Purple = Color4Extensions.FromHex(@"8866ee");
|
||||
public readonly Color4 PurpleDark = Color4Extensions.FromHex(@"6644cc");
|
||||
public readonly Color4 PurpleDarkAlternative = Color4Extensions.FromHex(@"312436");
|
||||
public readonly Color4 PurpleDarker = Color4Extensions.FromHex(@"441188");
|
||||
|
||||
public readonly Color4 PinkLighter = FromHex(@"ffddee");
|
||||
public readonly Color4 PinkLight = FromHex(@"ff99cc");
|
||||
public readonly Color4 Pink = FromHex(@"ff66aa");
|
||||
public readonly Color4 PinkDark = FromHex(@"cc5288");
|
||||
public readonly Color4 PinkDarker = FromHex(@"bb1177");
|
||||
public readonly Color4 PinkLighter = Color4Extensions.FromHex(@"ffddee");
|
||||
public readonly Color4 PinkLight = Color4Extensions.FromHex(@"ff99cc");
|
||||
public readonly Color4 Pink = Color4Extensions.FromHex(@"ff66aa");
|
||||
public readonly Color4 PinkDark = Color4Extensions.FromHex(@"cc5288");
|
||||
public readonly Color4 PinkDarker = Color4Extensions.FromHex(@"bb1177");
|
||||
|
||||
public readonly Color4 BlueLighter = FromHex(@"ddffff");
|
||||
public readonly Color4 BlueLight = FromHex(@"99eeff");
|
||||
public readonly Color4 Blue = FromHex(@"66ccff");
|
||||
public readonly Color4 BlueDark = FromHex(@"44aadd");
|
||||
public readonly Color4 BlueDarker = FromHex(@"2299bb");
|
||||
public readonly Color4 BlueLighter = Color4Extensions.FromHex(@"ddffff");
|
||||
public readonly Color4 BlueLight = Color4Extensions.FromHex(@"99eeff");
|
||||
public readonly Color4 Blue = Color4Extensions.FromHex(@"66ccff");
|
||||
public readonly Color4 BlueDark = Color4Extensions.FromHex(@"44aadd");
|
||||
public readonly Color4 BlueDarker = Color4Extensions.FromHex(@"2299bb");
|
||||
|
||||
public readonly Color4 YellowLighter = FromHex(@"ffffdd");
|
||||
public readonly Color4 YellowLight = FromHex(@"ffdd55");
|
||||
public readonly Color4 Yellow = FromHex(@"ffcc22");
|
||||
public readonly Color4 YellowDark = FromHex(@"eeaa00");
|
||||
public readonly Color4 YellowDarker = FromHex(@"cc6600");
|
||||
public readonly Color4 YellowLighter = Color4Extensions.FromHex(@"ffffdd");
|
||||
public readonly Color4 YellowLight = Color4Extensions.FromHex(@"ffdd55");
|
||||
public readonly Color4 Yellow = Color4Extensions.FromHex(@"ffcc22");
|
||||
public readonly Color4 YellowDark = Color4Extensions.FromHex(@"eeaa00");
|
||||
public readonly Color4 YellowDarker = Color4Extensions.FromHex(@"cc6600");
|
||||
|
||||
public readonly Color4 GreenLighter = FromHex(@"eeffcc");
|
||||
public readonly Color4 GreenLight = FromHex(@"b3d944");
|
||||
public readonly Color4 Green = FromHex(@"88b300");
|
||||
public readonly Color4 GreenDark = FromHex(@"668800");
|
||||
public readonly Color4 GreenDarker = FromHex(@"445500");
|
||||
public readonly Color4 GreenLighter = Color4Extensions.FromHex(@"eeffcc");
|
||||
public readonly Color4 GreenLight = Color4Extensions.FromHex(@"b3d944");
|
||||
public readonly Color4 Green = Color4Extensions.FromHex(@"88b300");
|
||||
public readonly Color4 GreenDark = Color4Extensions.FromHex(@"668800");
|
||||
public readonly Color4 GreenDarker = Color4Extensions.FromHex(@"445500");
|
||||
|
||||
public readonly Color4 Sky = FromHex(@"6bb5ff");
|
||||
public readonly Color4 GreySkyLighter = FromHex(@"c6e3f4");
|
||||
public readonly Color4 GreySkyLight = FromHex(@"8ab3cc");
|
||||
public readonly Color4 GreySky = FromHex(@"405461");
|
||||
public readonly Color4 GreySkyDark = FromHex(@"303d47");
|
||||
public readonly Color4 GreySkyDarker = FromHex(@"21272c");
|
||||
public readonly Color4 Sky = Color4Extensions.FromHex(@"6bb5ff");
|
||||
public readonly Color4 GreySkyLighter = Color4Extensions.FromHex(@"c6e3f4");
|
||||
public readonly Color4 GreySkyLight = Color4Extensions.FromHex(@"8ab3cc");
|
||||
public readonly Color4 GreySky = Color4Extensions.FromHex(@"405461");
|
||||
public readonly Color4 GreySkyDark = Color4Extensions.FromHex(@"303d47");
|
||||
public readonly Color4 GreySkyDarker = Color4Extensions.FromHex(@"21272c");
|
||||
|
||||
public readonly Color4 Seafoam = FromHex(@"05ffa2");
|
||||
public readonly Color4 GreySeafoamLighter = FromHex(@"9ebab1");
|
||||
public readonly Color4 GreySeafoamLight = FromHex(@"4d7365");
|
||||
public readonly Color4 GreySeafoam = FromHex(@"33413c");
|
||||
public readonly Color4 GreySeafoamDark = FromHex(@"2c3532");
|
||||
public readonly Color4 GreySeafoamDarker = FromHex(@"1e2422");
|
||||
public readonly Color4 Seafoam = Color4Extensions.FromHex(@"05ffa2");
|
||||
public readonly Color4 GreySeafoamLighter = Color4Extensions.FromHex(@"9ebab1");
|
||||
public readonly Color4 GreySeafoamLight = Color4Extensions.FromHex(@"4d7365");
|
||||
public readonly Color4 GreySeafoam = Color4Extensions.FromHex(@"33413c");
|
||||
public readonly Color4 GreySeafoamDark = Color4Extensions.FromHex(@"2c3532");
|
||||
public readonly Color4 GreySeafoamDarker = Color4Extensions.FromHex(@"1e2422");
|
||||
|
||||
public readonly Color4 Cyan = FromHex(@"05f4fd");
|
||||
public readonly Color4 GreyCyanLighter = FromHex(@"77b1b3");
|
||||
public readonly Color4 GreyCyanLight = FromHex(@"436d6f");
|
||||
public readonly Color4 GreyCyan = FromHex(@"293d3e");
|
||||
public readonly Color4 GreyCyanDark = FromHex(@"243536");
|
||||
public readonly Color4 GreyCyanDarker = FromHex(@"1e2929");
|
||||
public readonly Color4 Cyan = Color4Extensions.FromHex(@"05f4fd");
|
||||
public readonly Color4 GreyCyanLighter = Color4Extensions.FromHex(@"77b1b3");
|
||||
public readonly Color4 GreyCyanLight = Color4Extensions.FromHex(@"436d6f");
|
||||
public readonly Color4 GreyCyan = Color4Extensions.FromHex(@"293d3e");
|
||||
public readonly Color4 GreyCyanDark = Color4Extensions.FromHex(@"243536");
|
||||
public readonly Color4 GreyCyanDarker = Color4Extensions.FromHex(@"1e2929");
|
||||
|
||||
public readonly Color4 Lime = FromHex(@"82ff05");
|
||||
public readonly Color4 GreyLimeLighter = FromHex(@"deff87");
|
||||
public readonly Color4 GreyLimeLight = FromHex(@"657259");
|
||||
public readonly Color4 GreyLime = FromHex(@"3f443a");
|
||||
public readonly Color4 GreyLimeDark = FromHex(@"32352e");
|
||||
public readonly Color4 GreyLimeDarker = FromHex(@"2e302b");
|
||||
public readonly Color4 Lime = Color4Extensions.FromHex(@"82ff05");
|
||||
public readonly Color4 GreyLimeLighter = Color4Extensions.FromHex(@"deff87");
|
||||
public readonly Color4 GreyLimeLight = Color4Extensions.FromHex(@"657259");
|
||||
public readonly Color4 GreyLime = Color4Extensions.FromHex(@"3f443a");
|
||||
public readonly Color4 GreyLimeDark = Color4Extensions.FromHex(@"32352e");
|
||||
public readonly Color4 GreyLimeDarker = Color4Extensions.FromHex(@"2e302b");
|
||||
|
||||
public readonly Color4 Violet = FromHex(@"bf04ff");
|
||||
public readonly Color4 GreyVioletLighter = FromHex(@"ebb8fe");
|
||||
public readonly Color4 GreyVioletLight = FromHex(@"685370");
|
||||
public readonly Color4 GreyViolet = FromHex(@"46334d");
|
||||
public readonly Color4 GreyVioletDark = FromHex(@"2c2230");
|
||||
public readonly Color4 GreyVioletDarker = FromHex(@"201823");
|
||||
public readonly Color4 Violet = Color4Extensions.FromHex(@"bf04ff");
|
||||
public readonly Color4 GreyVioletLighter = Color4Extensions.FromHex(@"ebb8fe");
|
||||
public readonly Color4 GreyVioletLight = Color4Extensions.FromHex(@"685370");
|
||||
public readonly Color4 GreyViolet = Color4Extensions.FromHex(@"46334d");
|
||||
public readonly Color4 GreyVioletDark = Color4Extensions.FromHex(@"2c2230");
|
||||
public readonly Color4 GreyVioletDarker = Color4Extensions.FromHex(@"201823");
|
||||
|
||||
public readonly Color4 Carmine = FromHex(@"ff0542");
|
||||
public readonly Color4 GreyCarmineLighter = FromHex(@"deaab4");
|
||||
public readonly Color4 GreyCarmineLight = FromHex(@"644f53");
|
||||
public readonly Color4 GreyCarmine = FromHex(@"342b2d");
|
||||
public readonly Color4 GreyCarmineDark = FromHex(@"302a2b");
|
||||
public readonly Color4 GreyCarmineDarker = FromHex(@"241d1e");
|
||||
public readonly Color4 Carmine = Color4Extensions.FromHex(@"ff0542");
|
||||
public readonly Color4 GreyCarmineLighter = Color4Extensions.FromHex(@"deaab4");
|
||||
public readonly Color4 GreyCarmineLight = Color4Extensions.FromHex(@"644f53");
|
||||
public readonly Color4 GreyCarmine = Color4Extensions.FromHex(@"342b2d");
|
||||
public readonly Color4 GreyCarmineDark = Color4Extensions.FromHex(@"302a2b");
|
||||
public readonly Color4 GreyCarmineDarker = Color4Extensions.FromHex(@"241d1e");
|
||||
|
||||
public readonly Color4 Gray0 = FromHex(@"000");
|
||||
public readonly Color4 Gray1 = FromHex(@"111");
|
||||
public readonly Color4 Gray2 = FromHex(@"222");
|
||||
public readonly Color4 Gray3 = FromHex(@"333");
|
||||
public readonly Color4 Gray4 = FromHex(@"444");
|
||||
public readonly Color4 Gray5 = FromHex(@"555");
|
||||
public readonly Color4 Gray6 = FromHex(@"666");
|
||||
public readonly Color4 Gray7 = FromHex(@"777");
|
||||
public readonly Color4 Gray8 = FromHex(@"888");
|
||||
public readonly Color4 Gray9 = FromHex(@"999");
|
||||
public readonly Color4 GrayA = FromHex(@"aaa");
|
||||
public readonly Color4 GrayB = FromHex(@"bbb");
|
||||
public readonly Color4 GrayC = FromHex(@"ccc");
|
||||
public readonly Color4 GrayD = FromHex(@"ddd");
|
||||
public readonly Color4 GrayE = FromHex(@"eee");
|
||||
public readonly Color4 GrayF = FromHex(@"fff");
|
||||
public readonly Color4 Gray0 = Color4Extensions.FromHex(@"000");
|
||||
public readonly Color4 Gray1 = Color4Extensions.FromHex(@"111");
|
||||
public readonly Color4 Gray2 = Color4Extensions.FromHex(@"222");
|
||||
public readonly Color4 Gray3 = Color4Extensions.FromHex(@"333");
|
||||
public readonly Color4 Gray4 = Color4Extensions.FromHex(@"444");
|
||||
public readonly Color4 Gray5 = Color4Extensions.FromHex(@"555");
|
||||
public readonly Color4 Gray6 = Color4Extensions.FromHex(@"666");
|
||||
public readonly Color4 Gray7 = Color4Extensions.FromHex(@"777");
|
||||
public readonly Color4 Gray8 = Color4Extensions.FromHex(@"888");
|
||||
public readonly Color4 Gray9 = Color4Extensions.FromHex(@"999");
|
||||
public readonly Color4 GrayA = Color4Extensions.FromHex(@"aaa");
|
||||
public readonly Color4 GrayB = Color4Extensions.FromHex(@"bbb");
|
||||
public readonly Color4 GrayC = Color4Extensions.FromHex(@"ccc");
|
||||
public readonly Color4 GrayD = Color4Extensions.FromHex(@"ddd");
|
||||
public readonly Color4 GrayE = Color4Extensions.FromHex(@"eee");
|
||||
public readonly Color4 GrayF = Color4Extensions.FromHex(@"fff");
|
||||
|
||||
public readonly Color4 RedLighter = FromHex(@"ffeded");
|
||||
public readonly Color4 RedLight = FromHex(@"ed7787");
|
||||
public readonly Color4 Red = FromHex(@"ed1121");
|
||||
public readonly Color4 RedDark = FromHex(@"ba0011");
|
||||
public readonly Color4 RedDarker = FromHex(@"870000");
|
||||
public readonly Color4 RedLighter = Color4Extensions.FromHex(@"ffeded");
|
||||
public readonly Color4 RedLight = Color4Extensions.FromHex(@"ed7787");
|
||||
public readonly Color4 Red = Color4Extensions.FromHex(@"ed1121");
|
||||
public readonly Color4 RedDark = Color4Extensions.FromHex(@"ba0011");
|
||||
public readonly Color4 RedDarker = Color4Extensions.FromHex(@"870000");
|
||||
|
||||
public readonly Color4 ChatBlue = FromHex(@"17292e");
|
||||
public readonly Color4 ChatBlue = Color4Extensions.FromHex(@"17292e");
|
||||
|
||||
public readonly Color4 ContextMenuGray = FromHex(@"223034");
|
||||
public readonly Color4 ContextMenuGray = Color4Extensions.FromHex(@"223034");
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
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.Sprites;
|
||||
@ -38,7 +39,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
sampleClick = audio.Samples.Get(@"UI/generic-select");
|
||||
|
||||
BackgroundColour = Color4.Transparent;
|
||||
BackgroundColourHover = OsuColour.FromHex(@"172023");
|
||||
BackgroundColourHover = Color4Extensions.FromHex(@"172023");
|
||||
|
||||
updateTextColour();
|
||||
}
|
||||
@ -57,7 +58,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
break;
|
||||
|
||||
case MenuItemType.Highlighted:
|
||||
text.Colour = OsuColour.FromHex(@"ffcc22");
|
||||
text.Colour = Color4Extensions.FromHex(@"ffcc22");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,11 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class OsuPasswordTextBox : OsuTextBox, ISuppressKeyEventLogging
|
||||
{
|
||||
protected override Drawable GetDrawableCharacter(char c) => new PasswordMaskChar(CalculatedTextSize);
|
||||
protected override Drawable GetDrawableCharacter(char c) => new FallingDownContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Child = new PasswordMaskChar(CalculatedTextSize),
|
||||
};
|
||||
|
||||
protected override bool AllowClipboardExport => false;
|
||||
|
||||
|
@ -63,7 +63,11 @@ namespace osu.Game.Graphics.UserInterface
|
||||
base.OnFocusLost(e);
|
||||
}
|
||||
|
||||
protected override Drawable GetDrawableCharacter(char c) => new OsuSpriteText { Text = c.ToString(), Font = OsuFont.GetFont(size: CalculatedTextSize) };
|
||||
protected override Drawable GetDrawableCharacter(char c) => new FallingDownContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Child = new OsuSpriteText { Text = c.ToString(), Font = OsuFont.GetFont(size: CalculatedTextSize) },
|
||||
};
|
||||
|
||||
protected override Caret CreateCaret() => new OsuCaret
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class StarCounter : Container
|
||||
{
|
||||
private readonly Container<Star> stars;
|
||||
private readonly FillFlowContainer<Star> stars;
|
||||
|
||||
/// <summary>
|
||||
/// Maximum amount of stars displayed.
|
||||
@ -23,34 +23,29 @@ namespace osu.Game.Graphics.UserInterface
|
||||
/// </remarks>
|
||||
public int StarCount { get; }
|
||||
|
||||
private double animationDelay => 80;
|
||||
/// <summary>
|
||||
/// The added delay for each subsequent star to be animated.
|
||||
/// </summary>
|
||||
protected virtual double AnimationDelay => 80;
|
||||
|
||||
private double scalingDuration => 1000;
|
||||
private Easing scalingEasing => Easing.OutElasticHalf;
|
||||
private float minStarScale => 0.4f;
|
||||
|
||||
private double fadingDuration => 100;
|
||||
private float minStarAlpha => 0.5f;
|
||||
|
||||
private const float star_size = 20;
|
||||
private const float star_spacing = 4;
|
||||
|
||||
private float countStars;
|
||||
private float current;
|
||||
|
||||
/// <summary>
|
||||
/// Amount of stars represented.
|
||||
/// </summary>
|
||||
public float CountStars
|
||||
public float Current
|
||||
{
|
||||
get => countStars;
|
||||
get => current;
|
||||
|
||||
set
|
||||
{
|
||||
if (countStars == value) return;
|
||||
if (current == value) return;
|
||||
|
||||
if (IsLoaded)
|
||||
transformCount(value);
|
||||
countStars = value;
|
||||
animate(value);
|
||||
current = value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,11 +66,13 @@ namespace osu.Game.Graphics.UserInterface
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(star_spacing),
|
||||
ChildrenEnumerable = Enumerable.Range(0, StarCount).Select(i => new Star { Alpha = minStarAlpha })
|
||||
ChildrenEnumerable = Enumerable.Range(0, StarCount).Select(i => CreateStar())
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public virtual Star CreateStar() => new DefaultStar();
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
@ -86,63 +83,60 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
public void ResetCount()
|
||||
{
|
||||
countStars = 0;
|
||||
current = 0;
|
||||
StopAnimation();
|
||||
}
|
||||
|
||||
public void ReplayAnimation()
|
||||
{
|
||||
var t = countStars;
|
||||
var t = current;
|
||||
ResetCount();
|
||||
CountStars = t;
|
||||
Current = t;
|
||||
}
|
||||
|
||||
public void StopAnimation()
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
animate(current);
|
||||
foreach (var star in stars.Children)
|
||||
star.FinishTransforms(true);
|
||||
}
|
||||
|
||||
private float getStarScale(int i, float value) => i + 1 <= value ? 1.0f : Interpolation.ValueAt(value, 0, 1.0f, i, i + 1);
|
||||
|
||||
private void animate(float newValue)
|
||||
{
|
||||
for (var i = 0; i < stars.Children.Count; i++)
|
||||
{
|
||||
var star = stars.Children[i];
|
||||
|
||||
star.ClearTransforms(true);
|
||||
star.FadeTo(i < countStars ? 1.0f : minStarAlpha);
|
||||
star.Icon.ScaleTo(getStarScale(i, countStars));
|
||||
i++;
|
||||
|
||||
double delay = (current <= newValue ? Math.Max(i - current, 0) : Math.Max(current - 1 - i, 0)) * AnimationDelay;
|
||||
|
||||
using (star.BeginDelayedSequence(delay, true))
|
||||
star.DisplayAt(getStarScale(i, newValue));
|
||||
}
|
||||
}
|
||||
|
||||
private float getStarScale(int i, float value)
|
||||
public class DefaultStar : Star
|
||||
{
|
||||
if (value <= i)
|
||||
return minStarScale;
|
||||
private const double scaling_duration = 1000;
|
||||
|
||||
return i + 1 <= value ? 1.0f : Interpolation.ValueAt(value, minStarScale, 1.0f, i, i + 1);
|
||||
}
|
||||
private const double fading_duration = 100;
|
||||
|
||||
private void transformCount(float newValue)
|
||||
{
|
||||
int i = 0;
|
||||
private const Easing scaling_easing = Easing.OutElasticHalf;
|
||||
|
||||
foreach (var star in stars.Children)
|
||||
{
|
||||
star.ClearTransforms(true);
|
||||
private const float min_star_scale = 0.4f;
|
||||
|
||||
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);
|
||||
private const float star_size = 20;
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
private class Star : Container
|
||||
{
|
||||
public readonly SpriteIcon Icon;
|
||||
|
||||
public Star()
|
||||
public DefaultStar()
|
||||
{
|
||||
Size = new Vector2(star_size);
|
||||
|
||||
Child = Icon = new SpriteIcon
|
||||
InternalChild = Icon = new SpriteIcon
|
||||
{
|
||||
Size = new Vector2(star_size),
|
||||
Icon = FontAwesome.Solid.Star,
|
||||
@ -150,6 +144,19 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Origin = Anchor.Centre,
|
||||
};
|
||||
}
|
||||
|
||||
public override void DisplayAt(float scale)
|
||||
{
|
||||
scale = Math.Clamp(scale, min_star_scale, 1);
|
||||
|
||||
this.FadeTo(scale, fading_duration);
|
||||
Icon.ScaleTo(scale, scaling_duration, scaling_easing);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class Star : CompositeDrawable
|
||||
{
|
||||
public abstract void DisplayAt(float scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -42,7 +43,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = OsuColour.FromHex("1c2125"),
|
||||
Colour = Color4Extensions.FromHex("1c2125"),
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
|
Reference in New Issue
Block a user