-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
221 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,104 @@ | ||
using fluXis.Game.Map.Drawables; | ||
using fluXis.Game.Online.API.Requests.MapSets; | ||
using fluXis.Game.Online.Fluxel; | ||
using osu.Framework.Allocation; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using fluXis.Game.Map.Drawables; | ||
using fluXis.Shared.Components.Maps; | ||
using fluXis.Shared.Components.Users; | ||
using NUnit.Framework; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Containers; | ||
using osuTK; | ||
|
||
namespace fluXis.Game.Tests.Graphics; | ||
|
||
public partial class TestMapCard : FluXisTestScene | ||
{ | ||
[BackgroundDependencyLoader] | ||
private void load(IAPIClient api) | ||
{ | ||
var req = new MapSetRequest(4); | ||
api.PerformRequest(req); | ||
private FillFlowContainer container; | ||
|
||
Add(new MapCard(req.Response.Data) | ||
[SetUp] | ||
public void Setup() => Schedule(() => | ||
{ | ||
Child = container = new FillFlowContainer() | ||
{ | ||
AutoSizeAxes = Axes.Both, | ||
Direction = FillDirection.Vertical, | ||
Spacing = new Vector2(10), | ||
Anchor = Anchor.Centre, | ||
Origin = Anchor.Centre | ||
}; | ||
}); | ||
|
||
private APIMapSet create(Action<APIMapSet> func = null) | ||
{ | ||
var set = new APIMapSet() | ||
{ | ||
ID = 1, | ||
Creator = APIUser.CreateUnknown(1), | ||
Title = "super cool song with a long name", | ||
Artist = "super cool artist", | ||
Source = "somewhere", | ||
Tags = new[] { "some", "cool", "and fitting", "tags" }, | ||
Maps = new List<APIMap> | ||
{ | ||
new() | ||
{ | ||
ID = 1, | ||
MapSetID = 1, | ||
Mapper = APIUser.CreateUnknown(1), | ||
SHA256Hash = "veryvalidhash", | ||
Difficulty = "hard", | ||
Title = "super cool song", | ||
Artist = "super cool artist", | ||
Source = "somewhere", | ||
Tags = "some, cool, and fitting, tags", | ||
Mode = 4, | ||
Status = 0, | ||
BPM = 120, | ||
Length = 12000, | ||
NoteCount = 456, | ||
LongNoteCount = 32, | ||
MaxCombo = 488, | ||
NotesPerSecond = 14.24, | ||
Rating = 8, | ||
UpVotes = 4, | ||
DownVotes = 6, | ||
FileName = "195769352.fsc" | ||
} | ||
} | ||
}; | ||
|
||
func?.Invoke(set); | ||
return set; | ||
} | ||
|
||
[Test] | ||
public void TestDefault() | ||
{ | ||
AddStep("add default", () => container.Child = new MapCard(create())); | ||
} | ||
|
||
[Test] | ||
public void TestFlags() | ||
{ | ||
AddStep("add normal", () => container.Add(new MapCard(create()))); | ||
AddStep("add explicit", () => container.Add(new MapCard(create(s => s.Flags |= MapSetFlag.Explicit)))); | ||
AddStep("add featured", () => container.Add(new MapCard(create(s => s.Flags |= MapSetFlag.FeaturedArtist)))); | ||
} | ||
|
||
[Test] | ||
public void TestRankStatus() | ||
{ | ||
var states = Enumerable.Range(0, 4); | ||
AddStep("add all", () => | ||
{ | ||
foreach (var state in states) | ||
container.Add(new MapCard(create(s => s.Status = state))); | ||
}); | ||
} | ||
|
||
[Test] | ||
public void TestNullData() | ||
{ | ||
AddStep("add null", () => container.Child = new MapCard(null)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using fluXis.Game.Graphics.Sprites; | ||
using fluXis.Game.Graphics.UserInterface.Color; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Colour; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Framework.Graphics.Shapes; | ||
|
||
namespace fluXis.Game.Graphics.UserInterface; | ||
|
||
public partial class RoundedChip : CircularContainer | ||
{ | ||
public string Text { get; init; } = "text"; | ||
public float FontSize { get; init; } = FluXisSpriteText.GetWebFontSize(12); | ||
public ColourInfo TextColour { get; init; } = FluXisColors.Text.Opacity(.75f); | ||
public ColourInfo BackgroundColour { get; init; } = FluXisColors.Background2; | ||
public float SidePadding { get; init; } = 12; | ||
|
||
public RoundedChip() | ||
{ | ||
AutoSizeAxes = Axes.X; | ||
Height = 20; | ||
} | ||
|
||
[BackgroundDependencyLoader] | ||
private void load() | ||
{ | ||
Masking = true; | ||
|
||
InternalChildren = new Drawable[] | ||
{ | ||
new Box | ||
{ | ||
RelativeSizeAxes = Axes.Both, | ||
Colour = BackgroundColour | ||
}, | ||
new FluXisSpriteText | ||
{ | ||
Text = Text, | ||
FontSize = FontSize, | ||
Colour = TextColour, | ||
Anchor = Anchor.Centre, | ||
Origin = Anchor.Centre, | ||
Margin = new MarginPadding { Horizontal = SidePadding } | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.