Skip to content

Commit

Permalink
completely remake results (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
flustix committed Sep 1, 2024
1 parent 4041b39 commit 462c1c2
Show file tree
Hide file tree
Showing 58 changed files with 1,253 additions and 2,476 deletions.
74 changes: 0 additions & 74 deletions fluXis.Game.Tests/Results/TestNewResults.cs

This file was deleted.

22 changes: 0 additions & 22 deletions fluXis.Game.Tests/Results/TestResultsRating.cs

This file was deleted.

62 changes: 0 additions & 62 deletions fluXis.Game.Tests/Results/TestResultsScreen.cs

This file was deleted.

103 changes: 103 additions & 0 deletions fluXis.Game.Tests/Screens/TestResults.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
using System.Collections.Generic;
using fluXis.Game.Database.Maps;
using fluXis.Game.Map;
using fluXis.Game.Online.API;
using fluXis.Game.Online.API.Requests.Scores;
using fluXis.Game.Screens;
using fluXis.Game.Screens.Result;
using fluXis.Shared.API.Responses.Scores;
using fluXis.Shared.Components.Scores;
using fluXis.Shared.Components.Users;
using fluXis.Shared.Scoring;
using fluXis.Shared.Scoring.Enums;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Logging;

namespace fluXis.Game.Tests.Screens;

public partial class TestResults : FluXisTestScene
{
[Resolved]
private MapStore maps { get; set; }

private FluXisScreenStack stack;

[BackgroundDependencyLoader]
private void load()
{
CreateClock();
}

[SetUp]
public void Setup() => Schedule(() =>
{
Children = new Drawable[]
{
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Top = 60 },
Child = stack = new FluXisScreenStack()
}
};
});

private RealmMap getMap()
{
var set = maps.GetFromGuid("9896365c-5541-4612-9f39-5a44aa1012ed");
return set?.Maps[0] ?? maps.MapSets[0].Maps[0];
}

private ScoreInfo getScore() => new()
{
Accuracy = 98.661736f,
Rank = ScoreRank.S,
PerformanceRating = 8,
Score = 1139289,
MaxCombo = 1218,
Flawless = 898,
Perfect = 290,
Great = 30,
Alright = 0,
Okay = 0,
Miss = 0,
Mods = new List<string> { "1.5x" }
};

[Test]
public void FromGameplay()
{
AddStep("Push", () => stack.Push(new SoloResults(getMap(), getScore(), APIUser.Dummy) { ForceFromGameplay = true }));
}

[Test]
public void Normal()
{
AddStep("Push", () => stack.Push(new SoloResults(getMap(), getScore(), APIUser.Dummy)));
}

[Test]
public void WithRequest()
{
var score = getScore();
AddStep("Push With Request", () => stack.Push(new SoloResults(getMap(), score, APIUser.Dummy) { SubmitRequest = new SimulatedScoreRequest(score) }));
}

[Test]
public void WithRestart()
{
AddStep("Push With Restart", () => stack.Push(new SoloResults(getMap(), getScore(), APIUser.Dummy) { OnRestart = () => Logger.Log("Restart pressed.") }));
}

private class SimulatedScoreRequest : ScoreSubmitRequest
{
public SimulatedScoreRequest(ScoreInfo score)
: base(score)
{
Response = new APIResponse<ScoreSubmissionStats>(200, "", new ScoreSubmissionStats(new APIScore { PerformanceRating = 7 }, 10, 10, 1, 12, 10, 2));
}
}
}
2 changes: 1 addition & 1 deletion fluXis.Game/Graphics/Drawables/DrawableAvatar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private void load()

private void setTexture()
{
if (user != null) // the texture from the online store could still be null
if (user is { ID: >= 0 }) // the texture from the online store could still be null
Texture = store.GetAvatar(user.ID) ?? textures.Get("Online/default-avatar");
else
Texture = textures.Get("Online/default-avatar");
Expand Down
2 changes: 1 addition & 1 deletion fluXis.Game/Graphics/Drawables/DrawableBanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private void load()

private void setTexture()
{
if (user != null) // the texture from the online store could still be null
if (user is { ID: >= 0 }) // the texture from the online store could still be null
Texture = store.GetBanner(user.ID) ?? textures.Get("Online/default-banner");
else
Texture = textures.Get("Online/default-banner");
Expand Down
4 changes: 4 additions & 0 deletions fluXis.Game/Graphics/UserInterface/Text/FluXisTextFlow.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using fluXis.Game.Graphics.Sprites;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;

Expand All @@ -16,6 +18,8 @@ public FluXisTextFlow(Action<SpriteText> defaultCreationParameters = null)
{
}

public ITextPart AddCustom(Drawable drawable) => AddPart(new TextPartManual(drawable.Yield()));

protected override FluXisSpriteText CreateSpriteText() => new()
{
FontSize = FontSize,
Expand Down
30 changes: 30 additions & 0 deletions fluXis.Game/Graphics/UserInterface/Text/ForcedHeightText.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using fluXis.Game.Graphics.Sprites;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Localisation;

namespace fluXis.Game.Graphics.UserInterface.Text;

public partial class ForcedHeightText : CompositeDrawable
{
public LocalisableString Text { get; init; }
public float WebFontSize { set => FontSize = FluXisSpriteText.GetWebFontSize(value); }
public float FontSize { get; set; } = 20;
public bool Shadow { get; init; } = true;

[BackgroundDependencyLoader]
private void load()
{
AutoSizeAxes = Axes.X;

InternalChild = new FluXisSpriteText
{
Text = Text,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
FontSize = FontSize,
Shadow = Shadow
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ private void load(ExperimentConfigManager experiments)
new SettingsToggle
{
Label = "Seeking in replays",
Description = "Might make gameplay with a lot of effects more laggy.",
Bindable = experiments.GetBindable<bool>(ExperimentConfig.Seeking)
}
});
Expand Down
4 changes: 3 additions & 1 deletion fluXis.Game/Screens/Gameplay/GameplayScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
using fluXis.Game.Skinning.Default;
using fluXis.Game.Storyboards;
using fluXis.Game.Storyboards.Drawables;
using fluXis.Shared.Components.Users;
using fluXis.Shared.Replays;
using fluXis.Shared.Scoring.Enums;
using fluXis.Shared.Utils;
Expand Down Expand Up @@ -80,6 +81,7 @@ public partial class GameplayScreen : FluXisScreen, IKeyBindingHandler<FluXisGlo
public virtual bool FadeBackToGlobalClock => true;
public virtual bool SubmitScore => true;
protected virtual bool UseGlobalOffset => true;
protected virtual APIUser CurrentPlayer => api.User.Value;

protected bool CursorVisible { get; set; }

Expand Down Expand Up @@ -474,7 +476,7 @@ protected virtual void End()

Task.Run(() =>
{
var player = api.User.Value;
var player = CurrentPlayer;

var bestScore = scores.GetCurrentTop(RealmMap.ID);

Expand Down
2 changes: 2 additions & 0 deletions fluXis.Game/Screens/Gameplay/Replays/ReplayGameplayScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using fluXis.Game.Online.Activity;
using fluXis.Game.Screens.Gameplay.Input;
using fluXis.Game.Utils.Extensions;
using fluXis.Shared.Components.Users;
using fluXis.Shared.Replays;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
Expand All @@ -22,6 +23,7 @@ public partial class ReplayGameplayScreen : GameplayScreen
protected override bool InstantlyExitOnPause => true;
public override bool SubmitScore => false;
protected override bool UseGlobalOffset => !Config.Get<bool>(FluXisSetting.DisableOffsetInReplay);
protected override APIUser CurrentPlayer => replay.GetPlayer(users);

[Resolved]
private UserCache users { get; set; }
Expand Down
Loading

0 comments on commit 462c1c2

Please sign in to comment.