1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 03:23:03 +08:00

Merge remote-tracking branch 'upstream/master' into databased-sin-setting

This commit is contained in:
Dean Herbert 2019-06-05 19:03:57 +09:00
commit 8607f3b765
109 changed files with 2235 additions and 629 deletions

1
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1 @@
custom: https://osu.ppy.sh/home/support

View File

@ -1,13 +1,11 @@
// 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.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Platform;
using osu.Game;
using osu.Game.Configuration;
using osu.Game.Graphics;
@ -25,15 +23,13 @@ namespace osu.Desktop.Overlays
private OsuConfigManager config;
private OsuGameBase game;
private NotificationOverlay notificationOverlay;
private GameHost host;
[BackgroundDependencyLoader]
private void load(NotificationOverlay notification, OsuColour colours, TextureStore textures, OsuGameBase game, OsuConfigManager config, GameHost host)
private void load(NotificationOverlay notification, OsuColour colours, TextureStore textures, OsuGameBase game, OsuConfigManager config)
{
notificationOverlay = notification;
this.config = config;
this.game = game;
this.host = host;
AutoSizeAxes = Axes.Both;
Anchor = Anchor.BottomCentre;
@ -102,27 +98,31 @@ namespace osu.Desktop.Overlays
// only show a notification if we've previously saved a version to the config file (ie. not the first run).
if (!string.IsNullOrEmpty(lastVersion))
notificationOverlay.Post(new UpdateCompleteNotification(version, host.OpenUrlExternally));
notificationOverlay.Post(new UpdateCompleteNotification(version));
}
}
private class UpdateCompleteNotification : SimpleNotification
{
public UpdateCompleteNotification(string version, Action<string> openUrl = null)
private readonly string version;
public UpdateCompleteNotification(string version)
{
this.version = version;
Text = $"You are now running osu!lazer {version}.\nClick to see what's new!";
Icon = FontAwesome.Solid.CheckSquare;
Activated = delegate
{
openUrl?.Invoke($"https://osu.ppy.sh/home/changelog/lazer/{version}");
return true;
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
private void load(OsuColour colours, ChangelogOverlay changelog)
{
Icon = FontAwesome.Solid.CheckSquare;
IconBackgound.Colour = colours.BlueDark;
Activated = delegate
{
changelog.ShowBuild("lazer", version);
return true;
};
}
}

View File

@ -20,14 +20,14 @@ namespace osu.Game.Rulesets.Catch.Tests
{
}
protected override IBeatmap CreateBeatmap(Ruleset ruleset)
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
{
var beatmap = new Beatmap
{
BeatmapInfo = new BeatmapInfo
{
BaseDifficulty = new BeatmapDifficulty { CircleSize = 6, SliderMultiplier = 3 },
Ruleset = ruleset.RulesetInfo
Ruleset = ruleset
}
};

View File

@ -29,14 +29,14 @@ namespace osu.Game.Rulesets.Catch.Tests
{
}
protected override IBeatmap CreateBeatmap(Ruleset ruleset)
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
{
var beatmap = new Beatmap
{
BeatmapInfo = new BeatmapInfo
{
BaseDifficulty = new BeatmapDifficulty { CircleSize = 6 },
Ruleset = ruleset.RulesetInfo
Ruleset = ruleset
}
};

View File

@ -16,14 +16,14 @@ namespace osu.Game.Rulesets.Catch.Tests
{
}
protected override IBeatmap CreateBeatmap(Ruleset ruleset)
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
{
var beatmap = new Beatmap
{
BeatmapInfo = new BeatmapInfo
{
BaseDifficulty = new BeatmapDifficulty { CircleSize = 6 },
Ruleset = ruleset.RulesetInfo
Ruleset = ruleset
}
};

View File

@ -23,13 +23,13 @@ namespace osu.Game.Rulesets.Catch.Tests
AddAssert("First note is hyperdash", () => Beatmap.Value.Beatmap.HitObjects[0] is Fruit f && f.HyperDash);
}
protected override IBeatmap CreateBeatmap(Ruleset ruleset)
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
{
var beatmap = new Beatmap
{
BeatmapInfo =
{
Ruleset = ruleset.RulesetInfo,
Ruleset = ruleset,
BaseDifficulty = new BeatmapDifficulty { CircleSize = 3.6f }
}
};

View File

@ -17,14 +17,14 @@ namespace osu.Game.Rulesets.Osu.Tests
{
}
protected override IBeatmap CreateBeatmap(Ruleset ruleset)
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
{
var beatmap = new Beatmap
{
BeatmapInfo = new BeatmapInfo
{
BaseDifficulty = new BeatmapDifficulty { CircleSize = 6 },
Ruleset = ruleset.RulesetInfo
Ruleset = ruleset
}
};

View File

@ -20,7 +20,6 @@ using osu.Game.Rulesets.Replays;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osu.Game.Screens.Play;
using osu.Game.Tests.Beatmaps;
using osu.Game.Tests.Visual;
using osuTK;
@ -299,7 +298,7 @@ namespace osu.Game.Rulesets.Osu.Tests
{
AddStep("load player", () =>
{
Beatmap.Value = new TestWorkingBeatmap(new Beatmap<OsuHitObject>
Beatmap.Value = CreateWorkingBeatmap(new Beatmap<OsuHitObject>
{
HitObjects =
{
@ -323,7 +322,7 @@ namespace osu.Game.Rulesets.Osu.Tests
BaseDifficulty = new BeatmapDifficulty { SliderTickRate = 3 },
Ruleset = new OsuRuleset().RulesetInfo
},
}, Clock);
});
var p = new ScoreAccessibleReplayPlayer(new Score { Replay = new Replay { Frames = frames } });

View File

@ -18,7 +18,6 @@ using osu.Game.Rulesets.Taiko.Judgements;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.Taiko.Objects.Drawables;
using osu.Game.Rulesets.Taiko.UI;
using osu.Game.Tests.Beatmaps;
using osu.Game.Tests.Visual;
using osuTK;
using osu.Game.Rulesets.Scoring;
@ -64,7 +63,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
var controlPointInfo = new ControlPointInfo();
controlPointInfo.TimingPoints.Add(new TimingControlPoint());
WorkingBeatmap beatmap = new TestWorkingBeatmap(new Beatmap
WorkingBeatmap beatmap = CreateWorkingBeatmap(new Beatmap
{
HitObjects = new List<HitObject> { new CentreHit() },
BeatmapInfo = new BeatmapInfo
@ -79,7 +78,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
Ruleset = new TaikoRuleset().RulesetInfo
},
ControlPointInfo = controlPointInfo
}, Clock);
});
Add(playfieldContainer = new Container
{

View File

@ -7,6 +7,7 @@ using System.Linq;
using System.Threading;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
@ -54,7 +55,7 @@ namespace osu.Game.Tests.Visual.Background
private RulesetStore rulesets;
[BackgroundDependencyLoader]
private void load(GameHost host)
private void load(GameHost host, AudioManager audio)
{
factory = new DatabaseContextFactory(LocalStorage);
factory.ResetDatabase();
@ -68,7 +69,7 @@ namespace osu.Game.Tests.Visual.Background
usage.Migrate();
Dependencies.Cache(rulesets = new RulesetStore(factory));
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, factory, rulesets, null, null, host, Beatmap.Default));
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, factory, rulesets, null, audio, host, Beatmap.Default));
Dependencies.Cache(new OsuConfigManager(LocalStorage));
manager.Import(TestResources.GetTestBeatmapForImport());

View File

@ -111,16 +111,19 @@ namespace osu.Game.Tests.Visual.Components
private class TestPreviewTrackManager : PreviewTrackManager
{
protected override TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, TrackManager trackManager) => new TestPreviewTrack(beatmapSetInfo, trackManager);
protected override TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackStore) => new TestPreviewTrack(beatmapSetInfo, trackStore);
protected class TestPreviewTrack : TrackManagerPreviewTrack
{
public TestPreviewTrack(BeatmapSetInfo beatmapSetInfo, TrackManager trackManager)
private readonly ITrackStore trackManager;
public TestPreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackManager)
: base(beatmapSetInfo, trackManager)
{
this.trackManager = trackManager;
}
protected override Track GetTrack() => new TrackVirtual { Length = 100000 };
protected override Track GetTrack() => trackManager.GetVirtual(100000);
}
}
}

View File

@ -7,7 +7,6 @@ using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Edit.Compose;
using osu.Game.Tests.Beatmaps;
namespace osu.Game.Tests.Visual.Editor
{
@ -19,7 +18,7 @@ namespace osu.Game.Tests.Visual.Editor
[BackgroundDependencyLoader]
private void load()
{
Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo, Clock);
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
Child = new ComposeScreen();
}
}

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -30,9 +31,9 @@ namespace osu.Game.Tests.Visual.Editor
};
[BackgroundDependencyLoader]
private void load()
private void load(AudioManager audio)
{
Beatmap.Value = new WaveformTestBeatmap();
Beatmap.Value = new WaveformTestBeatmap(audio);
Children = new Drawable[]
{

View File

@ -1,4 +1,4 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// 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 NUnit.Framework;
@ -10,7 +10,6 @@ using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Tests.Beatmaps;
using osuTK;
using osuTK.Graphics;
@ -48,7 +47,7 @@ namespace osu.Game.Tests.Visual.Editor
}
};
Beatmap.Value = new TestWorkingBeatmap(testBeatmap, Clock);
Beatmap.Value = CreateWorkingBeatmap(testBeatmap);
Child = new TimingPointVisualiser(testBeatmap, 5000) { Clock = Clock };
}

View File

@ -8,7 +8,6 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Osu;
using osu.Game.Screens.Edit.Components.Timelines.Summary;
using osu.Game.Tests.Beatmaps;
using osuTK;
namespace osu.Game.Tests.Visual.Editor
@ -21,7 +20,7 @@ namespace osu.Game.Tests.Visual.Editor
[BackgroundDependencyLoader]
private void load()
{
Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo, null);
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
Add(new SummaryTimeline
{

View File

@ -18,7 +18,6 @@ using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Screens.Edit.Compose;
using osu.Game.Screens.Edit.Compose.Components;
using osu.Game.Tests.Beatmaps;
using osuTK;
namespace osu.Game.Tests.Visual.Editor
@ -45,7 +44,7 @@ namespace osu.Game.Tests.Visual.Editor
[BackgroundDependencyLoader]
private void load()
{
Beatmap.Value = new TestWorkingBeatmap(new Beatmap
Beatmap.Value = CreateWorkingBeatmap(new Beatmap
{
HitObjects = new List<HitObject>
{

View File

@ -1,4 +1,4 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// 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 NUnit.Framework;
@ -7,7 +7,6 @@ using osu.Framework.Graphics;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Screens.Edit.Components;
using osu.Game.Tests.Beatmaps;
using osuTK;
namespace osu.Game.Tests.Visual.Editor
@ -29,7 +28,7 @@ namespace osu.Game.Tests.Visual.Editor
Size = new Vector2(200, 100)
};
Beatmap.Value = new TestWorkingBeatmap(new Beatmap(), Clock);
Beatmap.Value = CreateWorkingBeatmap(new Beatmap());
Child = playback;
}

View File

@ -3,6 +3,7 @@
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Audio;
@ -10,6 +11,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Osu;
using osuTK.Graphics;
namespace osu.Game.Tests.Visual.Editor
@ -20,9 +22,9 @@ namespace osu.Game.Tests.Visual.Editor
private WorkingBeatmap waveformBeatmap;
[BackgroundDependencyLoader]
private void load()
private void load(AudioManager audio)
{
waveformBeatmap = new WaveformTestBeatmap();
waveformBeatmap = new WaveformTestBeatmap(audio);
}
[TestCase(1f)]
@ -91,7 +93,7 @@ namespace osu.Game.Tests.Visual.Editor
Child = graph = new TestWaveformGraph
{
RelativeSizeAxes = Axes.Both,
Waveform = new DummyWorkingBeatmap().Waveform,
Waveform = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo).Waveform,
},
};
});

View File

@ -1,4 +1,4 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// 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;
@ -16,7 +16,6 @@ using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osu.Game.Screens;
using osu.Game.Screens.Play;
using osu.Game.Tests.Beatmaps;
namespace osu.Game.Tests.Visual.Gameplay
{
@ -29,7 +28,7 @@ namespace osu.Game.Tests.Visual.Gameplay
public void Setup() => Schedule(() =>
{
InputManager.Child = stack = new OsuScreenStack { RelativeSizeAxes = Axes.Both };
Beatmap.Value = new TestWorkingBeatmap(new TestBeatmap(new OsuRuleset().RulesetInfo), Clock);
Beatmap.Value = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
});
[Test]

View File

@ -3,7 +3,6 @@
using System;
using osu.Framework.Lists;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
using osu.Game.Screens.Play;
@ -43,9 +42,9 @@ namespace osu.Game.Tests.Visual.Gameplay
});
}
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, IFrameBasedClock clock)
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap)
{
var working = base.CreateWorkingBeatmap(beatmap, clock);
var working = base.CreateWorkingBeatmap(beatmap);
workingWeakReferences.Add(working);
return working;
}

View File

@ -8,7 +8,6 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Multiplayer;
@ -57,7 +56,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
AddStep("set name", () => Room.Name.Value = "Room name");
AddAssert("button disabled", () => !settings.ApplyButton.Enabled.Value);
AddStep("set beatmap", () => Room.Playlist.Add(new PlaylistItem { Beatmap = new DummyWorkingBeatmap().BeatmapInfo }));
AddStep("set beatmap", () => Room.Playlist.Add(new PlaylistItem { Beatmap = CreateBeatmap(Ruleset.Value).BeatmapInfo }));
AddAssert("button enabled", () => settings.ApplyButton.Enabled.Value);
AddStep("clear name", () => Room.Name.Value = "");

View File

@ -0,0 +1,70 @@
// 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 NUnit.Framework;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
using osu.Game.Overlays.Changelog;
namespace osu.Game.Tests.Visual.Online
{
[TestFixture]
public class TestSceneChangelogOverlay : OsuTestScene
{
private ChangelogOverlay changelog;
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(UpdateStreamBadgeArea),
typeof(UpdateStreamBadge),
typeof(ChangelogHeader),
typeof(ChangelogContent),
typeof(ChangelogListing),
typeof(ChangelogSingleBuild),
typeof(ChangelogBuild),
};
protected override void LoadComplete()
{
base.LoadComplete();
Add(changelog = new ChangelogOverlay());
AddStep(@"Show", changelog.Show);
AddStep(@"Hide", changelog.Hide);
AddWaitStep("wait for hide", 3);
AddStep(@"Show with Lazer 2018.712.0", () =>
{
changelog.ShowBuild(new APIChangelogBuild
{
Version = "2018.712.0",
DisplayVersion = "2018.712.0",
UpdateStream = new APIUpdateStream { Name = "lazer" },
ChangelogEntries = new List<APIChangelogEntry>
{
new APIChangelogEntry
{
Category = "Test",
Title = "Title",
MessageHtml = "Message",
}
}
});
changelog.Show();
});
AddWaitStep("wait for show", 3);
AddStep(@"Hide", changelog.Hide);
AddWaitStep("wait for hide", 3);
AddStep(@"Show with listing", () =>
{
changelog.ShowListing();
changelog.Show();
});
}
}
}

View File

@ -8,7 +8,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Overlays.Direct;
using osu.Game.Rulesets.Osu;
using osu.Game.Tests.Beatmaps;
using osuTK;
namespace osu.Game.Tests.Visual.Online
@ -25,7 +24,7 @@ namespace osu.Game.Tests.Visual.Online
[BackgroundDependencyLoader]
private void load()
{
var beatmap = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo, null);
var beatmap = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
beatmap.BeatmapSetInfo.OnlineInfo.HasVideo = true;
beatmap.BeatmapSetInfo.OnlineInfo.HasStoryboard = true;

View File

@ -0,0 +1,55 @@
// 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.Game.Overlays.Profile.Sections;
using System;
using System.Collections.Generic;
using osu.Framework.Graphics;
namespace osu.Game.Tests.Visual.Online
{
public class TestSceneShowMoreButton : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(ShowMoreButton),
};
public TestSceneShowMoreButton()
{
ShowMoreButton button = null;
int fireCount = 0;
Add(button = new ShowMoreButton
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Action = () =>
{
fireCount++;
// ReSharper disable once AccessToModifiedClosure
// ReSharper disable once PossibleNullReferenceException
Scheduler.AddDelayed(() => button.IsLoading = false, 2000);
}
});
AddStep("click button", () => button.Click());
AddAssert("action fired once", () => fireCount == 1);
AddAssert("is in loading state", () => button.IsLoading);
AddStep("click button", () => button.Click());
AddAssert("action not fired", () => fireCount == 1);
AddAssert("is in loading state", () => button.IsLoading);
AddUntilStep("wait for loaded", () => !button.IsLoading);
AddStep("click button", () => button.Click());
AddAssert("action fired twice", () => fireCount == 2);
AddAssert("is in loading state", () => button.IsLoading);
}
}
}

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Screens.Select;
@ -18,7 +19,8 @@ namespace osu.Game.Tests.Visual.SongSelect
{
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(BeatmapDetails) };
public TestSceneBeatmapDetailArea()
[BackgroundDependencyLoader]
private void load(OsuGameBase game)
{
BeatmapDetailArea detailsArea;
Add(detailsArea = new BeatmapDetailArea
@ -28,7 +30,7 @@ namespace osu.Game.Tests.Visual.SongSelect
Size = new Vector2(550f, 450f),
});
AddStep("all metrics", () => detailsArea.Beatmap = new DummyWorkingBeatmap
AddStep("all metrics", () => detailsArea.Beatmap = new DummyWorkingBeatmap(null, null)
{
BeatmapInfo =
{
@ -56,7 +58,7 @@ namespace osu.Game.Tests.Visual.SongSelect
}
);
AddStep("all except source", () => detailsArea.Beatmap = new DummyWorkingBeatmap
AddStep("all except source", () => detailsArea.Beatmap = new DummyWorkingBeatmap(null, null)
{
BeatmapInfo =
{
@ -82,7 +84,7 @@ namespace osu.Game.Tests.Visual.SongSelect
}
});
AddStep("ratings", () => detailsArea.Beatmap = new DummyWorkingBeatmap
AddStep("ratings", () => detailsArea.Beatmap = new DummyWorkingBeatmap(null, null)
{
BeatmapInfo =
{
@ -107,7 +109,7 @@ namespace osu.Game.Tests.Visual.SongSelect
}
});
AddStep("fails+retries", () => detailsArea.Beatmap = new DummyWorkingBeatmap
AddStep("fails+retries", () => detailsArea.Beatmap = new DummyWorkingBeatmap(null, null)
{
BeatmapInfo =
{
@ -133,7 +135,7 @@ namespace osu.Game.Tests.Visual.SongSelect
}
});
AddStep("null metrics", () => detailsArea.Beatmap = new DummyWorkingBeatmap
AddStep("null metrics", () => detailsArea.Beatmap = new DummyWorkingBeatmap(null, null)
{
BeatmapInfo =
{

View File

@ -1,4 +1,4 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// 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;
@ -18,7 +18,6 @@ using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Taiko;
using osu.Game.Screens.Select;
using osu.Game.Tests.Beatmaps;
using osuTK;
namespace osu.Game.Tests.Visual.SongSelect
@ -136,7 +135,7 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep($"select {b?.Metadata.Title ?? "null"} beatmap", () =>
{
infoBefore = infoWedge.Info;
infoWedge.Beatmap = Beatmap.Value = b == null ? Beatmap.Default : new TestWorkingBeatmap(b);
infoWedge.Beatmap = Beatmap.Value = b == null ? Beatmap.Default : CreateWorkingBeatmap(b);
});
AddUntilStep("wait for async load", () => infoWedge.Info != infoBefore);

View File

@ -8,6 +8,7 @@ using System.Linq;
using System.Text;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.MathUtils;
@ -79,7 +80,7 @@ namespace osu.Game.Tests.Visual.SongSelect
}
[BackgroundDependencyLoader]
private void load(GameHost host)
private void load(GameHost host, AudioManager audio)
{
factory = new DatabaseContextFactory(LocalStorage);
factory.ResetDatabase();
@ -93,7 +94,7 @@ namespace osu.Game.Tests.Visual.SongSelect
usage.Migrate();
Dependencies.Cache(rulesets = new RulesetStore(factory));
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, factory, rulesets, null, null, host, defaultBeatmap = Beatmap.Default));
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, factory, rulesets, null, audio, host, defaultBeatmap = Beatmap.Default));
Beatmap.SetDefault();
}

View File

@ -41,7 +41,7 @@ namespace osu.Game.Tests.Visual.UserInterface
TestUpdateableBeatmapBackgroundSprite background = null;
AddStep("load null beatmap", () => Child = background = new TestUpdateableBeatmapBackgroundSprite { RelativeSizeAxes = Axes.Both });
AddUntilStep("wait for load", () => background.ContentLoaded);
AddUntilStep("content loaded", () => background.ContentLoaded);
}
[Test]

View File

@ -3,6 +3,7 @@
using System.IO;
using System.Linq;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Graphics.Textures;
using osu.Game.Beatmaps;
@ -19,12 +20,14 @@ namespace osu.Game.Tests
{
private readonly ZipArchiveReader reader;
private readonly Stream stream;
private readonly ITrackStore trackStore;
public WaveformTestBeatmap()
: base(new BeatmapInfo())
public WaveformTestBeatmap(AudioManager audioManager)
: base(new BeatmapInfo(), audioManager)
{
stream = TestResources.GetTestBeatmapStream();
reader = new ZipArchiveReader(stream);
trackStore = audioManager.GetTrackStore(reader);
}
public override void Dispose()
@ -32,17 +35,19 @@ namespace osu.Game.Tests
base.Dispose();
stream?.Dispose();
reader?.Dispose();
trackStore?.Dispose();
}
protected override IBeatmap GetBeatmap() => createTestBeatmap();
protected override Texture GetBackground() => null;
protected override Waveform GetWaveform() => new Waveform(getAudioStream());
protected override Waveform GetWaveform() => new Waveform(trackStore.GetStream(firstAudioFile));
protected override Track GetTrack() => new TrackBass(getAudioStream());
protected override Track GetTrack() => trackStore.Get(firstAudioFile);
private string firstAudioFile => reader.Filenames.First(f => f.EndsWith(".mp3"));
private Stream getAudioStream() => reader.GetStream(reader.Filenames.First(f => f.EndsWith(".mp3")));
private Stream getBeatmapStream() => reader.GetStream(reader.Filenames.First(f => f.EndsWith(".osu")));
private Beatmap createTestBeatmap()

View File

@ -20,19 +20,18 @@ namespace osu.Game.Audio
private readonly BindableDouble muteBindable = new BindableDouble();
private AudioManager audio;
private TrackManager trackManager;
private ITrackStore trackStore;
private TrackManagerPreviewTrack current;
[BackgroundDependencyLoader]
private void load(AudioManager audio, FrameworkConfigManager config)
{
trackManager = new TrackManager(new OnlineStore());
trackStore = audio.GetTrackStore(new OnlineStore());
this.audio = audio;
audio.AddItem(trackManager);
config.BindWith(FrameworkSetting.VolumeMusic, trackManager.Volume);
config.BindWith(FrameworkSetting.VolumeMusic, trackStore.Volume);
}
/// <summary>
@ -42,19 +41,19 @@ namespace osu.Game.Audio
/// <returns>The playable <see cref="PreviewTrack"/>.</returns>
public PreviewTrack Get(BeatmapSetInfo beatmapSetInfo)
{
var track = CreatePreviewTrack(beatmapSetInfo, trackManager);
var track = CreatePreviewTrack(beatmapSetInfo, trackStore);
track.Started += () =>
{
current?.Stop();
current = track;
audio.Track.AddAdjustment(AdjustableProperty.Volume, muteBindable);
audio.Tracks.AddAdjustment(AdjustableProperty.Volume, muteBindable);
};
track.Stopped += () =>
{
current = null;
audio.Track.RemoveAdjustment(AdjustableProperty.Volume, muteBindable);
audio.Tracks.RemoveAdjustment(AdjustableProperty.Volume, muteBindable);
};
return track;
@ -81,16 +80,16 @@ namespace osu.Game.Audio
/// <summary>
/// Creates the <see cref="TrackManagerPreviewTrack"/>.
/// </summary>
protected virtual TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, TrackManager trackManager) => new TrackManagerPreviewTrack(beatmapSetInfo, trackManager);
protected virtual TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackStore) => new TrackManagerPreviewTrack(beatmapSetInfo, trackStore);
protected class TrackManagerPreviewTrack : PreviewTrack
{
public IPreviewTrackOwner Owner { get; private set; }
private readonly BeatmapSetInfo beatmapSetInfo;
private readonly TrackManager trackManager;
private readonly ITrackStore trackManager;
public TrackManagerPreviewTrack(BeatmapSetInfo beatmapSetInfo, TrackManager trackManager)
public TrackManagerPreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackManager)
{
this.beatmapSetInfo = beatmapSetInfo;
this.trackManager = trackManager;

View File

@ -429,7 +429,7 @@ namespace osu.Game.Beatmaps
private readonly IBeatmap beatmap;
public DummyConversionBeatmap(IBeatmap beatmap)
: base(beatmap.BeatmapInfo)
: base(beatmap.BeatmapInfo, null)
{
this.beatmap = beatmap;
}

View File

@ -20,14 +20,12 @@ namespace osu.Game.Beatmaps
protected class BeatmapManagerWorkingBeatmap : WorkingBeatmap
{
private readonly IResourceStore<byte[]> store;
private readonly AudioManager audioManager;
public BeatmapManagerWorkingBeatmap(IResourceStore<byte[]> store, TextureStore textureStore, BeatmapInfo beatmapInfo, AudioManager audioManager)
: base(beatmapInfo)
: base(beatmapInfo, audioManager)
{
this.store = store;
this.textureStore = textureStore;
this.audioManager = audioManager;
}
protected override IBeatmap GetBeatmap()
@ -47,6 +45,8 @@ namespace osu.Game.Beatmaps
private TextureStore textureStore;
private ITrackStore trackStore;
protected override bool BackgroundStillValid(Texture b) => false; // bypass lazy logic. we want to return a new background each time for refcounting purposes.
protected override Texture GetBackground()
@ -68,8 +68,7 @@ namespace osu.Game.Beatmaps
{
try
{
var trackData = store.GetStream(getPathForFile(Metadata.AudioFile));
return trackData == null ? null : new TrackBass(trackData);
return (trackStore ?? (trackStore = AudioManager.GetTrackStore(store))).Get(getPathForFile(Metadata.AudioFile));
}
catch
{
@ -77,6 +76,14 @@ namespace osu.Game.Beatmaps
}
}
public override void RecycleTrack()
{
base.RecycleTrack();
trackStore?.Dispose();
trackStore = null;
}
public override void TransferTo(WorkingBeatmap other)
{
base.TransferTo(other);
@ -135,7 +142,7 @@ namespace osu.Game.Beatmaps
try
{
skin = new LegacyBeatmapSkin(BeatmapInfo, store, audioManager);
skin = new LegacyBeatmapSkin(BeatmapInfo, store, AudioManager);
}
catch (Exception e)
{

View File

@ -1,11 +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;
using System.Diagnostics;
using JetBrains.Annotations;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
namespace osu.Game.Beatmaps
@ -16,32 +12,15 @@ namespace osu.Game.Beatmaps
/// </summary>
public abstract class BindableBeatmap : NonNullableBindable<WorkingBeatmap>
{
private AudioManager audioManager;
private WorkingBeatmap lastBeatmap;
protected BindableBeatmap(WorkingBeatmap defaultValue)
: base(defaultValue)
{
BindValueChanged(b => updateAudioTrack(b.NewValue), true);
}
/// <summary>
/// Registers an <see cref="AudioManager"/> for <see cref="Track"/>s to be added to.
/// </summary>
/// <param name="audioManager">The <see cref="AudioManager"/> to register.</param>
protected void RegisterAudioManager([NotNull] AudioManager audioManager)
{
if (this.audioManager != null) throw new InvalidOperationException($"Cannot register multiple {nameof(AudioManager)}s.");
this.audioManager = audioManager;
ValueChanged += b => registerAudioTrack(b.NewValue);
// If the track has changed prior to this being called, let's register it
if (Value != Default)
registerAudioTrack(Value);
}
private void registerAudioTrack(WorkingBeatmap beatmap)
private void updateAudioTrack(WorkingBeatmap beatmap)
{
var trackLoaded = lastBeatmap?.TrackLoaded ?? false;
@ -55,18 +34,9 @@ namespace osu.Game.Beatmaps
lastBeatmap.RecycleTrack();
}
audioManager.Track.AddItem(beatmap.Track);
}
lastBeatmap = beatmap;
}
/// <summary>
/// Retrieve a new <see cref="BindableBeatmap"/> instance weakly bound to this <see cref="BindableBeatmap"/>.
/// If you are further binding to events of the retrieved <see cref="BindableBeatmap"/>, ensure a local reference is held.
/// </summary>
[NotNull]
public new abstract BindableBeatmap GetBoundCopy();
}
}

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -31,24 +32,8 @@ namespace osu.Game.Beatmaps.Drawables
/// </summary>
protected virtual double UnloadDelay => 10000;
private BeatmapInfo lastModel;
private bool firstLoad = true;
protected override DelayedLoadWrapper CreateDelayedLoadWrapper(Drawable content, double timeBeforeLoad)
{
return new DelayedLoadUnloadWrapper(() =>
{
// If DelayedLoadUnloadWrapper is attempting to RELOAD the same content (Beatmap), that means that it was
// previously UNLOADED and thus its children have been disposed of, so we need to recreate them here.
if (!firstLoad && lastModel == Beatmap.Value)
return CreateDrawable(Beatmap.Value);
// If the model has changed since the previous unload (or if there was no load), then we can safely use the given content
lastModel = Beatmap.Value;
firstLoad = false;
return content;
}, timeBeforeLoad, UnloadDelay);
}
protected override DelayedLoadWrapper CreateDelayedLoadWrapper(Func<Drawable> createContentFunc, double timeBeforeLoad)
=> new DelayedLoadUnloadWrapper(createContentFunc, timeBeforeLoad, UnloadDelay);
protected override Drawable CreateDrawable(BeatmapInfo model)
{

View File

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics.Textures;
@ -16,9 +17,9 @@ namespace osu.Game.Beatmaps
{
public class DummyWorkingBeatmap : WorkingBeatmap
{
private readonly OsuGameBase game;
private readonly TextureStore textures;
public DummyWorkingBeatmap(OsuGameBase game = null)
public DummyWorkingBeatmap(AudioManager audio, TextureStore textures)
: base(new BeatmapInfo
{
Metadata = new BeatmapMetadata
@ -34,16 +35,16 @@ namespace osu.Game.Beatmaps
OverallDifficulty = 0,
},
Ruleset = new DummyRulesetInfo()
})
}, audio)
{
this.game = game;
this.textures = textures;
}
protected override IBeatmap GetBeatmap() => new Beatmap();
protected override Texture GetBackground() => game?.Textures.Get(@"Backgrounds/bg4");
protected override Texture GetBackground() => textures?.Get(@"Backgrounds/bg4");
protected override Track GetTrack() => new TrackVirtual { Length = 1000 };
protected override Track GetTrack() => GetVirtualTrack();
private class DummyRulesetInfo : RulesetInfo
{

View File

@ -11,15 +11,17 @@ using osu.Framework.IO.File;
using System.IO;
using System.Linq;
using System.Threading;
using osu.Framework.Audio;
using osu.Game.IO.Serialization;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.UI;
using osu.Game.Skinning;
namespace osu.Game.Beatmaps
{
public abstract partial class WorkingBeatmap : IDisposable
public abstract class WorkingBeatmap : IDisposable
{
public readonly BeatmapInfo BeatmapInfo;
@ -27,8 +29,11 @@ namespace osu.Game.Beatmaps
public readonly BeatmapMetadata Metadata;
protected WorkingBeatmap(BeatmapInfo beatmapInfo)
protected AudioManager AudioManager { get; }
protected WorkingBeatmap(BeatmapInfo beatmapInfo, AudioManager audioManager)
{
AudioManager = audioManager;
BeatmapInfo = beatmapInfo;
BeatmapSetInfo = beatmapInfo.BeatmapSet;
Metadata = beatmapInfo.Metadata ?? BeatmapSetInfo?.Metadata ?? new BeatmapMetadata();
@ -46,13 +51,39 @@ namespace osu.Game.Beatmaps
return b;
});
track = new RecyclableLazy<Track>(() => GetTrack() ?? new VirtualBeatmapTrack(Beatmap));
track = new RecyclableLazy<Track>(() => GetTrack() ?? GetVirtualTrack());
background = new RecyclableLazy<Texture>(GetBackground, BackgroundStillValid);
waveform = new RecyclableLazy<Waveform>(GetWaveform);
storyboard = new RecyclableLazy<Storyboard>(GetStoryboard);
skin = new RecyclableLazy<Skin>(GetSkin);
}
protected virtual Track GetVirtualTrack()
{
const double excess_length = 1000;
var lastObject = Beatmap.HitObjects.LastOrDefault();
double length;
switch (lastObject)
{
case null:
length = excess_length;
break;
case IHasEndTime endTime:
length = endTime.EndTime + excess_length;
break;
default:
length = lastObject.StartTime + excess_length;
break;
}
return AudioManager.Tracks.GetVirtual(length);
}
/// <summary>
/// Saves the <see cref="Beatmaps.Beatmap"/>.
/// </summary>
@ -150,6 +181,7 @@ namespace osu.Game.Beatmaps
public bool SkinLoaded => skin.IsResultAvailable;
public Skin Skin => skin.Value;
protected virtual Skin GetSkin() => new DefaultSkin();
private readonly RecyclableLazy<Skin> skin;
@ -175,7 +207,7 @@ namespace osu.Game.Beatmaps
/// Eagerly dispose of the audio track associated with this <see cref="WorkingBeatmap"/> (if any).
/// Accessing track again will load a fresh instance.
/// </summary>
public void RecycleTrack() => track.Recycle();
public virtual void RecycleTrack() => track.Recycle();
public class RecyclableLazy<T>
{

View File

@ -1,41 +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.Linq;
using osu.Framework.Audio.Track;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types;
namespace osu.Game.Beatmaps
{
public partial class WorkingBeatmap
{
/// <summary>
/// A type of <see cref="TrackVirtual"/> which provides a valid length based on the <see cref="HitObject"/>s of an <see cref="IBeatmap"/>.
/// </summary>
protected class VirtualBeatmapTrack : TrackVirtual
{
private const double excess_length = 1000;
public VirtualBeatmapTrack(IBeatmap beatmap)
{
var lastObject = beatmap.HitObjects.LastOrDefault();
switch (lastObject)
{
case null:
Length = excess_length;
break;
case IHasEndTime endTime:
Length = endTime.EndTime + excess_length;
break;
default:
Length = lastObject.StartTime + excess_length;
break;
}
}
}
}
}

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Configuration;
using osu.Game.Rulesets;
@ -19,6 +20,8 @@ namespace osu.Game.Configuration
private readonly RulesetInfo ruleset;
private readonly bool legacySettingsExist;
protected DatabasedConfigManager(SettingsStore settings, RulesetInfo ruleset = null, int? variant = null)
{
this.settings = settings;
@ -26,6 +29,7 @@ namespace osu.Game.Configuration
this.variant = variant;
databasedSettings = settings.Query(ruleset?.ID, variant);
legacySettingsExist = databasedSettings.Any(s => int.TryParse(s.Key, out var _));
InitialiseDefaults();
}
@ -43,7 +47,18 @@ namespace osu.Game.Configuration
{
base.AddBindable(lookup, bindable);
var setting = databasedSettings.Find(s => (int)s.Key == (int)(object)lookup);
if (legacySettingsExist)
{
var legacySetting = databasedSettings.Find(s => s.Key == ((int)(object)lookup).ToString());
if (legacySetting != null)
{
bindable.Parse(legacySetting.Value);
settings.Delete(legacySetting);
}
}
var setting = databasedSettings.Find(s => s.Key == lookup.ToString());
if (setting != null)
{
@ -53,7 +68,7 @@ namespace osu.Game.Configuration
{
settings.Update(setting = new DatabasedSetting
{
Key = lookup,
Key = lookup.ToString(),
Value = bindable.Value,
RulesetID = ruleset?.ID,
Variant = variant,

View File

@ -1,4 +1,4 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// 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.ComponentModel.DataAnnotations.Schema;
@ -18,11 +18,7 @@ namespace osu.Game.Configuration
public int? SkinInfoID { get; set; }
[Column("Key")]
public int IntKey
{
get => (int)Key;
private set => Key = value;
}
public string Key { get; set; }
[Column("Value")]
public string StringValue
@ -31,10 +27,9 @@ namespace osu.Game.Configuration
set => Value = value;
}
public object Key;
public object Value;
public DatabasedSetting(object key, object value)
public DatabasedSetting(string key, object value)
{
Key = key;
Value = value;

View File

@ -37,5 +37,11 @@ namespace osu.Game.Configuration
SettingChanged?.Invoke();
}
public void Delete(DatabasedSetting setting)
{
using (var usage = ContextFactory.GetForWrite())
usage.Context.Remove(setting);
}
}
}

View File

@ -51,8 +51,8 @@ namespace osu.Game.Graphics.Containers
if (osuGame != null)
OverlayActivationMode.BindTo(osuGame.OverlayActivationMode);
samplePopIn = audio.Sample.Get(@"UI/overlay-pop-in");
samplePopOut = audio.Sample.Get(@"UI/overlay-pop-out");
samplePopIn = audio.Samples.Get(@"UI/overlay-pop-in");
samplePopOut = audio.Samples.Get(@"UI/overlay-pop-out");
StateChanged += onStateChanged;
}

View File

@ -24,7 +24,8 @@ namespace osu.Game.Graphics.Containers
{
Enabled.ValueChanged += e =>
{
if (!e.NewValue) unhover();
if (!e.NewValue)
unhover();
};
}
@ -49,7 +50,8 @@ namespace osu.Game.Graphics.Containers
private void unhover()
{
if (!isHovered) return;
if (!isHovered)
return;
isHovered = false;
EffectTargets.ForEach(d => d.FadeColour(IdleColour, FADE_DURATION, Easing.OutQuint));

View File

@ -40,8 +40,10 @@ namespace osu.Game.Graphics
// See https://github.com/ppy/osu-web/blob/master/resources/assets/less/colors.less
public readonly Color4 PurpleLighter = FromHex(@"eeeeff");
public readonly Color4 PurpleLight = FromHex(@"aa88ff");
public readonly Color4 PurpleLightAlternative = FromHex(@"cba4da");
public readonly Color4 Purple = FromHex(@"8866ee");
public readonly Color4 PurpleDark = FromHex(@"6644cc");
public readonly Color4 PurpleDarkAlternative = FromHex(@"312436");
public readonly Color4 PurpleDarker = FromHex(@"441188");
public readonly Color4 PinkLighter = FromHex(@"ffddee");

View File

@ -51,7 +51,7 @@ namespace osu.Game.Graphics
screenshotFormat = config.GetBindable<ScreenshotFormat>(OsuSetting.ScreenshotFormat);
captureMenuCursor = config.GetBindable<bool>(OsuSetting.ScreenshotCaptureMenuCursor);
shutter = audio.Sample.Get("UI/shutter");
shutter = audio.Samples.Get("UI/shutter");
}
public bool OnPressed(GlobalAction action)

View File

@ -31,7 +31,7 @@ namespace osu.Game.Graphics.UserInterface
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
sampleClick = audio.Sample.Get($@"UI/generic-select{SampleSet.GetDescription()}");
sampleClick = audio.Samples.Get($@"UI/generic-select{SampleSet.GetDescription()}");
}
}
}

View File

@ -37,7 +37,7 @@ namespace osu.Game.Graphics.UserInterface
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
sampleHover = audio.Sample.Get($@"UI/generic-hover{SampleSet.GetDescription()}");
sampleHover = audio.Samples.Get($@"UI/generic-hover{SampleSet.GetDescription()}");
}
}

View File

@ -17,11 +17,11 @@ namespace osu.Game.Graphics.UserInterface
/// <summary>
/// A button with added default sound effects.
/// </summary>
public class OsuButton : Button
public abstract class OsuButton : Button
{
private Box hover;
public OsuButton()
protected OsuButton()
{
Height = 40;

View File

@ -78,7 +78,7 @@ namespace osu.Game.Graphics.UserInterface
Current.DisabledChanged += disabled =>
{
Alpha = disabled ? 0.3f : 1;
labelSpriteText.Alpha = Nub.Alpha = disabled ? 0.3f : 1;
};
}
@ -112,8 +112,8 @@ namespace osu.Game.Graphics.UserInterface
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
sampleChecked = audio.Sample.Get(@"UI/check-on");
sampleUnchecked = audio.Sample.Get(@"UI/check-off");
sampleChecked = audio.Samples.Get(@"UI/check-on");
sampleUnchecked = audio.Samples.Get(@"UI/check-off");
}
}
}

View File

@ -71,8 +71,8 @@ namespace osu.Game.Graphics.UserInterface
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
sampleHover = audio.Sample.Get(@"UI/generic-hover");
sampleClick = audio.Sample.Get(@"UI/generic-select");
sampleHover = audio.Samples.Get(@"UI/generic-hover");
sampleClick = audio.Samples.Get(@"UI/generic-select");
BackgroundColour = Color4.Transparent;
BackgroundColourHover = OsuColour.FromHex(@"172023");

View File

@ -86,7 +86,7 @@ namespace osu.Game.Graphics.UserInterface
[BackgroundDependencyLoader]
private void load(AudioManager audio, OsuColour colours)
{
sample = audio.Sample.Get(@"UI/sliderbar-notch");
sample = audio.Samples.Get(@"UI/sliderbar-notch");
AccentColour = colours.Pink;
}

View File

@ -76,11 +76,11 @@ namespace osu.Game.Graphics.UserInterface
{
titleText = new OsuSpriteText
{
Font = OsuFont.GetFont(size: 25),
Font = OsuFont.GetFont(size: 30, weight: FontWeight.Light),
},
pageText = new OsuSpriteText
{
Font = OsuFont.GetFont(size: 25),
Font = OsuFont.GetFont(size: 30, weight: FontWeight.Light),
}
}
}

View File

@ -15,6 +15,8 @@ namespace osu.Game.IO.Archives
/// </summary>
public abstract Stream GetStream(string name);
public IEnumerable<string> GetAvailableResources() => Filenames;
public abstract void Dispose();
/// <summary>

View File

@ -16,7 +16,7 @@ namespace osu.Game.Migrations
{
ID = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Key = table.Column<int>(type: "INTEGER", nullable: false),
Key = table.Column<int>(type: "TEXT", nullable: false),
RulesetID = table.Column<int>(type: "INTEGER", nullable: true),
Value = table.Column<string>(type: "TEXT", nullable: true),
Variant = table.Column<int>(type: "INTEGER", nullable: true)

View File

@ -14,7 +14,7 @@ namespace osu.Game.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.1-servicing-10028");
.HasAnnotation("ProductVersion", "2.2.4-servicing-10062");
modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b =>
{
@ -198,7 +198,7 @@ namespace osu.Game.Migrations
b.Property<int>("ID")
.ValueGeneratedOnAdd();
b.Property<int>("IntKey")
b.Property<string>("Key")
.HasColumnName("Key");
b.Property<int?>("RulesetID");

View 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.Game.Online.API.Requests.Responses;
namespace osu.Game.Online.API.Requests
{
public class GetChangelogBuildRequest : APIRequest<APIChangelogBuild>
{
private readonly string name;
private readonly string version;
public GetChangelogBuildRequest(string streamName, string buildVersion)
{
name = streamName;
version = buildVersion;
}
protected override string Target => $@"changelog/{name}/{version}";
}
}

View File

@ -0,0 +1,12 @@
// 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.Game.Online.API.Requests.Responses;
namespace osu.Game.Online.API.Requests
{
public class GetChangelogRequest : APIRequest<APIChangelogIndex>
{
protected override string Target => @"changelog";
}
}

View File

@ -0,0 +1,49 @@
// 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 System;
using System.Collections.Generic;
namespace osu.Game.Online.API.Requests.Responses
{
public class APIChangelogBuild : IEquatable<APIChangelogBuild>
{
[JsonProperty("id")]
public long Id { get; set; }
[JsonProperty("version")]
public string Version { get; set; }
[JsonProperty("display_version")]
public string DisplayVersion { get; set; }
[JsonProperty("users")]
public long Users { get; set; }
[JsonProperty("created_at")]
public DateTimeOffset CreatedAt { get; set; }
[JsonProperty("update_stream")]
public APIUpdateStream UpdateStream { get; set; }
[JsonProperty("changelog_entries")]
public List<APIChangelogEntry> ChangelogEntries { get; set; }
[JsonProperty("versions")]
public VersionNatigation Versions { get; set; }
public class VersionNatigation
{
[JsonProperty("next")]
public APIChangelogBuild Next { get; set; }
[JsonProperty("previous")]
public APIChangelogBuild Previous { get; set; }
}
public bool Equals(APIChangelogBuild other) => Id == other?.Id;
public override string ToString() => $"{UpdateStream.DisplayName} {DisplayVersion}";
}
}

View File

@ -0,0 +1,47 @@
// 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 Newtonsoft.Json;
namespace osu.Game.Online.API.Requests.Responses
{
public class APIChangelogEntry
{
[JsonProperty("id")]
public long? Id { get; set; }
[JsonProperty("repository")]
public string Repository { get; set; }
[JsonProperty("github_pull_request_id")]
public long? GithubPullRequestId { get; set; }
[JsonProperty("github_url")]
public string GithubUrl { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("category")]
public string Category { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("message_html")]
public string MessageHtml { get; set; }
[JsonProperty("major")]
public bool? Major { get; set; }
[JsonProperty("created_at")]
public DateTimeOffset? CreatedAt { get; set; }
[JsonProperty("github_user")]
public APIChangelogUser GithubUser { get; set; }
}
}

View File

@ -0,0 +1,17 @@
// 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 Newtonsoft.Json;
namespace osu.Game.Online.API.Requests.Responses
{
public class APIChangelogIndex
{
[JsonProperty]
public List<APIChangelogBuild> Builds;
[JsonProperty]
public List<APIUpdateStream> Streams;
}
}

View File

@ -0,0 +1,28 @@
// 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;
namespace osu.Game.Online.API.Requests.Responses
{
public class APIChangelogUser
{
[JsonProperty("id")]
public long? Id { get; set; }
[JsonProperty("display_name")]
public string DisplayName { get; set; }
[JsonProperty("github_url")]
public string GithubUrl { get; set; }
[JsonProperty("osu_username")]
public string OsuUsername { get; set; }
[JsonProperty("user_id")]
public long? UserId { get; set; }
[JsonProperty("user_url")]
public string UserUrl { get; set; }
}
}

View File

@ -0,0 +1,60 @@
// 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 Newtonsoft.Json;
using osu.Framework.Graphics.Colour;
using osuTK.Graphics;
namespace osu.Game.Online.API.Requests.Responses
{
public class APIUpdateStream : IEquatable<APIUpdateStream>
{
[JsonProperty("id")]
public long Id { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("is_featured")]
public bool IsFeatured { get; set; }
[JsonProperty("display_name")]
public string DisplayName { get; set; }
[JsonProperty("latest_build")]
public APIChangelogBuild LatestBuild { get; set; }
public bool Equals(APIUpdateStream other) => Id == other?.Id;
public ColourInfo Colour
{
get
{
switch (Name)
{
case "stable40":
return new Color4(102, 204, 255, 255);
case "stable":
return new Color4(34, 153, 187, 255);
case "beta40":
return new Color4(255, 221, 85, 255);
case "cuttingedge":
return new Color4(238, 170, 0, 255);
case "lazer":
return new Color4(237, 18, 33, 255);
case "web":
return new Color4(136, 102, 238, 255);
default:
return new Color4(0, 0, 0, 255);
}
}
}
}
}

View File

@ -81,6 +81,9 @@ namespace osu.Game.Online.Chat
if (user == null)
throw new ArgumentNullException(nameof(user));
if (user.Id == api.LocalUser.Value.Id)
return;
CurrentChannel.Value = JoinedChannels.FirstOrDefault(c => c.Type == ChannelType.PM && c.Users.Count == 1 && c.Users.Any(u => u.Id == user.Id))
?? new Channel(user);
}

View File

@ -435,6 +435,7 @@ namespace osu.Game
loadComponentSingleFile(channelManager = new ChannelManager(), AddInternal, true);
loadComponentSingleFile(chatOverlay = new ChatOverlay(), overlayContent.Add, true);
loadComponentSingleFile(settings = new SettingsOverlay { GetToolbarHeight = () => ToolbarOffset }, leftFloatingOverlayContent.Add, true);
var changelogOverlay = loadComponentSingleFile(new ChangelogOverlay(), overlayContent.Add, true);
loadComponentSingleFile(userProfile = new UserProfileOverlay(), overlayContent.Add, true);
loadComponentSingleFile(beatmapSetOverlay = new BeatmapSetOverlay(), overlayContent.Add, true);
@ -492,7 +493,7 @@ namespace osu.Game
}
// ensure only one of these overlays are open at once.
var singleDisplayOverlays = new OverlayContainer[] { chatOverlay, social, direct };
var singleDisplayOverlays = new OverlayContainer[] { chatOverlay, social, direct, changelogOverlay };
overlays.AddRange(singleDisplayOverlays);
foreach (var overlay in singleDisplayOverlays)

View File

@ -161,7 +161,7 @@ namespace osu.Game
dependencies.CacheAs<IAPIProvider>(API);
var defaultBeatmap = new DummyWorkingBeatmap(this);
var defaultBeatmap = new DummyWorkingBeatmap(Audio, Textures);
dependencies.Cache(RulesetStore = new RulesetStore(contextFactory));
dependencies.Cache(FileStore = new FileStore(contextFactory, Host.Storage));
@ -193,9 +193,9 @@ namespace osu.Game
// tracks play so loud our samples can't keep up.
// this adds a global reduction of track volume for the time being.
Audio.Track.AddAdjustment(AdjustableProperty.Volume, new BindableDouble(0.8));
Audio.Tracks.AddAdjustment(AdjustableProperty.Volume, new BindableDouble(0.8));
beatmap = new OsuBindableBeatmap(defaultBeatmap, Audio);
beatmap = new OsuBindableBeatmap(defaultBeatmap);
dependencies.CacheAs<IBindable<WorkingBeatmap>>(beatmap);
dependencies.CacheAs(beatmap);
@ -281,23 +281,10 @@ namespace osu.Game
private class OsuBindableBeatmap : BindableBeatmap
{
public OsuBindableBeatmap(WorkingBeatmap defaultValue, AudioManager audioManager)
: this(defaultValue)
{
RegisterAudioManager(audioManager);
}
public OsuBindableBeatmap(WorkingBeatmap defaultValue)
: base(defaultValue)
{
}
public override BindableBeatmap GetBoundCopy()
{
var copy = new OsuBindableBeatmap(Default);
copy.BindTo(this);
return copy;
}
}
private class OsuUserInputManager : UserInputManager

View File

@ -0,0 +1,167 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Online.API.Requests.Responses;
using System;
using System.Linq;
using System.Text.RegularExpressions;
using osu.Game.Graphics.Sprites;
using osu.Game.Users;
using osuTK.Graphics;
namespace osu.Game.Overlays.Changelog
{
public class ChangelogBuild : FillFlowContainer
{
public const float HORIZONTAL_PADDING = 70;
public Action<APIChangelogBuild> SelectBuild;
protected readonly APIChangelogBuild Build;
public readonly FillFlowContainer ChangelogEntries;
public ChangelogBuild(APIChangelogBuild build)
{
Build = build;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Direction = FillDirection.Vertical;
Padding = new MarginPadding { Horizontal = HORIZONTAL_PADDING };
Children = new Drawable[]
{
CreateHeader(),
ChangelogEntries = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
},
};
foreach (var categoryEntries in build.ChangelogEntries.GroupBy(b => b.Category).OrderBy(c => c.Key))
{
ChangelogEntries.Add(new OsuSpriteText
{
Text = categoryEntries.Key,
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 24),
Margin = new MarginPadding { Top = 35, Bottom = 15 },
});
var fontLarge = OsuFont.GetFont(size: 18);
var fontMedium = OsuFont.GetFont(size: 14);
var fontSmall = OsuFont.GetFont(size: 12);
foreach (APIChangelogEntry entry in categoryEntries)
{
LinkFlowContainer title = new LinkFlowContainer
{
Direction = FillDirection.Full,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Margin = new MarginPadding { Vertical = 5 },
};
title.AddIcon(FontAwesome.Solid.Check, t =>
{
t.Font = fontSmall;
t.Padding = new MarginPadding { Left = -17, Right = 5 };
});
title.AddText(entry.Title, t => { t.Font = fontLarge; });
if (!string.IsNullOrEmpty(entry.Repository))
{
title.AddText(" (", t => t.Font = fontLarge);
title.AddLink($"{entry.Repository.Replace("ppy/", "")}#{entry.GithubPullRequestId}", entry.GithubUrl, Online.Chat.LinkAction.External,
creationParameters: t => { t.Font = fontLarge; });
title.AddText(")", t => t.Font = fontLarge);
}
title.AddText(" by ", t => t.Font = fontMedium);
if (entry.GithubUser.UserId != null)
title.AddUserLink(new User
{
Username = entry.GithubUser.OsuUsername,
Id = entry.GithubUser.UserId.Value
}, t => t.Font = fontMedium);
else if (entry.GithubUser.GithubUrl != null)
title.AddLink(entry.GithubUser.DisplayName, entry.GithubUser.GithubUrl, Online.Chat.LinkAction.External, null, null, t => t.Font = fontMedium);
else
title.AddText(entry.GithubUser.DisplayName, t => t.Font = fontSmall);
ChangelogEntries.Add(title);
if (!string.IsNullOrEmpty(entry.MessageHtml))
{
TextFlowContainer message = new TextFlowContainer
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
};
// todo: use markdown parsing once API returns markdown
message.AddText(Regex.Replace(entry.MessageHtml, @"<(.|\n)*?>", string.Empty), t =>
{
t.Font = fontSmall;
t.Colour = new Color4(235, 184, 254, 255);
});
ChangelogEntries.Add(message);
}
}
}
}
protected virtual FillFlowContainer CreateHeader() => new FillFlowContainer
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Margin = new MarginPadding { Top = 20 },
Children = new Drawable[]
{
new OsuHoverContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Action = () => SelectBuild?.Invoke(Build),
Child = new FillFlowContainer<SpriteText>
{
AutoSizeAxes = Axes.Both,
Margin = new MarginPadding { Horizontal = 40 },
Children = new[]
{
new OsuSpriteText
{
Text = Build.UpdateStream.DisplayName,
Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 19),
},
new OsuSpriteText
{
Text = " ",
Font = OsuFont.GetFont(weight: FontWeight.Medium, size: 19),
},
new OsuSpriteText
{
Text = Build.DisplayVersion,
Font = OsuFont.GetFont(weight: FontWeight.Light, size: 19),
Colour = Build.UpdateStream.Colour,
},
}
}
},
}
};
}
}

View File

@ -0,0 +1,25 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Online.API.Requests.Responses;
using System;
namespace osu.Game.Overlays.Changelog
{
public class ChangelogContent : FillFlowContainer
{
public Action<APIChangelogBuild> BuildSelected;
public void SelectBuild(APIChangelogBuild build) => BuildSelected?.Invoke(build);
public ChangelogContent()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Direction = FillDirection.Vertical;
Padding = new MarginPadding { Bottom = 100 };
}
}
}

View File

@ -0,0 +1,170 @@
// 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.Linq;
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.Textures;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API.Requests.Responses;
using osuTK;
namespace osu.Game.Overlays.Changelog
{
public class ChangelogHeader : OverlayHeader
{
public readonly Bindable<APIChangelogBuild> Current = new Bindable<APIChangelogBuild>();
public Action ListingSelected;
public UpdateStreamBadgeArea Streams;
private const string listing_string = "Listing";
public ChangelogHeader()
{
TabControl.AddItem(listing_string);
TabControl.Current.ValueChanged += e =>
{
if (e.NewValue == listing_string)
ListingSelected?.Invoke();
};
Current.ValueChanged += showBuild;
Streams.Current.ValueChanged += e =>
{
if (e.NewValue?.LatestBuild != null && e.NewValue != Current.Value?.UpdateStream)
Current.Value = e.NewValue.LatestBuild;
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
TabControl.AccentColour = colours.Violet;
}
private ChangelogHeaderTitle title;
private void showBuild(ValueChangedEvent<APIChangelogBuild> e)
{
if (e.OldValue != null)
TabControl.RemoveItem(e.OldValue.ToString());
if (e.NewValue != null)
{
TabControl.AddItem(e.NewValue.ToString());
TabControl.Current.Value = e.NewValue.ToString();
Streams.Current.Value = Streams.Items.FirstOrDefault(s => s.Name == e.NewValue.UpdateStream.Name);
title.Version = e.NewValue.UpdateStream.DisplayName;
}
else
{
TabControl.Current.Value = listing_string;
Streams.Current.Value = null;
title.Version = null;
}
}
protected override Drawable CreateBackground() => new HeaderBackground();
protected override Drawable CreateContent() => new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
Streams = new UpdateStreamBadgeArea(),
}
};
protected override ScreenTitle CreateTitle() => title = new ChangelogHeaderTitle();
public class HeaderBackground : Sprite
{
public HeaderBackground()
{
RelativeSizeAxes = Axes.Both;
FillMode = FillMode.Fill;
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
Texture = textures.Get(@"Headers/changelog");
}
}
private class ChangelogHeaderTitle : ScreenTitle
{
public string Version
{
set => Section = value ?? listing_string;
}
public ChangelogHeaderTitle()
{
Title = "Changelog";
Version = null;
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
AccentColour = colours.Violet;
}
protected override Drawable CreateIcon() => new ChangelogIcon();
internal class ChangelogIcon : CompositeDrawable
{
private const float circle_allowance = 0.8f;
[BackgroundDependencyLoader]
private void load(TextureStore textures, OsuColour colours)
{
Size = new Vector2(ICON_SIZE / circle_allowance);
InternalChildren = new Drawable[]
{
new CircularContainer
{
Masking = true,
BorderColour = colours.Violet,
BorderThickness = 3,
MaskingSmoothness = 1,
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new Sprite
{
RelativeSizeAxes = Axes.Both,
Texture = textures.Get(@"Icons/changelog"),
Size = new Vector2(circle_allowance),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colours.Violet,
Alpha = 0,
AlwaysPresent = true,
},
}
},
};
}
}
}
}
}

View File

@ -0,0 +1,80 @@
// 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.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses;
using osuTK.Graphics;
namespace osu.Game.Overlays.Changelog
{
public class ChangelogListing : ChangelogContent
{
private readonly List<APIChangelogBuild> entries;
public ChangelogListing(List<APIChangelogBuild> entries)
{
this.entries = entries;
}
[BackgroundDependencyLoader]
private void load()
{
DateTime currentDate = DateTime.MinValue;
if (entries == null) return;
foreach (APIChangelogBuild build in entries)
{
if (build.CreatedAt.Date != currentDate)
{
if (Children.Count != 0)
{
Add(new Box
{
RelativeSizeAxes = Axes.X,
Height = 2,
Colour = new Color4(17, 17, 17, 255),
Margin = new MarginPadding { Top = 30 },
});
}
Add(new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Margin = new MarginPadding { Top = 15 },
Text = build.CreatedAt.Date.ToString("dd MMM yyyy"),
Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 24),
Colour = OsuColour.FromHex(@"FD5"),
});
currentDate = build.CreatedAt.Date;
}
else
{
Add(new Container
{
RelativeSizeAxes = Axes.X,
Height = 1,
Padding = new MarginPadding { Horizontal = ChangelogBuild.HORIZONTAL_PADDING },
Margin = new MarginPadding { Top = 30 },
Child = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = new Color4(32, 24, 35, 255),
}
});
}
Add(new ChangelogBuild(build) { SelectBuild = SelectBuild });
}
}
}
}

View File

@ -0,0 +1,142 @@
// 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.Linq;
using System.Threading;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osuTK;
namespace osu.Game.Overlays.Changelog
{
public class ChangelogSingleBuild : ChangelogContent
{
private APIChangelogBuild build;
public ChangelogSingleBuild(APIChangelogBuild build)
{
this.build = build;
}
[BackgroundDependencyLoader]
private void load(CancellationToken? cancellation, IAPIProvider api)
{
bool complete = false;
var req = new GetChangelogBuildRequest(build.UpdateStream.Name, build.Version);
req.Success += res =>
{
build = res;
complete = true;
};
req.Failure += _ => complete = true;
// This is done on a separate thread to support cancellation below
Task.Run(() => req.Perform(api));
while (!complete)
{
if (cancellation?.IsCancellationRequested == true)
{
req.Cancel();
return;
}
Thread.Sleep(10);
}
if (build != null)
Child = new ChangelogBuildWithNavigation(build) { SelectBuild = SelectBuild };
}
public class ChangelogBuildWithNavigation : ChangelogBuild
{
public ChangelogBuildWithNavigation(APIChangelogBuild build)
: base(build)
{
}
protected override FillFlowContainer CreateHeader()
{
var fill = base.CreateHeader();
foreach (var existing in fill.Children.OfType<OsuHoverContainer>())
{
existing.Scale = new Vector2(1.25f);
existing.Action = null;
existing.Add(new OsuSpriteText
{
Text = Build.CreatedAt.Date.ToString("dd MMM yyyy"),
Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 14),
Colour = OsuColour.FromHex(@"FD5"),
Anchor = Anchor.BottomCentre,
Origin = Anchor.TopCentre,
Margin = new MarginPadding { Top = 5 },
});
}
NavigationIconButton left, right;
fill.AddRange(new[]
{
left = new NavigationIconButton(Build.Versions?.Previous)
{
Icon = FontAwesome.Solid.ChevronLeft,
SelectBuild = b => SelectBuild(b)
},
right = new NavigationIconButton(Build.Versions?.Next)
{
Icon = FontAwesome.Solid.ChevronRight,
SelectBuild = b => SelectBuild(b)
},
});
fill.SetLayoutPosition(left, -1);
fill.SetLayoutPosition(right, 1);
return fill;
}
}
private class NavigationIconButton : IconButton
{
public Action<APIChangelogBuild> SelectBuild;
public NavigationIconButton(APIChangelogBuild build)
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
if (build == null) return;
TooltipText = build.DisplayVersion;
Action = () =>
{
SelectBuild?.Invoke(build);
Enabled.Value = false;
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
HoverColour = colours.GreyVioletLight.Opacity(0.6f);
FlashColour = colours.GreyVioletLighter;
}
}
}
}

View File

@ -0,0 +1,157 @@
// 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 Humanizer;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Online.API.Requests.Responses;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Overlays.Changelog
{
public class UpdateStreamBadge : TabItem<APIUpdateStream>
{
private const float badge_height = 66.5f;
private const float badge_width = 100;
private const float transition_duration = 100;
private readonly ExpandingBar expandingBar;
private SampleChannel sampleClick;
private SampleChannel sampleHover;
private readonly FillFlowContainer<SpriteText> text;
public readonly Bindable<APIUpdateStream> SelectedTab = new Bindable<APIUpdateStream>();
private readonly Container fadeContainer;
public UpdateStreamBadge(APIUpdateStream stream)
: base(stream)
{
Size = new Vector2(stream.IsFeatured ? badge_width * 2 : badge_width, badge_height);
Padding = new MarginPadding(5);
Child = fadeContainer = new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
text = new FillFlowContainer<SpriteText>
{
AutoSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new[]
{
new OsuSpriteText
{
Text = stream.DisplayName,
Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 12),
Margin = new MarginPadding { Top = 6 },
},
new OsuSpriteText
{
Text = stream.LatestBuild.DisplayVersion,
Font = OsuFont.GetFont(weight: FontWeight.Light, size: 16),
},
new OsuSpriteText
{
Text = stream.LatestBuild.Users > 0 ? $"{stream.LatestBuild.Users:N0} {"user".Pluralize(stream.LatestBuild.Users == 1)} online" : null,
Font = OsuFont.GetFont(weight: FontWeight.Regular, size: 10),
Colour = new Color4(203, 164, 218, 255),
},
}
},
expandingBar = new ExpandingBar
{
Anchor = Anchor.TopCentre,
Colour = stream.Colour,
ExpandedSize = 4,
CollapsedSize = 2,
IsCollapsed = true
},
}
};
SelectedTab.BindValueChanged(_ => updateState(), true);
}
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
sampleClick = audio.Samples.Get(@"UI/generic-select-soft");
sampleHover = audio.Samples.Get(@"UI/generic-hover-soft");
}
protected override void OnActivated() => updateState();
protected override void OnDeactivated() => updateState();
protected override bool OnClick(ClickEvent e)
{
sampleClick?.Play();
return base.OnClick(e);
}
protected override bool OnHover(HoverEvent e)
{
sampleHover?.Play();
updateState();
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
updateState();
base.OnHoverLost(e);
}
private void updateState()
{
// Expand based on the local state
bool shouldExpand = Active.Value || IsHovered;
// Expand based on whether no build is selected and the badge area is hovered
shouldExpand |= SelectedTab.Value == null && !externalDimRequested;
if (shouldExpand)
{
expandingBar.Expand();
fadeContainer.FadeTo(1, transition_duration);
}
else
{
expandingBar.Collapse();
fadeContainer.FadeTo(0.5f, transition_duration);
}
text.FadeTo(externalDimRequested && !IsHovered ? 0.5f : 1, transition_duration);
}
private bool externalDimRequested;
public void EnableDim()
{
externalDimRequested = true;
updateState();
}
public void DisableDim()
{
externalDimRequested = false;
updateState();
}
}
}

View File

@ -0,0 +1,75 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osu.Game.Online.API.Requests.Responses;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osuTK.Graphics;
namespace osu.Game.Overlays.Changelog
{
public class UpdateStreamBadgeArea : TabControl<APIUpdateStream>
{
public UpdateStreamBadgeArea()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
AddInternal(new Box
{
Colour = Color4.Black,
Alpha = 0.12f,
RelativeSizeAxes = Axes.Both,
});
}
public void Populate(List<APIUpdateStream> streams)
{
Current.Value = null;
foreach (APIUpdateStream updateStream in streams)
AddItem(updateStream);
}
protected override bool OnHover(HoverEvent e)
{
foreach (UpdateStreamBadge streamBadge in TabContainer.Children.OfType<UpdateStreamBadge>())
streamBadge.EnableDim();
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
foreach (UpdateStreamBadge streamBadge in TabContainer.Children.OfType<UpdateStreamBadge>())
streamBadge.DisableDim();
base.OnHoverLost(e);
}
protected override TabFillFlowContainer CreateTabFlow()
{
var flow = base.CreateTabFlow();
flow.RelativeSizeAxes = Axes.X;
flow.AutoSizeAxes = Axes.Y;
flow.AllowMultiline = true;
flow.Padding = new MarginPadding
{
Vertical = 20,
Horizontal = 85,
};
return flow;
}
protected override Dropdown<APIUpdateStream> CreateDropdown() => null;
protected override TabItem<APIUpdateStream> CreateTabItem(APIUpdateStream value) =>
new UpdateStreamBadge(value) { SelectedTab = { BindTarget = Current } };
}
}

View File

@ -0,0 +1,210 @@
// 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.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Input.Bindings;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.Changelog;
namespace osu.Game.Overlays
{
public class ChangelogOverlay : FullscreenOverlay
{
public readonly Bindable<APIChangelogBuild> Current = new Bindable<APIChangelogBuild>();
private ChangelogHeader header;
private Container<ChangelogContent> content;
private SampleChannel sampleBack;
private List<APIChangelogBuild> builds;
private List<APIUpdateStream> streams;
[BackgroundDependencyLoader]
private void load(AudioManager audio, OsuColour colour)
{
Waves.FirstWaveColour = colour.GreyVioletLight;
Waves.SecondWaveColour = colour.GreyViolet;
Waves.ThirdWaveColour = colour.GreyVioletDark;
Waves.FourthWaveColour = colour.GreyVioletDarker;
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colour.PurpleDarkAlternative,
},
new ScrollContainer
{
RelativeSizeAxes = Axes.Both,
ScrollbarVisible = false,
Child = new ReverseChildIDFillFlowContainer<Drawable>
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
header = new ChangelogHeader
{
ListingSelected = ShowListing,
},
content = new Container<ChangelogContent>
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
}
},
},
},
};
sampleBack = audio.Samples.Get(@"UI/generic-select-soft");
header.Current.BindTo(Current);
Current.BindValueChanged(e =>
{
if (e.NewValue != null)
loadContent(new ChangelogSingleBuild(e.NewValue));
else
loadContent(new ChangelogListing(builds));
});
}
public void ShowListing()
{
Current.Value = null;
State = Visibility.Visible;
}
/// <summary>
/// Fetches and shows a specific build from a specific update stream.
/// </summary>
/// <param name="build">Must contain at least <see cref="APIUpdateStream.Name"/> and
/// <see cref="APIChangelogBuild.Version"/>. If <see cref="APIUpdateStream.DisplayName"/> and
/// <see cref="APIChangelogBuild.DisplayVersion"/> are specified, the header will instantly display them.</param>
public void ShowBuild([NotNull] APIChangelogBuild build)
{
if (build == null) throw new ArgumentNullException(nameof(build));
Current.Value = build;
State = Visibility.Visible;
}
public void ShowBuild([NotNull] string updateStream, [NotNull] string version)
{
if (updateStream == null) throw new ArgumentNullException(nameof(updateStream));
if (version == null) throw new ArgumentNullException(nameof(version));
performAfterFetch(() =>
{
var build = builds.Find(b => b.Version == version && b.UpdateStream.Name == updateStream)
?? streams.Find(s => s.Name == updateStream)?.LatestBuild;
if (build != null)
ShowBuild(build);
});
State = Visibility.Visible;
}
public override bool OnPressed(GlobalAction action)
{
switch (action)
{
case GlobalAction.Back:
if (Current.Value == null)
{
State = Visibility.Hidden;
}
else
{
Current.Value = null;
sampleBack?.Play();
}
return true;
}
return false;
}
protected override void PopIn()
{
base.PopIn();
if (initialFetchTask == null)
// fetch and refresh to show listing, if no other request was made via Show methods
performAfterFetch(() => Current.TriggerChange());
}
private Task initialFetchTask;
private void performAfterFetch(Action action) => fetchListing()?.ContinueWith(_ => Schedule(action));
private Task fetchListing()
{
if (initialFetchTask != null)
return initialFetchTask;
return initialFetchTask = Task.Run(async () =>
{
var tcs = new TaskCompletionSource<bool>();
var req = new GetChangelogRequest();
req.Success += res =>
{
// remap streams to builds to ensure model equality
res.Builds.ForEach(b => b.UpdateStream = res.Streams.Find(s => s.Id == b.UpdateStream.Id));
res.Streams.ForEach(s => s.LatestBuild.UpdateStream = res.Streams.Find(s2 => s2.Id == s.LatestBuild.UpdateStream.Id));
builds = res.Builds;
streams = res.Streams;
header.Streams.Populate(res.Streams);
tcs.SetResult(true);
};
req.Failure += _ => initialFetchTask = null;
req.Perform(API);
await tcs.Task;
});
}
private CancellationTokenSource loadContentCancellation;
private void loadContent(ChangelogContent newContent)
{
content.FadeTo(0.2f, 300, Easing.OutQuint);
loadContentCancellation?.Cancel();
LoadComponentAsync(newContent, c =>
{
content.FadeIn(300, Easing.OutQuint);
c.BuildSelected = ShowBuild;
content.Child = c;
}, (loadContentCancellation = new CancellationTokenSource()).Token);
}
}
}

View File

@ -3,6 +3,7 @@
using System;
using System.Linq;
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
@ -14,6 +15,7 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Online.Chat;
using osu.Game.Users;
using osuTK;
@ -201,6 +203,9 @@ namespace osu.Game.Overlays.Chat
private Action startChatAction;
[Resolved]
private IAPIProvider api { get; set; }
public MessageSender(User sender)
{
this.sender = sender;
@ -213,11 +218,21 @@ namespace osu.Game.Overlays.Chat
startChatAction = () => chatManager?.OpenPrivateChannel(sender);
}
public MenuItem[] ContextMenuItems => new MenuItem[]
public MenuItem[] ContextMenuItems
{
new OsuMenuItem("View Profile", MenuItemType.Highlighted, Action),
new OsuMenuItem("Start Chat", MenuItemType.Standard, startChatAction),
};
get
{
List<MenuItem> items = new List<MenuItem>
{
new OsuMenuItem("View Profile", MenuItemType.Highlighted, Action)
};
if (sender.Id != api.LocalUser.Value.Id)
items.Add(new OsuMenuItem("Start Chat", MenuItemType.Standard, startChatAction));
return items.ToArray();
}
}
}
private static readonly Color4[] username_colours =

View File

@ -3,22 +3,14 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Input.Bindings;
using osu.Game.Overlays.KeyBinding;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets;
using osu.Game.Screens.Ranking;
using osuTK;
namespace osu.Game.Overlays
{
public class KeyBindingPanel : SettingsPanel
public class KeyBindingPanel : SettingsSubPanel
{
protected override Drawable CreateHeader() => new SettingsHeader("key configuration", "Customise your keys!");
@ -29,84 +21,6 @@ namespace osu.Game.Overlays
foreach (var ruleset in rulesets.AvailableRulesets)
AddSection(new RulesetBindingsSection(ruleset));
AddInternal(new BackButton
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Action = Hide
});
}
public KeyBindingPanel()
: base(true)
{
}
private class BackButton : OsuClickableContainer, IKeyBindingHandler<GlobalAction>
{
private AspectContainer aspect;
[BackgroundDependencyLoader]
private void load()
{
Size = new Vector2(Sidebar.DEFAULT_WIDTH);
Children = new Drawable[]
{
aspect = new AspectContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Y,
Children = new Drawable[]
{
new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Y = -15,
Size = new Vector2(15),
Shadow = true,
Icon = FontAwesome.Solid.ChevronLeft
},
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Y = 15,
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
Text = @"back",
},
}
}
};
}
protected override bool OnMouseDown(MouseDownEvent e)
{
aspect.ScaleTo(0.75f, 2000, Easing.OutQuint);
return base.OnMouseDown(e);
}
protected override bool OnMouseUp(MouseUpEvent e)
{
aspect.ScaleTo(1, 1000, Easing.OutElastic);
return base.OnMouseUp(e);
}
public bool OnPressed(GlobalAction action)
{
switch (action)
{
case GlobalAction.Back:
Click();
return true;
}
return false;
}
public bool OnReleased(GlobalAction action) => false;
}
}
}

View File

@ -145,7 +145,7 @@ namespace osu.Game.Overlays
[BackgroundDependencyLoader]
private void load(OsuColour colours, TextureStore textures, AudioManager audio)
{
getSample = audio.Sample.Get(@"MedalSplash/medal-get");
getSample = audio.Samples.Get(@"MedalSplash/medal-get");
innerSpin.Texture = outerSpin.Texture = textures.Get(@"MedalSplash/disc-spin");
disc.EdgeEffect = leftStrip.EdgeEffect = rightStrip.EdgeEffect = new EdgeEffectParameters

View File

@ -56,8 +56,8 @@ namespace osu.Game.Overlays.Mods
Ruleset.BindTo(ruleset);
if (mods != null) SelectedMods.BindTo(mods);
sampleOn = audio.Sample.Get(@"UI/check-on");
sampleOff = audio.Sample.Get(@"UI/check-off");
sampleOn = audio.Samples.Get(@"UI/check-on");
sampleOff = audio.Samples.Get(@"UI/check-off");
}
protected override void LoadComplete()

View File

@ -350,7 +350,7 @@ namespace osu.Game.Overlays
direction = last > next ? TransformDirection.Prev : TransformDirection.Next;
}
current.Track.Completed -= currentTrackCompleted;
//current.Track.Completed -= currentTrackCompleted;
}
current = beatmap.NewValue;

View File

@ -29,13 +29,11 @@ namespace osu.Game.Overlays.Profile.Sections.Beatmaps
protected override void ShowMore()
{
base.ShowMore();
request = new GetUserBeatmapsRequest(User.Value.Id, type, VisiblePages++ * ItemsPerPage);
request.Success += sets => Schedule(() =>
{
ShowMoreButton.FadeTo(sets.Count == ItemsPerPage ? 1 : 0);
ShowMoreLoading.Hide();
MoreButton.FadeTo(sets.Count == ItemsPerPage ? 1 : 0);
MoreButton.IsLoading = false;
if (!sets.Any() && VisiblePages == 1)
{

View File

@ -24,13 +24,11 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
protected override void ShowMore()
{
base.ShowMore();
request = new GetUserMostPlayedBeatmapsRequest(User.Value.Id, VisiblePages++ * ItemsPerPage);
request.Success += beatmaps => Schedule(() =>
{
ShowMoreButton.FadeTo(beatmaps.Count == ItemsPerPage ? 1 : 0);
ShowMoreLoading.Hide();
MoreButton.FadeTo(beatmaps.Count == ItemsPerPage ? 1 : 0);
MoreButton.IsLoading = false;
if (!beatmaps.Any() && VisiblePages == 1)
{

View File

@ -3,17 +3,15 @@
using osu.Framework.Bindables;
using osuTK;
using osuTK.Graphics;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Users;
using osu.Framework.Allocation;
namespace osu.Game.Overlays.Profile.Sections.Kudosu
{
@ -24,46 +22,27 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu
public KudosuInfo(Bindable<User> user)
{
this.user.BindTo(user);
CountSection total;
CountSection avaliable;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Masking = true;
CornerRadius = 3;
EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Shadow,
Offset = new Vector2(0f, 1f),
Radius = 3f,
Colour = Color4.Black.Opacity(0.2f),
};
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(0.2f)
},
new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5, 0),
Children = new[]
{
total = new CountSection(
"Total Kudosu Earned",
"Based on how much of a contribution the user has made to beatmap moderation. See this link for more information."
),
avaliable = new CountSection(
"Kudosu Avaliable",
"Kudosu can be traded for kudosu stars, which will help your beatmap get more attention. This is the number of kudosu you haven't traded in yet."
),
total = new CountTotal(),
avaliable = new CountAvailable()
}
}
};
this.user.ValueChanged += u =>
{
total.Count = u.NewValue?.Kudosu.Total ?? 0;
@ -73,21 +52,43 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu
protected override bool OnClick(ClickEvent e) => true;
private class CountAvailable : CountSection
{
public CountAvailable()
: base("Kudosu Avaliable")
{
DescriptionText.Text = "Kudosu can be traded for kudosu stars, which will help your beatmap get more attention. This is the number of kudosu you haven't traded in yet.";
}
}
private class CountTotal : CountSection
{
public CountTotal()
: base("Total Kudosu Earned")
{
DescriptionText.AddText("Based on how much of a contribution the user has made to beatmap moderation. See ");
DescriptionText.AddLink("this link", "https://osu.ppy.sh/wiki/Kudosu");
DescriptionText.AddText(" for more information.");
}
}
private class CountSection : Container
{
private readonly OsuSpriteText valueText;
protected readonly LinkFlowContainer DescriptionText;
private readonly Box lineBackground;
public new int Count
{
set => valueText.Text = value.ToString();
}
public CountSection(string header, string description)
public CountSection(string header)
{
RelativeSizeAxes = Axes.X;
Width = 0.5f;
AutoSizeAxes = Axes.Y;
Padding = new MarginPadding { Horizontal = 10, Top = 10, Bottom = 20 };
Padding = new MarginPadding { Top = 10, Bottom = 20 };
Child = new FillFlowContainer
{
AutoSizeAxes = Axes.Y,
@ -96,39 +97,42 @@ namespace osu.Game.Overlays.Profile.Sections.Kudosu
Spacing = new Vector2(0, 5),
Children = new Drawable[]
{
new FillFlowContainer
new CircularContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5, 0),
Children = new Drawable[]
Masking = true,
RelativeSizeAxes = Axes.X,
Height = 5,
Child = lineBackground = new Box
{
new OsuSpriteText
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Text = header + ":",
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Regular, italics: true)
},
valueText = new OsuSpriteText
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Text = "0",
Font = OsuFont.GetFont(size: 40, weight: FontWeight.Regular, italics: true),
UseFullGlyphHeight = false,
}
RelativeSizeAxes = Axes.Both,
}
},
new OsuTextFlowContainer(t => t.Font = t.Font.With(size: 19))
new OsuSpriteText
{
Text = header,
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold)
},
valueText = new OsuSpriteText
{
Text = "0",
Font = OsuFont.GetFont(size: 40, weight: FontWeight.Light),
UseFullGlyphHeight = false,
},
DescriptionText = new LinkFlowContainer(t => t.Font = t.Font.With(size: 14))
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Text = description
}
}
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
lineBackground.Colour = colours.Yellow;
DescriptionText.Colour = colours.GreySeafoamLighter;
}
}
}
}

View File

@ -7,20 +7,17 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Rulesets;
using osu.Game.Users;
namespace osu.Game.Overlays.Profile.Sections
{
public class PaginatedContainer : FillFlowContainer
public abstract class PaginatedContainer : FillFlowContainer
{
protected readonly FillFlowContainer ItemsContainer;
protected readonly OsuHoverContainer ShowMoreButton;
protected readonly LoadingAnimation ShowMoreLoading;
protected readonly ShowMoreButton MoreButton;
protected readonly OsuSpriteText MissingText;
protected int VisiblePages;
@ -32,7 +29,7 @@ namespace osu.Game.Overlays.Profile.Sections
protected APIRequest RetrievalRequest;
protected RulesetStore Rulesets;
public PaginatedContainer(Bindable<User> user, string header, string missing)
protected PaginatedContainer(Bindable<User> user, string header, string missing)
{
User.BindTo(user);
@ -45,38 +42,27 @@ namespace osu.Game.Overlays.Profile.Sections
new OsuSpriteText
{
Text = header,
Font = OsuFont.GetFont(size: 15, weight: FontWeight.Regular, italics: true),
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Bold),
Margin = new MarginPadding { Top = 10, Bottom = 10 },
},
ItemsContainer = new FillFlowContainer
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Margin = new MarginPadding { Bottom = 10 }
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 2),
},
ShowMoreButton = new OsuHoverContainer
MoreButton = new ShowMoreButton
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Alpha = 0,
Margin = new MarginPadding { Top = 10 },
Action = ShowMore,
AutoSizeAxes = Axes.Both,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Child = new OsuSpriteText
{
Font = OsuFont.GetFont(size: 14),
Text = "show more",
Padding = new MarginPadding { Vertical = 10, Horizontal = 15 },
}
},
ShowMoreLoading = new LoadingAnimation
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Size = new Vector2(14),
},
MissingText = new OsuSpriteText
{
Font = OsuFont.GetFont(size: 14),
Font = OsuFont.GetFont(size: 15),
Text = missing,
Alpha = 0,
},
@ -97,16 +83,11 @@ namespace osu.Game.Overlays.Profile.Sections
{
VisiblePages = 0;
ItemsContainer.Clear();
ShowMoreButton.Hide();
if (e.NewValue != null)
ShowMore();
}
protected virtual void ShowMore()
{
ShowMoreLoading.Show();
ShowMoreButton.Hide();
}
protected abstract void ShowMore();
}
}

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Online.API.Requests;
using osu.Game.Users;
@ -9,6 +8,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
namespace osu.Game.Overlays.Profile.Sections.Ranks
{
@ -31,8 +31,6 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
protected override void ShowMore()
{
base.ShowMore();
request = new GetUserScoresRequest(User.Value.Id, type, VisiblePages++ * ItemsPerPage);
request.Success += scores => Schedule(() =>
{
@ -41,8 +39,8 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
if (!scores.Any() && VisiblePages == 1)
{
ShowMoreButton.Hide();
ShowMoreLoading.Hide();
MoreButton.Hide();
MoreButton.IsLoading = false;
MissingText.Show();
return;
}
@ -63,8 +61,8 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
LoadComponentsAsync(drawableScores, s =>
{
MissingText.Hide();
ShowMoreButton.FadeTo(scores.Count == ItemsPerPage ? 1 : 0);
ShowMoreLoading.Hide();
MoreButton.FadeTo(scores.Count == ItemsPerPage ? 1 : 0);
MoreButton.IsLoading = false;
ItemsContainer.AddRange(s);
});

View File

@ -22,13 +22,11 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
protected override void ShowMore()
{
base.ShowMore();
request = new GetUserRecentActivitiesRequest(User.Value.Id, VisiblePages++ * ItemsPerPage);
request.Success += activities => Schedule(() =>
{
ShowMoreButton.FadeTo(activities.Count == ItemsPerPage ? 1 : 0);
ShowMoreLoading.Hide();
MoreButton.FadeTo(activities.Count == ItemsPerPage ? 1 : 0);
MoreButton.IsLoading = false;
if (!activities.Any() && VisiblePages == 1)
{

View File

@ -0,0 +1,146 @@
// 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.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osuTK;
using System.Collections.Generic;
namespace osu.Game.Overlays.Profile.Sections
{
public class ShowMoreButton : OsuHoverContainer
{
private const float fade_duration = 200;
private readonly Box background;
private readonly LoadingAnimation loading;
private readonly FillFlowContainer content;
protected override IEnumerable<Drawable> EffectTargets => new[] { background };
private bool isLoading;
public bool IsLoading
{
get => isLoading;
set
{
if (isLoading == value)
return;
isLoading = value;
Enabled.Value = !isLoading;
if (value)
{
loading.FadeIn(fade_duration, Easing.OutQuint);
content.FadeOut(fade_duration, Easing.OutQuint);
}
else
{
loading.FadeOut(fade_duration, Easing.OutQuint);
content.FadeIn(fade_duration, Easing.OutQuint);
}
}
}
public ShowMoreButton()
{
AutoSizeAxes = Axes.Both;
Children = new Drawable[]
{
new CircularContainer
{
Masking = true,
Size = new Vector2(140, 30),
Children = new Drawable[]
{
background = new Box
{
RelativeSizeAxes = Axes.Both,
},
content = new FillFlowContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(7),
Children = new Drawable[]
{
new ChevronIcon(),
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
Text = "show more".ToUpper(),
},
new ChevronIcon(),
}
},
loading = new LoadingAnimation
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(12)
},
}
}
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colors)
{
IdleColour = colors.GreySeafoamDark;
HoverColour = colors.GreySeafoam;
}
protected override bool OnClick(ClickEvent e)
{
if (!Enabled.Value)
return false;
try
{
return base.OnClick(e);
}
finally
{
// run afterwards as this will disable this button.
IsLoading = true;
}
}
private class ChevronIcon : SpriteIcon
{
private const int bottom_margin = 2;
private const int icon_size = 8;
public ChevronIcon()
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Margin = new MarginPadding { Bottom = bottom_margin };
Size = new Vector2(icon_size);
Icon = FontAwesome.Solid.ChevronDown;
}
[BackgroundDependencyLoader]
private void load(OsuColour colors)
{
Colour = colors.Yellow;
}
}
}
}

View File

@ -8,13 +8,12 @@ using osu.Game.Overlays.Settings;
using osu.Game.Overlays.Settings.Sections;
using osuTK.Graphics;
using System.Collections.Generic;
using System.Linq;
namespace osu.Game.Overlays
{
public class SettingsOverlay : SettingsPanel
{
private readonly KeyBindingPanel keyBindingPanel;
protected override IEnumerable<SettingsSection> CreateSections() => new SettingsSection[]
{
new GeneralSection(),
@ -22,29 +21,37 @@ namespace osu.Game.Overlays
new GameplaySection(),
new AudioSection(),
new SkinSection(),
new InputSection(keyBindingPanel),
new InputSection(createSubPanel(new KeyBindingPanel())),
new OnlineSection(),
new MaintenanceSection(),
new DebugSection(),
};
private readonly List<SettingsSubPanel> subPanels = new List<SettingsSubPanel>();
protected override Drawable CreateHeader() => new SettingsHeader("settings", "Change the way osu! behaves");
protected override Drawable CreateFooter() => new SettingsFooter();
public SettingsOverlay()
: base(true)
{
keyBindingPanel = new KeyBindingPanel
{
Depth = 1,
Anchor = Anchor.TopRight,
};
keyBindingPanel.StateChanged += keyBindingPanelStateChanged;
}
public override bool AcceptsFocus => keyBindingPanel.State != Visibility.Visible;
public override bool AcceptsFocus => subPanels.All(s => s.State != Visibility.Visible);
private void keyBindingPanelStateChanged(Visibility visibility)
private T createSubPanel<T>(T subPanel)
where T : SettingsSubPanel
{
subPanel.Depth = 1;
subPanel.Anchor = Anchor.TopRight;
subPanel.StateChanged += subPanelStateChanged;
subPanels.Add(subPanel);
return subPanel;
}
private void subPanelStateChanged(Visibility visibility)
{
switch (visibility)
{
@ -66,12 +73,13 @@ namespace osu.Game.Overlays
}
}
protected override float ExpandedPosition => keyBindingPanel.State == Visibility.Visible ? -WIDTH : base.ExpandedPosition;
protected override float ExpandedPosition => subPanels.Any(s => s.State == Visibility.Visible) ? -WIDTH : base.ExpandedPosition;
[BackgroundDependencyLoader]
private void load()
{
ContentContainer.Add(keyBindingPanel);
foreach (var s in subPanels)
ContentContainer.Add(s);
}
}
}

View File

@ -28,8 +28,6 @@ namespace osu.Game.Overlays
protected const float WIDTH = 400;
private const float sidebar_padding = 10;
protected Container<Drawable> ContentContainer;
protected override Container<Drawable> Content => ContentContainer;

View File

@ -0,0 +1,103 @@
// 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.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Input.Bindings;
using osu.Game.Overlays.Settings;
using osu.Game.Screens.Ranking;
using osuTK;
namespace osu.Game.Overlays
{
public abstract class SettingsSubPanel : SettingsPanel
{
protected SettingsSubPanel()
: base(true)
{
}
[BackgroundDependencyLoader]
private void load()
{
AddInternal(new BackButton
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Action = Hide
});
}
private class BackButton : OsuClickableContainer, IKeyBindingHandler<GlobalAction>
{
private AspectContainer aspect;
[BackgroundDependencyLoader]
private void load()
{
Size = new Vector2(Sidebar.DEFAULT_WIDTH);
Children = new Drawable[]
{
aspect = new AspectContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Y,
Children = new Drawable[]
{
new SpriteIcon
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Y = -15,
Size = new Vector2(15),
Shadow = true,
Icon = FontAwesome.Solid.ChevronLeft
},
new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Y = 15,
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
Text = @"back",
},
}
}
};
}
protected override bool OnMouseDown(MouseDownEvent e)
{
aspect.ScaleTo(0.75f, 2000, Easing.OutQuint);
return base.OnMouseDown(e);
}
protected override bool OnMouseUp(MouseUpEvent e)
{
aspect.ScaleTo(1, 1000, Easing.OutElastic);
return base.OnMouseUp(e);
}
public bool OnPressed(GlobalAction action)
{
switch (action)
{
case GlobalAction.Back:
Click();
return true;
}
return false;
}
public bool OnReleased(GlobalAction action) => false;
}
}
}

View File

@ -69,6 +69,7 @@ namespace osu.Game.Overlays.Toolbar
AutoSizeAxes = Axes.X,
Children = new Drawable[]
{
new ToolbarChangelogButton(),
new ToolbarDirectButton(),
new ToolbarChatButton(),
new ToolbarSocialButton(),

View File

@ -0,0 +1,22 @@
// 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.Graphics.Sprites;
namespace osu.Game.Overlays.Toolbar
{
public class ToolbarChangelogButton : ToolbarOverlayToggleButton
{
public ToolbarChangelogButton()
{
SetIcon(FontAwesome.Solid.Bullhorn);
}
[BackgroundDependencyLoader(true)]
private void load(ChangelogOverlay changelog)
{
StateContainer = changelog;
}
}
}

View File

@ -182,9 +182,9 @@ namespace osu.Game.Screens.Menu
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
sampleHover = audio.Sample.Get(@"Menu/button-hover");
sampleHover = audio.Samples.Get(@"Menu/button-hover");
if (!string.IsNullOrEmpty(sampleName))
sampleClick = audio.Sample.Get($@"Menu/{sampleName}");
sampleClick = audio.Samples.Get($@"Menu/{sampleName}");
}
protected override bool OnMouseDown(MouseDownEvent e)

View File

@ -150,7 +150,7 @@ namespace osu.Game.Screens.Menu
if (idleTracker != null) isIdle.BindTo(idleTracker.IsIdle);
sampleBack = audio.Sample.Get(@"Menu/button-back-select");
sampleBack = audio.Samples.Get(@"Menu/button-back-select");
}
private void onMulti()
@ -176,7 +176,7 @@ namespace osu.Game.Screens.Menu
private void updateIdleState(bool isIdle)
{
if (isIdle && State != ButtonSystemState.Exit)
if (isIdle && State != ButtonSystemState.Exit && State != ButtonSystemState.EnteringMode)
State = ButtonSystemState.Initial;
}

View File

@ -76,8 +76,8 @@ namespace osu.Game.Screens.Menu
introBeatmap = beatmaps.GetWorkingBeatmap(setInfo.Beatmaps[0]);
track = introBeatmap.Track;
welcome = audio.Sample.Get(@"welcome");
seeya = audio.Sample.Get(@"seeya");
welcome = audio.Samples.Get(@"welcome");
seeya = audio.Samples.Get(@"seeya");
}
private const double delay_step_one = 2300;

View File

@ -255,8 +255,8 @@ namespace osu.Game.Screens.Menu
[BackgroundDependencyLoader]
private void load(TextureStore textures, AudioManager audio)
{
sampleClick = audio.Sample.Get(@"Menu/osu-logo-select");
sampleBeat = audio.Sample.Get(@"Menu/osu-logo-heartbeat");
sampleClick = audio.Samples.Get(@"Menu/osu-logo-select");
sampleBeat = audio.Samples.Get(@"Menu/osu-logo-heartbeat");
logo.Texture = textures.Get(@"Menu/logo");
ripple.Texture = textures.Get(@"Menu/logo");

View File

@ -137,7 +137,7 @@ namespace osu.Game.Screens.Multi.Match.Components
private class BackgroundSprite : UpdateableBeatmapBackgroundSprite
{
protected override double FadeDuration => 200;
protected override double TransformDuration => 200;
}
}
}

View File

@ -255,7 +255,7 @@ namespace osu.Game.Screens.Multi
if (!track.IsRunning)
{
game.Audio.AddItemToList(track);
game.Audio.AddItem(track);
track.Seek(Beatmap.Value.Metadata.PreviewTime);
track.Start();
}

View File

@ -99,7 +99,7 @@ namespace osu.Game.Screens
[BackgroundDependencyLoader(true)]
private void load(OsuGame osu, AudioManager audio)
{
sampleExit = audio.Sample.Get(@"UI/screen-back");
sampleExit = audio.Samples.Get(@"UI/screen-back");
}
public virtual bool OnPressed(GlobalAction action)

View File

@ -103,7 +103,7 @@ namespace osu.Game.Screens.Play
if (working == null)
return;
sampleRestart = audio.Sample.Get(@"Gameplay/restart");
sampleRestart = audio.Samples.Get(@"Gameplay/restart");
mouseWheelDisabled = config.GetBindable<bool>(OsuSetting.MouseDisableWheel);
showStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard);

View File

@ -234,7 +234,7 @@ namespace osu.Game.Screens.Play
colourNormal = colours.Yellow;
colourHover = colours.YellowDark;
sampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection");
sampleConfirm = audio.Samples.Get(@"SongSelect/confirm-selection");
Children = new Drawable[]
{

View File

@ -69,7 +69,7 @@ namespace osu.Game.Screens.Select.Carousel
}
};
sampleHover = audio.Sample.Get($@"SongSelect/song-ping-variation-{RNG.Next(1, 5)}");
sampleHover = audio.Samples.Get($@"SongSelect/song-ping-variation-{RNG.Next(1, 5)}");
hoverLayer.Colour = colours.Blue.Opacity(0.1f);
}

View File

@ -242,9 +242,9 @@ namespace osu.Game.Screens.Select
dialogOverlay = dialog;
sampleChangeDifficulty = audio.Sample.Get(@"SongSelect/select-difficulty");
sampleChangeBeatmap = audio.Sample.Get(@"SongSelect/select-expand");
SampleConfirm = audio.Sample.Get(@"SongSelect/confirm-selection");
sampleChangeDifficulty = audio.Samples.Get(@"SongSelect/select-difficulty");
sampleChangeBeatmap = audio.Samples.Get(@"SongSelect/select-expand");
SampleConfirm = audio.Samples.Get(@"SongSelect/confirm-selection");
Carousel.LoadBeatmapSetsFromManager(this.beatmaps);
@ -580,9 +580,6 @@ namespace osu.Game.Screens.Select
if (!track.IsRunning || restart)
{
// Ensure the track is added to the TrackManager, since it is removed after the player finishes the map.
// Using AddItemToList rather than AddItem so that it doesn't attempt to register adjustment dependencies more than once.
Game.Audio.Track.AddItemToList(track);
track.RestartPoint = Beatmap.Value.Metadata.PreviewTime;
track.Restart();
}

Some files were not shown because too many files have changed in this diff Show More