Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update framework with KeyBindings + TextBuilder changes #14764

Merged
merged 16 commits into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@ public class TestSceneOsuGame : OsuTestScene
[BackgroundDependencyLoader]
private void load(GameHost host, OsuGameBase gameBase)
{
OsuGame game = new OsuGame();
game.SetHost(host);

Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
},
game
};

AddGame(new OsuGame());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@ public class TestSceneOsuGame : OsuTestScene
[BackgroundDependencyLoader]
private void load(GameHost host, OsuGameBase gameBase)
{
OsuGame game = new OsuGame();
game.SetHost(host);

Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
},
game
};

AddGame(new OsuGame());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@ public class TestSceneOsuGame : OsuTestScene
[BackgroundDependencyLoader]
private void load(GameHost host, OsuGameBase gameBase)
{
OsuGame game = new OsuGame();
game.SetHost(host);

Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
},
game
};

AddGame(new OsuGame());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@ public class TestSceneOsuGame : OsuTestScene
[BackgroundDependencyLoader]
private void load(GameHost host, OsuGameBase gameBase)
{
OsuGame game = new OsuGame();
game.SetHost(host);

Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Black,
},
game
};

AddGame(new OsuGame());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.Containers;
using osuTK;
Expand Down Expand Up @@ -61,9 +62,9 @@ protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint,
}
}

public bool OnPressed(PippidonAction action)
public bool OnPressed(KeyBindingPressEvent<PippidonAction> e)
{
switch (action)
switch (e.Action)
{
case PippidonAction.MoveUp:
changeLane(-1);
Expand All @@ -78,7 +79,7 @@ public bool OnPressed(PippidonAction action)
}
}

public void OnReleased(PippidonAction action)
public void OnReleased(KeyBindingReleaseEvent<PippidonAction> e)
{
}

Expand Down
2 changes: 1 addition & 1 deletion osu.Android.props
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.913.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.907.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.916.1" />
</ItemGroup>
<ItemGroup Label="Transitive Dependencies">
<!-- Realm needs to be directly referenced in all Xamarin projects, as it will not pull in its transitive dependencies otherwise. -->
Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Rulesets.Catch/Mods/CatchModRelax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public MouseInputHelper(CatchPlayfield playfield)
}

// disable keyboard controls
public bool OnPressed(CatchAction action) => true;
public bool OnPressed(KeyBindingPressEvent<CatchAction> e) => true;

public void OnReleased(CatchAction action)
public void OnReleased(KeyBindingReleaseEvent<CatchAction> e)
{
}

Expand Down
9 changes: 5 additions & 4 deletions osu.Game.Rulesets.Catch/UI/CatcherArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Rulesets.Catch.Judgements;
using osu.Game.Rulesets.Catch.Objects.Drawables;
using osu.Game.Rulesets.Catch.Replays;
Expand Down Expand Up @@ -144,9 +145,9 @@ public void SetCatcherPosition(float X)
Catcher.VisualDirection = Direction.Left;
}

public bool OnPressed(CatchAction action)
public bool OnPressed(KeyBindingPressEvent<CatchAction> e)
{
switch (action)
switch (e.Action)
{
case CatchAction.MoveLeft:
currentDirection--;
Expand All @@ -164,9 +165,9 @@ public bool OnPressed(CatchAction action)
return false;
}

public void OnReleased(CatchAction action)
public void OnReleased(KeyBindingReleaseEvent<CatchAction> e)
{
switch (action)
switch (e.Action)
{
case CatchAction.MoveLeft:
currentDirection++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
Expand Down Expand Up @@ -58,7 +59,7 @@ public void TestHoldNoteHeadVisibility()
AddStep("Hold key", () =>
{
clock.CurrentTime = 0;
note.OnPressed(ManiaAction.Key1);
note.OnPressed(new KeyBindingPressEvent<ManiaAction>(GetContainingInputManager().CurrentState, ManiaAction.Key1));
});
AddStep("progress time", () => clock.CurrentTime = 500);
AddAssert("head is visible", () => note.Head.Alpha == 1);
Expand Down
9 changes: 5 additions & 4 deletions osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Rulesets.Mania.Skinning.Default;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
Expand Down Expand Up @@ -253,12 +254,12 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
HoldBrokenTime = Time.Current;
}

public bool OnPressed(ManiaAction action)
public bool OnPressed(KeyBindingPressEvent<ManiaAction> e)
{
if (AllJudged)
return false;

if (action != Action.Value)
if (e.Action != Action.Value)
return false;

// do not run any of this logic when rewinding, as it inverts order of presses/releases.
Expand Down Expand Up @@ -288,12 +289,12 @@ private void beginHoldAt(double timeOffset)
isHitting.Value = true;
}

public void OnReleased(ManiaAction action)
public void OnReleased(KeyBindingReleaseEvent<ManiaAction> e)
{
if (AllJudged)
return;

if (action != Action.Value)
if (e.Action != Action.Value)
return;

// do not run any of this logic when rewinding, as it inverts order of presses/releases.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osu.Game.Rulesets.Objects.Drawables;

namespace osu.Game.Rulesets.Mania.Objects.Drawables
Expand Down Expand Up @@ -43,9 +44,9 @@ protected override void UpdateHitStateTransforms(ArmedState state)
// it will be hidden along with its parenting hold note when required.
}

public override bool OnPressed(ManiaAction action) => false; // Handled by the hold note
public override bool OnPressed(KeyBindingPressEvent<ManiaAction> e) => false; // Handled by the hold note

public override void OnReleased(ManiaAction action)
public override void OnReleased(KeyBindingReleaseEvent<ManiaAction> e)
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Diagnostics;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osu.Game.Rulesets.Scoring;

namespace osu.Game.Rulesets.Mania.Objects.Drawables
Expand Down Expand Up @@ -68,9 +69,9 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
});
}

public override bool OnPressed(ManiaAction action) => false; // Handled by the hold note
public override bool OnPressed(KeyBindingPressEvent<ManiaAction> e) => false; // Handled by the hold note

public override void OnReleased(ManiaAction action)
public override void OnReleased(KeyBindingReleaseEvent<ManiaAction> e)
{
}
}
Expand Down
7 changes: 4 additions & 3 deletions osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Rulesets.Mania.Configuration;
Expand Down Expand Up @@ -97,9 +98,9 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
ApplyResult(r => r.Type = result);
}

public virtual bool OnPressed(ManiaAction action)
public virtual bool OnPressed(KeyBindingPressEvent<ManiaAction> e)
{
if (action != Action.Value)
if (e.Action != Action.Value)
return false;

if (CheckHittable?.Invoke(this, Time.Current) == false)
Expand All @@ -108,7 +109,7 @@ public virtual bool OnPressed(ManiaAction action)
return UpdateResult(true);
}

public virtual void OnReleased(ManiaAction action)
public virtual void OnReleased(KeyBindingReleaseEvent<ManiaAction> e)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Skinning;
using osuTK;
Expand Down Expand Up @@ -76,9 +77,9 @@ private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
}
}

public bool OnPressed(ManiaAction action)
public bool OnPressed(KeyBindingPressEvent<ManiaAction> e)
{
if (action == Column.Action.Value)
if (e.Action == Column.Action.Value)
{
light.FadeIn();
light.ScaleTo(Vector2.One);
Expand All @@ -87,12 +88,12 @@ public bool OnPressed(ManiaAction action)
return false;
}

public void OnReleased(ManiaAction action)
public void OnReleased(KeyBindingReleaseEvent<ManiaAction> e)
{
// Todo: Should be 400 * 100 / CurrentBPM
const double animation_length = 250;

if (action == Column.Action.Value)
if (e.Action == Column.Action.Value)
{
light.FadeTo(0, animation_length);
light.ScaleTo(new Vector2(1, 0), animation_length);
Expand Down
9 changes: 5 additions & 4 deletions osu.Game.Rulesets.Mania/Skinning/Legacy/LegacyKeyArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Skinning;
Expand Down Expand Up @@ -86,9 +87,9 @@ private void onDirectionChanged(ValueChangedEvent<ScrollingDirection> direction)
}
}

public bool OnPressed(ManiaAction action)
public bool OnPressed(KeyBindingPressEvent<ManiaAction> e)
{
if (action == column.Action.Value)
if (e.Action == column.Action.Value)
{
upSprite.FadeTo(0);
downSprite.FadeTo(1);
Expand All @@ -97,9 +98,9 @@ public bool OnPressed(ManiaAction action)
return false;
}

public void OnReleased(ManiaAction action)
public void OnReleased(KeyBindingReleaseEvent<ManiaAction> e)
{
if (action == column.Action.Value)
if (e.Action == column.Action.Value)
{
upSprite.Delay(LegacyHitExplosion.FADE_IN_DURATION).FadeTo(1);
downSprite.Delay(LegacyHitExplosion.FADE_IN_DURATION).FadeTo(0);
Expand Down
7 changes: 4 additions & 3 deletions osu.Game.Rulesets.Mania/UI/Column.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using osu.Framework.Bindables;
using osu.Framework.Graphics.Pooling;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mania.UI.Components;
using osu.Game.Rulesets.UI.Scrolling;
Expand Down Expand Up @@ -122,16 +123,16 @@ internal void OnNewResult(DrawableHitObject judgedObject, JudgementResult result
HitObjectArea.Explosions.Add(hitExplosionPool.Get(e => e.Apply(result)));
}

public bool OnPressed(ManiaAction action)
public bool OnPressed(KeyBindingPressEvent<ManiaAction> e)
{
if (action != Action.Value)
if (e.Action != Action.Value)
return false;

sampleTriggerSource.Play();
return true;
}

public void OnReleased(ManiaAction action)
public void OnReleased(KeyBindingReleaseEvent<ManiaAction> e)
{
}

Expand Down
Loading