godot icon indicating copy to clipboard operation
godot copied to clipboard

Enforce custom nodes to keep their original type

Open bjornmp opened this issue 1 year ago • 13 comments

Replaces PR https://github.com/godotengine/godot/pull/82684 with a move away from Core/Object in favor of ~~Scene/Main/Node~~ metadata usage.

Closes https://github.com/godotengine/godot-proposals/issues/7905

bjornmp avatar Apr 30 '24 02:04 bjornmp

Not sure if showing extend icon for non-custom-type scripts is a good idea: image It can show for scripts that can't be extended, and more importantly, takes space, which is already too small in that area.

KoBeWi avatar May 11 '24 20:05 KoBeWi

You could try using _property_can_revert() and _property_get_revert() to handle script default. It could allow removing PackedScene changes.

KoBeWi avatar May 11 '24 20:05 KoBeWi

  • Script button "Extend" is now only shown when the script is a custom type script
  • "Clear" is only removed if resource is actually a script

I haven't found a nice way around the PackedScene changes yet. As I see it, _property_can_revert() and _property_get_revert() are virtual methods. Where would be a good place to override them to get the desired effect?

bjornmp avatar May 12 '24 17:05 bjornmp

Where would be a good place to override them to get the desired effect?

In Object. Although they are part of GDClass, so not sure if it's possible. In worst case you can put some duplicate code in Node and Resource.

KoBeWi avatar May 12 '24 17:05 KoBeWi

I was trying to avoid changes to core/ as much as possible with this PR, as this was requested in the last PR attempt. That's why I initially didn't use CoreStringNames.

~~Maybe I can get away with the changes in packed_scene if I add a condition in PropertyUtils::is_property_value_different as I already did in PropertyUtils::get_property_default_value.~~ No, that's not going to work.

bjornmp avatar May 12 '24 18:05 bjornmp

Can you rebase to resolve conflicts?

KoBeWi avatar May 13 '24 21:05 KoBeWi

Can you rebase to resolve conflicts?

Yes, will do this now.

bjornmp avatar May 13 '24 21:05 bjornmp

Rebased.

bjornmp avatar May 13 '24 22:05 bjornmp

I think I got all suggestions in place and also moved from CoreStringNames to SceneStringNames.

bjornmp avatar May 14 '24 23:05 bjornmp