1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-21 18:07:19 +08:00

Merge branch 'master' into no-control-overlay-headers

This commit is contained in:
Dean Herbert 2020-01-27 18:35:33 +09:00 committed by GitHub
commit e37ae589ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 107 additions and 49 deletions

View File

@ -29,7 +29,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.6" />
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
<PackageReference Include="DiscordRichPresence" Version="1.0.121" />
<PackageReference Include="DiscordRichPresence" Version="1.0.147" />
</ItemGroup>
<ItemGroup Label="Resources">
<EmbeddedResource Include="lazer.ico" />

View File

@ -237,19 +237,19 @@ namespace osu.Game.Rulesets.Mania
{
LeftKeys = new[]
{
InputKey.Number1,
InputKey.Number2,
InputKey.Number3,
InputKey.Number4,
InputKey.Q,
InputKey.W,
InputKey.E,
InputKey.R,
},
RightKeys = new[]
{
InputKey.Z,
InputKey.X,
InputKey.C,
InputKey.V
InputKey.V,
InputKey.B
},
SpecialKey = InputKey.Tilde,
SpecialKey = InputKey.S,
SpecialAction = ManiaAction.Special1,
NormalActionStart = ManiaAction.Key1
}.GenerateKeyBindingsFor(keys, out var nextNormal);
@ -265,12 +265,12 @@ namespace osu.Game.Rulesets.Mania
},
RightKeys = new[]
{
InputKey.O,
InputKey.P,
InputKey.BracketLeft,
InputKey.BracketRight
InputKey.K,
InputKey.L,
InputKey.Semicolon,
InputKey.Quote
},
SpecialKey = InputKey.BackSlash,
SpecialKey = InputKey.I,
SpecialAction = ManiaAction.Special2,
NormalActionStart = nextNormal
}.GenerateKeyBindingsFor(keys, out _);

View File

@ -13,7 +13,7 @@ namespace osu.Game.Tests.Visual.Online
[TestFixture]
public class TestSceneChangelogOverlay : OsuTestScene
{
private ChangelogOverlay changelog;
private TestChangelogOverlay changelog;
public override IReadOnlyList<Type> RequiredTypes => new[]
{
@ -29,23 +29,40 @@ namespace osu.Game.Tests.Visual.Online
protected override bool UseOnlineAPI => true;
protected override void LoadComplete()
[SetUp]
public void SetUp() => Schedule(() =>
{
base.LoadComplete();
Child = changelog = new TestChangelogOverlay();
});
Add(changelog = new ChangelogOverlay());
AddStep(@"Show", changelog.Show);
AddStep(@"Hide", changelog.Hide);
[Test]
public void ShowWithNoFetch()
{
AddStep(@"Show", () => changelog.Show());
AddUntilStep(@"wait for streams", () => changelog.Streams?.Count > 0);
AddAssert(@"listing displayed", () => changelog.Current.Value == null);
AddAssert(@"no stream selected", () => changelog.Header.Streams.Current.Value == null);
}
AddWaitStep("wait for hide", 3);
[Test]
public void ShowWithListing()
{
AddStep(@"Show with listing", () => changelog.ShowListing());
AddUntilStep(@"wait for streams", () => changelog.Streams?.Count > 0);
AddAssert(@"listing displayed", () => changelog.Current.Value == null);
AddAssert(@"no stream selected", () => changelog.Header.Streams.Current.Value == null);
}
[Test]
public void ShowWithBuild()
{
AddStep(@"Show with Lazer 2018.712.0", () =>
{
changelog.ShowBuild(new APIChangelogBuild
{
Version = "2018.712.0",
DisplayVersion = "2018.712.0",
UpdateStream = new APIUpdateStream { Name = OsuGameBase.CLIENT_STREAM_NAME },
UpdateStream = new APIUpdateStream { Id = 7, Name = OsuGameBase.CLIENT_STREAM_NAME },
ChangelogEntries = new List<APIChangelogEntry>
{
new APIChangelogEntry
@ -56,19 +73,16 @@ namespace osu.Game.Tests.Visual.Online
}
}
});
changelog.Show();
});
AddWaitStep("wait for show", 3);
AddStep(@"Hide", changelog.Hide);
AddWaitStep("wait for hide", 3);
AddStep(@"Show with listing", () =>
{
changelog.ShowListing();
changelog.Show();
});
AddUntilStep(@"wait for streams", () => changelog.Streams?.Count > 0);
AddAssert(@"correct build displayed", () => changelog.Current.Value.Version == "2018.712.0");
AddAssert(@"correct stream selected", () => changelog.Header.Streams.Current.Value.Id == 7);
}
[Test]
public void TestHTMLUnescaping()
{
AddStep(@"Ensure HTML string unescaping", () =>
{
changelog.ShowBuild(new APIChangelogBuild
@ -97,5 +111,12 @@ namespace osu.Game.Tests.Visual.Online
});
});
}
private class TestChangelogOverlay : ChangelogOverlay
{
public new List<APIUpdateStream> Streams => base.Streams;
public new ChangelogHeader Header => base.Header;
}
}
}

View File

@ -1,9 +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.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
@ -12,11 +14,11 @@ namespace osu.Game.Tests.Visual.UserInterface
[TestFixture]
public class TestSceneBreadcrumbControl : OsuTestScene
{
private readonly BreadcrumbControl<BreadcrumbTab> breadcrumbs;
private readonly TestBreadcrumbControl breadcrumbs;
public TestSceneBreadcrumbControl()
{
Add(breadcrumbs = new BreadcrumbControl<BreadcrumbTab>
Add(breadcrumbs = new TestBreadcrumbControl
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
@ -25,8 +27,13 @@ namespace osu.Game.Tests.Visual.UserInterface
});
AddStep(@"first", () => breadcrumbs.Current.Value = BreadcrumbTab.Click);
assertVisible(1);
AddStep(@"second", () => breadcrumbs.Current.Value = BreadcrumbTab.The);
assertVisible(2);
AddStep(@"third", () => breadcrumbs.Current.Value = BreadcrumbTab.Circles);
assertVisible(3);
}
[BackgroundDependencyLoader]
@ -35,11 +42,27 @@ namespace osu.Game.Tests.Visual.UserInterface
breadcrumbs.StripColour = colours.Blue;
}
private void assertVisible(int count) => AddAssert($"first {count} item(s) visible", () =>
{
for (int i = 0; i < count; i++)
{
if (breadcrumbs.GetDrawable((BreadcrumbTab)i).State != Visibility.Visible)
return false;
}
return true;
});
private enum BreadcrumbTab
{
Click,
The,
Circles,
}
private class TestBreadcrumbControl : BreadcrumbControl<BreadcrumbTab>
{
public BreadcrumbTabItem GetDrawable(BreadcrumbTab tab) => (BreadcrumbTabItem)TabContainer.First(t => t.Value == tab);
}
}
}

View File

@ -90,7 +90,7 @@ namespace osu.Game.Graphics
{
ScheduledDelegate waitDelegate = host.DrawThread.Scheduler.AddDelayed(() =>
{
if (framesWaited++ < frames_to_wait)
if (framesWaited++ >= frames_to_wait)
// ReSharper disable once AccessToDisposedClosure
framesWaitedEvent.Set();
}, 10, true);

View File

@ -34,13 +34,13 @@ namespace osu.Game.Graphics.UserInterface
var tIndex = TabContainer.IndexOf(t);
var tabIndex = TabContainer.IndexOf(TabMap[index.NewValue]);
t.State = tIndex < tabIndex ? Visibility.Hidden : Visibility.Visible;
t.Chevron.FadeTo(tIndex <= tabIndex ? 0f : 1f, 500, Easing.OutQuint);
t.State = tIndex > tabIndex ? Visibility.Hidden : Visibility.Visible;
t.Chevron.FadeTo(tIndex >= tabIndex ? 0f : 1f, 500, Easing.OutQuint);
}
};
}
protected class BreadcrumbTabItem : OsuTabItem, IStateful<Visibility>
public class BreadcrumbTabItem : OsuTabItem, IStateful<Visibility>
{
protected virtual float ChevronSize => 10;

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 System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -37,7 +38,7 @@ namespace osu.Game.Overlays.Changelog
Streams.Current.ValueChanged += e =>
{
if (e.NewValue?.LatestBuild != null && e.NewValue != Current.Value?.UpdateStream)
if (e.NewValue?.LatestBuild != null && !e.NewValue.Equals(Current.Value?.UpdateStream))
Current.Value = e.NewValue.LatestBuild;
};
}
@ -54,7 +55,7 @@ namespace osu.Game.Overlays.Changelog
TabControl.AddItem(e.NewValue.ToString());
TabControl.Current.Value = e.NewValue.ToString();
Streams.Current.Value = Streams.Items.FirstOrDefault(s => s.Name == e.NewValue.UpdateStream.Name);
updateCurrentStream();
title.Version = e.NewValue.UpdateStream.DisplayName;
}
@ -80,6 +81,20 @@ namespace osu.Game.Overlays.Changelog
protected override ScreenTitle CreateTitle() => title = new ChangelogHeaderTitle();
public void Populate(List<APIUpdateStream> streams)
{
Streams.Populate(streams);
updateCurrentStream();
}
private void updateCurrentStream()
{
if (Current.Value == null)
return;
Streams.Current.Value = Streams.Items.FirstOrDefault(s => s.Name == Current.Value.UpdateStream.Name);
}
public class HeaderBackground : Sprite
{
public HeaderBackground()

View File

@ -29,8 +29,6 @@ namespace osu.Game.Overlays.Changelog
public void Populate(List<APIUpdateStream> streams)
{
Current.Value = null;
foreach (APIUpdateStream updateStream in streams)
AddItem(updateStream);
}

View File

@ -26,7 +26,7 @@ namespace osu.Game.Overlays
{
public readonly Bindable<APIChangelogBuild> Current = new Bindable<APIChangelogBuild>();
private ChangelogHeader header;
protected ChangelogHeader Header;
private Container<ChangelogContent> content;
@ -34,7 +34,7 @@ namespace osu.Game.Overlays
private List<APIChangelogBuild> builds;
private List<APIUpdateStream> streams;
protected List<APIUpdateStream> Streams;
public ChangelogOverlay()
: base(OverlayColourScheme.Purple)
@ -62,7 +62,7 @@ namespace osu.Game.Overlays
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
header = new ChangelogHeader
Header = new ChangelogHeader
{
ListingSelected = ShowListing,
},
@ -78,7 +78,7 @@ namespace osu.Game.Overlays
sampleBack = audio.Samples.Get(@"UI/generic-select-soft");
header.Current.BindTo(Current);
Header.Current.BindTo(Current);
Current.BindValueChanged(e =>
{
@ -117,7 +117,7 @@ namespace osu.Game.Overlays
performAfterFetch(() =>
{
var build = builds.Find(b => b.Version == version && b.UpdateStream.Name == updateStream)
?? streams.Find(s => s.Name == updateStream)?.LatestBuild;
?? Streams.Find(s => s.Name == updateStream)?.LatestBuild;
if (build != null)
ShowBuild(build);
@ -179,9 +179,9 @@ namespace osu.Game.Overlays
res.Streams.ForEach(s => s.LatestBuild.UpdateStream = res.Streams.Find(s2 => s2.Id == s.LatestBuild.UpdateStream.Id));
builds = res.Builds;
streams = res.Streams;
Streams = res.Streams;
header.Streams.Populate(res.Streams);
Header.Populate(res.Streams);
tcs.SetResult(true);
});

View File

@ -45,7 +45,7 @@ namespace osu.Game.Rulesets.Scoring
public readonly Bindable<ScoreRank> Rank = new Bindable<ScoreRank>(ScoreRank.X);
/// <summary>
/// THe highest combo achieved by this score.
/// The highest combo achieved by this score.
/// </summary>
public readonly BindableInt HighestCombo = new BindableInt();

View File

@ -298,6 +298,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GL/@EntryIndexedValue">GL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GLSL/@EntryIndexedValue">GLSL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HID/@EntryIndexedValue">HID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HTML/@EntryIndexedValue">HTML</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HUD/@EntryIndexedValue">HUD</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IL/@EntryIndexedValue">IL</s:String>