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 NRT to all skin editor classes #22430

Merged
merged 5 commits into from
Feb 2, 2023
Merged

Conversation

peppy
Copy link
Sponsor Member

@peppy peppy commented Jan 26, 2023

Doing some clean-up passes before adding more to the skin editor because the... skinning namespace is a bit shocking.

@@ -342,7 +344,7 @@ public void Save()
currentSkin.Value.UpdateDrawableTarget(t);

skins.Save(skins.CurrentSkin.Value);
onScreenDisplay?.Display(new SkinEditorToast(ToastStrings.SkinSaved, currentSkin.Value.SkinInfo.ToString()));
onScreenDisplay?.Display(new SkinEditorToast(ToastStrings.SkinSaved, currentSkin.Value.SkinInfo.ToString() ?? "Unknown"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure I would have bothered to fall back with this one. It's only an issue because this is object.ToString() which is allowed to return string?. In practice a Live<SkinInfo> should never return null from ToString().

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

What would you prefer in this scenario? .AsNonNull()? Seems like one which is going to come up quite regularly..

Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably .AsNonNull() yeah. Not that it matters much.

Comment on lines +31 to +32
[Resolved]
private OsuGame game { get; set; } = null!;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Was this dependency on OsuGame intentionally changed from optional to required here?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

Yeah, there were already usages where it wasn't null-checked (see Update()) and it does seem required for this overlay to work as expected.

Of note, this is SkinEditorOvleray, the component which creates a SkinEditor for the current screen.

osu.Game/Skinning/Editor/SkinEditorSceneLibrary.cs Outdated Show resolved Hide resolved
@@ -79,7 +75,7 @@ public SkinnableSound([NotNull] ISampleInfo sample)
/// <summary>
/// The samples that should be played.
/// </summary>
public ISampleInfo[] Samples
public ISampleInfo[]? Samples
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a bit awful... The property can accept null to unset the samples (and this is used in places), but will never return null. Which is tripping a code quality inspection as well (albeit in a test scene).

Don't necessarily have any good ideas what to do here. Simplest thing would be to just make the test shut up. But it'd be nice to actually have this not nullable - maybe there could be a ClearSamples() convenience method or something?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

Yeah I was worried about this, but didn't want to expand the scope of this PR further. I'll see if the non-nullable route requires minimal changes.

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.

Pretty okay with this, but will request a second review for the ClearSamples() thing as it's slightly API-breaking.

@bdach bdach requested a review from a team January 28, 2023 09:42
@peppy
Copy link
Sponsor Member Author

peppy commented Feb 2, 2023

Going to get this one in, as it's part of a chain of PRs I have that are co-dependent.

@peppy peppy merged commit 10df644 into ppy:master Feb 2, 2023
@peppy peppy deleted the skin-editor-nrt branch February 2, 2023 05:02
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.

2 participants