Skip to content

Commit

Permalink
添加美元符号,去除不必要的代码
Browse files Browse the repository at this point in the history
哈哈傻逼
  • Loading branch information
cdwcgt committed Nov 14, 2024
1 parent fee4b6b commit 9f02ca0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 41 deletions.
42 changes: 8 additions & 34 deletions osu.Game.Tournament/Components/RollingSignNumberContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,32 @@

using System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;

namespace osu.Game.Tournament.Components
{
public partial class RollingSignNumberContainer : CommaSeparatedScoreCounter
public partial class RollingSignNumberContainer : RollingCounter<double>
{
protected override double RollingDuration => 500;

protected override IHasText CreateText() => new SignNumberContainer(CreateSpriteText);
protected override Easing RollingEasing => Easing.Out;

protected override double GetProportionalDuration(double currentValue, double newValue) =>
currentValue > newValue ? currentValue - newValue : newValue - currentValue;

protected override OsuSpriteText CreateSpriteText() => new OsuSpriteText
{
Font = OsuFont.Torus.With(size: 20),
};

protected override LocalisableString FormatCount(double count) => count.ToString("N1");

public partial class SignNumberContainer : CompositeDrawable, IHasText
protected override LocalisableString FormatCount(double count)
{
private readonly OsuSpriteText text;

public LocalisableString Text
{
get => text.Text;
set
{
if (!double.TryParse(value.ToString().Replace(",", ""), out double result))
{
text.Text = "+0";
}

char sign = Math.Sign(result) == -1 ? '-' : '+';

text.Text = $"{sign}{Math.Abs(result)}";
}
}

public SignNumberContainer(Func<OsuSpriteText> createSpriteText)
{
AutoSizeAxes = Axes.Both;
char sign = Math.Sign(count) == -1 ? '-' : '+';

InternalChild = text = createSpriteText().With(t =>
{
t.Anchor = Anchor.Centre;
t.Origin = Anchor.Centre;
});
}
return $"{sign}{Math.Abs(count):N1}";
}
}
}
30 changes: 23 additions & 7 deletions osu.Game.Tournament/Screens/Gameplay/Components/TeamMultCoin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,13 @@ public TeamMultCoin(Bindable<double?> coin, TeamColour colour)
diffCounterBackground = new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
//Alpha = 0,
Colour = Color4Extensions.FromHex("#00D415")
},
diffCounter = new RollingMultDiffNumberContainer
{
Margin = new MarginPadding { Horizontal = 3f },
},
diffCounter = new RollingMultDiffNumberContainer(),
}
},
warningText = new TournamentSpriteText
Expand Down Expand Up @@ -217,16 +221,16 @@ private void updateScore(bool keepDiff = false)
if (ipc.State.Value == TourneyState.Playing)
{
diff = calculateDiffFromIpc();
warningText.FadeIn(100);
diffCounter.FadeColour(Color4Extensions.FromHex("EBBC23"), 100);
//warningText.FadeIn(100);
//diffCounter.FadeColour(Color4Extensions.FromHex("EBBC23"), 100);
}

diffBar.ResizeWidthTo(calculateBarWidth(diff), 400, Easing.OutQuint);

if (!keepDiff)
{
diffCounter.Current.Value = diff;
diffCounterBackground.FadeOut(100);
//diffCounterBackground.FadeOut(100);
}
}

Expand Down Expand Up @@ -272,13 +276,25 @@ protected override void UpdateAfterChildren()
multCounter.X = Math.Max(5, barContainer.DrawWidth - multCounter.DrawWidth) * (flip ? -1 : 1);
}

private partial class RollingMultDiffNumberContainer : RollingSignNumberContainer
private partial class RollingMultDiffNumberContainer : RollingCounter<double>
{
protected override double RollingDuration => 1000;

protected override Easing RollingEasing => Easing.Out;

protected override LocalisableString FormatCount(double count)
{
char sign = Math.Sign(count) == -1 ? '-' : '+';

return $"{sign}${Math.Abs(count):N1}";
}

protected override OsuSpriteText CreateSpriteText() => base.CreateSpriteText().With(t =>
{
t.Font = t.Font.With(size: 15);
t.Font = OsuFont.Torus.With(size: 15);
t.Shadow = true;
t.ShadowColour = Color4.Black.Opacity(0.3f);
t.ShadowOffset = new Vector2(0, 0.05f);
});
}

Expand Down

0 comments on commit 9f02ca0

Please sign in to comment.