1
0
mirror of https://github.com/ppy/osu.git synced 2026-06-03 11:30:49 +08:00

Temporary rollback of framework / SDL3

This commit is contained in:
Dean Herbert
2024-05-21 14:34:53 +08:00
Unverified
parent e740b8bcc3
commit d7d569cf4e
44 changed files with 304 additions and 226 deletions
@@ -1,7 +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.Numerics;
using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@@ -10,7 +10,7 @@ using osu.Framework.Graphics.UserInterface;
using osu.Framework.Localisation;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using Vector2 = osuTK.Vector2;
using osuTK;
namespace osu.Game.Graphics.UserInterface
{
@@ -18,7 +18,7 @@ namespace osu.Game.Graphics.UserInterface
/// An <see cref="IExpandable"/> implementation for the UI slider bar control.
/// </summary>
public partial class ExpandableSlider<T, TSlider> : CompositeDrawable, IExpandable, IHasCurrentValue<T>
where T : struct, INumber<T>, IMinMaxValue<T>
where T : struct, IEquatable<T>, IComparable<T>, IConvertible
where TSlider : RoundedSliderBar<T>, new()
{
private readonly OsuSpriteText label;
@@ -129,7 +129,7 @@ namespace osu.Game.Graphics.UserInterface
/// An <see cref="IExpandable"/> implementation for the UI slider bar control.
/// </summary>
public partial class ExpandableSlider<T> : ExpandableSlider<T, RoundedSliderBar<T>>
where T : struct, INumber<T>, IMinMaxValue<T>
where T : struct, IEquatable<T>, IComparable<T>, IConvertible
{
}
}
@@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Numerics;
using System.Globalization;
using osu.Framework.Allocation;
using osu.Framework.Audio;
@@ -16,7 +15,7 @@ using osu.Game.Utils;
namespace osu.Game.Graphics.UserInterface
{
public abstract partial class OsuSliderBar<T> : SliderBar<T>, IHasTooltip
where T : struct, INumber<T>, IMinMaxValue<T>
where T : struct, IEquatable<T>, IComparable<T>, IConvertible
{
public bool PlaySamplesOnAdjust { get; set; } = true;
@@ -86,11 +85,11 @@ namespace osu.Game.Graphics.UserInterface
private LocalisableString getTooltipText(T value)
{
if (CurrentNumber.IsInteger)
return int.CreateTruncating(value).ToString("N0");
return value.ToInt32(NumberFormatInfo.InvariantInfo).ToString("N0");
double floatValue = double.CreateTruncating(value);
double floatValue = value.ToDouble(NumberFormatInfo.InvariantInfo);
decimal decimalPrecision = normalise(decimal.CreateTruncating(CurrentNumber.Precision), max_decimal_digits);
decimal decimalPrecision = normalise(CurrentNumber.Precision.ToDecimal(NumberFormatInfo.InvariantInfo), max_decimal_digits);
// Find the number of significant digits (we could have less than 5 after normalize())
int significantDigits = FormatUtils.FindPrecision(decimalPrecision);
@@ -8,8 +8,6 @@ using System.Linq;
using osuTK;
using osuTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Extensions.Color4Extensions;
@@ -145,6 +143,13 @@ namespace osu.Game.Graphics.UserInterface
FadeUnhovered();
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
if (accentColour == default)
AccentColour = colours.Blue;
}
public OsuTabItem(T value)
: base(value)
{
@@ -191,21 +196,10 @@ namespace osu.Game.Graphics.UserInterface
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
},
new HoverSounds(HoverSampleSet.TabSelect)
new HoverClickSounds(HoverSampleSet.TabSelect)
};
}
private Sample selectSample;
[BackgroundDependencyLoader]
private void load(OsuColour colours, AudioManager audio)
{
if (accentColour == default)
AccentColour = colours.Blue;
selectSample = audio.Samples.Get(@"UI/tabselect-select");
}
protected override void OnActivated()
{
Text.Font = Text.Font.With(weight: FontWeight.Bold);
@@ -217,8 +211,6 @@ namespace osu.Game.Graphics.UserInterface
Text.Font = Text.Font.With(weight: FontWeight.Medium);
FadeUnhovered();
}
protected override void OnActivatedByUser() => selectSample.Play();
}
}
}
@@ -7,8 +7,6 @@ using System;
using osuTK;
using osuTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
@@ -55,8 +53,6 @@ namespace osu.Game.Graphics.UserInterface
}
}
private Sample selectSample = null!;
public PageTabItem(T value)
: base(value)
{
@@ -82,18 +78,12 @@ namespace osu.Game.Graphics.UserInterface
Origin = Anchor.BottomLeft,
Anchor = Anchor.BottomLeft,
},
new HoverSounds(HoverSampleSet.TabSelect)
new HoverClickSounds(HoverSampleSet.TabSelect)
};
Active.BindValueChanged(active => Text.Font = Text.Font.With(Typeface.Torus, weight: active.NewValue ? FontWeight.Bold : FontWeight.Medium), true);
}
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
selectSample = audio.Samples.Get(@"UI/tabselect-select");
}
protected virtual LocalisableString CreateText() => (Value as Enum)?.GetLocalisableDescription() ?? Value.ToString();
protected override bool OnHover(HoverEvent e)
@@ -122,8 +112,6 @@ namespace osu.Game.Graphics.UserInterface
protected override void OnActivated() => slideActive();
protected override void OnDeactivated() => slideInactive();
protected override void OnActivatedByUser() => selectSample.Play();
}
}
}
@@ -2,7 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Numerics;
using osuTK;
using osuTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
@@ -11,12 +11,11 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Game.Overlays;
using Vector2 = osuTK.Vector2;
namespace osu.Game.Graphics.UserInterface
{
public partial class RoundedSliderBar<T> : OsuSliderBar<T>
where T : struct, INumber<T>, IMinMaxValue<T>
where T : struct, IEquatable<T>, IComparable<T>, IConvertible
{
protected readonly Nub Nub;
protected readonly Box LeftBox;
@@ -2,7 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Numerics;
using osuTK;
using osuTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
@@ -12,12 +12,11 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Game.Overlays;
using static osu.Game.Graphics.UserInterface.ShearedNub;
using Vector2 = osuTK.Vector2;
namespace osu.Game.Graphics.UserInterface
{
public partial class ShearedSliderBar<T> : OsuSliderBar<T>
where T : struct, INumber<T>, IMinMaxValue<T>
where T : struct, IEquatable<T>, IComparable<T>, IConvertible
{
protected readonly ShearedNub Nub;
protected readonly Box LeftBox;