mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Merge branch 'master' into fix-slider-repeat-arrow-rotation-editor
This commit is contained in:
@ -52,6 +52,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.525.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.525.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.601.0" />
|
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.607.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Game.Rulesets.Catch.Skinning.Default;
|
using osu.Game.Rulesets.Catch.Skinning.Default;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||||
@ -9,21 +8,11 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a <see cref="Fruit"/> caught by the catcher.
|
/// Represents a <see cref="Fruit"/> caught by the catcher.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CaughtFruit : CaughtObject, IHasFruitState
|
public class CaughtFruit : CaughtObject
|
||||||
{
|
{
|
||||||
public Bindable<FruitVisualRepresentation> VisualRepresentation { get; } = new Bindable<FruitVisualRepresentation>();
|
|
||||||
|
|
||||||
public CaughtFruit()
|
public CaughtFruit()
|
||||||
: base(CatchSkinComponents.Fruit, _ => new FruitPiece())
|
: base(CatchSkinComponents.Fruit, _ => new FruitPiece())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void CopyStateFrom(IHasCatchObjectState objectState)
|
|
||||||
{
|
|
||||||
base.CopyStateFrom(objectState);
|
|
||||||
|
|
||||||
var fruitState = (IHasFruitState)objectState;
|
|
||||||
VisualRepresentation.Value = fruitState.VisualRepresentation.Value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
|||||||
public PalpableCatchHitObject HitObject { get; private set; }
|
public PalpableCatchHitObject HitObject { get; private set; }
|
||||||
public Bindable<Color4> AccentColour { get; } = new Bindable<Color4>();
|
public Bindable<Color4> AccentColour { get; } = new Bindable<Color4>();
|
||||||
public Bindable<bool> HyperDash { get; } = new Bindable<bool>();
|
public Bindable<bool> HyperDash { get; } = new Bindable<bool>();
|
||||||
|
public Bindable<int> IndexInBeatmap { get; } = new Bindable<int>();
|
||||||
|
|
||||||
public Vector2 DisplaySize => Size * Scale;
|
public Vector2 DisplaySize => Size * Scale;
|
||||||
|
|
||||||
@ -51,6 +52,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
|||||||
Rotation = objectState.DisplayRotation;
|
Rotation = objectState.DisplayRotation;
|
||||||
AccentColour.Value = objectState.AccentColour.Value;
|
AccentColour.Value = objectState.AccentColour.Value;
|
||||||
HyperDash.Value = objectState.HyperDash.Value;
|
HyperDash.Value = objectState.HyperDash.Value;
|
||||||
|
IndexInBeatmap.Value = objectState.IndexInBeatmap.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void FreeAfterUse()
|
protected override void FreeAfterUse()
|
||||||
|
@ -3,17 +3,14 @@
|
|||||||
|
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Rulesets.Catch.Skinning.Default;
|
using osu.Game.Rulesets.Catch.Skinning.Default;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||||
{
|
{
|
||||||
public class DrawableFruit : DrawablePalpableCatchHitObject, IHasFruitState
|
public class DrawableFruit : DrawablePalpableCatchHitObject
|
||||||
{
|
{
|
||||||
public Bindable<FruitVisualRepresentation> VisualRepresentation { get; } = new Bindable<FruitVisualRepresentation>();
|
|
||||||
|
|
||||||
public DrawableFruit()
|
public DrawableFruit()
|
||||||
: this(null)
|
: this(null)
|
||||||
{
|
{
|
||||||
@ -27,11 +24,6 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
IndexInBeatmap.BindValueChanged(change =>
|
|
||||||
{
|
|
||||||
VisualRepresentation.Value = (FruitVisualRepresentation)(change.NewValue % 4);
|
|
||||||
}, true);
|
|
||||||
|
|
||||||
ScalingContainer.Child = new SkinnableDrawable(
|
ScalingContainer.Child = new SkinnableDrawable(
|
||||||
new CatchSkinComponent(CatchSkinComponents.Fruit),
|
new CatchSkinComponent(CatchSkinComponents.Fruit),
|
||||||
_ => new FruitPiece());
|
_ => new FruitPiece());
|
||||||
@ -44,12 +36,4 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
|||||||
ScalingContainer.RotateTo((RandomSingle(1) - 0.5f) * 40);
|
ScalingContainer.RotateTo((RandomSingle(1) - 0.5f) * 40);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum FruitVisualRepresentation
|
|
||||||
{
|
|
||||||
Pear,
|
|
||||||
Grape,
|
|
||||||
Pineapple,
|
|
||||||
Raspberry,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
|||||||
|
|
||||||
Bindable<bool> HyperDash { get; }
|
Bindable<bool> HyperDash { get; }
|
||||||
|
|
||||||
|
Bindable<int> IndexInBeatmap { get; }
|
||||||
|
|
||||||
Vector2 DisplaySize { get; }
|
Vector2 DisplaySize { get; }
|
||||||
|
|
||||||
float DisplayRotation { get; }
|
float DisplayRotation { get; }
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
|
||||||
|
|
||||||
using osu.Framework.Bindables;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Provides a visual state of a <see cref="Fruit"/>.
|
|
||||||
/// </summary>
|
|
||||||
public interface IHasFruitState : IHasCatchObjectState
|
|
||||||
{
|
|
||||||
Bindable<FruitVisualRepresentation> VisualRepresentation { get; }
|
|
||||||
}
|
|
||||||
}
|
|
@ -9,5 +9,7 @@ namespace osu.Game.Rulesets.Catch.Objects
|
|||||||
public class Fruit : PalpableCatchHitObject
|
public class Fruit : PalpableCatchHitObject
|
||||||
{
|
{
|
||||||
public override Judgement CreateJudgement() => new CatchJudgement();
|
public override Judgement CreateJudgement() => new CatchJudgement();
|
||||||
|
|
||||||
|
public static FruitVisualRepresentation GetVisualRepresentation(int indexInBeatmap) => (FruitVisualRepresentation)(indexInBeatmap % 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
13
osu.Game.Rulesets.Catch/Objects/FruitVisualRepresentation.cs
Normal file
13
osu.Game.Rulesets.Catch/Objects/FruitVisualRepresentation.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Catch.Objects
|
||||||
|
{
|
||||||
|
public enum FruitVisualRepresentation
|
||||||
|
{
|
||||||
|
Pear,
|
||||||
|
Grape,
|
||||||
|
Pineapple,
|
||||||
|
Raspberry,
|
||||||
|
}
|
||||||
|
}
|
@ -15,6 +15,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Default
|
|||||||
{
|
{
|
||||||
public readonly Bindable<Color4> AccentColour = new Bindable<Color4>();
|
public readonly Bindable<Color4> AccentColour = new Bindable<Color4>();
|
||||||
public readonly Bindable<bool> HyperDash = new Bindable<bool>();
|
public readonly Bindable<bool> HyperDash = new Bindable<bool>();
|
||||||
|
public readonly Bindable<int> IndexInBeatmap = new Bindable<int>();
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
protected IHasCatchObjectState ObjectState { get; private set; }
|
protected IHasCatchObjectState ObjectState { get; private set; }
|
||||||
@ -37,6 +38,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Default
|
|||||||
|
|
||||||
AccentColour.BindTo(ObjectState.AccentColour);
|
AccentColour.BindTo(ObjectState.AccentColour);
|
||||||
HyperDash.BindTo(ObjectState.HyperDash);
|
HyperDash.BindTo(ObjectState.HyperDash);
|
||||||
|
IndexInBeatmap.BindTo(ObjectState.IndexInBeatmap);
|
||||||
|
|
||||||
HyperDash.BindValueChanged(hyper =>
|
HyperDash.BindValueChanged(hyper =>
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Skinning.Default
|
namespace osu.Game.Rulesets.Catch.Skinning.Default
|
||||||
{
|
{
|
||||||
@ -39,8 +39,10 @@ namespace osu.Game.Rulesets.Catch.Skinning.Default
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
var fruitState = (IHasFruitState)ObjectState;
|
IndexInBeatmap.BindValueChanged(index =>
|
||||||
VisualRepresentation.BindTo(fruitState.VisualRepresentation);
|
{
|
||||||
|
VisualRepresentation.Value = Fruit.GetVisualRepresentation(index.NewValue);
|
||||||
|
}, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Skinning.Default
|
namespace osu.Game.Rulesets.Catch.Skinning.Default
|
||||||
|
@ -19,6 +19,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
|
|||||||
{
|
{
|
||||||
public readonly Bindable<Color4> AccentColour = new Bindable<Color4>();
|
public readonly Bindable<Color4> AccentColour = new Bindable<Color4>();
|
||||||
public readonly Bindable<bool> HyperDash = new Bindable<bool>();
|
public readonly Bindable<bool> HyperDash = new Bindable<bool>();
|
||||||
|
public readonly Bindable<int> IndexInBeatmap = new Bindable<int>();
|
||||||
|
|
||||||
private readonly Sprite colouredSprite;
|
private readonly Sprite colouredSprite;
|
||||||
private readonly Sprite overlaySprite;
|
private readonly Sprite overlaySprite;
|
||||||
@ -64,6 +65,7 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
|
|||||||
|
|
||||||
AccentColour.BindTo(ObjectState.AccentColour);
|
AccentColour.BindTo(ObjectState.AccentColour);
|
||||||
HyperDash.BindTo(ObjectState.HyperDash);
|
HyperDash.BindTo(ObjectState.HyperDash);
|
||||||
|
IndexInBeatmap.BindTo(ObjectState.IndexInBeatmap);
|
||||||
|
|
||||||
hyperSprite.Colour = Skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDashFruit)?.Value ??
|
hyperSprite.Colour = Skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDashFruit)?.Value ??
|
||||||
Skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDash)?.Value ??
|
Skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDash)?.Value ??
|
||||||
|
@ -1,23 +1,20 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Skinning.Legacy
|
namespace osu.Game.Rulesets.Catch.Skinning.Legacy
|
||||||
{
|
{
|
||||||
internal class LegacyFruitPiece : LegacyCatchHitObjectPiece
|
internal class LegacyFruitPiece : LegacyCatchHitObjectPiece
|
||||||
{
|
{
|
||||||
public readonly Bindable<FruitVisualRepresentation> VisualRepresentation = new Bindable<FruitVisualRepresentation>();
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
var fruitState = (IHasFruitState)ObjectState;
|
IndexInBeatmap.BindValueChanged(index =>
|
||||||
VisualRepresentation.BindTo(fruitState.VisualRepresentation);
|
{
|
||||||
|
setTexture(Fruit.GetVisualRepresentation(index.NewValue));
|
||||||
VisualRepresentation.BindValueChanged(visual => setTexture(visual.NewValue), true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTexture(FruitVisualRepresentation visualRepresentation)
|
private void setTexture(FruitVisualRepresentation visualRepresentation)
|
||||||
|
@ -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 NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Screens;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Graphics.Backgrounds;
|
||||||
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Screens;
|
||||||
|
using osu.Game.Screens.Backgrounds;
|
||||||
|
using osu.Game.Users;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Background
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class TestSceneBackgroundScreenDefault : OsuTestScene
|
||||||
|
{
|
||||||
|
private BackgroundScreenStack stack;
|
||||||
|
private BackgroundScreenDefault screen;
|
||||||
|
|
||||||
|
private Graphics.Backgrounds.Background getCurrentBackground() => screen.ChildrenOfType<Graphics.Backgrounds.Background>().FirstOrDefault();
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuConfigManager config { get; set; }
|
||||||
|
|
||||||
|
[SetUpSteps]
|
||||||
|
public void SetUpSteps()
|
||||||
|
{
|
||||||
|
AddStep("create background stack", () => Child = stack = new BackgroundScreenStack());
|
||||||
|
AddStep("push default screen", () => stack.Push(screen = new BackgroundScreenDefault(false)));
|
||||||
|
AddUntilStep("wait for screen to load", () => screen.IsCurrentScreen());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestTogglingStoryboardSwitchesBackgroundType()
|
||||||
|
{
|
||||||
|
setSupporter(true);
|
||||||
|
|
||||||
|
setSourceMode(BackgroundSource.Beatmap);
|
||||||
|
AddUntilStep("is beatmap background", () => getCurrentBackground() is BeatmapBackground);
|
||||||
|
|
||||||
|
setSourceMode(BackgroundSource.BeatmapWithStoryboard);
|
||||||
|
AddUntilStep("is storyboard background", () => getCurrentBackground() is BeatmapBackgroundWithStoryboard);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestTogglingSupporterTogglesBeatmapBackground()
|
||||||
|
{
|
||||||
|
setSourceMode(BackgroundSource.Beatmap);
|
||||||
|
|
||||||
|
setSupporter(true);
|
||||||
|
AddUntilStep("is beatmap background", () => getCurrentBackground() is BeatmapBackground);
|
||||||
|
|
||||||
|
setSupporter(false);
|
||||||
|
AddUntilStep("is default background", () => !(getCurrentBackground() is BeatmapBackground));
|
||||||
|
|
||||||
|
setSupporter(true);
|
||||||
|
AddUntilStep("is beatmap background", () => getCurrentBackground() is BeatmapBackground);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestBeatmapDoesntReloadOnNoChange()
|
||||||
|
{
|
||||||
|
BeatmapBackground last = null;
|
||||||
|
|
||||||
|
setSourceMode(BackgroundSource.Beatmap);
|
||||||
|
setSupporter(true);
|
||||||
|
|
||||||
|
AddUntilStep("wait for beatmap background to be loaded", () => (last = getCurrentBackground() as BeatmapBackground) != null);
|
||||||
|
AddAssert("next doesn't load new background", () => screen.Next() == false);
|
||||||
|
|
||||||
|
// doesn't really need to be checked but might as well.
|
||||||
|
AddWaitStep("wait a bit", 5);
|
||||||
|
AddUntilStep("ensure same background instance", () => last == getCurrentBackground());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setSourceMode(BackgroundSource source) =>
|
||||||
|
AddStep("set background mode to beatmap", () => config.SetValue(OsuSetting.MenuBackgroundSource, source));
|
||||||
|
|
||||||
|
private void setSupporter(bool isSupporter) =>
|
||||||
|
AddStep($"set supporter {isSupporter}", () => ((DummyAPIAccess)API).LocalUser.Value = new User
|
||||||
|
{
|
||||||
|
IsSupporter = isSupporter,
|
||||||
|
Id = API.LocalUser.Value.Id + 1,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -30,9 +30,12 @@ namespace osu.Game.Graphics.Containers.Markdown
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ListItemBlock listItemBlock:
|
case ListItemBlock listItemBlock:
|
||||||
var isOrdered = ((ListBlock)listItemBlock.Parent).IsOrdered;
|
bool isOrdered = ((ListBlock)listItemBlock.Parent)?.IsOrdered == true;
|
||||||
var childContainer = CreateListItem(listItemBlock, level, isOrdered);
|
|
||||||
|
OsuMarkdownListItem childContainer = CreateListItem(listItemBlock, level, isOrdered);
|
||||||
|
|
||||||
container.Add(childContainer);
|
container.Add(childContainer);
|
||||||
|
|
||||||
foreach (var single in listItemBlock)
|
foreach (var single in listItemBlock)
|
||||||
base.AddMarkdownComponent(single, childContainer.Content, level);
|
base.AddMarkdownComponent(single, childContainer.Content, level);
|
||||||
break;
|
break;
|
||||||
|
@ -33,7 +33,7 @@ namespace osu.Game.Overlays.Wiki.Markdown
|
|||||||
|
|
||||||
case ParagraphBlock paragraphBlock:
|
case ParagraphBlock paragraphBlock:
|
||||||
// Check if paragraph only contains an image
|
// Check if paragraph only contains an image
|
||||||
if (paragraphBlock.Inline.Count() == 1 && paragraphBlock.Inline.FirstChild is LinkInline { IsImage: true } linkInline)
|
if (paragraphBlock.Inline?.Count() == 1 && paragraphBlock.Inline.FirstChild is LinkInline { IsImage: true } linkInline)
|
||||||
{
|
{
|
||||||
container.Add(new WikiMarkdownImageBlock(linkInline));
|
container.Add(new WikiMarkdownImageBlock(linkInline));
|
||||||
return;
|
return;
|
||||||
|
@ -5,8 +5,8 @@ using System.Threading;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Utils;
|
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics.Backgrounds;
|
using osu.Game.Graphics.Backgrounds;
|
||||||
@ -53,14 +53,41 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
mode.ValueChanged += _ => Next();
|
mode.ValueChanged += _ => Next();
|
||||||
beatmap.ValueChanged += _ => Next();
|
beatmap.ValueChanged += _ => Next();
|
||||||
introSequence.ValueChanged += _ => Next();
|
introSequence.ValueChanged += _ => Next();
|
||||||
seasonalBackgroundLoader.SeasonalBackgroundChanged += Next;
|
seasonalBackgroundLoader.SeasonalBackgroundChanged += () => Next();
|
||||||
|
|
||||||
currentDisplay = RNG.Next(0, background_count);
|
currentDisplay = RNG.Next(0, background_count);
|
||||||
|
|
||||||
Next();
|
Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void display(Background newBackground)
|
private ScheduledDelegate nextTask;
|
||||||
|
private CancellationTokenSource cancellationTokenSource;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Request loading the next background.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Whether a new background was queued for load. May return false if the current background is still valid.</returns>
|
||||||
|
public bool Next()
|
||||||
|
{
|
||||||
|
var nextBackground = createBackground();
|
||||||
|
|
||||||
|
// in the case that the background hasn't changed, we want to avoid cancelling any tasks that could still be loading.
|
||||||
|
if (nextBackground == background)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
cancellationTokenSource?.Cancel();
|
||||||
|
cancellationTokenSource = new CancellationTokenSource();
|
||||||
|
|
||||||
|
nextTask?.Cancel();
|
||||||
|
nextTask = Scheduler.AddDelayed(() =>
|
||||||
|
{
|
||||||
|
LoadComponentAsync(nextBackground, displayNext, cancellationTokenSource.Token);
|
||||||
|
}, 100);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void displayNext(Background newBackground)
|
||||||
{
|
{
|
||||||
background?.FadeOut(800, Easing.InOutSine);
|
background?.FadeOut(800, Easing.InOutSine);
|
||||||
background?.Expire();
|
background?.Expire();
|
||||||
@ -69,68 +96,51 @@ namespace osu.Game.Screens.Backgrounds
|
|||||||
currentDisplay++;
|
currentDisplay++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScheduledDelegate nextTask;
|
|
||||||
private CancellationTokenSource cancellationTokenSource;
|
|
||||||
|
|
||||||
public void Next()
|
|
||||||
{
|
|
||||||
nextTask?.Cancel();
|
|
||||||
cancellationTokenSource?.Cancel();
|
|
||||||
cancellationTokenSource = new CancellationTokenSource();
|
|
||||||
nextTask = Scheduler.AddDelayed(() => LoadComponentAsync(createBackground(), display, cancellationTokenSource.Token), 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Background createBackground()
|
private Background createBackground()
|
||||||
{
|
{
|
||||||
Background newBackground;
|
// seasonal background loading gets highest priority.
|
||||||
string backgroundName;
|
Background newBackground = seasonalBackgroundLoader.LoadNextBackground();
|
||||||
|
|
||||||
var seasonalBackground = seasonalBackgroundLoader.LoadNextBackground();
|
if (newBackground == null && user.Value?.IsSupporter == true)
|
||||||
|
|
||||||
if (seasonalBackground != null)
|
|
||||||
{
|
|
||||||
seasonalBackground.Depth = currentDisplay;
|
|
||||||
return seasonalBackground;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (introSequence.Value)
|
|
||||||
{
|
|
||||||
case IntroSequence.Welcome:
|
|
||||||
backgroundName = "Intro/Welcome/menu-background";
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
backgroundName = $@"Menu/menu-background-{currentDisplay % background_count + 1}";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user.Value?.IsSupporter ?? false)
|
|
||||||
{
|
{
|
||||||
switch (mode.Value)
|
switch (mode.Value)
|
||||||
{
|
{
|
||||||
case BackgroundSource.Beatmap:
|
case BackgroundSource.Beatmap:
|
||||||
newBackground = new BeatmapBackground(beatmap.Value, backgroundName);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BackgroundSource.BeatmapWithStoryboard:
|
case BackgroundSource.BeatmapWithStoryboard:
|
||||||
newBackground = AllowStoryboardBackground
|
{
|
||||||
? new BeatmapBackgroundWithStoryboard(beatmap.Value, backgroundName)
|
if (mode.Value == BackgroundSource.BeatmapWithStoryboard && AllowStoryboardBackground)
|
||||||
: new BeatmapBackground(beatmap.Value, backgroundName);
|
newBackground = new BeatmapBackgroundWithStoryboard(beatmap.Value, getBackgroundTextureName());
|
||||||
break;
|
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;
|
||||||
|
|
||||||
default:
|
|
||||||
newBackground = new SkinnedBackground(skin.Value, backgroundName);
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
newBackground = new Background(backgroundName);
|
|
||||||
|
|
||||||
|
newBackground ??= new Background(getBackgroundTextureName());
|
||||||
newBackground.Depth = currentDisplay;
|
newBackground.Depth = currentDisplay;
|
||||||
|
|
||||||
return newBackground;
|
return newBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string getBackgroundTextureName()
|
||||||
|
{
|
||||||
|
switch (introSequence.Value)
|
||||||
|
{
|
||||||
|
case IntroSequence.Welcome:
|
||||||
|
return @"Intro/Welcome/menu-background";
|
||||||
|
|
||||||
|
default:
|
||||||
|
return $@"Menu/menu-background-{currentDisplay % background_count + 1}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class SkinnedBackground : Background
|
private class SkinnedBackground : Background
|
||||||
{
|
{
|
||||||
private readonly Skin skin;
|
private readonly Skin skin;
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2021.601.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2021.607.0" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.525.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.525.0" />
|
||||||
<PackageReference Include="Sentry" Version="3.4.0" />
|
<PackageReference Include="Sentry" Version="3.4.0" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.28.2" />
|
<PackageReference Include="SharpCompress" Version="0.28.2" />
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Package References">
|
<ItemGroup Label="Package References">
|
||||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.601.0" />
|
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.607.0" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.525.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.525.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
|
<!-- 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" Version="2.2.6" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2021.601.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2021.607.0" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.28.2" />
|
<PackageReference Include="SharpCompress" Version="0.28.2" />
|
||||||
<PackageReference Include="NUnit" Version="3.13.2" />
|
<PackageReference Include="NUnit" Version="3.13.2" />
|
||||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||||
|
Reference in New Issue
Block a user