From 355378f4d554b0d53533239faf519492106a1b0a Mon Sep 17 00:00:00 2001 From: Relintai Date: Wed, 16 Nov 2022 00:30:49 +0100 Subject: [PATCH] Initial structural setup for editing PaintCanvases. --- game/PaintCanvas.gd | 6 +++++ game/PaintProject.gd | 17 ++++++++++++ game/Project.tscn | 8 +++++- game/addons/paint_canvas/plugin.cfg | 7 +++++ game/addons/paint_canvas/plugin.gd | 42 +++++++++++++++++++++++++++++ game/project.pandemonium | 2 +- 6 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 game/PaintCanvas.gd create mode 100644 game/PaintProject.gd create mode 100644 game/addons/paint_canvas/plugin.cfg create mode 100644 game/addons/paint_canvas/plugin.gd diff --git a/game/PaintCanvas.gd b/game/PaintCanvas.gd new file mode 100644 index 0000000..08c58ed --- /dev/null +++ b/game/PaintCanvas.gd @@ -0,0 +1,6 @@ +tool +extends PaintCanvas + + +func forward_canvas_gui_input(event: InputEvent) -> bool: + return false diff --git a/game/PaintProject.gd b/game/PaintProject.gd new file mode 100644 index 0000000..2de5c04 --- /dev/null +++ b/game/PaintProject.gd @@ -0,0 +1,17 @@ +tool +extends PaintProject + + +# Declare member variables here. Examples: +# var a: int = 2 +# var b: String = "text" + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta: float) -> void: +# pass diff --git a/game/Project.tscn b/game/Project.tscn index b326a7a..a6e5a06 100644 --- a/game/Project.tscn +++ b/game/Project.tscn @@ -1,5 +1,11 @@ -[gd_scene format=2] +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://PaintCanvas.gd" type="Script" id=1] +[ext_resource path="res://PaintProject.gd" type="Script" id=2] [node name="PaintProject" type="PaintProject"] +current_color = Color( 0.957181, 0.325235, 0.352407, 1 ) +script = ExtResource( 2 ) [node name="PaintCanvas" type="PaintCanvas" parent="."] +script = ExtResource( 1 ) diff --git a/game/addons/paint_canvas/plugin.cfg b/game/addons/paint_canvas/plugin.cfg new file mode 100644 index 0000000..06b0631 --- /dev/null +++ b/game/addons/paint_canvas/plugin.cfg @@ -0,0 +1,7 @@ +[plugin] + +name="PaintCanvasPlugin" +description="" +author="Relintai" +version="" +script="plugin.gd" diff --git a/game/addons/paint_canvas/plugin.gd b/game/addons/paint_canvas/plugin.gd new file mode 100644 index 0000000..75c36f2 --- /dev/null +++ b/game/addons/paint_canvas/plugin.gd @@ -0,0 +1,42 @@ +tool +extends EditorPlugin + +var active_canvas : PaintCanvas = null + +func handles(object: Object) -> bool: + return object is PaintCanvas + +func edit(object: Object) -> void: + active_canvas = object + +func forward_canvas_gui_input(event: InputEvent) -> bool: + if !active_canvas: + return false + + #Temp! + if active_canvas.get_script() == null: + return false + + return active_canvas.forward_canvas_gui_input(event) + +func on_node_removed(node: Node) -> void: + if node == active_canvas: + active_canvas = null + +func _enter_tree() -> void: + get_tree().connect("node_removed", self, "on_node_removed") + + var paint_editor_plugin : EditorPlugin = Engine.get_global("PaintEditorPlugin") + + if paint_editor_plugin: + var sidebar : PaintSidebar = paint_editor_plugin.get_sidebar() + + #print(sidebar) + +func _exit_tree() -> void: + var paint_editor_plugin : EditorPlugin = Engine.get_global("PaintEditorPlugin") + + if paint_editor_plugin: + var sidebar : PaintSidebar = paint_editor_plugin.get_sidebar() + + #print(sidebar) diff --git a/game/project.pandemonium b/game/project.pandemonium index ad4b29c..0209198 100644 --- a/game/project.pandemonium +++ b/game/project.pandemonium @@ -16,7 +16,7 @@ config/icon="res://icon.png" [editor_plugins] -enabled=PoolStringArray( "res://addons/paint/plugin.cfg" ) +enabled=PoolStringArray( "res://addons/paint/plugin.cfg", "res://addons/paint_canvas/plugin.cfg" ) [physics]