mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-19 01:29:49 +00:00
Some static typing and docstring improvements
This commit is contained in:
parent
ea71adf308
commit
1901078d98
|
@ -430,8 +430,8 @@ class ProjectAPI:
|
||||||
|
|
||||||
func get_cel_at(project: Project, frame: int, layer: int) -> BaseCel:
|
func get_cel_at(project: Project, frame: int, layer: int) -> BaseCel:
|
||||||
# frames from left to right, layers from bottom to top
|
# frames from left to right, layers from bottom to top
|
||||||
clamp(frame, 0, project.frames.size() - 1)
|
clampi(frame, 0, project.frames.size() - 1)
|
||||||
clamp(layer, 0, project.layers.size() - 1)
|
clampi(layer, 0, project.layers.size() - 1)
|
||||||
return project.frames[frame].cels[layer]
|
return project.frames[frame].cels[layer]
|
||||||
|
|
||||||
func set_pixelcel_image(image: Image, frame: int, layer: int) -> void:
|
func set_pixelcel_image(image: Image, frame: int, layer: int) -> void:
|
||||||
|
|
|
@ -410,7 +410,7 @@ func _ready() -> void:
|
||||||
default_fill_color = config_cache.get_value(
|
default_fill_color = config_cache.get_value(
|
||||||
"preferences", "default_fill_color", default_fill_color
|
"preferences", "default_fill_color", default_fill_color
|
||||||
)
|
)
|
||||||
var proj_size := Vector2(default_width, default_height)
|
var proj_size := Vector2i(default_width, default_height)
|
||||||
projects.append(Project.new([], tr("untitled"), proj_size))
|
projects.append(Project.new([], tr("untitled"), proj_size))
|
||||||
current_project = projects[0]
|
current_project = projects[0]
|
||||||
current_project.fill_color = default_fill_color
|
current_project.fill_color = default_fill_color
|
||||||
|
@ -565,13 +565,13 @@ func notification_label(text: String) -> void:
|
||||||
control.add_child(notif)
|
control.add_child(notif)
|
||||||
|
|
||||||
|
|
||||||
func general_undo(project: Project = current_project) -> void:
|
func general_undo(project:= current_project) -> void:
|
||||||
project.undos -= 1
|
project.undos -= 1
|
||||||
var action_name := project.undo_redo.get_current_action_name()
|
var action_name := project.undo_redo.get_current_action_name()
|
||||||
notification_label("Undo: %s" % action_name)
|
notification_label("Undo: %s" % action_name)
|
||||||
|
|
||||||
|
|
||||||
func general_redo(project: Project = current_project) -> void:
|
func general_redo(project := current_project) -> void:
|
||||||
if project.undos < project.undo_redo.get_version(): # If we did undo and then redo
|
if project.undos < project.undo_redo.get_version(): # If we did undo and then redo
|
||||||
project.undos = project.undo_redo.get_version()
|
project.undos = project.undo_redo.get_version()
|
||||||
if control.redone:
|
if control.redone:
|
||||||
|
@ -580,7 +580,7 @@ func general_redo(project: Project = current_project) -> void:
|
||||||
|
|
||||||
|
|
||||||
func undo_or_redo(
|
func undo_or_redo(
|
||||||
undo: bool, frame_index := -1, layer_index := -1, project: Project = current_project
|
undo: bool, frame_index := -1, layer_index := -1, project := current_project
|
||||||
) -> void:
|
) -> void:
|
||||||
if undo:
|
if undo:
|
||||||
general_undo(project)
|
general_undo(project)
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
class_name GIFAnimationExporter
|
class_name GIFAnimationExporter
|
||||||
extends AImgIOBaseExporter
|
extends AImgIOBaseExporter
|
||||||
# Acts as the interface between the AImgIO format-independent interface and gdgifexporter.
|
## Acts as the interface between the AImgIO format-independent interface and gdgifexporter.
|
||||||
# Note that if the interface needs changing for new features, do just change it!
|
## Note that if the interface needs changing for new features, do just change it!
|
||||||
|
|
||||||
# Gif exporter
|
## Gif exporter
|
||||||
const GIFExporter := preload("res://addons/gdgifexporter/exporter.gd")
|
const GIFExporter := preload("res://addons/gdgifexporter/exporter.gd")
|
||||||
const MedianCutQuantization := preload("res://addons/gdgifexporter/quantization/median_cut.gd")
|
const MedianCutQuantization := preload("res://addons/gdgifexporter/quantization/median_cut.gd")
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class_name AnimationTag
|
class_name AnimationTag
|
||||||
extends RefCounted
|
extends RefCounted
|
||||||
# A class for frame tag properties
|
## A class for frame tag properties
|
||||||
|
|
||||||
var name: String
|
var name: String
|
||||||
var color: Color
|
var color: Color
|
||||||
|
|
|
@ -50,7 +50,7 @@ func get_image() -> Image:
|
||||||
func update_texture() -> void:
|
func update_texture() -> void:
|
||||||
texture_changed.emit()
|
texture_changed.emit()
|
||||||
if link_set != null:
|
if link_set != null:
|
||||||
var frame: int = Global.current_project.current_frame
|
var frame := Global.current_project.current_frame
|
||||||
# This check is needed in case the user has selected multiple cels that are also linked
|
# This check is needed in case the user has selected multiple cels that are also linked
|
||||||
if self in Global.current_project.frames[frame].cels:
|
if self in Global.current_project.frames[frame].cels:
|
||||||
for cel in link_set["cels"]:
|
for cel in link_set["cels"]:
|
||||||
|
|
|
@ -246,7 +246,7 @@ func _add_object(type: int, file_path := "") -> void:
|
||||||
var dict := {"type": type, "file_path": file_path}
|
var dict := {"type": type, "file_path": file_path}
|
||||||
var new_objects := _cel.object_properties.duplicate()
|
var new_objects := _cel.object_properties.duplicate()
|
||||||
new_objects[_cel.current_object_id] = dict
|
new_objects[_cel.current_object_id] = dict
|
||||||
var undo_redo: UndoRedo = Global.current_project.undo_redo
|
var undo_redo := Global.current_project.undo_redo
|
||||||
undo_redo.create_action("Add 3D object")
|
undo_redo.create_action("Add 3D object")
|
||||||
undo_redo.add_do_property(_cel, "object_properties", new_objects)
|
undo_redo.add_do_property(_cel, "object_properties", new_objects)
|
||||||
undo_redo.add_undo_property(_cel, "object_properties", _cel.object_properties)
|
undo_redo.add_undo_property(_cel, "object_properties", _cel.object_properties)
|
||||||
|
@ -277,7 +277,7 @@ func _on_RemoveObject_pressed() -> void:
|
||||||
|
|
||||||
|
|
||||||
func _object_property_changed(object: Cel3DObject) -> void:
|
func _object_property_changed(object: Cel3DObject) -> void:
|
||||||
var undo_redo: UndoRedo = Global.current_project.undo_redo
|
var undo_redo := Global.current_project.undo_redo
|
||||||
var new_properties := _cel.object_properties.duplicate()
|
var new_properties := _cel.object_properties.duplicate()
|
||||||
new_properties[object.id] = object.serialize()
|
new_properties[object.id] = object.serialize()
|
||||||
undo_redo.create_action("Change object transform")
|
undo_redo.create_action("Change object transform")
|
||||||
|
|
|
@ -322,8 +322,8 @@ func _prepare_circle_tool(fill: bool) -> void:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Make sure to always have invoked _prepare_tool() before this. This computes the coordinates to be
|
## Make sure to always have invoked _prepare_tool() before this. This computes the coordinates to be
|
||||||
# drawn if it can (except for the generic brush, when it's actually drawing them)
|
## drawn if it can (except for the generic brush, when it's actually drawing them)
|
||||||
func _draw_tool(pos: Vector2) -> PackedVector2Array:
|
func _draw_tool(pos: Vector2) -> PackedVector2Array:
|
||||||
if !Global.current_project.layers[Global.current_project.current_layer].can_layer_get_drawn():
|
if !Global.current_project.layers[Global.current_project.current_layer].can_layer_get_drawn():
|
||||||
return PackedVector2Array() # empty fallback
|
return PackedVector2Array() # empty fallback
|
||||||
|
|
|
@ -28,13 +28,13 @@ func _input(event: InputEvent) -> void:
|
||||||
return
|
return
|
||||||
visible = true
|
visible = true
|
||||||
if event is InputEventMouseMotion:
|
if event is InputEventMouseMotion:
|
||||||
var tmp_transform = get_canvas_transform().affine_inverse()
|
var tmp_transform := get_canvas_transform().affine_inverse()
|
||||||
var tmp_position = Global.main_viewport.get_local_mouse_position()
|
var tmp_position := Global.main_viewport.get_local_mouse_position()
|
||||||
var mouse_point = (tmp_transform.basis_xform(tmp_position) + tmp_transform.origin).snapped(
|
var mouse_point := (tmp_transform.basis_xform(tmp_position) + tmp_transform.origin).snapped(
|
||||||
Vector2(0.5, 0.5)
|
Vector2(0.5, 0.5)
|
||||||
)
|
)
|
||||||
|
|
||||||
var project_size = Global.current_project.size
|
var project_size: = Global.current_project.size
|
||||||
if Rect2(Vector2.ZERO, project_size).has_point(mouse_point):
|
if Rect2(Vector2.ZERO, project_size).has_point(mouse_point):
|
||||||
visible = true
|
visible = true
|
||||||
else:
|
else:
|
||||||
|
@ -51,11 +51,11 @@ func _input(event: InputEvent) -> void:
|
||||||
|
|
||||||
func _draw() -> void:
|
func _draw() -> void:
|
||||||
width = Global.camera.zoom.x * 2
|
width = Global.camera.zoom.x * 2
|
||||||
var viewport_size: Vector2 = Global.main_viewport.size
|
var viewport_size := Global.main_viewport.size
|
||||||
var zoom: Vector2 = Global.camera.zoom
|
var zoom := Global.camera.zoom
|
||||||
|
|
||||||
# viewport_poly is an array of the points that make up the corners of the viewport
|
# viewport_poly is an array of the points that make up the corners of the viewport
|
||||||
var viewport_poly := [
|
var viewport_poly: PackedVector2Array = [
|
||||||
Vector2.ZERO, Vector2(viewport_size.x, 0), viewport_size, Vector2(0, viewport_size.y)
|
Vector2.ZERO, Vector2(viewport_size.x, 0), viewport_size, Vector2(0, viewport_size.y)
|
||||||
]
|
]
|
||||||
# Adjusting viewport_poly to take into account the camera offset, zoom, and rotation
|
# Adjusting viewport_poly to take into account the camera offset, zoom, and rotation
|
||||||
|
|
|
@ -24,9 +24,9 @@ func _draw() -> void:
|
||||||
draw_set_transform(position_tmp, rotation, scale_tmp)
|
draw_set_transform(position_tmp, rotation, scale_tmp)
|
||||||
|
|
||||||
for i in range(1, rate + 1):
|
for i in range(1, rate + 1):
|
||||||
var change: int = project.current_frame
|
var change := project.current_frame
|
||||||
change += i if type == FUTURE else -i
|
change += i if type == FUTURE else -i
|
||||||
if change == clamp(change, 0, project.frames.size() - 1):
|
if change == clampi(change, 0, project.frames.size() - 1):
|
||||||
var layer_i := 0
|
var layer_i := 0
|
||||||
for cel in project.frames[change].cels:
|
for cel in project.frames[change].cels:
|
||||||
var layer: BaseLayer = project.layers[layer_i]
|
var layer: BaseLayer = project.layers[layer_i]
|
||||||
|
|
|
@ -14,7 +14,9 @@ var image_exports: Array[Export.FileFormat] = [
|
||||||
Export.FileFormat.GIF,
|
Export.FileFormat.GIF,
|
||||||
Export.FileFormat.APNG
|
Export.FileFormat.APNG
|
||||||
]
|
]
|
||||||
var spritesheet_exports := [Export.FileFormat.PNG, Export.FileFormat.WEBP, Export.FileFormat.JPEG]
|
var spritesheet_exports: Array[Export.FileFormat]= [
|
||||||
|
Export.FileFormat.PNG, Export.FileFormat.WEBP, Export.FileFormat.JPEG
|
||||||
|
]
|
||||||
|
|
||||||
@onready var tabs: TabBar = $VBoxContainer/TabBar
|
@onready var tabs: TabBar = $VBoxContainer/TabBar
|
||||||
@onready var checker: ColorRect = $"%TransparentChecker"
|
@onready var checker: ColorRect = $"%TransparentChecker"
|
||||||
|
@ -158,7 +160,6 @@ func create_preview_container() -> VBoxContainer:
|
||||||
|
|
||||||
func create_preview_rect() -> TextureRect:
|
func create_preview_rect() -> TextureRect:
|
||||||
var preview := TextureRect.new()
|
var preview := TextureRect.new()
|
||||||
preview.expand = true
|
|
||||||
preview.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
preview.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||||
preview.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
preview.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||||
preview.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
preview.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||||
|
@ -180,7 +181,7 @@ func set_file_format_selector() -> void:
|
||||||
|
|
||||||
## Updates the suitable list of file formats. First is preferred.
|
## Updates the suitable list of file formats. First is preferred.
|
||||||
## Note that if the current format is in the list, it stays for consistency.
|
## Note that if the current format is in the list, it stays for consistency.
|
||||||
func _set_file_format_selector_suitable_file_formats(formats: Array) -> void:
|
func _set_file_format_selector_suitable_file_formats(formats: Array[Export.FileFormat]) -> void:
|
||||||
var project := Global.current_project
|
var project := Global.current_project
|
||||||
file_format_options.clear()
|
file_format_options.clear()
|
||||||
var needs_update := true
|
var needs_update := true
|
||||||
|
@ -362,8 +363,8 @@ func _on_FileFormat_item_selected(idx: int) -> void:
|
||||||
set_preview()
|
set_preview()
|
||||||
|
|
||||||
|
|
||||||
|
## Overwrite existing file
|
||||||
func _on_FileExistsAlert_confirmed() -> void:
|
func _on_FileExistsAlert_confirmed() -> void:
|
||||||
# Overwrite existing file
|
|
||||||
file_exists_alert_popup.dialog_text = Export.file_exists_alert
|
file_exists_alert_popup.dialog_text = Export.file_exists_alert
|
||||||
Export.stop_export = false
|
Export.stop_export = false
|
||||||
resume_export_function.emit()
|
resume_export_function.emit()
|
||||||
|
|
Loading…
Reference in a new issue