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

Merge remote-tracking branch 'origin/master' into reverse-winding

This commit is contained in:
smoogipoo 2020-01-29 15:38:06 +09:00
commit ec015d750b
69 changed files with 1238 additions and 607 deletions

View File

@ -135,7 +135,7 @@ csharp_preferred_modifier_order = public,private,protected,internal,new,abstract
csharp_style_expression_bodied_accessors = true:warning
csharp_style_expression_bodied_constructors = false:none
csharp_style_expression_bodied_indexers = true:warning
csharp_style_expression_bodied_methods = true:silent
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_operators = true:warning
csharp_style_expression_bodied_properties = true:warning
csharp_style_expression_bodied_local_functions = true:silent

View File

@ -111,7 +111,6 @@ platform :ios do
souyuz(
platform: "ios",
build_target: "osu_iOS",
plist_path: "../osu.iOS/Info.plist"
)
end

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

@ -1,146 +1,15 @@
// 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.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Compose.Components.Timeline;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Tests.Visual.Editor
{
[TestFixture]
public class TestSceneTimelineBlueprintContainer : EditorClockTestScene
public class TestSceneTimelineBlueprintContainer : TimelineTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(TimelineArea),
typeof(Timeline),
typeof(TimelineButton),
typeof(CentreMarker)
};
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
Beatmap.Value = new WaveformTestBeatmap(audio);
var editorBeatmap = new EditorBeatmap((Beatmap<HitObject>)Beatmap.Value.Beatmap, BeatDivisor);
Dependencies.Cache(editorBeatmap);
Dependencies.CacheAs<IBeatSnapProvider>(editorBeatmap);
Children = new Drawable[]
{
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 5),
Children = new Drawable[]
{
new StartStopButton(),
new AudioVisualiser(),
}
},
new TimelineArea
{
Child = new TimelineBlueprintContainer(),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.X,
Size = new Vector2(0.8f, 100)
}
};
}
private class AudioVisualiser : CompositeDrawable
{
private readonly Drawable marker;
[Resolved]
private IBindable<WorkingBeatmap> beatmap { get; set; }
[Resolved]
private IAdjustableClock adjustableClock { get; set; }
public AudioVisualiser()
{
Size = new Vector2(250, 25);
InternalChildren = new[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0.25f,
},
marker = new Box
{
RelativePositionAxes = Axes.X,
RelativeSizeAxes = Axes.Y,
Width = 2,
}
};
}
protected override void Update()
{
base.Update();
if (beatmap.Value.Track.IsLoaded)
marker.X = (float)(adjustableClock.CurrentTime / beatmap.Value.Track.Length);
}
}
private class StartStopButton : OsuButton
{
private IAdjustableClock adjustableClock;
private bool started;
public StartStopButton()
{
BackgroundColour = Color4.SlateGray;
Size = new Vector2(100, 50);
Text = "Start";
Action = onClick;
}
[BackgroundDependencyLoader]
private void load(IAdjustableClock adjustableClock)
{
this.adjustableClock = adjustableClock;
}
private void onClick()
{
if (started)
{
adjustableClock.Stop();
Text = "Start";
}
else
{
adjustableClock.Start();
Text = "Stop";
}
started = !started;
}
}
public override Drawable CreateTestComponent() => new TimelineBlueprintContainer();
}
}

View File

@ -0,0 +1,32 @@
// 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;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Screens.Edit.Compose.Components;
using osu.Game.Screens.Edit.Compose.Components.Timeline;
using osuTK;
namespace osu.Game.Tests.Visual.Editor
{
[TestFixture]
public class TestSceneTimelineTickDisplay : TimelineTestScene
{
public override Drawable CreateTestComponent() => new TimelineTickDisplay();
[BackgroundDependencyLoader]
private void load()
{
BeatDivisor.Value = 4;
Add(new BeatDivisorControl(BeatDivisor)
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
Margin = new MarginPadding(30),
Size = new Vector2(90)
});
}
}
}

View File

@ -0,0 +1,148 @@
// 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.Audio;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Graphics.UserInterface;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Objects;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Compose.Components.Timeline;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Tests.Visual.Editor
{
public abstract class TimelineTestScene : EditorClockTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(TimelineArea),
typeof(Timeline),
typeof(TimelineButton),
typeof(CentreMarker)
};
protected TimelineArea TimelineArea { get; private set; }
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
Beatmap.Value = new WaveformTestBeatmap(audio);
var editorBeatmap = new EditorBeatmap((Beatmap<HitObject>)Beatmap.Value.Beatmap, BeatDivisor);
Dependencies.Cache(editorBeatmap);
Dependencies.CacheAs<IBeatSnapProvider>(editorBeatmap);
AddRange(new Drawable[]
{
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 5),
Children = new Drawable[]
{
new StartStopButton(),
new AudioVisualiser(),
}
},
TimelineArea = new TimelineArea
{
Child = CreateTestComponent(),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.X,
Size = new Vector2(0.8f, 100),
}
});
}
public abstract Drawable CreateTestComponent();
private class AudioVisualiser : CompositeDrawable
{
private readonly Drawable marker;
[Resolved]
private IBindable<WorkingBeatmap> beatmap { get; set; }
[Resolved]
private IAdjustableClock adjustableClock { get; set; }
public AudioVisualiser()
{
Size = new Vector2(250, 25);
InternalChildren = new[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0.25f,
},
marker = new Box
{
RelativePositionAxes = Axes.X,
RelativeSizeAxes = Axes.Y,
Width = 2,
}
};
}
protected override void Update()
{
base.Update();
if (beatmap.Value.Track.IsLoaded)
marker.X = (float)(adjustableClock.CurrentTime / beatmap.Value.Track.Length);
}
}
private class StartStopButton : OsuButton
{
private IAdjustableClock adjustableClock;
private bool started;
public StartStopButton()
{
BackgroundColour = Color4.SlateGray;
Size = new Vector2(100, 50);
Text = "Start";
Action = onClick;
}
[BackgroundDependencyLoader]
private void load(IAdjustableClock adjustableClock)
{
this.adjustableClock = adjustableClock;
}
private void onClick()
{
if (started)
{
adjustableClock.Stop();
Text = "Start";
}
else
{
adjustableClock.Start();
Text = "Stop";
}
started = !started;
}
}
}
}

View File

@ -7,6 +7,7 @@ using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
@ -65,10 +66,14 @@ namespace osu.Game.Tests.Visual.Menus
game.Dispose();
}
// see MouseSettings
var frameworkConfig = host.Dependencies.Get<FrameworkConfigManager>();
frameworkConfig.GetBindable<double>(FrameworkSetting.CursorSensitivity).Disabled = false;
game = new TestOsuGame(LocalStorage, API);
game.SetHost(host);
// todo: this can be removed once we can run audio trakcs without a device present
// todo: this can be removed once we can run audio tracks without a device present
// see https://github.com/ppy/osu/issues/1302
game.LocalConfig.Set(OsuSetting.IntroSequence, IntroSequence.Circles);

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

@ -8,6 +8,8 @@ using osu.Game.Online.API.Requests;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics;
using osu.Game.Overlays.Comments;
using osu.Game.Overlays;
using osu.Framework.Allocation;
namespace osu.Game.Tests.Visual.Online
{
@ -28,6 +30,9 @@ namespace osu.Game.Tests.Visual.Online
protected override bool UseOnlineAPI => true;
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
public TestSceneCommentsContainer()
{
BasicScrollContainer scroll;

View File

@ -4,7 +4,9 @@
using System;
using System.Collections.Generic;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Overlays;
using osu.Game.Overlays.Comments;
namespace osu.Game.Tests.Visual.Online
@ -19,6 +21,9 @@ namespace osu.Game.Tests.Visual.Online
typeof(SortTabControl),
};
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
private readonly Bindable<CommentsSortCriteria> sort = new Bindable<CommentsSortCriteria>();
private readonly BindableBool showDeleted = new BindableBool();

View File

@ -41,6 +41,7 @@ namespace osu.Game.Tests.Visual.Online
private class TestFullscreenOverlay : FullscreenOverlay
{
public TestFullscreenOverlay()
: base(OverlayColourScheme.Pink)
{
Children = new Drawable[]
{

View File

@ -7,6 +7,8 @@ using osu.Framework.Graphics;
using osu.Framework.Bindables;
using osu.Game.Overlays.Comments;
using osu.Framework.Utils;
using osu.Framework.Allocation;
using osu.Game.Overlays;
namespace osu.Game.Tests.Visual.Online
{
@ -17,6 +19,9 @@ namespace osu.Game.Tests.Visual.Online
typeof(TotalCommentsCounter),
};
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
public TestSceneTotalCommentsCounter()
{
var count = new BindableInt();

View File

@ -24,13 +24,16 @@ namespace osu.Game.Tests.Visual.Online
typeof(ProfileHeader),
typeof(RankGraph),
typeof(LineGraph),
typeof(TabControlOverlayHeader.OverlayHeaderTabControl),
typeof(TabControlOverlayHeader<>.OverlayHeaderTabControl),
typeof(CentreHeaderContainer),
typeof(BottomHeaderContainer),
typeof(DetailHeaderContainer),
typeof(ProfileHeaderButton)
};
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Green);
[Resolved]
private IAPIProvider api { get; set; }

View File

@ -14,6 +14,7 @@ using osu.Framework.Extensions;
using osu.Framework.Utils;
using osu.Framework.Platform;
using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Overlays;
@ -25,6 +26,7 @@ using osu.Game.Rulesets.Taiko;
using osu.Game.Screens.Select;
using osu.Game.Screens.Select.Carousel;
using osu.Game.Screens.Select.Filter;
using osuTK.Input;
namespace osu.Game.Tests.Visual.SongSelect
{
@ -95,6 +97,127 @@ namespace osu.Game.Tests.Visual.SongSelect
AddAssert("filter count is 1", () => songSelect.FilterCount == 1);
}
[Test]
public void TestChangeBeatmapBeforeEnter()
{
addRulesetImportStep(0);
createSongSelect();
AddUntilStep("wait for initial selection", () => !Beatmap.IsDefault);
WorkingBeatmap selected = null;
AddStep("store selected beatmap", () => selected = Beatmap.Value);
AddStep("select next and enter", () =>
{
InputManager.PressKey(Key.Down);
InputManager.ReleaseKey(Key.Down);
InputManager.PressKey(Key.Enter);
InputManager.ReleaseKey(Key.Enter);
});
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
AddAssert("ensure selection changed", () => selected != Beatmap.Value);
AddUntilStep("wait for return to song select", () => songSelect.IsCurrentScreen());
AddUntilStep("bindable lease returned", () => !Beatmap.Disabled);
}
[Test]
public void TestChangeBeatmapAfterEnter()
{
addRulesetImportStep(0);
createSongSelect();
AddUntilStep("wait for initial selection", () => !Beatmap.IsDefault);
WorkingBeatmap selected = null;
AddStep("store selected beatmap", () => selected = Beatmap.Value);
AddStep("select next and enter", () =>
{
InputManager.PressKey(Key.Enter);
InputManager.ReleaseKey(Key.Enter);
InputManager.PressKey(Key.Down);
InputManager.ReleaseKey(Key.Down);
});
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
AddAssert("ensure selection didn't change", () => selected == Beatmap.Value);
AddUntilStep("wait for return to song select", () => songSelect.IsCurrentScreen());
AddUntilStep("bindable lease returned", () => !Beatmap.Disabled);
}
[Test]
public void TestChangeBeatmapViaMouseBeforeEnter()
{
addRulesetImportStep(0);
createSongSelect();
AddUntilStep("wait for initial selection", () => !Beatmap.IsDefault);
WorkingBeatmap selected = null;
AddStep("store selected beatmap", () => selected = Beatmap.Value);
AddStep("select next and enter", () =>
{
InputManager.MoveMouseTo(songSelect.Carousel.ChildrenOfType<DrawableCarouselBeatmap>()
.First(b => ((CarouselBeatmap)b.Item).Beatmap != songSelect.Carousel.SelectedBeatmap));
InputManager.PressButton(MouseButton.Left);
InputManager.ReleaseButton(MouseButton.Left);
InputManager.PressKey(Key.Enter);
InputManager.ReleaseKey(Key.Enter);
});
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
AddAssert("ensure selection changed", () => selected != Beatmap.Value);
AddUntilStep("wait for return to song select", () => songSelect.IsCurrentScreen());
AddUntilStep("bindable lease returned", () => !Beatmap.Disabled);
}
[Test]
public void TestChangeBeatmapViaMouseAfterEnter()
{
addRulesetImportStep(0);
createSongSelect();
AddUntilStep("wait for initial selection", () => !Beatmap.IsDefault);
WorkingBeatmap selected = null;
AddStep("store selected beatmap", () => selected = Beatmap.Value);
AddStep("select next and enter", () =>
{
InputManager.MoveMouseTo(songSelect.Carousel.ChildrenOfType<DrawableCarouselBeatmap>()
.First(b => ((CarouselBeatmap)b.Item).Beatmap != songSelect.Carousel.SelectedBeatmap));
InputManager.PressButton(MouseButton.Left);
InputManager.PressKey(Key.Enter);
InputManager.ReleaseKey(Key.Enter);
InputManager.ReleaseButton(MouseButton.Left);
});
AddUntilStep("wait for not current", () => !songSelect.IsCurrentScreen());
AddAssert("ensure selection didn't change", () => selected == Beatmap.Value);
AddUntilStep("wait for return to song select", () => songSelect.IsCurrentScreen());
AddUntilStep("bindable lease returned", () => !Beatmap.Disabled);
}
[Test]
public void TestNoFilterOnSimpleResume()
{

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

@ -0,0 +1,163 @@
// 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.Containers;
using osu.Game.Overlays;
using System;
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Framework.Allocation;
using osu.Game.Graphics.UserInterface;
using osu.Framework.Graphics.Shapes;
using osuTK.Graphics;
namespace osu.Game.Tests.Visual.UserInterface
{
public class TestSceneOverlayHeader : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(OverlayHeader),
typeof(TabControlOverlayHeader<>),
typeof(BreadcrumbControlOverlayHeader),
typeof(TestNoControlHeader),
typeof(TestStringTabControlHeader),
typeof(TestEnumTabControlHeader),
typeof(TestBreadcrumbControlHeader),
typeof(OverlayHeaderBackground)
};
private readonly FillFlowContainer flow;
public TestSceneOverlayHeader()
{
AddRange(new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
},
new BasicScrollContainer
{
RelativeSizeAxes = Axes.Both,
Child = flow = new FillFlowContainer
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Direction = FillDirection.Vertical
}
}
});
addHeader("Orange OverlayHeader (no background)", new TestNoBackgroundHeader(), OverlayColourScheme.Orange);
addHeader("Blue OverlayHeader", new TestNoControlHeader(), OverlayColourScheme.Blue);
addHeader("Green TabControlOverlayHeader (string)", new TestStringTabControlHeader(), OverlayColourScheme.Green);
addHeader("Pink TabControlOverlayHeader (enum)", new TestEnumTabControlHeader(), OverlayColourScheme.Pink);
addHeader("Red BreadcrumbControlOverlayHeader (no background)", new TestBreadcrumbControlHeader(), OverlayColourScheme.Red);
}
private void addHeader(string name, OverlayHeader header, OverlayColourScheme colourScheme)
{
flow.Add(new FillFlowContainer
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Direction = FillDirection.Vertical,
Children = new Drawable[]
{
new OsuSpriteText
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Margin = new MarginPadding(20),
Text = name,
},
new ColourProvidedContainer(colourScheme, header)
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
}
}
});
}
private class ColourProvidedContainer : Container
{
[Cached]
private readonly OverlayColourProvider colourProvider;
public ColourProvidedContainer(OverlayColourScheme colourScheme, OverlayHeader header)
{
colourProvider = new OverlayColourProvider(colourScheme);
AutoSizeAxes = Axes.Y;
RelativeSizeAxes = Axes.X;
Add(header);
}
}
private class TestNoBackgroundHeader : OverlayHeader
{
protected override ScreenTitle CreateTitle() => new TestTitle();
}
private class TestNoControlHeader : OverlayHeader
{
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/changelog");
protected override ScreenTitle CreateTitle() => new TestTitle();
}
private class TestStringTabControlHeader : TabControlOverlayHeader<string>
{
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/news");
protected override ScreenTitle CreateTitle() => new TestTitle();
public TestStringTabControlHeader()
{
TabControl.AddItem("tab1");
TabControl.AddItem("tab2");
}
}
private class TestEnumTabControlHeader : TabControlOverlayHeader<TestEnum>
{
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/rankings");
protected override ScreenTitle CreateTitle() => new TestTitle();
}
private enum TestEnum
{
Some,
Cool,
Tabs
}
private class TestBreadcrumbControlHeader : BreadcrumbControlOverlayHeader
{
protected override ScreenTitle CreateTitle() => new TestTitle();
public TestBreadcrumbControlHeader()
{
TabControl.AddItem("tab1");
TabControl.AddItem("tab2");
TabControl.Current.Value = "tab2";
}
}
private class TestTitle : ScreenTitle
{
public TestTitle()
{
Title = "title";
Section = "section";
}
protected override Drawable CreateIcon() => new ScreenTitleTextureIcon(@"Icons/changelog");
}
}
}

View File

@ -0,0 +1,42 @@
// 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.Containers;
using osu.Game.Overlays;
using System;
using System.Collections.Generic;
using osu.Framework.Graphics;
using osuTK;
namespace osu.Game.Tests.Visual.UserInterface
{
public class TestSceneOverlayHeaderBackground : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(OverlayHeaderBackground)
};
public TestSceneOverlayHeaderBackground()
{
Add(new BasicScrollContainer
{
RelativeSizeAxes = Axes.Both,
Child = new FillFlowContainer
{
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 20),
Children = new[]
{
new OverlayHeaderBackground(@"Headers/changelog"),
new OverlayHeaderBackground(@"Headers/news"),
new OverlayHeaderBackground(@"Headers/rankings"),
new OverlayHeaderBackground(@"Headers/search"),
}
}
});
}
}
}

View File

@ -239,11 +239,11 @@ namespace osu.Game.Beatmaps.Formats
break;
case @"Source":
beatmap.BeatmapInfo.Metadata.Source = pair.Value;
metadata.Source = pair.Value;
break;
case @"Tags":
beatmap.BeatmapInfo.Metadata.Tags = pair.Value;
metadata.Tags = pair.Value;
break;
case @"BeatmapID":
@ -300,13 +300,11 @@ namespace osu.Game.Beatmaps.Formats
switch (type)
{
case LegacyEventType.Background:
string bgFilename = split[2].Trim('"');
beatmap.BeatmapInfo.Metadata.BackgroundFile = bgFilename.ToStandardisedPath();
beatmap.BeatmapInfo.Metadata.BackgroundFile = CleanFilename(split[2]);
break;
case LegacyEventType.Video:
string videoFilename = split[2].Trim('"');
beatmap.BeatmapInfo.Metadata.VideoFile = videoFilename.ToStandardisedPath();
beatmap.BeatmapInfo.Metadata.VideoFile = CleanFilename(split[2]);
break;
case LegacyEventType.Break:

View File

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using osu.Framework.Extensions;
using osu.Framework.Logging;
using osu.Game.Audio;
using osu.Game.Beatmaps.ControlPoints;
@ -115,7 +116,7 @@ namespace osu.Game.Beatmaps.Formats
protected KeyValuePair<string, string> SplitKeyVal(string line, char separator = ':')
{
var split = line.Trim().Split(new[] { separator }, 2);
var split = line.Split(separator, 2);
return new KeyValuePair<string, string>
(
@ -124,6 +125,8 @@ namespace osu.Game.Beatmaps.Formats
);
}
protected string CleanFilename(string path) => path.Trim('"').ToStandardisedPath();
protected enum Section
{
None,

View File

@ -7,7 +7,6 @@ using System.Globalization;
using System.IO;
using osuTK;
using osuTK.Graphics;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Game.IO;
using osu.Game.Storyboards;
@ -65,13 +64,16 @@ namespace osu.Game.Beatmaps.Formats
private void handleEvents(string line)
{
var depth = 0;
var lineSpan = line.AsSpan();
while (line.StartsWith(" ", StringComparison.Ordinal) || line.StartsWith("_", StringComparison.Ordinal))
while (lineSpan.StartsWith(" ", StringComparison.Ordinal) || lineSpan.StartsWith("_", StringComparison.Ordinal))
{
lineSpan = lineSpan.Slice(1);
++depth;
line = line.Substring(1);
}
line = lineSpan.ToString();
decodeVariables(ref line);
string[] split = line.Split(',');
@ -89,7 +91,7 @@ namespace osu.Game.Beatmaps.Formats
{
var layer = parseLayer(split[1]);
var origin = parseOrigin(split[2]);
var path = cleanFilename(split[3]);
var path = CleanFilename(split[3]);
var x = float.Parse(split[4], NumberFormatInfo.InvariantInfo);
var y = float.Parse(split[5], NumberFormatInfo.InvariantInfo);
storyboardSprite = new StoryboardSprite(path, origin, new Vector2(x, y));
@ -101,7 +103,7 @@ namespace osu.Game.Beatmaps.Formats
{
var layer = parseLayer(split[1]);
var origin = parseOrigin(split[2]);
var path = cleanFilename(split[3]);
var path = CleanFilename(split[3]);
var x = float.Parse(split[4], NumberFormatInfo.InvariantInfo);
var y = float.Parse(split[5], NumberFormatInfo.InvariantInfo);
var frameCount = int.Parse(split[6]);
@ -116,7 +118,7 @@ namespace osu.Game.Beatmaps.Formats
{
var time = double.Parse(split[1], CultureInfo.InvariantCulture);
var layer = parseLayer(split[2]);
var path = cleanFilename(split[3]);
var path = CleanFilename(split[3]);
var volume = split.Length > 4 ? float.Parse(split[4], CultureInfo.InvariantCulture) : 100;
storyboard.GetLayer(layer).Add(new StoryboardSampleInfo(path, time, (int)volume));
break;
@ -331,7 +333,5 @@ namespace osu.Game.Beatmaps.Formats
break;
}
}
private string cleanFilename(string path) => path.Trim('"').ToStandardisedPath();
}
}

View File

@ -3,7 +3,6 @@
using System;
using osu.Game.Beatmaps;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Graphics
@ -78,46 +77,6 @@ namespace osu.Game.Graphics
}
}
public Color4 ForOverlayElement(OverlayColourScheme colourScheme, float saturation, float lightness, float opacity = 1) => Color4.FromHsl(new Vector4(getBaseHue(colourScheme), saturation, lightness, opacity));
// See https://github.com/ppy/osu-web/blob/4218c288292d7c810b619075471eaea8bbb8f9d8/app/helpers.php#L1463
private static float getBaseHue(OverlayColourScheme colourScheme)
{
float hue;
switch (colourScheme)
{
default:
throw new ArgumentException($@"{colourScheme} colour scheme does not provide a hue value in {nameof(getBaseHue)}.");
case OverlayColourScheme.Red:
hue = 0;
break;
case OverlayColourScheme.Pink:
hue = 333;
break;
case OverlayColourScheme.Orange:
hue = 46;
break;
case OverlayColourScheme.Green:
hue = 115;
break;
case OverlayColourScheme.Purple:
hue = 255;
break;
case OverlayColourScheme.Blue:
hue = 200;
break;
}
return hue / 360f;
}
// 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");
@ -220,14 +179,4 @@ namespace osu.Game.Graphics
public readonly Color4 ContextMenuGray = FromHex(@"223034");
}
public enum OverlayColourScheme
{
Red,
Pink,
Orange,
Green,
Purple,
Blue
}
}

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

@ -36,6 +36,11 @@ namespace osu.Game.Graphics.UserInterface
public virtual string TooltipText { get; private set; }
/// <summary>
/// Whether to format the tooltip as a percentage or the actual value.
/// </summary>
public bool DisplayAsPercentage { get; set; }
private Color4 accentColour;
public Color4 AccentColour
@ -169,11 +174,11 @@ namespace osu.Game.Graphics.UserInterface
else
{
double floatValue = value.ToDouble(NumberFormatInfo.InvariantInfo);
double floatMinValue = CurrentNumber.MinValue.ToDouble(NumberFormatInfo.InvariantInfo);
double floatMaxValue = CurrentNumber.MaxValue.ToDouble(NumberFormatInfo.InvariantInfo);
if (floatMaxValue == 1 && floatMinValue >= -1)
if (DisplayAsPercentage)
{
TooltipText = floatValue.ToString("P0");
}
else
{
var decimalPrecision = normalise(CurrentNumber.Precision.ToDecimal(NumberFormatInfo.InvariantInfo), max_decimal_digits);

View File

@ -10,7 +10,6 @@ using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
@ -22,6 +21,22 @@ namespace osu.Game.Graphics.UserInterface
{
public class OsuTabControl<T> : TabControl<T>
{
private Color4 accentColour;
public virtual Color4 AccentColour
{
get => accentColour;
set
{
accentColour = value;
if (Dropdown is IHasAccentColour dropdown)
dropdown.AccentColour = value;
foreach (var i in TabContainer.Children.OfType<IHasAccentColour>())
i.AccentColour = value;
}
}
private readonly Box strip;
protected override Dropdown<T> CreateDropdown() => new OsuTabDropdown();
@ -63,35 +78,12 @@ namespace osu.Game.Graphics.UserInterface
AccentColour = colours.Blue;
}
private Color4 accentColour;
public Color4 AccentColour
{
get => accentColour;
set
{
accentColour = value;
if (Dropdown is IHasAccentColour dropdown)
dropdown.AccentColour = value;
foreach (var i in TabContainer.Children.OfType<IHasAccentColour>())
i.AccentColour = value;
}
}
public Color4 StripColour
{
get => strip.Colour;
set => strip.Colour = value;
}
protected override TabFillFlowContainer CreateTabFlow() => new OsuTabFillFlowContainer
{
Direction = FillDirection.Full,
RelativeSizeAxes = Axes.Both,
Depth = -1,
Masking = true
};
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();
@ -283,10 +275,5 @@ namespace osu.Game.Graphics.UserInterface
}
}
}
private class OsuTabFillFlowContainer : TabFillFlowContainer
{
protected override int Compare(Drawable x, Drawable y) => CompareReverseChildID(x, y);
}
}
}

View File

@ -130,91 +130,91 @@ namespace osu.Game.IO.Legacy
}
else
{
switch (obj.GetType().Name)
switch (obj)
{
case "Boolean":
case bool boolObj:
Write((byte)ObjType.boolType);
Write((bool)obj);
Write(boolObj);
break;
case "Byte":
case byte byteObj:
Write((byte)ObjType.byteType);
Write((byte)obj);
Write(byteObj);
break;
case "UInt16":
case ushort ushortObj:
Write((byte)ObjType.uint16Type);
Write((ushort)obj);
Write(ushortObj);
break;
case "UInt32":
case uint uintObj:
Write((byte)ObjType.uint32Type);
Write((uint)obj);
Write(uintObj);
break;
case "UInt64":
case ulong ulongObj:
Write((byte)ObjType.uint64Type);
Write((ulong)obj);
Write(ulongObj);
break;
case "SByte":
case sbyte sbyteObj:
Write((byte)ObjType.sbyteType);
Write((sbyte)obj);
Write(sbyteObj);
break;
case "Int16":
case short shortObj:
Write((byte)ObjType.int16Type);
Write((short)obj);
Write(shortObj);
break;
case "Int32":
case int intObj:
Write((byte)ObjType.int32Type);
Write((int)obj);
Write(intObj);
break;
case "Int64":
case long longObj:
Write((byte)ObjType.int64Type);
Write((long)obj);
Write(longObj);
break;
case "Char":
case char charObj:
Write((byte)ObjType.charType);
base.Write((char)obj);
base.Write(charObj);
break;
case "String":
case string stringObj:
Write((byte)ObjType.stringType);
base.Write((string)obj);
base.Write(stringObj);
break;
case "Single":
case float floatObj:
Write((byte)ObjType.singleType);
Write((float)obj);
Write(floatObj);
break;
case "Double":
case double doubleObj:
Write((byte)ObjType.doubleType);
Write((double)obj);
Write(doubleObj);
break;
case "Decimal":
case decimal decimalObj:
Write((byte)ObjType.decimalType);
Write((decimal)obj);
Write(decimalObj);
break;
case "DateTime":
case DateTime dateTimeObj:
Write((byte)ObjType.dateTimeType);
Write((DateTime)obj);
Write(dateTimeObj);
break;
case "Byte[]":
case byte[] byteArray:
Write((byte)ObjType.byteArrayType);
base.Write((byte[])obj);
base.Write(byteArray);
break;
case "Char[]":
case char[] charArray:
Write((byte)ObjType.charArrayType);
base.Write((char[])obj);
base.Write(charArray);
break;
default:

View File

@ -34,6 +34,7 @@ namespace osu.Game.Overlays
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
public BeatmapSetOverlay()
: base(OverlayColourScheme.Blue)
{
OsuScrollContainer scroll;
Info info;

View File

@ -1,30 +1,15 @@
// 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.UserInterface;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays
{
public abstract class BreadcrumbControlOverlayHeader : OverlayHeader
public abstract class BreadcrumbControlOverlayHeader : TabControlOverlayHeader<string>
{
protected OverlayHeaderBreadcrumbControl BreadcrumbControl;
protected override TabControl<string> CreateTabControl() => BreadcrumbControl = new OverlayHeaderBreadcrumbControl();
protected BreadcrumbControlOverlayHeader(OverlayColourScheme colourScheme)
: base(colourScheme)
{
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
BreadcrumbControl.AccentColour = colours.ForOverlayElement(ColourScheme, 1, 0.75f);
}
protected override OsuTabControl<string> CreateTabControl() => new OverlayHeaderBreadcrumbControl();
public class OverlayHeaderBreadcrumbControl : BreadcrumbControl<string>
{

View File

@ -2,14 +2,11 @@
// 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;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
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;
@ -26,10 +23,9 @@ namespace osu.Game.Overlays.Changelog
private const string listing_string = "listing";
public ChangelogHeader()
: base(OverlayColourScheme.Purple)
{
BreadcrumbControl.AddItem(listing_string);
BreadcrumbControl.Current.ValueChanged += e =>
TabControl.AddItem(listing_string);
TabControl.Current.ValueChanged += e =>
{
if (e.NewValue == listing_string)
ListingSelected?.Invoke();
@ -39,7 +35,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;
};
}
@ -49,26 +45,26 @@ namespace osu.Game.Overlays.Changelog
private void showBuild(ValueChangedEvent<APIChangelogBuild> e)
{
if (e.OldValue != null)
BreadcrumbControl.RemoveItem(e.OldValue.ToString());
TabControl.RemoveItem(e.OldValue.ToString());
if (e.NewValue != null)
{
BreadcrumbControl.AddItem(e.NewValue.ToString());
BreadcrumbControl.Current.Value = e.NewValue.ToString();
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;
}
else
{
BreadcrumbControl.Current.Value = listing_string;
TabControl.Current.Value = listing_string;
Streams.Current.Value = null;
title.Version = null;
}
}
protected override Drawable CreateBackground() => new HeaderBackground();
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/changelog");
protected override Drawable CreateContent() => new Container
{
@ -82,19 +78,18 @@ namespace osu.Game.Overlays.Changelog
protected override ScreenTitle CreateTitle() => title = new ChangelogHeaderTitle();
public class HeaderBackground : Sprite
public void Populate(List<APIUpdateStream> streams)
{
public HeaderBackground()
{
RelativeSizeAxes = Axes.Both;
FillMode = FillMode.Fill;
}
Streams.Populate(streams);
updateCurrentStream();
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
Texture = textures.Get(@"Headers/changelog");
}
private void updateCurrentStream()
{
if (Current.Value == null)
return;
Streams.Current.Value = Streams.Items.FirstOrDefault(s => s.Name == Current.Value.UpdateStream.Name);
}
private class ChangelogHeaderTitle : ScreenTitle

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,16 +34,16 @@ namespace osu.Game.Overlays
private List<APIChangelogBuild> builds;
private List<APIUpdateStream> streams;
protected List<APIUpdateStream> Streams;
public ChangelogOverlay()
: base(OverlayColourScheme.Purple)
{
}
[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
@ -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

@ -9,6 +9,7 @@ using osuTK;
using System;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Overlays.Chat.Tabs
{
@ -113,5 +114,18 @@ namespace osu.Game.Overlays.Chat.Tabs
OnRequestLeave?.Invoke(tab.Value);
}
protected override TabFillFlowContainer CreateTabFlow() => new ChannelTabFillFlowContainer
{
Direction = FillDirection.Full,
RelativeSizeAxes = Axes.Both,
Depth = -1,
Masking = true
};
private class ChannelTabFillFlowContainer : TabFillFlowContainer
{
protected override int Compare(Drawable x, Drawable y) => CompareReverseChildID(x, y);
}
}
}

View File

@ -8,7 +8,6 @@ using osu.Game.Online.API.Requests;
using osu.Framework.Graphics;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Online.API.Requests.Responses;
using System.Threading;
using System.Linq;
@ -27,28 +26,26 @@ namespace osu.Game.Overlays.Comments
[Resolved]
private IAPIProvider api { get; set; }
[Resolved]
private OsuColour colours { get; set; }
private GetCommentsRequest request;
private CancellationTokenSource loadCancellation;
private int currentPage;
private readonly Box background;
private readonly FillFlowContainer content;
private readonly DeletedChildrenPlaceholder deletedChildrenPlaceholder;
private readonly CommentsShowMoreButton moreButton;
private readonly TotalCommentsCounter commentCounter;
private FillFlowContainer content;
private DeletedChildrenPlaceholder deletedChildrenPlaceholder;
private CommentsShowMoreButton moreButton;
private TotalCommentsCounter commentCounter;
public CommentsContainer()
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
AddRangeInternal(new Drawable[]
{
background = new Box
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background5
},
new FillFlowContainer
{
@ -78,7 +75,7 @@ namespace osu.Game.Overlays.Comments
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(0.2f)
Colour = colourProvider.Background4
},
new FillFlowContainer
{
@ -113,12 +110,6 @@ namespace osu.Game.Overlays.Comments
});
}
[BackgroundDependencyLoader]
private void load()
{
background.Colour = colours.Gray2;
}
protected override void LoadComplete()
{
Sort.BindValueChanged(_ => refetchComments(), true);

View File

@ -76,9 +76,9 @@ namespace osu.Game.Overlays.Comments
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
private void load(OverlayColourProvider colourProvider)
{
background.Colour = colours.Gray3;
background.Colour = colourProvider.Background4;
}
private class ShowDeletedButton : HeaderButton

View File

@ -1,8 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Comments
@ -11,11 +11,12 @@ namespace osu.Game.Overlays.Comments
{
public readonly BindableInt Current = new BindableInt();
public CommentsShowMoreButton()
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
IdleColour = OsuColour.Gray(0.3f);
HoverColour = OsuColour.Gray(0.4f);
ChevronIconColour = OsuColour.Gray(0.5f);
IdleColour = colourProvider.Background2;
HoverColour = colourProvider.Background1;
ChevronIconColour = colourProvider.Foreground1;
}
protected override void LoadComplete()

View File

@ -5,7 +5,6 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Framework.Input.Events;
using osu.Game.Graphics.UserInterface;
@ -45,9 +44,9 @@ namespace osu.Game.Overlays.Comments
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
private void load(OverlayColourProvider colourProvider)
{
background.Colour = colours.Gray4;
background.Colour = colourProvider.Background3;
}
protected override bool OnHover(HoverEvent e)

View File

@ -56,7 +56,7 @@ namespace osu.Game.Overlays.Comments
public readonly BindableBool Active = new BindableBool();
[Resolved]
private OsuColour colours { get; set; }
private OverlayColourProvider colourProvider { get; set; }
private readonly SpriteText text;
@ -78,7 +78,7 @@ namespace osu.Game.Overlays.Comments
updateBackgroundState();
text.Font = text.Font.With(weight: active.NewValue ? FontWeight.Bold : FontWeight.Medium);
text.Colour = active.NewValue ? colours.BlueLighter : Color4.White;
text.Colour = active.NewValue ? colourProvider.Light1 : Color4.White;
}, true);
}

View File

@ -5,7 +5,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Framework.Graphics.Sprites;
using osuTK;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -17,9 +16,10 @@ namespace osu.Game.Overlays.Comments
{
public readonly BindableInt Current = new BindableInt();
private readonly SpriteText counter;
private OsuSpriteText counter;
public TotalCommentsCounter()
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
RelativeSizeAxes = Axes.X;
Height = 50;
@ -38,6 +38,7 @@ namespace osu.Game.Overlays.Comments
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Font = OsuFont.GetFont(size: 20, italics: true),
Colour = colourProvider.Light1,
Text = @"Comments"
},
new CircularContainer
@ -51,14 +52,15 @@ namespace osu.Game.Overlays.Comments
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(0.05f)
Colour = colourProvider.Background6
},
counter = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Margin = new MarginPadding { Horizontal = 10, Vertical = 5 },
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold)
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold),
Colour = colourProvider.Foreground1
}
},
}
@ -66,12 +68,6 @@ namespace osu.Game.Overlays.Comments
});
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
counter.Colour = colours.BlueLighter;
}
protected override void LoadComplete()
{
Current.BindValueChanged(value => counter.Text = value.NewValue.ToString("N0"), true);

View File

@ -84,14 +84,8 @@ namespace osu.Game.Overlays
}
public DirectOverlay()
: base(OverlayColourScheme.Blue)
{
// osu!direct colours are not part of the standard palette
Waves.FirstWaveColour = OsuColour.FromHex(@"19b0e2");
Waves.SecondWaveColour = OsuColour.FromHex(@"2280a2");
Waves.ThirdWaveColour = OsuColour.FromHex(@"005774");
Waves.FourthWaveColour = OsuColour.FromHex(@"003a4e");
ScrollFlow.Children = new Drawable[]
{
resultCountsContainer = new FillFlowContainer

View File

@ -6,7 +6,6 @@ using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Online.API;
using osuTK.Graphics;
@ -18,12 +17,12 @@ namespace osu.Game.Overlays
[Resolved]
protected IAPIProvider API { get; private set; }
protected FullscreenOverlay()
[Cached]
private readonly OverlayColourProvider colourProvider;
protected FullscreenOverlay(OverlayColourScheme colourScheme)
{
Waves.FirstWaveColour = OsuColour.Gray(0.4f);
Waves.SecondWaveColour = OsuColour.Gray(0.3f);
Waves.ThirdWaveColour = OsuColour.Gray(0.2f);
Waves.FourthWaveColour = OsuColour.Gray(0.1f);
colourProvider = new OverlayColourProvider(colourScheme);
RelativeSizeAxes = Axes.Both;
RelativePositionAxes = Axes.Both;
@ -41,6 +40,15 @@ namespace osu.Game.Overlays
};
}
[BackgroundDependencyLoader]
private void load()
{
Waves.FirstWaveColour = colourProvider.Light4;
Waves.SecondWaveColour = colourProvider.Light3;
Waves.ThirdWaveColour = colourProvider.Dark4;
Waves.FourthWaveColour = colourProvider.Dark3;
}
public override void Show()
{
if (State.Value == Visibility.Visible)

View File

@ -1,12 +1,8 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using System;
@ -23,11 +19,10 @@ namespace osu.Game.Overlays.News
public Action ShowFrontPage;
public NewsHeader()
: base(OverlayColourScheme.Purple)
{
BreadcrumbControl.AddItem(front_page_string);
TabControl.AddItem(front_page_string);
BreadcrumbControl.Current.ValueChanged += e =>
TabControl.Current.ValueChanged += e =>
{
if (e.NewValue == front_page_string)
ShowFrontPage?.Invoke();
@ -39,41 +34,26 @@ namespace osu.Game.Overlays.News
private void showPost(ValueChangedEvent<string> e)
{
if (e.OldValue != null)
BreadcrumbControl.RemoveItem(e.OldValue);
TabControl.RemoveItem(e.OldValue);
if (e.NewValue != null)
{
BreadcrumbControl.AddItem(e.NewValue);
BreadcrumbControl.Current.Value = e.NewValue;
TabControl.AddItem(e.NewValue);
TabControl.Current.Value = e.NewValue;
title.IsReadingPost = true;
}
else
{
BreadcrumbControl.Current.Value = front_page_string;
TabControl.Current.Value = front_page_string;
title.IsReadingPost = false;
}
}
protected override Drawable CreateBackground() => new NewsHeaderBackground();
protected override Drawable CreateBackground() => new OverlayHeaderBackground(@"Headers/news");
protected override ScreenTitle CreateTitle() => title = new NewsHeaderTitle();
private class NewsHeaderBackground : Sprite
{
public NewsHeaderBackground()
{
RelativeSizeAxes = Axes.Both;
FillMode = FillMode.Fill;
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
Texture = textures.Get(@"Headers/news");
}
}
private class NewsHeaderTitle : ScreenTitle
{
private const string post_string = "post";

View File

@ -21,6 +21,11 @@ namespace osu.Game.Overlays
public readonly Bindable<string> Current = new Bindable<string>(null);
public NewsOverlay()
: base(OverlayColourScheme.Purple)
{
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{

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 osuTK;
using osuTK.Graphics;
namespace osu.Game.Overlays
{
public class OverlayColourProvider
{
private readonly OverlayColourScheme colourScheme;
public OverlayColourProvider(OverlayColourScheme colourScheme)
{
this.colourScheme = colourScheme;
}
public Color4 Highlight1 => getColour(1, 0.7f);
public Color4 Content1 => getColour(0.4f, 1);
public Color4 Content2 => getColour(0.4f, 0.9f);
public Color4 Light1 => getColour(0.4f, 0.8f);
public Color4 Light2 => getColour(0.4f, 0.75f);
public Color4 Light3 => getColour(0.4f, 0.7f);
public Color4 Light4 => getColour(0.4f, 0.5f);
public Color4 Dark1 => getColour(0.2f, 0.35f);
public Color4 Dark2 => getColour(0.2f, 0.3f);
public Color4 Dark3 => getColour(0.2f, 0.25f);
public Color4 Dark4 => getColour(0.2f, 0.2f);
public Color4 Dark5 => getColour(0.2f, 0.15f);
public Color4 Dark6 => getColour(0.2f, 0.1f);
public Color4 Foreground1 => getColour(0.1f, 0.6f);
public Color4 Background1 => getColour(0.1f, 0.4f);
public Color4 Background2 => getColour(0.1f, 0.3f);
public Color4 Background3 => getColour(0.1f, 0.25f);
public Color4 Background4 => getColour(0.1f, 0.2f);
public Color4 Background5 => getColour(0.1f, 0.15f);
public Color4 Background6 => getColour(0.1f, 0.1f);
private Color4 getColour(float saturation, float lightness) => Color4.FromHsl(new Vector4(getBaseHue(colourScheme), saturation, lightness, 1));
// See https://github.com/ppy/osu-web/blob/4218c288292d7c810b619075471eaea8bbb8f9d8/app/helpers.php#L1463
private static float getBaseHue(OverlayColourScheme colourScheme)
{
switch (colourScheme)
{
default:
throw new ArgumentException($@"{colourScheme} colour scheme does not provide a hue value in {nameof(getBaseHue)}.");
case OverlayColourScheme.Red:
return 0;
case OverlayColourScheme.Pink:
return 333 / 360f;
case OverlayColourScheme.Orange:
return 46 / 360f;
case OverlayColourScheme.Green:
return 115 / 360f;
case OverlayColourScheme.Purple:
return 255 / 360f;
case OverlayColourScheme.Blue:
return 200 / 360f;
}
}
}
public enum OverlayColourScheme
{
Red,
Pink,
Orange,
Green,
Purple,
Blue
}
}

View File

@ -6,8 +6,6 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osuTK.Graphics;
@ -16,21 +14,12 @@ namespace osu.Game.Overlays
public abstract class OverlayHeader : Container
{
private readonly Box titleBackground;
private readonly Box controlBackground;
private readonly Container background;
private readonly ScreenTitle title;
protected float BackgroundHeight
protected readonly FillFlowContainer HeaderInfo;
protected OverlayHeader()
{
set => background.Height = value;
}
protected OverlayColourScheme ColourScheme { get; }
protected OverlayHeader(OverlayColourScheme colourScheme)
{
ColourScheme = colourScheme;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
@ -41,46 +30,36 @@ namespace osu.Game.Overlays
Direction = FillDirection.Vertical,
Children = new[]
{
background = new Container
{
RelativeSizeAxes = Axes.X,
Height = 80,
Masking = true,
Child = CreateBackground()
},
new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
titleBackground = new Box
{
RelativeSizeAxes = Axes.Both,
},
title = CreateTitle().With(title =>
{
title.Margin = new MarginPadding
{
Vertical = 10,
Left = UserProfileOverlay.CONTENT_X_MARGIN
};
})
}
},
new Container
HeaderInfo = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Depth = -float.MaxValue,
Children = new Drawable[]
Children = new[]
{
controlBackground = new Box
CreateBackground(),
new Container
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Gray,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
titleBackground = new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Gray,
},
title = CreateTitle().With(title =>
{
title.Margin = new MarginPadding
{
Vertical = 10,
Left = UserProfileOverlay.CONTENT_X_MARGIN
};
})
}
},
CreateTabControl().With(control => control.Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN })
}
},
CreateContent()
@ -89,20 +68,18 @@ namespace osu.Game.Overlays
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
private void load(OverlayColourProvider colourProvider)
{
titleBackground.Colour = colours.ForOverlayElement(ColourScheme, 0.2f, 0.15f);
title.AccentColour = colours.ForOverlayElement(ColourScheme, 1, 0.7f);
controlBackground.Colour = colours.ForOverlayElement(ColourScheme, 0.2f, 0.2f);
titleBackground.Colour = colourProvider.Dark5;
title.AccentColour = colourProvider.Highlight1;
}
protected abstract Drawable CreateBackground();
[NotNull]
protected virtual Drawable CreateContent() => Drawable.Empty();
[NotNull]
protected virtual Drawable CreateContent() => new Container();
protected virtual Drawable CreateBackground() => Drawable.Empty();
protected abstract ScreenTitle CreateTitle();
protected abstract TabControl<string> CreateTabControl();
}
}

View File

@ -0,0 +1,43 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
namespace osu.Game.Overlays
{
public class OverlayHeaderBackground : CompositeDrawable
{
public OverlayHeaderBackground(string textureName)
{
Height = 80;
RelativeSizeAxes = Axes.X;
Masking = true;
InternalChild = new Background(textureName);
}
private class Background : Sprite
{
private readonly string textureName;
public Background(string textureName)
{
this.textureName = textureName;
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
RelativeSizeAxes = Axes.Both;
FillMode = FillMode.Fill;
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
Texture = textures.Get(textureName);
}
}
}
}

View File

@ -13,41 +13,25 @@ using osuTK.Graphics;
namespace osu.Game.Overlays
{
public abstract class OverlayTabControl<T> : TabControl<T>
public abstract class OverlayTabControl<T> : OsuTabControl<T>
{
private readonly Box bar;
private Color4 accentColour = Color4.White;
public Color4 AccentColour
{
get => accentColour;
set
{
if (accentColour == value)
return;
accentColour = value;
bar.Colour = value;
foreach (TabItem<T> tabItem in TabContainer)
{
((OverlayTabItem)tabItem).AccentColour = value;
}
}
}
public new MarginPadding Padding
{
get => TabContainer.Padding;
set => TabContainer.Padding = value;
}
protected float BarHeight
{
set => bar.Height = value;
}
public override Color4 AccentColour
{
get => base.AccentColour;
set
{
base.AccentColour = value;
bar.Colour = value;
}
}
protected OverlayTabControl()
{
TabContainer.Masking = false;
@ -66,7 +50,7 @@ namespace osu.Game.Overlays
protected override TabItem<T> CreateTabItem(T value) => new OverlayTabItem(value);
protected class OverlayTabItem : TabItem<T>
protected class OverlayTabItem : TabItem<T>, IHasAccentColour
{
protected readonly ExpandingBar Bar;
protected readonly OsuSpriteText Text;

View File

@ -14,7 +14,7 @@ using osu.Game.Users;
namespace osu.Game.Overlays.Profile
{
public class ProfileHeader : TabControlOverlayHeader
public class ProfileHeader : TabControlOverlayHeader<string>
{
private UserCoverBackground coverContainer;
@ -24,10 +24,7 @@ namespace osu.Game.Overlays.Profile
private DetailHeaderContainer detailHeaderContainer;
public ProfileHeader()
: base(OverlayColourScheme.Green)
{
BackgroundHeight = 150;
User.ValueChanged += e => updateDisplay(e.NewValue);
TabControl.AddItem("info");
@ -39,7 +36,9 @@ namespace osu.Game.Overlays.Profile
protected override Drawable CreateBackground() =>
new Container
{
RelativeSizeAxes = Axes.Both,
RelativeSizeAxes = Axes.X,
Height = 150,
Masking = true,
Children = new Drawable[]
{
coverContainer = new UserCoverBackground

View File

@ -25,7 +25,6 @@ namespace osu.Game.Overlays
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
private readonly BasicScrollContainer scrollFlow;
private readonly Box background;
private readonly Container tableContainer;
private readonly DimmedLoadingLayer loading;
@ -36,12 +35,14 @@ namespace osu.Game.Overlays
private IAPIProvider api { get; set; }
public RankingsOverlay()
: base(OverlayColourScheme.Green)
{
Children = new Drawable[]
{
background = new Box
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = OsuColour.Gray(0.1f),
},
scrollFlow = new BasicScrollContainer
{
@ -85,17 +86,6 @@ namespace osu.Game.Overlays
};
}
[BackgroundDependencyLoader]
private void load(OsuColour colour)
{
Waves.FirstWaveColour = colour.Green;
Waves.SecondWaveColour = colour.GreenLight;
Waves.ThirdWaveColour = colour.GreenDark;
Waves.FourthWaveColour = colour.GreenDarker;
background.Colour = OsuColour.Gray(0.1f);
}
protected override void LoadComplete()
{
Country.BindValueChanged(_ =>

View File

@ -16,6 +16,11 @@ namespace osu.Game.Overlays.SearchableList
public abstract class SearchableListOverlay : FullscreenOverlay
{
public const float WIDTH_PADDING = 80;
protected SearchableListOverlay(OverlayColourScheme colourScheme)
: base(colourScheme)
{
}
}
public abstract class SearchableListOverlay<THeader, TTab, TCategory> : SearchableListOverlay
@ -35,7 +40,8 @@ namespace osu.Game.Overlays.SearchableList
protected abstract SearchableListHeader<THeader> CreateHeader();
protected abstract SearchableListFilterControl<TTab, TCategory> CreateFilterControl();
protected SearchableListOverlay()
protected SearchableListOverlay(OverlayColourScheme colourScheme)
: base(colourScheme)
{
Children = new Drawable[]
{

View File

@ -17,10 +17,34 @@ namespace osu.Game.Overlays.Settings.Sections.Audio
{
Children = new Drawable[]
{
new SettingsSlider<double> { LabelText = "Master", Bindable = audio.Volume, KeyboardStep = 0.01f },
new SettingsSlider<double> { LabelText = "Master (window inactive)", Bindable = config.GetBindable<double>(OsuSetting.VolumeInactive), KeyboardStep = 0.01f },
new SettingsSlider<double> { LabelText = "Effect", Bindable = audio.VolumeSample, KeyboardStep = 0.01f },
new SettingsSlider<double> { LabelText = "Music", Bindable = audio.VolumeTrack, KeyboardStep = 0.01f },
new SettingsSlider<double>
{
LabelText = "Master",
Bindable = audio.Volume,
KeyboardStep = 0.01f,
DisplayAsPercentage = true
},
new SettingsSlider<double>
{
LabelText = "Master (window inactive)",
Bindable = config.GetBindable<double>(OsuSetting.VolumeInactive),
KeyboardStep = 0.01f,
DisplayAsPercentage = true
},
new SettingsSlider<double>
{
LabelText = "Effect",
Bindable = audio.VolumeSample,
KeyboardStep = 0.01f,
DisplayAsPercentage = true
},
new SettingsSlider<double>
{
LabelText = "Music",
Bindable = audio.VolumeTrack,
KeyboardStep = 0.01f,
DisplayAsPercentage = true
},
};
}
}

View File

@ -21,13 +21,15 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
{
LabelText = "Background dim",
Bindable = config.GetBindable<double>(OsuSetting.DimLevel),
KeyboardStep = 0.01f
KeyboardStep = 0.01f,
DisplayAsPercentage = true
},
new SettingsSlider<double>
{
LabelText = "Background blur",
Bindable = config.GetBindable<double>(OsuSetting.BlurLevel),
KeyboardStep = 0.01f
KeyboardStep = 0.01f,
DisplayAsPercentage = true
},
new SettingsCheckbox
{

View File

@ -98,25 +98,29 @@ namespace osu.Game.Overlays.Settings.Sections.Graphics
{
LabelText = "Horizontal position",
Bindable = scalingPositionX,
KeyboardStep = 0.01f
KeyboardStep = 0.01f,
DisplayAsPercentage = true
},
new SettingsSlider<float>
{
LabelText = "Vertical position",
Bindable = scalingPositionY,
KeyboardStep = 0.01f
KeyboardStep = 0.01f,
DisplayAsPercentage = true
},
new SettingsSlider<float>
{
LabelText = "Horizontal scale",
Bindable = scalingSizeX,
KeyboardStep = 0.01f
KeyboardStep = 0.01f,
DisplayAsPercentage = true
},
new SettingsSlider<float>
{
LabelText = "Vertical scale",
Bindable = scalingSizeY,
KeyboardStep = 0.01f
KeyboardStep = 0.01f,
DisplayAsPercentage = true
},
}
},

View File

@ -3,6 +3,7 @@
using System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics.UserInterface;
namespace osu.Game.Overlays.Settings
@ -22,16 +23,32 @@ namespace osu.Game.Overlays.Settings
RelativeSizeAxes = Axes.X
};
/// <summary>
/// When set, value changes based on user input are only transferred to any bound control's Current on commit.
/// This is useful if the UI interaction could be adversely affected by the value changing, such as the position of the <see cref="SliderBar{T}"/> on the screen.
/// </summary>
public bool TransferValueOnCommit
{
get => ((TSlider)Control).TransferValueOnCommit;
set => ((TSlider)Control).TransferValueOnCommit = value;
}
/// <summary>
/// A custom step value for each key press which actuates a change on this control.
/// </summary>
public float KeyboardStep
{
get => ((TSlider)Control).KeyboardStep;
set => ((TSlider)Control).KeyboardStep = value;
}
/// <summary>
/// Whether to format the tooltip as a percentage or the actual value.
/// </summary>
public bool DisplayAsPercentage
{
get => ((TSlider)Control).DisplayAsPercentage;
set => ((TSlider)Control).DisplayAsPercentage = value;
}
}
}

View File

@ -52,12 +52,8 @@ namespace osu.Game.Overlays
}
public SocialOverlay()
: base(OverlayColourScheme.Pink)
{
Waves.FirstWaveColour = OsuColour.FromHex(@"cb5fa0");
Waves.SecondWaveColour = OsuColour.FromHex(@"b04384");
Waves.ThirdWaveColour = OsuColour.FromHex(@"9b2b6e");
Waves.FourthWaveColour = OsuColour.FromHex(@"6d214d");
Add(loading = new LoadingAnimation());
Filter.Search.Current.ValueChanged += text =>

View File

@ -1,33 +1,56 @@
// 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 JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osuTK;
namespace osu.Game.Overlays
{
public abstract class TabControlOverlayHeader : OverlayHeader
/// <summary>
/// An overlay header which contains a <see cref="OsuTabControl{T}"/>.
/// </summary>
/// <typeparam name="T">The type of item to be represented by tabs.</typeparam>
public abstract class TabControlOverlayHeader<T> : OverlayHeader
{
protected OverlayHeaderTabControl TabControl;
protected OsuTabControl<T> TabControl;
protected override TabControl<string> CreateTabControl() => TabControl = new OverlayHeaderTabControl();
private readonly Box controlBackground;
protected TabControlOverlayHeader(OverlayColourScheme colourScheme)
: base(colourScheme)
protected TabControlOverlayHeader()
{
HeaderInfo.Add(new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
controlBackground = new Box
{
RelativeSizeAxes = Axes.Both,
},
TabControl = CreateTabControl().With(control => control.Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN })
}
});
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
private void load(OverlayColourProvider colourProvider)
{
TabControl.AccentColour = colours.ForOverlayElement(ColourScheme, 1, 0.75f);
TabControl.AccentColour = colourProvider.Highlight1;
controlBackground.Colour = colourProvider.Dark4;
}
public class OverlayHeaderTabControl : OverlayTabControl<string>
[NotNull]
protected virtual OsuTabControl<T> CreateTabControl() => new OverlayHeaderTabControl();
public class OverlayHeaderTabControl : OverlayTabControl<T>
{
public OverlayHeaderTabControl()
{
@ -39,10 +62,7 @@ namespace osu.Game.Overlays
Height = 35;
}
protected override TabItem<string> CreateTabItem(string value) => new OverlayHeaderTabItem(value)
{
AccentColour = AccentColour,
};
protected override TabItem<T> CreateTabItem(T value) => new OverlayHeaderTabItem(value);
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
{
@ -54,10 +74,10 @@ namespace osu.Game.Overlays
private class OverlayHeaderTabItem : OverlayTabItem
{
public OverlayHeaderTabItem(string value)
public OverlayHeaderTabItem(T value)
: base(value)
{
Text.Text = value;
Text.Text = value.ToString().ToLower();
Text.Font = OsuFont.GetFont(size: 14);
Bar.ExpandedSize = 5;
}

View File

@ -29,6 +29,11 @@ namespace osu.Game.Overlays
public const float CONTENT_X_MARGIN = 70;
public UserProfileOverlay()
: base(OverlayColourScheme.Green)
{
}
public void ShowUser(long userId) => ShowUser(new User { Id = userId });
public void ShowUser(User user, bool fetchOnline = 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

@ -52,30 +52,52 @@ namespace osu.Game.Screens.Edit
{
switch (beatDivisor)
{
case 1:
return Color4.White;
case 2:
return colours.BlueLight;
return colours.Red;
case 4:
return colours.Blue;
case 8:
return colours.BlueDarker;
return colours.Yellow;
case 16:
return colours.PurpleDark;
case 3:
return colours.YellowLight;
return colours.Purple;
case 6:
return colours.Yellow;
return colours.YellowDark;
case 12:
return colours.YellowDarker;
default:
return Color4.White;
return Color4.Red;
}
}
/// <summary>
/// Retrieves the applicable divisor for a specific beat index.
/// </summary>
/// <param name="index">The 0-based beat index.</param>
/// <param name="beatDivisor">The beat divisor.</param>
/// <returns>The applicable divisor.</returns>
public static int GetDivisorForBeatIndex(int index, int beatDivisor)
{
int beat = index % beatDivisor;
foreach (var divisor in BindableBeatDivisor.VALID_DIVISORS)
{
if ((beat * divisor) % beatDivisor == 0)
return divisor;
}
return 0;
}
}
}

View File

@ -12,7 +12,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations
/// </summary>
public class PointVisualisation : Box
{
protected PointVisualisation(double startTime)
public PointVisualisation(double startTime)
{
Origin = Anchor.TopCentre;

View File

@ -130,19 +130,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// <returns>The applicable colour.</returns>
protected ColourInfo GetColourForBeatIndex(int index)
{
int beat = (index + 1) % beatDivisor.Value;
ColourInfo colour = Colours.Gray5;
for (int i = 0; i < BindableBeatDivisor.VALID_DIVISORS.Length; i++)
{
int divisor = BindableBeatDivisor.VALID_DIVISORS[i];
if ((beat * divisor) % beatDivisor.Value == 0)
{
colour = BindableBeatDivisor.GetColourFor(divisor, Colours);
break;
}
}
var colour = BindableBeatDivisor.GetColourFor(BindableBeatDivisor.GetDivisorForBeatIndex(index + 1, beatDivisor.Value), Colours);
int repeatIndex = index / beatDivisor.Value;
return colour.MultiplyAlpha(0.5f / (repeatIndex + 1));

View File

@ -30,7 +30,10 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
{
ZoomDuration = 200;
ZoomEasing = Easing.OutQuint;
Zoom = 10;
Zoom = 60;
MaxZoom = 240;
ScrollbarVisible = false;
}

View File

@ -0,0 +1,90 @@
// 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.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts;
using osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations;
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
{
public class TimelineTickDisplay : TimelinePart
{
[Resolved]
private EditorBeatmap beatmap { get; set; }
[Resolved]
private Bindable<WorkingBeatmap> working { get; set; }
[Resolved]
private BindableBeatDivisor beatDivisor { get; set; }
[Resolved]
private OsuColour colours { get; set; }
public TimelineTickDisplay()
{
RelativeSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load()
{
beatDivisor.BindValueChanged(_ => createLines(), true);
}
private void createLines()
{
Clear();
for (var i = 0; i < beatmap.ControlPointInfo.TimingPoints.Count; i++)
{
var point = beatmap.ControlPointInfo.TimingPoints[i];
var until = beatmap.ControlPointInfo.TimingPoints.Count < i + 1 ? beatmap.ControlPointInfo.TimingPoints[i + 1].Time : working.Value.Track.Length;
int beat = 0;
for (double t = point.Time; t < until; t += point.BeatLength / beatDivisor.Value)
{
var indexInBeat = beat % beatDivisor.Value;
if (indexInBeat == 0)
{
Add(new PointVisualisation(t)
{
Colour = BindableBeatDivisor.GetColourFor(1, colours),
Origin = Anchor.TopCentre,
});
}
else
{
var divisor = BindableBeatDivisor.GetDivisorForBeatIndex(beat, beatDivisor.Value);
var colour = BindableBeatDivisor.GetColourFor(divisor, colours);
var height = 0.1f - (float)divisor / BindableBeatDivisor.VALID_DIVISORS.Last() * 0.08f;
Add(new PointVisualisation(t)
{
Colour = colour,
Height = height,
Origin = Anchor.TopCentre,
});
Add(new PointVisualisation(t)
{
Colour = colour,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomCentre,
Height = height,
});
}
beat++;
}
}
}
}
}

View File

@ -102,7 +102,11 @@ namespace osu.Game.Screens.Edit
LoadComponentAsync(new TimelineArea
{
RelativeSizeAxes = Axes.Both,
Child = CreateTimelineContent()
Children = new[]
{
new TimelineTickDisplay(),
CreateTimelineContent(),
}
}, timelineContainer.Add);
});
}

View File

@ -27,12 +27,18 @@ namespace osu.Game.Screens.Play.PlayerSettings
{
Text = "Background dim:"
},
dimSliderBar = new PlayerSliderBar<double>(),
dimSliderBar = new PlayerSliderBar<double>
{
DisplayAsPercentage = true
},
new OsuSpriteText
{
Text = "Background blur:"
},
blurSliderBar = new PlayerSliderBar<double>(),
blurSliderBar = new PlayerSliderBar<double>
{
DisplayAsPercentage = true
},
new OsuSpriteText
{
Text = "Toggles:"

View File

@ -56,6 +56,9 @@ namespace osu.Game.Screens.Select
public override bool HandleNonPositionalInput => AllowSelection;
public override bool HandlePositionalInput => AllowSelection;
public override bool PropagatePositionalInputSubTree => AllowSelection;
public override bool PropagateNonPositionalInputSubTree => AllowSelection;
/// <summary>
/// Whether carousel items have completed asynchronously loaded.
/// </summary>
@ -449,8 +452,6 @@ namespace osu.Game.Screens.Select
return true;
}
protected override bool ReceivePositionalInputAtSubTree(Vector2 screenSpacePos) => ReceivePositionalInputAt(screenSpacePos);
protected override void Update()
{
base.Update();

View File

@ -117,9 +117,20 @@ namespace osu.Game.Screens.Select.Details
mod.ApplyToDifficulty(adjustedDifficulty);
}
// Account for mania differences
firstValue.Title = (Beatmap?.Ruleset?.ID ?? 0) == 3 ? "Key Amount" : "Circle Size";
firstValue.Value = (baseDifficulty?.CircleSize ?? 0, adjustedDifficulty?.CircleSize);
switch (Beatmap?.Ruleset?.ID ?? 0)
{
case 3:
// Account for mania differences locally for now
// Eventually this should be handled in a more modular way, allowing rulesets to return arbitrary difficulty attributes
firstValue.Title = "Key Count";
firstValue.Value = (baseDifficulty?.CircleSize ?? 0, null);
break;
default:
firstValue.Title = "Circle Size";
firstValue.Value = (baseDifficulty?.CircleSize ?? 0, adjustedDifficulty?.CircleSize);
break;
}
starDifficulty.Value = ((float)(Beatmap?.StarDifficulty ?? 0), null);

View File

@ -8,6 +8,7 @@ using osu.Framework.Testing.Input;
using osu.Game.Graphics.Cursor;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Input.Bindings;
using osuTK;
using osuTK.Graphics;
@ -30,7 +31,11 @@ namespace osu.Game.Tests.Visual
InputManager = new ManualInputManager
{
UseParentInput = true,
Child = content = new MenuCursorContainer { RelativeSizeAxes = Axes.Both },
Child = new GlobalActionContainer(null)
{
RelativeSizeAxes = Axes.Both,
Child = content = new MenuCursorContainer { RelativeSizeAxes = Axes.Both }
},
},
new Container
{

View File

@ -1,4 +1,4 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Efnt/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Emp3/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Epng/@EntryIndexedValue">True</s:Boolean>
@ -245,7 +245,7 @@
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_WHILE/@EntryValue">RequiredForMultiline</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/DEFAULT_INTERNAL_MODIFIER/@EntryValue">Explicit</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/LOCAL_FUNCTION_BODY/@EntryValue">ExpressionBody</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/METHOD_OR_OPERATOR_BODY/@EntryValue">ExpressionBody</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/METHOD_OR_OPERATOR_BODY/@EntryValue">BlockBody</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/USE_HEURISTICS_FOR_BODY_STYLE/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ACCESSOR_DECLARATION_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_LINQ_QUERY/@EntryValue">True</s:Boolean>
@ -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>