mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Merge branch 'master' into UserDimLogic
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
|
@ -2,7 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
|
||||
|
@ -4,9 +4,9 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osuTK;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Audio;
|
||||
@ -90,7 +90,7 @@ namespace osu.Game.Graphics.Containers
|
||||
switch (visibility)
|
||||
{
|
||||
case Visibility.Visible:
|
||||
if (OverlayActivationMode != OverlayActivation.Disabled)
|
||||
if (OverlayActivationMode.Value != OverlayActivation.Disabled)
|
||||
{
|
||||
if (PlaySamplesOnStateChange) samplePopIn?.Play();
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Input;
|
||||
using osuTK;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.MathUtils;
|
||||
|
||||
namespace osu.Game.Graphics.Containers
|
||||
@ -45,7 +45,7 @@ namespace osu.Game.Graphics.Containers
|
||||
parallaxEnabled = config.GetBindable<bool>(OsuSetting.MenuParallax);
|
||||
parallaxEnabled.ValueChanged += delegate
|
||||
{
|
||||
if (!parallaxEnabled)
|
||||
if (!parallaxEnabled.Value)
|
||||
{
|
||||
content.MoveTo(Vector2.Zero, firstUpdate ? 0 : 1000, Easing.OutQuint);
|
||||
content.Scale = new Vector2(1 + System.Math.Abs(ParallaxAmount));
|
||||
@ -65,7 +65,7 @@ namespace osu.Game.Graphics.Containers
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (parallaxEnabled)
|
||||
if (parallaxEnabled.Value)
|
||||
{
|
||||
Vector2 offset = (input.CurrentState.Mouse == null ? Vector2.Zero : ToLocalSpace(input.CurrentState.Mouse.Position) - DrawSize / 2) * ParallaxAmount;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Configuration;
|
||||
@ -74,10 +74,10 @@ namespace osu.Game.Graphics.Containers
|
||||
}
|
||||
}
|
||||
|
||||
private void scaleChanged(float value)
|
||||
private void scaleChanged(ValueChangedEvent<float> args)
|
||||
{
|
||||
this.ScaleTo(new Vector2(value), 500, Easing.Out);
|
||||
this.ResizeTo(new Vector2(1 / value), 500, Easing.Out);
|
||||
this.ScaleTo(new Vector2(args.NewValue), 500, Easing.Out);
|
||||
this.ResizeTo(new Vector2(1 / args.NewValue), 500, Easing.Out);
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ namespace osu.Game.Graphics.Containers
|
||||
sizableContainer.FinishTransforms();
|
||||
}
|
||||
|
||||
private bool requiresBackgroundVisible => (scalingMode == ScalingMode.Everything || scalingMode == ScalingMode.ExcludeOverlays) && (sizeX.Value != 1 || sizeY.Value != 1);
|
||||
private bool requiresBackgroundVisible => (scalingMode.Value == ScalingMode.Everything || scalingMode.Value == ScalingMode.ExcludeOverlays) && (sizeX.Value != 1 || sizeY.Value != 1);
|
||||
|
||||
private void updateSize()
|
||||
{
|
||||
@ -137,8 +137,8 @@ namespace osu.Game.Graphics.Containers
|
||||
|
||||
bool scaling = targetMode == null || scalingMode.Value == targetMode;
|
||||
|
||||
var targetSize = scaling ? new Vector2(sizeX, sizeY) : Vector2.One;
|
||||
var targetPosition = scaling ? new Vector2(posX, posY) * (Vector2.One - targetSize) : Vector2.Zero;
|
||||
var targetSize = scaling ? new Vector2(sizeX.Value, sizeY.Value) : Vector2.One;
|
||||
var targetPosition = scaling ? new Vector2(posX.Value, posY.Value) * (Vector2.One - targetSize) : Vector2.Zero;
|
||||
bool requiresMasking = scaling && targetSize != Vector2.One;
|
||||
|
||||
if (requiresMasking)
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
using osuTK;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
@ -11,6 +10,7 @@ using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Configuration;
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Input.Events;
|
||||
using osuTK.Input;
|
||||
@ -80,7 +80,7 @@ namespace osu.Game.Graphics.Cursor
|
||||
activeCursor.AdditiveLayer.FadeInFromZero(800, Easing.OutQuint);
|
||||
}
|
||||
|
||||
if (e.Button == MouseButton.Left && cursorRotate)
|
||||
if (e.Button == MouseButton.Left && cursorRotate.Value)
|
||||
{
|
||||
dragRotationState = DragRotationState.DragStarted;
|
||||
positionMouseDown = e.MousePosition;
|
||||
@ -156,7 +156,7 @@ namespace osu.Game.Graphics.Cursor
|
||||
};
|
||||
|
||||
cursorScale = config.GetBindable<double>(OsuSetting.MenuCursorSize);
|
||||
cursorScale.ValueChanged += newScale => cursorContainer.Scale = new Vector2((float)newScale * base_scale);
|
||||
cursorScale.ValueChanged += scale => cursorContainer.Scale = new Vector2((float)scale.NewValue * base_scale);
|
||||
cursorScale.TriggerChange();
|
||||
}
|
||||
}
|
||||
|
@ -46,8 +46,6 @@ namespace osu.Game.Graphics.Cursor
|
||||
}
|
||||
}
|
||||
|
||||
private const float text_size = 16;
|
||||
|
||||
public OsuTooltip()
|
||||
{
|
||||
AutoSizeEasing = Easing.OutQuint;
|
||||
@ -69,9 +67,8 @@ namespace osu.Game.Graphics.Cursor
|
||||
},
|
||||
text = new OsuSpriteText
|
||||
{
|
||||
TextSize = text_size,
|
||||
Padding = new MarginPadding(5),
|
||||
Font = @"Exo2.0-Regular",
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Regular)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -30,8 +30,7 @@ namespace osu.Game.Graphics
|
||||
|
||||
public DrawableDate(DateTimeOffset date)
|
||||
{
|
||||
Font = "Exo2.0-RegularItalic";
|
||||
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Regular, italics: true);
|
||||
Date = date;
|
||||
}
|
||||
|
||||
|
117
osu.Game/Graphics/OsuFont.cs
Normal file
117
osu.Game/Graphics/OsuFont.cs
Normal file
@ -0,0 +1,117 @@
|
||||
// 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 osu.Framework.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Graphics
|
||||
{
|
||||
public struct OsuFont
|
||||
{
|
||||
/// <summary>
|
||||
/// The default font size.
|
||||
/// </summary>
|
||||
public const float DEFAULT_FONT_SIZE = 16;
|
||||
|
||||
/// <summary>
|
||||
/// The default font.
|
||||
/// </summary>
|
||||
public static FontUsage Default => GetFont();
|
||||
|
||||
public static FontUsage Numeric => GetFont(Typeface.Venera, weight: FontWeight.Regular);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a <see cref="FontUsage"/>.
|
||||
/// </summary>
|
||||
/// <param name="typeface">The font typeface.</param>
|
||||
/// <param name="size">The size of the text in local space. For a value of 16, a single line will have a height of 16px.</param>
|
||||
/// <param name="weight">The font weight.</param>
|
||||
/// <param name="italics">Whether the font is italic.</param>
|
||||
/// <param name="fixedWidth">Whether all characters should be spaced the same distance apart.</param>
|
||||
/// <returns>The <see cref="FontUsage"/>.</returns>
|
||||
public static FontUsage GetFont(Typeface typeface = Typeface.Exo, float size = DEFAULT_FONT_SIZE, FontWeight weight = FontWeight.Medium, bool italics = false, bool fixedWidth = false)
|
||||
=> new FontUsage(GetFamilyString(typeface), size, GetWeightString(typeface, weight), italics, fixedWidth);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the string representation of a <see cref="Typeface"/>.
|
||||
/// </summary>
|
||||
/// <param name="typeface">The <see cref="Typeface"/>.</param>
|
||||
/// <returns>The string representation.</returns>
|
||||
public static string GetFamilyString(Typeface typeface)
|
||||
{
|
||||
switch (typeface)
|
||||
{
|
||||
case Typeface.Exo:
|
||||
return "Exo2.0";
|
||||
case Typeface.FontAwesome:
|
||||
return "FontAwesome";
|
||||
case Typeface.Venera:
|
||||
return "Venera";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the string representation of a <see cref="FontWeight"/>.
|
||||
/// </summary>
|
||||
/// <param name="typeface">The <see cref="Typeface"/>.</param>
|
||||
/// <param name="weight">The <see cref="FontWeight"/>.</param>
|
||||
/// <returns>The string representation of <paramref name="weight"/> in the specified <paramref name="typeface"/>.</returns>
|
||||
public static string GetWeightString(Typeface typeface, FontWeight weight)
|
||||
=> GetWeightString(GetFamilyString(typeface), weight);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the string representation of a <see cref="FontWeight"/>.
|
||||
/// </summary>
|
||||
/// <param name="typeface">The <see cref="Typeface"/>.</param>
|
||||
/// <param name="weight">The <see cref="FontWeight"/>.</param>
|
||||
/// <returns>The string representation of <paramref name="weight"/> in the specified <paramref name="typeface"/>.</returns>
|
||||
public static string GetWeightString(string family, FontWeight weight)
|
||||
{
|
||||
string weightString = weight.ToString();
|
||||
|
||||
// Only exo has an explicit "regular" weight, other fonts do not
|
||||
if (family != GetFamilyString(Typeface.Exo) && weight == FontWeight.Regular)
|
||||
weightString = string.Empty;
|
||||
|
||||
return weightString;
|
||||
}
|
||||
}
|
||||
|
||||
public static class OsuFontExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="FontUsage"/> by applying adjustments to this <see cref="FontUsage"/>.
|
||||
/// </summary>
|
||||
/// <param name="typeface">The font typeface. If null, the value is copied from this <see cref="FontUsage"/>.</param>
|
||||
/// <param name="size">The text size. If null, the value is copied from this <see cref="FontUsage"/>.</param>
|
||||
/// <param name="weight">The font weight. If null, the value is copied from this <see cref="FontUsage"/>.</param>
|
||||
/// <param name="italics">Whether the font is italic. If null, the value is copied from this <see cref="FontUsage"/>.</param>
|
||||
/// <param name="fixedWidth">Whether all characters should be spaced apart the same distance. If null, the value is copied from this <see cref="FontUsage"/>.</param>
|
||||
/// <returns>The resulting <see cref="FontUsage"/>.</returns>
|
||||
public static FontUsage With(this FontUsage usage, Typeface? typeface = null, float? size = null, FontWeight? weight = null, bool? italics = null, bool? fixedWidth = null)
|
||||
{
|
||||
string familyString = typeface != null ? OsuFont.GetFamilyString(typeface.Value) : usage.Family;
|
||||
string weightString = weight != null ? OsuFont.GetWeightString(familyString, weight.Value) : usage.Weight;
|
||||
|
||||
return usage.With(familyString, size, weightString, italics, fixedWidth);
|
||||
}
|
||||
}
|
||||
|
||||
public enum Typeface
|
||||
{
|
||||
Exo,
|
||||
FontAwesome,
|
||||
Venera,
|
||||
}
|
||||
|
||||
public enum FontWeight
|
||||
{
|
||||
Light,
|
||||
Regular,
|
||||
Medium,
|
||||
SemiBold,
|
||||
Bold,
|
||||
Black
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Input.Bindings;
|
||||
@ -127,7 +127,7 @@ namespace osu.Game.Graphics
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (cursorVisibility == false && Interlocked.CompareExchange(ref screenShotTasks, 0, 0) == 0)
|
||||
if (cursorVisibility.Value == false && Interlocked.CompareExchange(ref screenShotTasks, 0, 0) == 0)
|
||||
cursorVisibility.Value = true;
|
||||
}
|
||||
|
||||
|
@ -9,12 +9,10 @@ namespace osu.Game.Graphics.Sprites
|
||||
{
|
||||
public class OsuSpriteText : SpriteText
|
||||
{
|
||||
public const float FONT_SIZE = 16;
|
||||
|
||||
public OsuSpriteText()
|
||||
{
|
||||
Shadow = true;
|
||||
TextSize = FONT_SIZE;
|
||||
Font = OsuFont.Default;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,12 +27,12 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
Height = 32;
|
||||
TabContainer.Spacing = new Vector2(padding, 0f);
|
||||
Current.ValueChanged += tab =>
|
||||
Current.ValueChanged += index =>
|
||||
{
|
||||
foreach (var t in TabContainer.Children.OfType<BreadcrumbTabItem>())
|
||||
{
|
||||
var tIndex = TabContainer.IndexOf(t);
|
||||
var tabIndex = TabContainer.IndexOf(TabMap[tab]);
|
||||
var tabIndex = TabContainer.IndexOf(TabMap[index.NewValue]);
|
||||
|
||||
t.State = tIndex < tabIndex ? Visibility.Hidden : Visibility.Visible;
|
||||
t.Chevron.FadeTo(tIndex <= tabIndex ? 0f : 1f, 500, Easing.OutQuint);
|
||||
@ -82,7 +82,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
public BreadcrumbTabItem(T value) : base(value)
|
||||
{
|
||||
Text.TextSize = 18;
|
||||
Text.Font = Text.Font.With(size: 18);
|
||||
Text.Margin = new MarginPadding { Vertical = 8 };
|
||||
Padding = new MarginPadding { Right = padding + item_chevron_size };
|
||||
Add(Chevron = new SpriteIcon
|
||||
|
@ -1,6 +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 osu.Framework.Bindables;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Graphics;
|
||||
@ -12,7 +13,6 @@ using osu.Game.Graphics.Backgrounds;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Input.Events;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
@ -141,8 +141,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Text = Text,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
TextSize = 28,
|
||||
Font = "Exo2.0-Bold",
|
||||
Font = OsuFont.GetFont(size: 28, weight: FontWeight.Bold),
|
||||
Shadow = true,
|
||||
ShadowColour = new Color4(0, 0, 0, 0.1f),
|
||||
Colour = Color4.White,
|
||||
@ -197,18 +196,10 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
private float textSize = 28;
|
||||
public float TextSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return textSize;
|
||||
}
|
||||
set
|
||||
{
|
||||
textSize = value;
|
||||
spriteText.TextSize = value;
|
||||
}
|
||||
get => spriteText.Font.Size;
|
||||
set => spriteText.Font = spriteText.Font.With(size: value);
|
||||
}
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => backgroundContainer.ReceivePositionalInputAt(screenSpacePos);
|
||||
@ -242,9 +233,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Selected.Value = false;
|
||||
}
|
||||
|
||||
private void selectionChanged(bool isSelected)
|
||||
private void selectionChanged(ValueChangedEvent<bool> args)
|
||||
{
|
||||
if (isSelected)
|
||||
if (args.NewValue)
|
||||
{
|
||||
spriteText.TransformSpacingTo(hoverSpacing, hover_duration, Easing.OutElastic);
|
||||
colourContainer.ResizeTo(new Vector2(hover_width, 1f), hover_duration, Easing.OutElastic);
|
||||
|
@ -5,7 +5,7 @@ using System;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -41,9 +41,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
},
|
||||
};
|
||||
|
||||
Current.ValueChanged += newValue =>
|
||||
Current.ValueChanged += filled =>
|
||||
{
|
||||
if (newValue)
|
||||
if (filled.NewValue)
|
||||
fill.FadeIn(200, Easing.OutQuint);
|
||||
else
|
||||
fill.FadeTo(0.01f, 200, Easing.OutQuint); //todo: remove once we figure why containers aren't drawing at all times
|
||||
|
@ -73,7 +73,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
Enabled.BindValueChanged(enabled => this.FadeColour(enabled ? Color4.White : colours.Gray9, 200, Easing.OutQuint), true);
|
||||
Enabled.BindValueChanged(enabled => this.FadeColour(enabled.NewValue ? Color4.White : colours.Gray9, 200, Easing.OutQuint), true);
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -46,13 +47,13 @@ namespace osu.Game.Graphics.UserInterface
|
||||
new HoverClickSounds(HoverSampleSet.Loud),
|
||||
});
|
||||
|
||||
Enabled.ValueChanged += enabled_ValueChanged;
|
||||
Enabled.ValueChanged += enabledChanged;
|
||||
Enabled.TriggerChange();
|
||||
}
|
||||
|
||||
private void enabled_ValueChanged(bool enabled)
|
||||
private void enabledChanged(ValueChangedEvent<bool> e)
|
||||
{
|
||||
this.FadeColour(enabled ? Color4.White : Color4.Gray, 200, Easing.OutQuint);
|
||||
this.FadeColour(e.NewValue ? Color4.White : Color4.Gray, 200, Easing.OutQuint);
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
@ -84,7 +85,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Depth = -1,
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Font = @"Exo2.0-Bold",
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Bold)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
@ -86,9 +86,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Current.ValueChanged += newValue =>
|
||||
Current.ValueChanged += enabled =>
|
||||
{
|
||||
if (newValue)
|
||||
if (enabled.NewValue)
|
||||
sampleChecked?.Play();
|
||||
else
|
||||
sampleUnchecked?.Play();
|
||||
|
@ -149,7 +149,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
TextSize = text_size,
|
||||
Font = OsuFont.GetFont(size: text_size),
|
||||
Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL },
|
||||
},
|
||||
BoldText = new OsuSpriteText
|
||||
@ -158,8 +158,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Alpha = 0,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
TextSize = text_size,
|
||||
Font = @"Exo2.0-Bold",
|
||||
Font = OsuFont.GetFont(size: text_size, weight: FontWeight.Bold),
|
||||
Margin = new MarginPadding { Horizontal = margin_horizontal, Vertical = MARGIN_VERTICAL },
|
||||
}
|
||||
};
|
||||
|
@ -95,7 +95,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
CurrentNumber.BindValueChanged(updateTooltipText, true);
|
||||
CurrentNumber.BindValueChanged(current => updateTooltipText(current.NewValue), true);
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
|
@ -6,7 +6,7 @@ using System.Linq;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
@ -107,7 +107,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
set
|
||||
{
|
||||
accentColour = value;
|
||||
if (!Active)
|
||||
if (!Active.Value)
|
||||
Text.Colour = value;
|
||||
}
|
||||
}
|
||||
@ -128,14 +128,14 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
if (!Active)
|
||||
if (!Active.Value)
|
||||
fadeActive();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
if (!Active)
|
||||
if (!Active.Value)
|
||||
fadeInactive();
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Text = (value as IHasDescription)?.Description ?? (value as Enum)?.GetDescription() ?? value.ToString(),
|
||||
TextSize = 14,
|
||||
Font = OsuFont.GetFont(size: 14)
|
||||
},
|
||||
Bar = new Box
|
||||
{
|
||||
@ -173,7 +173,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
new HoverClickSounds()
|
||||
};
|
||||
|
||||
Active.BindValueChanged(val => Text.Font = val ? @"Exo2.0-Bold" : @"Exo2.0", true);
|
||||
Active.BindValueChanged(active => Text.Font = Text.Font.With(Typeface.Exo, weight: active.NewValue ? FontWeight.Bold : FontWeight.Medium), true);
|
||||
}
|
||||
|
||||
protected override void OnActivated() => fadeActive();
|
||||
|
@ -31,7 +31,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
accentColour = value;
|
||||
|
||||
if (Current)
|
||||
if (Current.Value)
|
||||
{
|
||||
text.Colour = AccentColour;
|
||||
icon.Colour = AccentColour;
|
||||
@ -67,7 +67,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
if (!Current)
|
||||
if (!Current.Value)
|
||||
fadeOut();
|
||||
|
||||
base.OnHoverLost(e);
|
||||
@ -94,11 +94,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
text = new OsuSpriteText
|
||||
{
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Bold",
|
||||
},
|
||||
text = new OsuSpriteText { Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold) },
|
||||
icon = new SpriteIcon
|
||||
{
|
||||
Size = new Vector2(14),
|
||||
@ -118,9 +114,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
};
|
||||
|
||||
Current.ValueChanged += v =>
|
||||
Current.ValueChanged += selected =>
|
||||
{
|
||||
if (v)
|
||||
if (selected.NewValue)
|
||||
{
|
||||
fadeIn();
|
||||
icon.Icon = FontAwesome.fa_check_circle_o;
|
||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected override SpriteText CreatePlaceholder() => new OsuSpriteText
|
||||
{
|
||||
Font = @"Exo2.0-MediumItalic",
|
||||
Font = OsuFont.GetFont(italics: true),
|
||||
Colour = new Color4(180, 180, 180, 255),
|
||||
Margin = new MarginPadding { Left = 2 },
|
||||
};
|
||||
@ -57,7 +57,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
base.OnFocusLost(e);
|
||||
}
|
||||
|
||||
protected override Drawable GetDrawableCharacter(char c) => new OsuSpriteText { Text = c.ToString(), TextSize = CalculatedTextSize };
|
||||
protected override Drawable GetDrawableCharacter(char c) => new OsuSpriteText { Text = c.ToString(), Font = OsuFont.GetFont(size: CalculatedTextSize) };
|
||||
|
||||
public virtual bool OnPressed(GlobalAction action)
|
||||
{
|
||||
|
@ -45,7 +45,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Text = (value as Enum)?.GetDescription() ?? value.ToString(),
|
||||
TextSize = 14,
|
||||
Font = OsuFont.GetFont(size: 14)
|
||||
},
|
||||
box = new Box
|
||||
{
|
||||
@ -59,7 +59,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
new HoverClickSounds()
|
||||
};
|
||||
|
||||
Active.BindValueChanged(val => Text.Font = val ? @"Exo2.0-Bold" : @"Exo2.0", true);
|
||||
Active.BindValueChanged(active => Text.Font = Text.Font.With(Typeface.Exo, weight: active.NewValue ? FontWeight.Bold : FontWeight.Medium), true);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -70,14 +70,14 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
if (!Active)
|
||||
if (!Active.Value)
|
||||
slideActive();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
if (!Active)
|
||||
if (!Active.Value)
|
||||
slideInactive();
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
public PercentageCounter()
|
||||
{
|
||||
DisplayedCountSpriteText.FixedWidth = true;
|
||||
DisplayedCountSpriteText.Font = DisplayedCountSpriteText.Font.With(fixedWidth: true);
|
||||
Current.Value = DisplayedCount = 1.0f;
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
public override void Increment(double amount)
|
||||
{
|
||||
Current.Value = Current + amount;
|
||||
Current.Value = Current.Value + amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
// 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 osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Bindables;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
@ -61,16 +61,11 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
public abstract void Increment(T amount);
|
||||
|
||||
private float textSize;
|
||||
|
||||
public float TextSize
|
||||
{
|
||||
get { return textSize; }
|
||||
set
|
||||
{
|
||||
textSize = value;
|
||||
DisplayedCountSpriteText.TextSize = value;
|
||||
}
|
||||
get => DisplayedCountSpriteText.Font.Size;
|
||||
set => DisplayedCountSpriteText.Font = DisplayedCountSpriteText.Font.With(size: value);
|
||||
}
|
||||
|
||||
public Color4 AccentColour
|
||||
@ -86,20 +81,17 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
DisplayedCountSpriteText = new OsuSpriteText
|
||||
{
|
||||
Font = @"Venera"
|
||||
},
|
||||
DisplayedCountSpriteText = new OsuSpriteText { Font = OsuFont.Numeric }
|
||||
};
|
||||
|
||||
TextSize = 40;
|
||||
AutoSizeAxes = Axes.Both;
|
||||
|
||||
DisplayedCount = Current;
|
||||
DisplayedCount = Current.Value;
|
||||
|
||||
Current.ValueChanged += newValue =>
|
||||
Current.ValueChanged += val =>
|
||||
{
|
||||
if (IsLoaded) TransformCount(displayedCount, newValue);
|
||||
if (IsLoaded) TransformCount(displayedCount, val.NewValue);
|
||||
};
|
||||
}
|
||||
|
||||
@ -107,7 +99,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
DisplayedCountSpriteText.Text = FormatCount(Current);
|
||||
DisplayedCountSpriteText.Text = FormatCount(Current.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -126,7 +118,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
public virtual void StopRolling()
|
||||
{
|
||||
FinishTransforms(false, nameof(DisplayedCount));
|
||||
DisplayedCount = Current;
|
||||
DisplayedCount = Current.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -28,7 +28,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
/// <param name="leading">How many leading zeroes the counter will have.</param>
|
||||
public ScoreCounter(uint leading = 0)
|
||||
{
|
||||
DisplayedCountSpriteText.FixedWidth = true;
|
||||
DisplayedCountSpriteText.Font = DisplayedCountSpriteText.Font.With(fixedWidth: true);
|
||||
LeadingZeroes = leading;
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
public override void Increment(double amount)
|
||||
{
|
||||
Current.Value = Current + amount;
|
||||
Current.Value = Current.Value + amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
onPushed(null, stack.CurrentScreen);
|
||||
|
||||
Current.ValueChanged += newScreen => newScreen.MakeCurrent();
|
||||
Current.ValueChanged += current => current.NewValue.MakeCurrent();
|
||||
}
|
||||
|
||||
private void onPushed(IScreen lastScreen, IScreen newScreen)
|
||||
|
@ -33,7 +33,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
public override void Increment(int amount)
|
||||
{
|
||||
Current.Value = Current + amount;
|
||||
Current.Value = Current.Value + amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user