Author
Topic: text input field parameter (Read 2842 times)

How can I add and set the context of a simple text field parameter?I can create int/float/bool parameters and enumerators but can't seem to find a simple method for creating a simple text input field which I can set.

Thanks, that did it for me I couldn't figure it out through the example files.

Another question (related to the previous one, or causing the previous one)I noticed that when switching between views (for example from device to lay-out) the objects get destructed and constructed again.When dealing with data that needs to be imported (and kept around, for example images) this becomes quite heavy. The actual processing times are low compared to loading the image in memory every time.

I tried creating a singleton class holding the image but this results in only one image to be loaded at all times (shared across the generators). The other option would be to create some sort of file manager but that looks (to me) as overkill. How would you approach handling data that needs to be associated with an object (generator for example) and kept around?

Is there any method or functionality in world machine that supports this?

Yes, in the current architecture, the device world is copied for the layout/explorer view, and also for tiled builds. This means that each device is essentially deep copied, which is OK for lightweight but not, as you note, for heavyweight.

If it is a simple read-only resource (like a loaded file), then a shared resource via smart pointer/reference counting is the best way to share the resource. More heavyweight shared resources might need a separate resource manager class (the Tiled File Input device does this because it is managing a much more complicated set of files, caching, etc)

Anyways.

In the 2.2 codebase, shared resources are manually reference counted. For example, the File Input device does something like the below.