mirror of
https://github.com/osukey/osukey.git
synced 2025-06-09 21:37:59 +09:00
Merge branch 'master' into mod-text
This commit is contained in:
commit
6579aa144d
@ -6,13 +6,11 @@ using System.Collections.Generic;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
|
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osu.Game.Skinning;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||||
{
|
{
|
||||||
@ -23,7 +21,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
private double animDuration;
|
private double animDuration;
|
||||||
|
|
||||||
private readonly SkinnableDrawable scaleContainer;
|
private readonly Drawable scaleContainer;
|
||||||
|
|
||||||
public DrawableRepeatPoint(RepeatPoint repeatPoint, DrawableSlider drawableSlider)
|
public DrawableRepeatPoint(RepeatPoint repeatPoint, DrawableSlider drawableSlider)
|
||||||
: base(repeatPoint)
|
: base(repeatPoint)
|
||||||
@ -36,16 +34,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
Blending = BlendingParameters.Additive;
|
Blending = BlendingParameters.Additive;
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
|
|
||||||
InternalChild = scaleContainer = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.ReverseArrow), _ => new SpriteIcon
|
InternalChild = scaleContainer = new ReverseArrowPiece();
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Icon = FontAwesome.Solid.ChevronRight,
|
|
||||||
Size = new Vector2(0.35f)
|
|
||||||
}, confineMode: ConfineMode.NoScaling)
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly IBindable<float> scaleBindable = new Bindable<float>();
|
private readonly IBindable<float> scaleBindable = new Bindable<float>();
|
||||||
@ -65,11 +54,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
|
|
||||||
protected override void UpdateInitialTransforms()
|
protected override void UpdateInitialTransforms()
|
||||||
{
|
{
|
||||||
animDuration = Math.Min(150, repeatPoint.SpanDuration / 2);
|
animDuration = Math.Min(300, repeatPoint.SpanDuration);
|
||||||
|
|
||||||
this.Animate(
|
this.Animate(
|
||||||
d => d.FadeIn(animDuration),
|
d => d.FadeIn(animDuration),
|
||||||
d => d.ScaleTo(0.5f).ScaleTo(1f, animDuration * 4, Easing.OutElasticHalf)
|
d => d.ScaleTo(0.5f).ScaleTo(1f, animDuration * 2, Easing.OutElasticHalf)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +77,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ArmedState.Hit:
|
case ArmedState.Hit:
|
||||||
this.FadeOut(animDuration, Easing.OutQuint)
|
this.FadeOut(animDuration, Easing.Out)
|
||||||
.ScaleTo(Scale * 1.5f, animDuration, Easing.Out);
|
.ScaleTo(Scale * 1.5f, animDuration, Easing.Out);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
// 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.Audio.Track;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osuTK;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||||
|
{
|
||||||
|
public class ReverseArrowPiece : BeatSyncedContainer
|
||||||
|
{
|
||||||
|
public ReverseArrowPiece()
|
||||||
|
{
|
||||||
|
Divisor = 2;
|
||||||
|
MinimumBeatLength = 200;
|
||||||
|
|
||||||
|
Anchor = Anchor.Centre;
|
||||||
|
Origin = Anchor.Centre;
|
||||||
|
|
||||||
|
Blending = BlendingParameters.Additive;
|
||||||
|
|
||||||
|
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
|
||||||
|
|
||||||
|
Child = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.ReverseArrow), _ => new SpriteIcon
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Icon = FontAwesome.Solid.ChevronRight,
|
||||||
|
Size = new Vector2(0.35f)
|
||||||
|
})
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) =>
|
||||||
|
Child.ScaleTo(1.3f).ScaleTo(1f, timingPoint.BeatLength, Easing.Out);
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
@ -13,7 +14,9 @@ using osu.Game.IPC;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.Formats;
|
||||||
using osu.Game.IO;
|
using osu.Game.IO;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
using SharpCompress.Archives;
|
using SharpCompress.Archives;
|
||||||
using SharpCompress.Archives.Zip;
|
using SharpCompress.Archives.Zip;
|
||||||
@ -552,6 +555,83 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task TestUpdateBeatmapInfo()
|
||||||
|
{
|
||||||
|
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestUpdateBeatmapInfo)))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var osu = loadOsu(host);
|
||||||
|
var manager = osu.Dependencies.Get<BeatmapManager>();
|
||||||
|
|
||||||
|
var temp = TestResources.GetTestBeatmapForImport();
|
||||||
|
await osu.Dependencies.Get<BeatmapManager>().Import(temp);
|
||||||
|
|
||||||
|
// Update via the beatmap, not the beatmap info, to ensure correct linking
|
||||||
|
BeatmapSetInfo setToUpdate = manager.GetAllUsableBeatmapSets()[0];
|
||||||
|
Beatmap beatmapToUpdate = (Beatmap)manager.GetWorkingBeatmap(setToUpdate.Beatmaps.First(b => b.RulesetID == 0)).Beatmap;
|
||||||
|
beatmapToUpdate.BeatmapInfo.Version = "updated";
|
||||||
|
|
||||||
|
manager.Update(setToUpdate);
|
||||||
|
|
||||||
|
BeatmapInfo updatedInfo = manager.QueryBeatmap(b => b.ID == beatmapToUpdate.BeatmapInfo.ID);
|
||||||
|
Assert.That(updatedInfo.Version, Is.EqualTo("updated"));
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
host.Exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public async Task TestUpdateBeatmapFile()
|
||||||
|
{
|
||||||
|
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(TestUpdateBeatmapFile)))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var osu = loadOsu(host);
|
||||||
|
var manager = osu.Dependencies.Get<BeatmapManager>();
|
||||||
|
|
||||||
|
var temp = TestResources.GetTestBeatmapForImport();
|
||||||
|
await osu.Dependencies.Get<BeatmapManager>().Import(temp);
|
||||||
|
|
||||||
|
BeatmapSetInfo setToUpdate = manager.GetAllUsableBeatmapSets()[0];
|
||||||
|
Beatmap beatmapToUpdate = (Beatmap)manager.GetWorkingBeatmap(setToUpdate.Beatmaps.First(b => b.RulesetID == 0)).Beatmap;
|
||||||
|
BeatmapSetFileInfo fileToUpdate = setToUpdate.Files.First(f => beatmapToUpdate.BeatmapInfo.Path.Contains(f.Filename));
|
||||||
|
|
||||||
|
using (var stream = new MemoryStream())
|
||||||
|
{
|
||||||
|
using (var writer = new StreamWriter(stream, Encoding.UTF8, 1024, true))
|
||||||
|
{
|
||||||
|
beatmapToUpdate.HitObjects.Clear();
|
||||||
|
beatmapToUpdate.HitObjects.Add(new HitCircle { StartTime = 5000 });
|
||||||
|
|
||||||
|
new LegacyBeatmapEncoder(beatmapToUpdate).Encode(writer);
|
||||||
|
}
|
||||||
|
|
||||||
|
stream.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
|
manager.UpdateFile(setToUpdate, fileToUpdate, stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that the old file reference has been removed
|
||||||
|
Assert.That(manager.QueryBeatmapSet(s => s.ID == setToUpdate.ID).Files.All(f => f.ID != fileToUpdate.ID));
|
||||||
|
|
||||||
|
// Check that the new file is referenced correctly by attempting a retrieval
|
||||||
|
Beatmap updatedBeatmap = (Beatmap)manager.GetWorkingBeatmap(manager.QueryBeatmap(b => b.ID == beatmapToUpdate.BeatmapInfo.ID)).Beatmap;
|
||||||
|
Assert.That(updatedBeatmap.HitObjects.Count, Is.EqualTo(1));
|
||||||
|
Assert.That(updatedBeatmap.HitObjects[0].StartTime, Is.EqualTo(5000));
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
host.Exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task<BeatmapSetInfo> LoadOszIntoOsu(OsuGameBase osu, string path = null, bool virtualTrack = false)
|
public static async Task<BeatmapSetInfo> LoadOszIntoOsu(OsuGameBase osu, string path = null, bool virtualTrack = false)
|
||||||
{
|
{
|
||||||
var temp = path ?? TestResources.GetTestBeatmapForImport(virtualTrack);
|
var temp = path ?? TestResources.GetTestBeatmapForImport(virtualTrack);
|
||||||
|
@ -0,0 +1,76 @@
|
|||||||
|
// 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 osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Overlays.Rankings;
|
||||||
|
using osu.Game.Users;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Online
|
||||||
|
{
|
||||||
|
public class TestSceneRankingsCountryFilter : OsuTestScene
|
||||||
|
{
|
||||||
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
|
{
|
||||||
|
typeof(CountryFilter),
|
||||||
|
typeof(CountryPill)
|
||||||
|
};
|
||||||
|
|
||||||
|
public TestSceneRankingsCountryFilter()
|
||||||
|
{
|
||||||
|
var countryBindable = new Bindable<Country>();
|
||||||
|
|
||||||
|
AddRange(new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = Color4.Gray,
|
||||||
|
},
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
Direction = FillDirection.Vertical,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new CountryFilter
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
Current = { BindTarget = countryBindable }
|
||||||
|
},
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
Text = "Some content",
|
||||||
|
Margin = new MarginPadding { Vertical = 20 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var country = new Country
|
||||||
|
{
|
||||||
|
FlagName = "BY",
|
||||||
|
FullName = "Belarus"
|
||||||
|
};
|
||||||
|
var unknownCountry = new Country
|
||||||
|
{
|
||||||
|
FlagName = "CK",
|
||||||
|
FullName = "Cook Islands"
|
||||||
|
};
|
||||||
|
|
||||||
|
AddStep("Set country", () => countryBindable.Value = country);
|
||||||
|
AddStep("Set null country", () => countryBindable.Value = null);
|
||||||
|
AddStep("Set country with no flag", () => countryBindable.Value = unknownCountry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
@ -26,6 +27,8 @@ using osu.Game.Online.API;
|
|||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using Decoder = osu.Game.Beatmaps.Formats.Decoder;
|
||||||
|
using ZipArchive = SharpCompress.Archives.Zip.ZipArchive;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps
|
namespace osu.Game.Beatmaps
|
||||||
{
|
{
|
||||||
@ -56,14 +59,11 @@ namespace osu.Game.Beatmaps
|
|||||||
protected override string ImportFromStablePath => "Songs";
|
protected override string ImportFromStablePath => "Songs";
|
||||||
|
|
||||||
private readonly RulesetStore rulesets;
|
private readonly RulesetStore rulesets;
|
||||||
|
|
||||||
private readonly BeatmapStore beatmaps;
|
private readonly BeatmapStore beatmaps;
|
||||||
|
|
||||||
private readonly AudioManager audioManager;
|
private readonly AudioManager audioManager;
|
||||||
|
|
||||||
private readonly GameHost host;
|
private readonly GameHost host;
|
||||||
|
|
||||||
private readonly BeatmapUpdateQueue updateQueue;
|
private readonly BeatmapUpdateQueue updateQueue;
|
||||||
|
private readonly Storage exportStorage;
|
||||||
|
|
||||||
public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, AudioManager audioManager, GameHost host = null,
|
public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, AudioManager audioManager, GameHost host = null,
|
||||||
WorkingBeatmap defaultBeatmap = null)
|
WorkingBeatmap defaultBeatmap = null)
|
||||||
@ -80,6 +80,7 @@ namespace osu.Game.Beatmaps
|
|||||||
beatmaps.BeatmapRestored += b => BeatmapRestored?.Invoke(b);
|
beatmaps.BeatmapRestored += b => BeatmapRestored?.Invoke(b);
|
||||||
|
|
||||||
updateQueue = new BeatmapUpdateQueue(api);
|
updateQueue = new BeatmapUpdateQueue(api);
|
||||||
|
exportStorage = storage.GetStorageForDirectory("exports");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override ArchiveDownloadRequest<BeatmapSetInfo> CreateDownloadRequest(BeatmapSetInfo set, bool minimiseDownloadSize) =>
|
protected override ArchiveDownloadRequest<BeatmapSetInfo> CreateDownloadRequest(BeatmapSetInfo set, bool minimiseDownloadSize) =>
|
||||||
@ -174,6 +175,50 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <param name="beatmap">The beatmap difficulty to restore.</param>
|
/// <param name="beatmap">The beatmap difficulty to restore.</param>
|
||||||
public void Restore(BeatmapInfo beatmap) => beatmaps.Restore(beatmap);
|
public void Restore(BeatmapInfo beatmap) => beatmaps.Restore(beatmap);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Saves an <see cref="IBeatmap"/> file against a given <see cref="BeatmapInfo"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info">The <see cref="BeatmapInfo"/> to save the content against. The file referenced by <see cref="BeatmapInfo.Path"/> will be replaced.</param>
|
||||||
|
/// <param name="beatmapContent">The <see cref="IBeatmap"/> content to write.</param>
|
||||||
|
public void Save(BeatmapInfo info, IBeatmap beatmapContent)
|
||||||
|
{
|
||||||
|
var setInfo = QueryBeatmapSet(s => s.Beatmaps.Any(b => b.ID == info.ID));
|
||||||
|
|
||||||
|
using (var stream = new MemoryStream())
|
||||||
|
{
|
||||||
|
using (var sw = new StreamWriter(stream, Encoding.UTF8, 1024, true))
|
||||||
|
new LegacyBeatmapEncoder(beatmapContent).Encode(sw);
|
||||||
|
|
||||||
|
stream.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
|
UpdateFile(setInfo, setInfo.Files.Single(f => string.Equals(f.Filename, info.Path, StringComparison.OrdinalIgnoreCase)), stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
var working = workingCache.FirstOrDefault(w => w.BeatmapInfo?.ID == info.ID);
|
||||||
|
if (working != null)
|
||||||
|
workingCache.Remove(working);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Exports a <see cref="BeatmapSetInfo"/> to an .osz package.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="set">The <see cref="BeatmapSetInfo"/> to export.</param>
|
||||||
|
public void Export(BeatmapSetInfo set)
|
||||||
|
{
|
||||||
|
var localSet = QueryBeatmapSet(s => s.ID == set.ID);
|
||||||
|
|
||||||
|
using (var archive = ZipArchive.Create())
|
||||||
|
{
|
||||||
|
foreach (var file in localSet.Files)
|
||||||
|
archive.AddEntry(file.Filename, Files.Storage.GetStream(file.FileInfo.StoragePath));
|
||||||
|
|
||||||
|
using (var outputStream = exportStorage.GetStream($"{set}.osz", FileAccess.Write, FileMode.Create))
|
||||||
|
archive.SaveTo(outputStream);
|
||||||
|
|
||||||
|
exportStorage.OpenInNativeExplorer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private readonly WeakList<WorkingBeatmap> workingCache = new WeakList<WorkingBeatmap>();
|
private readonly WeakList<WorkingBeatmap> workingCache = new WeakList<WorkingBeatmap>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -63,7 +63,7 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
writer.WriteLine(FormattableString.Invariant($"PreviewTime: {beatmap.Metadata.PreviewTime}"));
|
writer.WriteLine(FormattableString.Invariant($"PreviewTime: {beatmap.Metadata.PreviewTime}"));
|
||||||
// Todo: Not all countdown types are supported by lazer yet
|
// Todo: Not all countdown types are supported by lazer yet
|
||||||
writer.WriteLine(FormattableString.Invariant($"Countdown: {(beatmap.BeatmapInfo.Countdown ? '1' : '0')}"));
|
writer.WriteLine(FormattableString.Invariant($"Countdown: {(beatmap.BeatmapInfo.Countdown ? '1' : '0')}"));
|
||||||
writer.WriteLine(FormattableString.Invariant($"SampleSet: {toLegacySampleBank(beatmap.ControlPointInfo.SamplePoints[0].SampleBank)}"));
|
writer.WriteLine(FormattableString.Invariant($"SampleSet: {toLegacySampleBank(beatmap.ControlPointInfo.SamplePointAt(double.MinValue).SampleBank)}"));
|
||||||
writer.WriteLine(FormattableString.Invariant($"StackLeniency: {beatmap.BeatmapInfo.StackLeniency}"));
|
writer.WriteLine(FormattableString.Invariant($"StackLeniency: {beatmap.BeatmapInfo.StackLeniency}"));
|
||||||
writer.WriteLine(FormattableString.Invariant($"Mode: {beatmap.BeatmapInfo.RulesetID}"));
|
writer.WriteLine(FormattableString.Invariant($"Mode: {beatmap.BeatmapInfo.RulesetID}"));
|
||||||
writer.WriteLine(FormattableString.Invariant($"LetterboxInBreaks: {(beatmap.BeatmapInfo.LetterboxInBreaks ? '1' : '0')}"));
|
writer.WriteLine(FormattableString.Invariant($"LetterboxInBreaks: {(beatmap.BeatmapInfo.LetterboxInBreaks ? '1' : '0')}"));
|
||||||
|
@ -7,13 +7,11 @@ using osu.Game.Rulesets.Mods;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Game.Storyboards;
|
using osu.Game.Storyboards;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Statistics;
|
using osu.Framework.Statistics;
|
||||||
using osu.Game.IO.Serialization;
|
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
@ -76,21 +74,6 @@ namespace osu.Game.Beatmaps
|
|||||||
return AudioManager.Tracks.GetVirtual(length);
|
return AudioManager.Tracks.GetVirtual(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Saves the <see cref="Beatmaps.Beatmap"/>.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>The absolute path of the output file.</returns>
|
|
||||||
public string Save()
|
|
||||||
{
|
|
||||||
string directory = Path.Combine(Path.GetTempPath(), @"osu!");
|
|
||||||
Directory.CreateDirectory(directory);
|
|
||||||
|
|
||||||
var path = Path.Combine(directory, Guid.NewGuid().ToString().Replace("-", string.Empty) + ".json");
|
|
||||||
using (var sw = new StreamWriter(path))
|
|
||||||
sw.WriteLine(Beatmap.Serialize());
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a <see cref="IBeatmapConverter"/> to convert a <see cref="IBeatmap"/> for a specified <see cref="Ruleset"/>.
|
/// Creates a <see cref="IBeatmapConverter"/> to convert a <see cref="IBeatmap"/> for a specified <see cref="Ruleset"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -34,7 +34,7 @@ namespace osu.Game.Database
|
|||||||
/// <typeparam name="TFileModel">The associated file join type.</typeparam>
|
/// <typeparam name="TFileModel">The associated file join type.</typeparam>
|
||||||
public abstract class ArchiveModelManager<TModel, TFileModel> : ICanAcceptFiles, IModelManager<TModel>
|
public abstract class ArchiveModelManager<TModel, TFileModel> : ICanAcceptFiles, IModelManager<TModel>
|
||||||
where TModel : class, IHasFiles<TFileModel>, IHasPrimaryKey, ISoftDelete
|
where TModel : class, IHasFiles<TFileModel>, IHasPrimaryKey, ISoftDelete
|
||||||
where TFileModel : INamedFileInfo, new()
|
where TFileModel : class, INamedFileInfo, new()
|
||||||
{
|
{
|
||||||
private const int import_queue_request_concurrency = 1;
|
private const int import_queue_request_concurrency = 1;
|
||||||
|
|
||||||
@ -222,9 +222,8 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
model = CreateModel(archive);
|
model = CreateModel(archive);
|
||||||
|
|
||||||
if (model == null) return Task.FromResult<TModel>(null);
|
if (model == null)
|
||||||
|
return Task.FromResult<TModel>(null);
|
||||||
model.Hash = computeHash(archive);
|
|
||||||
}
|
}
|
||||||
catch (TaskCanceledException)
|
catch (TaskCanceledException)
|
||||||
{
|
{
|
||||||
@ -262,18 +261,24 @@ namespace osu.Game.Database
|
|||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// In the case of no matching files, a hash will be generated from the passed archive's <see cref="ArchiveReader.Name"/>.
|
/// In the case of no matching files, a hash will be generated from the passed archive's <see cref="ArchiveReader.Name"/>.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
private string computeHash(ArchiveReader reader)
|
private string computeHash(TModel item, ArchiveReader reader = null)
|
||||||
{
|
{
|
||||||
// for now, concatenate all .osu files in the set to create a unique hash.
|
// for now, concatenate all .osu files in the set to create a unique hash.
|
||||||
MemoryStream hashable = new MemoryStream();
|
MemoryStream hashable = new MemoryStream();
|
||||||
|
|
||||||
foreach (string file in reader.Filenames.Where(f => HashableFileTypes.Any(f.EndsWith)))
|
foreach (TFileModel file in item.Files.Where(f => HashableFileTypes.Any(f.Filename.EndsWith)))
|
||||||
{
|
{
|
||||||
using (Stream s = reader.GetStream(file))
|
using (Stream s = Files.Store.GetStream(file.FileInfo.StoragePath))
|
||||||
s.CopyTo(hashable);
|
s.CopyTo(hashable);
|
||||||
}
|
}
|
||||||
|
|
||||||
return hashable.Length > 0 ? hashable.ComputeSHA2Hash() : reader.Name.ComputeSHA2Hash();
|
if (hashable.Length > 0)
|
||||||
|
return hashable.ComputeSHA2Hash();
|
||||||
|
|
||||||
|
if (reader != null)
|
||||||
|
return reader.Name.ComputeSHA2Hash();
|
||||||
|
|
||||||
|
return item.Hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -303,6 +308,7 @@ namespace osu.Game.Database
|
|||||||
LogForModel(item, "Beginning import...");
|
LogForModel(item, "Beginning import...");
|
||||||
|
|
||||||
item.Files = archive != null ? createFileInfos(archive, Files) : new List<TFileModel>();
|
item.Files = archive != null ? createFileInfos(archive, Files) : new List<TFileModel>();
|
||||||
|
item.Hash = computeHash(item, archive);
|
||||||
|
|
||||||
await Populate(item, archive, cancellationToken);
|
await Populate(item, archive, cancellationToken);
|
||||||
|
|
||||||
@ -358,12 +364,42 @@ namespace osu.Game.Database
|
|||||||
return item;
|
return item;
|
||||||
}, cancellationToken, TaskCreationOptions.HideScheduler, import_scheduler).Unwrap();
|
}, cancellationToken, TaskCreationOptions.HideScheduler, import_scheduler).Unwrap();
|
||||||
|
|
||||||
|
public void UpdateFile(TModel model, TFileModel file, Stream contents)
|
||||||
|
{
|
||||||
|
using (var usage = ContextFactory.GetForWrite())
|
||||||
|
{
|
||||||
|
// Dereference the existing file info, since the file model will be removed.
|
||||||
|
Files.Dereference(file.FileInfo);
|
||||||
|
|
||||||
|
// Remove the file model.
|
||||||
|
usage.Context.Set<TFileModel>().Remove(file);
|
||||||
|
|
||||||
|
// Add the new file info and containing file model.
|
||||||
|
model.Files.Remove(file);
|
||||||
|
model.Files.Add(new TFileModel
|
||||||
|
{
|
||||||
|
Filename = file.Filename,
|
||||||
|
FileInfo = Files.Add(contents)
|
||||||
|
});
|
||||||
|
|
||||||
|
Update(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Perform an update of the specified item.
|
/// Perform an update of the specified item.
|
||||||
/// TODO: Support file changes.
|
/// TODO: Support file additions/removals.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item">The item to update.</param>
|
/// <param name="item">The item to update.</param>
|
||||||
public void Update(TModel item) => ModelStore.Update(item);
|
public void Update(TModel item)
|
||||||
|
{
|
||||||
|
using (ContextFactory.GetForWrite())
|
||||||
|
{
|
||||||
|
item.Hash = computeHash(item);
|
||||||
|
|
||||||
|
ModelStore.Update(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete an item from the manager.
|
/// Delete an item from the manager.
|
||||||
|
@ -21,7 +21,7 @@ namespace osu.Game.Database
|
|||||||
/// <typeparam name="TFileModel">The associated file join type.</typeparam>
|
/// <typeparam name="TFileModel">The associated file join type.</typeparam>
|
||||||
public abstract class DownloadableArchiveModelManager<TModel, TFileModel> : ArchiveModelManager<TModel, TFileModel>, IModelDownloader<TModel>
|
public abstract class DownloadableArchiveModelManager<TModel, TFileModel> : ArchiveModelManager<TModel, TFileModel>, IModelDownloader<TModel>
|
||||||
where TModel : class, IHasFiles<TFileModel>, IHasPrimaryKey, ISoftDelete, IEquatable<TModel>
|
where TModel : class, IHasFiles<TFileModel>, IHasPrimaryKey, ISoftDelete, IEquatable<TModel>
|
||||||
where TFileModel : INamedFileInfo, new()
|
where TFileModel : class, INamedFileInfo, new()
|
||||||
{
|
{
|
||||||
public event Action<ArchiveDownloadRequest<TModel>> DownloadBegan;
|
public event Action<ArchiveDownloadRequest<TModel>> DownloadBegan;
|
||||||
|
|
||||||
|
@ -38,6 +38,11 @@ namespace osu.Game.Graphics.Containers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int Divisor { get; set; } = 1;
|
public int Divisor { get; set; } = 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An optional minimum beat length. Any beat length below this will be multiplied by two until valid.
|
||||||
|
/// </summary>
|
||||||
|
public double MinimumBeatLength { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default length of a beat in milliseconds. Used whenever there is no beatmap or track playing.
|
/// Default length of a beat in milliseconds. Used whenever there is no beatmap or track playing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -89,6 +94,9 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
double beatLength = timingPoint.BeatLength / Divisor;
|
double beatLength = timingPoint.BeatLength / Divisor;
|
||||||
|
|
||||||
|
while (beatLength < MinimumBeatLength)
|
||||||
|
beatLength *= 2;
|
||||||
|
|
||||||
int beatIndex = (int)((currentTrackTime - timingPoint.Time) / beatLength) - (effectPoint.OmitFirstBarLine ? 1 : 0);
|
int beatIndex = (int)((currentTrackTime - timingPoint.Time) / beatLength) - (effectPoint.OmitFirstBarLine ? 1 : 0);
|
||||||
|
|
||||||
// The beats before the start of the first control point are off by 1, this should do the trick
|
// The beats before the start of the first control point are off by 1, this should do the trick
|
||||||
|
@ -63,7 +63,7 @@ namespace osu.Game.Graphics.Containers
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void AddUserLink(User user, Action<SpriteText> creationParameters = null)
|
public void AddUserLink(User user, Action<SpriteText> creationParameters = null)
|
||||||
=> createLink(AddText(user.Username, creationParameters), new LinkDetails(LinkAction.OpenUserProfile, user.Id.ToString()), "View Profile");
|
=> createLink(AddText(user.Username, creationParameters), new LinkDetails(LinkAction.OpenUserProfile, user.Id.ToString()), "view profile");
|
||||||
|
|
||||||
private void createLink(IEnumerable<Drawable> drawables, LinkDetails link, string tooltipText, Action action = null)
|
private void createLink(IEnumerable<Drawable> drawables, LinkDetails link, string tooltipText, Action action = null)
|
||||||
{
|
{
|
||||||
|
@ -57,6 +57,6 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string TooltipText => "View in browser";
|
public string TooltipText => "view in browser";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
private class CapsWarning : SpriteIcon, IHasTooltip
|
private class CapsWarning : SpriteIcon, IHasTooltip
|
||||||
{
|
{
|
||||||
public string TooltipText => @"Caps lock is active";
|
public string TooltipText => @"caps lock is active";
|
||||||
|
|
||||||
public CapsWarning()
|
public CapsWarning()
|
||||||
{
|
{
|
||||||
|
@ -162,16 +162,6 @@ namespace osu.Game.Online.API
|
|||||||
[JsonProperty("error")]
|
[JsonProperty("error")]
|
||||||
public string ErrorMessage { get; set; }
|
public string ErrorMessage { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private class OsuWebRequest : WebRequest
|
|
||||||
{
|
|
||||||
public OsuWebRequest(string uri)
|
|
||||||
: base(uri)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override string UserAgent => "osu!";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class APIException : InvalidOperationException
|
public class APIException : InvalidOperationException
|
||||||
|
21
osu.Game/Online/API/OsuWebRequest.cs
Normal file
21
osu.Game/Online/API/OsuWebRequest.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// 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.IO.Network;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.API
|
||||||
|
{
|
||||||
|
public class OsuWebRequest : WebRequest
|
||||||
|
{
|
||||||
|
public OsuWebRequest(string uri)
|
||||||
|
: base(uri)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public OsuWebRequest()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string UserAgent => "osu!";
|
||||||
|
}
|
||||||
|
}
|
@ -2,11 +2,10 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Framework.IO.Network;
|
|
||||||
|
|
||||||
namespace osu.Game.Online.API
|
namespace osu.Game.Online.API
|
||||||
{
|
{
|
||||||
public class RegistrationRequest : WebRequest
|
public class RegistrationRequest : OsuWebRequest
|
||||||
{
|
{
|
||||||
internal string Username;
|
internal string Username;
|
||||||
internal string Email;
|
internal string Email;
|
||||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
|
|||||||
{
|
{
|
||||||
private readonly bool noVideo;
|
private readonly bool noVideo;
|
||||||
|
|
||||||
public string TooltipText => button.Enabled.Value ? "Download this beatmap" : "Login to download";
|
public string TooltipText => button.Enabled.Value ? "download this beatmap" : "login to download";
|
||||||
|
|
||||||
private readonly IBindable<User> localUser = new Bindable<User>();
|
private readonly IBindable<User> localUser = new Bindable<User>();
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ namespace osu.Game.Overlays.Direct
|
|||||||
if (BeatmapSet.Value.OnlineInfo.Availability?.DownloadDisabled ?? false)
|
if (BeatmapSet.Value.OnlineInfo.Availability?.DownloadDisabled ?? false)
|
||||||
{
|
{
|
||||||
button.Enabled.Value = false;
|
button.Enabled.Value = false;
|
||||||
button.TooltipText = "This beatmap is currently not available for download.";
|
button.TooltipText = "this beatmap is currently not available for download.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
|
|
||||||
public LevelBadge()
|
public LevelBadge()
|
||||||
{
|
{
|
||||||
TooltipText = "Level";
|
TooltipText = "level";
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
|
|
||||||
public LevelProgressBar()
|
public LevelProgressBar()
|
||||||
{
|
{
|
||||||
TooltipText = "Progress to next level";
|
TooltipText = "progress to next level";
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
105
osu.Game/Overlays/Rankings/CountryFilter.cs
Normal file
105
osu.Game/Overlays/Rankings/CountryFilter.cs
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
// 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.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Users;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Rankings
|
||||||
|
{
|
||||||
|
public class CountryFilter : CompositeDrawable, IHasCurrentValue<Country>
|
||||||
|
{
|
||||||
|
private const int duration = 200;
|
||||||
|
private const int height = 50;
|
||||||
|
|
||||||
|
private readonly BindableWithCurrent<Country> current = new BindableWithCurrent<Country>();
|
||||||
|
|
||||||
|
public Bindable<Country> Current
|
||||||
|
{
|
||||||
|
get => current.Current;
|
||||||
|
set => current.Current = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly Box background;
|
||||||
|
private readonly CountryPill countryPill;
|
||||||
|
private readonly Container content;
|
||||||
|
|
||||||
|
public CountryFilter()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X;
|
||||||
|
|
||||||
|
InternalChild = content = new Container
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = height,
|
||||||
|
Alpha = 0,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
background = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
|
},
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Spacing = new Vector2(10, 0),
|
||||||
|
Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN },
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
Text = @"filtered by country:",
|
||||||
|
Font = OsuFont.GetFont(size: 14)
|
||||||
|
},
|
||||||
|
countryPill = new CountryPill
|
||||||
|
{
|
||||||
|
Anchor = Anchor.CentreLeft,
|
||||||
|
Origin = Anchor.CentreLeft,
|
||||||
|
Alpha = 0,
|
||||||
|
Current = Current
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
background.Colour = colours.GreySeafoam;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
Current.BindValueChanged(onCountryChanged, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onCountryChanged(ValueChangedEvent<Country> country)
|
||||||
|
{
|
||||||
|
if (country.NewValue == null)
|
||||||
|
{
|
||||||
|
countryPill.Collapse();
|
||||||
|
this.ResizeHeightTo(0, duration, Easing.OutQuint);
|
||||||
|
content.FadeOut(duration, Easing.OutQuint);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.ResizeHeightTo(height, duration, Easing.OutQuint);
|
||||||
|
content.FadeIn(duration, Easing.OutQuint);
|
||||||
|
countryPill.Expand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
164
osu.Game/Overlays/Rankings/CountryPill.cs
Normal file
164
osu.Game/Overlays/Rankings/CountryPill.cs
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
// 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.Collections.Generic;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Users;
|
||||||
|
using osu.Game.Users.Drawables;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Rankings
|
||||||
|
{
|
||||||
|
public class CountryPill : CompositeDrawable, IHasCurrentValue<Country>
|
||||||
|
{
|
||||||
|
private const int duration = 200;
|
||||||
|
|
||||||
|
private readonly BindableWithCurrent<Country> current = new BindableWithCurrent<Country>();
|
||||||
|
|
||||||
|
public Bindable<Country> Current
|
||||||
|
{
|
||||||
|
get => current.Current;
|
||||||
|
set => current.Current = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly Container content;
|
||||||
|
private readonly Box background;
|
||||||
|
private readonly UpdateableFlag flag;
|
||||||
|
private readonly OsuSpriteText countryName;
|
||||||
|
|
||||||
|
public CountryPill()
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
InternalChild = content = new CircularContainer
|
||||||
|
{
|
||||||
|
Height = 25,
|
||||||
|
AutoSizeDuration = duration,
|
||||||
|
AutoSizeEasing = Easing.OutQuint,
|
||||||
|
Masking = true,
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
background = new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
|
},
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
AutoSizeAxes = Axes.X,
|
||||||
|
Margin = new MarginPadding { Horizontal = 10 },
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Spacing = new Vector2(8, 0),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
AutoSizeAxes = Axes.X,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Spacing = new Vector2(3, 0),
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
flag = new UpdateableFlag
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Size = new Vector2(22, 15)
|
||||||
|
},
|
||||||
|
countryName = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Font = OsuFont.GetFont(size: 14)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new CloseButton
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Action = () => Current.Value = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
background.Colour = colours.GreySeafoamDarker;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
Current.BindValueChanged(onCountryChanged, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Expand()
|
||||||
|
{
|
||||||
|
content.ClearTransforms();
|
||||||
|
content.AutoSizeAxes = Axes.X;
|
||||||
|
|
||||||
|
this.FadeIn(duration, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Collapse()
|
||||||
|
{
|
||||||
|
content.ClearTransforms();
|
||||||
|
content.AutoSizeAxes = Axes.None;
|
||||||
|
content.ResizeWidthTo(0, duration, Easing.OutQuint);
|
||||||
|
|
||||||
|
this.FadeOut(duration, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onCountryChanged(ValueChangedEvent<Country> country)
|
||||||
|
{
|
||||||
|
if (country.NewValue == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
flag.Country = country.NewValue;
|
||||||
|
countryName.Text = country.NewValue.FullName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class CloseButton : OsuHoverContainer
|
||||||
|
{
|
||||||
|
private readonly SpriteIcon icon;
|
||||||
|
|
||||||
|
protected override IEnumerable<Drawable> EffectTargets => new[] { icon };
|
||||||
|
|
||||||
|
public CloseButton()
|
||||||
|
{
|
||||||
|
AutoSizeAxes = Axes.Both;
|
||||||
|
Add(icon = new SpriteIcon
|
||||||
|
{
|
||||||
|
Size = new Vector2(8),
|
||||||
|
Icon = FontAwesome.Solid.Times
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours)
|
||||||
|
{
|
||||||
|
IdleColour = colours.GreySeafoamLighter;
|
||||||
|
HoverColour = Color4.White;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
new SettingsButton
|
new SettingsButton
|
||||||
{
|
{
|
||||||
Text = "Key configuration",
|
Text = "Key configuration",
|
||||||
TooltipText = "Change global shortcut keys and gameplay bindings",
|
TooltipText = "change global shortcut keys and gameplay bindings",
|
||||||
Action = keyConfig.ToggleVisibility
|
Action = keyConfig.ToggleVisibility
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -87,7 +87,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
|
|
||||||
private class SensitivitySlider : OsuSliderBar<double>
|
private class SensitivitySlider : OsuSliderBar<double>
|
||||||
{
|
{
|
||||||
public override string TooltipText => Current.Disabled ? "Enable raw input to adjust sensitivity" : $"{base.TooltipText}x";
|
public override string TooltipText => Current.Disabled ? "enable raw input to adjust sensitivity" : $"{base.TooltipText}x";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ namespace osu.Game.Overlays.Settings
|
|||||||
UpdateState();
|
UpdateState();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string TooltipText => "Revert to default";
|
public string TooltipText => "revert to default";
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
{
|
{
|
||||||
|
@ -44,6 +44,9 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
public override bool DisallowExternalBeatmapRulesetChanges => true;
|
public override bool DisallowExternalBeatmapRulesetChanges => true;
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private BeatmapManager beatmapManager { get; set; }
|
||||||
|
|
||||||
private Box bottomBackground;
|
private Box bottomBackground;
|
||||||
private Container screenContainer;
|
private Container screenContainer;
|
||||||
|
|
||||||
@ -56,7 +59,6 @@ namespace osu.Game.Screens.Edit
|
|||||||
private EditorBeatmap editorBeatmap;
|
private EditorBeatmap editorBeatmap;
|
||||||
|
|
||||||
private DependencyContainer dependencies;
|
private DependencyContainer dependencies;
|
||||||
private GameHost host;
|
|
||||||
|
|
||||||
protected override UserActivity InitialActivity => new UserActivity.Editing(Beatmap.Value.BeatmapInfo);
|
protected override UserActivity InitialActivity => new UserActivity.Editing(Beatmap.Value.BeatmapInfo);
|
||||||
|
|
||||||
@ -66,8 +68,6 @@ namespace osu.Game.Screens.Edit
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours, GameHost host)
|
private void load(OsuColour colours, GameHost host)
|
||||||
{
|
{
|
||||||
this.host = host;
|
|
||||||
|
|
||||||
beatDivisor.Value = Beatmap.Value.BeatmapInfo.BeatDivisor;
|
beatDivisor.Value = Beatmap.Value.BeatmapInfo.BeatDivisor;
|
||||||
beatDivisor.BindValueChanged(divisor => Beatmap.Value.BeatmapInfo.BeatDivisor = divisor.NewValue);
|
beatDivisor.BindValueChanged(divisor => Beatmap.Value.BeatmapInfo.BeatDivisor = divisor.NewValue);
|
||||||
|
|
||||||
@ -90,7 +90,8 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
if (RuntimeInfo.IsDesktop)
|
if (RuntimeInfo.IsDesktop)
|
||||||
{
|
{
|
||||||
fileMenuItems.Add(new EditorMenuItem("Export", MenuItemType.Standard, exportBeatmap));
|
fileMenuItems.Add(new EditorMenuItem("Save", MenuItemType.Standard, saveBeatmap));
|
||||||
|
fileMenuItems.Add(new EditorMenuItem("Export package", MenuItemType.Standard, exportBeatmap));
|
||||||
fileMenuItems.Add(new EditorMenuItemSpacer());
|
fileMenuItems.Add(new EditorMenuItemSpacer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,6 +206,15 @@ namespace osu.Game.Screens.Edit
|
|||||||
case Key.Right:
|
case Key.Right:
|
||||||
seek(e, 1);
|
seek(e, 1);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case Key.S:
|
||||||
|
if (e.ControlPressed)
|
||||||
|
{
|
||||||
|
saveBeatmap();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return base.OnKeyDown(e);
|
return base.OnKeyDown(e);
|
||||||
@ -292,8 +302,6 @@ namespace osu.Game.Screens.Edit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void exportBeatmap() => host.OpenFileExternally(Beatmap.Value.Save());
|
|
||||||
|
|
||||||
private void onModeChanged(ValueChangedEvent<EditorScreenMode> e)
|
private void onModeChanged(ValueChangedEvent<EditorScreenMode> e)
|
||||||
{
|
{
|
||||||
currentScreen?.Exit();
|
currentScreen?.Exit();
|
||||||
@ -329,5 +337,13 @@ namespace osu.Game.Screens.Edit
|
|||||||
else
|
else
|
||||||
clock.SeekForward(!clock.IsRunning, amount);
|
clock.SeekForward(!clock.IsRunning, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void saveBeatmap() => beatmapManager.Save(playableBeatmap.BeatmapInfo, editorBeatmap);
|
||||||
|
|
||||||
|
private void exportBeatmap()
|
||||||
|
{
|
||||||
|
saveBeatmap();
|
||||||
|
beatmapManager.Export(Beatmap.Value.BeatmapSetInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,15 +74,15 @@ namespace osu.Game.Screens.Ranking.Pages
|
|||||||
switch (replayAvailability)
|
switch (replayAvailability)
|
||||||
{
|
{
|
||||||
case ReplayAvailability.Local:
|
case ReplayAvailability.Local:
|
||||||
button.TooltipText = @"Watch replay";
|
button.TooltipText = @"watch replay";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ReplayAvailability.Online:
|
case ReplayAvailability.Online:
|
||||||
button.TooltipText = @"Download replay";
|
button.TooltipText = @"download replay";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
button.TooltipText = @"Replay unavailable";
|
button.TooltipText = @"replay unavailable";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
@ -39,7 +39,7 @@ namespace osu.Game.Screens.Ranking.Pages
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
TooltipText = "Retry";
|
TooltipText = "retry";
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
@ -412,6 +412,12 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
protected override bool OnKeyDown(KeyDownEvent e)
|
protected override bool OnKeyDown(KeyDownEvent e)
|
||||||
{
|
{
|
||||||
|
// allow for controlling volume when alt is held.
|
||||||
|
// this is required as the VolumeControlReceptor uses OnPressed, which is
|
||||||
|
// executed after all OnKeyDown events.
|
||||||
|
if (e.AltPressed)
|
||||||
|
return base.OnKeyDown(e);
|
||||||
|
|
||||||
int direction = 0;
|
int direction = 0;
|
||||||
bool skipDifficulties = false;
|
bool skipDifficulties = false;
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ namespace osu.Game.Users.Drawables
|
|||||||
|
|
||||||
private class ClickableArea : OsuClickableContainer
|
private class ClickableArea : OsuClickableContainer
|
||||||
{
|
{
|
||||||
public override string TooltipText => Enabled.Value ? @"View Profile" : null;
|
public override string TooltipText => Enabled.Value ? @"view profile" : null;
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user