Browse Source

Merge pull request #453 from aaronfranke/plugin-proj

Refactor the plugin demos to be inside of a project and add main screen plugin demo
Aaron Franke 5 years ago
parent
commit
57baf0a1b5
35 changed files with 250 additions and 22 deletions
  1. 32 3
      plugins/README.md
  2. 12 0
      plugins/addons/README.md
  3. 0 0
      plugins/addons/custom_node/README.md
  4. 0 0
      plugins/addons/custom_node/heart.gd
  5. 0 0
      plugins/addons/custom_node/heart.png
  6. 0 0
      plugins/addons/custom_node/heart.png.import
  7. 0 0
      plugins/addons/custom_node/heart_icon.png
  8. 0 0
      plugins/addons/custom_node/heart_icon.png.import
  9. 0 0
      plugins/addons/custom_node/heart_plugin.gd
  10. 0 0
      plugins/addons/custom_node/plugin.cfg
  11. 11 0
      plugins/addons/main_screen/README.md
  12. 1 0
      plugins/addons/main_screen/handled_by_main_screen.gd
  13. 20 0
      plugins/addons/main_screen/main_panel.tscn
  14. 41 0
      plugins/addons/main_screen/main_screen_plugin.gd
  15. 7 0
      plugins/addons/main_screen/plugin.cfg
  16. 5 0
      plugins/addons/main_screen/print_hello.gd
  17. 20 0
      plugins/addons/material_creator/README.md
  18. 0 0
      plugins/addons/material_creator/material_creator.gd
  19. 0 0
      plugins/addons/material_creator/material_dock.tscn
  20. 0 0
      plugins/addons/material_creator/material_plugin.gd
  21. 0 0
      plugins/addons/material_creator/material_resource.gd
  22. 0 0
      plugins/addons/material_creator/plugin.cfg
  23. 9 0
      plugins/addons/material_import_plugin/README.md
  24. 0 0
      plugins/addons/material_import_plugin/import.gd
  25. 0 0
      plugins/addons/material_import_plugin/plugin.cfg
  26. 0 0
      plugins/addons/material_import_plugin/plugin.gd
  27. 0 0
      plugins/addons/material_import_plugin/test.mtxt
  28. 0 0
      plugins/addons/material_import_plugin/test.mtxt.import
  29. 7 0
      plugins/default_env.tres
  30. BIN
      plugins/icon.png
  31. 34 0
      plugins/icon.png.import
  32. 0 13
      plugins/material_creator/README.md
  33. 0 6
      plugins/material_import_plugin/README.md
  34. 32 0
      plugins/project.godot
  35. 19 0
      plugins/test_scene.tscn

+ 32 - 3
plugins/README.md

@@ -1,9 +1,38 @@
-# 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 4 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).
+
+* 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.
 
 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/*`

+ 12 - 0
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/*`

+ 0 - 0
plugins/custom_node/README.md → plugins/addons/custom_node/README.md


+ 0 - 0
plugins/custom_node/heart.gd → plugins/addons/custom_node/heart.gd


+ 0 - 0
plugins/custom_node/heart.png → plugins/addons/custom_node/heart.png


+ 0 - 0
plugins/custom_node/heart.png.import → plugins/addons/custom_node/heart.png.import


+ 0 - 0
plugins/custom_node/heart_icon.png → plugins/addons/custom_node/heart_icon.png


+ 0 - 0
plugins/custom_node/heart_icon.png.import → plugins/addons/custom_node/heart_icon.png.import


+ 0 - 0
plugins/custom_node/heart_plugin.gd → plugins/addons/custom_node/heart_plugin.gd


+ 0 - 0
plugins/custom_node/plugin.cfg → plugins/addons/custom_node/plugin.cfg


+ 11 - 0
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).

+ 1 - 0
plugins/addons/main_screen/handled_by_main_screen.gd

@@ -0,0 +1 @@
+extends Node

+ 20 - 0
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"]

+ 41 - 0
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")

+ 7 - 0
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"

+ 5 - 0
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!")

+ 20 - 0
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.

+ 0 - 0
plugins/material_creator/material_creator.gd → plugins/addons/material_creator/material_creator.gd


+ 0 - 0
plugins/material_creator/material_dock.tscn → plugins/addons/material_creator/material_dock.tscn


+ 0 - 0
plugins/material_creator/material_plugin.gd → plugins/addons/material_creator/material_plugin.gd


+ 0 - 0
plugins/material_creator/material_resource.gd → plugins/addons/material_creator/material_resource.gd


+ 0 - 0
plugins/material_creator/plugin.cfg → plugins/addons/material_creator/plugin.cfg


+ 9 - 0
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.

+ 0 - 0
plugins/material_import_plugin/import.gd → plugins/addons/material_import_plugin/import.gd


+ 0 - 0
plugins/material_import_plugin/plugin.cfg → plugins/addons/material_import_plugin/plugin.cfg


+ 0 - 0
plugins/material_import_plugin/plugin.gd → plugins/addons/material_import_plugin/plugin.gd


+ 0 - 0
plugins/material_import_plugin/test.mtxt → plugins/addons/material_import_plugin/test.mtxt


+ 0 - 0
plugins/material_import_plugin/test.mtxt.import → plugins/addons/material_import_plugin/test.mtxt.import


+ 7 - 0
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 )

BIN
plugins/icon.png


+ 34 - 0
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

+ 0 - 13
plugins/material_creator/README.md

@@ -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.

+ 0 - 6
plugins/material_import_plugin/README.md

@@ -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.

+ 32 - 0
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://test_scene.tscn"
+config/icon="res://icon.png"
+
+[editor_plugins]
+
+enabled=PoolStringArray( "custom_node", "main_screen", "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"

+ 19 - 0
plugins/test_scene.tscn

@@ -0,0 +1,19 @@
+[gd_scene load_steps=4 format=2]
+
+[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="TestScene" type="Node"]
+
+[node name="Heart" type="Node2D" parent="."]
+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 )