Skip to content

Commit

Permalink
Merge branch 'master' into comment-mapper-pill
Browse files Browse the repository at this point in the history
  • Loading branch information
bdach committed Feb 14, 2024
2 parents 68247fa + 746f50e commit 3f46e1a
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 156 deletions.
111 changes: 0 additions & 111 deletions osu.Game.Rulesets.Catch.Tests/TestSceneCatchSkinConfiguration.cs

This file was deleted.

13 changes: 0 additions & 13 deletions osu.Game.Rulesets.Catch/Skinning/CatchSkinConfiguration.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,6 @@ public CatchLegacySkinTransformer(ISkin skin)

result.Value = LegacyColourCompatibility.DisallowZeroAlpha(result.Value);
return (IBindable<TValue>)result;

case CatchSkinConfiguration config:
switch (config)
{
case CatchSkinConfiguration.FlipCatcherPlate:
// Don't flip catcher plate contents if the catcher is provided by this legacy skin.
if (GetDrawableComponent(new CatchSkinComponentLookup(CatchSkinComponents.Catcher)) != null)
return (IBindable<TValue>)new Bindable<bool>();

break;
}

break;
}

return base.GetConfig<TLookup, TValue>(lookup);
Expand Down
10 changes: 1 addition & 9 deletions osu.Game.Rulesets.Catch/UI/Catcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,6 @@ public CatcherAnimationState CurrentState

public Vector2 BodyScale => Scale * body.Scale;

/// <summary>
/// Whether the contents of the catcher plate should be visually flipped when the catcher direction is changed.
/// </summary>
private bool flipCatcherPlate;

/// <summary>
/// Width of the area that can be used to attempt catches during gameplay.
/// </summary>
Expand Down Expand Up @@ -339,8 +334,6 @@ protected override void SkinChanged(ISkinSource skin)
skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDash)?.Value ??
DEFAULT_HYPER_DASH_COLOUR;

flipCatcherPlate = skin.GetConfig<CatchSkinConfiguration, bool>(CatchSkinConfiguration.FlipCatcherPlate)?.Value ?? true;

runHyperDashStateTransition(HyperDashing);
}

Expand All @@ -352,8 +345,7 @@ protected override void Update()

body.Scale = scaleFromDirection;
// Inverse of catcher scale is applied here, as catcher gets scaled by circle size and so do the incoming fruit.
caughtObjectContainer.Scale = (1 / Scale.X) * (flipCatcherPlate ? scaleFromDirection : Vector2.One);
hitExplosionContainer.Scale = flipCatcherPlate ? scaleFromDirection : Vector2.One;
caughtObjectContainer.Scale = new Vector2(1 / Scale.X);

// Correct overshooting.
if ((hyperDashDirection > 0 && hyperDashTargetPosition < X) ||
Expand Down
74 changes: 69 additions & 5 deletions osu.Game.Rulesets.Osu/Mods/OsuModRelax.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 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.

using System;
Expand Down Expand Up @@ -38,28 +38,41 @@ public class OsuModRelax : ModRelax, IUpdatableByPlayfield, IApplicableToDrawabl
private ReplayState<OsuAction> state = null!;
private double lastStateChangeTime;

private DrawableOsuRuleset ruleset = null!;
private IPressHandler pressHandler = null!;

private bool hasReplay;
private bool legacyReplay;

public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
{
ruleset = (DrawableOsuRuleset)drawableRuleset;

// grab the input manager for future use.
osuInputManager = ((DrawableOsuRuleset)drawableRuleset).KeyBindingInputManager;
osuInputManager = ruleset.KeyBindingInputManager;
}

public void ApplyToPlayer(Player player)
{
if (osuInputManager.ReplayInputHandler != null)
{
hasReplay = true;

Debug.Assert(ruleset.ReplayScore != null);
legacyReplay = ruleset.ReplayScore.ScoreInfo.IsLegacyScore;

pressHandler = legacyReplay ? new LegacyReplayPressHandler(this) : new PressHandler(this);

return;
}

pressHandler = new PressHandler(this);
osuInputManager.AllowGameplayInputs = false;
}

public void Update(Playfield playfield)
{
if (hasReplay)
if (hasReplay && !legacyReplay)
return;

bool requiresHold = false;
Expand Down Expand Up @@ -132,11 +145,62 @@ void changeState(bool down)

if (down)
{
state.PressedActions.Add(wasLeft ? OsuAction.LeftButton : OsuAction.RightButton);
pressHandler.HandlePress(wasLeft);
wasLeft = !wasLeft;
}
else
{
pressHandler.HandleRelease(wasLeft);
}
}
}

private interface IPressHandler
{
void HandlePress(bool wasLeft);
void HandleRelease(bool wasLeft);
}

private class PressHandler : IPressHandler
{
private readonly OsuModRelax mod;

public PressHandler(OsuModRelax mod)
{
this.mod = mod;
}

state.Apply(osuInputManager.CurrentState, osuInputManager);
public void HandlePress(bool wasLeft)
{
mod.state.PressedActions.Add(wasLeft ? OsuAction.LeftButton : OsuAction.RightButton);
mod.state.Apply(mod.osuInputManager.CurrentState, mod.osuInputManager);
}

public void HandleRelease(bool wasLeft)
{
mod.state.Apply(mod.osuInputManager.CurrentState, mod.osuInputManager);
}
}

// legacy replays do not contain key-presses with Relax mod, so they need to be triggered by themselves.
private class LegacyReplayPressHandler : IPressHandler
{
private readonly OsuModRelax mod;

public LegacyReplayPressHandler(OsuModRelax mod)
{
this.mod = mod;
}

public void HandlePress(bool wasLeft)
{
mod.osuInputManager.KeyBindingContainer.TriggerPressed(wasLeft ? OsuAction.LeftButton : OsuAction.RightButton);
}

public void HandleRelease(bool wasLeft)
{
// this intentionally releases right when `wasLeft` is true because `wasLeft` is set at point of press and not at point of release
mod.osuInputManager.KeyBindingContainer.TriggerReleased(wasLeft ? OsuAction.RightButton : OsuAction.LeftButton);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public void TestEarlyAddedSkinRequester()

AddStep("setup provider", () =>
{
var rulesetSkinProvider = new RulesetSkinProvidingContainer(Ruleset.Value.CreateInstance(), Beatmap.Value.Beatmap, Beatmap.Value.Skin);
rulesetSkinProvider.Add(requester = new SkinRequester());
requester = new SkinRequester();
requester.OnLoadAsync += () => textureOnLoad = requester.GetTexture("test-image");
Child = rulesetSkinProvider;
Child = new RulesetSkinProvidingContainer(Ruleset.Value.CreateInstance(), Beatmap.Value.Beatmap, Beatmap.Value.Skin)
{
requester
};
});

AddAssert("requester got correct initial texture", () => textureOnLoad != null);
Expand Down

0 comments on commit 3f46e1a

Please sign in to comment.