1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Add a get_class_name() method in the cel classes

I wish Godot had a method for this already
This commit is contained in:
Emmanouil Papadeas 2023-04-30 14:52:01 +03:00
parent 280fb748e9
commit 860370bd4e
5 changed files with 18 additions and 11 deletions

View file

@ -303,14 +303,5 @@ class ProjectAPI:
# then the old extension would have no idea how to identify the types they use
# E.g the extension may try to use a GroupCel as a PixelCel (if it doesn't know the difference)
# So it's encouraged to use this function to access cels
var project = get_current_project()
var cel = project.get_current_cel()
# Add cel types as we have more and more cels
if cel is PixelCel:
return {"cel": cel, "type": "PixelCel"}
elif cel is GroupCel:
return {"cel": cel, "type": "GroupCel"}
elif cel is Cel3D:
return {"cel": cel, "type": "Cel3D"}
else:
return {"cel": cel, "type": "BaseCel"}
var cel := get_current_project().get_current_cel()
return {"cel": cel, "type": cel.get_class_name()}

View file

@ -73,3 +73,7 @@ func on_remove() -> void:
func instantiate_cel_button() -> Node:
return null
func get_class_name() -> String:
return "BaseCel"

View file

@ -210,3 +210,7 @@ func load_image_data_from_pxo(file: File, project_size: Vector2) -> void:
func instantiate_cel_button() -> Node:
return Global.pixel_cel_button_node.instance()
func get_class_name() -> String:
return "Cel3D"

View file

@ -19,3 +19,7 @@ func get_image() -> Image:
func instantiate_cel_button() -> Node:
return Global.group_cel_button_node.instance()
func get_class_name() -> String:
return "GroupCel"

View file

@ -71,3 +71,7 @@ func load_image_data_from_pxo(file: File, project_size: Vector2) -> void:
func instantiate_cel_button() -> Node:
return Global.pixel_cel_button_node.instance()
func get_class_name() -> String:
return "PixelCel"