mirror of
https://github.com/ppy/osu
synced 2024-12-15 03:16:17 +00:00
Merge branch 'master' into fix-beatmap-skin-disables
This commit is contained in:
commit
266c1e2e25
@ -52,6 +52,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.525.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.608.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.609.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -71,7 +71,7 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
|
||||
{
|
||||
isLegacySkin = new Lazy<bool>(() => FindProvider(s => s.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version) != null) != null);
|
||||
hasKeyTexture = new Lazy<bool>(() => FindProvider(s => s.GetAnimation(
|
||||
this.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.KeyImage, 0)?.Value
|
||||
s.GetManiaSkinConfig<string>(LegacyManiaSkinConfigurationLookups.KeyImage, 0)?.Value
|
||||
?? "mania-key1", true, true) != null) != null);
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,6 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
||||
{
|
||||
public class MainCirclePiece : CompositeDrawable
|
||||
{
|
||||
public override bool RemoveCompletedTransforms => false;
|
||||
|
||||
private readonly CirclePiece circle;
|
||||
private readonly RingPiece ring;
|
||||
private readonly FlashPiece flash;
|
||||
@ -44,7 +42,6 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
||||
|
||||
private readonly IBindable<Color4> accentColour = new Bindable<Color4>();
|
||||
private readonly IBindable<int> indexInCurrentCombo = new Bindable<int>();
|
||||
private readonly IBindable<ArmedState> armedState = new Bindable<ArmedState>();
|
||||
|
||||
[Resolved]
|
||||
private DrawableHitObject drawableObject { get; set; }
|
||||
@ -56,7 +53,6 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
||||
|
||||
accentColour.BindTo(drawableObject.AccentColour);
|
||||
indexInCurrentCombo.BindTo(drawableOsuObject.IndexInCurrentComboBindable);
|
||||
armedState.BindTo(drawableObject.State);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -72,19 +68,18 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
||||
|
||||
indexInCurrentCombo.BindValueChanged(index => number.Text = (index.NewValue + 1).ToString(), true);
|
||||
|
||||
armedState.BindValueChanged(animate, true);
|
||||
drawableObject.ApplyCustomUpdateState += updateStateTransforms;
|
||||
updateStateTransforms(drawableObject, drawableObject.State.Value);
|
||||
}
|
||||
|
||||
private void animate(ValueChangedEvent<ArmedState> state)
|
||||
private void updateStateTransforms(DrawableHitObject drawableHitObject, ArmedState state)
|
||||
{
|
||||
ClearTransforms(true);
|
||||
|
||||
using (BeginAbsoluteSequence(drawableObject.StateUpdateTime))
|
||||
glow.FadeOut(400);
|
||||
|
||||
using (BeginAbsoluteSequence(drawableObject.HitStateUpdateTime))
|
||||
{
|
||||
switch (state.NewValue)
|
||||
switch (state)
|
||||
{
|
||||
case ArmedState.Hit:
|
||||
const double flash_in = 40;
|
||||
@ -111,5 +106,13 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
if (drawableObject != null)
|
||||
drawableObject.ApplyCustomUpdateState -= updateStateTransforms;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,6 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
|
||||
private readonly Bindable<Color4> accentColour = new Bindable<Color4>();
|
||||
private readonly IBindable<int> indexInCurrentCombo = new Bindable<int>();
|
||||
private readonly IBindable<ArmedState> armedState = new Bindable<ArmedState>();
|
||||
|
||||
[Resolved]
|
||||
private DrawableHitObject drawableObject { get; set; }
|
||||
@ -116,7 +115,6 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
|
||||
accentColour.BindTo(drawableObject.AccentColour);
|
||||
indexInCurrentCombo.BindTo(drawableOsuObject.IndexInCurrentComboBindable);
|
||||
armedState.BindTo(drawableObject.State);
|
||||
|
||||
Texture getTextureWithFallback(string name)
|
||||
{
|
||||
@ -142,18 +140,17 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
if (hasNumber)
|
||||
indexInCurrentCombo.BindValueChanged(index => hitCircleText.Text = (index.NewValue + 1).ToString(), true);
|
||||
|
||||
armedState.BindValueChanged(animate, true);
|
||||
drawableObject.ApplyCustomUpdateState += updateStateTransforms;
|
||||
updateStateTransforms(drawableObject, drawableObject.State.Value);
|
||||
}
|
||||
|
||||
private void animate(ValueChangedEvent<ArmedState> state)
|
||||
private void updateStateTransforms(DrawableHitObject drawableHitObject, ArmedState state)
|
||||
{
|
||||
const double legacy_fade_duration = 240;
|
||||
|
||||
ClearTransforms(true);
|
||||
|
||||
using (BeginAbsoluteSequence(drawableObject.HitStateUpdateTime))
|
||||
{
|
||||
switch (state.NewValue)
|
||||
switch (state)
|
||||
{
|
||||
case ArmedState.Hit:
|
||||
circleSprites.FadeOut(legacy_fade_duration, Easing.Out);
|
||||
@ -178,5 +175,13 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
if (drawableObject != null)
|
||||
drawableObject.ApplyCustomUpdateState -= updateStateTransforms;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
@ -11,6 +12,7 @@ using osu.Game.Graphics.Backgrounds;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Backgrounds;
|
||||
using osu.Game.Skinning;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Background
|
||||
@ -23,6 +25,9 @@ namespace osu.Game.Tests.Visual.Background
|
||||
|
||||
private Graphics.Backgrounds.Background getCurrentBackground() => screen.ChildrenOfType<Graphics.Backgrounds.Background>().FirstOrDefault();
|
||||
|
||||
[Resolved]
|
||||
private SkinManager skins { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private OsuConfigManager config { get; set; }
|
||||
|
||||
@ -35,7 +40,7 @@ namespace osu.Game.Tests.Visual.Background
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTogglingStoryboardSwitchesBackgroundType()
|
||||
public void TestBackgroundTypeSwitch()
|
||||
{
|
||||
setSupporter(true);
|
||||
|
||||
@ -44,6 +49,12 @@ namespace osu.Game.Tests.Visual.Background
|
||||
|
||||
setSourceMode(BackgroundSource.BeatmapWithStoryboard);
|
||||
AddUntilStep("is storyboard background", () => getCurrentBackground() is BeatmapBackgroundWithStoryboard);
|
||||
|
||||
setSourceMode(BackgroundSource.Skin);
|
||||
AddUntilStep("is default background", () => getCurrentBackground().GetType() == typeof(Graphics.Backgrounds.Background));
|
||||
|
||||
setCustomSkin();
|
||||
AddUntilStep("is skin background", () => getCurrentBackground() is SkinBackground);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -61,15 +72,19 @@ namespace osu.Game.Tests.Visual.Background
|
||||
AddUntilStep("is beatmap background", () => getCurrentBackground() is BeatmapBackground);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBeatmapDoesntReloadOnNoChange()
|
||||
[TestCase(BackgroundSource.Beatmap, typeof(BeatmapBackground))]
|
||||
[TestCase(BackgroundSource.BeatmapWithStoryboard, typeof(BeatmapBackgroundWithStoryboard))]
|
||||
[TestCase(BackgroundSource.Skin, typeof(SkinBackground))]
|
||||
public void TestBackgroundDoesntReloadOnNoChange(BackgroundSource source, Type backgroundType)
|
||||
{
|
||||
BeatmapBackground last = null;
|
||||
Graphics.Backgrounds.Background last = null;
|
||||
|
||||
setSourceMode(BackgroundSource.Beatmap);
|
||||
setSourceMode(source);
|
||||
setSupporter(true);
|
||||
if (source == BackgroundSource.Skin)
|
||||
setCustomSkin();
|
||||
|
||||
AddUntilStep("wait for beatmap background to be loaded", () => (last = getCurrentBackground() as BeatmapBackground) != null);
|
||||
AddUntilStep("wait for beatmap background to be loaded", () => (last = getCurrentBackground())?.GetType() == backgroundType);
|
||||
AddAssert("next doesn't load new background", () => screen.Next() == false);
|
||||
|
||||
// doesn't really need to be checked but might as well.
|
||||
@ -77,8 +92,25 @@ namespace osu.Game.Tests.Visual.Background
|
||||
AddUntilStep("ensure same background instance", () => last == getCurrentBackground());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBackgroundCyclingOnDefaultSkin([Values] bool supporter)
|
||||
{
|
||||
Graphics.Backgrounds.Background last = null;
|
||||
|
||||
setSourceMode(BackgroundSource.Skin);
|
||||
setSupporter(supporter);
|
||||
setDefaultSkin();
|
||||
|
||||
AddUntilStep("wait for beatmap background to be loaded", () => (last = getCurrentBackground())?.GetType() == typeof(Graphics.Backgrounds.Background));
|
||||
AddAssert("next cycles background", () => screen.Next());
|
||||
|
||||
// doesn't really need to be checked but might as well.
|
||||
AddWaitStep("wait a bit", 5);
|
||||
AddUntilStep("ensure different background instance", () => last != getCurrentBackground());
|
||||
}
|
||||
|
||||
private void setSourceMode(BackgroundSource source) =>
|
||||
AddStep("set background mode to beatmap", () => config.SetValue(OsuSetting.MenuBackgroundSource, source));
|
||||
AddStep($"set background mode to {source}", () => config.SetValue(OsuSetting.MenuBackgroundSource, source));
|
||||
|
||||
private void setSupporter(bool isSupporter) =>
|
||||
AddStep($"set supporter {isSupporter}", () => ((DummyAPIAccess)API).LocalUser.Value = new User
|
||||
@ -86,5 +118,16 @@ namespace osu.Game.Tests.Visual.Background
|
||||
IsSupporter = isSupporter,
|
||||
Id = API.LocalUser.Value.Id + 1,
|
||||
});
|
||||
|
||||
private void setCustomSkin()
|
||||
{
|
||||
// feign a skin switch. this doesn't do anything except force CurrentSkin to become a LegacySkin.
|
||||
AddStep("set custom skin", () => skins.CurrentSkinInfo.Value = new SkinInfo { ID = 5 });
|
||||
}
|
||||
|
||||
private void setDefaultSkin() => AddStep("set default skin", () => skins.CurrentSkinInfo.SetDefault());
|
||||
|
||||
[TearDownSteps]
|
||||
public void TearDown() => setDefaultSkin();
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +109,34 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
meter => meter.ChildrenOfType<ColourHitErrorMeter.HitErrorCircle>().Count() == 2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBonus()
|
||||
{
|
||||
AddStep("OD 1", () => recreateDisplay(new OsuHitWindows(), 1));
|
||||
|
||||
AddStep("small bonus", () => newJudgement(result: HitResult.SmallBonus));
|
||||
AddAssert("no bars added", () => !this.ChildrenOfType<BarHitErrorMeter.JudgementLine>().Any());
|
||||
AddAssert("no circle added", () => !this.ChildrenOfType<ColourHitErrorMeter.HitErrorCircle>().Any());
|
||||
|
||||
AddStep("large bonus", () => newJudgement(result: HitResult.LargeBonus));
|
||||
AddAssert("no bars added", () => !this.ChildrenOfType<BarHitErrorMeter.JudgementLine>().Any());
|
||||
AddAssert("no circle added", () => !this.ChildrenOfType<ColourHitErrorMeter.HitErrorCircle>().Any());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestIgnore()
|
||||
{
|
||||
AddStep("OD 1", () => recreateDisplay(new OsuHitWindows(), 1));
|
||||
|
||||
AddStep("ignore hit", () => newJudgement(result: HitResult.IgnoreHit));
|
||||
AddAssert("no bars added", () => !this.ChildrenOfType<BarHitErrorMeter.JudgementLine>().Any());
|
||||
AddAssert("no circle added", () => !this.ChildrenOfType<ColourHitErrorMeter.HitErrorCircle>().Any());
|
||||
|
||||
AddStep("ignore miss", () => newJudgement(result: HitResult.IgnoreMiss));
|
||||
AddAssert("no bars added", () => !this.ChildrenOfType<BarHitErrorMeter.JudgementLine>().Any());
|
||||
AddAssert("no circle added", () => !this.ChildrenOfType<ColourHitErrorMeter.HitErrorCircle>().Any());
|
||||
}
|
||||
|
||||
private void recreateDisplay(HitWindows hitWindows, float overallDifficulty)
|
||||
{
|
||||
hitWindows?.SetDifficulty(overallDifficulty);
|
||||
|
File diff suppressed because one or more lines are too long
65
osu.Game.Tests/Visual/Online/TestSceneWikiSidebar.cs
Normal file
65
osu.Game.Tests/Visual/Online/TestSceneWikiSidebar.cs
Normal file
@ -0,0 +1,65 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using Markdig.Parsers;
|
||||
using Markdig.Syntax;
|
||||
using Markdig.Syntax.Inlines;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Graphics.Containers.Markdown;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Wiki;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneWikiSidebar : OsuTestScene
|
||||
{
|
||||
[Cached]
|
||||
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Orange);
|
||||
|
||||
[Cached]
|
||||
private readonly OverlayScrollContainer scrollContainer = new OverlayScrollContainer();
|
||||
|
||||
private WikiSidebar sidebar;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(() => Child = sidebar = new WikiSidebar());
|
||||
|
||||
[Test]
|
||||
public void TestNoContent()
|
||||
{
|
||||
AddStep("No Content", () => { });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestOnlyMainTitle()
|
||||
{
|
||||
AddStep("Add TOC", () =>
|
||||
{
|
||||
for (var i = 0; i < 10; i++)
|
||||
addTitle($"This is a very long title {i + 1}");
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestWithSubtitle()
|
||||
{
|
||||
AddStep("Add TOC", () =>
|
||||
{
|
||||
for (var i = 0; i < 10; i++)
|
||||
addTitle($"This is a very long title {i + 1}", i % 4 != 0);
|
||||
});
|
||||
}
|
||||
|
||||
private void addTitle(string text, bool subtitle = false)
|
||||
{
|
||||
var headingBlock = new HeadingBlock(new HeadingBlockParser())
|
||||
{
|
||||
Inline = new ContainerInline().AppendChild(new LiteralInline(text)),
|
||||
Level = subtitle ? 3 : 2,
|
||||
};
|
||||
var heading = new OsuMarkdownHeading(headingBlock);
|
||||
sidebar.AddEntry(headingBlock, heading);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -14,7 +15,7 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
/// <summary>
|
||||
/// A background which offers blurring via a <see cref="BufferedContainer"/> on demand.
|
||||
/// </summary>
|
||||
public class Background : CompositeDrawable
|
||||
public class Background : CompositeDrawable, IEquatable<Background>
|
||||
{
|
||||
private const float blur_scale = 0.5f;
|
||||
|
||||
@ -71,5 +72,14 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
|
||||
bufferedContainer?.BlurTo(newBlurSigma * blur_scale, duration, easing);
|
||||
}
|
||||
|
||||
public virtual bool Equals(Background other)
|
||||
{
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
|
||||
return other.GetType() == GetType()
|
||||
&& other.textureName == textureName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,5 +24,14 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
{
|
||||
Sprite.Texture = Beatmap?.Background ?? textures.Get(fallbackTextureName);
|
||||
}
|
||||
|
||||
public override bool Equals(Background other)
|
||||
{
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
|
||||
return other.GetType() == GetType()
|
||||
&& ((BeatmapBackground)other).Beatmap == Beatmap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
34
osu.Game/Graphics/Backgrounds/SkinBackground.cs
Normal file
34
osu.Game/Graphics/Backgrounds/SkinBackground.cs
Normal file
@ -0,0 +1,34 @@
|
||||
// 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.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Graphics.Backgrounds
|
||||
{
|
||||
internal class SkinBackground : Background
|
||||
{
|
||||
private readonly Skin skin;
|
||||
|
||||
public SkinBackground(Skin skin, string fallbackTextureName)
|
||||
: base(fallbackTextureName)
|
||||
{
|
||||
this.skin = skin;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Sprite.Texture = skin.GetTexture("menu-background") ?? Sprite.Texture;
|
||||
}
|
||||
|
||||
public override bool Equals(Background other)
|
||||
{
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
|
||||
return other.GetType() == GetType()
|
||||
&& ((SkinBackground)other).skin.SkinInfo.Equals(skin.SkinInfo);
|
||||
}
|
||||
}
|
||||
}
|
@ -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 osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
@ -13,7 +14,9 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
protected override Container<Drawable> Content => content;
|
||||
|
||||
[Cached]
|
||||
protected readonly OverlayScrollContainer ScrollFlow;
|
||||
|
||||
protected readonly LoadingLayer Loading;
|
||||
private readonly Container content;
|
||||
|
||||
|
80
osu.Game/Overlays/Wiki/WikiArticlePage.cs
Normal file
80
osu.Game/Overlays/Wiki/WikiArticlePage.cs
Normal 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 Markdig.Syntax;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Containers.Markdown;
|
||||
using osu.Game.Overlays.Wiki.Markdown;
|
||||
|
||||
namespace osu.Game.Overlays.Wiki
|
||||
{
|
||||
public class WikiArticlePage : CompositeDrawable
|
||||
{
|
||||
public Container SidebarContainer { get; }
|
||||
|
||||
public WikiArticlePage(string currentPath, string markdown)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
WikiSidebar sidebar;
|
||||
|
||||
InternalChild = new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RowDimensions = new[]
|
||||
{
|
||||
new Dimension(GridSizeMode.AutoSize),
|
||||
},
|
||||
ColumnDimensions = new[]
|
||||
{
|
||||
new Dimension(GridSizeMode.AutoSize),
|
||||
new Dimension(),
|
||||
},
|
||||
Content = new[]
|
||||
{
|
||||
new Drawable[]
|
||||
{
|
||||
SidebarContainer = new Container
|
||||
{
|
||||
AutoSizeAxes = Axes.X,
|
||||
Child = sidebar = new WikiSidebar(),
|
||||
},
|
||||
new ArticleMarkdownContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
CurrentPath = currentPath,
|
||||
Text = markdown,
|
||||
DocumentMargin = new MarginPadding(0),
|
||||
DocumentPadding = new MarginPadding
|
||||
{
|
||||
Vertical = 20,
|
||||
Left = 30,
|
||||
Right = 50,
|
||||
},
|
||||
OnAddHeading = sidebar.AddEntry,
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
private class ArticleMarkdownContainer : WikiMarkdownContainer
|
||||
{
|
||||
public Action<HeadingBlock, MarkdownHeading> OnAddHeading;
|
||||
|
||||
protected override MarkdownHeading CreateHeading(HeadingBlock headingBlock)
|
||||
{
|
||||
var heading = base.CreateHeading(headingBlock);
|
||||
|
||||
OnAddHeading(headingBlock, heading);
|
||||
|
||||
return heading;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
66
osu.Game/Overlays/Wiki/WikiSidebar.cs
Normal file
66
osu.Game/Overlays/Wiki/WikiSidebar.cs
Normal file
@ -0,0 +1,66 @@
|
||||
// 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 Markdig.Syntax;
|
||||
using Markdig.Syntax.Inlines;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Containers.Markdown;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Overlays.Wiki
|
||||
{
|
||||
public class WikiSidebar : OverlaySidebar
|
||||
{
|
||||
private WikiTableOfContents tableOfContents;
|
||||
|
||||
protected override Drawable CreateContent() => new FillFlowContainer
|
||||
{
|
||||
Direction = FillDirection.Vertical,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Text = "CONTENTS",
|
||||
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
|
||||
Margin = new MarginPadding { Bottom = 5 },
|
||||
},
|
||||
tableOfContents = new WikiTableOfContents(),
|
||||
},
|
||||
};
|
||||
|
||||
public void AddEntry(HeadingBlock headingBlock, MarkdownHeading heading)
|
||||
{
|
||||
switch (headingBlock.Level)
|
||||
{
|
||||
case 2:
|
||||
case 3:
|
||||
tableOfContents.AddEntry(getTitle(headingBlock.Inline), heading, headingBlock.Level == 3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private string getTitle(ContainerInline containerInline)
|
||||
{
|
||||
foreach (var inline in containerInline)
|
||||
{
|
||||
switch (inline)
|
||||
{
|
||||
case LiteralInline literalInline:
|
||||
return literalInline.Content.ToString();
|
||||
|
||||
case LinkInline linkInline:
|
||||
if (!linkInline.IsImage)
|
||||
return getTitle(linkInline);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
91
osu.Game/Overlays/Wiki/WikiTableOfContents.cs
Normal file
91
osu.Game/Overlays/Wiki/WikiTableOfContents.cs
Normal file
@ -0,0 +1,91 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Containers.Markdown;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.Overlays.Wiki
|
||||
{
|
||||
public class WikiTableOfContents : CompositeDrawable
|
||||
{
|
||||
private readonly FillFlowContainer content;
|
||||
|
||||
private TableOfContentsEntry lastMainTitle;
|
||||
|
||||
private TableOfContentsEntry lastSubTitle;
|
||||
|
||||
public WikiTableOfContents()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
InternalChild = content = new FillFlowContainer
|
||||
{
|
||||
Direction = FillDirection.Vertical,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
};
|
||||
}
|
||||
|
||||
public void AddEntry(string title, MarkdownHeading target, bool subtitle = false)
|
||||
{
|
||||
var entry = new TableOfContentsEntry(title, target, subtitle);
|
||||
|
||||
if (subtitle)
|
||||
{
|
||||
lastMainTitle.Margin = new MarginPadding(0);
|
||||
|
||||
if (lastSubTitle != null)
|
||||
lastSubTitle.Margin = new MarginPadding(0);
|
||||
|
||||
content.Add(lastSubTitle = entry.With(d => d.Margin = new MarginPadding { Bottom = 10 }));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
lastSubTitle = null;
|
||||
|
||||
content.Add(lastMainTitle = entry.With(d => d.Margin = new MarginPadding { Bottom = 5 }));
|
||||
}
|
||||
|
||||
private class TableOfContentsEntry : OsuHoverContainer
|
||||
{
|
||||
private readonly MarkdownHeading target;
|
||||
|
||||
private readonly OsuTextFlowContainer textFlow;
|
||||
|
||||
public TableOfContentsEntry(string text, MarkdownHeading target, bool subtitle = false)
|
||||
{
|
||||
this.target = target;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
Child = textFlow = new OsuTextFlowContainer(t =>
|
||||
{
|
||||
t.Font = OsuFont.GetFont(size: subtitle ? 12 : 15);
|
||||
}).With(f =>
|
||||
{
|
||||
f.AddText(text);
|
||||
f.RelativeSizeAxes = Axes.X;
|
||||
f.AutoSizeAxes = Axes.Y;
|
||||
f.Margin = new MarginPadding { Bottom = 2 };
|
||||
});
|
||||
Padding = new MarginPadding { Left = subtitle ? 10 : 0 };
|
||||
}
|
||||
|
||||
protected override IEnumerable<Drawable> EffectTargets => new Drawable[] { textFlow };
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OverlayColourProvider colourProvider, OverlayScrollContainer scrollContainer)
|
||||
{
|
||||
IdleColour = colourProvider.Light2;
|
||||
HoverColour = colourProvider.Light1;
|
||||
Action = () => scrollContainer.ScrollTo(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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.Linq;
|
||||
using System.Threading;
|
||||
using osu.Framework.Allocation;
|
||||
@ -10,7 +11,6 @@ using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays.Wiki;
|
||||
using osu.Game.Overlays.Wiki.Markdown;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
@ -31,6 +31,8 @@ namespace osu.Game.Overlays
|
||||
|
||||
private bool displayUpdateRequired = true;
|
||||
|
||||
private WikiArticlePage articlePage;
|
||||
|
||||
public WikiOverlay()
|
||||
: base(OverlayColourScheme.Orange, false)
|
||||
{
|
||||
@ -82,6 +84,17 @@ namespace osu.Game.Overlays
|
||||
}, (cancellationToken = new CancellationTokenSource()).Token);
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
|
||||
if (articlePage != null)
|
||||
{
|
||||
articlePage.SidebarContainer.Height = DrawHeight;
|
||||
articlePage.SidebarContainer.Y = Math.Clamp(ScrollFlow.Current - Header.DrawHeight, 0, Math.Max(ScrollFlow.ScrollContent.DrawHeight - DrawHeight - Header.DrawHeight, 0));
|
||||
}
|
||||
}
|
||||
|
||||
private void onPathChanged(ValueChangedEvent<string> e)
|
||||
{
|
||||
cancellationToken?.Cancel();
|
||||
@ -115,39 +128,14 @@ namespace osu.Game.Overlays
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadDisplay(new WikiMarkdownContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
CurrentPath = $@"{api.WebsiteRootUrl}/wiki/{path.Value}/",
|
||||
Text = response.Markdown,
|
||||
DocumentMargin = new MarginPadding(0),
|
||||
DocumentPadding = new MarginPadding
|
||||
{
|
||||
Vertical = 20,
|
||||
Left = 30,
|
||||
Right = 50,
|
||||
},
|
||||
});
|
||||
LoadDisplay(articlePage = new WikiArticlePage($@"{api.WebsiteRootUrl}/wiki/{path.Value}/", response.Markdown));
|
||||
}
|
||||
}
|
||||
|
||||
private void onFail()
|
||||
{
|
||||
LoadDisplay(new WikiMarkdownContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
CurrentPath = $@"{api.WebsiteRootUrl}/wiki/",
|
||||
Text = $"Something went wrong when trying to fetch page \"{path.Value}\".\n\n[Return to the main page](Main_Page).",
|
||||
DocumentMargin = new MarginPadding(0),
|
||||
DocumentPadding = new MarginPadding
|
||||
{
|
||||
Vertical = 20,
|
||||
Left = 30,
|
||||
Right = 50,
|
||||
},
|
||||
});
|
||||
LoadDisplay(articlePage = new WikiArticlePage($@"{api.WebsiteRootUrl}/wiki/",
|
||||
$"Something went wrong when trying to fetch page \"{path.Value}\".\n\n[Return to the main page](Main_Page)."));
|
||||
}
|
||||
|
||||
private void showParentPage()
|
||||
|
@ -112,17 +112,24 @@ namespace osu.Game.Screens.Backgrounds
|
||||
newBackground = new BeatmapBackgroundWithStoryboard(beatmap.Value, getBackgroundTextureName());
|
||||
newBackground ??= new BeatmapBackground(beatmap.Value, getBackgroundTextureName());
|
||||
|
||||
// this method is called in many cases where the beatmap hasn't changed (ie. on screen transitions).
|
||||
// if a background is already displayed for the requested beatmap, we don't want to load it again.
|
||||
if (background?.GetType() == newBackground.GetType() &&
|
||||
(background as BeatmapBackground)?.Beatmap == beatmap.Value)
|
||||
return background;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case BackgroundSource.Skin:
|
||||
// default skins should use the default background rotation, which won't be the case if a SkinBackground is created for them.
|
||||
if (skin.Value is DefaultSkin || skin.Value is DefaultLegacySkin)
|
||||
break;
|
||||
|
||||
newBackground = new SkinBackground(skin.Value, getBackgroundTextureName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// this method is called in many cases where the background might not necessarily need to change.
|
||||
// if an equivalent background is currently being shown, we don't want to load it again.
|
||||
if (newBackground?.Equals(background) == true)
|
||||
return background;
|
||||
|
||||
newBackground ??= new Background(getBackgroundTextureName());
|
||||
newBackground.Depth = currentDisplay;
|
||||
|
||||
@ -140,22 +147,5 @@ namespace osu.Game.Screens.Backgrounds
|
||||
return $@"Menu/menu-background-{currentDisplay % background_count + 1}";
|
||||
}
|
||||
}
|
||||
|
||||
private class SkinnedBackground : Background
|
||||
{
|
||||
private readonly Skin skin;
|
||||
|
||||
public SkinnedBackground(Skin skin, string fallbackTextureName)
|
||||
: base(fallbackTextureName)
|
||||
{
|
||||
this.skin = skin;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Sprite.Texture = skin.GetTexture("menu-background") ?? Sprite.Texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -217,6 +217,9 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||
if (!judgement.IsHit || judgement.HitObject.HitWindows?.WindowFor(HitResult.Miss) == 0)
|
||||
return;
|
||||
|
||||
if (!judgement.Type.IsScorable() || judgement.Type.IsBonus())
|
||||
return;
|
||||
|
||||
if (judgementsContainer.Count > max_concurrent_judgements)
|
||||
{
|
||||
const double quick_fade_time = 100;
|
||||
|
@ -7,6 +7,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -24,7 +25,13 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||
InternalChild = judgementsFlow = new JudgementFlow();
|
||||
}
|
||||
|
||||
protected override void OnNewJudgement(JudgementResult judgement) => judgementsFlow.Push(GetColourForHitResult(judgement.Type));
|
||||
protected override void OnNewJudgement(JudgementResult judgement)
|
||||
{
|
||||
if (!judgement.Type.IsScorable() || judgement.Type.IsBonus())
|
||||
return;
|
||||
|
||||
judgementsFlow.Push(GetColourForHitResult(judgement.Type));
|
||||
}
|
||||
|
||||
private class JudgementFlow : FillFlowContainer<HitErrorCircle>
|
||||
{
|
||||
|
@ -41,6 +41,8 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||
{
|
||||
switch (result)
|
||||
{
|
||||
case HitResult.SmallTickMiss:
|
||||
case HitResult.LargeTickMiss:
|
||||
case HitResult.Miss:
|
||||
return colours.Red;
|
||||
|
||||
@ -53,6 +55,8 @@ namespace osu.Game.Screens.Play.HUD.HitErrorMeters
|
||||
case HitResult.Good:
|
||||
return colours.GreenLight;
|
||||
|
||||
case HitResult.SmallTickHit:
|
||||
case HitResult.LargeTickHit:
|
||||
case HitResult.Great:
|
||||
return colours.Blue;
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2021.608.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2021.609.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.525.0" />
|
||||
<PackageReference Include="Sentry" Version="3.4.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.28.2" />
|
||||
|
@ -70,7 +70,7 @@
|
||||
<Reference Include="System.Net.Http" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Label="Package References">
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.608.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.609.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.525.0" />
|
||||
</ItemGroup>
|
||||
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
|
||||
@ -93,7 +93,7 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2021.608.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2021.609.0" />
|
||||
<PackageReference Include="SharpCompress" Version="0.28.2" />
|
||||
<PackageReference Include="NUnit" Version="3.13.2" />
|
||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||
|
Loading…
Reference in New Issue
Block a user