1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Merge branch 'master' into slider-controlpoint-addition

This commit is contained in:
Dean Herbert 2019-11-12 18:13:27 +09:00 committed by GitHub
commit 4b66ce0c52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 191 additions and 78 deletions

View File

@ -53,6 +53,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.1108.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.1112.0" />
</ItemGroup>
</Project>

View File

@ -7,6 +7,7 @@ using osu.Framework.Audio.Track;
using osu.Framework.Graphics.Containers;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using static osu.Game.Tests.Visual.Components.TestScenePreviewTrackManager.TestPreviewTrackManager;
namespace osu.Game.Tests.Visual.Components
{
@ -59,6 +60,9 @@ namespace osu.Game.Tests.Visual.Components
AddStep("start track 2", () => track2.Start());
AddAssert("track 1 stopped", () => !track1.IsRunning);
AddAssert("track 2 started", () => track2.IsRunning);
AddStep("start track 1", () => track1.Start());
AddAssert("track 2 stopped", () => !track2.IsRunning);
AddAssert("track 1 started", () => track1.IsRunning);
}
[Test]
@ -88,9 +92,25 @@ namespace osu.Game.Tests.Visual.Components
AddAssert("stopped", () => !track.IsRunning);
}
private PreviewTrack getTrack() => trackManager.Get(null);
[Test]
public void TestNonPresentTrack()
{
TestPreviewTrack track = null;
private PreviewTrack getOwnedTrack()
AddStep("get non-present track", () =>
{
Add(new TestTrackOwner(track = getTrack()));
track.Alpha = 0;
});
AddUntilStep("wait loaded", () => track.IsLoaded);
AddStep("start", () => track.Start());
AddStep("seek to end", () => track.Track.Seek(track.Track.Length));
AddAssert("track stopped", () => !track.IsRunning);
}
private TestPreviewTrack getTrack() => (TestPreviewTrack)trackManager.Get(null);
private TestPreviewTrack getOwnedTrack()
{
var track = getTrack();
@ -122,14 +142,16 @@ namespace osu.Game.Tests.Visual.Components
}
}
private class TestPreviewTrackManager : PreviewTrackManager
public class TestPreviewTrackManager : PreviewTrackManager
{
protected override TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackStore) => new TestPreviewTrack(beatmapSetInfo, trackStore);
protected class TestPreviewTrack : TrackManagerPreviewTrack
public class TestPreviewTrack : TrackManagerPreviewTrack
{
private readonly ITrackStore trackManager;
public new Track Track => base.Track;
public TestPreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackManager)
: base(beatmapSetInfo, trackManager)
{

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using osu.Framework.Bindables;
using osu.Game.Rulesets;
namespace osu.Game.Tournament.Models
{
@ -14,6 +15,8 @@ namespace osu.Game.Tournament.Models
[Serializable]
public class LadderInfo
{
public Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
public BindableList<TournamentMatch> Matches = new BindableList<TournamentMatch>();
public BindableList<TournamentRound> Rounds = new BindableList<TournamentRound>();
public BindableList<TournamentTeam> Teams = new BindableList<TournamentTeam>();

View File

@ -12,7 +12,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Overlays.Settings;
using osu.Game.Tournament.Components;
using osu.Game.Tournament.Models;
@ -24,7 +23,7 @@ namespace osu.Game.Tournament.Screens.Editors
public class TeamEditorScreen : TournamentEditorScreen<TeamEditorScreen.TeamRow, TournamentTeam>
{
[Resolved]
private Framework.Game game { get; set; }
private TournamentGameBase game { get; set; }
protected override BindableList<TournamentTeam> Storage => LadderInfo.Teams;
@ -198,6 +197,9 @@ namespace osu.Game.Tournament.Screens.Editors
[Resolved]
protected IAPIProvider API { get; private set; }
[Resolved]
private TournamentGameBase game { get; set; }
private readonly Bindable<string> userId = new Bindable<string>();
private readonly Container drawableContainer;
@ -280,25 +282,7 @@ namespace osu.Game.Tournament.Screens.Editors
return;
}
var req = new GetUserRequest(user.Id);
req.Success += res =>
{
// TODO: this should be done in a better way.
user.Username = res.Username;
user.Country = res.Country;
user.Cover = res.Cover;
updatePanel();
};
req.Failure += _ =>
{
user.Id = 1;
updatePanel();
};
API.Queue(req);
game.PopulateUser(user, updatePanel, updatePanel);
}, true);
}

View File

@ -2,6 +2,7 @@
// 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;
@ -10,6 +11,7 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Online.API;
using osu.Game.Overlays;
using osu.Game.Rulesets;
using osu.Game.Tournament.IPC;
using osuTK;
using osuTK.Graphics;
@ -28,6 +30,9 @@ namespace osu.Game.Tournament.Screens
[Resolved]
private IAPIProvider api { get; set; }
[Resolved]
private RulesetStore rulesets { get; set; }
[BackgroundDependencyLoader]
private void load()
{
@ -85,7 +90,34 @@ namespace osu.Game.Tournament.Screens
Value = api?.LocalUser.Value.Username,
Failing = api?.IsLoggedIn != true,
Description = "In order to access the API and display metadata, a login is required."
}
},
new LabelledDropdown<RulesetInfo>
{
Label = "Ruleset",
Description = "Decides what stats are displayed and which ranks are retrieved for players",
Items = rulesets.AvailableRulesets,
Current = LadderInfo.Ruleset,
},
};
}
public class LabelledDropdown<T> : LabelledComponent<OsuDropdown<T>, T>
{
public LabelledDropdown()
: base(true)
{
}
public IEnumerable<T> Items
{
get => Component.Items;
set => Component.Items = value;
}
protected override OsuDropdown<T> CreateComponent() => new OsuDropdown<T>
{
RelativeSizeAxes = Axes.X,
Width = 0.5f,
};
}

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 System.Drawing;
using System.IO;
using System.Linq;
@ -21,11 +22,13 @@ using osu.Game.Graphics;
using osu.Game.Online.API.Requests;
using osu.Game.Tournament.IPC;
using osu.Game.Tournament.Models;
using osu.Game.Users;
using osuTK.Graphics;
using osuTK.Input;
namespace osu.Game.Tournament
{
[Cached(typeof(TournamentGameBase))]
public abstract class TournamentGameBase : OsuGameBase
{
private const string bracket_filename = "bracket.json";
@ -126,6 +129,8 @@ namespace osu.Game.Tournament
ladder = new LadderInfo();
}
Ruleset.BindTo(ladder.Ruleset);
dependencies.Cache(ladder);
bool addedInfo = false;
@ -197,14 +202,8 @@ namespace osu.Game.Tournament
{
foreach (var p in t.Players)
{
if (string.IsNullOrEmpty(p.Username))
{
var req = new GetUserRequest(p.Id);
req.Perform(API);
p.Username = req.Result.Username;
addedInfo = true;
}
PopulateUser(p);
addedInfo = true;
}
}
@ -236,6 +235,30 @@ namespace osu.Game.Tournament
return addedInfo;
}
public void PopulateUser(User user, Action success = null, Action failure = null)
{
var req = new GetUserRequest(user.Id, Ruleset.Value);
req.Success += res =>
{
user.Username = res.Username;
user.Statistics = res.Statistics;
user.Username = res.Username;
user.Country = res.Country;
user.Cover = res.Cover;
success?.Invoke();
};
req.Failure += _ =>
{
user.Id = 1;
failure?.Invoke();
};
API.Queue(req);
}
protected override void LoadComplete()
{
MenuCursorContainer.Cursor.AlwaysPresent = true; // required for tooltip display

View File

@ -24,36 +24,37 @@ namespace osu.Game.Audio
/// </summary>
public event Action Started;
private Track track;
protected Track Track { get; private set; }
private bool hasStarted;
[BackgroundDependencyLoader]
private void load()
{
track = GetTrack();
if (track != null)
track.Completed += Stop;
Track = GetTrack();
if (Track != null)
Track.Completed += Stop;
}
/// <summary>
/// Length of the track.
/// </summary>
public double Length => track?.Length ?? 0;
public double Length => Track?.Length ?? 0;
/// <summary>
/// The current track time.
/// </summary>
public double CurrentTime => track?.CurrentTime ?? 0;
public double CurrentTime => Track?.CurrentTime ?? 0;
/// <summary>
/// Whether the track is loaded.
/// </summary>
public bool TrackLoaded => track?.IsLoaded ?? false;
public bool TrackLoaded => Track?.IsLoaded ?? false;
/// <summary>
/// Whether the track is playing.
/// </summary>
public bool IsRunning => track?.IsRunning ?? false;
public bool IsRunning => Track?.IsRunning ?? false;
private ScheduledDelegate startDelegate;
@ -63,7 +64,7 @@ namespace osu.Game.Audio
/// <returns>Whether the track is started or already playing.</returns>
public bool Start()
{
if (track == null)
if (Track == null)
return false;
startDelegate = Schedule(() =>
@ -73,7 +74,7 @@ namespace osu.Game.Audio
hasStarted = true;
track.Restart();
Track.Restart();
Started?.Invoke();
});
@ -87,7 +88,7 @@ namespace osu.Game.Audio
{
startDelegate?.Cancel();
if (track == null)
if (Track == null)
return;
if (!hasStarted)
@ -95,7 +96,7 @@ namespace osu.Game.Audio
hasStarted = false;
track.Stop();
Track.Stop();
Stopped?.Invoke();
}

View File

@ -55,6 +55,9 @@ namespace osu.Game.Audio
track.Stopped += () => Schedule(() =>
{
if (current != track)
return;
current = null;
audio.Tracks.RemoveAdjustment(AdjustableProperty.Volume, muteBindable);
});
@ -85,7 +88,7 @@ namespace osu.Game.Audio
/// </summary>
protected virtual TrackManagerPreviewTrack CreatePreviewTrack(BeatmapSetInfo beatmapSetInfo, ITrackStore trackStore) => new TrackManagerPreviewTrack(beatmapSetInfo, trackStore);
protected class TrackManagerPreviewTrack : PreviewTrack
public class TrackManagerPreviewTrack : PreviewTrack
{
public IPreviewTrackOwner Owner { get; private set; }

View File

@ -102,8 +102,6 @@ namespace osu.Game
private readonly List<OverlayContainer> overlays = new List<OverlayContainer>();
private readonly List<VisibilityContainer> toolbarElements = new List<VisibilityContainer>();
private readonly List<OverlayContainer> visibleBlockingOverlays = new List<OverlayContainer>();
public OsuGame(string[] args = null)
@ -134,17 +132,13 @@ namespace osu.Game
/// <summary>
/// Close all game-wide overlays.
/// </summary>
/// <param name="hideToolbarElements">Whether the toolbar (and accompanying controls) should also be hidden.</param>
public void CloseAllOverlays(bool hideToolbarElements = true)
/// <param name="hideToolbar">Whether the toolbar should also be hidden.</param>
public void CloseAllOverlays(bool hideToolbar = true)
{
foreach (var overlay in overlays)
overlay.Hide();
if (hideToolbarElements)
{
foreach (var overlay in toolbarElements)
overlay.Hide();
}
if (hideToolbar) Toolbar.Hide();
}
private DependencyContainer dependencies;
@ -393,6 +387,8 @@ namespace osu.Game
protected virtual Loader CreateLoader() => new Loader();
protected override Container CreateScalingContainer() => new ScalingContainer(ScalingMode.Everything);
#region Beatmap progression
private void beatmapChanged(ValueChangedEvent<WorkingBeatmap> beatmap)
@ -572,11 +568,7 @@ namespace osu.Game
CloseAllOverlays(false);
menuScreen?.MakeCurrent();
},
}, d =>
{
topMostOverlayContent.Add(d);
toolbarElements.Add(d);
});
}, topMostOverlayContent.Add);
loadComponentSingleFile(volume = new VolumeOverlay(), leftFloatingOverlayContent.Add, true);
@ -615,11 +607,7 @@ namespace osu.Game
GetToolbarHeight = () => ToolbarOffset,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
}, d =>
{
rightFloatingOverlayContent.Add(d);
toolbarElements.Add(d);
}, true);
}, rightFloatingOverlayContent.Add, true);
loadComponentSingleFile(new AccountCreationOverlay(), topMostOverlayContent.Add, true);
loadComponentSingleFile(new DialogOverlay(), topMostOverlayContent.Add, true);
@ -629,8 +617,8 @@ namespace osu.Game
Add(externalLinkOpener = new ExternalLinkOpener());
// side overlays which cancel each other.
var singleDisplaySideOverlays = new OverlayContainer[] { Settings, notifications };
overlays.AddRange(singleDisplaySideOverlays);
foreach (var overlay in singleDisplaySideOverlays)
{
@ -644,7 +632,6 @@ namespace osu.Game
// eventually informational overlays should be displayed in a stack, but for now let's only allow one to stay open at a time.
var informationalOverlays = new OverlayContainer[] { beatmapSetOverlay, userProfile };
overlays.AddRange(informationalOverlays);
foreach (var overlay in informationalOverlays)
{
@ -658,7 +645,6 @@ namespace osu.Game
// ensure only one of these overlays are open at once.
var singleDisplayOverlays = new OverlayContainer[] { chatOverlay, social, direct, changelogOverlay };
overlays.AddRange(singleDisplayOverlays);
foreach (var overlay in singleDisplayOverlays)
{
@ -759,6 +745,9 @@ namespace osu.Game
if (cache)
dependencies.Cache(d);
if (d is OverlayContainer overlay)
overlays.Add(overlay);
// schedule is here to ensure that all component loads are done after LoadComplete is run (and thus all dependencies are cached).
// with some better organisation of LoadComplete to do construction and dependency caching in one step, followed by calls to loadComponentSingleFile,
// we could avoid the need for scheduling altogether.

View File

@ -26,7 +26,6 @@ using osu.Framework.Input;
using osu.Framework.Logging;
using osu.Game.Audio;
using osu.Game.Database;
using osu.Game.Graphics.Containers;
using osu.Game.Input;
using osu.Game.Input.Bindings;
using osu.Game.IO;
@ -228,7 +227,7 @@ namespace osu.Game
Child = content = new OsuTooltipContainer(MenuCursorContainer.Cursor) { RelativeSizeAxes = Axes.Both }
};
base.Content.Add(new ScalingContainer(ScalingMode.Everything) { Child = MenuCursorContainer });
base.Content.Add(CreateScalingContainer().WithChild(MenuCursorContainer));
KeyBindingStore.Register(globalBinding);
dependencies.Cache(globalBinding);
@ -238,6 +237,8 @@ namespace osu.Game
Add(previewTrackManager);
}
protected virtual Container CreateScalingContainer() => new DrawSizePreservingFillContainer();
protected override void LoadComplete()
{
base.LoadComplete();

View File

@ -10,6 +10,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.Timing;
using osu.Game.Rulesets.Edit;
@ -21,7 +22,7 @@ using osuTK.Input;
namespace osu.Game.Screens.Edit.Compose.Components
{
public class BlueprintContainer : CompositeDrawable
public class BlueprintContainer : CompositeDrawable, IKeyBindingHandler<PlatformAction>
{
public event Action<IEnumerable<HitObject>> SelectionChanged;
@ -185,6 +186,37 @@ namespace osu.Game.Screens.Edit.Compose.Components
return true;
}
protected override bool OnKeyDown(KeyDownEvent e)
{
switch (e.Key)
{
case Key.Escape:
if (!selectionHandler.SelectedBlueprints.Any())
return false;
deselectAll();
return true;
}
return false;
}
protected override bool OnKeyUp(KeyUpEvent e) => false;
public bool OnPressed(PlatformAction action)
{
switch (action.ActionType)
{
case PlatformActionType.SelectAll:
selectAll();
return true;
}
return false;
}
public bool OnReleased(PlatformAction action) => false;
protected override void Update()
{
base.Update();
@ -330,6 +362,15 @@ namespace osu.Game.Screens.Edit.Compose.Components
}
}
/// <summary>
/// Selects all <see cref="SelectionBlueprint"/>s.
/// </summary>
private void selectAll()
{
selectionBlueprints.ToList().ForEach(m => m.Select());
selectionHandler.UpdateVisibility();
}
/// <summary>
/// Deselects all selected <see cref="SelectionBlueprint"/>s.
/// </summary>

View File

@ -80,8 +80,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
switch (action.ActionMethod)
{
case PlatformActionMethod.Delete:
foreach (var h in selectedBlueprints.ToList())
placementHandler.Delete(h.DrawableObject.HitObject);
deleteSelected();
return true;
}
@ -144,6 +143,12 @@ namespace osu.Game.Screens.Edit.Compose.Components
UpdateVisibility();
}
private void deleteSelected()
{
foreach (var h in selectedBlueprints.ToList())
placementHandler.Delete(h.DrawableObject.HitObject);
}
#endregion
#region Outline Display
@ -234,7 +239,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
createHitSampleMenuItem("Clap", HitSampleInfo.HIT_CLAP),
createHitSampleMenuItem("Finish", HitSampleInfo.HIT_FINISH)
}
}
},
new OsuMenuItem("Delete", MenuItemType.Destructive, deleteSelected),
};
if (selectedBlueprints.Count == 1)

View File

@ -10,6 +10,8 @@ using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Textures;
using osu.Framework.Platform;
using osu.Framework.Testing;
@ -93,6 +95,10 @@ namespace osu.Game.Tests.Visual
return Dependencies;
}
protected override Container<Drawable> Content => content ?? base.Content;
private readonly Container content;
protected OsuTestScene()
{
localStorage = new Lazy<Storage>(() => new NativeStorage($"{GetType().Name}-{Guid.NewGuid()}"));
@ -104,6 +110,8 @@ namespace osu.Game.Tests.Visual
usage.Migrate();
return factory;
});
base.Content.Add(content = new DrawSizePreservingFillContainer());
}
[Resolved]

View File

@ -21,7 +21,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.1108.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.1112.0" />
<PackageReference Include="SharpCompress" Version="0.24.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />

View File

@ -73,6 +73,6 @@
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.1010.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.1108.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.1112.0" />
</ItemGroup>
</Project>