-
-
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
Move combo counter to ruleset-specific HUD components container #26249
Conversation
osu.Game.Rulesets.Catch/Skinning/Legacy/CatchLegacySkinTransformer.cs
Outdated
Show resolved
Hide resolved
@frenzibyte can you respond to reviews on this? would like to see movement here |
I've kept this away from my sight as I was focusing on song select redesign, but I'll try soon. |
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. |
The above comment should be resolved with 78e0126 (I may have improvised too much on the direction though, it works at least). |
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] | ||
public int Version = LATEST_VERSION; |
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 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
.
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.
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...
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); | ||
} | ||
}); |
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.
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).
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.
No issues from me, not sure why I'd ever have a problem with this
73f363c
to
dce1b4e
Compare
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.
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.
// 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"); |
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 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.
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.
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.
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); | ||
} | ||
}); |
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.
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 |
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 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? Transformer
s were supposed to allow rulesets to do things, but you have changed what transformer means now, as this is being instantiated by Ruleset
.
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.
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?
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.
@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.
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.
That is correct.
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.
@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:
Skin.GetDrawableComponent
, which tries to look up user configuration, then fall back to...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".
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.
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".
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.
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.
This didn't make any sense, so let's do it a better way.
02a370f
to
88c5997
Compare
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 toSkin.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.