-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 potential issues with medal display #30877
Open
peppy
wants to merge
10
commits into
ppy:master
Choose a base branch
from
peppy:medal-display-fix
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8585327
Ensure `DrawableMedal` loading doesn't ever block on online resources
peppy d057dc9
Refactor `MedalOverlay` to be more readable
peppy 672dbe6
Better control of show/hide of overlay
peppy e8fae85
Fix hidden dissmissing logic
peppy 1e6c04e
Remove debug logging
peppy 98044c1
Revert "Ensure `DrawableMedal` loading doesn't ever block on online r…
peppy 71294c3
Change point of queueing to avoid loading-from-in-queue
peppy bf29e3a
Simplify hide code by moving to common method
peppy b0958c8
Attempt to fix test failures
bdach c14fe21
Fix LCA call crashing in actual usage
bdach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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 |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
using osu.Framework.Graphics.Containers; | ||
using osu.Framework.Graphics.Sprites; | ||
using osu.Framework.Graphics.Textures; | ||
using osu.Framework.Logging; | ||
using osu.Game.Graphics; | ||
using osu.Game.Graphics.Containers; | ||
using osu.Game.Graphics.Sprites; | ||
|
@@ -28,16 +29,14 @@ public partial class DrawableMedal : Container, IStateful<DisplayState> | |
[CanBeNull] | ||
public event Action<DisplayState> StateChanged; | ||
|
||
private readonly Medal medal; | ||
private readonly Container medalContainer; | ||
private readonly Sprite medalSprite, medalGlow; | ||
private readonly Sprite medalGlow; | ||
private readonly OsuSpriteText unlocked, name; | ||
private readonly TextFlowContainer description; | ||
private DisplayState state; | ||
|
||
public DrawableMedal(Medal medal) | ||
{ | ||
this.medal = medal; | ||
Position = new Vector2(0f, MedalAnimation.DISC_SIZE / 2); | ||
|
||
FillFlowContainer infoFlow; | ||
|
@@ -51,7 +50,7 @@ public DrawableMedal(Medal medal) | |
Alpha = 0f, | ||
Children = new Drawable[] | ||
{ | ||
medalSprite = new Sprite | ||
new DelayedLoadWrapper(() => new MedalOnlineSprite(medal), 0) | ||
{ | ||
Anchor = Anchor.Centre, | ||
Origin = Anchor.Centre, | ||
|
@@ -122,11 +121,12 @@ public DrawableMedal(Medal medal) | |
} | ||
|
||
[BackgroundDependencyLoader] | ||
private void load(OsuColour colours, TextureStore textures, LargeTextureStore largeTextures) | ||
private void load(OsuColour colours, TextureStore textures) | ||
{ | ||
medalSprite.Texture = largeTextures.Get(medal.ImageUrl); | ||
medalGlow.Texture = textures.Get(@"MedalSplash/medal-glow"); | ||
description.Colour = colours.BlueLight; | ||
|
||
Logger.Log("loaded"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pretty non-descript log message. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops, was debug |
||
} | ||
|
||
protected override void LoadComplete() | ||
|
@@ -191,6 +191,31 @@ private void updateState() | |
break; | ||
} | ||
} | ||
|
||
private partial class MedalOnlineSprite : Sprite | ||
{ | ||
private readonly Medal medal; | ||
|
||
public MedalOnlineSprite(Medal medal) | ||
{ | ||
this.medal = medal; | ||
} | ||
|
||
[BackgroundDependencyLoader] | ||
private void load(OsuColour colours, TextureStore textures, LargeTextureStore largeTextures) | ||
{ | ||
Texture = largeTextures.Get(medal.ImageUrl); | ||
|
||
Anchor = Anchor.Centre; | ||
Origin = Anchor.Centre; | ||
} | ||
|
||
protected override void LoadComplete() | ||
{ | ||
base.LoadComplete(); | ||
this.FadeInFromZero(150, Easing.OutQuint); | ||
} | ||
} | ||
} | ||
|
||
public enum DisplayState | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really what we want? Doesn't this mean the medal will display without a texture on slow internet? I would rather it were delayed (by LCA) as it was previously. The LCA and whole "preparing to display" stuff in
MedalOverlay
looks unnecessary now because it's not doing anything that would take a long time to load?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It displays with just the border, along with description etc.
I think this is better than having the whole overlay just sit there loading. You can test by adding a short delay, I don't think it feels too bad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still loading a sample and texture. If a stutter from that is not of concern, then I guess it could be removed, but I'd prefer having it there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why this is better than having the whole overlay sit there loading? I would rather have the overlay look good than to have it display immediately as soon as a medal is awarded, no?
Master:
2024-11-26.16-27-03.mp4
This PR:
2024-11-26.16-25-42.mp4
Have you actually noticed a stutter there...? I'd be highly concerned if that caused a stutter because we do that pattern everywhere else in the game without LCA.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dunno. Perhaps I'm being dense with the above, so will ask for a second opinion from @bdach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, potentially that works. Just have to make sure the load actually still works without the thing loading being present. It would be the refactor I'd look at doing.
I'll give that direction a try and see how it goes. It kind of freaks me out that right now, a loading texture can block medals from ever displaying again (I'm not sure if we have an established "load failed" path for drawables?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that will work because the scheduler (LCA callback) is only updated if the overlay is present. But there's like 1001 different ways to get around that, not the least being to use the scheduler callback on LCA, set AlwaysPresent, or override IsPresent like we do everywhere else.
Edit: In fact,
IsPresent
is already overridden in this class.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I'm aware (that it already does). But I have apprehension due to the latter thing I mentioned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest if that's so hard to handle and DLW is used as a shot-in-the-dark way to handle that, then I'm even less confident about this change. I'm not interested in quick merging this as it was reported once ever, so I would rather it be fixed properly as long as we agree that my dislike of DLW is not insane.
Also I'm not exactly sure what can "fail" here,
OnlineStore
try-catches everything and returnsnull
, and so willTextureStore
. I understand you haven't reproed it (and I haven't either - tested prior to this PR), but that feels like a weird thing to hinge on.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've adjusted this in line with your proposal on discord, see what you think.