mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 19:22:54 +08:00
Merge branch 'master' into use-beatmap-interfaces-more-uncontested
This commit is contained in:
commit
1e3c84b34b
@ -0,0 +1,53 @@
|
||||
// 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.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Tests.Visual.UserInterface;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Beatmaps
|
||||
{
|
||||
public class TestSceneBeatmapSetOnlineStatusPill : ThemeComparisonTestScene
|
||||
{
|
||||
protected override Drawable CreateContent() => new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 10),
|
||||
ChildrenEnumerable = Enum.GetValues(typeof(BeatmapSetOnlineStatus)).Cast<BeatmapSetOnlineStatus>().Select(status => new BeatmapSetOnlineStatusPill
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Status = status
|
||||
})
|
||||
};
|
||||
|
||||
private IEnumerable<BeatmapSetOnlineStatusPill> statusPills => this.ChildrenOfType<BeatmapSetOnlineStatusPill>();
|
||||
|
||||
[Test]
|
||||
public void TestFixedWidth()
|
||||
{
|
||||
AddStep("create themed content", () => CreateThemedContent(OverlayColourScheme.Red));
|
||||
|
||||
AddStep("set fixed width", () => statusPills.ForEach(pill =>
|
||||
{
|
||||
pill.AutoSizeAxes = Axes.Y;
|
||||
pill.Width = 90;
|
||||
}));
|
||||
AddStep("unset fixed width", () => statusPills.ForEach(pill => pill.AutoSizeAxes = Axes.Both));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
// 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 Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Tournament.Models;
|
||||
|
||||
namespace osu.Game.Tournament.Tests.NonVisual
|
||||
{
|
||||
[TestFixture]
|
||||
public class LadderInfoSerialisationTest
|
||||
{
|
||||
[Test]
|
||||
public void TestDeserialise()
|
||||
{
|
||||
var ladder = createSampleLadder();
|
||||
string serialised = JsonConvert.SerializeObject(ladder);
|
||||
|
||||
JsonConvert.DeserializeObject<LadderInfo>(serialised, new JsonPointConverter());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSerialise()
|
||||
{
|
||||
var ladder = createSampleLadder();
|
||||
JsonConvert.SerializeObject(ladder);
|
||||
}
|
||||
|
||||
private static LadderInfo createSampleLadder()
|
||||
{
|
||||
var match = TournamentTestScene.CreateSampleMatch();
|
||||
|
||||
return new LadderInfo
|
||||
{
|
||||
PlayersPerTeam = { Value = 4 },
|
||||
Teams =
|
||||
{
|
||||
match.Team1.Value,
|
||||
match.Team2.Value,
|
||||
},
|
||||
Rounds =
|
||||
{
|
||||
new TournamentRound
|
||||
{
|
||||
Beatmaps =
|
||||
{
|
||||
new RoundBeatmap { BeatmapInfo = TournamentTestScene.CreateSampleBeatmapInfo() },
|
||||
new RoundBeatmap { BeatmapInfo = TournamentTestScene.CreateSampleBeatmapInfo() },
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Matches =
|
||||
{
|
||||
match,
|
||||
},
|
||||
Progressions =
|
||||
{
|
||||
new TournamentProgression(1, 2),
|
||||
new TournamentProgression(1, 3, true),
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -152,7 +152,16 @@ namespace osu.Game.Tournament.Tests
|
||||
};
|
||||
|
||||
public static BeatmapInfo CreateSampleBeatmapInfo() =>
|
||||
new BeatmapInfo { Metadata = new BeatmapMetadata { Title = "Test Title", Artist = "Test Artist", ID = RNG.Next(0, 1000000) } };
|
||||
new BeatmapInfo
|
||||
{
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Title = "Test Title",
|
||||
Artist = "Test Artist",
|
||||
ID = RNG.Next(0, 1000000)
|
||||
},
|
||||
OnlineInfo = new BeatmapOnlineInfo(),
|
||||
};
|
||||
|
||||
protected override ITestSceneTestRunner CreateRunner() => new TournamentTestSceneTestRunner();
|
||||
|
||||
|
@ -12,6 +12,7 @@ using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input.Handlers.Mouse;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Cursor;
|
||||
@ -60,72 +61,89 @@ namespace osu.Game.Tournament
|
||||
|
||||
loadingSpinner.Show();
|
||||
|
||||
BracketLoadTask.ContinueWith(_ => LoadComponentsAsync(new[]
|
||||
BracketLoadTask.ContinueWith(t =>
|
||||
{
|
||||
new Container
|
||||
if (t.IsFaulted)
|
||||
{
|
||||
CornerRadius = 10,
|
||||
Depth = float.MinValue,
|
||||
Position = new Vector2(5),
|
||||
Masking = true,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Children = new Drawable[]
|
||||
Schedule(() =>
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = OsuColour.Gray(0.2f),
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new TourneyButton
|
||||
{
|
||||
Text = "Save Changes",
|
||||
Width = 140,
|
||||
Height = 50,
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
Top = 10,
|
||||
Left = 10,
|
||||
},
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Right = 10,
|
||||
Bottom = 10,
|
||||
},
|
||||
Action = SaveChanges,
|
||||
},
|
||||
}
|
||||
},
|
||||
heightWarning = new WarningBox("Please make the window wider")
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Margin = new MarginPadding(20),
|
||||
},
|
||||
new OsuContextMenuContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new TournamentSceneManager()
|
||||
loadingSpinner.Hide();
|
||||
loadingSpinner.Expire();
|
||||
|
||||
Logger.Error(t.Exception, "Couldn't load bracket with error");
|
||||
Add(new WarningBox("Your bracket.json file could not be parsed. Please check runtime.log for more details."));
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
}, drawables =>
|
||||
{
|
||||
loadingSpinner.Hide();
|
||||
loadingSpinner.Expire();
|
||||
|
||||
AddRange(drawables);
|
||||
|
||||
windowSize.BindValueChanged(size => ScheduleAfterChildren(() =>
|
||||
LoadComponentsAsync(new[]
|
||||
{
|
||||
var minWidth = (int)(size.NewValue.Height / 768f * TournamentSceneManager.REQUIRED_WIDTH) - 1;
|
||||
heightWarning.Alpha = size.NewValue.Width < minWidth ? 1 : 0;
|
||||
}), true);
|
||||
|
||||
windowMode.BindValueChanged(mode => ScheduleAfterChildren(() =>
|
||||
new Container
|
||||
{
|
||||
CornerRadius = 10,
|
||||
Depth = float.MinValue,
|
||||
Position = new Vector2(5),
|
||||
Masking = true,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
Colour = OsuColour.Gray(0.2f),
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
new TourneyButton
|
||||
{
|
||||
Text = "Save Changes",
|
||||
Width = 140,
|
||||
Height = 50,
|
||||
Padding = new MarginPadding
|
||||
{
|
||||
Top = 10,
|
||||
Left = 10,
|
||||
},
|
||||
Margin = new MarginPadding
|
||||
{
|
||||
Right = 10,
|
||||
Bottom = 10,
|
||||
},
|
||||
Action = SaveChanges,
|
||||
},
|
||||
}
|
||||
},
|
||||
heightWarning = new WarningBox("Please make the window wider")
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Margin = new MarginPadding(20),
|
||||
},
|
||||
new OsuContextMenuContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new TournamentSceneManager()
|
||||
}
|
||||
}, drawables =>
|
||||
{
|
||||
windowMode.Value = WindowMode.Windowed;
|
||||
}), true);
|
||||
}));
|
||||
loadingSpinner.Hide();
|
||||
loadingSpinner.Expire();
|
||||
|
||||
AddRange(drawables);
|
||||
|
||||
windowSize.BindValueChanged(size => ScheduleAfterChildren(() =>
|
||||
{
|
||||
var minWidth = (int)(size.NewValue.Height / 768f * TournamentSceneManager.REQUIRED_WIDTH) - 1;
|
||||
heightWarning.Alpha = size.NewValue.Width < minWidth ? 1 : 0;
|
||||
}), true);
|
||||
|
||||
windowMode.BindValueChanged(mode => ScheduleAfterChildren(() =>
|
||||
{
|
||||
windowMode.Value = WindowMode.Windowed;
|
||||
}), true);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,75 +58,83 @@ namespace osu.Game.Tournament
|
||||
|
||||
private void readBracket()
|
||||
{
|
||||
if (storage.Exists(bracket_filename))
|
||||
try
|
||||
{
|
||||
using (Stream stream = storage.GetStream(bracket_filename, FileAccess.Read, FileMode.Open))
|
||||
using (var sr = new StreamReader(stream))
|
||||
ladder = JsonConvert.DeserializeObject<LadderInfo>(sr.ReadToEnd(), new JsonPointConverter());
|
||||
}
|
||||
|
||||
ladder ??= new LadderInfo();
|
||||
|
||||
ladder.Ruleset.Value = RulesetStore.GetRuleset(ladder.Ruleset.Value?.ShortName)
|
||||
?? RulesetStore.AvailableRulesets.First();
|
||||
|
||||
bool addedInfo = false;
|
||||
|
||||
// assign teams
|
||||
foreach (var match in ladder.Matches)
|
||||
{
|
||||
match.Team1.Value = ladder.Teams.FirstOrDefault(t => t.Acronym.Value == match.Team1Acronym);
|
||||
match.Team2.Value = ladder.Teams.FirstOrDefault(t => t.Acronym.Value == match.Team2Acronym);
|
||||
|
||||
foreach (var conditional in match.ConditionalMatches)
|
||||
if (storage.Exists(bracket_filename))
|
||||
{
|
||||
conditional.Team1.Value = ladder.Teams.FirstOrDefault(t => t.Acronym.Value == conditional.Team1Acronym);
|
||||
conditional.Team2.Value = ladder.Teams.FirstOrDefault(t => t.Acronym.Value == conditional.Team2Acronym);
|
||||
conditional.Round.Value = match.Round.Value;
|
||||
using (Stream stream = storage.GetStream(bracket_filename, FileAccess.Read, FileMode.Open))
|
||||
using (var sr = new StreamReader(stream))
|
||||
ladder = JsonConvert.DeserializeObject<LadderInfo>(sr.ReadToEnd(), new JsonPointConverter());
|
||||
}
|
||||
}
|
||||
|
||||
// assign progressions
|
||||
foreach (var pair in ladder.Progressions)
|
||||
{
|
||||
var src = ladder.Matches.FirstOrDefault(p => p.ID == pair.SourceID);
|
||||
var dest = ladder.Matches.FirstOrDefault(p => p.ID == pair.TargetID);
|
||||
ladder ??= new LadderInfo();
|
||||
|
||||
if (src == null)
|
||||
continue;
|
||||
ladder.Ruleset.Value = RulesetStore.GetRuleset(ladder.Ruleset.Value?.ShortName)
|
||||
?? RulesetStore.AvailableRulesets.First();
|
||||
|
||||
if (dest != null)
|
||||
bool addedInfo = false;
|
||||
|
||||
// assign teams
|
||||
foreach (var match in ladder.Matches)
|
||||
{
|
||||
if (pair.Losers)
|
||||
src.LosersProgression.Value = dest;
|
||||
else
|
||||
src.Progression.Value = dest;
|
||||
}
|
||||
}
|
||||
match.Team1.Value = ladder.Teams.FirstOrDefault(t => t.Acronym.Value == match.Team1Acronym);
|
||||
match.Team2.Value = ladder.Teams.FirstOrDefault(t => t.Acronym.Value == match.Team2Acronym);
|
||||
|
||||
// link matches to rounds
|
||||
foreach (var round in ladder.Rounds)
|
||||
{
|
||||
foreach (var id in round.Matches)
|
||||
{
|
||||
var found = ladder.Matches.FirstOrDefault(p => p.ID == id);
|
||||
|
||||
if (found != null)
|
||||
foreach (var conditional in match.ConditionalMatches)
|
||||
{
|
||||
found.Round.Value = round;
|
||||
if (round.StartDate.Value > found.Date.Value)
|
||||
found.Date.Value = round.StartDate.Value;
|
||||
conditional.Team1.Value = ladder.Teams.FirstOrDefault(t => t.Acronym.Value == conditional.Team1Acronym);
|
||||
conditional.Team2.Value = ladder.Teams.FirstOrDefault(t => t.Acronym.Value == conditional.Team2Acronym);
|
||||
conditional.Round.Value = match.Round.Value;
|
||||
}
|
||||
}
|
||||
|
||||
// assign progressions
|
||||
foreach (var pair in ladder.Progressions)
|
||||
{
|
||||
var src = ladder.Matches.FirstOrDefault(p => p.ID == pair.SourceID);
|
||||
var dest = ladder.Matches.FirstOrDefault(p => p.ID == pair.TargetID);
|
||||
|
||||
if (src == null)
|
||||
continue;
|
||||
|
||||
if (dest != null)
|
||||
{
|
||||
if (pair.Losers)
|
||||
src.LosersProgression.Value = dest;
|
||||
else
|
||||
src.Progression.Value = dest;
|
||||
}
|
||||
}
|
||||
|
||||
// link matches to rounds
|
||||
foreach (var round in ladder.Rounds)
|
||||
{
|
||||
foreach (var id in round.Matches)
|
||||
{
|
||||
var found = ladder.Matches.FirstOrDefault(p => p.ID == id);
|
||||
|
||||
if (found != null)
|
||||
{
|
||||
found.Round.Value = round;
|
||||
if (round.StartDate.Value > found.Date.Value)
|
||||
found.Date.Value = round.StartDate.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addedInfo |= addPlayers();
|
||||
addedInfo |= addBeatmaps();
|
||||
|
||||
if (addedInfo)
|
||||
SaveChanges();
|
||||
|
||||
ladder.CurrentMatch.Value = ladder.Matches.FirstOrDefault(p => p.Current.Value);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
taskCompletionSource.SetException(e);
|
||||
return;
|
||||
}
|
||||
|
||||
addedInfo |= addPlayers();
|
||||
addedInfo |= addBeatmaps();
|
||||
|
||||
if (addedInfo)
|
||||
SaveChanges();
|
||||
|
||||
ladder.CurrentMatch.Value = ladder.Matches.FirstOrDefault(p => p.Current.Value);
|
||||
|
||||
Schedule(() =>
|
||||
{
|
||||
|
@ -237,7 +237,7 @@ namespace osu.Game.Tournament
|
||||
{
|
||||
Type = type;
|
||||
BackgroundColour = OsuColour.Gray(0.2f);
|
||||
Action = () => RequestSelection(type);
|
||||
Action = () => RequestSelection?.Invoke(type);
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
}
|
||||
|
@ -117,7 +117,6 @@ namespace osu.Game.Beatmaps
|
||||
[JsonIgnore]
|
||||
public DateTimeOffset? LastUpdated => OnlineInfo.LastUpdated;
|
||||
|
||||
[NotMapped]
|
||||
[JsonIgnore]
|
||||
public BeatmapSetOnlineStatus Status { get; set; } = BeatmapSetOnlineStatus.None;
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
// 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.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.LocalisationExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
@ -8,15 +11,13 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Overlays;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawables
|
||||
{
|
||||
public class BeatmapSetOnlineStatusPill : CircularContainer
|
||||
{
|
||||
private readonly OsuSpriteText statusText;
|
||||
private readonly Box background;
|
||||
|
||||
private BeatmapSetOnlineStatus status;
|
||||
|
||||
public BeatmapSetOnlineStatus Status
|
||||
@ -29,8 +30,8 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
|
||||
status = value;
|
||||
|
||||
Alpha = value == BeatmapSetOnlineStatus.None ? 0 : 1;
|
||||
statusText.Text = value.GetLocalisableDescription().ToUpper();
|
||||
if (IsLoaded)
|
||||
updateState();
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,15 +47,17 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
set => statusText.Padding = value;
|
||||
}
|
||||
|
||||
public Color4 BackgroundColour
|
||||
{
|
||||
get => background.Colour;
|
||||
set => background.Colour = value;
|
||||
}
|
||||
private readonly OsuSpriteText statusText;
|
||||
private readonly Box background;
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; } = null!;
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private OverlayColourProvider? colourProvider { get; set; }
|
||||
|
||||
public BeatmapSetOnlineStatusPill()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Masking = true;
|
||||
|
||||
Children = new Drawable[]
|
||||
@ -63,7 +66,6 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.5f,
|
||||
},
|
||||
statusText = new OsuSpriteText
|
||||
{
|
||||
@ -74,6 +76,27 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
};
|
||||
|
||||
Status = BeatmapSetOnlineStatus.None;
|
||||
TextPadding = new MarginPadding { Horizontal = 5, Bottom = 1 };
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
updateState();
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
Alpha = Status == BeatmapSetOnlineStatus.None ? 0 : 1;
|
||||
|
||||
statusText.Text = Status.GetLocalisableDescription().ToUpper();
|
||||
|
||||
if (colourProvider != null)
|
||||
statusText.Colour = status == BeatmapSetOnlineStatus.Graveyard ? colourProvider.Background1 : colourProvider.Background3;
|
||||
else
|
||||
statusText.Colour = status == BeatmapSetOnlineStatus.Graveyard ? colours.GreySeafoamLight : Color4.Black;
|
||||
|
||||
background.Colour = OsuColour.ForBeatmapSetOnlineStatus(Status) ?? colourProvider?.Light1 ?? colours.GreySeafoamLighter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -118,6 +118,42 @@ namespace osu.Game.Graphics
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a colour for the given <see cref="BeatmapSetOnlineStatus"/>.
|
||||
/// A <see langword="null"/> value indicates that a "background" shade from the local <see cref="OverlayColourProvider"/>
|
||||
/// (or another fallback colour) should be used.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Sourced from web: https://github.com/ppy/osu-web/blob/007eebb1916ed5cb6a7866d82d8011b1060a945e/resources/assets/less/layout.less#L36-L50
|
||||
/// </remarks>
|
||||
public static Color4? ForBeatmapSetOnlineStatus(BeatmapSetOnlineStatus status)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case BeatmapSetOnlineStatus.Ranked:
|
||||
case BeatmapSetOnlineStatus.Approved:
|
||||
return Color4Extensions.FromHex(@"b3ff66");
|
||||
|
||||
case BeatmapSetOnlineStatus.Loved:
|
||||
return Color4Extensions.FromHex(@"ff66ab");
|
||||
|
||||
case BeatmapSetOnlineStatus.Qualified:
|
||||
return Color4Extensions.FromHex(@"66ccff");
|
||||
|
||||
case BeatmapSetOnlineStatus.Pending:
|
||||
return Color4Extensions.FromHex(@"ffd966");
|
||||
|
||||
case BeatmapSetOnlineStatus.WIP:
|
||||
return Color4Extensions.FromHex(@"ff9966");
|
||||
|
||||
case BeatmapSetOnlineStatus.Graveyard:
|
||||
return Color4.Black;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a foreground text colour that is supposed to contrast well with
|
||||
/// the supplied <paramref name="backgroundColour"/>.
|
||||
|
@ -1,20 +1,38 @@
|
||||
// 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;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace osu.Game.Online.API.Requests
|
||||
{
|
||||
public class GetBeatmapRequest : APIRequest<APIBeatmap>
|
||||
{
|
||||
private readonly BeatmapInfo beatmapInfo;
|
||||
private readonly IBeatmapInfo beatmapInfo;
|
||||
|
||||
public GetBeatmapRequest(BeatmapInfo beatmapInfo)
|
||||
private readonly string filename;
|
||||
|
||||
public GetBeatmapRequest(IBeatmapInfo beatmapInfo)
|
||||
{
|
||||
this.beatmapInfo = beatmapInfo;
|
||||
|
||||
filename = (beatmapInfo as BeatmapInfo)?.Path ?? string.Empty;
|
||||
}
|
||||
|
||||
protected override string Target => $@"beatmaps/lookup?id={beatmapInfo.OnlineBeatmapID}&checksum={beatmapInfo.MD5Hash}&filename={System.Uri.EscapeUriString(beatmapInfo.Path ?? string.Empty)}";
|
||||
protected override WebRequest CreateWebRequest()
|
||||
{
|
||||
var request = base.CreateWebRequest();
|
||||
|
||||
request.AddParameter(@"id", beatmapInfo.OnlineID.ToString());
|
||||
request.AddParameter(@"checksum", beatmapInfo.MD5Hash);
|
||||
request.AddParameter(@"filename", filename);
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
protected override string Target => @"beatmaps/lookup";
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
[JsonProperty(@"accuracy")]
|
||||
private float overallDifficulty { get; set; }
|
||||
|
||||
public double Length => lengthInSeconds * 1000;
|
||||
public double Length => TimeSpan.FromSeconds(lengthInSeconds).TotalMilliseconds;
|
||||
|
||||
[JsonProperty(@"total_length")]
|
||||
private double lengthInSeconds { get; set; }
|
||||
@ -86,7 +86,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
OnlineBeatmapID = OnlineID,
|
||||
Version = DifficultyName,
|
||||
// this is actually an incorrect mapping (Length is calculated as drain length in lazer's import process, see BeatmapManager.calculateLength).
|
||||
Length = TimeSpan.FromSeconds(Length).TotalMilliseconds,
|
||||
Length = Length,
|
||||
Status = Status,
|
||||
MD5Hash = Checksum,
|
||||
BeatmapSet = set,
|
||||
|
@ -243,6 +243,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
|
||||
|
||||
statusContainer.Add(new BeatmapSetOnlineStatusPill
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
TextSize = 12,
|
||||
TextPadding = new MarginPadding { Horizontal = 10, Vertical = 5 },
|
||||
Status = SetInfo.OnlineInfo?.Status ?? BeatmapSetOnlineStatus.None,
|
||||
|
@ -257,6 +257,7 @@ namespace osu.Game.Overlays.BeatmapListing.Panels
|
||||
|
||||
statusContainer.Add(new BeatmapSetOnlineStatusPill
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
TextSize = 12,
|
||||
TextPadding = new MarginPadding { Horizontal = 10, Vertical = 4 },
|
||||
Status = SetInfo.OnlineInfo?.Status ?? BeatmapSetOnlineStatus.None,
|
||||
|
@ -198,6 +198,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
onlineStatusPill = new BeatmapSetOnlineStatusPill
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
TextSize = 14,
|
||||
@ -220,7 +221,6 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
private void load(OverlayColourProvider colourProvider)
|
||||
{
|
||||
coverGradient.Colour = ColourInfo.GradientVertical(colourProvider.Background6.Opacity(0.3f), colourProvider.Background6.Opacity(0.8f));
|
||||
onlineStatusPill.BackgroundColour = colourProvider.Background6;
|
||||
|
||||
State.BindValueChanged(_ => updateDownloadButtons());
|
||||
|
||||
|
@ -257,6 +257,7 @@ namespace osu.Game.Screens.Select
|
||||
},
|
||||
StatusPill = new BeatmapSetOnlineStatusPill
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Shear = -wedged_container_shear,
|
||||
|
@ -60,6 +60,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
new BeatmapSetOnlineStatusPill
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Margin = new MarginPadding { Right = 5 },
|
||||
|
Loading…
Reference in New Issue
Block a user