diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..ac1becab --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*] +charset = utf-8 + +[*.gd] +indent_style = tab +max_line_length = 200 diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index 73011e50..00000000 --- a/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1,5 +0,0 @@ -blank_issues_enabled: false -contact_links: - - name: Create Internal Task - url: https://phabricator.endlessm.com/tag/baby_godot/ - about: Endless OS Foundation employees, please use this tag on Phabricator diff --git a/.github/ISSUE_TEMPLATE/public.yml b/.github/ISSUE_TEMPLATE/issue.yml similarity index 85% rename from .github/ISSUE_TEMPLATE/public.yml rename to .github/ISSUE_TEMPLATE/issue.yml index 4e749039..d7c86765 100644 --- a/.github/ISSUE_TEMPLATE/public.yml +++ b/.github/ISSUE_TEMPLATE/issue.yml @@ -1,9 +1,9 @@ -name: Report Public Issue +name: Report Issue description: Report an issue with using the Godot Block Coding plugin body: - type: markdown attributes: - value: Thanks for taking the time to report an issue! If you're an employee of Endless OS Foundation, please track internal tasks [on Phabricator](https://phabricator.endlessm.com/tag/baby_godot/) instead. + value: Thanks for taking the time to report an issue! - type: textarea id: what-happened attributes: @@ -20,7 +20,7 @@ body: description: Can it be reliably reproduced, and if so, how? placeholder: | 1. Add a BlockCode child node - 2. Drag blocks X, Y, and Z to the editor + 2. Drag blocks X, Y, and Z to the editor 3. ... validations: required: true diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index f8057221..1ca97690 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -6,12 +6,17 @@ on: branches: - main +# Cancel any ongoing previous run if a PR is updated +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: pre-commit: name: Linting and Formatting runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - uses: actions/setup-python@v5 with: python-version: '3.11' @@ -27,13 +32,15 @@ jobs: name: Tests strategy: matrix: - godot-version: [4.2.2, 4.3.0] + godot-version: + - 4.3.0 + - 4.4.0-dev7 runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Setup Godot - uses: chickensoft-games/setup-godot@v2.1.1 + uses: chickensoft-games/setup-godot@v2.3.0 with: version: ${{ matrix.godot-version }} use-dotnet: false @@ -42,4 +49,4 @@ jobs: godot --path . --headless --import - name: Run tests run: | - godot --path . --headless --script addons/gut/gut_cmdln.gd -gexit + godot --path . --headless -s addons/gut/gut_cmdln.gd -gexit diff --git a/.github/workflows/godot-asset-library.yaml b/.github/workflows/godot-asset-library.yaml index e57363a1..e5941831 100644 --- a/.github/workflows/godot-asset-library.yaml +++ b/.github/workflows/godot-asset-library.yaml @@ -11,7 +11,7 @@ jobs: name: Push new release steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Push to Godot Asset Library uses: deep-entertainment/godot-asset-lib-action@v0.6.0 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f5954e68..0b6a47d2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,17 +2,15 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml - id: check-added-large-files - repo: https://github.com/Scony/godot-gdscript-toolkit - # Use this commit from the master branch until the next stable release with - # - rev: f836958a4487e31e3c5ab35c57c7a2128b7e2303 + rev: 4.3.3 hooks: - id: gdformat args: [--line-length=200] -files: ^(addons/block_code/(?!lib/).*|tests/.*)$ +files: ^(addons/block_code/(?!lib/|locale/).*|tests/.*)$ diff --git a/.tx/config b/.tx/config new file mode 100644 index 00000000..71af3289 --- /dev/null +++ b/.tx/config @@ -0,0 +1,8 @@ +[main] +host = https://www.transifex.com + +[o:endless-os:p:godot-block-coding:r:all] +source_file = addons/block_code/locale/godot_block_coding.pot +source_lang = en +file_filter = addons/block_code/locale/.po +type = PO diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..0818b135 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +tech AT endlessos DOT org. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. diff --git a/addons/block_code/README.md b/addons/block_code/README.md index d349988f..3073ad88 100644 --- a/addons/block_code/README.md +++ b/addons/block_code/README.md @@ -5,13 +5,15 @@ Experimental plugin by [Endless OS Foundation](https://endlessos.org) that intro [![Godot asset](https://img.shields.io/badge/Asset_Library-Block_Coding-blue?logo=godot-engine)](https://godotengine.org/asset-library/asset/3095) [![Latest release](https://img.shields.io/github/v/release/endlessm/godot-block-coding?label=Release&logo=github)](https://github.com/endlessm/godot-block-coding/releases) +[![Youtube video](https://i.ibb.co/B2Y11n5/Bildschirmfoto-20241213-173815.png)](https://www.youtube.com/watch?v=WlUN7Zz0Djg) + ## Background Our aim is to reduce the learning curve faced by learners who are on the early part of their journey towards becoming game developers. Learners within our target audience understand game concepts, but have never used Godot (or any other game engine) before, and do not have programming experience. Ordinarily, such learners are faced with the challenge of learning their way around Godot's powerful, complex editor UI, combined with the additional challenge of learning to code for the first time as they navigate the ins and outs of GDScript. With this project, we aim to reduce the height of the mountain that such learners have to climb. Specifically, we aim to eliminate the requirement of learners having to simultaneously learn to code while building their first games. Instead of writing GDScript to implement games, this plugin enables learners use block coding. Tools like [Scratch](https://scratch.mit.edu/), [Blockly](https://developers.google.com/blockly), and [MakeCode](https://www.microsoft.com/en-us/makecode) have demonstrated that block coding can be much more accessible and intuitive to beginners than textual programming—we are bringing those concepts into Godot to help learners become familiar with some aspects of Godot itself while simplifying the creation of their first games. -In order to be learner-friendly, we implement blocks at a suitable level of abstraction. For example, we have blocks that allow the user to trivially connect keyboard input to the movement of a particular game element, and to make the score show up on-screen. That abstraction does place limits on what can be achieved with this tool, while still allowing us to provide a gentler introduction to Godot for learners, such that they can get familiar with other aspects of the Godot Editor and learn programming concepts while creating basic games. We envision that learners would use block coding as a stepping stone and then later progress onto learning GDScript. +In order to be learner-friendly, we implement blocks at a suitable level of abstraction. For example, we have blocks that allow the user to trivially connect keyboard and gamepad input to the movement of a particular game element, and to make the score show up on-screen. That abstraction does place limits on what can be achieved with this tool, while still allowing us to provide a gentler introduction to Godot for learners, such that they can get familiar with other aspects of the Godot Editor and learn programming concepts while creating basic games. We envision that learners would use block coding as a stepping stone and then later progress onto learning GDScript. That said, we are in no way opposed to having this project grow to be able to create more complex games, as long as it does not negatively affect the experience for early stage learners. @@ -19,7 +21,9 @@ See our [pedagogy and audience documentation](docs/PEDAGOGY.md) for more info. ## Getting Started -1. Install the plugin through the Godot AssetLib searching for the name +1. Make sure you have Godot 4.3 or a newer version installed. + +2. Install the plugin through the Godot AssetLib searching for the name Block Coding. You can also download it from the online [Asset Library](https://godotengine.org/asset-library/asset/3095) and import it through AssetLib. Alternatively, you can clone the git repository and @@ -28,13 +32,9 @@ See our [pedagogy and audience documentation](docs/PEDAGOGY.md) for more info. project, reload the project once after opening it for the first time to resolve any errors. This is a Godot issue.* -2. Make sure to enable the plugin in **Project** → **Project Settings** → **Plugins**. - -3. You're ready to get started! Open a scene, select a node, and observe that there's a **Block Code** section within the lower central pane of the Godot editor, where you usually find debugging, animation and shader functionality. Click **Block Code** and then use the **Add Block Code** button to create a block canvas. +3. Make sure to enable the plugin in **Project** → **Project Settings** → **Plugins**. -4. Drag blocks from the picker and snap them together to create a script. You can switch to other Block Code scripts by selecting the respective node from the scene tree. - -5. **Run** the scene to see your Block Code scripts in action. Block Code scripts are saved within the scene. +You're ready to get started! You can continue reading our [user documentation](docs/USAGE.md). If you clone the plugin's git repository and open it in Godot, you will be presented with a block-built Pong game as an example. @@ -50,21 +50,74 @@ We will now seek feedback from learners, educators and game makers, as well as r There is no language or data format stability implemented or expected in these early stages. If you upgrade the block coding plugin within an existing project, expect any existing block scripts to stop working and need reimplementing from scratch. For now, you probably want to avoid updating the plugin within your project if it's meeting your needs, or only doing that very sporadically. We will consider offering stability guarantees in future stages of development. -## General user guidance - -Block scripts run against the node where you created them. The "Queue Free" block is going to free that node, not any other. - -The selection of available blocks varies based on the node type. For example, create a block script on an `Area2D` and you will notice that you have an `On body entered` signal handling block available. Create a node script on an `AnimationPlayer` node and you will observe blocks for starting and stopping animations. - -If you wish to switch context to another node, you need to define a function in that other node, and then call it. Once execution jumps into that function, blocks will now act against that other node, and you'll have access to type-specific blocks belonging to that other node. You'll need do this kind of thing if you want to trigger the freeing of another node, or trigger an animation to start playing. This is both strong in conveying the concepts of objects and encapsulation, while also a bit tedious - we may revisit in future! - -We have some high level blocks for simplifying common game elements. Add a SimpleCharacter node to get a game element that can be connected to keyboard input with just one type-specific block. Add a SimpleScoring node to display a score on-screen, accompanied by simple blocks for adjusting that score. - -Lean into animations! Godot's animations functionality goes beyond just simple animations of graphics. You can do so much by combining block coding with Godot's powerful animations editor. - -## Feedback - -Please share feedback in the [Godot Forum Block Coding thread](https://forum.godotengine.org/t/block-coding-high-level-block-based-visual-programming/68941). +## Feedback & Discussion + +Please join our [Discussion Board](https://github.com/endlessm/godot-block-coding/discussions) to provide feedback, share ideas, and ask questions about building your games with Block Coding. + +## Localization + +The plugin supports translations through Godot's [gettext][godot-gettext] +support. We welcome contributions to make the plugin work better in your +language! However, please note that translations in the Godot editor **will +only work with Godot 4.4 or newer**. + +The gettext PO files are located in the `addons/block_code/locale` directory. +See the Godot [documentation][godot-gettext] for instructions on working with +PO files. You can also join our project on [Transifex][transifex-project] to +collaborate with others translating the Block Coding content. + +[godot-gettext]: https://docs.godotengine.org/en/stable/tutorials/i18n/localization_using_gettext.html +[transifex-project]: https://explore.transifex.com/endless-os/godot-block-coding/ + +For developers, a few things need to be done to keep the translatable strings +up to date. + +* If files are added or removed, the list of translatable files needs to be + updated. This can be done by using the **Add** dialog in the [POT + Generation][pot-generation] tab. Or you can use the **Project → Tools → + Update BlockCode translated files** menu item in the editor. From the command + line, the POT file can be regenerated with the `scripts/update-pot-files.sh` + shell script. + +* If translatable strings have changed, the POT file needs to be updated. This + can be done by using the **Generate POT** dialog in the [POT + Generation][pot-generation] tab. Or you can use the **Project → Tools → + Regenerate BlockCode POT file** menu item in the editor. From the command + line, the POT file can be regenerated with the `scripts/regenerate-pot.sh` + shell script. + +* If the POT file has changed, the PO message files need to be updated. This + can be done using the gettext `msgmerge` tool with the + `scripts/merge-messages.sh` shell script. + +[pot-generation]: https://docs.godotengine.org/en/stable/tutorials/i18n/localization_using_gettext.html#automatic-generation-using-the-editor + +Strings added in scene files or block definition resources will usually be +extracted for localization and translated in the editor automatically. Strings +in scripts need more consideration. + +* `Object`s or `Node`s that are not descendents of the Block Coding panel need + to have their translation domain set with the `set_block_translation_domain` + helper function. This should usually be done in the object's `_init` method + to make sure the translation domain is set before that object or any of its + descendents (which inherit the translation domain by default) try to use + localized strings. + +* Usually [`tr`][object-tr] and [`tr_n`][object-tr-n] (or [`atr`][node-atr] and + [`atr_n`][node-atr-n] for `Node`s) should be used to mark translatable + strings. These will eventually call the domain's + [`translate`][domain-translate] or + [`translate_plural`][domain-translate-plural] methods, but the `tr` methods + respect translation settings on the object instances. The only time the + `translate` methods should be called directly is within a static context when + an object instance isn't available. + +[object-tr]: https://docs.godotengine.org/en/stable/classes/class_object.html#class-object-method-tr +[object-tr-n]: https://docs.godotengine.org/en/stable/classes/class_object.html#class-object-method-tr-n +[node-atr]: https://docs.godotengine.org/en/stable/classes/class_node.html#class-node-method-atr +[node-atr-n]: https://docs.godotengine.org/en/stable/classes/class_node.html#class-node-method-atr-n +[domain-translate]: https://docs.godotengine.org/en/latest/classes/class_translationdomain.html#class-translationdomain-method-translate +[domain-translate-plural]: https://docs.godotengine.org/en/latest/classes/class_translationdomain.html#class-translationdomain-method-translate-plural ## Development @@ -89,14 +142,19 @@ This plugin uses the [Godot Unit Test](https://gut.readthedocs.io/en/latest/) (G Tests can also be run from the command line using the GUT command line script: ``` -godot --path . --headless --script addons/gut/gut_cmdln.gd -gexit +godot --path . --headless -s addons/gut/gut_cmdln.gd -gexit ``` -A few options are of note here. `--path` instructs Godot to use the project in -the current directory. `--headless` instructs Godot to run without a display or -sound. `--script` instructs Godot to run the GUT command line script instead of -running the main scene. `-gexit` is an option for the GUT command line script -that instructs GUT to exit after the tests complete. +A few options are of note here: + +- `--path` instructs Godot to use the project in the current directory. +- `--headless` instructs Godot to run without a display or sound. +- `-s` instructs Godot to run the GUT command line script instead of + running the main scene. Due to a [bug in + GUT](https://github.com/bitwes/Gut/issues/667), the long form `--script` + cannot be used. +- `-gexit` is an option for the GUT command line script that instructs GUT to + exit after the tests complete. There are several other GUT command line options for running specific tests. For example, `-gtest=path/to/test_script_1.gd,path/to/test_script_2.gd` can be diff --git a/addons/block_code/block_code_node/block_code.gd b/addons/block_code/block_code_node/block_code.gd index 97f81e7d..07e7cdeb 100644 --- a/addons/block_code/block_code_node/block_code.gd +++ b/addons/block_code/block_code_node/block_code.gd @@ -3,7 +3,14 @@ class_name BlockCode extends Node -@export var block_script: BlockScriptSerialization = null +const TxUtils := preload("res://addons/block_code/translation/utils.gd") + +@export var block_script: BlockScriptSerialization = null: + set = _set_block_script + + +func _init(): + TxUtils.set_block_translation_domain(self) func _ready(): @@ -31,6 +38,17 @@ func _enter_tree(): block_script = new_block_script +func _set_block_script(value): + if value == null: + # Wipe out the bidirectional link between this block code node and the + # block script + if block_script: + block_script.block_code_node = null + else: + value.block_code_node = self + block_script = value + + func _update_parent_script(): if Engine.is_editor_hint(): push_error("Updating the parent script must happen in game.") @@ -66,6 +84,10 @@ func _get_configuration_warnings(): warnings.append("A BlockCode must not be a root node.") if get_parent() is BlockCode: warnings.append("The parent must not be a BlockCode.") + if get_parent().script: + var parent_script_name: StringName = get_parent().script.get_global_name() + if not (parent_script_name and block_script and parent_script_name == block_script.script_inherits): + warnings.append("This BlockCode will override the existing script in the parent node.") if get_parent().find_children("*", "BlockCode", false).size() > 1: warnings.append("The parent should only contain one BlockCode.") if block_script and _get_custom_or_native_class(get_parent()) != block_script.script_inherits: diff --git a/addons/block_code/block_code_node/block_code.gd.uid b/addons/block_code/block_code_node/block_code.gd.uid new file mode 100644 index 00000000..f194ab11 --- /dev/null +++ b/addons/block_code/block_code_node/block_code.gd.uid @@ -0,0 +1 @@ +uid://cumxsbxj56dmk diff --git a/addons/block_code/block_code_plugin.gd b/addons/block_code/block_code_plugin.gd index 0067b7f2..ff960f1c 100644 --- a/addons/block_code/block_code_plugin.gd +++ b/addons/block_code/block_code_plugin.gd @@ -4,6 +4,7 @@ extends EditorPlugin const MainPanelScene := preload("res://addons/block_code/ui/main_panel.tscn") const MainPanel = preload("res://addons/block_code/ui/main_panel.gd") const Types = preload("res://addons/block_code/types/types.gd") +const TxUtils := preload("res://addons/block_code/translation/utils.gd") const ScriptWindow := preload("res://addons/block_code/ui/script_window/script_window.tscn") static var main_panel: MainPanel @@ -12,6 +13,9 @@ static var block_code_button: Button const BlockInspectorPlugin := preload("res://addons/block_code/inspector_plugin/block_script_inspector.gd") var block_inspector_plugin: BlockInspectorPlugin +const BlockTranslationParserPlugin := preload("res://addons/block_code/translation/parser.gd") +var _tx_parser_plugin: BlockTranslationParserPlugin + var editor_inspector: EditorInspector var _selected_block_code: BlockCode @@ -29,6 +33,11 @@ const DISABLED_CLASSES := [ ] +func _init(): + TxUtils.load_translations() + TxUtils.set_block_translation_domain(self) + + func _enter_tree(): Types.init_cast_graph() @@ -41,6 +50,14 @@ func _enter_tree(): block_inspector_plugin = BlockInspectorPlugin.new() add_inspector_plugin(block_inspector_plugin) + if not _tx_parser_plugin: + _tx_parser_plugin = BlockTranslationParserPlugin.new() + add_translation_parser_plugin(_tx_parser_plugin) + + # Custom Project->Tools menu items. + add_tool_menu_item(tr("Regenerate %s POT file") % "BlockCode", TxUtils.regenerate_pot_file) + add_tool_menu_item(tr("Update %s translated files") % "BlockCode", TxUtils.update_pot_files) + # Remove unwanted class nodes from create node old_feature_profile = EditorInterface.get_current_feature_profile() @@ -61,9 +78,7 @@ func _enter_tree(): func script_window_requested(script: String): var script_window = ScriptWindow.instantiate() script_window.script_content = script - - EditorInterface.get_base_control().add_child(script_window) - + EditorInterface.popup_dialog(script_window) await script_window.close_requested script_window.queue_free() @@ -71,6 +86,7 @@ func script_window_requested(script: String): func _exit_tree(): + remove_translation_parser_plugin(_tx_parser_plugin) remove_inspector_plugin(block_inspector_plugin) if block_code_button: diff --git a/addons/block_code/block_code_plugin.gd.uid b/addons/block_code/block_code_plugin.gd.uid new file mode 100644 index 00000000..0be7dba6 --- /dev/null +++ b/addons/block_code/block_code_plugin.gd.uid @@ -0,0 +1 @@ +uid://bx7wld2cftncr diff --git a/addons/block_code/blocks/communication/add_node_to_group.tres b/addons/block_code/blocks/communication/add_node_to_group.tres index 2e386d22..00c2bf7f 100644 --- a/addons/block_code/blocks/communication/add_node_to_group.tres +++ b/addons/block_code/blocks/communication/add_node_to_group.tres @@ -1,8 +1,8 @@ [gd_resource type="Resource" load_steps=5 format=3 uid="uid://bpvefei72nh3a"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/block_definition.gd" id="1_5qal7"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/option_data.gd" id="1_auf06"] -[ext_resource type="Script" path="res://addons/block_code/blocks/communication/groups.gd" id="1_p83c7"] +[ext_resource type="Script" uid="uid://bau6qtv87fcdo" path="res://addons/block_code/code_generation/block_definition.gd" id="1_5qal7"] +[ext_resource type="Script" uid="uid://bkapmk0btnk7y" path="res://addons/block_code/code_generation/option_data.gd" id="1_auf06"] +[ext_resource type="Script" uid="uid://cumj4bsraukca" path="res://addons/block_code/blocks/communication/groups.gd" id="1_p83c7"] [sub_resource type="Resource" id="Resource_sus0f"] script = ExtResource("1_auf06") @@ -23,5 +23,5 @@ defaults = { "group": SubResource("Resource_sus0f") } signal_name = "" -scope = "" +is_advanced = false extension_script = ExtResource("1_p83c7") diff --git a/addons/block_code/blocks/communication/add_to_group.tres b/addons/block_code/blocks/communication/add_to_group.tres index 04e14a6f..d5cfc713 100644 --- a/addons/block_code/blocks/communication/add_to_group.tres +++ b/addons/block_code/blocks/communication/add_to_group.tres @@ -1,8 +1,8 @@ [gd_resource type="Resource" load_steps=5 format=3 uid="uid://bvrmau8atjx1x"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/option_data.gd" id="1_aom4j"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/block_definition.gd" id="1_bcm71"] -[ext_resource type="Script" path="res://addons/block_code/blocks/communication/groups.gd" id="2_42ixf"] +[ext_resource type="Script" uid="uid://bkapmk0btnk7y" path="res://addons/block_code/code_generation/option_data.gd" id="1_aom4j"] +[ext_resource type="Script" uid="uid://bau6qtv87fcdo" path="res://addons/block_code/code_generation/block_definition.gd" id="1_bcm71"] +[ext_resource type="Script" uid="uid://cumj4bsraukca" path="res://addons/block_code/blocks/communication/groups.gd" id="2_42ixf"] [sub_resource type="Resource" id="Resource_fk0wa"] script = ExtResource("1_aom4j") @@ -23,5 +23,5 @@ defaults = { "group": SubResource("Resource_fk0wa") } signal_name = "" -scope = "" +is_advanced = false extension_script = ExtResource("2_42ixf") diff --git a/addons/block_code/blocks/communication/area2d_on_entered.tres b/addons/block_code/blocks/communication/area2d_on_entered.tres index 7b358968..66e926cf 100644 --- a/addons/block_code/blocks/communication/area2d_on_entered.tres +++ b/addons/block_code/blocks/communication/area2d_on_entered.tres @@ -11,8 +11,7 @@ category = "Communication | Methods" type = 1 variant_type = 0 display_template = "when this node collides with [something: OBJECT]" -code_template = "func _on_body_entered(something: Node2D): -" +code_template = "func _on_body_entered(something: Node2D):" defaults = {} signal_name = "body_entered" scope = "" diff --git a/addons/block_code/blocks/communication/area2d_on_exited.tres b/addons/block_code/blocks/communication/area2d_on_exited.tres index 7e959b17..1af61a60 100644 --- a/addons/block_code/blocks/communication/area2d_on_exited.tres +++ b/addons/block_code/blocks/communication/area2d_on_exited.tres @@ -11,8 +11,7 @@ category = "Communication | Methods" type = 1 variant_type = 0 display_template = "when this node stops colliding with [something: OBJECT]" -code_template = "func _on_body_exited(something: Node2D): -" +code_template = "func _on_body_exited(something: Node2D):" defaults = {} signal_name = "body_exited" scope = "" diff --git a/addons/block_code/blocks/communication/call_method_group.tres b/addons/block_code/blocks/communication/call_method_group.tres index 06515f55..b0dc5d19 100644 --- a/addons/block_code/blocks/communication/call_method_group.tres +++ b/addons/block_code/blocks/communication/call_method_group.tres @@ -1,8 +1,8 @@ [gd_resource type="Resource" load_steps=5 format=3 uid="uid://c15vtdfihdxb8"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/option_data.gd" id="1_3nuts"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/block_definition.gd" id="1_mlm68"] -[ext_resource type="Script" path="res://addons/block_code/blocks/communication/groups.gd" id="1_of577"] +[ext_resource type="Script" uid="uid://bkapmk0btnk7y" path="res://addons/block_code/code_generation/option_data.gd" id="1_3nuts"] +[ext_resource type="Script" uid="uid://bau6qtv87fcdo" path="res://addons/block_code/code_generation/block_definition.gd" id="1_mlm68"] +[ext_resource type="Script" uid="uid://cumj4bsraukca" path="res://addons/block_code/blocks/communication/groups.gd" id="1_of577"] [sub_resource type="Resource" id="Resource_f4ctg"] script = ExtResource("1_3nuts") @@ -23,5 +23,5 @@ defaults = { "group": SubResource("Resource_f4ctg") } signal_name = "" -scope = "" +is_advanced = false extension_script = ExtResource("1_of577") diff --git a/addons/block_code/blocks/communication/call_method_node.tres b/addons/block_code/blocks/communication/call_method_node.tres index b677cdb4..3937dddb 100644 --- a/addons/block_code/blocks/communication/call_method_node.tres +++ b/addons/block_code/blocks/communication/call_method_node.tres @@ -10,7 +10,7 @@ description = "Calls the method/function of the given node" category = "Communication | Methods" type = 2 variant_type = 0 -display_template = "call method {method_name: STRING} in node {node: OBJECT}" +display_template = "call method {method_name: STRING} on node {node: OBJECT}" code_template = "{node}.call({method_name})" defaults = {} signal_name = "" diff --git a/addons/block_code/blocks/communication/get_node.gd.uid b/addons/block_code/blocks/communication/get_node.gd.uid new file mode 100644 index 00000000..b08b5b23 --- /dev/null +++ b/addons/block_code/blocks/communication/get_node.gd.uid @@ -0,0 +1 @@ +uid://cscfelhxcapk3 diff --git a/addons/block_code/blocks/communication/get_node.tres b/addons/block_code/blocks/communication/get_node.tres index 22f7f5ff..62652213 100644 --- a/addons/block_code/blocks/communication/get_node.tres +++ b/addons/block_code/blocks/communication/get_node.tres @@ -1,8 +1,8 @@ [gd_resource type="Resource" load_steps=5 format=3 uid="uid://canpdkahokjqs"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/option_data.gd" id="1_bk47y"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/block_definition.gd" id="1_d60g7"] -[ext_resource type="Script" path="res://addons/block_code/blocks/communication/get_node.gd" id="1_we5wl"] +[ext_resource type="Script" uid="uid://bkapmk0btnk7y" path="res://addons/block_code/code_generation/option_data.gd" id="1_bk47y"] +[ext_resource type="Script" uid="uid://bau6qtv87fcdo" path="res://addons/block_code/code_generation/block_definition.gd" id="1_d60g7"] +[ext_resource type="Script" uid="uid://cscfelhxcapk3" path="res://addons/block_code/blocks/communication/get_node.gd" id="1_we5wl"] [sub_resource type="Resource" id="Resource_esr4a"] script = ExtResource("1_bk47y") @@ -23,5 +23,5 @@ defaults = { "path": SubResource("Resource_esr4a") } signal_name = "" -scope = "" +is_advanced = false extension_script = ExtResource("1_we5wl") diff --git a/addons/block_code/blocks/communication/groups.gd b/addons/block_code/blocks/communication/groups.gd index 8faf4aa1..c217d71a 100644 --- a/addons/block_code/blocks/communication/groups.gd +++ b/addons/block_code/blocks/communication/groups.gd @@ -3,7 +3,6 @@ extends BlockExtension const OptionData = preload("res://addons/block_code/code_generation/option_data.gd") -const Util = preload("res://addons/block_code/ui/util.gd") # Global groups are just project settings in the global_group group. @@ -58,7 +57,7 @@ func get_defaults() -> Dictionary: return {} # The default groups are only needed in the editor. - if not Util.node_is_part_of_edited_scene(context_node): + if not context_node.is_part_of_edited_scene(): return {} var groups: Array[String] = _get_edited_scene_groups() diff --git a/addons/block_code/blocks/communication/groups.gd.uid b/addons/block_code/blocks/communication/groups.gd.uid new file mode 100644 index 00000000..e39b79d2 --- /dev/null +++ b/addons/block_code/blocks/communication/groups.gd.uid @@ -0,0 +1 @@ +uid://cumj4bsraukca diff --git a/addons/block_code/blocks/communication/is_in_group.tres b/addons/block_code/blocks/communication/is_in_group.tres index afd089d8..f4dd5499 100644 --- a/addons/block_code/blocks/communication/is_in_group.tres +++ b/addons/block_code/blocks/communication/is_in_group.tres @@ -1,8 +1,8 @@ [gd_resource type="Resource" load_steps=5 format=3 uid="uid://q4cnstftvsiu"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/option_data.gd" id="1_cla3i"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/block_definition.gd" id="1_tjyq5"] -[ext_resource type="Script" path="res://addons/block_code/blocks/communication/groups.gd" id="2_o165d"] +[ext_resource type="Script" uid="uid://bkapmk0btnk7y" path="res://addons/block_code/code_generation/option_data.gd" id="1_cla3i"] +[ext_resource type="Script" uid="uid://bau6qtv87fcdo" path="res://addons/block_code/code_generation/block_definition.gd" id="1_tjyq5"] +[ext_resource type="Script" uid="uid://cumj4bsraukca" path="res://addons/block_code/blocks/communication/groups.gd" id="2_o165d"] [sub_resource type="Resource" id="Resource_d0v0d"] script = ExtResource("1_cla3i") @@ -23,5 +23,5 @@ defaults = { "group": SubResource("Resource_d0v0d") } signal_name = "" -scope = "" +is_advanced = false extension_script = ExtResource("2_o165d") diff --git a/addons/block_code/blocks/communication/is_node_in_group.tres b/addons/block_code/blocks/communication/is_node_in_group.tres index d56b3f7e..a10fe700 100644 --- a/addons/block_code/blocks/communication/is_node_in_group.tres +++ b/addons/block_code/blocks/communication/is_node_in_group.tres @@ -1,8 +1,8 @@ [gd_resource type="Resource" load_steps=5 format=3 uid="uid://bbtdxeey74x67"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/block_definition.gd" id="1_5krrs"] -[ext_resource type="Script" path="res://addons/block_code/blocks/communication/groups.gd" id="1_r4prw"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/option_data.gd" id="1_y4j0k"] +[ext_resource type="Script" uid="uid://bau6qtv87fcdo" path="res://addons/block_code/code_generation/block_definition.gd" id="1_5krrs"] +[ext_resource type="Script" uid="uid://cumj4bsraukca" path="res://addons/block_code/blocks/communication/groups.gd" id="1_r4prw"] +[ext_resource type="Script" uid="uid://bkapmk0btnk7y" path="res://addons/block_code/code_generation/option_data.gd" id="1_y4j0k"] [sub_resource type="Resource" id="Resource_o38ym"] script = ExtResource("1_y4j0k") @@ -23,5 +23,5 @@ defaults = { "group": SubResource("Resource_o38ym") } signal_name = "" -scope = "" +is_advanced = false extension_script = ExtResource("1_r4prw") diff --git a/addons/block_code/blocks/communication/remove_from_group.tres b/addons/block_code/blocks/communication/remove_from_group.tres index b25fe8ad..64dd8d3d 100644 --- a/addons/block_code/blocks/communication/remove_from_group.tres +++ b/addons/block_code/blocks/communication/remove_from_group.tres @@ -1,8 +1,8 @@ [gd_resource type="Resource" load_steps=5 format=3 uid="uid://dgenw5wyqorvq"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/block_definition.gd" id="1_cdwef"] -[ext_resource type="Script" path="res://addons/block_code/blocks/communication/groups.gd" id="1_i50fw"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/option_data.gd" id="1_mnxp7"] +[ext_resource type="Script" uid="uid://bau6qtv87fcdo" path="res://addons/block_code/code_generation/block_definition.gd" id="1_cdwef"] +[ext_resource type="Script" uid="uid://cumj4bsraukca" path="res://addons/block_code/blocks/communication/groups.gd" id="1_i50fw"] +[ext_resource type="Script" uid="uid://bkapmk0btnk7y" path="res://addons/block_code/code_generation/option_data.gd" id="1_mnxp7"] [sub_resource type="Resource" id="Resource_45b71"] script = ExtResource("1_mnxp7") @@ -23,5 +23,5 @@ defaults = { "group": SubResource("Resource_45b71") } signal_name = "" -scope = "" +is_advanced = false extension_script = ExtResource("1_i50fw") diff --git a/addons/block_code/blocks/communication/remove_node_from_group.tres b/addons/block_code/blocks/communication/remove_node_from_group.tres index defa9251..afc4a9cf 100644 --- a/addons/block_code/blocks/communication/remove_node_from_group.tres +++ b/addons/block_code/blocks/communication/remove_node_from_group.tres @@ -1,8 +1,8 @@ [gd_resource type="Resource" load_steps=5 format=3 uid="uid://b2dwk77hnri8y"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/option_data.gd" id="1_clwhe"] -[ext_resource type="Script" path="res://addons/block_code/blocks/communication/groups.gd" id="1_h3lhb"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/block_definition.gd" id="1_pec24"] +[ext_resource type="Script" uid="uid://bkapmk0btnk7y" path="res://addons/block_code/code_generation/option_data.gd" id="1_clwhe"] +[ext_resource type="Script" uid="uid://cumj4bsraukca" path="res://addons/block_code/blocks/communication/groups.gd" id="1_h3lhb"] +[ext_resource type="Script" uid="uid://bau6qtv87fcdo" path="res://addons/block_code/code_generation/block_definition.gd" id="1_pec24"] [sub_resource type="Resource" id="Resource_03rge"] script = ExtResource("1_clwhe") @@ -23,5 +23,5 @@ defaults = { "group": SubResource("Resource_03rge") } signal_name = "" -scope = "" +is_advanced = false extension_script = ExtResource("1_h3lhb") diff --git a/addons/block_code/blocks/communication/rigidbody2d_on_entered.tres b/addons/block_code/blocks/communication/rigidbody2d_on_entered.tres index b9859c3c..9ffcfaf6 100644 --- a/addons/block_code/blocks/communication/rigidbody2d_on_entered.tres +++ b/addons/block_code/blocks/communication/rigidbody2d_on_entered.tres @@ -11,8 +11,7 @@ category = "Communication | Methods" type = 1 variant_type = 0 display_template = "when this node collides with [something: OBJECT]" -code_template = "func _on_body_entered(something: Node2D): -" +code_template = "func _on_body_entered(something: Node2D):" defaults = {} signal_name = "body_entered" scope = "" diff --git a/addons/block_code/blocks/communication/rigidbody2d_on_exited.tres b/addons/block_code/blocks/communication/rigidbody2d_on_exited.tres index 7d8cf419..89638d96 100644 --- a/addons/block_code/blocks/communication/rigidbody2d_on_exited.tres +++ b/addons/block_code/blocks/communication/rigidbody2d_on_exited.tres @@ -11,8 +11,7 @@ category = "Communication | Methods" type = 1 variant_type = 0 display_template = "when this node stops colliding with [something: OBJECT]" -code_template = "func _on_body_exited(something: Node2D): -" +code_template = "func _on_body_exited(something: Node2D):" defaults = {} signal_name = "body_exited" scope = "" diff --git a/addons/block_code/blocks/communication/switch_scene.tres b/addons/block_code/blocks/communication/switch_scene.tres new file mode 100644 index 00000000..cf1bfe7e --- /dev/null +++ b/addons/block_code/blocks/communication/switch_scene.tres @@ -0,0 +1,18 @@ +[gd_resource type="Resource" load_steps=2 format=3 uid="uid://dnc2555wnobks"] + +[ext_resource type="Script" path="res://addons/block_code/code_generation/block_definition.gd" id="1_rnqd5"] + +[resource] +script = ExtResource("1_rnqd5") +name = &"switch_scene" +target_node_class = "" +description = "Stop playing the current scene, and switch to a different one. You might use this to switch to a new level." +category = "Communication | Methods" +type = 2 +variant_type = 0 +display_template = "switch the scene to {file_path: STRING}" +code_template = "get_tree().change_scene_to_file({file_path}) +" +defaults = {} +signal_name = "" +scope = "" diff --git a/addons/block_code/blocks/graphics/animationplayer_play.gd.uid b/addons/block_code/blocks/graphics/animationplayer_play.gd.uid new file mode 100644 index 00000000..5b979254 --- /dev/null +++ b/addons/block_code/blocks/graphics/animationplayer_play.gd.uid @@ -0,0 +1 @@ +uid://c38ngxebcyrg6 diff --git a/addons/block_code/blocks/graphics/animationplayer_play.tres b/addons/block_code/blocks/graphics/animationplayer_play.tres index 38149cc1..1f1cfc9d 100644 --- a/addons/block_code/blocks/graphics/animationplayer_play.tres +++ b/addons/block_code/blocks/graphics/animationplayer_play.tres @@ -1,8 +1,8 @@ -[gd_resource type="Resource" load_steps=6 format=3 uid="uid://c5e1byehtxwc0"] +[gd_resource type="Resource" load_steps=7 format=3 uid="uid://c5e1byehtxwc0"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/block_definition.gd" id="1_emeuv"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/option_data.gd" id="1_xu43h"] -[ext_resource type="Script" path="res://addons/block_code/blocks/graphics/animationplayer_play.gd" id="2_7ymgi"] +[ext_resource type="Script" uid="uid://bau6qtv87fcdo" path="res://addons/block_code/code_generation/block_definition.gd" id="1_emeuv"] +[ext_resource type="Script" uid="uid://bkapmk0btnk7y" path="res://addons/block_code/code_generation/option_data.gd" id="1_xu43h"] +[ext_resource type="Script" uid="uid://c38ngxebcyrg6" path="res://addons/block_code/blocks/graphics/animationplayer_play.gd" id="2_7ymgi"] [sub_resource type="Resource" id="Resource_qpxn2"] script = ExtResource("1_xu43h") @@ -14,6 +14,11 @@ script = ExtResource("1_xu43h") selected = 0 items = ["forward", "backwards"] +[sub_resource type="Resource" id="Resource_17pec"] +script = ExtResource("1_xu43h") +selected = 0 +items = ["until done", "in the background"] + [resource] script = ExtResource("1_emeuv") name = &"animationplayer_play" @@ -22,16 +27,19 @@ description = "Play the animation." category = "Graphics | Animation" type = 2 variant_type = 0 -display_template = "play {animation: STRING} {direction: NIL}" +display_template = "play {animation: STRING} | {direction: NIL} {wait_mode: NIL}" code_template = "if {direction} == \"forward\": play({animation}) else: play_backwards({animation}) +if {wait_mode} == \"until done\": + await animation_finished " defaults = { "animation": SubResource("Resource_qpxn2"), -"direction": SubResource("Resource_vnp2w") +"direction": SubResource("Resource_vnp2w"), +"wait_mode": SubResource("Resource_17pec") } signal_name = "" -scope = "" +is_advanced = false extension_script = ExtResource("2_7ymgi") diff --git a/addons/block_code/blocks/input/is_input_actioned.gd.uid b/addons/block_code/blocks/input/is_input_actioned.gd.uid new file mode 100644 index 00000000..406cdc00 --- /dev/null +++ b/addons/block_code/blocks/input/is_input_actioned.gd.uid @@ -0,0 +1 @@ +uid://cg3sepbbe45ey diff --git a/addons/block_code/blocks/input/is_input_actioned.tres b/addons/block_code/blocks/input/is_input_actioned.tres index 5f7545f3..7acfc62e 100644 --- a/addons/block_code/blocks/input/is_input_actioned.tres +++ b/addons/block_code/blocks/input/is_input_actioned.tres @@ -1,8 +1,8 @@ [gd_resource type="Resource" load_steps=5 format=3 uid="uid://86j17le5e58u"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/option_data.gd" id="1_d8i05"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/block_definition.gd" id="1_rprh7"] -[ext_resource type="Script" path="res://addons/block_code/blocks/input/is_input_actioned.gd" id="2_h11b7"] +[ext_resource type="Script" uid="uid://bkapmk0btnk7y" path="res://addons/block_code/code_generation/option_data.gd" id="1_d8i05"] +[ext_resource type="Script" uid="uid://bau6qtv87fcdo" path="res://addons/block_code/code_generation/block_definition.gd" id="1_rprh7"] +[ext_resource type="Script" uid="uid://cg3sepbbe45ey" path="res://addons/block_code/blocks/input/is_input_actioned.gd" id="2_h11b7"] [sub_resource type="Resource" id="Resource_ai5in"] script = ExtResource("1_d8i05") @@ -23,5 +23,5 @@ defaults = { "action": SubResource("Resource_ai5in") } signal_name = "" -scope = "" +is_advanced = false extension_script = ExtResource("2_h11b7") diff --git a/addons/block_code/blocks/input/mouse_position.tres b/addons/block_code/blocks/input/mouse_position.tres new file mode 100644 index 00000000..39fb46ee --- /dev/null +++ b/addons/block_code/blocks/input/mouse_position.tres @@ -0,0 +1,17 @@ +[gd_resource type="Resource" load_steps=2 format=3 uid="uid://dwrdne76nxk7t"] + +[ext_resource type="Script" path="res://addons/block_code/code_generation/block_definition.gd" id="1_7vl3n"] + +[resource] +script = ExtResource("1_7vl3n") +name = &"mouse_position" +target_node_class = "CanvasItem" +description = "The coordinates of the mouse position." +category = "Input" +type = 3 +variant_type = 5 +display_template = "mouse position" +code_template = "get_global_mouse_position()" +defaults = {} +signal_name = "" +is_advanced = false diff --git a/addons/block_code/blocks/lifecycle/physics_process.tres b/addons/block_code/blocks/lifecycle/physics_process.tres new file mode 100644 index 00000000..315c4b55 --- /dev/null +++ b/addons/block_code/blocks/lifecycle/physics_process.tres @@ -0,0 +1,18 @@ +[gd_resource type="Resource" load_steps=2 format=3 uid="uid://3l8wefwlme2v"] + +[ext_resource type="Script" path="res://addons/block_code/code_generation/block_definition.gd" id="1_pmina"] + +[resource] +script = ExtResource("1_pmina") +name = &"physics_process" +target_node_class = "" +description = "Attached blocks will be executed before each physics step" +category = "Lifecycle" +type = 1 +variant_type = 0 +display_template = "every physics step" +code_template = "func _physics_process(delta):" +defaults = {} +signal_name = "" +scope = "" +is_advanced = true diff --git a/addons/block_code/blocks/lifecycle/queue_free_node.tres b/addons/block_code/blocks/lifecycle/queue_free_node.tres new file mode 100644 index 00000000..4c393087 --- /dev/null +++ b/addons/block_code/blocks/lifecycle/queue_free_node.tres @@ -0,0 +1,17 @@ +[gd_resource type="Resource" load_steps=2 format=3 uid="uid://d31lkxkm5lww7"] + +[ext_resource type="Script" path="res://addons/block_code/code_generation/block_definition.gd" id="1_75fle"] + +[resource] +script = ExtResource("1_75fle") +name = &"queue_free_node" +target_node_class = "" +description = "Queues the given node to be deleted at the end of the current frame" +category = "Lifecycle" +type = 2 +variant_type = 0 +display_template = "remove {node: OBJECT}" +code_template = "{node}.queue_free()" +defaults = {} +signal_name = "" +scope = "" diff --git a/addons/block_code/blocks/log/to_string.tres b/addons/block_code/blocks/log/to_string.tres new file mode 100644 index 00000000..73931305 --- /dev/null +++ b/addons/block_code/blocks/log/to_string.tres @@ -0,0 +1,25 @@ +[gd_resource type="Resource" load_steps=4 format=3 uid="uid://bfugvntm6mdjm"] + +[ext_resource type="Script" uid="uid://bkapmk0btnk7y" path="res://addons/block_code/code_generation/option_data.gd" id="1_i1nej"] +[ext_resource type="Script" uid="uid://bau6qtv87fcdo" path="res://addons/block_code/code_generation/block_definition.gd" id="2_xs7a8"] + +[sub_resource type="Resource" id="Resource_ie4sg"] +script = ExtResource("1_i1nej") +selected = 0 +items = ["0", "true", "Vector2(0, 0)", "Vector3(0, 0, 0)", "Color(0, 0, 0, 1)", "Object(Object, \"script\": null)"] + +[resource] +script = ExtResource("2_xs7a8") +name = &"to_string" +target_node_class = "" +description = "Converts [i]parameter[/i] to a [b]String[/b]" +category = "Log" +type = 3 +variant_type = 4 +display_template = "{parameter: NIL} to string" +code_template = "str({{parameter}})" +defaults = { +"parameter": SubResource("Resource_ie4sg") +} +signal_name = "" +is_advanced = true diff --git a/addons/block_code/blocks/logic/compare.tres b/addons/block_code/blocks/logic/compare.tres index d4b4dc4f..5fbeb31c 100644 --- a/addons/block_code/blocks/logic/compare.tres +++ b/addons/block_code/blocks/logic/compare.tres @@ -1,7 +1,7 @@ [gd_resource type="Resource" load_steps=4 format=3 uid="uid://pr5wnn3ltkbo"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/option_data.gd" id="1_hcv2h"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/block_definition.gd" id="1_wp40r"] +[ext_resource type="Script" uid="uid://bkapmk0btnk7y" path="res://addons/block_code/code_generation/option_data.gd" id="1_hcv2h"] +[ext_resource type="Script" uid="uid://bau6qtv87fcdo" path="res://addons/block_code/code_generation/block_definition.gd" id="1_wp40r"] [sub_resource type="Resource" id="Resource_ie4sg"] script = ExtResource("1_hcv2h") @@ -24,4 +24,4 @@ defaults = { "op": SubResource("Resource_ie4sg") } signal_name = "" -scope = "" +is_advanced = false diff --git a/addons/block_code/blocks/math/vector2_xy.tres b/addons/block_code/blocks/math/vector2_xy.tres new file mode 100644 index 00000000..32846064 --- /dev/null +++ b/addons/block_code/blocks/math/vector2_xy.tres @@ -0,0 +1,25 @@ +[gd_resource type="Resource" load_steps=4 format=3 uid="uid://bpdjqy6oidfo4"] + +[ext_resource type="Script" uid="uid://bkapmk0btnk7y" path="res://addons/block_code/code_generation/option_data.gd" id="1_p8v57"] +[ext_resource type="Script" uid="uid://bau6qtv87fcdo" path="res://addons/block_code/code_generation/block_definition.gd" id="2_207xo"] + +[sub_resource type="Resource" id="Resource_ie4sg"] +script = ExtResource("1_p8v57") +selected = 0 +items = ["x", "y"] + +[resource] +script = ExtResource("2_207xo") +name = &"vector2_xy" +target_node_class = "" +description = "Gives the x or y of a [b]Vector2[/b]" +category = "Math" +type = 3 +variant_type = 3 +display_template = "{xy: NIL} of {vector2: VECTOR2}" +code_template = "{vector2}.{{xy}}" +defaults = { +"xy": SubResource("Resource_ie4sg") +} +signal_name = "" +is_advanced = false diff --git a/addons/block_code/blocks/math/vector3_multiply.tres b/addons/block_code/blocks/math/vector3_multiply.tres new file mode 100644 index 00000000..65b8ff55 --- /dev/null +++ b/addons/block_code/blocks/math/vector3_multiply.tres @@ -0,0 +1,20 @@ +[gd_resource type="Resource" load_steps=2 format=3 uid="uid://ctl30ew7wtnlj"] + +[ext_resource type="Script" uid="uid://bau6qtv87fcdo" path="res://addons/block_code/code_generation/block_definition.gd" id="1_bxnpg"] + +[resource] +script = ExtResource("1_bxnpg") +name = &"vector3_multiply" +target_node_class = "" +description = "Multiplies a Vector3 with a number. Use this, for example, to get a point some distance away along an angle." +category = "Math" +type = 3 +variant_type = 9 +display_template = "multiply {vector: VECTOR3} by {number: FLOAT}" +code_template = "{vector} * {number}" +defaults = { +"number": 1.0, +"vector": Vector3(1, 1, 1) +} +signal_name = "" +is_advanced = false diff --git a/addons/block_code/blocks/math/vector3_xyz.tres b/addons/block_code/blocks/math/vector3_xyz.tres new file mode 100644 index 00000000..01374a87 --- /dev/null +++ b/addons/block_code/blocks/math/vector3_xyz.tres @@ -0,0 +1,25 @@ +[gd_resource type="Resource" load_steps=4 format=3 uid="uid://s72tgtbci1ui"] + +[ext_resource type="Script" uid="uid://bkapmk0btnk7y" path="res://addons/block_code/code_generation/option_data.gd" id="1_0wc0o"] +[ext_resource type="Script" uid="uid://bau6qtv87fcdo" path="res://addons/block_code/code_generation/block_definition.gd" id="2_e6ohf"] + +[sub_resource type="Resource" id="Resource_ie4sg"] +script = ExtResource("1_0wc0o") +selected = 0 +items = ["x", "y", "z"] + +[resource] +script = ExtResource("2_e6ohf") +name = &"vector3_xyz" +target_node_class = "" +description = "Gives the x, y, or z of a [b]Vector3[/b]" +category = "Math" +type = 3 +variant_type = 3 +display_template = "{xyz: NIL} of {vector3: VECTOR3}" +code_template = "{vector3}.{{xyz}}" +defaults = { +"xyz": SubResource("Resource_ie4sg") +} +signal_name = "" +is_advanced = false diff --git a/addons/block_code/blocks/math/vector_from_angle.tres b/addons/block_code/blocks/math/vector_from_angle.tres new file mode 100644 index 00000000..fce91df3 --- /dev/null +++ b/addons/block_code/blocks/math/vector_from_angle.tres @@ -0,0 +1,17 @@ +[gd_resource type="Resource" load_steps=2 format=3 uid="uid://c7a6wnxegkfd5"] + +[ext_resource type="Script" path="res://addons/block_code/code_generation/block_definition.gd" id="1_1p1ve"] + +[resource] +script = ExtResource("1_1p1ve") +name = &"from_angle" +target_node_class = "" +description = "Creates a unit Vector2 rotated to the given angle in radians." +category = "Math" +type = 3 +variant_type = 5 +display_template = "vector from {angle: FLOAT}" +code_template = "Vector2.from_angle({angle})" +defaults = {} +signal_name = "" +scope = "" diff --git a/addons/block_code/blocks/math/vector_multiply.tres b/addons/block_code/blocks/math/vector_multiply.tres new file mode 100644 index 00000000..8c82607d --- /dev/null +++ b/addons/block_code/blocks/math/vector_multiply.tres @@ -0,0 +1,20 @@ +[gd_resource type="Resource" load_steps=2 format=3 uid="uid://bff7cwmpisihj"] + +[ext_resource type="Script" path="res://addons/block_code/code_generation/block_definition.gd" id="1_52jwf"] + +[resource] +script = ExtResource("1_52jwf") +name = &"vector_multiply" +target_node_class = "" +description = "Multiplies a vector with a number. Use this, for example, to get a point some distance away along an angle." +category = "Math" +type = 3 +variant_type = 5 +display_template = "multiply {vector: VECTOR2} by {number: FLOAT}" +code_template = "{vector} * {number}" +defaults = { +"number": 1.0, +"vector": Vector2(1, 1) +} +signal_name = "" +scope = "" diff --git a/addons/block_code/blocks/sounds/pause_continue_sound.tres b/addons/block_code/blocks/sounds/pause_continue_sound.tres index 17487bbc..946c5b94 100644 --- a/addons/block_code/blocks/sounds/pause_continue_sound.tres +++ b/addons/block_code/blocks/sounds/pause_continue_sound.tres @@ -1,7 +1,7 @@ [gd_resource type="Resource" load_steps=4 format=3 uid="uid://wpdspamg3f6g"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/option_data.gd" id="1_ilhdq"] -[ext_resource type="Script" path="res://addons/block_code/code_generation/block_definition.gd" id="1_q04gm"] +[ext_resource type="Script" uid="uid://bkapmk0btnk7y" path="res://addons/block_code/code_generation/option_data.gd" id="1_ilhdq"] +[ext_resource type="Script" uid="uid://bau6qtv87fcdo" path="res://addons/block_code/code_generation/block_definition.gd" id="1_q04gm"] [sub_resource type="Resource" id="Resource_lalgp"] script = ExtResource("1_ilhdq") @@ -27,4 +27,4 @@ defaults = { "pause": SubResource("Resource_lalgp") } signal_name = "" -scope = "" +is_advanced = false diff --git a/addons/block_code/blocks/sounds/play_sound.tres b/addons/block_code/blocks/sounds/play_sound.tres index 72840769..06d6a34a 100644 --- a/addons/block_code/blocks/sounds/play_sound.tres +++ b/addons/block_code/blocks/sounds/play_sound.tres @@ -10,7 +10,7 @@ description = "Play the audio stream with volume and pitch" category = "Sounds" type = 2 variant_type = 0 -display_template = "play the sound {name: STRING} with volume {db: FLOAT} dB and pitch scale {pitch: FLOAT}" +display_template = "play the sound {name: STRING} | with volume {db: FLOAT} dB and pitch scale {pitch: FLOAT}" code_template = "var __sound_node = get_node({name}) __sound_node.volume_db = {db} __sound_node.pitch_scale = {pitch} diff --git a/addons/block_code/blocks/spawn/cpuparticles2d_finished.tres b/addons/block_code/blocks/spawn/cpuparticles2d_finished.tres new file mode 100644 index 00000000..7758be63 --- /dev/null +++ b/addons/block_code/blocks/spawn/cpuparticles2d_finished.tres @@ -0,0 +1,17 @@ +[gd_resource type="Resource" load_steps=2 format=3 uid="uid://c188gpgf4rpns"] + +[ext_resource type="Script" path="res://addons/block_code/code_generation/block_definition.gd" id="1_pmpup"] + +[resource] +script = ExtResource("1_pmpup") +name = &"cpuparticles2d_finished" +target_node_class = "CPUParticles2D" +description = "Emitted when all active particles have finished processing." +category = "Lifecycle | Spawn" +type = 1 +variant_type = 0 +display_template = "when particles are finished" +code_template = "func _on_finished():" +defaults = {} +signal_name = "finished" +scope = "" diff --git a/addons/block_code/blocks/ui/label_set_text.tres b/addons/block_code/blocks/ui/label_set_text.tres new file mode 100644 index 00000000..1a4f82ca --- /dev/null +++ b/addons/block_code/blocks/ui/label_set_text.tres @@ -0,0 +1,17 @@ +[gd_resource type="Resource" load_steps=2 format=3 uid="uid://ciqkywxdk4uht"] + +[ext_resource type="Script" path="res://addons/block_code/code_generation/block_definition.gd" id="1_bofov"] + +[resource] +script = ExtResource("1_bofov") +name = &"label_set_text" +target_node_class = "Label" +description = "Set the text for the label." +category = "UI" +type = 2 +variant_type = 0 +display_template = "set text to {text: STRING}" +code_template = "text = {text}" +defaults = {} +signal_name = "" +scope = "" diff --git a/addons/block_code/blocks/variables/vector3.tres b/addons/block_code/blocks/variables/vector3.tres new file mode 100644 index 00000000..a4633e61 --- /dev/null +++ b/addons/block_code/blocks/variables/vector3.tres @@ -0,0 +1,21 @@ +[gd_resource type="Resource" load_steps=2 format=3 uid="uid://ydahicas0yma"] + +[ext_resource type="Script" uid="uid://bau6qtv87fcdo" path="res://addons/block_code/code_generation/block_definition.gd" id="1_62jin"] + +[resource] +script = ExtResource("1_62jin") +name = &"vector3" +target_node_class = "" +description = "" +category = "Math" +type = 3 +variant_type = 9 +display_template = "vector3 x: {x: FLOAT} y: {y: FLOAT}: z: {z: FLOAT}" +code_template = "Vector3({x}, {y}, {z})" +defaults = { +"x": 0.0, +"y": 0.0, +"z": 0.0 +} +signal_name = "" +is_advanced = false diff --git a/addons/block_code/code_generation/ast_list.gd.uid b/addons/block_code/code_generation/ast_list.gd.uid new file mode 100644 index 00000000..cda02b1d --- /dev/null +++ b/addons/block_code/code_generation/ast_list.gd.uid @@ -0,0 +1 @@ +uid://b052nx55audtf diff --git a/addons/block_code/code_generation/block_ast.gd b/addons/block_code/code_generation/block_ast.gd index a90657e2..865e3047 100644 --- a/addons/block_code/code_generation/block_ast.gd +++ b/addons/block_code/code_generation/block_ast.gd @@ -131,6 +131,8 @@ static func raw_input_to_code_string(input) -> String: return "'%s'" % input.c_escape() TYPE_VECTOR2: return "Vector2%s" % str(input) + TYPE_VECTOR3: + return "Vector3%s" % str(input) TYPE_COLOR: return "Color%s" % str(input) _: diff --git a/addons/block_code/code_generation/block_ast.gd.uid b/addons/block_code/code_generation/block_ast.gd.uid new file mode 100644 index 00000000..776c8b97 --- /dev/null +++ b/addons/block_code/code_generation/block_ast.gd.uid @@ -0,0 +1 @@ +uid://ds7sl2qhnam75 diff --git a/addons/block_code/code_generation/block_definition.gd b/addons/block_code/code_generation/block_definition.gd index 26ac9e70..75273a73 100644 --- a/addons/block_code/code_generation/block_definition.gd +++ b/addons/block_code/code_generation/block_definition.gd @@ -2,8 +2,17 @@ extends Resource const Types = preload("res://addons/block_code/types/types.gd") - -const FORMAT_STRING_PATTERN = "\\[(?[^\\]]+)\\]|\\{(?[^}]+)\\}|(?