-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Editor: ActorEditLogic: support for dynamic generation of items in dropdown #21274
base: bleed
Are you sure you want to change the base?
Editor: ActorEditLogic: support for dynamic generation of items in dropdown #21274
Conversation
@@ -340,14 +340,16 @@ ScrollItemWidget SetupItem(PlayerReference option, ScrollItemWidget template) | |||
initContainer.Bounds.Height += dropdownContainer.Bounds.Height; | |||
dropdownContainer.Get<LabelWidget>("LABEL").GetText = () => ddo.Name; | |||
|
|||
var editorActionHandle = new EditorActorOptionActionHandle<string>(ddo.OnChange, ddo.GetValue(actor)); | |||
var labels = ddo.GetLabels(actor); |
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.
doesn't cacheing this defeat the desire for labels to be dynamic?
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.
But the labels are still cached, just the cache is not directly inside EditorActorDropdown
as a field, but instead it's in a closure in one of the constructors.
IMO adding a new constructor just for downstream use isn't a great idea - it is likely to break or be removed in the future. If there's a good motivation for per-actor items then we should make the default logic use the same code paths. |
Yes, it might seem it's somewhat specific to our mod, but this can be used any other mod. But I agree that there might be a better solution for our specific use case. I'm reposting two more solutions from Discord here: Another solution that I can think of is to create a completely separate Yet another solution: make it possible to create entirely custom |
This PR makes it possible for
EditorActorDropdown
to dynamically generate items for particular actor.This requires second constructor for
EditorActorDropdown
to keep backward-compatibility with existing traits (which will still use old callbacksGetLabels
andGetValue
).