Skip to content

Commit a0a87c3

Browse files
committed
Add a main screen plugin to the plugin demos
1 parent 51c0f3a commit a0a87c3

File tree

9 files changed

+99
-7
lines changed

9 files changed

+99
-7
lines changed

plugins/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Renderer: GLES 2
1111

1212
# How does it work?
1313

14-
This project contains 3 plugins:
14+
This project contains 4 plugins:
1515

1616
* The custom node plugin shows how to create a custom node type
1717
using `add_custom_type`. [More info](addons/custom_node).
@@ -22,6 +22,9 @@ This project contains 3 plugins:
2222
* The material creator plugin shows how to add a custom dock with some
2323
simple functionality. [More info](addons/material_creator).
2424

25+
* The main screen plugin is a minimal example of how to create a plugin
26+
with a main screen. [More info](addons/main_screen).
27+
2528
To use these plugins in another project, copy any of these
2629
folders to the `addons/` folder in a Godot project, and then
2730
enable them in the project settings menu.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Main Screen Plugin Demo
2+
3+
This plugin demo shows how to make a main screen plugin.
4+
The main screen appears as a button next to the "2D", "3D", "Script", and
5+
"AssetLib" buttons. It also shows up when a Node it `handles` is selected.
6+
7+
For more information, see this documentation article:
8+
https://docs.godotengine.org/en/latest/tutorials/plugins/editor/making_main_screen_plugins.html
9+
10+
If you would like to see a more complete example of what main screen plugins
11+
are capable of, check out the [2.5D demo project](../../../misc/2.5d).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extends Node
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[gd_scene load_steps=2 format=2]
2+
3+
[ext_resource path="res://addons/main_screen/print_hello.gd" type="Script" id=1]
4+
5+
[node name="MainPanel" type="CenterContainer"]
6+
anchor_right = 1.0
7+
anchor_bottom = 1.0
8+
size_flags_vertical = 3
9+
10+
[node name="PrintHello" type="Button" parent="."]
11+
margin_left = 472.0
12+
margin_top = 290.0
13+
margin_right = 552.0
14+
margin_bottom = 310.0
15+
text = "Print Hello"
16+
script = ExtResource( 1 )
17+
__meta__ = {
18+
"_edit_use_anchors_": false
19+
}
20+
[connection signal="pressed" from="PrintHello" to="PrintHello" method="_on_PrintHello_pressed"]
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
tool
2+
extends EditorPlugin
3+
4+
const MainPanel = preload("res://addons/main_screen/main_panel.tscn")
5+
6+
var main_panel_instance
7+
8+
func _enter_tree():
9+
main_panel_instance = MainPanel.instance()
10+
# Add the main panel to the editor's main viewport.
11+
get_editor_interface().get_editor_viewport().add_child(main_panel_instance)
12+
# Hide the main panel. Very much required.
13+
make_visible(false)
14+
15+
16+
func _exit_tree():
17+
if main_panel_instance:
18+
main_panel_instance.queue_free()
19+
20+
21+
func has_main_screen():
22+
return true
23+
24+
25+
func make_visible(visible):
26+
if main_panel_instance:
27+
main_panel_instance.visible = visible
28+
29+
30+
# If your plugin doesn't handle any node types, you can remove this method.
31+
func handles(obj):
32+
return obj is preload("res://addons/main_screen/handled_by_main_screen.gd")
33+
34+
35+
func get_plugin_name():
36+
return "Main Screen Plugin"
37+
38+
39+
func get_plugin_icon():
40+
# Must return some kind of Texture for the icon.
41+
return get_editor_interface().get_base_control().get_icon("Node", "EditorIcons")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[plugin]
2+
3+
name="Main Screen Plugin Demo"
4+
description="Demonstrates how to make a main screen plugin."
5+
author="Aaron Franke, Julian Murgia"
6+
version="1.0"
7+
script="main_screen_plugin.gd"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
tool
2+
extends Button
3+
4+
func _on_PrintHello_pressed():
5+
print("Hello from the main screen plugin!")

plugins/project.godot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ _global_script_class_icons={
1717

1818
config/name="Plugin Demos"
1919
config/description="This contains multiple plugin demos, all placed in a project for convenience."
20-
run/main_scene="res://custom_node_test.tscn"
20+
run/main_scene="res://test_scene.tscn"
2121
config/icon="res://icon.png"
2222

2323
[editor_plugins]
2424

25-
enabled=PoolStringArray( "custom_node", "material_creator", "material_import_plugin" )
25+
enabled=PoolStringArray( "custom_node", "main_screen", "material_creator", "material_import_plugin" )
2626

2727
[rendering]
2828

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
[gd_scene load_steps=3 format=2]
1+
[gd_scene load_steps=4 format=2]
22

3-
[ext_resource path="res://addons/custom_node/heart.gd" type="Script" id=1]
3+
[ext_resource path="res://addons/main_screen/handled_by_main_screen.gd" type="Script" id=1]
4+
[ext_resource path="res://addons/custom_node/heart.gd" type="Script" id=2]
45

56
[sub_resource type="CubeMesh" id=1]
67

7-
[node name="CustomNodeTest" type="Node2D"]
8+
[node name="TestScene" type="Node"]
89

910
[node name="Heart" type="Node2D" parent="."]
10-
script = ExtResource( 1 )
11+
script = ExtResource( 2 )
1112

1213
[node name="MeshInstance" type="MeshInstance" parent="."]
1314
mesh = SubResource( 1 )
1415
skeleton = NodePath("")
1516
material/0 = null
17+
18+
[node name="HandledByMainScreen" type="Node" parent="."]
19+
script = ExtResource( 1 )

0 commit comments

Comments
 (0)