Skip to content

Commit

Permalink
make the top notes properly gray. add top note flash on note hit
Browse files Browse the repository at this point in the history
  • Loading branch information
hwabis committed Oct 14, 2024
1 parent b0b734a commit 8e24989
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.PumpTrainer.UI;
using osu.Game.Rulesets.Scoring;
using osuTK;

Expand All @@ -16,7 +17,9 @@ public partial class DrawablePumpTrainerHitObject : DrawableHitObject<PumpTraine
{
public const int WIDTH = 85;

public DrawablePumpTrainerHitObject(PumpTrainerHitObject hitObject)
private DrawableTopRowHitObject correspondingTopRowHitObject;

public DrawablePumpTrainerHitObject(PumpTrainerHitObject hitObject, PumpTrainerPlayfield playfield)
: base(hitObject)
{
Size = new Vector2(WIDTH);
Expand All @@ -25,12 +28,14 @@ public DrawablePumpTrainerHitObject(PumpTrainerHitObject hitObject)

// Indexes 0 to 9 so midpoint is 4.5
X = (float)((int)HitObject.Column - 4.5) * WIDTH;

correspondingTopRowHitObject = playfield.TopRowHitObjects[(int)HitObject.Column];
}

[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
AddInternal(HitObject.GetAssociatedSprite(textures));
AddInternal(HitObject.GetAssociatedSprite(textures, false));
}

protected override void CheckForResult(bool userTriggered, double timeOffset)
Expand All @@ -51,6 +56,7 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
return;

ApplyResult(result);
correspondingTopRowHitObject.FlashOnHit();
}

protected override void UpdateHitStateTransforms(ArmedState state)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Textures;
using osuTK;
Expand All @@ -16,13 +17,18 @@ public DrawableTopRowHitObject(PumpTrainerHitObject hitObject)
this.hitObject = hitObject;
Size = new Vector2(DrawablePumpTrainerHitObject.WIDTH);

Colour = Color4.Gray; // TODO OH MY GOD WHY CAN'T I GET THIS TO BE BLACK AND WHITE
Colour = Color4.Gray;
}

[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
AddInternal(hitObject.GetAssociatedSprite(textures));
AddInternal(hitObject.GetAssociatedSprite(textures, true));
}

public void FlashOnHit()
{
this.FlashColour(Color4.White, 250, Easing.In);
}
}
}
19 changes: 13 additions & 6 deletions osu.Game.Rulesets.PumpTrainer/Objects/PumpTrainerHitObject.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System.Linq;
using System.Text;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
Expand All @@ -23,35 +25,40 @@ public PumpTrainerHitObject(Column column)
}

// does this belong here?
public Sprite GetAssociatedSprite(TextureStore textures)
public Sprite GetAssociatedSprite(TextureStore textures, bool gray)
{
string textureString;
StringBuilder textureString = new();

switch (Column)
{
case Column.P1DL:
case Column.P1DR:
case Column.P2DL:
case Column.P2DR:
textureString = "DL";
textureString.Append("DL");
break;
case Column.P1UL:
case Column.P1UR:
case Column.P2UL:
case Column.P2UR:
textureString = "UL";
textureString.Append("UL");
break;
default:
textureString = "C";
textureString.Append("C");
break;
}

if (gray)
{
textureString.Append("-gray");
}

Sprite sprite = new()
{
RelativeSizeAxes = Axes.Both,
Origin = Anchor.TopCentre,
Anchor = Anchor.TopCentre,
Texture = textures.Get(textureString),
Texture = textures.Get(textureString.ToString()),
};

switch (Column)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified osu.Game.Rulesets.PumpTrainer/Resources/Textures/UL.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public DrawablePumpTrainerRuleset(PumpTrainerRuleset ruleset, IBeatmap beatmap,

protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new PumpTrainerFramedReplayInputHandler(replay);

public override DrawableHitObject<PumpTrainerHitObject> CreateDrawableRepresentation(PumpTrainerHitObject h) => new DrawablePumpTrainerHitObject(h);
public override DrawableHitObject<PumpTrainerHitObject> CreateDrawableRepresentation(PumpTrainerHitObject h) =>
new DrawablePumpTrainerHitObject(h, (PumpTrainerPlayfield)Playfield);

protected override PassThroughInputManager CreateInputManager() => new PumpTrainerInputManager(Ruleset?.RulesetInfo);
}
Expand Down
5 changes: 4 additions & 1 deletion osu.Game.Rulesets.PumpTrainer/UI/PumpTrainerPlayfield.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. 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;
Expand All @@ -14,6 +15,8 @@ namespace osu.Game.Rulesets.PumpTrainer.UI
[Cached]
public partial class PumpTrainerPlayfield : ScrollingPlayfield
{
public IReadOnlyList<DrawableTopRowHitObject> TopRowHitObjects;

[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
Expand All @@ -30,7 +33,7 @@ private void load(TextureStore textures)
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
AutoSizeAxes = Axes.Both,
Children =
Children = TopRowHitObjects =
[
new DrawableTopRowHitObject(new(Column.P1DL)),
new DrawableTopRowHitObject(new(Column.P1UL)),
Expand Down

0 comments on commit 8e24989

Please sign in to comment.