Skip to content

TeraNUI 3.0 update: Implemented UISkinTypeHandler.getAsString#4604

Merged
keturn merged 2 commits into
MovingBlocks:nui-gestalt-separationfrom
BenjaminAmos:nui-gestalt-separation__UISkinTypeHandler-subclassing
Apr 1, 2021
Merged

TeraNUI 3.0 update: Implemented UISkinTypeHandler.getAsString#4604
keturn merged 2 commits into
MovingBlocks:nui-gestalt-separationfrom
BenjaminAmos:nui-gestalt-separation__UISkinTypeHandler-subclassing

Conversation

@BenjaminAmos
Copy link
Copy Markdown
Contributor

Description

This pull request attempts to resolve #4598 (comment) through a work-around involving sub-classing UISkin into UISkinWithUrn in order to associate a ResourceUrn with it. When a UISkin is deserialised, then it is copied into a new UISkinWithUrn instance to associate it with the urn it was deserialised with.

How to test

I haven't found anywhere where the serialisation part of this code is used yet whilst debugging, so I am not sure how to test this.

Notes

This is based off #4598 and, if merged, should be merged into it.

Copy link
Copy Markdown
Member

@skaldarnar skaldarnar left a comment

Choose a reason for hiding this comment

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

I'd like to persist the comment we had on this in the code such that we don't forget about it.

If we're not using the feature right now, and we're not really sure whether it should be a feature at all, maybe we should not implement it and see if it breaks anywhere instead?

However, I think this change looks reasonable clean, I'd be fine with merging it when the comment is in.

import java.util.HashMap;
import java.util.Map;

public class UISkinWithUrn extends UISkin {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's add this as a remark here for future reference.

Suggested change
public class UISkinWithUrn extends UISkin {
/**
* [NOTE] Sub-classing UISkin into UISkinWithUrn is a work-around in order to associate a ResourceUrn with a UISkin.
* When a UISkin is deserialised, then it is copied into a new UISkinWithUrn instance to associate it with the urn it was deserialised with.
*
* (2021-03-31) It is not clear whether this feature is used anywhere (in the Omega module space) right now.
*/
public class UISkinWithUrn extends UISkin {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've added the suggested comment, also clarifying which that this refers to deserialisation from UISkinTypeHandler (the UISkin is deserialised from JSON by UISkinFormat into data for a UISkinAsset and the UISkinTypeHandler fetches the skin from its asset).

@keturn
Copy link
Copy Markdown
Member

keturn commented Apr 1, 2021

I looked more at this area of the code and have a better idea of what it's role is.

I'm still wary of code we don't know how to test, but that's not telling you anything you don't already know.

I'm going to go ahead and merge this, especially as the merge target is just the other PR.

@keturn keturn merged commit 0a9f93d into MovingBlocks:nui-gestalt-separation Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants