xyz
the editor plugIN
loads an instance and the EditorInspectorPlugin and creates a costum node
@tool
extends EditorPlugin
const menuScene = preload("res://menu/menu.tscn");
const tileDrawNode = preload("res://test3/tileDrawNode.gd");
const tileDrawIcon = preload("res://test3/icon.png");
#---------//---inspector---//---------
var tlDrawInspector = preload("res://addons/tiledrawtest2/tileDrawInspector.gd");
func _enter_tree():
add_custom_type("TileDraw", "Node2D", tileDrawNode, tileDrawIcon );
dockedScene = menuScene.instantiate();
add_control_to_container(CONTAINER_CANVAS_EDITOR_SIDE_RIGHT, dockedScene );
dockedScene.custom_minimum_size = Vector2(10,0);
tlDrawInspector = tlDrawInspector.new();
tlDrawInspector.PlugInDockedScene = dockedScene;
add_inspector_plugin(tlDrawInspector);
var TileDrawNode;
func _handles(object: Object) -> bool:
#return object is tileDrawNode
if ( object is tileDrawNode ):
TileDrawNode = object;
return true
return false
the costum node 'tileDrawNode' draws all of this stuff in engine editor screen
@tool
extends Node2D
class_name tileDrawX1;
var layers = {
'Lnum': [ {} ]
}
for i in range(0, drawText.get_image().get_size().x,32 ):
for j in range(0, drawText.get_image().get_size().y, 32):
mouseGroup.Fnum.append( { "cords": Vector2(i, j), "img": ImageTexture.create_from_image(drawText.get_image().get_region( Rect2( i, j, 32, 32) ) ) } );
func _draw():
for p in range(0, layerMax ):
for i in layers.Lnum[p]:
if ( layers.Lnum[p].has(i) ):
draw_texture( layers.Lnum[p][i], i );
and the EditorInspectorPlugin adds a menu to the inspector with the itemList and other things
@tool
extends EditorInspectorPlugin
var itemLlist1;
func _can_handle(object):
if object is tileDrawX1:
PlugTileDrawNode = object;
return true
return false
func _parse_end(object):
itemLlist1 = ItemList.new();
itemLlist1.set_custom_minimum_size(Vector2(100, 90));
itemLlist1.set( "theme_override_styles/focus",StyleBoxEmpty.new() );
itemLlist1.select_mode = 1;
for n in 3:
itemLlist1.add_item(" layer " + str(n) );
itemLlist1.select(0, true);
var listSize = itemLlist1.get_item_count();
for n in range( listSize-1 ):
if ( PlugTileDrawNode.layers.Lnum.size() < listSize ):
PlugTileDrawNode.layers.Lnum.append( {} );
func btn_UpLayer_pressed(): # move layers UP
var listSize = itemLlist1.get_item_count();
PlugTileDrawNode.layerMax = listSize;
#PlugTileDrawNode.add_layers();
var itemListSize = itemLlist1.get_item_count();
var itemListSelectedItems = itemLlist1.get_selected_items();
for n in itemListSize:
if ( itemListSelectedItems.has(n) && n >= 1 ):
if ( itemListSelectedItems[0] != 0 ):
#itemLlist1.move_item(n, n - 1);
itemLlist1.move_item(itemListSelectedItems[0], n - 1);
var a1 = PlugTileDrawNode.layers.Lnum[n-1];
var a2 = PlugTileDrawNode.layers.Lnum[n];
PlugTileDrawNode.layers.Lnum[n] = a1;
PlugTileDrawNode.layers.Lnum[n-1] = a2;
This things cant communicate with one an other... I have to pass them on to the other using a var.
If i had an itemList on both sides the result would be the same
EditorInspectorPlugin, doesnt have proccess() nor ready() the user selects the options there...
And putting this layers.Lnum in an itemList i dont know if its possible, i dont know whats going on inside an itemList ?
I dont know if its an array or sometimes its already an array, drawing the list in the draw function could be possible i just dont know how.