-
Notifications
You must be signed in to change notification settings - Fork 936
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
Allow extensions to define units of measurement for their properties #4576
Conversation
D8H
commented
Nov 23, 2022
•
edited
Loading
edited
- It use the scientific notation because it's the easiest to generate and it looks clean.
- It only works for behavior properties. It will be hard to do for objects like the ParticleEmitter because there is no property metadata.
- It doesn't allow event-based extensions to define units. I want to wait that everyone is ok with what is done for the built-in extensions because event-based extensions need a serialization and it's hard to go back.
// Strings are used instead of gdMeasurementUnit | ||
// because the C++ instance would be dead when the component is rendered. | ||
type Props = {| | ||
label: string, | ||
description: string, | ||
elementsWithWords: string, | ||
|}; |
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.
Is it ok?
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'm not sure what "dead" means
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 gdMeasurementUnit
instances are only living during their iteration on the properties when building the property editor view. As the rendering of MeasurementUnitDocumentation
is done outside of this loop, the memory referenced by the gdMeasurementUnit
instance has been reused and it displays wrong values.
I pass strings instead of gdMeasurementUnit
to avoid this.
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.
ok then! (maybe adding what you wrote in the code would be a better comment 👍)
08c9b6d
to
8b6e357
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.
lgtm 👍
Just unsure about the typing comment's meaning
// Strings are used instead of gdMeasurementUnit | ||
// because the C++ instance would be dead when the component is rendered. | ||
type Props = {| | ||
label: string, | ||
description: string, | ||
elementsWithWords: string, | ||
|}; |
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'm not sure what "dead" means
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.
maybe improve the comment on typing a bit, then good to go!
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.
Looks good generally but the translations won't work when you switch to another language because things are constructed statically.
Would be worth having a "gd::MeasurementUnit::ApplyTranslation" to changes all the transaltable labels.
Note that it is a good thing to avoid recreating at every call a new MeasurementUnit! Otherwise this creates a lot of temporary just to destroy them after and this is needlessly costly.
But the labels should be updated when the language is changed in the editor.
Yes. Terribly risky (there is even a page about it: https://en.cppreference.com/w/cpp/language/siof). Let's avoid doing anything risky in the statics and just keep a good old function applying translations. |