-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Script hierarchies for Inspector #13116
Script hierarchies for Inspector #13116
Conversation
List::insert_before and List::insert_after used to not properly hook up the previous / following node to the new neighbor. Had been running into problems doing a forward loop after calling |
2a36e75
to
2b58b4f
Compare
core/object.cpp
Outdated
if (r_valid) | ||
*r_valid = true; | ||
return; | ||
metadata = p_value; |
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.
You broke indentation all over the file :)
See http://docs.godotengine.org/en/latest/community/contributing/code_style_guidelines.html#using-clang-format-locally
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.
oh gosh. Yeah, thanks for this. Hopefully I can fix it up. XD
4fc24ff
to
f7164cb
Compare
I'm gonna have to make some modifications to this because I've encountered a bug where my code is crashing the engine. |
It might be worth splitting your |
@akien-mga Is that a good idea if the code relies on it? I mean, if I separate it out, I won't be able to test the script changes locally without changing the code to not use |
I suppose I could separate it and then keep the change, but just not have it recorded by git in the script-var-categories branch... |
You can make that commit in a new branch and a new PR, and rebase this PR on that other branch (so you would have two commits here). |
oh, so that sounds good. Will get on that. |
14d6884
to
a3fd74c
Compare
2374edb
to
f5c9528
Compare
@willnationsdev Could you now rebase again since #13143 was merged but the related commit here has a different hash? (also you might want to remove the |
Yes, I can do that later. I will likely be away from a computer for the next day or two. Will ping you when I have it ready. |
No worry, I can also merge it manually myself when it's approved if need be. |
That works too. I can ping you early if I get a chance to work on it sooner rather than later. Otherwise, I'll see the merge notification. Thanks! :-) |
I still won't get to work on this until later, but keep in mind that currently, there seems to be an issue when you have a single script with only one exported variable. Something is causing the |
50e90ad
to
529610d
Compare
b8a14e6
to
96a37d1
Compare
Can you test this with the new inspector? |
Maybe. I'm pressed for time in a lot of ways for the next two weeks, but if I get a chance I will. |
How hard would it be to Introduce proper coustom class names. |
@Toger that's actually a project I've been working on for a while. Been trying to unify the custom type system API with the ability to register namespaces and typenames for scripts. There is a TypeDB issue I created about it before. Basically, once it's done, you should be able to do You'll also be able to register scenes as custom types, so there will be an analogous |
Nice!!! This is amazing and something i was hoping for since a long time. |
I don't really know how the Intellisense works (haven't looked at it), but it's theoretically possible. All I will really be doing under the hood is keeping a HashMap of namespaces typenames to file paths for each resource. It will be a slash-delimeted typename mapped to a file path, stored in ProjectSettings. Then I am planning to detect the use of "Scripts" or "Scenes", begin parsing a dot-delimited set of names, take the whole of those names, replacing the dots with slashes, and then plugging it in to get the path to the appropriate resource, returning the loaded resource. This keeps us from having to constantly keep custom type resources loaded in memory. Now, if the resource were a scene, then you would be able to get the SceneState of the PackedScene, analyze it's contents, and then fill an auto completion popup with the node paths in the scene to somehow get a reference to that node. You'd probably have to store the SceneState alongside the variable data so that it'd be accessible when attempting.pt to get a node from that variable. |
Makes sense. I thought the custom type would become part of the classDB. Are there anybissues when saving the coustom type to file connection in the ProjectSettings when moving files from one project to another to reuse them? How hard would it be to use classDB. |
I would actually be much easier to use the ClassDB, and in fact, that's what I did at first. But reduz didn't want what should really only be editor-time type checking (for custom type reinforcement) and GDScript-module-specific parser/compiler changes affect the core of the engine (rightly so). So I refactored all the code out of the ClassDB and inserted it into a TypeDB in the EditorData class. This keeps it globally accessible through the EditorNode singleton, but keeps all of the dependencies strictly in the Editor or language-specific module space. I've actually refactored the whole thing about 3 different times. That's the only reason it's taken so long to get this far. Started this project around the beginning of the year.
There are no issues with moving custom types. The EditorNode has a callback for when the filesystem is changed. It catalogues which files are new / have been modified, and I pass those files to the TypeDB which re-registers any existing files with updated typenames / file locations if those ever change.
Yes, this would be great! And luckily, as it turns out, you don't need the ClassDB to do any of that. There is a DocData class associated with the Editor that allows you to search a directory for XML files and generate documentation from those files. I plan on exposing this method to the EditorPlugin class so that users can directly have their plugin generate updated documentation for their content. |
this all sounds really promising! Thank you! for taking the time to give me an insight on how it works.
maybe a second function for parsing doc information to DocData could be created which parses it directly from the script file itself. with custom comments which than represent the documentation for a fucniton/member. how feasible do you think this would be? This Is also discussed in a different issue? |
You are probably looking for the annotations feature that has been discussed somewhere (I can't seem to find the related Issue(s)?). At one point, we were throwing around the idea of adding @-based annotations in GDScript so that you could add metadata about class content for documentation and autocompletion features. So, something like...
|
96a37d1
to
5cd5b47
Compare
@mhilbrunner I just tested this after a fresh pull / rebase onto master. Everything in my branch seems to be working as far as I can tell. All this PR does is insert |
5cd5b47
to
83a748b
Compare
@mhilbrunner Don't C# scripts allow for inheritance too? I may have to test this with a C# script as well, but I haven't messed around with that at all. |
get_base_script() is not yet implemented in C#. |
@neikeq ah, thanks. I'll have to do that. |
83a748b
to
c084651
Compare
c084651
to
8d76c03
Compare
8d76c03
to
2cf53f2
Compare
As discussed in the IRC meeting, the idea behind this is good and welcome, but needs to be implemented in a solid way. Notes from IRC:
|
Fixes #10799
Demonstration:
Here are some various screenshots. These are from an environment in which I have the following structure:
The only variable/class we should NOT see show up is
class_b.gd
with the single, un-exportedb
property with valuetrue
.If I attach
class_c.gd
to a Node, I see this before/after:If I have a builtin script with exported
builtin1
and non-exportedbuiltin2
, then I get this before/after (script_test.tscn
is the name of the scene and the built-in script extends aNode
type):If I have
class_c
open, and I change it to extend fromclass_2
instead ofclass_b
, but I HAVEN'T saved it yet, then I will see this before/after (looks the same as the saved version, which was the goal):In the course of doing this, I did find another small bug for the unsaved scripts (going from less derived to more derived base class in an unsaved script. In this case, I went fromclass_1
toclass_a
, soclass_2
andclass_a's variables are showing up under
class_1`'s), so it seems it still needs some more work.Edit: Oh wait! No, that's a purposeful "bug". If you ADD scripts and properties to the inheritance hierarchy, but the script hasn't been saved, the
p_list
ends up with all of these extra properties and doesn't yet know about the new scripts, so it just bundles them all underneath the most relevant script it can find. It gets revised when you actually save the script.(after saving:)
Incidentally, if you add a script to a node that has nothing else in the script hierarchy, and the script is not yet saved (so it doesn't have a name yet), AND if it has export variables that show up in the Inspector, then it starts autonaming the category blocks with "Class 0", "Class 1", etc. for every script that isn't yet saved. If anywhere in the script hierarchy there is a saved script, then all of the unsaved scripts' properties are assumed to belong to the saved script, until those other scripts are saved. This is why we see the "buggy" behavior above. Here's what this algorithm results in for the objects with no saved scripts:
Regardless of whether this ends up as part of the 3.0 release or not, I might actually start extending this out into a full on overhaul of custom types in general, targeting a 3.1 release. This would be a critical change to have for a full custom type simulation across the engine.
Edit:
Here are some various screenshots. These are from an environment in which I have the following structure:
The only variable/class we should NOT see show up is
class_b.gd
with the single, un-exportedb
property with valuetrue
.If I attach
class_c.gd
to a Node, I see this before/after:If I have a builtin script with exported
builtin1
and non-exportedbuiltin2
, then I get this before/after (script_test.tscn
is the name of the scene and the built-in script extends aNode
type):If I have
class_c
open, and I change it to extend fromclass_2
instead ofclass_b
, but I HAVEN'T saved it yet, then I will see this before/after (looks the same as the saved version, which was the goal):In the course of doing this, I did find another small bug for the unsaved scripts (going from less derived to more derived base class in an unsaved script. In this case, I went fromclass_1
toclass_a
, soclass_2
andclass_a's variables are showing up under
class_1`'s), so it seems it still needs some more work.Edit: Oh wait! No, that's a purposeful "bug". If you ADD scripts and properties to the inheritance hierarchy, but the script hasn't been saved, the
p_list
ends up with all of these extra properties and doesn't yet know about the new scripts, so it just bundles them all underneath the most relevant script it can find. It gets revised when you actually save the script.(after saving:)
Incidentally, if you add a script to a node that has nothing else in the script hierarchy, and the script is not yet saved (so it doesn't have a name yet), AND if it has export variables that show up in the Inspector, then it starts autonaming the category blocks with "Class 0", "Class 1", etc. for every script that isn't yet saved. If anywhere in the script hierarchy there is a saved script, then all of the unsaved scripts' properties are assumed to belong to the saved script, until those other scripts are saved. This is why we see the "buggy" behavior above. Here's what this algorithm results in for the objects with no saved scripts:
Regardless of whether this ends up as part of the 3.0 release or not, I might actually start extending this out into a full on overhaul of custom types in general, targeting a 3.1 release. This would be a critical change to have for a full custom type simulation across the engine.