public void AddEntry_FloatingPointScore_IsRoundedUp() { var input = "empty.json"; AddStep($"Add leaderboard {input}", () => Add(Leaderboard = new LeaderboardContainer(StoryDirectory, input, new()))); AddStep("Add entry", () => Leaderboard.AddEntry("test", 99.999)); AddAssert($"Is rounded up", () => Leaderboard.LeaderboardData.First().Score == "100"); }
public void Load_ValidLeaderboardFile_HasThreeEntries() { var input = "valid.json"; AddStep($"Add leaderboard {input}", () => { Leaderboard = new LeaderboardContainer(StoryDirectory, input) { Width = 540, Height = 360, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }; Add(Leaderboard); }); AddAssert($"Valid leaderboard with 3 entries", () => Leaderboard.EntryCount == 3); }
public void Load_InvalidLeaderboardFile_HasMinusOneEntries() { var input = "invalid.json"; AddStep($"Add leaderboard {input}", () => { Leaderboard = new LeaderboardContainer(StoryDirectory, input) { Width = 540, Height = 360, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }; Add(Leaderboard); }); AddAssert($"Invalid leaderboard has -1 entries", () => Leaderboard.EntryCount == -1); }
public void Load_NoLeaderboardFile_HasZeroEntries() { var input = "doesNotExist.json"; AddStep($"Add leaderboard {input}", () => { Leaderboard = new LeaderboardContainer(StoryDirectory, input) { Width = 540, Height = 360, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }; Add(Leaderboard); }); AddAssert($"No leaderboard file has 0 entries", () => Leaderboard.EntryCount == 0); }
public void AddEntry_IncrementsEntryCountByOne() { var input = "increment.json"; ScoreStatistics scoreStatistics = new(); var oldEntryCount = -1; AddStep($"Add leaderboard {input}", () => { Leaderboard = new LeaderboardContainer(StoryDirectory, input, scoreStatistics) { Width = 540, Height = 360, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }; Add(Leaderboard); }); AddStep($"Save old EntryCount", () => oldEntryCount = Leaderboard.EntryCount); AddStep($"Add entry", () => Leaderboard.AddEntry("test", 123)); AddAssert($"New EntryCount is one more", () => Leaderboard.EntryCount == oldEntryCount + 1); }
/// <summary> /// Creates the container that houses the leaderboard. /// </summary> private void CreateLeaderboard() => Leaderboard = new LeaderboardContainer(this) { Parent = Container, Position = new ScalableVector2(28 - Banner.Border.Thickness, LeaderboardSelector.Y + LeaderboardSelector.Height + 10) };
private void Load() { var width = Width; var songInfoHeight = width * 0.4f; var leaderboardWidth = width * 0.6f; var leaderboardHeight = width * 0.4f; var btnHeight = width * 0.2f; var spacingMargin = 0.05f; var textSize = SizeConsts.TextSize1; var thumbnailSize = width * 0.3f; var btnSize = new Vector2(width / 5, width / 10); BtnEdit = new() { Origin = Anchor.Centre, Anchor = Anchor.Centre, Size = btnSize, Icon = FontAwesome.Solid.Edit, BorderColour = Color4.Red, Masking = true, Action = LoadEditor }; BtnPlay = new() { Origin = Anchor.Centre, Anchor = Anchor.Centre, Size = btnSize, Icon = FontAwesome.Solid.Play, BorderColour = Color4.Red, Masking = true, Action = LoadPlay }; InternalChildren = new Drawable[] { // TODO: add blurred background new FillFlowContainer { Width = width, Height = songInfoHeight, Children = new Drawable[] { // Thumbnail new IconButton { Size = new Vector2(thumbnailSize), Anchor = Anchor.TopLeft, Origin = Anchor.TopLeft, Margin = new MarginPadding { Horizontal = width * spacingMargin, Vertical = width * spacingMargin, }, Texture = ThumbnailTexture, TextureName = "logo", }, TextContainer = new TextFlowContainer(s => s.Font = new FontUsage("default", textSize)) { Width = width - thumbnailSize - width * spacingMargin * 2, Height = songInfoHeight, Margin = new MarginPadding { Vertical = width * spacingMargin, }, TextAnchor = Anchor.TopLeft, Colour = Color4.White, // TODO: truncate text if it's too long }, } }, LeaderboardContainer = new LeaderboardContainer(StoryDirectory) { Width = leaderboardWidth, Height = leaderboardHeight, Y = songInfoHeight, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }, new FillFlowContainer { Width = width, Height = btnHeight, Y = songInfoHeight + leaderboardHeight, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Direction = FillDirection.Horizontal, Children = new[] { BtnEdit, BtnPlay, } } }; LoadSongMetadata(); } private void LoadEditor() { try { var story = new S2VXStory(StoryPath, true); var track = S2VXTrack.Open(AudioPath, Audio); Screens.Push(new EditorScreen(story, track)); } catch (Exception exception) { BtnEdit.BorderThickness = 5; Console.WriteLine(exception); } }