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

Only show components in skin editor which are usable on the current screen #17279

Merged
merged 11 commits into from Mar 18, 2022

Conversation

peppy
Copy link
Sponsor Member

@peppy peppy commented Mar 16, 2022

@bdach
Copy link
Collaborator

bdach commented Mar 16, 2022

I'm just going to review this wholesale with the third dependency not here since that one is a bit circular...

Comment on lines +72 to +75
fill.Add(new ToolboxComponentButton(instance, target)
{
RequestPlacement = t => RequestPlacement?.Invoke(t)
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

So if I understand this correctly, this add is what actually holds the invariant that only usable components are shown on their corresponding screens, and it works because the synchronous add causes a synchronous load which fails after dependencies are not found in the borrowing container, and therefore the element is finally not added.

I guess it works but I feel some reservations towards that - it feels a bit too magic if I'm honest and needs to be properly xmldoc'd / signposted. Like right now SongProgress are visible when skin editing song select because they have nullable dependencies. The try-catch is also doing a lot of magic - any old other failure that isn't a DI failure will also make the component disappear. I'd be more fine with catching a DI-specific exception and logging any other unexpected one.

Dunno, probably going to wait for @smoogipoo's thoughts on this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it's okay for now? Definitely needs documentation though.

Copy link
Member

Choose a reason for hiding this comment

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

The try-catch is also doing a lot of magic - any old other failure that isn't a DI failure will also make the component disappear. I'd be more fine with catching a DI-specific exception and logging any other unexpected one.

I also agree with this bit for better safety, DependencyNotRegisteredException should be enough to indicate a DI failure.

@bdach bdach requested a review from smoogipoo March 16, 2022 20:33
All other similar UI components have required dependencies, so this is
mainly to bring things in line with expectations. I am using this fact
in the skin editor to only show components which can be used in the
current editor context (by `try-catch`ing their
`Activator.CreateInstance`).
@peppy
Copy link
Sponsor Member Author

peppy commented Mar 17, 2022

I've adjusted the exception handling and added some comments. Let me know if that's enough.

frenzibyte
frenzibyte previously approved these changes Mar 17, 2022
@frenzibyte frenzibyte dismissed their stale review March 17, 2022 10:25

tests need attention, nevermind.

@bdach
Copy link
Collaborator

bdach commented Mar 17, 2022

ef29de9 didn't cache enough gameplay clocks to fix all test failures so I cached more.

Seems okay otherwise.

@smoogipoo smoogipoo merged commit af6d53a into ppy:master Mar 18, 2022
@peppy peppy deleted the skin-editor-borrowed-dependencies branch March 18, 2022 07:32
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.

None yet

4 participants