mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Fix issue where nothing would be drawn in the canvas if the first cel is a GroupCel
This commit is contained in:
parent
ffd9d2bca8
commit
970d1d3c23
|
@ -158,6 +158,7 @@ func new_empty_frame() -> Frame:
|
|||
return frame
|
||||
|
||||
|
||||
## Returns the currently selected [BaseCel].
|
||||
func get_current_cel() -> BaseCel:
|
||||
return frames[current_frame].cels[current_layer]
|
||||
|
||||
|
@ -644,6 +645,22 @@ func can_pixel_get_drawn(
|
|||
return true
|
||||
|
||||
|
||||
## Loops through all of the cels until it finds a drawable (non-[GroupCel]) [BaseCel]
|
||||
## in the specified [param frame] and returns it. If no drawable cel is found,
|
||||
## meaning that all of the cels are [GroupCel]s, the method returns null.
|
||||
## If no [param frame] is specified, the method will use the current frame.
|
||||
func find_first_drawable_cel(frame := frames[current_frame]) -> BaseCel:
|
||||
var result: BaseCel
|
||||
var cel := frame.cels[0]
|
||||
var i := 0
|
||||
while cel is GroupCel and i < layers.size():
|
||||
cel = frame.cels[i]
|
||||
i += 1
|
||||
if not cel is GroupCel:
|
||||
result = cel
|
||||
return result
|
||||
|
||||
|
||||
# Timeline modifications
|
||||
# Modifying layers or frames Arrays on the current project should generally only be done
|
||||
# through these methods.
|
||||
|
|
|
@ -39,12 +39,13 @@ func _draw() -> void:
|
|||
if Global.mirror_view:
|
||||
position_tmp.x = position_tmp.x + Global.current_project.size.x
|
||||
scale_tmp.x = -1
|
||||
# If we just use the first cel and it happens to be a GroupCel
|
||||
# nothing will get drawn
|
||||
var cel_to_draw := Global.current_project.find_first_drawable_cel()
|
||||
draw_set_transform(position_tmp, rotation, scale_tmp)
|
||||
# Placeholder so we can have a material here
|
||||
draw_texture(
|
||||
Global.current_project.frames[Global.current_project.current_frame].cels[0].image_texture,
|
||||
Vector2.ZERO
|
||||
)
|
||||
if is_instance_valid(cel_to_draw):
|
||||
draw_texture(cel_to_draw.image_texture, Vector2.ZERO)
|
||||
draw_layers()
|
||||
if Global.onion_skinning:
|
||||
refresh_onion()
|
||||
|
|
|
@ -40,8 +40,12 @@ func _draw() -> void:
|
|||
frame_index = project.current_frame
|
||||
var frame := project.frames[frame_index]
|
||||
animation_timer.wait_time = frame.duration * (1.0 / project.fps)
|
||||
var texture := frame.cels[0].image_texture
|
||||
draw_texture(texture, Vector2.ZERO) # Placeholder so we can have a material here
|
||||
# If we just use the first cel and it happens to be a GroupCel
|
||||
# nothing will get drawn
|
||||
var cel_to_draw := Global.current_project.find_first_drawable_cel(frame)
|
||||
# Placeholder so we can have a material here
|
||||
if is_instance_valid(cel_to_draw):
|
||||
draw_texture(cel_to_draw.image_texture, Vector2.ZERO)
|
||||
if material == animation_material:
|
||||
# Only use a unique material if the animation of the canvas preview is playing
|
||||
# Otherwise showing a different frame than the main canvas is impossible
|
||||
|
@ -58,9 +62,12 @@ func _draw() -> void:
|
|||
frame_index = start_sprite_sheet_frame - 1
|
||||
var src_rect := slices[frame_index]
|
||||
var rect := Rect2(Vector2.ZERO, src_rect.size)
|
||||
var texture := project.frames[project.current_frame].cels[0].image_texture
|
||||
# If we just use the first cel and it happens to be a GroupCel
|
||||
# nothing will get drawn
|
||||
var cel_to_draw := Global.current_project.find_first_drawable_cel()
|
||||
# Placeholder so we can have a material here
|
||||
draw_texture_rect_region(texture, rect, src_rect)
|
||||
if is_instance_valid(cel_to_draw):
|
||||
draw_texture_rect_region(cel_to_draw.image_texture, rect, src_rect)
|
||||
transparent_checker.fit_rect(rect)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue