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

Move combo counter to ruleset-specific HUD components container #26249

Merged
merged 13 commits into from
Aug 8, 2024

Conversation

frenzibyte
Copy link
Member

Prerequisite for adding ruleset-specific combo counter implementations (e.g. mania). Also removes HiddenByRulesetImplementation in favour of overriding the default layout from within ruleset skin transformers.

For a ruleset to override the default display of the combo counter, it would handle lookups to MainHUDComponents with a non-null ruleset inside the ruleset skin transformer. A call to Skin.GetDrawableComponent is made first, to allow presenting user customisations. If null, then a default layout of the ruleset-specific combo counter is returned.

The pattern above will be taken into practice in follow-up PRs.

osu.Game/Rulesets/Ruleset.cs Outdated Show resolved Hide resolved
osu.Game/Skinning/LegacySkinTransformer.cs Outdated Show resolved Hide resolved
osu.Game/Skinning/LegacySkinTransformer.cs Outdated Show resolved Hide resolved
@bdach
Copy link
Collaborator

bdach commented Jun 24, 2024

@frenzibyte can you respond to reviews on this? would like to see movement here

@frenzibyte
Copy link
Member Author

I've kept this away from my sight as I was focusing on song select redesign, but I'll try soon.

@frenzibyte
Copy link
Member Author

A casualty from this PR occurred on all lazer-modified skins where the combo counter would be duplicated between non-ruleset and ruleset HUD targets. This is due to the skin containing custom layout on non-ruleset HUD target that includes a combo counter. Not sure how to easily fix...I will probably need to add some logic to migrate custom layout information of the combo counter to the correct target.

@frenzibyte
Copy link
Member Author

frenzibyte commented Jun 25, 2024

The above comment should be resolved with 78e0126 (I may have improvised too much on the direction though, it works at least).

osu.Game/Skinning/SkinInfo.cs Outdated Show resolved Hide resolved
osu.Game/Skinning/SkinInfo.cs Outdated Show resolved Hide resolved
osu.Game/Skinning/LegacySkin.cs Outdated Show resolved Hide resolved
@peppy peppy self-requested a review June 29, 2024 07:25
Comment on lines +33 to +34
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
public int Version = LATEST_VERSION;
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know if I'm approaching this correctly but I'm using DefaultValueHandling.Populate so that when deserialising any skin prior to this PR, the value of Version will be assigned to 0 (default int value) instead of LATEST_VERSION.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The documentation on this is hilariously bad:

Members with a default value but no JSON will be set to their default value when deserializing.

Like that sounds like the inverse to the actual desired behaviour here. That said, as far as my real-world testing is concerned, this does appear to function as advertised...

Comment on lines +266 to +274
resources.RealmAccess.Run(r =>
{
foreach (var ruleset in r.All<RulesetInfo>())
{
layout.Update(ruleset, layout.TryGetDrawableInfo(ruleset, out var rulesetHUDComponents)
? rulesetHUDComponents.Concat(comboCounters).ToArray()
: comboCounters);
}
});
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure how well this will sit with everyone, but it's the easiest way to access the rulesets that the user has locally to populate the layout with.

Alternative approach would be to take the entirety of this migration logic to SkinManager as a post-process of selecting the skin (i.e. changing the CurrentSkinInfo bindable), so that it would at least make more sense to access realm or the ruleset store directly...but I'm not sure if it's really worth the effort over a simple Realm query in here (which could be further improved by adding the ruleset store to the IStorageResourceProvider interface).

Copy link
Collaborator

Choose a reason for hiding this comment

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

No issues from me, not sure why I'd ever have a problem with this

@frenzibyte frenzibyte force-pushed the ruleset-specific-combo-counter branch from 73f363c to dce1b4e Compare July 1, 2024 05:32
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.

The migration logic is much better.

I'm fine with this in principle but will want a @peppy cross-check to ensure this does not interfere with any ongoing skinning changes in a dealbreaking way.

Comment on lines +214 to +217
// handle namespace changes...
jsonContent = jsonContent.Replace(@"osu.Game.Screens.Play.SongProgress", @"osu.Game.Screens.Play.HUD.DefaultSongProgress");
jsonContent = jsonContent.Replace(@"osu.Game.Screens.Play.HUD.LegacyComboCounter", @"osu.Game.Skinning.LegacyComboCounter");
jsonContent = jsonContent.Replace(@"osu.Game.Screens.Play.HUD.PerformancePointsCounter", @"osu.Game.Skinning.Triangles.TrianglesPerformancePointsCounter");
Copy link
Collaborator

Choose a reason for hiding this comment

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

I digress but I wonder how long this crap will have to live... I'd hope we can remove it in a few months or something.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, technically this can live on as part of the migration process for 100% compatibility, I was just unable to move it into the actual migration method because it manipulates the JSON string itself before deserialising it.

Comment on lines +266 to +274
resources.RealmAccess.Run(r =>
{
foreach (var ruleset in r.All<RulesetInfo>())
{
layout.Update(ruleset, layout.TryGetDrawableInfo(ruleset, out var rulesetHUDComponents)
? rulesetHUDComponents.Concat(comboCounters).ToArray()
: comboCounters);
}
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

No issues from me, not sure why I'd ever have a problem with this

&& containerLookup.Target == SkinComponentsContainerLookup.TargetArea.MainHUDComponents
&& containerLookup.Ruleset != null)
{
return base.GetDrawableComponent(lookup) ?? new Container
Copy link
Member

Choose a reason for hiding this comment

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

I've hopefully resolved conflicts, but I still have a lot of questions.

Will start with a simple question: why is this here now? Why does ArgonSkinTransformer have to exist? Transformers were supposed to allow rulesets to do things, but you have changed what transformer means now, as this is being instantiated by Ruleset.

Copy link
Member

Choose a reason for hiding this comment

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

On further reading and understanding of this PR, the probable answer is "because I wanted to be able to provide a per-skin default for cases where a ruleset doesn't do anything special", does that sound right?

Copy link
Member

Choose a reason for hiding this comment

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

@frenzibyte I've applied 60d3834 which removes this stuff. please give it 5 minutes and let me know if it makes sense within that time limit.

Copy link
Member Author

Choose a reason for hiding this comment

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

That is correct.

Copy link
Member Author

Choose a reason for hiding this comment

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

@frenzibyte I've applied 60d3834 which removes this stuff. please give it 5 minutes and let me know if it makes sense within that time limit.

I...don't know. It looks correct, but I feel it's introducing another level of complexity to the lookup system in my head / when parsing this mentally. I wouldn't say that the way I had it is better, though.

This is all cheap talk and I cannot easily imagine how it can be put to code, but, it definitely feels like there should be two methods:

  1. Skin.GetDrawableComponent, which tries to look up user configuration, then fall back to...
  2. Skin.GetDefaultDrawableComponent, which returns default skin implementation, and that can be transformed by a skin transformer somehow.

I'm proposing this for Skin specifically because it is the class that introduces the concept of "user configuration".

Copy link
Member

@peppy peppy Aug 8, 2024

Choose a reason for hiding this comment

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

This is all cheap talk and I cannot easily imagine how it can be put to code, but, it definitely feels like there should be two methods

Yep, in previous discussions with smoogi this was unanimously agreed upon, but I'm not doing that here. It will be a separate step after all your changes are merged.

I don't see any complexity being added here. I'm just explicitly defining which early returns are due to "skin has user layout".

Copy link
Member Author

Choose a reason for hiding this comment

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

As long as it's all temporary until a split happens then I'm fine looking away, I can't easily explain why this feels complicated in my head.

@peppy peppy added priority:1 Very important. Feels bad without fix. Affects the majority of users. and removed priority:1 Very important. Feels bad without fix. Affects the majority of users. labels Aug 7, 2024
@peppy peppy self-requested a review August 8, 2024 06:43
This didn't make any sense, so let's do it a better way.
@peppy peppy self-assigned this Aug 8, 2024
@peppy peppy force-pushed the ruleset-specific-combo-counter branch from 02a370f to 88c5997 Compare August 8, 2024 07:37
@peppy peppy merged commit dcafee7 into ppy:master Aug 8, 2024
10 of 13 checks passed
@frenzibyte frenzibyte deleted the ruleset-specific-combo-counter branch August 8, 2024 08:55
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.

3 participants