mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-12 08:43:08 +00:00
* Updated PixelLayerButton's LinkButton's hint_tooltip to be more accurate * Don't automatically link the current frame's cel when enabling new_cels_linked on a layer * Mostly added new system * renamed link group to link set * Enable drag and drop of linked cels on the same layer * formatted CelButton.gd * serialize/deserialize * Copy frames w/ new linked cels system. Removed copy_cel from layer classes * Removed commented out code from AnimationTimeline.copy_frames * Removed Project.duplicate_layers * Removed unlink_cel in favour of using null with link cel (as the first part of that method was the same) * Disabled show_behind_parent on PixelCelButton's LinkedIndicator, as it wasn't enough to improve visibility of selection * Moved BaseLayer.copy out of the Methods to Override section * Added optional texture param to Cel's set_content method (needed for use when deserializing, and otherwise helpful * set textures with set_content where needed * open_image_as_spritesheet_layer new_cels_linked part updated * clone layer with linked cels implemented. Removed copy_all_cels from layer classes * weaked how copied layers names are updated * Merge layers works with new linked cels now * Fixed texture on cel buttons not being updated on button setup * fixed bug where using set_content with new image texture would result in an empty texture * Open old .pxo with new linked cels * simplified backwards compatiblity * removed linked_cels * better linked cels backwards compatibility * Removed some old TODO comments * fixed linked_cels conversion bug when linked_cels is empty * Added undo for linking the previous cel when creating new cels with new_cels_linked enabled * Removed TODOs * Cleaned up some method variable naming * Cleaned up deserialization * combined matching for loops * Inlined BaseLayer.copy() where its used * gdformat * Fixed Translations,pot Co-authored-by: MrTriPie <MrTriPie>
74 lines
1.9 KiB
GDScript
74 lines
1.9 KiB
GDScript
class_name PixelCel
|
|
extends BaseCel
|
|
# A class for the properties of cels in PixelLayers.
|
|
# The term "cel" comes from "celluloid" (https://en.wikipedia.org/wiki/Cel).
|
|
# The "image" variable is where the image data of each cel are.
|
|
|
|
var image: Image setget image_changed
|
|
|
|
|
|
func _init(_image := Image.new(), _opacity := 1.0, _image_texture: ImageTexture = null) -> void:
|
|
if _image_texture:
|
|
image_texture = _image_texture
|
|
else:
|
|
image_texture = ImageTexture.new()
|
|
self.image = _image # Set image and call setter
|
|
opacity = _opacity
|
|
|
|
|
|
func image_changed(value: Image) -> void:
|
|
image = value
|
|
if !image.is_empty():
|
|
image_texture.create_from_image(image, 0)
|
|
|
|
|
|
func get_content():
|
|
return image
|
|
|
|
|
|
func set_content(content, texture: ImageTexture = null) -> void:
|
|
image = content
|
|
if is_instance_valid(texture):
|
|
image_texture = texture
|
|
if image_texture.get_size() != image.get_size():
|
|
image_texture.create_from_image(image, 0)
|
|
else:
|
|
image_texture.create_from_image(image, 0)
|
|
|
|
|
|
func create_empty_content():
|
|
var empty_image := Image.new()
|
|
empty_image.create(image.get_size().x, image.get_size().y, false, Image.FORMAT_RGBA8)
|
|
return empty_image
|
|
|
|
|
|
func copy_content():
|
|
var copy_image := Image.new()
|
|
copy_image.create_from_data(
|
|
image.get_width(), image.get_height(), false, Image.FORMAT_RGBA8, image.get_data()
|
|
)
|
|
return copy_image
|
|
|
|
|
|
func get_image() -> Image:
|
|
return image
|
|
|
|
|
|
func update_texture() -> void:
|
|
image_texture.set_data(image)
|
|
|
|
|
|
func save_image_data_to_pxo(file: File) -> void:
|
|
file.store_buffer(image.get_data())
|
|
|
|
|
|
func load_image_data_from_pxo(file: File, project_size: Vector2) -> void:
|
|
var buffer := file.get_buffer(project_size.x * project_size.y * 4)
|
|
image.create_from_data(project_size.x, project_size.y, false, Image.FORMAT_RGBA8, buffer)
|
|
image_changed(image)
|
|
|
|
|
|
func instantiate_cel_button() -> Node:
|
|
var cel_button = Global.pixel_cel_button_node.instance()
|
|
return cel_button
|