mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Merge branch 'master' into fix-tournament-ruleset-dropdown-anchor
This commit is contained in:
@ -86,13 +86,24 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
/// </summary>
|
||||
public float Velocity = 1;
|
||||
|
||||
private readonly Random stableRandom;
|
||||
|
||||
private float nextRandom() => (float)(stableRandom?.NextDouble() ?? RNG.NextSingle());
|
||||
|
||||
private readonly SortedList<TriangleParticle> parts = new SortedList<TriangleParticle>(Comparer<TriangleParticle>.Default);
|
||||
|
||||
private IShader shader;
|
||||
private readonly Texture texture;
|
||||
|
||||
public Triangles()
|
||||
/// <summary>
|
||||
/// Construct a new triangle visualisation.
|
||||
/// </summary>
|
||||
/// <param name="seed">An optional seed to stabilise random positions / attributes. Note that this does not guarantee stable playback when seeking in time.</param>
|
||||
public Triangles(int? seed = null)
|
||||
{
|
||||
if (seed != null)
|
||||
stableRandom = new Random(seed.Value);
|
||||
|
||||
texture = Texture.WhitePixel;
|
||||
}
|
||||
|
||||
@ -175,8 +186,8 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
{
|
||||
TriangleParticle particle = CreateTriangle();
|
||||
|
||||
particle.Position = new Vector2(RNG.NextSingle(), randomY ? RNG.NextSingle() : 1);
|
||||
particle.ColourShade = RNG.NextSingle();
|
||||
particle.Position = new Vector2(nextRandom(), randomY ? nextRandom() : 1);
|
||||
particle.ColourShade = nextRandom();
|
||||
particle.Colour = CreateTriangleShade(particle.ColourShade);
|
||||
|
||||
return particle;
|
||||
@ -191,8 +202,8 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
const float std_dev = 0.16f;
|
||||
const float mean = 0.5f;
|
||||
|
||||
float u1 = 1 - RNG.NextSingle(); //uniform(0,1] random floats
|
||||
float u2 = 1 - RNG.NextSingle();
|
||||
float u1 = 1 - nextRandom(); //uniform(0,1] random floats
|
||||
float u2 = 1 - nextRandom();
|
||||
float randStdNormal = (float)(Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2)); // random normal(0,1)
|
||||
var scale = Math.Max(triangleScale * (mean + std_dev * randStdNormal), 0.1f); // random normal(mean,stdDev^2)
|
||||
|
||||
|
@ -112,6 +112,9 @@ namespace osu.Game.Graphics.Containers
|
||||
|
||||
CornerRadius = 5;
|
||||
|
||||
// needs to be set initially for the ResizeTo to respect minimum size
|
||||
Size = new Vector2(SCROLL_BAR_HEIGHT);
|
||||
|
||||
const float margin = 3;
|
||||
|
||||
Margin = new MarginPadding
|
||||
|
@ -2,7 +2,6 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Utils;
|
||||
@ -28,9 +27,6 @@ namespace osu.Game.Graphics.UserInterface
|
||||
Current.Value = DisplayedCount = 1.0f;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours) => Colour = colours.BlueLighter;
|
||||
|
||||
protected override string FormatCount(double count) => count.FormatAccuracy();
|
||||
|
||||
protected override double GetProportionalDuration(double currentValue, double newValue)
|
||||
|
@ -56,8 +56,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
return;
|
||||
|
||||
displayedCount = value;
|
||||
if (displayedCountSpriteText != null)
|
||||
displayedCountSpriteText.Text = FormatCount(value);
|
||||
UpdateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,10 +72,17 @@ namespace osu.Game.Graphics.UserInterface
|
||||
private void load()
|
||||
{
|
||||
displayedCountSpriteText = CreateSpriteText();
|
||||
displayedCountSpriteText.Text = FormatCount(DisplayedCount);
|
||||
|
||||
UpdateDisplay();
|
||||
Child = displayedCountSpriteText;
|
||||
}
|
||||
|
||||
protected void UpdateDisplay()
|
||||
{
|
||||
if (displayedCountSpriteText != null)
|
||||
displayedCountSpriteText.Text = FormatCount(DisplayedCount);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
@ -1,35 +1,37 @@
|
||||
// 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.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
public class ScoreCounter : RollingCounter<double>
|
||||
public abstract class ScoreCounter : RollingCounter<double>, IScoreCounter
|
||||
{
|
||||
protected override double RollingDuration => 1000;
|
||||
protected override Easing RollingEasing => Easing.Out;
|
||||
|
||||
public bool UseCommaSeparator;
|
||||
|
||||
/// <summary>
|
||||
/// How many leading zeroes the counter has.
|
||||
/// Whether comma separators should be displayed.
|
||||
/// </summary>
|
||||
public uint LeadingZeroes { get; }
|
||||
public bool UseCommaSeparator { get; }
|
||||
|
||||
public Bindable<int> RequiredDisplayDigits { get; } = new Bindable<int>();
|
||||
|
||||
/// <summary>
|
||||
/// Displays score.
|
||||
/// </summary>
|
||||
/// <param name="leading">How many leading zeroes the counter will have.</param>
|
||||
public ScoreCounter(uint leading = 0)
|
||||
/// <param name="useCommaSeparator">Whether comma separators should be displayed.</param>
|
||||
protected ScoreCounter(int leading = 0, bool useCommaSeparator = false)
|
||||
{
|
||||
LeadingZeroes = leading;
|
||||
}
|
||||
UseCommaSeparator = useCommaSeparator;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours) => Colour = colours.BlueLighter;
|
||||
RequiredDisplayDigits.Value = leading;
|
||||
RequiredDisplayDigits.BindValueChanged(_ => UpdateDisplay());
|
||||
}
|
||||
|
||||
protected override double GetProportionalDuration(double currentValue, double newValue)
|
||||
{
|
||||
@ -38,7 +40,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
protected override string FormatCount(double count)
|
||||
{
|
||||
string format = new string('0', (int)LeadingZeroes);
|
||||
string format = new string('0', RequiredDisplayDigits.Value);
|
||||
|
||||
if (UseCommaSeparator)
|
||||
{
|
||||
|
@ -1,39 +0,0 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
/// <summary>
|
||||
/// Used as an accuracy counter. Represented visually as a percentage.
|
||||
/// </summary>
|
||||
public class SimpleComboCounter : RollingCounter<int>
|
||||
{
|
||||
protected override double RollingDuration => 750;
|
||||
|
||||
public SimpleComboCounter()
|
||||
{
|
||||
Current.Value = DisplayedCount = 0;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours) => Colour = colours.BlueLighter;
|
||||
|
||||
protected override string FormatCount(int count)
|
||||
{
|
||||
return $@"{count}x";
|
||||
}
|
||||
|
||||
protected override double GetProportionalDuration(int currentValue, int newValue)
|
||||
{
|
||||
return Math.Abs(currentValue - newValue) * RollingDuration * 100.0f;
|
||||
}
|
||||
|
||||
protected override OsuSpriteText CreateSpriteText()
|
||||
=> base.CreateSpriteText().With(s => s.Font = s.Font.With(size: 20f));
|
||||
}
|
||||
}
|
@ -28,11 +28,11 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
private GameHost host { get; set; }
|
||||
|
||||
[Cached]
|
||||
public readonly Bindable<DirectoryInfo> CurrentDirectory = new Bindable<DirectoryInfo>();
|
||||
public readonly Bindable<DirectoryInfo> CurrentPath = new Bindable<DirectoryInfo>();
|
||||
|
||||
public DirectorySelector(string initialPath = null)
|
||||
{
|
||||
CurrentDirectory.Value = new DirectoryInfo(initialPath ?? Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
|
||||
CurrentPath.Value = new DirectoryInfo(initialPath ?? Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -74,7 +74,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
}
|
||||
};
|
||||
|
||||
CurrentDirectory.BindValueChanged(updateDisplay, true);
|
||||
CurrentPath.BindValueChanged(updateDisplay, true);
|
||||
}
|
||||
|
||||
private void updateDisplay(ValueChangedEvent<DirectoryInfo> directory)
|
||||
@ -92,22 +92,27 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
}
|
||||
else
|
||||
{
|
||||
directoryFlow.Add(new ParentDirectoryPiece(CurrentDirectory.Value.Parent));
|
||||
directoryFlow.Add(new ParentDirectoryPiece(CurrentPath.Value.Parent));
|
||||
|
||||
foreach (var dir in CurrentDirectory.Value.GetDirectories().OrderBy(d => d.Name))
|
||||
{
|
||||
if ((dir.Attributes & FileAttributes.Hidden) == 0)
|
||||
directoryFlow.Add(new DirectoryPiece(dir));
|
||||
}
|
||||
directoryFlow.AddRange(GetEntriesForPath(CurrentPath.Value));
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CurrentDirectory.Value = directory.OldValue;
|
||||
CurrentPath.Value = directory.OldValue;
|
||||
this.FlashColour(Color4.Red, 300);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual IEnumerable<DisplayPiece> GetEntriesForPath(DirectoryInfo path)
|
||||
{
|
||||
foreach (var dir in path.GetDirectories().OrderBy(d => d.Name))
|
||||
{
|
||||
if ((dir.Attributes & FileAttributes.Hidden) == 0)
|
||||
yield return new DirectoryPiece(dir);
|
||||
}
|
||||
}
|
||||
|
||||
private class CurrentDirectoryDisplay : CompositeDrawable
|
||||
{
|
||||
[Resolved]
|
||||
@ -126,7 +131,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Spacing = new Vector2(5),
|
||||
Height = DirectoryPiece.HEIGHT,
|
||||
Height = DisplayPiece.HEIGHT,
|
||||
Direction = FillDirection.Horizontal,
|
||||
},
|
||||
};
|
||||
@ -150,7 +155,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
|
||||
flow.ChildrenEnumerable = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText { Text = "Current Directory: ", Font = OsuFont.Default.With(size: DirectoryPiece.HEIGHT), },
|
||||
new OsuSpriteText { Text = "Current Directory: ", Font = OsuFont.Default.With(size: DisplayPiece.HEIGHT), },
|
||||
new ComputerPiece(),
|
||||
}.Concat(pathPieces);
|
||||
}
|
||||
@ -198,24 +203,44 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
}
|
||||
}
|
||||
|
||||
private class DirectoryPiece : CompositeDrawable
|
||||
protected class DirectoryPiece : DisplayPiece
|
||||
{
|
||||
public const float HEIGHT = 20;
|
||||
|
||||
protected const float FONT_SIZE = 16;
|
||||
|
||||
protected readonly DirectoryInfo Directory;
|
||||
|
||||
private readonly string displayName;
|
||||
|
||||
protected FillFlowContainer Flow;
|
||||
|
||||
[Resolved]
|
||||
private Bindable<DirectoryInfo> currentDirectory { get; set; }
|
||||
|
||||
public DirectoryPiece(DirectoryInfo directory, string displayName = null)
|
||||
: base(displayName)
|
||||
{
|
||||
Directory = directory;
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
currentDirectory.Value = Directory;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override string FallbackName => Directory.Name;
|
||||
|
||||
protected override IconUsage? Icon => Directory.Name.Contains(Path.DirectorySeparatorChar)
|
||||
? FontAwesome.Solid.Database
|
||||
: FontAwesome.Regular.Folder;
|
||||
}
|
||||
|
||||
protected abstract class DisplayPiece : CompositeDrawable
|
||||
{
|
||||
public const float HEIGHT = 20;
|
||||
|
||||
protected const float FONT_SIZE = 16;
|
||||
|
||||
private readonly string displayName;
|
||||
|
||||
protected FillFlowContainer Flow;
|
||||
|
||||
protected DisplayPiece(string displayName = null)
|
||||
{
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
@ -259,20 +284,14 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Text = displayName ?? Directory.Name,
|
||||
Text = displayName ?? FallbackName,
|
||||
Font = OsuFont.Default.With(size: FONT_SIZE)
|
||||
});
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
currentDirectory.Value = Directory;
|
||||
return true;
|
||||
}
|
||||
protected abstract string FallbackName { get; }
|
||||
|
||||
protected virtual IconUsage? Icon => Directory.Name.Contains(Path.DirectorySeparatorChar)
|
||||
? FontAwesome.Solid.Database
|
||||
: FontAwesome.Regular.Folder;
|
||||
protected abstract IconUsage? Icon { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
94
osu.Game/Graphics/UserInterfaceV2/FileSelector.cs
Normal file
94
osu.Game/Graphics/UserInterfaceV2/FileSelector.cs
Normal file
@ -0,0 +1,94 @@
|
||||
// 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.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Events;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterfaceV2
|
||||
{
|
||||
public class FileSelector : DirectorySelector
|
||||
{
|
||||
private readonly string[] validFileExtensions;
|
||||
|
||||
[Cached]
|
||||
public readonly Bindable<FileInfo> CurrentFile = new Bindable<FileInfo>();
|
||||
|
||||
public FileSelector(string initialPath = null, string[] validFileExtensions = null)
|
||||
: base(initialPath)
|
||||
{
|
||||
this.validFileExtensions = validFileExtensions ?? Array.Empty<string>();
|
||||
}
|
||||
|
||||
protected override IEnumerable<DisplayPiece> GetEntriesForPath(DirectoryInfo path)
|
||||
{
|
||||
foreach (var dir in base.GetEntriesForPath(path))
|
||||
yield return dir;
|
||||
|
||||
IEnumerable<FileInfo> files = path.GetFiles();
|
||||
|
||||
if (validFileExtensions.Length > 0)
|
||||
files = files.Where(f => validFileExtensions.Contains(f.Extension));
|
||||
|
||||
foreach (var file in files.OrderBy(d => d.Name))
|
||||
{
|
||||
if ((file.Attributes & FileAttributes.Hidden) == 0)
|
||||
yield return new FilePiece(file);
|
||||
}
|
||||
}
|
||||
|
||||
protected class FilePiece : DisplayPiece
|
||||
{
|
||||
private readonly FileInfo file;
|
||||
|
||||
[Resolved]
|
||||
private Bindable<FileInfo> currentFile { get; set; }
|
||||
|
||||
public FilePiece(FileInfo file)
|
||||
{
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
currentFile.Value = file;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override string FallbackName => file.Name;
|
||||
|
||||
protected override IconUsage? Icon
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (file.Extension)
|
||||
{
|
||||
case ".ogg":
|
||||
case ".mp3":
|
||||
case ".wav":
|
||||
return FontAwesome.Regular.FileAudio;
|
||||
|
||||
case ".jpg":
|
||||
case ".jpeg":
|
||||
case ".png":
|
||||
return FontAwesome.Regular.FileImage;
|
||||
|
||||
case ".mp4":
|
||||
case ".avi":
|
||||
case ".mov":
|
||||
case ".flv":
|
||||
return FontAwesome.Regular.FileVideo;
|
||||
|
||||
default:
|
||||
return FontAwesome.Regular.File;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
24
osu.Game/Graphics/UserInterfaceV2/LabelledSliderBar.cs
Normal file
24
osu.Game/Graphics/UserInterfaceV2/LabelledSliderBar.cs
Normal file
@ -0,0 +1,24 @@
|
||||
// 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 osu.Framework.Graphics;
|
||||
using osu.Game.Overlays.Settings;
|
||||
|
||||
namespace osu.Game.Graphics.UserInterfaceV2
|
||||
{
|
||||
public class LabelledSliderBar<TNumber> : LabelledComponent<SettingsSlider<TNumber>, TNumber>
|
||||
where TNumber : struct, IEquatable<TNumber>, IComparable<TNumber>, IConvertible
|
||||
{
|
||||
public LabelledSliderBar()
|
||||
: base(true)
|
||||
{
|
||||
}
|
||||
|
||||
protected override SettingsSlider<TNumber> CreateComponent() => new SettingsSlider<TNumber>
|
||||
{
|
||||
TransferValueOnCommit = true,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
};
|
||||
}
|
||||
}
|
@ -44,12 +44,18 @@ namespace osu.Game.Graphics.UserInterfaceV2
|
||||
Component.BorderColour = colours.Blue;
|
||||
}
|
||||
|
||||
protected override OsuTextBox CreateComponent() => new OsuTextBox
|
||||
protected virtual OsuTextBox CreateTextBox() => new OsuTextBox
|
||||
{
|
||||
CommitOnFocusLost = true,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
CornerRadius = CORNER_RADIUS,
|
||||
}.With(t => t.OnCommit += (sender, newText) => OnCommit?.Invoke(sender, newText));
|
||||
};
|
||||
|
||||
protected override OsuTextBox CreateComponent() => CreateTextBox().With(t =>
|
||||
{
|
||||
t.OnCommit += (sender, newText) => OnCommit?.Invoke(sender, newText);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user