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

Apply draw colour to segmented graph #22285

Merged
merged 3 commits into from
Jan 19, 2023
Merged

Conversation

bdach
Copy link
Collaborator

@bdach bdach commented Jan 18, 2023

This fixes the issue mentioned in #22144 (review), wherein the new argon song progress bar would not hide along with the rest of the HUD.

The segmented graph entirely ignored DrawColourInfo, which meant that the drawable's draw colour did not change how it was drawn at all. In particular, this meant that if the graph was hidden at a higher level, therefore having a transparent draw colour - which is the case with gameplay HUD - it would still continue to draw the exact same way regardless.

The fix is rather self-explanatory and easy. I even made it fully support gradiented colours because I could:

2023-01-18.23-09-50.mp4

@bdach bdach requested a review from a team January 18, 2023 22:21
@bdach bdach self-assigned this Jan 18, 2023
Comment on lines 159 to 170
private ColourInfo getSegmentColour(SegmentInfo segment)
{
var tierColour = segment.Tier >= 0 ? tierColours[segment.Tier] : new Colour4(0, 0, 0, 0);
var ourColour = DrawColourInfo.Colour;

return new ColourInfo
{
TopLeft = tierColour * Interpolation.ValueAt<Colour4>(segment.Start, ourColour.TopLeft, ourColour.TopRight, 0, 1),
TopRight = tierColour * Interpolation.ValueAt<Colour4>(segment.End, ourColour.TopLeft, ourColour.TopRight, 0, 1),
BottomLeft = tierColour * Interpolation.ValueAt<Colour4>(segment.Start, ourColour.BottomLeft, ourColour.BottomRight, 0, 1),
BottomRight = tierColour * Interpolation.ValueAt<Colour4>(segment.End, ourColour.BottomLeft, ourColour.BottomRight, 0, 1)
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar function (getting a colour quad out of source colour) exists in TrianglesV2, probably would be useful to create one in the framework level

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure. I'm looking to get this out the door for a release tomorrow for now though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Here's a simplified version

Suggested change
private ColourInfo getSegmentColour(SegmentInfo segment)
{
var tierColour = segment.Tier >= 0 ? tierColours[segment.Tier] : new Colour4(0, 0, 0, 0);
var ourColour = DrawColourInfo.Colour;
return new ColourInfo
{
TopLeft = tierColour * Interpolation.ValueAt<Colour4>(segment.Start, ourColour.TopLeft, ourColour.TopRight, 0, 1),
TopRight = tierColour * Interpolation.ValueAt<Colour4>(segment.End, ourColour.TopLeft, ourColour.TopRight, 0, 1),
BottomLeft = tierColour * Interpolation.ValueAt<Colour4>(segment.Start, ourColour.BottomLeft, ourColour.BottomRight, 0, 1),
BottomRight = tierColour * Interpolation.ValueAt<Colour4>(segment.End, ourColour.BottomLeft, ourColour.BottomRight, 0, 1)
};
private ColourInfo getSegmentColour(SegmentInfo segment)
{
var subQuad = new ColourInfo
{
TopLeft = DrawColourInfo.Colour.Interpolate(new Vector2(segment.Start, 0f)),
TopRight = DrawColourInfo.Colour.Interpolate(new Vector2(segment.End, 0f)),
BottomLeft = DrawColourInfo.Colour.Interpolate(new Vector2(segment.Start, 1f)),
BottomRight = DrawColourInfo.Colour.Interpolate(new Vector2(segment.End, 1f))
};
subQuad.ApplyChild(segment.Tier >= 0 ? tierColours[segment.Tier] : new Colour4(0, 0, 0, 0));
return subQuad;
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Applied with minor variations, thanks.

@pull-request-size pull-request-size bot added size/M and removed size/S labels Jan 18, 2023
@peppy peppy merged commit db80845 into ppy:master Jan 19, 2023
@bdach bdach deleted the segmented-graph-tint branch January 19, 2023 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants