Skip to content

Commit

Permalink
[Compatibility] Add stub for VisualShaderNodeComment
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometror committed Apr 18, 2024
1 parent 4b7776e commit 735c45d
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 4 deletions.
16 changes: 16 additions & 0 deletions doc/classes/VisualShaderNodeComment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisualShaderNodeComment" inherits="VisualShaderNodeFrame" deprecated="This class has no function anymore and only exists for compatibility." xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Only exists for compatibility. Use [VisualShaderNodeFrame] as a replacement.
</brief_description>
<description>
This node was replaced by [VisualShaderNodeFrame] and only exists to preserve compatibility. In the [VisualShader] editor it behaves exactly like [VisualShaderNodeFrame].
</description>
<tutorials>
</tutorials>
<members>
<member name="description" type="String" setter="set_description" getter="get_description" default="&quot;&quot;">
This property only exists to preserve data authored in earlier versions of Godot. It has currently no function.
</member>
</members>
</class>
6 changes: 3 additions & 3 deletions misc/extension_api_validation/4.2-stable.expected
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ Compatibility methods registered.

GH-88014
--------
Validate extension JSON: API was removed: classes/VisualShaderNodeComment

Removed VisualShaderNodeComment, which is replaced by VisualShaderNodeFrame.
Validate extension JSON: API was removed: classes/VisualShaderNodeComment/methods/get_title
Validate extension JSON: API was removed: classes/VisualShaderNodeComment/methods/set_title
Validate extension JSON: API was removed: classes/VisualShaderNodeComment/properties/title


GH-87888
Expand Down
3 changes: 3 additions & 0 deletions scene/register_scene_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,9 @@ void register_scene_types() {
GDREGISTER_ABSTRACT_CLASS(VisualShaderNodeConstant);
GDREGISTER_ABSTRACT_CLASS(VisualShaderNodeVectorBase);
GDREGISTER_CLASS(VisualShaderNodeFrame);
#ifndef DISABLE_DEPRECATED
GDREGISTER_CLASS(VisualShaderNodeComment); // Deprecated, just for compatibility.
#endif
GDREGISTER_CLASS(VisualShaderNodeFloatConstant);
GDREGISTER_CLASS(VisualShaderNodeIntConstant);
GDREGISTER_CLASS(VisualShaderNodeUIntConstant);
Expand Down
21 changes: 20 additions & 1 deletion scene/resources/visual_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4206,7 +4206,7 @@ VisualShaderNodeResizableBase::VisualShaderNodeResizableBase() {
set_allow_v_resize(true);
}

////////////// Comment
////////////// Frame

String VisualShaderNodeFrame::get_caption() const {
return title;
Expand Down Expand Up @@ -4323,6 +4323,25 @@ void VisualShaderNodeFrame::_bind_methods() {
VisualShaderNodeFrame::VisualShaderNodeFrame() {
}

////////////// Comment (Deprecated)

#ifndef DISABLE_DEPRECATED
void VisualShaderNodeComment::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_description", "description"), &VisualShaderNodeComment::set_description);
ClassDB::bind_method(D_METHOD("get_description"), &VisualShaderNodeComment::get_description);

ADD_PROPERTY(PropertyInfo(Variant::STRING, "description"), "set_description", "get_description");
}

void VisualShaderNodeComment::set_description(const String &p_description) {
description = p_description;
}

String VisualShaderNodeComment::get_description() const {
return description;
}
#endif

////////////// GroupBase

void VisualShaderNodeGroupBase::set_inputs(const String &p_inputs) {
Expand Down
22 changes: 22 additions & 0 deletions scene/resources/visual_shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,28 @@ class VisualShaderNodeFrame : public VisualShaderNodeResizableBase {
VisualShaderNodeFrame();
};

#ifndef DISABLE_DEPRECATED
// Deprecated, for compatibility only.
class VisualShaderNodeComment : public VisualShaderNodeFrame {
GDCLASS(VisualShaderNodeComment, VisualShaderNodeFrame);

String description;

protected:
static void _bind_methods();

public:
virtual String get_caption() const override { return "Comment(Deprecated)"; }

virtual Category get_category() const override { return CATEGORY_NONE; }

void set_description(const String &p_description);
String get_description() const;

VisualShaderNodeComment() {}
};
#endif

class VisualShaderNodeGroupBase : public VisualShaderNodeResizableBase {
GDCLASS(VisualShaderNodeGroupBase, VisualShaderNodeResizableBase);

Expand Down

0 comments on commit 735c45d

Please sign in to comment.