Initial structural setup for editing PaintCanvases.

This commit is contained in:
Relintai 2022-11-16 00:30:49 +01:00
parent 52cd6670ac
commit 355378f4d5
6 changed files with 80 additions and 2 deletions

6
game/PaintCanvas.gd Normal file
View File

@ -0,0 +1,6 @@
tool
extends PaintCanvas
func forward_canvas_gui_input(event: InputEvent) -> bool:
return false

17
game/PaintProject.gd Normal file
View File

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

View File

@ -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"] [node name="PaintProject" type="PaintProject"]
current_color = Color( 0.957181, 0.325235, 0.352407, 1 )
script = ExtResource( 2 )
[node name="PaintCanvas" type="PaintCanvas" parent="."] [node name="PaintCanvas" type="PaintCanvas" parent="."]
script = ExtResource( 1 )

View File

@ -0,0 +1,7 @@
[plugin]
name="PaintCanvasPlugin"
description=""
author="Relintai"
version=""
script="plugin.gd"

View File

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

View File

@ -16,7 +16,7 @@ config/icon="res://icon.png"
[editor_plugins] [editor_plugins]
enabled=PoolStringArray( "res://addons/paint/plugin.cfg" ) enabled=PoolStringArray( "res://addons/paint/plugin.cfg", "res://addons/paint_canvas/plugin.cfg" )
[physics] [physics]