diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..1df6c35
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,199 @@
+# Commented out parameters are those with the same value as base LLVM style.
+# We can uncomment them if we want to change their value, or enforce the
+# chosen value in case the base style changes (last sync: Clang 14.0).
+---
+### General config, applies to all languages ###
+BasedOnStyle: LLVM
+AccessModifierOffset: -4
+AlignAfterOpenBracket: DontAlign
+# AlignArrayOfStructures: None
+# AlignConsecutiveMacros: None
+# AlignConsecutiveAssignments: None
+# AlignConsecutiveBitFields: None
+# AlignConsecutiveDeclarations: None
+# AlignEscapedNewlines: Right
+AlignOperands: DontAlign
+AlignTrailingComments: false
+# AllowAllArgumentsOnNextLine: true
+AllowAllParametersOfDeclarationOnNextLine: false
+# AllowShortEnumsOnASingleLine: true
+# AllowShortBlocksOnASingleLine: Never
+# AllowShortCaseLabelsOnASingleLine: false
+# AllowShortFunctionsOnASingleLine: All
+# AllowShortLambdasOnASingleLine: All
+# AllowShortIfStatementsOnASingleLine: Never
+# AllowShortLoopsOnASingleLine: false
+# AlwaysBreakAfterDefinitionReturnType: None
+# AlwaysBreakAfterReturnType: None
+# AlwaysBreakBeforeMultilineStrings: false
+# AlwaysBreakTemplateDeclarations: MultiLine
+# AttributeMacros:
+# - __capability
+# BinPackArguments: true
+# BinPackParameters: true
+# BraceWrapping:
+# AfterCaseLabel: false
+# AfterClass: false
+# AfterControlStatement: Never
+# AfterEnum: false
+# AfterFunction: false
+# AfterNamespace: false
+# AfterObjCDeclaration: false
+# AfterStruct: false
+# AfterUnion: false
+# AfterExternBlock: false
+# BeforeCatch: false
+# BeforeElse: false
+# BeforeLambdaBody: false
+# BeforeWhile: false
+# IndentBraces: false
+# SplitEmptyFunction: true
+# SplitEmptyRecord: true
+# SplitEmptyNamespace: true
+# BreakBeforeBinaryOperators: None
+# BreakBeforeConceptDeclarations: true
+# BreakBeforeBraces: Attach
+# BreakBeforeInheritanceComma: false
+# BreakInheritanceList: BeforeColon
+# BreakBeforeTernaryOperators: true
+# BreakConstructorInitializersBeforeComma: false
+BreakConstructorInitializers: AfterColon
+# BreakStringLiterals: true
+ColumnLimit: 0
+# CommentPragmas: '^ IWYU pragma:'
+# QualifierAlignment: Leave
+# CompactNamespaces: false
+ConstructorInitializerIndentWidth: 8
+ContinuationIndentWidth: 8
+Cpp11BracedListStyle: false
+# DeriveLineEnding: true
+# DerivePointerAlignment: false
+# DisableFormat: false
+# EmptyLineAfterAccessModifier: Never
+# EmptyLineBeforeAccessModifier: LogicalBlock
+# ExperimentalAutoDetectBinPacking: false
+# PackConstructorInitializers: BinPack
+ConstructorInitializerAllOnOneLineOrOnePerLine: true
+# AllowAllConstructorInitializersOnNextLine: true
+# FixNamespaceComments: true
+# ForEachMacros:
+# - foreach
+# - Q_FOREACH
+# - BOOST_FOREACH
+# IfMacros:
+# - KJ_IF_MAYBE
+# IncludeBlocks: Preserve
+IncludeCategories:
+ - Regex: '".*"'
+ Priority: 1
+ - Regex: '^<.*\.h>'
+ Priority: 2
+ - Regex: '^<.*'
+ Priority: 3
+# IncludeIsMainRegex: '(Test)?$'
+# IncludeIsMainSourceRegex: ''
+# IndentAccessModifiers: false
+IndentCaseLabels: true
+# IndentCaseBlocks: false
+# IndentGotoLabels: true
+# IndentPPDirectives: None
+# IndentExternBlock: AfterExternBlock
+# IndentRequires: false
+IndentWidth: 4
+# IndentWrappedFunctionNames: false
+# InsertTrailingCommas: None
+# JavaScriptQuotes: Leave
+# JavaScriptWrapImports: true
+KeepEmptyLinesAtTheStartOfBlocks: false
+# LambdaBodyIndentation: Signature
+# MacroBlockBegin: ''
+# MacroBlockEnd: ''
+# MaxEmptyLinesToKeep: 1
+# NamespaceIndentation: None
+# PenaltyBreakAssignment: 2
+# PenaltyBreakBeforeFirstCallParameter: 19
+# PenaltyBreakComment: 300
+# PenaltyBreakFirstLessLess: 120
+# PenaltyBreakOpenParenthesis: 0
+# PenaltyBreakString: 1000
+# PenaltyBreakTemplateDeclaration: 10
+# PenaltyExcessCharacter: 1000000
+# PenaltyReturnTypeOnItsOwnLine: 60
+# PenaltyIndentedWhitespace: 0
+# PointerAlignment: Right
+# PPIndentWidth: -1
+# ReferenceAlignment: Pointer
+# ReflowComments: true
+# RemoveBracesLLVM: false
+# SeparateDefinitionBlocks: Leave
+# ShortNamespaceLines: 1
+# SortIncludes: CaseSensitive
+# SortJavaStaticImport: Before
+# SortUsingDeclarations: true
+# SpaceAfterCStyleCast: false
+# SpaceAfterLogicalNot: false
+# SpaceAfterTemplateKeyword: true
+# SpaceBeforeAssignmentOperators: true
+# SpaceBeforeCaseColon: false
+# SpaceBeforeCpp11BracedList: false
+# SpaceBeforeCtorInitializerColon: true
+# SpaceBeforeInheritanceColon: true
+# SpaceBeforeParens: ControlStatements
+# SpaceBeforeParensOptions:
+# AfterControlStatements: true
+# AfterForeachMacros: true
+# AfterFunctionDefinitionName: false
+# AfterFunctionDeclarationName: false
+# AfterIfMacros: true
+# AfterOverloadedOperator: false
+# BeforeNonEmptyParentheses: false
+# SpaceAroundPointerQualifiers: Default
+# SpaceBeforeRangeBasedForLoopColon: true
+# SpaceInEmptyBlock: false
+# SpaceInEmptyParentheses: false
+# SpacesBeforeTrailingComments: 1
+# SpacesInAngles: Never
+# SpacesInConditionalStatement: false
+# SpacesInContainerLiterals: true
+# SpacesInCStyleCastParentheses: false
+## Godot TODO: We'll want to use a min of 1, but we need to see how to fix
+## our comment capitalization at the same time.
+SpacesInLineCommentPrefix:
+ Minimum: 0
+ Maximum: -1
+# SpacesInParentheses: false
+# SpacesInSquareBrackets: false
+# SpaceBeforeSquareBrackets: false
+# BitFieldColonSpacing: Both
+# StatementAttributeLikeMacros:
+# - Q_EMIT
+# StatementMacros:
+# - Q_UNUSED
+# - QT_REQUIRE_VERSION
+TabWidth: 4
+# UseCRLF: false
+UseTab: Always
+# WhitespaceSensitiveMacros:
+# - STRINGIZE
+# - PP_STRINGIZE
+# - BOOST_PP_STRINGIZE
+# - NS_SWIFT_NAME
+# - CF_SWIFT_NAME
+---
+### C++ specific config ###
+Language: Cpp
+Standard: c++17
+---
+### ObjC specific config ###
+Language: ObjC
+# ObjCBinPackProtocolList: Auto
+ObjCBlockIndentWidth: 4
+# ObjCBreakBeforeNestedBlockParam: true
+# ObjCSpaceAfterProperty: false
+# ObjCSpaceBeforeProtocolList: true
+---
+### Java specific config ###
+Language: Java
+# BreakAfterJavaFieldAnnotations: false
+JavaImportGroups: ['org.godotengine', 'android', 'androidx', 'com.android', 'com.google', 'java', 'javax']
+...
diff --git a/.clang-tidy b/.clang-tidy
new file mode 100644
index 0000000..659b910
--- /dev/null
+++ b/.clang-tidy
@@ -0,0 +1,47 @@
+---
+Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,cppcoreguidelines-pro-type-member-init,modernize-redundant-void-arg,modernize-use-bool-literals,modernize-use-default-member-init,modernize-use-nullptr,readability-braces-around-statements,readability-redundant-member-init'
+WarningsAsErrors: ''
+HeaderFilterRegex: ''
+AnalyzeTemporaryDtors: false
+FormatStyle: none
+CheckOptions:
+ - key: cert-dcl16-c.NewSuffixes
+ value: 'L;LL;LU;LLU'
+ - key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
+ value: '0'
+ - key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
+ value: '1'
+ - key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
+ value: '1'
+ - key: cppcoreguidelines-pro-type-member-init.IgnoreArrays
+ value: '1'
+ - key: cppcoreguidelines-pro-type-member-init.UseAssignment
+ value: '1'
+ - key: google-readability-function-size.StatementThreshold
+ value: '800'
+ - key: google-readability-namespace-comments.ShortNamespaceLines
+ value: '10'
+ - key: google-readability-namespace-comments.SpacesBeforeComments
+ value: '2'
+ - key: modernize-loop-convert.MaxCopySize
+ value: '16'
+ - key: modernize-loop-convert.MinConfidence
+ value: reasonable
+ - key: modernize-loop-convert.NamingStyle
+ value: CamelCase
+ - key: modernize-pass-by-value.IncludeStyle
+ value: llvm
+ - key: modernize-replace-auto-ptr.IncludeStyle
+ value: llvm
+ - key: modernize-use-bool-literals.IgnoreMacros
+ value: '0'
+ - key: modernize-use-default-member-init.IgnoreMacros
+ value: '0'
+ - key: modernize-use-default-member-init.UseAssignment
+ value: '1'
+ - key: modernize-use-nullptr.NullMacros
+ value: 'NULL'
+ - key: readability-braces-around-statements.ShortStatementLines
+ value: '0'
+...
+
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index c184db2..73b1253 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -1,56 +1,56 @@
-name: Bug report
-description: Report a bug in Godot
-body:
-
-- type: markdown
- attributes:
- value: |
- - Read our [CONTRIBUTING.md guide](https://github.com/godotengine/godot/blob/master/CONTRIBUTING.md#reporting-bugs) on reporting bugs.
- - Write a descriptive issue title above.
- - Search [open](https://github.com/godotengine/godot-visual-script/issues) and [closed](https://github.com/godotengine/godot-visual-script/issues?q=is%3Aissue+is%3Aclosed) issues to ensure it has not already been reported.
- - Verify that you are using a [supported Godot version](https://docs.godotengine.org/en/stable/about/release_policy.html).
-
-- type: input
- attributes:
- label: Godot version
- description: >
- Specify the Git commit hash if using a development or non-official build.
- If you use a custom build, please test if your issue is reproducible in official builds too.
- placeholder: 3.3.stable, 4.0.dev (3041becc6)
- validations:
- required: true
-
-- type: input
- attributes:
- label: System information
- description: |
- Specify the OS version, and when relevant hardware information.
- For graphics-related issues, specify the GPU model, driver version, and the rendering backend (GLES2, GLES3, Vulkan).
- placeholder: Windows 10, GLES3, Intel HD Graphics 620 (27.20.100.9616)
- validations:
- required: true
-
-- type: textarea
- attributes:
- label: Issue description
- description: |
- Describe your issue briefly. What doesn't work, and how do you expect it to work instead?
- You can include images or videos with drag and drop, and format code blocks or logs with ``` tags.
- validations:
- required: true
-
-- type: textarea
- attributes:
- label: Steps to reproduce
- description: |
- List of steps or sample code that reproduces the issue. Having reproducible issues is a prerequisite for contributors to be able to solve them.
- If you include a minimal reproduction project below, you can detail how to use it here.
- validations:
- required: true
-
-- type: textarea
- attributes:
- label: Minimal reproduction project
- description: |
- A small Godot project which reproduces the issue. Highly recommended to speed up troubleshooting.
- Drag and drop a ZIP archive to upload it.
+name: Bug report
+description: Report a bug in Godot
+body:
+
+- type: markdown
+ attributes:
+ value: |
+ - Read our [CONTRIBUTING.md guide](https://github.com/godotengine/godot/blob/master/CONTRIBUTING.md#reporting-bugs) on reporting bugs.
+ - Write a descriptive issue title above.
+ - Search [open](https://github.com/godotengine/godot-visual-script/issues) and [closed](https://github.com/godotengine/godot-visual-script/issues?q=is%3Aissue+is%3Aclosed) issues to ensure it has not already been reported.
+ - Verify that you are using a [supported Godot version](https://docs.godotengine.org/en/stable/about/release_policy.html).
+
+- type: input
+ attributes:
+ label: Godot version
+ description: >
+ Specify the Git commit hash if using a development or non-official build.
+ If you use a custom build, please test if your issue is reproducible in official builds too.
+ placeholder: 3.3.stable, 4.0.dev (3041becc6)
+ validations:
+ required: true
+
+- type: input
+ attributes:
+ label: System information
+ description: |
+ Specify the OS version, and when relevant hardware information.
+ For graphics-related issues, specify the GPU model, driver version, and the rendering backend (GLES2, GLES3, Vulkan).
+ placeholder: Windows 10, GLES3, Intel HD Graphics 620 (27.20.100.9616)
+ validations:
+ required: true
+
+- type: textarea
+ attributes:
+ label: Issue description
+ description: |
+ Describe your issue briefly. What doesn't work, and how do you expect it to work instead?
+ You can include images or videos with drag and drop, and format code blocks or logs with ``` tags.
+ validations:
+ required: true
+
+- type: textarea
+ attributes:
+ label: Steps to reproduce
+ description: |
+ List of steps or sample code that reproduces the issue. Having reproducible issues is a prerequisite for contributors to be able to solve them.
+ If you include a minimal reproduction project below, you can detail how to use it here.
+ validations:
+ required: true
+
+- type: textarea
+ attributes:
+ label: Minimal reproduction project
+ description: |
+ A small Godot project which reproduces the issue. Highly recommended to speed up troubleshooting.
+ Drag and drop a ZIP archive to upload it.
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
index 0f0564a..cefdbcb 100644
--- a/.github/ISSUE_TEMPLATE/config.yml
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -1,6 +1,6 @@
-blank_issues_enabled: false
-
-contact_links:
- - name: Godot community channels
- url: https://godotengine.org/community
- about: Please ask for technical support on one of the other community channels, not here.
+blank_issues_enabled: false
+
+contact_links:
+ - name: Godot community channels
+ url: https://godotengine.org/community
+ about: Please ask for technical support on one of the other community channels, not here.
diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
index 0224617..23a6baf 100644
--- a/.github/workflows/linux.yml
+++ b/.github/workflows/linux.yml
@@ -30,8 +30,6 @@ jobs:
# Azure repositories are not reliable, we need to prevent azure giving us packages.
- name: Make apt sources.list use the default Ubuntu repositories
run: |
- sudo rm -f /etc/apt/sources.list.d/*
- sudo cp -f misc/ci/sources.list /etc/apt/sources.list
sudo apt-get update
# Install all packages (except scons)
@@ -74,7 +72,7 @@ jobs:
env:
SCONS_CACHE: ${{github.workspace}}/.scons_cache/
run: |
- scons -j2 verbose=yes warnings=all werror=yes platform=linuxbsd tools=yes tests=no target=release_debug production=yes
+ scons -j2 verbose=yes warnings=all werror=yes platform=linuxbsd tools=yes tests=no target=template_release production=yes
# TODO Such tests are able to run from Godot 4.0 only
# Execute unit tests for the editor
diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml
index 8d4cb90..1614763 100644
--- a/.github/workflows/macos.yml
+++ b/.github/workflows/macos.yml
@@ -12,7 +12,7 @@ env:
jobs:
macos-editor:
- runs-on: "macos-10.15"
+ runs-on: "macos-latest"
name: Editor
steps:
@@ -56,12 +56,16 @@ jobs:
python --version
scons --version
+ - name: Setup Vulkan SDK
+ run: |
+ sh misc/scripts/install_vulkan_sdk_macos.sh
+
# We should always be explicit with our flags usage here since it's gonna be sure to always set those flags
- name: Compilation
env:
SCONS_CACHE: ${{github.workspace}}/.scons_cache/
run: |
- scons -j2 verbose=yes warnings=all werror=yes platform=osx tools=yes tests=no target=release_debug production=yes module_text_server_fb_enabled=yes
+ scons -j2 verbose=yes warnings=all werror=yes platform=macos tools=yes tests=no target=template_release production=yes module_text_server_fb_enabled=yes
# TODO Such tests are able to run from Godot 4.0 only
# Execute unit tests for the editor
diff --git a/.github/workflows/scripts/clang_format.sh b/.github/workflows/scripts/clang_format.sh
old mode 100644
new mode 100755
diff --git a/.github/workflows/scripts/file_format.sh b/.github/workflows/scripts/file_format.sh
index b2c64ba..fb2c44c 100644
--- a/.github/workflows/scripts/file_format.sh
+++ b/.github/workflows/scripts/file_format.sh
@@ -46,9 +46,9 @@ while IFS= read -rd '' f; do
continue
fi
# Disallow empty lines after the opening brace.
- sed -z -i 's/\x7B\x0A\x0A/\x7B\x0A/g' "$f"
+ perl -i -0777 -pe 's/\x7B\x0A\x0A/\x7B\x0A/g' "$f"
# Disallow some empty lines before the closing brace.
- sed -z -i 's/\x0A\x0A\x7D/\x0A\x7D/g' "$f"
+ perl -i -0777 -pe 's/\x0A\x0A\x7D/\x0A\x7D/g' "$f"
done
git diff > patch.patch
@@ -66,4 +66,5 @@ printf "and the formatting rules:\n\n"
cat patch.patch
printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i '\n"
rm -f patch.patch
+
exit 1
diff --git a/.github/workflows/scripts/install_vulkan_sdk_macos.sh b/.github/workflows/scripts/install_vulkan_sdk_macos.sh
new file mode 100755
index 0000000..17d567f
--- /dev/null
+++ b/.github/workflows/scripts/install_vulkan_sdk_macos.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env sh
+
+set -euo pipefail
+IFS=$'\n\t'
+
+# Download and install the Vulkan SDK.
+curl -L "https://sdk.lunarg.com/sdk/download/latest/mac/vulkan-sdk.dmg" -o /tmp/vulkan-sdk.dmg
+hdiutil attach /tmp/vulkan-sdk.dmg -mountpoint /Volumes/vulkan-sdk
+/Volumes/vulkan-sdk/InstallVulkan.app/Contents/MacOS/InstallVulkan \
+ --accept-licenses --default-answer --confirm-command install
+
+cnt=5
+until hdiutil detach -force /Volumes/vulkan-sdk
+do
+ [[ cnt -eq "0" ]] && break
+ sleep 1
+ ((cnt--))
+done
+
+rm -f /tmp/vulkan-sdk.dmg
+
+echo 'Vulkan SDK installed successfully! You can now build Godot by running "scons".'
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml
index 3ee9b6d..c2786af 100644
--- a/.github/workflows/windows.yml
+++ b/.github/workflows/windows.yml
@@ -65,7 +65,7 @@ jobs:
env:
SCONS_CACHE: /.scons_cache/
run: |
- scons -j2 verbose=yes warnings=all werror=yes platform=windows tools=yes tests=no target=release_debug
+ scons -j2 verbose=yes warnings=all werror=yes platform=windows tools=yes tests=no target=template_release
# TODO Such tests are able to run from Godot 4.0 only
# Execute unit tests for the editor
@@ -131,7 +131,7 @@ jobs:
env:
SCONS_CACHE: /.scons_cache/
run: |
- scons -j2 verbose=yes warnings=all werror=yes platform=windows tools=no tests=no target=release
+ scons -j2 verbose=yes warnings=all werror=yes platform=windows tools=no tests=no target=template_release
# TODO Such tests are able to run from Godot 4.0 only
# Execute unit tests for the editor
diff --git a/config.py b/config.py
index e8990c4..617112d 100644
--- a/config.py
+++ b/config.py
@@ -11,7 +11,6 @@ def get_doc_classes():
"VisualScriptBasicTypeConstant",
"VisualScriptBuiltinFunc",
"VisualScriptClassConstant",
- "VisualScriptComment",
"VisualScriptComposeArray",
"VisualScriptCondition",
"VisualScriptConstant",
diff --git a/doc_classes/VisualScript.xml b/doc_classes/VisualScript.xml
index ff6b7a8..d32ac8d 100644
--- a/doc_classes/VisualScript.xml
+++ b/doc_classes/VisualScript.xml
@@ -1,5 +1,5 @@
-
+
A script implemented in the Visual Script programming environment.
diff --git a/doc_classes/VisualScriptBasicTypeConstant.xml b/doc_classes/VisualScriptBasicTypeConstant.xml
index 0ed66f4..a036fa4 100644
--- a/doc_classes/VisualScriptBasicTypeConstant.xml
+++ b/doc_classes/VisualScriptBasicTypeConstant.xml
@@ -1,5 +1,5 @@
-
+
A Visual Script node representing a constant from the base types.
diff --git a/doc_classes/VisualScriptBuiltinFunc.xml b/doc_classes/VisualScriptBuiltinFunc.xml
deleted file mode 100644
index 647b627..0000000
--- a/doc_classes/VisualScriptBuiltinFunc.xml
+++ /dev/null
@@ -1,221 +0,0 @@
-
-
-
- A Visual Script node used to call built-in functions.
-
-
- A built-in function used inside a [VisualScript]. It is usually a math function or an utility function.
- See also [@GDScript], for the same functions in the GDScript language.
-
-
-
-
-
- The function to be executed.
-
-
-
-
- Returns the sine of the input.
-
-
- Returns the cosine of the input.
-
-
- Returns the tangent of the input.
-
-
- Returns the hyperbolic sine of the input.
-
-
- Returns the hyperbolic cosine of the input.
-
-
- Returns the hyperbolic tangent of the input.
-
-
- Returns the arc sine of the input.
-
-
- Returns the arc cosine of the input.
-
-
- Returns the arc tangent of the input.
-
-
- Returns the arc tangent of the input, using the signs of both parameters to determine the exact angle.
-
-
- Returns the square root of the input.
-
-
- Returns the remainder of one input divided by the other, using floating-point numbers.
-
-
- Returns the positive remainder of one input divided by the other, using floating-point numbers.
-
-
- Returns the input rounded down.
-
-
- Returns the input rounded up.
-
-
- Returns the input rounded to the nearest integer.
-
-
- Returns the absolute value of the input.
-
-
- Returns the sign of the input, turning it into 1, -1, or 0. Useful to determine if the input is positive or negative.
-
-
- Returns the input raised to a given power.
-
-
- Returns the natural logarithm of the input. Note that this is not the typical base-10 logarithm function calculators use.
-
-
- Returns the mathematical constant [b]e[/b] raised to the specified power of the input. [b]e[/b] has an approximate value of 2.71828.
-
-
- Returns whether the input is NaN (Not a Number) or not. NaN is usually produced by dividing 0 by 0, though other ways exist.
-
-
- Returns whether the input is an infinite floating-point number or not. Infinity is usually produced by dividing a number by 0, though other ways exist.
-
-
- Easing function, based on exponent. 0 is constant, 1 is linear, 0 to 1 is ease-in, 1+ is ease out. Negative values are in-out/out in.
-
-
- Returns the number of digit places after the decimal that the first non-zero digit occurs.
-
-
- Returns the input snapped to a given step.
-
-
- Returns a number linearly interpolated between the first two inputs, based on the third input. Uses the formula [code]a + (a - b) * t[/code].
-
-
-
-
-
-
-
-
- Moves the number toward a value, based on the third input.
-
-
- Randomize the seed (or the internal state) of the random number generator. Current implementation reseeds using a number based on time.
-
-
- Returns a random 32 bits integer value. To obtain a random value between 0 to N (where N is smaller than 2^32 - 1), you can use it with the remainder function.
-
-
- Returns a random floating-point value between 0 and 1. To obtain a random value between 0 to N, you can use it with multiplication.
-
-
- Returns a random 32-bit integer value between the two inputs.
-
-
- Returns a random floating-point value between the two inputs.
-
-
- Returns a normally-distributed pseudo-random number, using Box-Muller transform with the specified mean and a standard deviation. This is also called Gaussian distribution.
-
-
- Set the seed for the random number generator.
-
-
- Returns a random value from the given seed, along with the new seed.
-
-
- Convert the input from degrees to radians.
-
-
- Convert the input from radians to degrees.
-
-
- Convert the input from linear volume to decibel volume.
-
-
- Convert the input from decibel volume to linear volume.
-
-
-
-
-
-
- Returns the [code]value[/code] wrapped between [code]0[/code] and the [code]length[/code]. If the limit is reached, the next value the function returned is decreased to the [code]0[/code] side or increased to the [code]length[/code] side (like a triangle wave). If [code]length[/code] is less than zero, it becomes positive.
-
-
- Returns the greater of the two numbers, also known as their maximum.
-
-
- Returns the lesser of the two numbers, also known as their minimum.
-
-
- Returns the input clamped inside the given range, ensuring the result is never outside it. Equivalent to [code]min(max(input, range_low), range_high)[/code].
-
-
- Returns the nearest power of 2 to the input.
-
-
- Create a [WeakRef] from the input.
-
-
- Convert between types.
-
-
- Returns the type of the input as an integer. Check [enum Variant.Type] for the integers that might be returned.
-
-
- Checks if a type is registered in the [ClassDB].
-
-
- Returns a character with the given ascii value.
-
-
- Convert the input to a string.
-
-
- Print the given string to the output window.
-
-
- Print the given string to the standard error output.
-
-
- Print the given string to the standard output, without adding a newline.
-
-
-
-
- Serialize a [Variant] to a string.
-
-
- Deserialize a [Variant] from a string serialized using [constant VAR_TO_STR].
-
-
- Serialize a [Variant] to a [PackedByteArray].
-
-
- Deserialize a [Variant] from a [PackedByteArray] serialized using [constant VAR_TO_BYTES].
-
-
- Returns a number smoothly interpolated between the first two inputs, based on the third input. Similar to [constant MATH_LERP], but interpolates faster at the beginning and slower at the end. Using Hermite interpolation formula:
- [codeblock]
- var t = clamp((weight - from) / (to - from), 0.0, 1.0)
- return t * t * (3.0 - 2.0 * t)
- [/codeblock]
-
-
-
-
-
-
-
-
- Represents the size of the [enum BuiltinFunc] enum.
-
-
-
diff --git a/doc_classes/VisualScriptClassConstant.xml b/doc_classes/VisualScriptClassConstant.xml
index 2509084..c9f580e 100644
--- a/doc_classes/VisualScriptClassConstant.xml
+++ b/doc_classes/VisualScriptClassConstant.xml
@@ -1,5 +1,5 @@
-
+
Gets a constant from a given class.
diff --git a/doc_classes/VisualScriptComment.xml b/doc_classes/VisualScriptComment.xml
deleted file mode 100644
index cf4b57c..0000000
--- a/doc_classes/VisualScriptComment.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
- A Visual Script node used to annotate the script.
-
-
- A Visual Script node used to display annotations in the script, so that code may be documented.
- Comment nodes can be resized so they encompass a group of nodes.
-
-
-
-
-
- The text inside the comment node.
-
-
- The comment node's size (in pixels).
-
-
- The comment node's title.
-
-
-
diff --git a/doc_classes/VisualScriptComposeArray.xml b/doc_classes/VisualScriptComposeArray.xml
index ea73867..7e8551f 100644
--- a/doc_classes/VisualScriptComposeArray.xml
+++ b/doc_classes/VisualScriptComposeArray.xml
@@ -1,5 +1,5 @@
-
+
A Visual Script Node used to create array from a list of items.
diff --git a/doc_classes/VisualScriptCondition.xml b/doc_classes/VisualScriptCondition.xml
index a293885..56e3ea9 100644
--- a/doc_classes/VisualScriptCondition.xml
+++ b/doc_classes/VisualScriptCondition.xml
@@ -1,5 +1,5 @@
-
+
A Visual Script node which branches the flow.
diff --git a/doc_classes/VisualScriptConstant.xml b/doc_classes/VisualScriptConstant.xml
index 645ede9..5afe687 100644
--- a/doc_classes/VisualScriptConstant.xml
+++ b/doc_classes/VisualScriptConstant.xml
@@ -1,5 +1,5 @@
-
+
Gets a contant's value.
diff --git a/doc_classes/VisualScriptConstructor.xml b/doc_classes/VisualScriptConstructor.xml
index a003f21..c2b4231 100644
--- a/doc_classes/VisualScriptConstructor.xml
+++ b/doc_classes/VisualScriptConstructor.xml
@@ -1,5 +1,5 @@
-
+
A Visual Script node which calls a base type constructor.
diff --git a/doc_classes/VisualScriptCustomNode.xml b/doc_classes/VisualScriptCustomNode.xml
index 6e522b2..fb8fa5e 100644
--- a/doc_classes/VisualScriptCustomNode.xml
+++ b/doc_classes/VisualScriptCustomNode.xml
@@ -1,5 +1,5 @@
-
+
A scripted Visual Script node.
diff --git a/doc_classes/VisualScriptCustomNodes.xml b/doc_classes/VisualScriptCustomNodes.xml
index 48d7975..7f62f85 100644
--- a/doc_classes/VisualScriptCustomNodes.xml
+++ b/doc_classes/VisualScriptCustomNodes.xml
@@ -1,5 +1,5 @@
-
+
Manages custom nodes for the Visual Script editor.
diff --git a/doc_classes/VisualScriptDeconstruct.xml b/doc_classes/VisualScriptDeconstruct.xml
index b544fd9..e2dfac7 100644
--- a/doc_classes/VisualScriptDeconstruct.xml
+++ b/doc_classes/VisualScriptDeconstruct.xml
@@ -1,5 +1,5 @@
-
+
A Visual Script node which deconstructs a base type instance into its parts.
diff --git a/doc_classes/VisualScriptEmitSignal.xml b/doc_classes/VisualScriptEmitSignal.xml
index c0cefa0..5f05d5e 100644
--- a/doc_classes/VisualScriptEmitSignal.xml
+++ b/doc_classes/VisualScriptEmitSignal.xml
@@ -1,5 +1,5 @@
-
+
Emits a specified signal.
diff --git a/doc_classes/VisualScriptEngineSingleton.xml b/doc_classes/VisualScriptEngineSingleton.xml
index f60a048..38a44b4 100644
--- a/doc_classes/VisualScriptEngineSingleton.xml
+++ b/doc_classes/VisualScriptEngineSingleton.xml
@@ -1,5 +1,5 @@
-
+
A Visual Script node returning a singleton from [@GlobalScope].
diff --git a/doc_classes/VisualScriptExpression.xml b/doc_classes/VisualScriptExpression.xml
index 14750e7..93e153d 100644
--- a/doc_classes/VisualScriptExpression.xml
+++ b/doc_classes/VisualScriptExpression.xml
@@ -1,5 +1,5 @@
-
+
A Visual Script node that can execute a custom expression.
diff --git a/doc_classes/VisualScriptFunction.xml b/doc_classes/VisualScriptFunction.xml
index 74d9f19..12a1b2d 100644
--- a/doc_classes/VisualScriptFunction.xml
+++ b/doc_classes/VisualScriptFunction.xml
@@ -1,5 +1,5 @@
-
+
A Visual Script node representing a function.
diff --git a/doc_classes/VisualScriptFunctionCall.xml b/doc_classes/VisualScriptFunctionCall.xml
index 543263f..92c0100 100644
--- a/doc_classes/VisualScriptFunctionCall.xml
+++ b/doc_classes/VisualScriptFunctionCall.xml
@@ -1,5 +1,5 @@
-
+
A Visual Script node for calling a function.
@@ -33,7 +33,7 @@
The singleton to call the method on. Used when [member call_mode] is set to [constant CALL_MODE_SINGLETON].
-
+
Number of default arguments that will be used when calling the function. Can't be higher than the number of available default arguments in the method's declaration.
diff --git a/doc_classes/VisualScriptFunctionState.xml b/doc_classes/VisualScriptFunctionState.xml
index 03fef9c..d7d88f9 100644
--- a/doc_classes/VisualScriptFunctionState.xml
+++ b/doc_classes/VisualScriptFunctionState.xml
@@ -1,5 +1,5 @@
-
+
A Visual Script node representing a function state.
diff --git a/doc_classes/VisualScriptGlobalConstant.xml b/doc_classes/VisualScriptGlobalConstant.xml
index 42ada99..05c4137 100644
--- a/doc_classes/VisualScriptGlobalConstant.xml
+++ b/doc_classes/VisualScriptGlobalConstant.xml
@@ -1,5 +1,5 @@
-
+
A Visual Script node returning a constant from [@GlobalScope].
diff --git a/doc_classes/VisualScriptIndexGet.xml b/doc_classes/VisualScriptIndexGet.xml
index 8828bf9..1a71176 100644
--- a/doc_classes/VisualScriptIndexGet.xml
+++ b/doc_classes/VisualScriptIndexGet.xml
@@ -1,5 +1,5 @@
-
+
A Visual Script node for getting a value from an array or a dictionary.
diff --git a/doc_classes/VisualScriptIndexSet.xml b/doc_classes/VisualScriptIndexSet.xml
index 5c81dcd..6265ed6 100644
--- a/doc_classes/VisualScriptIndexSet.xml
+++ b/doc_classes/VisualScriptIndexSet.xml
@@ -1,5 +1,5 @@
-
+
A Visual Script node for setting a value in an array or a dictionary.
diff --git a/doc_classes/VisualScriptInputAction.xml b/doc_classes/VisualScriptInputAction.xml
index 51c2eaf..cd03bf9 100644
--- a/doc_classes/VisualScriptInputAction.xml
+++ b/doc_classes/VisualScriptInputAction.xml
@@ -1,5 +1,5 @@
-
+
A Visual Script node returning a state of an action.
diff --git a/doc_classes/VisualScriptIterator.xml b/doc_classes/VisualScriptIterator.xml
index ef6846d..098b2a6 100644
--- a/doc_classes/VisualScriptIterator.xml
+++ b/doc_classes/VisualScriptIterator.xml
@@ -1,5 +1,5 @@
-
+
Steps through items in a given input.
diff --git a/doc_classes/VisualScriptLists.xml b/doc_classes/VisualScriptLists.xml
index 607965b..2e136e8 100644
--- a/doc_classes/VisualScriptLists.xml
+++ b/doc_classes/VisualScriptLists.xml
@@ -1,5 +1,5 @@
-
+
A Visual Script virtual class for in-graph editable nodes.
diff --git a/doc_classes/VisualScriptLocalVar.xml b/doc_classes/VisualScriptLocalVar.xml
index dbf9049..3377308 100644
--- a/doc_classes/VisualScriptLocalVar.xml
+++ b/doc_classes/VisualScriptLocalVar.xml
@@ -1,5 +1,5 @@
-
+
Gets a local variable's value.
diff --git a/doc_classes/VisualScriptLocalVarSet.xml b/doc_classes/VisualScriptLocalVarSet.xml
index 1ae4e20..d9c704d 100644
--- a/doc_classes/VisualScriptLocalVarSet.xml
+++ b/doc_classes/VisualScriptLocalVarSet.xml
@@ -1,5 +1,5 @@
-
+
Changes a local variable's value.
diff --git a/doc_classes/VisualScriptMathConstant.xml b/doc_classes/VisualScriptMathConstant.xml
index 01c36e7..825fda1 100644
--- a/doc_classes/VisualScriptMathConstant.xml
+++ b/doc_classes/VisualScriptMathConstant.xml
@@ -1,5 +1,5 @@
-
+
Commonly used mathematical constants.
diff --git a/doc_classes/VisualScriptNode.xml b/doc_classes/VisualScriptNode.xml
index 97c4f8c..aa12622 100644
--- a/doc_classes/VisualScriptNode.xml
+++ b/doc_classes/VisualScriptNode.xml
@@ -1,5 +1,5 @@
-
+
A node which is part of a [VisualScript].
diff --git a/doc_classes/VisualScriptOperator.xml b/doc_classes/VisualScriptOperator.xml
index 47ca6dd..148cc3c 100644
--- a/doc_classes/VisualScriptOperator.xml
+++ b/doc_classes/VisualScriptOperator.xml
@@ -1,5 +1,5 @@
-
+
A Visual Script node that performs an operation on two values.
diff --git a/doc_classes/VisualScriptPreload.xml b/doc_classes/VisualScriptPreload.xml
index 146d6cd..dd9163a 100644
--- a/doc_classes/VisualScriptPreload.xml
+++ b/doc_classes/VisualScriptPreload.xml
@@ -1,5 +1,5 @@
-
+
Creates a new [Resource] or loads one from the filesystem.
diff --git a/doc_classes/VisualScriptPropertyGet.xml b/doc_classes/VisualScriptPropertyGet.xml
index 77cd639..3217a3d 100644
--- a/doc_classes/VisualScriptPropertyGet.xml
+++ b/doc_classes/VisualScriptPropertyGet.xml
@@ -1,5 +1,5 @@
-
+
A Visual Script node returning a value of a property from an [Object].
diff --git a/doc_classes/VisualScriptPropertySet.xml b/doc_classes/VisualScriptPropertySet.xml
index 6cffa32..7f000b7 100644
--- a/doc_classes/VisualScriptPropertySet.xml
+++ b/doc_classes/VisualScriptPropertySet.xml
@@ -1,5 +1,5 @@
-
+
A Visual Script node that sets a property of an [Object].
diff --git a/doc_classes/VisualScriptResourcePath.xml b/doc_classes/VisualScriptResourcePath.xml
index 6ca8260..eee339f 100644
--- a/doc_classes/VisualScriptResourcePath.xml
+++ b/doc_classes/VisualScriptResourcePath.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/doc_classes/VisualScriptReturn.xml b/doc_classes/VisualScriptReturn.xml
index 1d59392..ff5a02c 100644
--- a/doc_classes/VisualScriptReturn.xml
+++ b/doc_classes/VisualScriptReturn.xml
@@ -1,5 +1,5 @@
-
+
Exits a function and returns an optional value.
diff --git a/doc_classes/VisualScriptSceneNode.xml b/doc_classes/VisualScriptSceneNode.xml
index a769d11..cf6ca51 100644
--- a/doc_classes/VisualScriptSceneNode.xml
+++ b/doc_classes/VisualScriptSceneNode.xml
@@ -1,5 +1,5 @@
-
+
Node reference.
diff --git a/doc_classes/VisualScriptSceneTree.xml b/doc_classes/VisualScriptSceneTree.xml
index 84ab908..3c52792 100644
--- a/doc_classes/VisualScriptSceneTree.xml
+++ b/doc_classes/VisualScriptSceneTree.xml
@@ -1,5 +1,5 @@
-
+
A Visual Script node for accessing [SceneTree] methods.
diff --git a/doc_classes/VisualScriptSelect.xml b/doc_classes/VisualScriptSelect.xml
index 1aa916f..8dde38e 100644
--- a/doc_classes/VisualScriptSelect.xml
+++ b/doc_classes/VisualScriptSelect.xml
@@ -1,5 +1,5 @@
-
+
Chooses between two input values.
diff --git a/doc_classes/VisualScriptSelf.xml b/doc_classes/VisualScriptSelf.xml
index 8cc59db..fd87dfd 100644
--- a/doc_classes/VisualScriptSelf.xml
+++ b/doc_classes/VisualScriptSelf.xml
@@ -1,5 +1,5 @@
-
+
Outputs a reference to the current instance.
diff --git a/doc_classes/VisualScriptSequence.xml b/doc_classes/VisualScriptSequence.xml
index 9adbc30..a8cb284 100644
--- a/doc_classes/VisualScriptSequence.xml
+++ b/doc_classes/VisualScriptSequence.xml
@@ -1,5 +1,5 @@
-
+
Executes a series of Sequence ports.
diff --git a/doc_classes/VisualScriptSubCall.xml b/doc_classes/VisualScriptSubCall.xml
index 535e89f..ba593a7 100644
--- a/doc_classes/VisualScriptSubCall.xml
+++ b/doc_classes/VisualScriptSubCall.xml
@@ -1,5 +1,5 @@
-
+
Calls a method called [code]_subcall[/code] in this object.
diff --git a/doc_classes/VisualScriptSwitch.xml b/doc_classes/VisualScriptSwitch.xml
index 7befe89..a5fecfa 100644
--- a/doc_classes/VisualScriptSwitch.xml
+++ b/doc_classes/VisualScriptSwitch.xml
@@ -1,5 +1,5 @@
-
+
Branches program flow based on a given input's value.
diff --git a/doc_classes/VisualScriptTypeCast.xml b/doc_classes/VisualScriptTypeCast.xml
index ec84a75..3607812 100644
--- a/doc_classes/VisualScriptTypeCast.xml
+++ b/doc_classes/VisualScriptTypeCast.xml
@@ -1,5 +1,5 @@
-
+
A Visual Script node that casts the given value to another type.
diff --git a/doc_classes/VisualScriptVariableGet.xml b/doc_classes/VisualScriptVariableGet.xml
index 8d99b4b..d71f0ec 100644
--- a/doc_classes/VisualScriptVariableGet.xml
+++ b/doc_classes/VisualScriptVariableGet.xml
@@ -1,5 +1,5 @@
-
+
Gets a variable's value.
diff --git a/doc_classes/VisualScriptVariableSet.xml b/doc_classes/VisualScriptVariableSet.xml
index 4f568cc..c5f34af 100644
--- a/doc_classes/VisualScriptVariableSet.xml
+++ b/doc_classes/VisualScriptVariableSet.xml
@@ -1,5 +1,5 @@
-
+
Changes a variable's value.
diff --git a/doc_classes/VisualScriptWhile.xml b/doc_classes/VisualScriptWhile.xml
index 4e7ccce..e92172b 100644
--- a/doc_classes/VisualScriptWhile.xml
+++ b/doc_classes/VisualScriptWhile.xml
@@ -1,5 +1,5 @@
-
+
Conditional loop.
diff --git a/doc_classes/VisualScriptYield.xml b/doc_classes/VisualScriptYield.xml
index ec757a3..31ca8cc 100644
--- a/doc_classes/VisualScriptYield.xml
+++ b/doc_classes/VisualScriptYield.xml
@@ -1,5 +1,5 @@
-
+
A Visual Script node used to pause a function execution.
diff --git a/doc_classes/VisualScriptYieldSignal.xml b/doc_classes/VisualScriptYieldSignal.xml
index c3f4bc4..f9a9ff8 100644
--- a/doc_classes/VisualScriptYieldSignal.xml
+++ b/doc_classes/VisualScriptYieldSignal.xml
@@ -1,5 +1,5 @@
-
+
A Visual Script node yielding for a signal.
diff --git a/editor/visual_script_editor.cpp b/editor/visual_script_editor.cpp
index 1795bf0..0417c96 100644
--- a/editor/visual_script_editor.cpp
+++ b/editor/visual_script_editor.cpp
@@ -1,32 +1,32 @@
-/*************************************************************************/
-/* visual_script_editor.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
+/**************************************************************************/
+/* visual_script_editor.cpp */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
#include "visual_script_editor.h"
@@ -35,6 +35,7 @@
#include "../visual_script_func_nodes.h"
#include "../visual_script_nodes.h"
#include "core/input/input.h"
+#include "core/input/input_enums.h"
#include "core/object/class_db.h"
#include "core/object/script_language.h"
#include "core/os/keyboard.h"
@@ -44,20 +45,25 @@
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/editor_undo_redo_manager.h"
+#include "editor/inspector_dock.h"
#include "scene/gui/check_button.h"
#include "scene/gui/graph_edit.h"
#include "scene/gui/separator.h"
+#include "scene/gui/texture_rect.h"
#include "scene/gui/view_panner.h"
-#include "editor/inspector_dock.h"
#include "scene/main/window.h"
#ifdef TOOLS_ENABLED
void VisualScriptEditedProperty::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_edited_property", "value"), &VisualScriptEditedProperty::set_edited_property);
- ClassDB::bind_method(D_METHOD("get_edited_property"), &VisualScriptEditedProperty::get_edited_property);
+ ClassDB::bind_method(D_METHOD("set_edited_property", "value"),
+ &VisualScriptEditedProperty::set_edited_property);
+ ClassDB::bind_method(D_METHOD("get_edited_property"),
+ &VisualScriptEditedProperty::get_edited_property);
- ADD_PROPERTY(PropertyInfo(Variant::NIL, "edited_property", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT), "set_edited_property", "get_edited_property");
+ ADD_PROPERTY(PropertyInfo(Variant::NIL, "edited_property", PROPERTY_HINT_NONE,
+ "", PROPERTY_USAGE_NIL_IS_VARIANT),
+ "set_edited_property", "get_edited_property");
}
void VisualScriptEditedProperty::set_edited_property(Variant p_variant) {
@@ -76,12 +82,13 @@ class VisualScriptEditorSignalEdit : public Object {
StringName sig;
public:
- Ref undo_redo;
+ EditorUndoRedoManager *undo_redo = nullptr;
Ref script;
protected:
static void _bind_methods() {
- ClassDB::bind_method("_sig_changed", &VisualScriptEditorSignalEdit::_sig_changed);
+ ClassDB::bind_method("_sig_changed",
+ &VisualScriptEditorSignalEdit::_sig_changed);
ADD_SIGNAL(MethodInfo("changed"));
}
@@ -106,13 +113,19 @@ protected:
if (new_argc < argc) {
for (int i = new_argc; i < argc; i++) {
- undo_redo->add_do_method(script.ptr(), "custom_signal_remove_argument", sig, new_argc);
- undo_redo->add_undo_method(script.ptr(), "custom_signal_add_argument", sig, script->custom_signal_get_argument_name(sig, i), script->custom_signal_get_argument_type(sig, i), -1);
+ undo_redo->add_do_method(
+ script.ptr(), "custom_signal_remove_argument", sig, new_argc);
+ undo_redo->add_undo_method(
+ script.ptr(), "custom_signal_add_argument", sig,
+ script->custom_signal_get_argument_name(sig, i),
+ script->custom_signal_get_argument_type(sig, i), -1);
}
} else if (new_argc > argc) {
for (int i = argc; i < new_argc; i++) {
- undo_redo->add_do_method(script.ptr(), "custom_signal_add_argument", sig, Variant::NIL, "arg" + itos(i + 1), -1);
- undo_redo->add_undo_method(script.ptr(), "custom_signal_remove_argument", sig, argc);
+ undo_redo->add_do_method(script.ptr(), "custom_signal_add_argument",
+ sig, Variant::NIL, "arg" + itos(i + 1), -1);
+ undo_redo->add_undo_method(
+ script.ptr(), "custom_signal_remove_argument", sig, argc);
}
}
@@ -125,14 +138,19 @@ protected:
}
if (String(p_name).begins_with("argument/")) {
int idx = String(p_name).get_slice("/", 1).to_int() - 1;
- ERR_FAIL_INDEX_V(idx, script->custom_signal_get_argument_count(sig), false);
+ ERR_FAIL_INDEX_V(idx, script->custom_signal_get_argument_count(sig),
+ false);
String what = String(p_name).get_slice("/", 2);
if (what == "type") {
int old_type = script->custom_signal_get_argument_type(sig, idx);
int new_type = p_value;
undo_redo->create_action(TTR("Change Argument Type"));
- undo_redo->add_do_method(script.ptr(), "custom_signal_set_argument_type", sig, idx, new_type);
- undo_redo->add_undo_method(script.ptr(), "custom_signal_set_argument_type", sig, idx, old_type);
+ undo_redo->add_do_method(script.ptr(),
+ "custom_signal_set_argument_type", sig, idx,
+ new_type);
+ undo_redo->add_undo_method(script.ptr(),
+ "custom_signal_set_argument_type", sig, idx,
+ old_type);
undo_redo->commit_action();
return true;
@@ -142,8 +160,12 @@ protected:
String old_name = script->custom_signal_get_argument_name(sig, idx);
String new_name = p_value;
undo_redo->create_action(TTR("Change Argument name"));
- undo_redo->add_do_method(script.ptr(), "custom_signal_set_argument_name", sig, idx, new_name);
- undo_redo->add_undo_method(script.ptr(), "custom_signal_set_argument_name", sig, idx, old_name);
+ undo_redo->add_do_method(script.ptr(),
+ "custom_signal_set_argument_name", sig, idx,
+ new_name);
+ undo_redo->add_undo_method(script.ptr(),
+ "custom_signal_set_argument_name", sig, idx,
+ old_name);
undo_redo->commit_action();
return true;
}
@@ -163,7 +185,8 @@ protected:
}
if (String(p_name).begins_with("argument/")) {
int idx = String(p_name).get_slice("/", 1).to_int() - 1;
- ERR_FAIL_INDEX_V(idx, script->custom_signal_get_argument_count(sig), false);
+ ERR_FAIL_INDEX_V(idx, script->custom_signal_get_argument_count(sig),
+ false);
String what = String(p_name).get_slice("/", 2);
if (what == "type") {
r_ret = script->custom_signal_get_argument_type(sig, idx);
@@ -182,15 +205,19 @@ protected:
return;
}
- p_list->push_back(PropertyInfo(Variant::INT, "argument_count", PROPERTY_HINT_RANGE, "0,256"));
+ p_list->push_back(PropertyInfo(Variant::INT, "argument_count",
+ PROPERTY_HINT_RANGE, "0,256"));
String argt = "Variant";
for (int i = 1; i < Variant::VARIANT_MAX; i++) {
argt += "," + Variant::get_type_name(Variant::Type(i));
}
for (int i = 0; i < script->custom_signal_get_argument_count(sig); i++) {
- p_list->push_back(PropertyInfo(Variant::INT, "argument/" + itos(i + 1) + "/type", PROPERTY_HINT_ENUM, argt));
- p_list->push_back(PropertyInfo(Variant::STRING, "argument/" + itos(i + 1) + "/name"));
+ p_list->push_back(PropertyInfo(Variant::INT,
+ "argument/" + itos(i + 1) + "/type",
+ PROPERTY_HINT_ENUM, argt));
+ p_list->push_back(
+ PropertyInfo(Variant::STRING, "argument/" + itos(i + 1) + "/name"));
}
}
@@ -207,13 +234,15 @@ class VisualScriptEditorVariableEdit : public Object {
StringName var;
public:
- Ref undo_redo;
+ EditorUndoRedoManager *undo_redo = nullptr;
Ref script;
protected:
static void _bind_methods() {
- ClassDB::bind_method("_var_changed", &VisualScriptEditorVariableEdit::_var_changed);
- ClassDB::bind_method("_var_value_changed", &VisualScriptEditorVariableEdit::_var_value_changed);
+ ClassDB::bind_method("_var_changed",
+ &VisualScriptEditorVariableEdit::_var_changed);
+ ClassDB::bind_method("_var_value_changed",
+ &VisualScriptEditorVariableEdit::_var_value_changed);
ADD_SIGNAL(MethodInfo("changed"));
}
@@ -221,9 +250,7 @@ protected:
notify_property_list_changed();
emit_signal(SNAME("changed"));
}
- void _var_value_changed() {
- emit_signal(SNAME("changed"));
- }
+ void _var_value_changed() { emit_signal(SNAME("changed")); }
bool _set(const StringName &p_name, const Variant &p_value) {
if (var == StringName()) {
@@ -233,8 +260,10 @@ protected:
if (String(p_name) == "value") {
undo_redo->create_action(TTR("Set Variable Default Value"));
Variant current = script->get_variable_default_value(var);
- undo_redo->add_do_method(script.ptr(), "set_variable_default_value", var, p_value);
- undo_redo->add_undo_method(script.ptr(), "set_variable_default_value", var, current);
+ undo_redo->add_do_method(script.ptr(), "set_variable_default_value", var,
+ p_value);
+ undo_redo->add_undo_method(script.ptr(), "set_variable_default_value",
+ var, current);
undo_redo->add_do_method(this, "_var_value_changed");
undo_redo->add_undo_method(this, "_var_value_changed");
undo_redo->commit_action();
@@ -257,8 +286,10 @@ protected:
Callable::CallError ce;
Variant::construct(type, default_value, nullptr, 0, ce);
if (ce.error == Callable::CallError::CALL_OK) {
- undo_redo->add_do_method(script.ptr(), "set_variable_default_value", var, default_value);
- undo_redo->add_undo_method(script.ptr(), "set_variable_default_value", var, dc["value"]);
+ undo_redo->add_do_method(script.ptr(), "set_variable_default_value",
+ var, default_value);
+ undo_redo->add_undo_method(script.ptr(), "set_variable_default_value",
+ var, dc["value"]);
}
}
@@ -342,10 +373,23 @@ protected:
for (int i = 1; i < Variant::VARIANT_MAX; i++) {
argt += "," + Variant::get_type_name(Variant::Type(i));
}
- p_list->push_back(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, argt));
- p_list->push_back(PropertyInfo(script->get_variable_info(var).type, "value", script->get_variable_info(var).hint, script->get_variable_info(var).hint_string, PROPERTY_USAGE_DEFAULT));
+ p_list->push_back(
+ PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, argt));
+ p_list->push_back(PropertyInfo(script->get_variable_info(var).type, "value",
+ script->get_variable_info(var).hint,
+ script->get_variable_info(var).hint_string,
+ PROPERTY_USAGE_DEFAULT));
// Update this when PropertyHint changes.
- p_list->push_back(PropertyInfo(Variant::INT, "hint", PROPERTY_HINT_ENUM, "None,Range,ExpRange,Enum,ExpEasing,Length,SpriteFrame,KeyAccel,Flags,Layers2dRender,Layers2dPhysics,Layer3dRender,Layer3dPhysics,File,Dir,GlobalFile,GlobalDir,ResourceType,MultilineText,PlaceholderText,ColorNoAlpha,ImageCompressLossy,ImageCompressLossLess,ObjectId,String,NodePathToEditedNode,MethodOfVariantType,MethodOfBaseType,MethodOfInstance,MethodOfScript,PropertyOfVariantType,PropertyOfBaseType,PropertyOfInstance,PropertyOfScript,ObjectTooBig,NodePathValidTypes"));
+ p_list->push_back(PropertyInfo(
+ Variant::INT, "hint", PROPERTY_HINT_ENUM,
+ "None,Range,ExpRange,Enum,ExpEasing,Length,SpriteFrame,KeyAccel,Flags,"
+ "Layers2dRender,Layers2dPhysics,Layer3dRender,Layer3dPhysics,File,Dir,"
+ "GlobalFile,GlobalDir,ResourceType,MultilineText,PlaceholderText,"
+ "ColorNoAlpha,ImageCompressLossy,ImageCompressLossLess,ObjectId,String,"
+ "NodePathToEditedNode,MethodOfVariantType,MethodOfBaseType,"
+ "MethodOfInstance,MethodOfScript,PropertyOfVariantType,"
+ "PropertyOfBaseType,PropertyOfInstance,PropertyOfScript,ObjectTooBig,"
+ "NodePathValidTypes"));
p_list->push_back(PropertyInfo(Variant::STRING, "hint_string"));
p_list->push_back(PropertyInfo(Variant::BOOL, "export"));
}
@@ -605,7 +649,8 @@ void VisualScriptEditor::_update_graph_connections() {
dc.from_port += from_node->get_output_sequence_port_count();
- graph->connect_node(itos(dc.from_node), dc.from_port, itos(dc.to_node), dc.to_port);
+ graph->connect_node(itos(dc.from_node), dc.from_port, itos(dc.to_node),
+ dc.to_port);
}
}
@@ -616,7 +661,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
updating_graph = true;
- //byebye all nodes
+ // byebye all nodes
if (p_only_id >= 0) {
if (graph->has_node(itos(p_only_id))) {
Node *gid = graph->get_node(itos(p_only_id));
@@ -665,23 +710,30 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
Control::get_theme_icon(SNAME("PackedByteArray"), SNAME("EditorIcons")),
Control::get_theme_icon(SNAME("PackedInt32Array"), SNAME("EditorIcons")),
Control::get_theme_icon(SNAME("PackedInt64Array"), SNAME("EditorIcons")),
- Control::get_theme_icon(SNAME("PackedFloat32Array"), SNAME("EditorIcons")),
- Control::get_theme_icon(SNAME("PackedFloat64Array"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedFloat32Array"),
+ SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedFloat64Array"),
+ SNAME("EditorIcons")),
Control::get_theme_icon(SNAME("PackedStringArray"), SNAME("EditorIcons")),
- Control::get_theme_icon(SNAME("PackedVector2Array"), SNAME("EditorIcons")),
- Control::get_theme_icon(SNAME("PackedVector3Array"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedVector2Array"),
+ SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedVector3Array"),
+ SNAME("EditorIcons")),
Control::get_theme_icon(SNAME("PackedColorArray"), SNAME("EditorIcons"))
};
// Visual script specific theme for MSDF font.
Ref vstheme;
vstheme.instantiate();
- Ref label_font = EditorNode::get_singleton()->get_editor_theme()->get_font("main_msdf", "EditorFonts");
+ Ref label_font =
+ EditorNode::get_singleton()->get_editor_theme()->get_font("main_msdf",
+ "EditorFonts");
vstheme->set_font("font", "Label", label_font);
vstheme->set_font("font", "LineEdit", label_font);
vstheme->set_font("font", "Button", label_font);
- Ref seq_port = Control::get_theme_icon(SNAME("VisualShaderPort"), SNAME("EditorIcons"));
+ Ref seq_port =
+ Control::get_theme_icon(SNAME("VisualShaderPort"), SNAME("EditorIcons"));
List node_ids;
script->get_node_list(&node_ids);
@@ -707,8 +759,11 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
gnode->set_meta("__vnode", node);
gnode->set_name(itos(E));
- gnode->connect("dragged", callable_mp(this, &VisualScriptEditor::_node_moved).bind(E));
- gnode->connect("close_request", callable_mp(this, &VisualScriptEditor::_remove_node).bind(E), CONNECT_DEFERRED);
+ gnode->connect("dragged",
+ callable_mp(this, &VisualScriptEditor::_node_moved).bind(E));
+ gnode->connect("close_request",
+ callable_mp(this, &VisualScriptEditor::_remove_node).bind(E),
+ CONNECT_DEFERRED);
{
Ref v = node;
@@ -728,7 +783,10 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
Button *btn = memnew(Button);
btn->set_text(TTR("Add Input Port"));
hbnc->add_child(btn);
- btn->connect("pressed", callable_mp(this, &VisualScriptEditor::_add_input_port).bind(E), CONNECT_DEFERRED);
+ btn->connect(
+ "pressed",
+ callable_mp(this, &VisualScriptEditor::_add_input_port).bind(E),
+ CONNECT_DEFERRED);
}
if (nd_list->is_output_port_editable()) {
if (nd_list->is_input_port_editable()) {
@@ -738,7 +796,10 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
Button *btn = memnew(Button);
btn->set_text(TTR("Add Output Port"));
hbnc->add_child(btn);
- btn->connect("pressed", callable_mp(this, &VisualScriptEditor::_add_output_port).bind(E), CONNECT_DEFERRED);
+ btn->connect(
+ "pressed",
+ callable_mp(this, &VisualScriptEditor::_add_output_port).bind(E),
+ CONNECT_DEFERRED);
}
gnode->add_child(hbnc);
} else if (Object::cast_to(node.ptr())) {
@@ -746,9 +807,13 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
LineEdit *line_edit = memnew(LineEdit);
line_edit->set_text(node->get_text());
line_edit->set_expand_to_text_length_enabled(true);
- line_edit->add_theme_font_override("font", get_theme_font(SNAME("source"), SNAME("EditorFonts")));
+ line_edit->add_theme_font_override(
+ "font", get_theme_font(SNAME("source"), SNAME("EditorFonts")));
gnode->add_child(line_edit);
- line_edit->connect("text_changed", callable_mp(this, &VisualScriptEditor::_expression_text_changed).bind(E));
+ line_edit->connect(
+ "text_changed",
+ callable_mp(this, &VisualScriptEditor::_expression_text_changed)
+ .bind(E));
} else {
String text = node->get_text();
if (!text.is_empty()) {
@@ -759,22 +824,11 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
}
}
- if (Object::cast_to(node.ptr())) {
- Ref vsc = node;
- gnode->set_comment(true);
- gnode->set_resizable(true);
- gnode->set_custom_minimum_size(vsc->get_size() * EDSCALE);
- gnode->connect("resize_request", callable_mp(this, &VisualScriptEditor::_comment_node_resized).bind(E));
- }
-
if (node_styles.has(node->get_category())) {
Ref sbf = node_styles[node->get_category()];
- if (gnode->is_comment()) {
- sbf = EditorNode::get_singleton()->get_theme_base()->get_theme()->get_stylebox(SNAME("comment"), SNAME("GraphNode"));
- }
-
Color c = sbf->get_border_color();
- c = ((c.r + c.g + c.b) / 3) < 0.7 ? Color(1.0, 1.0, 1.0, 0.85) : Color(0.0, 0.0, 0.0, 0.85);
+ c = ((c.r + c.g + c.b) / 3) < 0.7 ? Color(1.0, 1.0, 1.0, 0.85)
+ : Color(0.0, 0.0, 0.0, 0.85);
Color ic = c;
gnode->add_theme_color_override("title_color", c);
c.a = 1;
@@ -783,24 +837,30 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
gnode->add_theme_style_override("frame", sbf);
}
- const Color mono_color = get_theme_color(SNAME("mono_color"), SNAME("Editor"));
+ const Color mono_color =
+ get_theme_color(SNAME("mono_color"), SNAME("Editor"));
int slot_idx = 0;
- bool single_seq_output = node->get_output_sequence_port_count() == 1 && node->get_output_sequence_port_text(0) == String();
- if ((node->has_input_sequence_port() || single_seq_output) || has_gnode_text) {
- // IF has_gnode_text is true BUT we have no sequence ports to draw (in here),
- // we still draw the disabled default ones to shift up the slots by one,
- // so the slots DON'T start with the content text.
+ bool single_seq_output = node->get_output_sequence_port_count() == 1 &&
+ node->get_output_sequence_port_text(0) == String();
+ if ((node->has_input_sequence_port() || single_seq_output) ||
+ has_gnode_text) {
+ // IF has_gnode_text is true BUT we have no sequence ports to draw (in
+ // here), we still draw the disabled default ones to shift up the slots by
+ // one, so the slots DON'T start with the content text.
- // IF has_gnode_text is false, but we DO want to draw default sequence ports,
- // we draw a dummy text to take up the position of the sequence nodes, so all the other ports are still aligned correctly.
+ // IF has_gnode_text is false, but we DO want to draw default sequence
+ // ports, we draw a dummy text to take up the position of the sequence
+ // nodes, so all the other ports are still aligned correctly.
if (!has_gnode_text) {
Label *dummy = memnew(Label);
dummy->set_text(" ");
gnode->add_child(dummy);
}
- gnode->set_slot(0, node->has_input_sequence_port(), TYPE_SEQUENCE, mono_color, single_seq_output, TYPE_SEQUENCE, mono_color, seq_port, seq_port);
+ gnode->set_slot(0, node->has_input_sequence_port(), TYPE_SEQUENCE,
+ mono_color, single_seq_output, TYPE_SEQUENCE, mono_color,
+ seq_port, seq_port);
slot_idx++;
}
@@ -815,13 +875,17 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
text2->set_text(node->get_output_sequence_port_text(i));
text2->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_RIGHT);
gnode->add_child(text2);
- gnode->set_slot(slot_idx, false, 0, Color(), true, TYPE_SEQUENCE, mono_color, seq_port, seq_port);
+ gnode->set_slot(slot_idx, false, 0, Color(), true, TYPE_SEQUENCE,
+ mono_color, seq_port, seq_port);
slot_idx++;
}
}
}
- for (int i = 0; i < MAX(node->get_output_value_port_count(), MAX(mixed_seq_ports, node->get_input_value_port_count())); i++) {
+ for (int i = 0;
+ i < MAX(node->get_output_value_port_count(),
+ MAX(mixed_seq_ports, node->get_input_value_port_count()));
+ i++) {
bool left_ok = false;
Variant::Type left_type = Variant::NIL;
String left_name;
@@ -837,7 +901,8 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
Variant::Type right_type = Variant::NIL;
String right_name;
- if (i >= mixed_seq_ports && i < node->get_output_value_port_count() + mixed_seq_ports) {
+ if (i >= mixed_seq_ports &&
+ i < node->get_output_value_port_count() + mixed_seq_ports) {
PropertyInfo pi = node->get_output_value_port_info(i - mixed_seq_ports);
right_ok = true;
right_type = pi.type;
@@ -867,8 +932,14 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
name_box->set_custom_minimum_size(Size2(60 * EDSCALE, 0));
name_box->set_text(left_name);
name_box->set_expand_to_text_length_enabled(true);
- name_box->connect("resized", callable_mp(this, &VisualScriptEditor::_update_node_size).bind(E));
- name_box->connect("focus_exited", callable_mp(this, &VisualScriptEditor::_port_name_focus_out).bind(name_box, E, i, true));
+ name_box->connect(
+ "resized",
+ callable_mp(this, &VisualScriptEditor::_update_node_size)
+ .bind(E));
+ name_box->connect(
+ "focus_exited",
+ callable_mp(this, &VisualScriptEditor::_port_name_focus_out)
+ .bind(name_box, E, i, true));
} else {
hbc->add_child(memnew(Label(left_name)));
}
@@ -881,24 +952,35 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
opbtn->select(left_type);
opbtn->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
hbc->add_child(opbtn);
- opbtn->connect("item_selected", callable_mp(this, &VisualScriptEditor::_change_port_type).bind(E, i, true), CONNECT_DEFERRED);
+ opbtn->connect(
+ "item_selected",
+ callable_mp(this, &VisualScriptEditor::_change_port_type)
+ .bind(E, i, true),
+ CONNECT_DEFERRED);
}
Button *rmbtn = memnew(Button);
- rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
+ rmbtn->set_icon(
+ EditorNode::get_singleton()->get_gui_base()->get_theme_icon(
+ SNAME("Remove"), SNAME("EditorIcons")));
hbc->add_child(rmbtn);
- rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_input_port).bind(E, i), CONNECT_DEFERRED);
+ rmbtn->connect(
+ "pressed",
+ callable_mp(this, &VisualScriptEditor::_remove_input_port)
+ .bind(E, i),
+ CONNECT_DEFERRED);
} else {
hbc->add_child(memnew(Label(left_name)));
}
- if (left_type != Variant::NIL && !script->is_input_value_port_connected(E, i)) {
+ if (left_type != Variant::NIL &&
+ !script->is_input_value_port_connected(E, i)) {
PropertyInfo pi = node->get_input_value_port_info(i);
Button *button = memnew(Button);
Variant value = node->get_default_input_value(i);
if (value.get_type() != left_type) {
- //different type? for now convert
- //not the same, reconvert
+ // different type? for now convert
+ // not the same, reconvert
Callable::CallError ce;
const Variant *existingp = &value;
Variant::construct(left_type, value, &existingp, 1, ce);
@@ -906,13 +988,19 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
if (left_type == Variant::COLOR) {
button->set_custom_minimum_size(Size2(30, 0) * EDSCALE);
- button->connect("draw", callable_mp(this, &VisualScriptEditor::_draw_color_over_button).bind(button, value));
- } else if (left_type == Variant::OBJECT && Ref(value).is_valid()) {
+ button->connect(
+ "draw",
+ callable_mp(this, &VisualScriptEditor::_draw_color_over_button)
+ .bind(button, value));
+ } else if (left_type == Variant::OBJECT &&
+ Ref(value).is_valid()) {
Ref res = value;
Array arr;
arr.push_back(button->get_instance_id());
arr.push_back(String(value));
- EditorResourcePreview::get_singleton()->queue_edited_resource_preview(res, this, "_button_resource_previewed", arr);
+ EditorResourcePreview::get_singleton()
+ ->queue_edited_resource_preview(
+ res, this, "_button_resource_previewed", arr);
} else if (pi.type == Variant::INT && pi.hint == PROPERTY_HINT_ENUM) {
bool found = false;
@@ -933,7 +1021,8 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
if (!found) {
button->set_text(value);
}
- } else if (pi.type == Variant::INT && pi.hint == PROPERTY_HINT_FLAGS) {
+ } else if (pi.type == Variant::INT &&
+ pi.hint == PROPERTY_HINT_FLAGS) {
Vector value_texts;
const Vector options = pi.hint_string.split(",");
uint32_t v = value;
@@ -961,7 +1050,10 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
} else {
button->set_text(value);
}
- button->connect("pressed", callable_mp(this, &VisualScriptEditor::_default_value_edited).bind(button, E, i));
+ button->connect(
+ "pressed",
+ callable_mp(this, &VisualScriptEditor::_default_value_edited)
+ .bind(button, E, i));
hbc2->add_child(button);
}
} else {
@@ -983,9 +1075,15 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
if (right_ok) {
if (is_vslist) {
Button *rmbtn = memnew(Button);
- rmbtn->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
+ rmbtn->set_icon(
+ EditorNode::get_singleton()->get_gui_base()->get_theme_icon(
+ SNAME("Remove"), SNAME("EditorIcons")));
hbc->add_child(rmbtn);
- rmbtn->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_output_port).bind(E, i), CONNECT_DEFERRED);
+ rmbtn->connect(
+ "pressed",
+ callable_mp(this, &VisualScriptEditor::_remove_output_port)
+ .bind(E, i),
+ CONNECT_DEFERRED);
if (nd_list->is_output_port_type_editable()) {
OptionButton *opbtn = memnew(OptionButton);
@@ -995,7 +1093,11 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
opbtn->select(right_type);
opbtn->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
hbc->add_child(opbtn);
- opbtn->connect("item_selected", callable_mp(this, &VisualScriptEditor::_change_port_type).bind(E, i, false), CONNECT_DEFERRED);
+ opbtn->connect(
+ "item_selected",
+ callable_mp(this, &VisualScriptEditor::_change_port_type)
+ .bind(E, i, false),
+ CONNECT_DEFERRED);
}
if (nd_list->is_output_port_name_editable()) {
@@ -1004,8 +1106,14 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
name_box->set_custom_minimum_size(Size2(60 * EDSCALE, 0));
name_box->set_text(right_name);
name_box->set_expand_to_text_length_enabled(true);
- name_box->connect("resized", callable_mp(this, &VisualScriptEditor::_update_node_size).bind(E));
- name_box->connect("focus_exited", callable_mp(this, &VisualScriptEditor::_port_name_focus_out).bind(name_box, E, i, false));
+ name_box->connect(
+ "resized",
+ callable_mp(this, &VisualScriptEditor::_update_node_size)
+ .bind(E));
+ name_box->connect(
+ "focus_exited",
+ callable_mp(this, &VisualScriptEditor::_port_name_focus_out)
+ .bind(name_box, E, i, false));
} else {
hbc->add_child(memnew(Label(right_name)));
}
@@ -1027,36 +1135,42 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
gnode->add_child(vbc);
- bool dark_theme = get_theme_constant(SNAME("dark_theme"), SNAME("Editor"));
+ bool dark_theme =
+ get_theme_constant(SNAME("dark_theme"), SNAME("Editor"));
if (i < mixed_seq_ports) {
- gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type, dark_theme), true, TYPE_SEQUENCE, mono_color, Ref(), seq_port);
+ gnode->set_slot(slot_idx, left_ok, left_type,
+ _color_from_type(left_type, dark_theme), true,
+ TYPE_SEQUENCE, mono_color, Ref(), seq_port);
} else {
- gnode->set_slot(slot_idx, left_ok, left_type, _color_from_type(left_type, dark_theme), right_ok, right_type, _color_from_type(right_type, dark_theme));
+ gnode->set_slot(slot_idx, left_ok, left_type,
+ _color_from_type(left_type, dark_theme), right_ok,
+ right_type, _color_from_type(right_type, dark_theme));
}
slot_idx++;
}
graph->add_child(gnode);
gnode->set_theme(vstheme);
- if (gnode->is_comment()) {
- graph->move_child(gnode, 0);
- }
}
_update_graph_connections();
- float graph_minimap_opacity = EditorSettings::get_singleton()->get("editors/visual_editors/minimap_opacity");
+ float graph_minimap_opacity = EditorSettings::get_singleton()->get(
+ "editors/visual_editors/minimap_opacity");
graph->set_minimap_opacity(graph_minimap_opacity);
- float graph_lines_curvature = EditorSettings::get_singleton()->get("editors/visual_editors/lines_curvature");
+ float graph_lines_curvature = EditorSettings::get_singleton()->get(
+ "editors/visual_editors/lines_curvature");
graph->set_connection_lines_curvature(graph_lines_curvature);
- // Use default_func instead of default_func for now I think that should be good stop gap solution to ensure not breaking anything.
+ // Use default_func instead of default_func for now I think that should be
+ // good stop gap solution to ensure not breaking anything.
graph->call_deferred(SNAME("set_scroll_ofs"), script->get_scroll() * EDSCALE);
updating_graph = false;
}
-void VisualScriptEditor::_change_port_type(int p_select, int p_id, int p_port, bool is_input) {
+void VisualScriptEditor::_change_port_type(int p_select, int p_id, int p_port,
+ bool is_input) {
Ref vsn = script->get_node(p_id);
if (!vsn.is_valid()) {
return;
@@ -1064,11 +1178,15 @@ void VisualScriptEditor::_change_port_type(int p_select, int p_id, int p_port, b
undo_redo->create_action(TTR("Change Port Type"));
if (is_input) {
- undo_redo->add_do_method(vsn.ptr(), "set_input_data_port_type", p_port, Variant::Type(p_select));
- undo_redo->add_undo_method(vsn.ptr(), "set_input_data_port_type", p_port, vsn->get_input_value_port_info(p_port).type);
+ undo_redo->add_do_method(vsn.ptr(), "set_input_data_port_type", p_port,
+ Variant::Type(p_select));
+ undo_redo->add_undo_method(vsn.ptr(), "set_input_data_port_type", p_port,
+ vsn->get_input_value_port_info(p_port).type);
} else {
- undo_redo->add_do_method(vsn.ptr(), "set_output_data_port_type", p_port, Variant::Type(p_select));
- undo_redo->add_undo_method(vsn.ptr(), "set_output_data_port_type", p_port, vsn->get_output_value_port_info(p_port).type);
+ undo_redo->add_do_method(vsn.ptr(), "set_output_data_port_type", p_port,
+ Variant::Type(p_select));
+ undo_redo->add_undo_method(vsn.ptr(), "set_output_data_port_type", p_port,
+ vsn->get_output_value_port_info(p_port).type);
}
undo_redo->commit_action();
}
@@ -1080,7 +1198,8 @@ void VisualScriptEditor::_update_node_size(int p_id) {
}
}
-void VisualScriptEditor::_port_name_focus_out(const Node *p_name_box, int p_id, int p_port, bool is_input) {
+void VisualScriptEditor::_port_name_focus_out(const Node *p_name_box, int p_id,
+ int p_port, bool is_input) {
Ref vsn = script->get_node(p_id);
if (!vsn.is_valid()) {
return;
@@ -1096,11 +1215,15 @@ void VisualScriptEditor::_port_name_focus_out(const Node *p_name_box, int p_id,
undo_redo->create_action(TTR("Change Port Name"));
if (is_input) {
- undo_redo->add_do_method(vsn.ptr(), "set_input_data_port_name", p_port, text);
- undo_redo->add_undo_method(vsn.ptr(), "set_input_data_port_name", p_port, vsn->get_input_value_port_info(p_port).name);
+ undo_redo->add_do_method(vsn.ptr(), "set_input_data_port_name", p_port,
+ text);
+ undo_redo->add_undo_method(vsn.ptr(), "set_input_data_port_name", p_port,
+ vsn->get_input_value_port_info(p_port).name);
} else {
- undo_redo->add_do_method(vsn.ptr(), "set_output_data_port_name", p_port, text);
- undo_redo->add_undo_method(vsn.ptr(), "set_output_data_port_name", p_port, vsn->get_output_value_port_info(p_port).name);
+ undo_redo->add_do_method(vsn.ptr(), "set_output_data_port_name", p_port,
+ text);
+ undo_redo->add_undo_method(vsn.ptr(), "set_output_data_port_name", p_port,
+ vsn->get_output_value_port_info(p_port).name);
}
undo_redo->commit_action();
}
@@ -1116,9 +1239,14 @@ void VisualScriptEditor::_update_members() {
TreeItem *functions = members->create_item(root);
functions->set_selectable(0, false);
functions->set_text(0, TTR("Functions:"));
- functions->add_button(0, Control::get_theme_icon(SNAME("Override"), SNAME("EditorIcons")), 1, false, TTR("Override an existing built-in function."));
- functions->add_button(0, Control::get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), 0, false, TTR("Create a new function."));
- functions->set_custom_color(0, Control::get_theme_color(SNAME("mono_color"), SNAME("Editor")));
+ functions->add_button(
+ 0, Control::get_theme_icon(SNAME("Override"), SNAME("EditorIcons")), 1,
+ false, TTR("Override an existing built-in function."));
+ functions->add_button(
+ 0, Control::get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), 0, false,
+ TTR("Create a new function."));
+ functions->set_custom_color(
+ 0, Control::get_theme_color(SNAME("mono_color"), SNAME("Editor")));
List func_names;
script->get_function_list(&func_names);
@@ -1128,7 +1256,8 @@ void VisualScriptEditor::_update_members() {
ti->set_text(0, E);
ti->set_selectable(0, true);
ti->set_metadata(0, E);
- ti->add_button(0, Control::get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), 0);
+ ti->add_button(
+ 0, Control::get_theme_icon(SNAME("Edit"), SNAME("EditorIcons")), 0);
if (selected == E) {
ti->select(0);
}
@@ -1137,8 +1266,11 @@ void VisualScriptEditor::_update_members() {
TreeItem *variables = members->create_item(root);
variables->set_selectable(0, false);
variables->set_text(0, TTR("Variables:"));
- variables->add_button(0, Control::get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), -1, false, TTR("Create a new variable."));
- variables->set_custom_color(0, Control::get_theme_color(SNAME("mono_color"), SNAME("Editor")));
+ variables->add_button(
+ 0, Control::get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), -1, false,
+ TTR("Create a new variable."));
+ variables->set_custom_color(
+ 0, Control::get_theme_color(SNAME("mono_color"), SNAME("Editor")));
Ref type_icons[Variant::VARIANT_MAX] = {
Control::get_theme_icon(SNAME("Variant"), SNAME("EditorIcons")),
@@ -1170,11 +1302,15 @@ void VisualScriptEditor::_update_members() {
Control::get_theme_icon(SNAME("PackedByteArray"), SNAME("EditorIcons")),
Control::get_theme_icon(SNAME("PackedInt32Array"), SNAME("EditorIcons")),
Control::get_theme_icon(SNAME("PackedInt64Array"), SNAME("EditorIcons")),
- Control::get_theme_icon(SNAME("PackedFloat32Array"), SNAME("EditorIcons")),
- Control::get_theme_icon(SNAME("PackedFloat64Array"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedFloat32Array"),
+ SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedFloat64Array"),
+ SNAME("EditorIcons")),
Control::get_theme_icon(SNAME("PackedStringArray"), SNAME("EditorIcons")),
- Control::get_theme_icon(SNAME("PackedVector2Array"), SNAME("EditorIcons")),
- Control::get_theme_icon(SNAME("PackedVector3Array"), SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedVector2Array"),
+ SNAME("EditorIcons")),
+ Control::get_theme_icon(SNAME("PackedVector3Array"),
+ SNAME("EditorIcons")),
Control::get_theme_icon(SNAME("PackedColorArray"), SNAME("EditorIcons"))
};
@@ -1200,8 +1336,11 @@ void VisualScriptEditor::_update_members() {
TreeItem *_signals = members->create_item(root);
_signals->set_selectable(0, false);
_signals->set_text(0, TTR("Signals:"));
- _signals->add_button(0, Control::get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), -1, false, TTR("Create a new signal."));
- _signals->set_custom_color(0, Control::get_theme_color(SNAME("mono_color"), SNAME("Editor")));
+ _signals->add_button(
+ 0, Control::get_theme_icon(SNAME("Add"), SNAME("EditorIcons")), -1, false,
+ TTR("Create a new signal."));
+ _signals->set_custom_color(
+ 0, Control::get_theme_color(SNAME("mono_color"), SNAME("Editor")));
List signal_names;
script->get_custom_signal_list(&signal_names);
@@ -1223,19 +1362,22 @@ void VisualScriptEditor::_update_members() {
}
base_type_select->set_text(base_type);
- base_type_select->set_icon(Control::get_theme_icon(icon_type, SNAME("EditorIcons")));
+ base_type_select->set_icon(
+ Control::get_theme_icon(icon_type, SNAME("EditorIcons")));
updating_members = false;
}
-String VisualScriptEditor::_sanitized_variant_text(const StringName &property_name) {
+String
+VisualScriptEditor::_sanitized_variant_text(const StringName &property_name) {
Variant var = script->get_variable_default_value(property_name);
if (script->get_variable_info(property_name).type != Variant::NIL) {
Callable::CallError ce;
const Variant *converted = &var;
Variant n;
- Variant::construct(script->get_variable_info(property_name).type, n, &converted, 1, ce);
+ Variant::construct(script->get_variable_info(property_name).type, n,
+ &converted, 1, ce);
var = n;
}
@@ -1273,25 +1415,29 @@ void VisualScriptEditor::_member_edited() {
TreeItem *ti = members->get_edited();
ERR_FAIL_COND(!ti);
- String name = ti->get_metadata(0);
+ String metadata_name = ti->get_metadata(0);
String new_name = ti->get_text(0);
- if (name == new_name) {
+ if (metadata_name == new_name) {
return;
}
if (!new_name.is_valid_identifier()) {
- EditorNode::get_singleton()->show_warning(TTR("Name is not a valid identifier:") + " " + new_name);
+ EditorNode::get_singleton()->show_warning(
+ TTR("Name is not a valid identifier:") + " " + new_name);
updating_members = true;
- ti->set_text(0, name);
+ ti->set_text(0, metadata_name);
updating_members = false;
return;
}
- if (script->has_function(new_name) || script->has_variable(new_name) || script->has_custom_signal(new_name)) {
- EditorNode::get_singleton()->show_warning(TTR("Name already in use by another func/var/signal:") + " " + new_name);
+ if (script->has_function(new_name) || script->has_variable(new_name) ||
+ script->has_custom_signal(new_name)) {
+ EditorNode::get_singleton()->show_warning(
+ TTR("Name already in use by another func/var/signal:") + " " +
+ new_name);
updating_members = true;
- ti->set_text(0, name);
+ ti->set_text(0, metadata_name);
updating_members = false;
return;
}
@@ -1301,17 +1447,17 @@ void VisualScriptEditor::_member_edited() {
if (ti->get_parent() == root->get_first_child()) {
selected = new_name;
- int node_id = script->get_function_node_id(name);
+ int node_id = script->get_function_node_id(metadata_name);
Ref func;
if (script->has_node(node_id)) {
func = script->get_node(node_id);
}
undo_redo->create_action(TTR("Rename Function"));
- undo_redo->add_do_method(script.ptr(), "rename_function", name, new_name);
- undo_redo->add_undo_method(script.ptr(), "rename_function", new_name, name);
+ undo_redo->add_do_method(script.ptr(), "rename_function", metadata_name, new_name);
+ undo_redo->add_undo_method(script.ptr(), "rename_function", new_name, metadata_name);
if (func.is_valid()) {
undo_redo->add_do_method(func.ptr(), "set_name", new_name);
- undo_redo->add_undo_method(func.ptr(), "set_name", name);
+ undo_redo->add_undo_method(func.ptr(), "set_name", metadata_name);
}
// Also fix all function calls.
@@ -1322,9 +1468,9 @@ void VisualScriptEditor::_member_edited() {
if (!fncall.is_valid()) {
continue;
}
- if (fncall->get_function() == name) {
+ if (fncall->get_function() == metadata_name) {
undo_redo->add_do_method(fncall.ptr(), "set_function", new_name);
- undo_redo->add_undo_method(fncall.ptr(), "set_function", name);
+ undo_redo->add_undo_method(fncall.ptr(), "set_function", metadata_name);
}
}
@@ -1342,22 +1488,22 @@ void VisualScriptEditor::_member_edited() {
if (ti->get_parent() == root->get_first_child()->get_next()) {
selected = new_name;
undo_redo->create_action(TTR("Rename Variable"));
- undo_redo->add_do_method(script.ptr(), "rename_variable", name, new_name);
- undo_redo->add_undo_method(script.ptr(), "rename_variable", new_name, name);
+ undo_redo->add_do_method(script.ptr(), "rename_variable", metadata_name, new_name);
+ undo_redo->add_undo_method(script.ptr(), "rename_variable", new_name, metadata_name);
// Also fix all variable setter & getter calls
List lst;
script->get_node_list(&lst);
for (int &P : lst) {
Ref pset = script->get_node(P);
- if (pset.is_valid() && pset->get_property() == name) {
+ if (pset.is_valid() && pset->get_property() == metadata_name) {
undo_redo->add_do_method(pset.ptr(), "set_property", new_name);
- undo_redo->add_undo_method(pset.ptr(), "set_property", name);
+ undo_redo->add_undo_method(pset.ptr(), "set_property", metadata_name);
}
Ref pget = script->get_node(P);
- if (pget.is_valid() && pget->get_property() == name) {
+ if (pget.is_valid() && pget->get_property() == metadata_name) {
undo_redo->add_do_method(pget.ptr(), "set_property", new_name);
- undo_redo->add_undo_method(pget.ptr(), "set_property", name);
+ undo_redo->add_undo_method(pget.ptr(), "set_property", metadata_name);
}
}
@@ -1375,17 +1521,19 @@ void VisualScriptEditor::_member_edited() {
if (ti->get_parent() == root->get_first_child()->get_next()->get_next()) {
selected = new_name;
undo_redo->create_action(TTR("Rename Signal"));
- undo_redo->add_do_method(script.ptr(), "rename_custom_signal", name, new_name);
- undo_redo->add_undo_method(script.ptr(), "rename_custom_signal", new_name, name);
+ undo_redo->add_do_method(script.ptr(), "rename_custom_signal", metadata_name,
+ new_name);
+ undo_redo->add_undo_method(script.ptr(), "rename_custom_signal", new_name,
+ metadata_name);
// Also fix all signal emitting nodes
List lst;
script->get_node_list(&lst);
for (int &P : lst) {
Ref psig = script->get_node(P);
- if (psig.is_valid() && psig->get_signal() == name) {
+ if (psig.is_valid() && psig->get_signal() == metadata_name) {
undo_redo->add_do_method(psig.ptr(), "set_signal", new_name);
- undo_redo->add_undo_method(psig.ptr(), "set_signal", name);
+ undo_redo->add_undo_method(psig.ptr(), "set_signal", metadata_name);
}
}
@@ -1410,17 +1558,21 @@ void VisualScriptEditor::_create_function_dialog() {
}
void VisualScriptEditor::_create_function() {
- String name = _validate_name((func_name_box->get_text().is_empty()) ? "new_func" : func_name_box->get_text());
- selected = name;
+ String validate_name = _validate_name((func_name_box->get_text().is_empty())
+ ? "new_func"
+ : func_name_box->get_text());
+ selected = validate_name;
Vector2 pos = _get_available_pos();
Ref func_node;
func_node.instantiate();
- func_node->set_name(name);
+ func_node->set_name(validate_name);
for (int i = 0; i < func_input_vbox->get_child_count(); i++) {
- OptionButton *opbtn = Object::cast_to(func_input_vbox->get_child(i)->get_child(3));
- LineEdit *lne = Object::cast_to(func_input_vbox->get_child(i)->get_child(1));
+ OptionButton *opbtn = Object::cast_to(
+ func_input_vbox->get_child(i)->get_child(3));
+ LineEdit *lne =
+ Object::cast_to(func_input_vbox->get_child(i)->get_child(1));
if (!opbtn || !lne) {
continue;
}
@@ -1432,9 +1584,10 @@ void VisualScriptEditor::_create_function() {
int func_node_id = script->get_available_id();
undo_redo->create_action(TTR("Add Function"));
- undo_redo->add_do_method(script.ptr(), "add_function", name, func_node_id);
- undo_redo->add_undo_method(script.ptr(), "remove_function", name);
- undo_redo->add_do_method(script.ptr(), "add_node", func_node_id, func_node, pos);
+ undo_redo->add_do_method(script.ptr(), "add_function", validate_name, func_node_id);
+ undo_redo->add_undo_method(script.ptr(), "remove_function", validate_name);
+ undo_redo->add_do_method(script.ptr(), "add_node", func_node_id, func_node,
+ pos);
undo_redo->add_undo_method(script.ptr(), "remove_node", func_node_id);
undo_redo->add_do_method(this, "_update_members");
undo_redo->add_undo_method(this, "_update_members");
@@ -1462,7 +1615,9 @@ void VisualScriptEditor::_add_func_input() {
LineEdit *name_box = memnew(LineEdit);
name_box->set_h_size_flags(SIZE_EXPAND_FILL);
name_box->set_text("input");
- name_box->connect("focus_entered", callable_mp(this, &VisualScriptEditor::_deselect_input_names));
+ name_box->connect(
+ "focus_entered",
+ callable_mp(this, &VisualScriptEditor::_deselect_input_names));
hbox->add_child(name_box);
Label *type_label = memnew(Label);
@@ -1478,19 +1633,24 @@ void VisualScriptEditor::_add_func_input() {
hbox->add_child(type_box);
Button *delete_button = memnew(Button);
- delete_button->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
+ delete_button->set_icon(
+ EditorNode::get_singleton()->get_gui_base()->get_theme_icon(
+ SNAME("Remove"), SNAME("EditorIcons")));
delete_button->set_tooltip_text(vformat(TTR("Delete input port")));
hbox->add_child(delete_button);
for (int i = 0; i < func_input_vbox->get_child_count(); i++) {
- LineEdit *line_edit = (LineEdit *)func_input_vbox->get_child(i)->get_child(1);
+ LineEdit *line_edit =
+ (LineEdit *)func_input_vbox->get_child(i)->get_child(1);
line_edit->deselect();
}
func_input_vbox->add_child(hbox);
hbox->set_meta("id", hbox->get_index());
- delete_button->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_func_input).bind(hbox));
+ delete_button->connect(
+ "pressed",
+ callable_mp(this, &VisualScriptEditor::_remove_func_input).bind(hbox));
name_box->select_all();
name_box->grab_focus();
@@ -1504,14 +1664,17 @@ void VisualScriptEditor::_remove_func_input(Node *p_node) {
void VisualScriptEditor::_deselect_input_names() {
int cn = func_input_vbox->get_child_count();
for (int i = 0; i < cn; i++) {
- LineEdit *lne = Object::cast_to(func_input_vbox->get_child(i)->get_child(1));
+ LineEdit *lne =
+ Object::cast_to(func_input_vbox->get_child(i)->get_child(1));
if (lne) {
lne->deselect();
}
}
}
-void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_button, MouseButton p_mouse_button) {
+void VisualScriptEditor::_member_button(Object *p_item, int p_column,
+ int p_button,
+ MouseButton p_mouse_button) {
if (p_mouse_button != MouseButton::LEFT) {
return;
}
@@ -1521,36 +1684,39 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
TreeItem *root = members->get_root();
if (ti->get_parent() == root) {
- //main buttons
+ // main buttons
if (ti == root->get_first_child()) {
// Add function, this one uses menu.
if (p_button == 1) {
// Ensure script base exists otherwise use custom base type.
ERR_FAIL_COND(script.is_null());
- new_virtual_method_select->select_method_from_base_type(script->get_instance_base_type(), true);
+ new_virtual_method_select->select_method_from_base_type(
+ script->get_instance_base_type(), true);
return;
} else if (p_button == 0) {
- String name = _validate_name("new_function");
- selected = name;
+ String new_function_name = _validate_name("new_function");
+ selected = new_function_name;
Vector2 pos = _get_available_pos();
Ref func_node;
func_node.instantiate();
- func_node->set_name(name);
+ func_node->set_name(new_function_name);
int fn_id = script->get_available_id();
undo_redo->create_action(TTR("Add Function"));
- undo_redo->add_do_method(script.ptr(), "add_function", name, fn_id);
- undo_redo->add_do_method(script.ptr(), "add_node", fn_id, func_node, pos);
- undo_redo->add_undo_method(script.ptr(), "remove_function", name);
+ undo_redo->add_do_method(script.ptr(), "add_function", new_function_name, fn_id);
+ undo_redo->add_do_method(script.ptr(), "add_node", fn_id, func_node,
+ pos);
+ undo_redo->add_undo_method(script.ptr(), "remove_function", new_function_name);
undo_redo->add_undo_method(script.ptr(), "remove_node", fn_id);
undo_redo->add_do_method(this, "_update_members");
undo_redo->add_undo_method(this, "_update_members");
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
undo_redo->add_do_method(this, "emit_signal", "edited_script_changed");
- undo_redo->add_undo_method(this, "emit_signal", "edited_script_changed");
+ undo_redo->add_undo_method(this, "emit_signal",
+ "edited_script_changed");
undo_redo->commit_action();
_update_graph();
@@ -1561,12 +1727,12 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
if (ti == root->get_first_child()->get_next()) {
// Add variable.
- String name = _validate_name("new_variable");
- selected = name;
+ String new_variable_name = _validate_name("new_variable");
+ selected = new_variable_name;
undo_redo->create_action(TTR("Add Variable"));
- undo_redo->add_do_method(script.ptr(), "add_variable", name);
- undo_redo->add_undo_method(script.ptr(), "remove_variable", name);
+ undo_redo->add_do_method(script.ptr(), "add_variable", new_variable_name);
+ undo_redo->add_undo_method(script.ptr(), "remove_variable", new_variable_name);
undo_redo->add_do_method(this, "_update_members");
undo_redo->add_undo_method(this, "_update_members");
undo_redo->add_do_method(this, "emit_signal", "edited_script_changed");
@@ -1577,12 +1743,12 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
if (ti == root->get_first_child()->get_next()->get_next()) {
// Add variable.
- String name = _validate_name("new_signal");
- selected = name;
+ String new_signal_name = _validate_name("new_signal");
+ selected = new_signal_name;
undo_redo->create_action(TTR("Add Signal"));
- undo_redo->add_do_method(script.ptr(), "add_custom_signal", name);
- undo_redo->add_undo_method(script.ptr(), "remove_custom_signal", name);
+ undo_redo->add_do_method(script.ptr(), "add_custom_signal", new_signal_name);
+ undo_redo->add_undo_method(script.ptr(), "remove_custom_signal", new_signal_name);
undo_redo->add_do_method(this, "_update_members");
undo_redo->add_undo_method(this, "_update_members");
undo_redo->add_do_method(this, "emit_signal", "edited_script_changed");
@@ -1592,7 +1758,8 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
}
} else if (ti->get_parent() == root->get_first_child()) {
selected = ti->get_text(0);
- function_name_edit->set_position(get_screen_position() + get_local_mouse_position() - Vector2(60, -10));
+ function_name_edit->set_position(
+ get_screen_position() + get_local_mouse_position() - Vector2(60, -10));
function_name_edit->popup();
function_name_box->set_text(selected);
function_name_box->select_all();
@@ -1609,10 +1776,12 @@ void VisualScriptEditor::_add_input_port(int p_id) {
updating_graph = true;
undo_redo->create_action(TTR("Add Input Port"), UndoRedo::MERGE_ENDS);
- undo_redo->add_do_method(vsn.ptr(), "add_input_data_port", Variant::NIL, "arg", -1);
+ undo_redo->add_do_method(vsn.ptr(), "add_input_data_port", Variant::NIL,
+ "arg", -1);
undo_redo->add_do_method(this, "_update_graph", p_id);
- undo_redo->add_undo_method(vsn.ptr(), "remove_input_data_port", vsn->get_input_value_port_count());
+ undo_redo->add_undo_method(vsn.ptr(), "remove_input_data_port",
+ vsn->get_input_value_port_count());
undo_redo->add_undo_method(this, "_update_graph", p_id);
updating_graph = false;
@@ -1629,10 +1798,12 @@ void VisualScriptEditor::_add_output_port(int p_id) {
updating_graph = true;
undo_redo->create_action(TTR("Add Output Port"), UndoRedo::MERGE_ENDS);
- undo_redo->add_do_method(vsn.ptr(), "add_output_data_port", Variant::NIL, "arg", -1);
+ undo_redo->add_do_method(vsn.ptr(), "add_output_data_port", Variant::NIL,
+ "arg", -1);
undo_redo->add_do_method(this, "_update_graph", p_id);
- undo_redo->add_undo_method(vsn.ptr(), "remove_output_data_port", vsn->get_output_value_port_count());
+ undo_redo->add_undo_method(vsn.ptr(), "remove_output_data_port",
+ vsn->get_output_value_port_count());
undo_redo->add_undo_method(this, "_update_graph", p_id);
updating_graph = false;
@@ -1651,20 +1822,26 @@ void VisualScriptEditor::_remove_input_port(int p_id, int p_port) {
undo_redo->create_action(TTR("Remove Input Port"), UndoRedo::MERGE_ENDS);
int conn_from = -1, conn_port = -1;
- script->get_input_value_port_connection_source(p_id, p_port, &conn_from, &conn_port);
+ script->get_input_value_port_connection_source(p_id, p_port, &conn_from,
+ &conn_port);
if (conn_from != -1) {
- undo_redo->add_do_method(script.ptr(), "data_disconnect", conn_from, conn_port, p_id, p_port);
+ undo_redo->add_do_method(script.ptr(), "data_disconnect", conn_from,
+ conn_port, p_id, p_port);
}
undo_redo->add_do_method(vsn.ptr(), "remove_input_data_port", p_port);
undo_redo->add_do_method(this, "_update_graph", p_id);
if (conn_from != -1) {
- undo_redo->add_undo_method(script.ptr(), "data_connect", conn_from, conn_port, p_id, p_port);
+ undo_redo->add_undo_method(script.ptr(), "data_connect", conn_from,
+ conn_port, p_id, p_port);
}
- undo_redo->add_undo_method(vsn.ptr(), "add_input_data_port", vsn->get_input_value_port_info(p_port).type, vsn->get_input_value_port_info(p_port).name, p_port);
+ undo_redo->add_undo_method(vsn.ptr(), "add_input_data_port",
+ vsn->get_input_value_port_info(p_port).type,
+ vsn->get_input_value_port_info(p_port).name,
+ p_port);
undo_redo->add_undo_method(this, "_update_graph", p_id);
updating_graph = false;
@@ -1701,11 +1878,15 @@ void VisualScriptEditor::_remove_output_port(int p_id, int p_port) {
for (const KeyValue> &E : conn_map) {
for (const int &F : E.value) {
- undo_redo->add_undo_method(script.ptr(), "data_connect", p_id, p_port, E.key, F);
+ undo_redo->add_undo_method(script.ptr(), "data_connect", p_id, p_port,
+ E.key, F);
}
}
- undo_redo->add_undo_method(vsn.ptr(), "add_output_data_port", vsn->get_output_value_port_info(p_port).type, vsn->get_output_value_port_info(p_port).name, p_port);
+ undo_redo->add_undo_method(vsn.ptr(), "add_output_data_port",
+ vsn->get_output_value_port_info(p_port).type,
+ vsn->get_output_value_port_info(p_port).name,
+ p_port);
undo_redo->add_undo_method(this, "_update_graph", p_id);
updating_graph = false;
@@ -1713,7 +1894,8 @@ void VisualScriptEditor::_remove_output_port(int p_id, int p_port) {
undo_redo->commit_action();
}
-void VisualScriptEditor::_expression_text_changed(const String &p_text, int p_id) {
+void VisualScriptEditor::_expression_text_changed(const String &p_text,
+ int p_id) {
Ref vse = script->get_node(p_id);
if (!vse.is_valid()) {
return;
@@ -1737,15 +1919,17 @@ void VisualScriptEditor::_expression_text_changed(const String &p_text, int p_id
}
Vector2 VisualScriptEditor::_get_pos_in_graph(Vector2 p_point) const {
- Vector2 pos = (graph->get_scroll_ofs() + p_point) / (graph->get_zoom() * EDSCALE);
- if (graph->is_using_snap()) {
- int snap = graph->get_snap();
+ Vector2 pos =
+ (graph->get_scroll_offset() + p_point) / (graph->get_zoom() * EDSCALE);
+ if (graph->is_snapping_enabled()) {
+ int snap = graph->get_snapping_distance();
pos = pos.snapped(Vector2(snap, snap));
}
return pos;
}
-Vector2 VisualScriptEditor::_get_available_pos(bool p_centered, Vector2 p_pos) const {
+Vector2 VisualScriptEditor::_get_available_pos(bool p_centered,
+ Vector2 p_pos) const {
if (p_centered) {
p_pos = _get_pos_in_graph(graph->get_size() * 0.5);
}
@@ -1757,7 +1941,7 @@ Vector2 VisualScriptEditor::_get_available_pos(bool p_centered, Vector2 p_pos) c
for (int &E : existing) {
Point2 pos = script->get_node_position(E);
if (pos.distance_to(p_pos) < 50) {
- p_pos += Vector2(graph->get_snap(), graph->get_snap());
+ p_pos += Vector2(graph->get_snapping_distance(), graph->get_snapping_distance());
exists = true;
break;
}
@@ -1776,7 +1960,8 @@ String VisualScriptEditor::_validate_name(const String &p_name) const {
int counter = 1;
while (true) {
- bool exists = script->has_function(valid) || script->has_variable(valid) || script->has_custom_signal(valid);
+ bool exists = script->has_function(valid) || script->has_variable(valid) ||
+ script->has_custom_signal(valid);
if (exists) {
counter++;
@@ -1802,7 +1987,8 @@ void VisualScriptEditor::_on_nodes_copy() {
int id = gn->get_name().operator String().to_int();
Ref node = script->get_node(id);
if (Object::cast_to(*node)) {
- EditorNode::get_singleton()->show_warning(TTR("Can't copy the function node."));
+ EditorNode::get_singleton()->show_warning(
+ TTR("Can't copy the function node."));
return;
}
if (node.is_valid()) {
@@ -1874,7 +2060,9 @@ void VisualScriptEditor::_on_nodes_paste() {
Vector2 paste_pos = clipboard->nodes_positions[E.key];
if (first_paste) {
- position_offset = _get_pos_in_graph(mouse_up_position - graph->get_global_position()) - paste_pos;
+ position_offset =
+ _get_pos_in_graph(mouse_up_position - graph->get_global_position()) -
+ paste_pos;
first_paste = false;
}
@@ -1888,14 +2076,22 @@ void VisualScriptEditor::_on_nodes_paste() {
undo_redo->add_undo_method(script.ptr(), "remove_node", new_id);
}
- for (const VisualScript::SequenceConnection &E : clipboard->sequence_connections) {
- undo_redo->add_do_method(script.ptr(), "sequence_connect", remap[E.from_node], E.from_output, remap[E.to_node]);
- undo_redo->add_undo_method(script.ptr(), "sequence_disconnect", remap[E.from_node], E.from_output, remap[E.to_node]);
+ for (const VisualScript::SequenceConnection &E :
+ clipboard->sequence_connections) {
+ undo_redo->add_do_method(script.ptr(), "sequence_connect",
+ remap[E.from_node], E.from_output,
+ remap[E.to_node]);
+ undo_redo->add_undo_method(script.ptr(), "sequence_disconnect",
+ remap[E.from_node], E.from_output,
+ remap[E.to_node]);
}
for (const VisualScript::DataConnection &E : clipboard->data_connections) {
- undo_redo->add_do_method(script.ptr(), "data_connect", remap[E.from_node], E.from_port, remap[E.to_node], E.to_port);
- undo_redo->add_undo_method(script.ptr(), "data_disconnect", remap[E.from_node], E.from_port, remap[E.to_node], E.to_port);
+ undo_redo->add_do_method(script.ptr(), "data_connect", remap[E.from_node],
+ E.from_port, remap[E.to_node], E.to_port);
+ undo_redo->add_undo_method(script.ptr(), "data_disconnect",
+ remap[E.from_node], E.from_port,
+ remap[E.to_node], E.to_port);
}
undo_redo->add_do_method(this, "_update_graph");
@@ -1936,14 +2132,17 @@ void VisualScriptEditor::_on_nodes_delete() {
int cr_node = F;
undo_redo->add_do_method(script.ptr(), "remove_node", cr_node);
- undo_redo->add_undo_method(script.ptr(), "add_node", cr_node, script->get_node(cr_node), script->get_node_position(cr_node));
+ undo_redo->add_undo_method(script.ptr(), "add_node", cr_node,
+ script->get_node(cr_node),
+ script->get_node_position(cr_node));
List sequence_conns;
script->get_sequence_connection_list(&sequence_conns);
for (const VisualScript::SequenceConnection &E : sequence_conns) {
if (E.from_node == cr_node || E.to_node == cr_node) {
- undo_redo->add_undo_method(script.ptr(), "sequence_connect", E.from_node, E.from_output, E.to_node);
+ undo_redo->add_undo_method(script.ptr(), "sequence_connect",
+ E.from_node, E.from_output, E.to_node);
}
}
@@ -1952,7 +2151,8 @@ void VisualScriptEditor::_on_nodes_delete() {
for (const VisualScript::DataConnection &E : data_conns) {
if (E.from_node == F || E.to_node == F) {
- undo_redo->add_undo_method(script.ptr(), "data_connect", E.from_node, E.from_port, E.to_node, E.to_port);
+ undo_redo->add_undo_method(script.ptr(), "data_connect", E.from_node,
+ E.from_port, E.to_node, E.to_port);
}
}
}
@@ -1986,7 +2186,8 @@ void VisualScriptEditor::_on_nodes_duplicate() {
HashMap remap;
for (const int &F : to_duplicate) {
- // Duplicate from the specific function but place it into the default func as it would lack the connections.
+ // Duplicate from the specific function but place it into the default func
+ // as it would lack the connections.
Ref node = script->get_node(F);
Ref dupe = node->duplicate(true);
@@ -1995,7 +2196,8 @@ void VisualScriptEditor::_on_nodes_duplicate() {
remap.insert(F, new_id);
to_select.insert(new_id);
- undo_redo->add_do_method(script.ptr(), "add_node", new_id, dupe, script->get_node_position(F) + Vector2(20, 20));
+ undo_redo->add_do_method(script.ptr(), "add_node", new_id, dupe,
+ script->get_node_position(F) + Vector2(20, 20));
undo_redo->add_undo_method(script.ptr(), "remove_node", new_id);
}
@@ -2003,7 +2205,9 @@ void VisualScriptEditor::_on_nodes_duplicate() {
script->get_sequence_connection_list(&seqs);
for (const VisualScript::SequenceConnection &E : seqs) {
if (to_duplicate.has(E.from_node) && to_duplicate.has(E.to_node)) {
- undo_redo->add_do_method(script.ptr(), "sequence_connect", remap[E.from_node], E.from_output, remap[E.to_node]);
+ undo_redo->add_do_method(script.ptr(), "sequence_connect",
+ remap[E.from_node], E.from_output,
+ remap[E.to_node]);
}
}
@@ -2011,7 +2215,8 @@ void VisualScriptEditor::_on_nodes_duplicate() {
script->get_data_connection_list(&data);
for (const VisualScript::DataConnection &E : data) {
if (to_duplicate.has(E.from_node) && to_duplicate.has(E.to_node)) {
- undo_redo->add_do_method(script.ptr(), "data_connect", remap[E.from_node], E.from_port, remap[E.to_node], E.to_port);
+ undo_redo->add_do_method(script.ptr(), "data_connect", remap[E.from_node],
+ E.from_port, remap[E.to_node], E.to_port);
}
}
@@ -2029,7 +2234,8 @@ void VisualScriptEditor::_on_nodes_duplicate() {
}
if (to_select.size()) {
- EditorNode::get_singleton()->push_item(script->get_node(to_select.front()->get()).ptr());
+ EditorNode::get_singleton()->push_item(
+ script->get_node(to_select.front()->get()).ptr());
}
}
@@ -2037,10 +2243,10 @@ void VisualScriptEditor::_generic_search(Vector2 pos, bool node_centered) {
if (node_centered) {
port_action_pos = graph->get_size() / 2.0f;
} else {
- port_action_pos = graph->get_viewport()->get_mouse_position() - graph->get_global_position();
+ port_action_pos = graph->get_viewport()->get_mouse_position() -
+ graph->get_global_position();
}
-
- new_connect_node_select->select_from_visual_script(script, false); // do not reset text
+ new_connect_node_select->select_from_visual_script(script);
}
void VisualScriptEditor::input(const Ref &p_event) {
@@ -2057,7 +2263,8 @@ void VisualScriptEditor::input(const Ref &p_event) {
void VisualScriptEditor::_graph_gui_input(const Ref &p_event) {
Ref key = p_event;
- if (key.is_valid() && key->is_pressed() && key->get_button_mask() == MouseButton::RIGHT) {
+ if (key.is_valid() && key->is_pressed() &&
+ key->get_button_mask().has_flag(MouseButtonMask::RIGHT)) {
bool is_empty_selection = true;
for (int i = 0; i < graph->get_child_count(); i++) {
@@ -2072,10 +2279,13 @@ void VisualScriptEditor::_graph_gui_input(const Ref &p_event) {
} else {
popup_menu->set_item_disabled(int(EDIT_CUT_NODES), is_empty_selection);
popup_menu->set_item_disabled(int(EDIT_COPY_NODES), is_empty_selection);
- popup_menu->set_item_disabled(int(EDIT_PASTE_NODES), clipboard->nodes.is_empty());
+ popup_menu->set_item_disabled(int(EDIT_PASTE_NODES),
+ clipboard->nodes.is_empty());
popup_menu->set_item_disabled(int(EDIT_DELETE_NODES), is_empty_selection);
- popup_menu->set_item_disabled(int(EDIT_DUPLICATE_NODES), is_empty_selection);
- popup_menu->set_item_disabled(int(EDIT_CLEAR_COPY_BUFFER), clipboard->nodes.is_empty());
+ popup_menu->set_item_disabled(int(EDIT_DUPLICATE_NODES),
+ is_empty_selection);
+ popup_menu->set_item_disabled(int(EDIT_CLEAR_COPY_BUFFER),
+ clipboard->nodes.is_empty());
popup_menu->set_position(mouse_up_position);
popup_menu->popup();
@@ -2096,7 +2306,8 @@ void VisualScriptEditor::_members_gui_input(const Ref &p_event) {
if (ti->get_parent() == root->get_first_child()->get_next()) {
member_type = MEMBER_VARIABLE;
}
- if (ti->get_parent() == root->get_first_child()->get_next()->get_next()) {
+ if (ti->get_parent() ==
+ root->get_first_child()->get_next()->get_next()) {
member_type = MEMBER_SIGNAL;
}
member_name = ti->get_text(0);
@@ -2119,14 +2330,19 @@ void VisualScriptEditor::_members_gui_input(const Ref &p_event) {
}
}
-void VisualScriptEditor::_rename_function(const String &name, const String &new_name) {
+void VisualScriptEditor::_rename_function(const String &name,
+ const String &new_name) {
if (!new_name.is_valid_identifier()) {
- EditorNode::get_singleton()->show_warning(TTR("Name is not a valid identifier:") + " " + new_name);
+ EditorNode::get_singleton()->show_warning(
+ TTR("Name is not a valid identifier:") + " " + new_name);
return;
}
- if (script->has_function(new_name) || script->has_variable(new_name) || script->has_custom_signal(new_name)) {
- EditorNode::get_singleton()->show_warning(TTR("Name already in use by another func/var/signal:") + " " + new_name);
+ if (script->has_function(new_name) || script->has_variable(new_name) ||
+ script->has_custom_signal(new_name)) {
+ EditorNode::get_singleton()->show_warning(
+ TTR("Name already in use by another func/var/signal:") + " " +
+ new_name);
return;
}
@@ -2183,89 +2399,98 @@ void VisualScriptEditor::_on_fn_name_box_confirmed() {
_rename_function(selected, function_name_box->get_text());
}
-Variant VisualScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
- if (p_from == members) {
- TreeItem *it = members->get_item_at_position(p_point);
- if (!it) {
- return Variant();
- }
-
- String type = it->get_metadata(0);
-
- if (type.is_empty()) {
- return Variant();
- }
-
- Dictionary dd;
- TreeItem *root = members->get_root();
-
- if (it->get_parent() == root->get_first_child()) {
- dd["type"] = "visual_script_function_drag";
- dd["function"] = type;
- } else if (it->get_parent() == root->get_first_child()->get_next()) {
- dd["type"] = "visual_script_variable_drag";
- dd["variable"] = type;
- } else if (it->get_parent() == root->get_first_child()->get_next()->get_next()) {
- dd["type"] = "visual_script_signal_drag";
- dd["signal"] = type;
-
- } else {
- return Variant();
- }
-
- Label *label = memnew(Label);
- label->set_text(it->get_text(0));
- set_drag_preview(label);
- return dd;
+Variant VisualScriptEditor::get_drag_data_fw(const Point2 &p_point) {
+ TreeItem *it = members->get_item_at_position(p_point);
+ if (!it) {
+ return Variant();
}
- return Variant();
+
+ String type = it->get_metadata(0);
+
+ if (type.is_empty()) {
+ return Variant();
+ }
+
+ Dictionary dd;
+ TreeItem *root = members->get_root();
+
+ if (it->get_parent() == root->get_first_child()) {
+ dd["type"] = "visual_script_function_drag";
+ dd["function"] = type;
+ } else if (it->get_parent() == root->get_first_child()->get_next()) {
+ dd["type"] = "visual_script_variable_drag";
+ dd["variable"] = type;
+ } else if (it->get_parent() ==
+ root->get_first_child()->get_next()->get_next()) {
+ dd["type"] = "visual_script_signal_drag";
+ dd["signal"] = type;
+
+ } else {
+ return Variant();
+ }
+
+ Label *label = memnew(Label);
+ label->set_text(it->get_text(0));
+ set_drag_preview(label);
+ return dd;
}
-bool VisualScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
- if (p_from == graph) {
- Dictionary d = p_data;
- if (d.has("type") &&
- (String(d["type"]) == "visual_script_node_drag" ||
- String(d["type"]) == "visual_script_function_drag" ||
- String(d["type"]) == "visual_script_variable_drag" ||
- String(d["type"]) == "visual_script_signal_drag" ||
- String(d["type"]) == "obj_property" ||
- String(d["type"]) == "resource" ||
- String(d["type"]) == "files" ||
- String(d["type"]) == "nodes")) {
- if (String(d["type"]) == "obj_property") {
+bool VisualScriptEditor::can_drop_data_fw(const Point2 &p_point,
+ const Variant &p_data) const {
+ Dictionary d = p_data;
+ if (d.has("type") &&
+ (String(d["type"]) == "visual_script_node_drag" ||
+ String(d["type"]) == "visual_script_function_drag" ||
+ String(d["type"]) == "visual_script_variable_drag" ||
+ String(d["type"]) == "visual_script_signal_drag" ||
+ String(d["type"]) == "obj_property" ||
+ String(d["type"]) == "resource" || String(d["type"]) == "files" ||
+ String(d["type"]) == "nodes")) {
+ if (String(d["type"]) == "obj_property") {
#ifdef MACOS_ENABLED
- const_cast(this)->_show_hint(vformat(TTR("Hold %s to drop a Getter. Hold Shift to drop a generic signature."), find_keycode_name(Key::META)));
+ const_cast(this)->_show_hint(
+ vformat(TTR("Hold %s to drop a Getter. Hold Shift to drop a "
+ "generic signature."),
+ find_keycode_name(Key::META)));
#else
- const_cast(this)->_show_hint(TTR("Hold Ctrl to drop a Getter. Hold Shift to drop a generic signature."));
+ const_cast(this)->_show_hint(
+ TTR("Hold Ctrl to drop a Getter. Hold Shift to drop a generic "
+ "signature."));
#endif
- }
-
- if (String(d["type"]) == "nodes") {
-#ifdef MACOS_ENABLED
- const_cast(this)->_show_hint(vformat(TTR("Hold %s to drop a simple reference to the node."), find_keycode_name(Key::META)));
-#else
- const_cast(this)->_show_hint(TTR("Hold Ctrl to drop a simple reference to the node."));
-#endif
- }
-
- if (String(d["type"]) == "visual_script_variable_drag") {
-#ifdef MACOS_ENABLED
- const_cast(this)->_show_hint(vformat(TTR("Hold %s to drop a Variable Setter."), find_keycode_name(Key::META)));
-#else
- const_cast(this)->_show_hint(TTR("Hold Ctrl to drop a Variable Setter."));
-#endif
- }
-
- return true;
}
+
+ if (String(d["type"]) == "nodes") {
+#ifdef MACOS_ENABLED
+ const_cast(this)->_show_hint(
+ vformat(TTR("Hold %s to drop a simple reference to the node."),
+ find_keycode_name(Key::META)));
+#else
+ const_cast(this)->_show_hint(
+ TTR("Hold Ctrl to drop a simple reference to the node."));
+#endif
+ }
+
+ if (String(d["type"]) == "visual_script_variable_drag") {
+#ifdef MACOS_ENABLED
+ const_cast(this)->_show_hint(
+ vformat(TTR("Hold %s to drop a Variable Setter."),
+ find_keycode_name(Key::META)));
+#else
+ const_cast(this)->_show_hint(
+ TTR("Hold Ctrl to drop a Variable Setter."));
+#endif
+ }
+
+ return true;
}
return false;
}
-static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref