8000 Add Seasonal backgrounds by hbnrmx · Pull Request #10586 · ppy/osu · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add Seasonal backgrounds #10586

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

Merged
merged 33 commits into from
Oct 31, 2020
Merged

Add Seasonal backgrounds #10586

merged 33 commits into from
Oct 31, 2020

Conversation

hbnrmx
Copy link
Contributor
@hbnrmx hbnrmx commented Oct 23, 2020

Resolves #7055

PRing this as a first draft because I would like some assistance with the remaining issues.

  1. stable gives the user the option Seasonal Backgrounds: Always / Sometimes (default) / Never
    Not sure if this is worth keeping around in lazers Background source. For now, I only added Seasonal (default)

  2. we definitely need some way of caching or prefetching, but I would like some guidance on which level to do that.

  3. In BackgroundScreenDefault I had to change the initial load to LoadComponentAsync
    because of [LongRunningLoad] but chaining LoadComponentAsyncs like that looks very wrong to me.

@bdach
Copy link
Collaborator
bdach commented Oct 23, 2020

No offence, but I think it would have been wiser to ask your questions in an issue comment. Fetching the images every time is pretty shocking.

Here's a proposal of a completely different flow instead:

  • On game load, check if there are seasonal backgrounds available
  • If there are new backgrounds, fetch them all at once in the background and persist them to storage, then display a notification to the user prompting if they would like to switch
  • If the backgrounds went away, clean up the old ones and restore the user's setting to the one before going to seasonal

Could also have seasonal as a separate option, I guess. It can't be as done currently as every switch to seasonal will then require users to revert back manually.

I would need confirmation on this, though. This is only my idea that I came up with on the fly.

@peppy
Copy link
Member
peppy commented Oct 23, 2020

All at once sounds like not a great idea. Stable currently downloads each time a new one is required asynchronously, and caches after retrieval.

@bdach
Copy link
Collaborator
bdach commented Oct 23, 2020

I guess it's a pretty huge footprint, true. The seasonal background API response should probably persist across the current session, though, to avoid re-querying to check if there is a need to fetch a new one (SessionStatics?)

@hbnrmx
Copy link
Contributor Author
hbnrmx commented Oct 23, 2020

For reference, the current Halloween event has 15 images, so ~6Mb.
SessionStatics only stores boolean configuration values currently, so it may not be built with textures in mind.
That said, I don't know half a thing about caching...

@bdach
Copy link
Collaborator
bdach commented Oct 23, 2020

I was suggesting storing the API response there, not the textures themselves. For textures, the framework LargeTextureStore already does some caching, but I believe it won't have much of an effect here as the textures are refcounted - so if all references to a background are lost the texture will get unloaded, which I think will happen on screen transitions rendering the caching pretty pointless in this particular case.

@PercyDan54
Copy link
Contributor

A suggestion: We might want to split the settings into two
Use seasonal background: Sometimes, always, never
Background Source: Beatmap, Skin

@hbnrmx
Copy link
Contributor Author
hbnrmx commented Oct 29, 2020

@bdach
@PercyDan54

Thanks for your feedback, and sorry I didn't get to this earlier.
In this iteration I

  • split out Seasonal Backgrounds (Always/Sometimes/Never) from Background Source (Beatmap/Skin)
    (I also feel this makes more sense in the case where no seasonal event is happening.)

  • changed background fallback such that Beatmap/Skin source choice
    is respected when no Seasonal event is happening.

  • made SeasonalBackgroundLoader read from SessionStatics
    (this should make sure that the API is queried only once for the index)

This still leaves:

  • repeated texture fetching issue
  • ugly LoadComponentAsync chain as described in the OP. (3)
  • what does the option Sometimes mean? For now, I set it to 50% probability

@peppy
Copy link
Member
peppy commented Oct 30, 2020

"Sometimes" is based off whether we are currently "in season". This is provided by the api response already in the form of a timestamp (ends_at) so you should be able to consume this.

I think the re-fetch of textures is fine for the time being, for what it's worth.

@bdach
Copy link
Collaborator
bdach commented Oct 30, 2020

For the record I've fixed the test failures locally and am currently in the process of writing a test scene for this.

@bdach
Copy link
Collaborator
bdach commented Oct 30, 2020

I've fixed the test failures, made a few stylistic changes, added test coverage, and also added support for delayed fetching of the backgrounds if API is not immediately available on launch, as the game would actually hard-crash if network was not available. The side effect of that change is that even though the API endpoint seems to be guest-accessible, the backgrounds won't be loaded until login, as we don't have an online-but-not-logged-in API state.

Another wonky thing about the API endpoint is that it seems to be responding with an EndTime of essentially DateTimeOffset.Now, which means that Sometimes is now essentially Never. Not sure what that's about...

There's one transition at load that looks a little off that I want to look at but other than that I guess this is ok if we don't want to deal with caching the downloaded assets yet.

@bdach
Copy link
Collaborator
bdach commented Oct 30, 2020

It should be sliiightly better now. The fade in SeasonalBackground.load is a bit dodge but unsure if there's a better way to make sure it just doesn't come in without any transition at all and look absolutely janky.

@peppy peppy merged commit ea007af into ppy:master Oct 31, 2020
@hbnrmx hbnrmx deleted the seasonal-backgrounds branch October 31, 2020 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Seasonal backgrounds
4 participants
0