-
Notifications
You must be signed in to change notification settings - Fork 160
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
AGS 4: autogenerate Custom Properties as extender attributes in script #2605
Comments
My original off-the-top-of-my-head idea was that this would replace One thing to consider: what happens if the generated extender attribute name collides with an existing property? |
I don't exactly see how that would be possible without a big overhaul of this system, unless by "replace" you mean "hide". EDIT: there may still be a use of accessing custom properties by the name using a string, for example if a game saves this data in a file or provides a console for tester to type property names in.
Maybe we could issue a warning and ask to rename this custom property? |
Or do you mean that we only declare these properties in script, but they are implemented in the engine somehow, by generating functions objects, which wrap custom property name, and are assigned to corresponding get_/set_ function names?... But I'm not sure if the Get/SetTextProperty are not needed anymore. In the past I've been actually thinking to let assign arbitrary properties at runtime, disregarding editor's schema. Then this might work as a free Dictionary attached to an object. Maybe we should begin with the current proposal, since it does not add any long term restrictions, and then discuss bigger change separately... |
I just meant that I didn't think that
What if the IDE enforced script-compatible property names? (I see you already suggested this for names that collide with existing properties.) I wouldn't enforce PascalCase, though. |
I like the idea of generating code and I would go that way, but I would put it in the same file that has the global vars. Until we change the bytecode to give a few more bits to the section that has the index of the script module, it's best to be more economic. |
Last time I checked, the instance id field may be easily increased, because
|
In addition to above, I am currently starting to rewrite a script executor class in the engine; this is mostly in attempt to make it easier to do #1409, but also with intent to get rid of "instance forks", that double the number of occupied instance slots. |
That is not only it, it will also need to make a header that is available while writing the code and available to the autocomplete parser somehow
It also need to be on top for the autocomplete parser. Other approach is to have the header part directly in the autogenerated header. |
I don't remember this by heart, how are GlobalVariables list processed for autocomplete? I suppose we might use the same method for these properties. |
Great point, had to read to figure it out but apparently it is very simple, Autocomplete.ConstructCache take a single script and then it just keeps it in cache forever apparently unless you ask about it again. So it is just a call to it with the generated script, whenever something requires it to be regenerated. |
Issue
Custom Properties are useful, but they are inconvenient to access in scripts. One has to use syntax like
object.GetProperty("name", value)
andobject.SetProperty("name", value)
. An alternative approach is to define extender methods for the object type, and hide calls to GetProperty/SetProperty inside.In AGS 4's new compiler we now have a extender attribute support. It works like this:
where
T
is the name of a struct.This lets users define the custom properties as attributes and hide Get/Set function calls inside implementation.
See Also: a PR that displays custom properties in Property Grid #2604.
Proposal
Support auto-generating extender attributes for the custom properties, reducing amount of manual work for the user.
The text was updated successfully, but these errors were encountered: