Skip to content

Commit

Permalink
Decorate key counter and add unimplemented "Total" key counter
Browse files Browse the repository at this point in the history
  • Loading branch information
frenzibyte committed Sep 24, 2023
1 parent 3bfd7f9 commit 2ec068a
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 15 deletions.
17 changes: 9 additions & 8 deletions osu.Game/Screens/Play/ArgonKeyCounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ public partial class ArgonKeyCounter : KeyCounter
private OsuSpriteText countText = null!;

// These values were taken from Figma
private const float line_height = 3;
public const float LINE_HEIGHT = 3;

private const float name_font_size = 10;
private const float count_font_size = 14;

// Make things look bigger without using Scale
private const float scale_factor = 1.5f;
public const float SCALE_FACTOR = 1.5f;

[Resolved]
private OsuColour colours { get; set; } = null!;
Expand All @@ -43,30 +44,30 @@ private void load()
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X,
Height = line_height * scale_factor,
Height = LINE_HEIGHT * SCALE_FACTOR,
Alpha = 0.5f
},
keyNameText = new OsuSpriteText
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Position = new Vector2(0, -13) * scale_factor,
Font = OsuFont.Torus.With(size: name_font_size * scale_factor, weight: FontWeight.Bold),
Position = new Vector2(0, -13) * SCALE_FACTOR,
Font = OsuFont.Torus.With(size: name_font_size * SCALE_FACTOR, weight: FontWeight.Bold),
Colour = colours.Blue0,
Text = Trigger.Name
},
countText = new OsuSpriteText
{
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Font = OsuFont.Torus.With(size: count_font_size * scale_factor, weight: FontWeight.Bold),
Font = OsuFont.Torus.With(size: count_font_size * SCALE_FACTOR, weight: FontWeight.Bold),
},
};

// Values from Figma didn't match visually
// So these were just eyeballed
Height = 30 * scale_factor;
Width = 35 * scale_factor;
Height = 30 * SCALE_FACTOR;
Width = 35 * SCALE_FACTOR;
}

protected override void LoadComplete()
Expand Down
94 changes: 90 additions & 4 deletions osu.Game/Screens/Play/ArgonKeyCounterDisplay.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
// 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;

Check failure on line 4 in osu.Game/Screens/Play/ArgonKeyCounterDisplay.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Using directive is unnecessary.

Check failure on line 4 in osu.Game/Screens/Play/ArgonKeyCounterDisplay.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Using directive is unnecessary.
using System.Linq;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Lines;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Utils;
using osu.Game.Screens.Play.HUD;
using osuTK;
using osuTK.Graphics;
using osuTK.Input;

Check failure on line 15 in osu.Game/Screens/Play/ArgonKeyCounterDisplay.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Using directive is unnecessary.

Check failure on line 15 in osu.Game/Screens/Play/ArgonKeyCounterDisplay.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Using directive is unnecessary.

namespace osu.Game.Screens.Play
{
Expand All @@ -14,17 +22,84 @@ public partial class ArgonKeyCounterDisplay : KeyCounterDisplay

protected override FillFlowContainer<KeyCounter> KeyFlow { get; }

private KeyCounterTotalTrigger totalTrigger;

public ArgonKeyCounterDisplay()
{
InternalChild = KeyFlow = new FillFlowContainer<KeyCounter>
InternalChild = new FillFlowContainer
{
Direction = FillDirection.Horizontal,
AutoSizeAxes = Axes.Both,
Alpha = 0,
Spacing = new Vector2(2),
Spacing = new Vector2(2f, 0f),
Children = new Drawable[]
{
new Circle
{
Size = new Vector2(48f, 2f),
Margin = new MarginPadding { Top = ArgonKeyCounter.LINE_HEIGHT * ArgonKeyCounter.SCALE_FACTOR / 2f - 1f },
Colour = Color4.White.Opacity(0.5f),
},
KeyFlow = new FillFlowContainer<KeyCounter>
{
Direction = FillDirection.Horizontal,
AutoSizeAxes = Axes.Both,
Alpha = 0,
Spacing = new Vector2(2),
},
new SmoothPath
{
PathRadius = 1f,
Colour = Color4.White.Opacity(0.5f),
Margin = new MarginPadding { Top = ArgonKeyCounter.LINE_HEIGHT * ArgonKeyCounter.SCALE_FACTOR / 2f - 1f },
Vertices = PathApproximator.ApproximateBezier(new[]
{
// todo: this is silly but it works
new Vector2(0, 0),
new Vector2(13, 0),
new Vector2(13, 0),
new Vector2(13, 0),
new Vector2(52, 40),
new Vector2(52, 40),
new Vector2(52, 40),
new Vector2(86, 40),
}.Select(v => v * ArgonKeyCounter.SCALE_FACTOR).ToArray()),
},
new ArgonKeyCounter(totalTrigger = new KeyCounterTotalTrigger())
{
Margin = new MarginPadding { Left = -50 },
},
new SmoothPath
{
PathRadius = 1f,
Colour = Color4.White.Opacity(0.5f),
Margin = new MarginPadding { Top = ArgonKeyCounter.LINE_HEIGHT * ArgonKeyCounter.SCALE_FACTOR / 2f - 1f },
Vertices = PathApproximator.ApproximateBezier(new[]
{
// todo: this is silly but it works
new Vector2(0, 0),
new Vector2(13, 0),
new Vector2(13, 0),
new Vector2(13, 0),
new Vector2(52, 40),
new Vector2(52, 40),
new Vector2(52, 40),
new Vector2(86, 40),
}.Select(v => v * ArgonKeyCounter.SCALE_FACTOR).ToArray()),
},
}
};
}

protected override void LoadComplete()
{
base.LoadComplete();

foreach (var trigger in KeyFlow.Children.Select(c => c.Trigger))
{
trigger.OnActivate += totalTrigger.Activate;
trigger.OnDeactivate += totalTrigger.Deactivate;
}
}

protected override void Update()
{
base.Update();
Expand All @@ -36,5 +111,16 @@ protected override void Update()

protected override void UpdateVisibility()
=> KeyFlow.FadeTo(AlwaysVisible.Value || ConfigVisibility.Value ? 1 : 0, duration);

private partial class KeyCounterTotalTrigger : InputTrigger
{
public KeyCounterTotalTrigger()
: base("Total")
{
}

public new void Activate(bool forwardPlayback) => base.Activate(forwardPlayback);
public new void Deactivate(bool forwardPlayback) => base.Deactivate(forwardPlayback);
}
}
}
6 changes: 3 additions & 3 deletions osu.Game/Skinning/ArgonSkin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ public ArgonSkin(SkinInfo skin, IStorageResourceProvider resources)
// Hard to find this at runtime, so taken from the most expanded state during replay.
const float song_progress_offset_height = 36 + padding;
keyCounter.Anchor = Anchor.BottomRight;
keyCounter.Origin = Anchor.BottomRight;
keyCounter.Position = new Vector2(-(hitError.Width + padding), -(padding * 2 + song_progress_offset_height));
keyCounter.Anchor = Anchor.BottomLeft;
keyCounter.Origin = Anchor.BottomLeft;
keyCounter.Position = new Vector2(0, -(padding * 2 + song_progress_offset_height));
}
}
}
Expand Down

0 comments on commit 2ec068a

Please sign in to comment.