From 51c0f3abb864eaeda8984749cdab3f3ab2e3fbfe Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Tue, 24 Mar 2020 03:46:15 -0400 Subject: [PATCH 1/2] Refactor the plugin demos to be inside of a project for convenience --- plugins/README.md | 32 +++++++++++++++-- plugins/addons/README.md | 12 +++++++ plugins/{ => addons}/custom_node/README.md | 0 plugins/{ => addons}/custom_node/heart.gd | 0 plugins/{ => addons}/custom_node/heart.png | Bin .../{ => addons}/custom_node/heart.png.import | 0 .../{ => addons}/custom_node/heart_icon.png | Bin .../custom_node/heart_icon.png.import | 0 .../{ => addons}/custom_node/heart_plugin.gd | 0 plugins/{ => addons}/custom_node/plugin.cfg | 0 plugins/addons/material_creator/README.md | 20 +++++++++++ .../material_creator/material_creator.gd | 0 .../material_creator/material_dock.tscn | 0 .../material_creator/material_plugin.gd | 0 .../material_creator/material_resource.gd | 0 .../{ => addons}/material_creator/plugin.cfg | 0 .../addons/material_import_plugin/README.md | 9 +++++ .../material_import_plugin/import.gd | 0 .../material_import_plugin/plugin.cfg | 0 .../material_import_plugin/plugin.gd | 0 .../material_import_plugin/test.mtxt | 0 .../material_import_plugin/test.mtxt.import | 0 plugins/custom_node_test.tscn | 15 ++++++++ plugins/default_env.tres | 7 ++++ plugins/icon.png | Bin 0 -> 3305 bytes plugins/icon.png.import | 34 ++++++++++++++++++ plugins/material_creator/README.md | 13 ------- plugins/material_import_plugin/README.md | 6 ---- plugins/project.godot | 32 +++++++++++++++++ 29 files changed, 158 insertions(+), 22 deletions(-) create mode 100644 plugins/addons/README.md rename plugins/{ => addons}/custom_node/README.md (100%) rename plugins/{ => addons}/custom_node/heart.gd (100%) rename plugins/{ => addons}/custom_node/heart.png (100%) rename plugins/{ => addons}/custom_node/heart.png.import (100%) rename plugins/{ => addons}/custom_node/heart_icon.png (100%) rename plugins/{ => addons}/custom_node/heart_icon.png.import (100%) rename plugins/{ => addons}/custom_node/heart_plugin.gd (100%) rename plugins/{ => addons}/custom_node/plugin.cfg (100%) create mode 100644 plugins/addons/material_creator/README.md rename plugins/{ => addons}/material_creator/material_creator.gd (100%) rename plugins/{ => addons}/material_creator/material_dock.tscn (100%) rename plugins/{ => addons}/material_creator/material_plugin.gd (100%) rename plugins/{ => addons}/material_creator/material_resource.gd (100%) rename plugins/{ => addons}/material_creator/plugin.cfg (100%) create mode 100644 plugins/addons/material_import_plugin/README.md rename plugins/{ => addons}/material_import_plugin/import.gd (100%) rename plugins/{ => addons}/material_import_plugin/plugin.cfg (100%) rename plugins/{ => addons}/material_import_plugin/plugin.gd (100%) rename plugins/{ => addons}/material_import_plugin/test.mtxt (100%) rename plugins/{ => addons}/material_import_plugin/test.mtxt.import (100%) create mode 100644 plugins/custom_node_test.tscn create mode 100644 plugins/default_env.tres create mode 100644 plugins/icon.png create mode 100644 plugins/icon.png.import delete mode 100644 plugins/material_creator/README.md delete mode 100644 plugins/material_import_plugin/README.md create mode 100644 plugins/project.godot diff --git a/plugins/README.md b/plugins/README.md index 2b8de36dc8..0e07ad8bbf 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -1,9 +1,35 @@ -# Plugin demos +# Plugin Demos -To use these plugins, copy any of these folders to the `addons/` folder in a Godot project. +This contains multiple plugin demos, all placed in a project for convenience. + +Please see the documentation for editor plugins: +https://docs.godotengine.org/en/latest/tutorials/plugins/editor/index.html + +Language: GDScript + +Renderer: GLES 2 + +# How does it work? + +This project contains 3 plugins: + +* The custom node plugin shows how to create a custom node type + using `add_custom_type`. [More info](addons/custom_node). + +* The material import plugin shows how to make a plugin handle importing + a custom file type (mtxt). [More info](addons/material_import_plugin). + +* The material creator plugin shows how to add a custom dock with some + simple functionality. [More info](addons/material_creator). + +To use these plugins in another project, copy any of these +folders to the `addons/` folder in a Godot project, and then +enable them in the project settings menu. For example, the path would look like: `addons/custom_node` -Plugins can be distributed and installed from the UI. If you make a zip that contains the folder, Godot will recognize it as a plugin and will allow you to install it. +Plugins can be distributed and installed from the UI. +If you make a zip that contains the folder, Godot will recognize +it as a plugin and will allow you to install it. This can be done via the terminal: `zip -r custom_node.zip custom_node/*` diff --git a/plugins/addons/README.md b/plugins/addons/README.md new file mode 100644 index 0000000000..dbc4d3eda4 --- /dev/null +++ b/plugins/addons/README.md @@ -0,0 +1,12 @@ +# How to use + +To use these plugins in another project, copy any of these +folders to the `addons/` folder in a Godot project. + +For example, the path would look like: `addons/custom_node` + +Plugins can be distributed and installed from the UI. +If you make a zip that contains the folder, Godot will recognize +it as a plugin and will allow you to install it. + +This can be done via the terminal: `zip -r custom_node.zip custom_node/*` diff --git a/plugins/custom_node/README.md b/plugins/addons/custom_node/README.md similarity index 100% rename from plugins/custom_node/README.md rename to plugins/addons/custom_node/README.md diff --git a/plugins/custom_node/heart.gd b/plugins/addons/custom_node/heart.gd similarity index 100% rename from plugins/custom_node/heart.gd rename to plugins/addons/custom_node/heart.gd diff --git a/plugins/custom_node/heart.png b/plugins/addons/custom_node/heart.png similarity index 100% rename from plugins/custom_node/heart.png rename to plugins/addons/custom_node/heart.png diff --git a/plugins/custom_node/heart.png.import b/plugins/addons/custom_node/heart.png.import similarity index 100% rename from plugins/custom_node/heart.png.import rename to plugins/addons/custom_node/heart.png.import diff --git a/plugins/custom_node/heart_icon.png b/plugins/addons/custom_node/heart_icon.png similarity index 100% rename from plugins/custom_node/heart_icon.png rename to plugins/addons/custom_node/heart_icon.png diff --git a/plugins/custom_node/heart_icon.png.import b/plugins/addons/custom_node/heart_icon.png.import similarity index 100% rename from plugins/custom_node/heart_icon.png.import rename to plugins/addons/custom_node/heart_icon.png.import diff --git a/plugins/custom_node/heart_plugin.gd b/plugins/addons/custom_node/heart_plugin.gd similarity index 100% rename from plugins/custom_node/heart_plugin.gd rename to plugins/addons/custom_node/heart_plugin.gd diff --git a/plugins/custom_node/plugin.cfg b/plugins/addons/custom_node/plugin.cfg similarity index 100% rename from plugins/custom_node/plugin.cfg rename to plugins/addons/custom_node/plugin.cfg diff --git a/plugins/addons/material_creator/README.md b/plugins/addons/material_creator/README.md new file mode 100644 index 0000000000..147fbca783 --- /dev/null +++ b/plugins/addons/material_creator/README.md @@ -0,0 +1,20 @@ +# Material Creator Plugin Demo + +This plugin demo contains a custom material creator +interface using a custom dock in the editor. + +Custom docks are made of Control nodes, they run in the +editor, and any behavior must be done through `tool` scripts. +For more information, see this documentation article: +https://docs.godotengine.org/en/latest/tutorials/plugins/editor/making_plugins.html#a-custom-dock + +This plugin allows you to specify color, metallic, and +roughness values, and then use it as a material. + +You can apply this material directly to Spatial +nodes by selecting them and then clicking "Apply". +This shows how a plugin can interact closely with the +editor, manipulating nodes the user selects. + +Alternatively, you can also save the material to +a file, and then load it back into the plugin later. diff --git a/plugins/material_creator/material_creator.gd b/plugins/addons/material_creator/material_creator.gd similarity index 100% rename from plugins/material_creator/material_creator.gd rename to plugins/addons/material_creator/material_creator.gd diff --git a/plugins/material_creator/material_dock.tscn b/plugins/addons/material_creator/material_dock.tscn similarity index 100% rename from plugins/material_creator/material_dock.tscn rename to plugins/addons/material_creator/material_dock.tscn diff --git a/plugins/material_creator/material_plugin.gd b/plugins/addons/material_creator/material_plugin.gd similarity index 100% rename from plugins/material_creator/material_plugin.gd rename to plugins/addons/material_creator/material_plugin.gd diff --git a/plugins/material_creator/material_resource.gd b/plugins/addons/material_creator/material_resource.gd similarity index 100% rename from plugins/material_creator/material_resource.gd rename to plugins/addons/material_creator/material_resource.gd diff --git a/plugins/material_creator/plugin.cfg b/plugins/addons/material_creator/plugin.cfg similarity index 100% rename from plugins/material_creator/plugin.cfg rename to plugins/addons/material_creator/plugin.cfg diff --git a/plugins/addons/material_import_plugin/README.md b/plugins/addons/material_import_plugin/README.md new file mode 100644 index 0000000000..77294182e0 --- /dev/null +++ b/plugins/addons/material_import_plugin/README.md @@ -0,0 +1,9 @@ +# Material Import Plugin Demo + +This plugin demo shows how a custom import system can +be added to the editor. In this case, it imports a material. +For more information, see this documentation article: +https://docs.godotengine.org/en/latest/tutorials/plugins/editor/import_plugins.html + +In the editor, try opening `test.mtxt`. Godot will recognize +it and import it as a material because of this plugin. diff --git a/plugins/material_import_plugin/import.gd b/plugins/addons/material_import_plugin/import.gd similarity index 100% rename from plugins/material_import_plugin/import.gd rename to plugins/addons/material_import_plugin/import.gd diff --git a/plugins/material_import_plugin/plugin.cfg b/plugins/addons/material_import_plugin/plugin.cfg similarity index 100% rename from plugins/material_import_plugin/plugin.cfg rename to plugins/addons/material_import_plugin/plugin.cfg diff --git a/plugins/material_import_plugin/plugin.gd b/plugins/addons/material_import_plugin/plugin.gd similarity index 100% rename from plugins/material_import_plugin/plugin.gd rename to plugins/addons/material_import_plugin/plugin.gd diff --git a/plugins/material_import_plugin/test.mtxt b/plugins/addons/material_import_plugin/test.mtxt similarity index 100% rename from plugins/material_import_plugin/test.mtxt rename to plugins/addons/material_import_plugin/test.mtxt diff --git a/plugins/material_import_plugin/test.mtxt.import b/plugins/addons/material_import_plugin/test.mtxt.import similarity index 100% rename from plugins/material_import_plugin/test.mtxt.import rename to plugins/addons/material_import_plugin/test.mtxt.import diff --git a/plugins/custom_node_test.tscn b/plugins/custom_node_test.tscn new file mode 100644 index 0000000000..8684e02a9d --- /dev/null +++ b/plugins/custom_node_test.tscn @@ -0,0 +1,15 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://addons/custom_node/heart.gd" type="Script" id=1] + +[sub_resource type="CubeMesh" id=1] + +[node name="CustomNodeTest" type="Node2D"] + +[node name="Heart" type="Node2D" parent="."] +script = ExtResource( 1 ) + +[node name="MeshInstance" type="MeshInstance" parent="."] +mesh = SubResource( 1 ) +skeleton = NodePath("") +material/0 = null diff --git a/plugins/default_env.tres b/plugins/default_env.tres new file mode 100644 index 0000000000..20207a4aa2 --- /dev/null +++ b/plugins/default_env.tres @@ -0,0 +1,7 @@ +[gd_resource type="Environment" load_steps=2 format=2] + +[sub_resource type="ProceduralSky" id=1] + +[resource] +background_mode = 2 +background_sky = SubResource( 1 ) diff --git a/plugins/icon.png b/plugins/icon.png new file mode 100644 index 0000000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 HcmV?d00001 diff --git a/plugins/icon.png.import b/plugins/icon.png.import new file mode 100644 index 0000000000..96cbf4629a --- /dev/null +++ b/plugins/icon.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.png" +dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/plugins/material_creator/README.md b/plugins/material_creator/README.md deleted file mode 100644 index acdde591d4..0000000000 --- a/plugins/material_creator/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# Material Creator Plugin Demo - -This plugin demo contains a custom material creator interface using a custom dock in the editor. - -Custom docks are made of Control nodes, they run in the editor, and any behavior must be done through `tool` scripts. -For more information, see this documentation article: https://docs.godotengine.org/en/latest/tutorials/plugins/editor/making_plugins.html#a-custom-dock - -This plugin allows you to specify color, metallic, and roughness values, and then use it as a material. - -You can apply this silly material directly to Spatial nodes by selecting them and then clicking "Apply". -This shows how a plugin can interact closely with the editor, manipulating nodes the user selects. - -Alternatively, you can also save the silly material to a file, and then load it back into the plugin later. diff --git a/plugins/material_import_plugin/README.md b/plugins/material_import_plugin/README.md deleted file mode 100644 index 70a3a26ffa..0000000000 --- a/plugins/material_import_plugin/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# Material Import Plugin Demo - -This plugin demo shows how a custom import system can be added to the editor. In this case, it imports a material. -For more information, see this documentation article: https://docs.godotengine.org/en/latest/tutorials/plugins/editor/import_plugins.html - -In the editor, try opening `test.mtxt`. Godot will recognize it and import it as a material because of this plugin. diff --git a/plugins/project.godot b/plugins/project.godot new file mode 100644 index 0000000000..8ffa7ea02b --- /dev/null +++ b/plugins/project.godot @@ -0,0 +1,32 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=4 + +_global_script_classes=[ ] +_global_script_class_icons={ + +} + +[application] + +config/name="Plugin Demos" +config/description="This contains multiple plugin demos, all placed in a project for convenience." +run/main_scene="res://custom_node_test.tscn" +config/icon="res://icon.png" + +[editor_plugins] + +enabled=PoolStringArray( "custom_node", "material_creator", "material_import_plugin" ) + +[rendering] + +quality/driver/driver_name="GLES2" +vram_compression/import_etc=true +vram_compression/import_etc2=false +environment/default_environment="res://default_env.tres" From a0a87c3bea4ee950cc5e57b4471cbee471f94243 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Tue, 24 Mar 2020 05:06:52 -0400 Subject: [PATCH 2/2] Add a main screen plugin to the plugin demos --- plugins/README.md | 5 ++- plugins/addons/main_screen/README.md | 11 +++++ .../main_screen/handled_by_main_screen.gd | 1 + plugins/addons/main_screen/main_panel.tscn | 20 +++++++++ .../addons/main_screen/main_screen_plugin.gd | 41 +++++++++++++++++++ plugins/addons/main_screen/plugin.cfg | 7 ++++ plugins/addons/main_screen/print_hello.gd | 5 +++ plugins/project.godot | 4 +- ...{custom_node_test.tscn => test_scene.tscn} | 12 ++++-- 9 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 plugins/addons/main_screen/README.md create mode 100644 plugins/addons/main_screen/handled_by_main_screen.gd create mode 100644 plugins/addons/main_screen/main_panel.tscn create mode 100644 plugins/addons/main_screen/main_screen_plugin.gd create mode 100644 plugins/addons/main_screen/plugin.cfg create mode 100644 plugins/addons/main_screen/print_hello.gd rename plugins/{custom_node_test.tscn => test_scene.tscn} (53%) diff --git a/plugins/README.md b/plugins/README.md index 0e07ad8bbf..dff4fa3dc0 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -11,7 +11,7 @@ Renderer: GLES 2 # How does it work? -This project contains 3 plugins: +This project contains 4 plugins: * The custom node plugin shows how to create a custom node type using `add_custom_type`. [More info](addons/custom_node). @@ -22,6 +22,9 @@ This project contains 3 plugins: * The material creator plugin shows how to add a custom dock with some simple functionality. [More info](addons/material_creator). +* The main screen plugin is a minimal example of how to create a plugin + with a main screen. [More info](addons/main_screen). + To use these plugins in another project, copy any of these folders to the `addons/` folder in a Godot project, and then enable them in the project settings menu. diff --git a/plugins/addons/main_screen/README.md b/plugins/addons/main_screen/README.md new file mode 100644 index 0000000000..453959f585 --- /dev/null +++ b/plugins/addons/main_screen/README.md @@ -0,0 +1,11 @@ +# Main Screen Plugin Demo + +This plugin demo shows how to make a main screen plugin. +The main screen appears as a button next to the "2D", "3D", "Script", and +"AssetLib" buttons. It also shows up when a Node it `handles` is selected. + +For more information, see this documentation article: +https://docs.godotengine.org/en/latest/tutorials/plugins/editor/making_main_screen_plugins.html + +If you would like to see a more complete example of what main screen plugins +are capable of, check out the [2.5D demo project](../../../misc/2.5d). diff --git a/plugins/addons/main_screen/handled_by_main_screen.gd b/plugins/addons/main_screen/handled_by_main_screen.gd new file mode 100644 index 0000000000..61510e14cd --- /dev/null +++ b/plugins/addons/main_screen/handled_by_main_screen.gd @@ -0,0 +1 @@ +extends Node diff --git a/plugins/addons/main_screen/main_panel.tscn b/plugins/addons/main_screen/main_panel.tscn new file mode 100644 index 0000000000..b8693bea0d --- /dev/null +++ b/plugins/addons/main_screen/main_panel.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/main_screen/print_hello.gd" type="Script" id=1] + +[node name="MainPanel" type="CenterContainer"] +anchor_right = 1.0 +anchor_bottom = 1.0 +size_flags_vertical = 3 + +[node name="PrintHello" type="Button" parent="."] +margin_left = 472.0 +margin_top = 290.0 +margin_right = 552.0 +margin_bottom = 310.0 +text = "Print Hello" +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} +[connection signal="pressed" from="PrintHello" to="PrintHello" method="_on_PrintHello_pressed"] diff --git a/plugins/addons/main_screen/main_screen_plugin.gd b/plugins/addons/main_screen/main_screen_plugin.gd new file mode 100644 index 0000000000..b85aaa8be9 --- /dev/null +++ b/plugins/addons/main_screen/main_screen_plugin.gd @@ -0,0 +1,41 @@ +tool +extends EditorPlugin + +const MainPanel = preload("res://addons/main_screen/main_panel.tscn") + +var main_panel_instance + +func _enter_tree(): + main_panel_instance = MainPanel.instance() + # Add the main panel to the editor's main viewport. + get_editor_interface().get_editor_viewport().add_child(main_panel_instance) + # Hide the main panel. Very much required. + make_visible(false) + + +func _exit_tree(): + if main_panel_instance: + main_panel_instance.queue_free() + + +func has_main_screen(): + return true + + +func make_visible(visible): + if main_panel_instance: + main_panel_instance.visible = visible + + +# If your plugin doesn't handle any node types, you can remove this method. +func handles(obj): + return obj is preload("res://addons/main_screen/handled_by_main_screen.gd") + + +func get_plugin_name(): + return "Main Screen Plugin" + + +func get_plugin_icon(): + # Must return some kind of Texture for the icon. + return get_editor_interface().get_base_control().get_icon("Node", "EditorIcons") diff --git a/plugins/addons/main_screen/plugin.cfg b/plugins/addons/main_screen/plugin.cfg new file mode 100644 index 0000000000..b38b73b7ad --- /dev/null +++ b/plugins/addons/main_screen/plugin.cfg @@ -0,0 +1,7 @@ +[plugin] + +name="Main Screen Plugin Demo" +description="Demonstrates how to make a main screen plugin." +author="Aaron Franke, Julian Murgia" +version="1.0" +script="main_screen_plugin.gd" diff --git a/plugins/addons/main_screen/print_hello.gd b/plugins/addons/main_screen/print_hello.gd new file mode 100644 index 0000000000..aecd7e5940 --- /dev/null +++ b/plugins/addons/main_screen/print_hello.gd @@ -0,0 +1,5 @@ +tool +extends Button + +func _on_PrintHello_pressed(): + print("Hello from the main screen plugin!") diff --git a/plugins/project.godot b/plugins/project.godot index 8ffa7ea02b..1d5247e94b 100644 --- a/plugins/project.godot +++ b/plugins/project.godot @@ -17,12 +17,12 @@ _global_script_class_icons={ config/name="Plugin Demos" config/description="This contains multiple plugin demos, all placed in a project for convenience." -run/main_scene="res://custom_node_test.tscn" +run/main_scene="res://test_scene.tscn" config/icon="res://icon.png" [editor_plugins] -enabled=PoolStringArray( "custom_node", "material_creator", "material_import_plugin" ) +enabled=PoolStringArray( "custom_node", "main_screen", "material_creator", "material_import_plugin" ) [rendering] diff --git a/plugins/custom_node_test.tscn b/plugins/test_scene.tscn similarity index 53% rename from plugins/custom_node_test.tscn rename to plugins/test_scene.tscn index 8684e02a9d..30a80ed5a7 100644 --- a/plugins/custom_node_test.tscn +++ b/plugins/test_scene.tscn @@ -1,15 +1,19 @@ -[gd_scene load_steps=3 format=2] +[gd_scene load_steps=4 format=2] -[ext_resource path="res://addons/custom_node/heart.gd" type="Script" id=1] +[ext_resource path="res://addons/main_screen/handled_by_main_screen.gd" type="Script" id=1] +[ext_resource path="res://addons/custom_node/heart.gd" type="Script" id=2] [sub_resource type="CubeMesh" id=1] -[node name="CustomNodeTest" type="Node2D"] +[node name="TestScene" type="Node"] [node name="Heart" type="Node2D" parent="."] -script = ExtResource( 1 ) +script = ExtResource( 2 ) [node name="MeshInstance" type="MeshInstance" parent="."] mesh = SubResource( 1 ) skeleton = NodePath("") material/0 = null + +[node name="HandledByMainScreen" type="Node" parent="."] +script = ExtResource( 1 )