Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix difficulty icon tooltip not displaying duration above 1 hour correctly #30613

Merged
merged 5 commits into from
Nov 14, 2024

Conversation

shinmorisawa
Copy link
Contributor

this will fix #30612, but as a downside, it will always show the hour.

Copy link
Collaborator

@bdach bdach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can't always show the hour. Please modify the pull request such that it doesn't always show the hour.

@shinmorisawa
Copy link
Contributor Author

yes

@shinmorisawa
Copy link
Contributor Author

i believe this is what you meant?

@Joehuu
Copy link
Member

Joehuu commented Nov 13, 2024

This should use ToFormattedDuration(), which is used in the other length displays.

@shinmorisawa
Copy link
Contributor Author

ok

@@ -146,7 +146,10 @@ public void SetContent(DifficultyIconTooltipContent content)
approachRate.Text = @" AR: " + adjustedDifficulty.ApproachRate.ToString(@"0.##");
overallDifficulty.Text = @" OD: " + adjustedDifficulty.OverallDifficulty.ToString(@"0.##");

length.Text = "Length: " + TimeSpan.FromMilliseconds(displayedContent.BeatmapInfo.Length / rate).ToString(@"mm\:ss");
TimeSpan lengthTimeSpan = TimeSpan.FromMilliseconds(displayedContent.BeatmapInfo.Length / rate);
length.Text = "Length: " + (lengthTimeSpan.Hours > 0
Copy link
Collaborator

@bdach bdach Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct. Counterexample: try any timespan which is a multiple of 24 hours. You would want

Suggested change
length.Text = "Length: " + (lengthTimeSpan.Hours > 0
length.Text = "Length: " + (lengthTimeSpan.TotalHours >= 1

See docs to understand the difference.

Then again, as above, there's an established helper for this already.

@@ -146,7 +146,10 @@ public void SetContent(DifficultyIconTooltipContent content)
approachRate.Text = @" AR: " + adjustedDifficulty.ApproachRate.ToString(@"0.##");
overallDifficulty.Text = @" OD: " + adjustedDifficulty.OverallDifficulty.ToString(@"0.##");

length.Text = "Length: " + TimeSpan.FromMilliseconds(displayedContent.BeatmapInfo.Length / rate).ToString(@"mm\:ss");
TimeSpan lengthTimeSpan = TimeSpan.FromMilliseconds(displayedContent.BeatmapInfo.Length / rate);
length.Text = "Length: " + (lengthTimeSpan.Hours > 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something like this would be cleaner

length.Text = "Length: " + lengthTimeSpan.ToString(lengthTimeSpan.TotalHours >= 1 ? @"hh\:mm\:ss" : @"mm\:ss");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense

@shinmorisawa shinmorisawa marked this pull request as draft November 13, 2024 22:34
@shinmorisawa shinmorisawa marked this pull request as ready for review November 14, 2024 07:35
Copy link
Collaborator

@bdach bdach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bdach bdach changed the title Fix multi tooltip Fix difficulty icon tooltip not displaying duration above 1 hour correctly Nov 14, 2024
@bdach bdach merged commit 15a474d into ppy:master Nov 14, 2024
10 checks passed
@shinmorisawa shinmorisawa deleted the 1hour-song-multi branch December 9, 2024 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Songs longer than 1 hour in multiplayer don't show on hover of diff
4 participants