mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +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:
|
||||
# frames from left to right, layers from bottom to top
|
||||
clamp(frame, 0, project.frames.size() - 1)
|
||||
clamp(layer, 0, project.layers.size() - 1)
|
||||
clampi(frame, 0, project.frames.size() - 1)
|
||||
clampi(layer, 0, project.layers.size() - 1)
|
||||
return project.frames[frame].cels[layer]
|
||||
|
||||
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(
|
||||
"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))
|
||||
current_project = projects[0]
|
||||
current_project.fill_color = default_fill_color
|
||||
|
@ -565,13 +565,13 @@ func notification_label(text: String) -> void:
|
|||
control.add_child(notif)
|
||||
|
||||
|
||||
func general_undo(project: Project = current_project) -> void:
|
||||
func general_undo(project:= current_project) -> void:
|
||||
project.undos -= 1
|
||||
var action_name := project.undo_redo.get_current_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
|
||||
project.undos = project.undo_redo.get_version()
|
||||
if control.redone:
|
||||
|
@ -580,7 +580,7 @@ func general_redo(project: Project = current_project) -> void:
|
|||
|
||||
|
||||
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:
|
||||
if undo:
|
||||
general_undo(project)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
class_name GIFAnimationExporter
|
||||
extends AImgIOBaseExporter
|
||||
# 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!
|
||||
## 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!
|
||||
|
||||
# Gif exporter
|
||||
## Gif exporter
|
||||
const GIFExporter := preload("res://addons/gdgifexporter/exporter.gd")
|
||||
const MedianCutQuantization := preload("res://addons/gdgifexporter/quantization/median_cut.gd")
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class_name AnimationTag
|
||||
extends RefCounted
|
||||
# A class for frame tag properties
|
||||
## A class for frame tag properties
|
||||
|
||||
var name: String
|
||||
var color: Color
|
||||
|
|
|
@ -50,7 +50,7 @@ func get_image() -> Image:
|
|||
func update_texture() -> void:
|
||||
texture_changed.emit()
|
||||
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
|
||||
if self in Global.current_project.frames[frame].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 new_objects := _cel.object_properties.duplicate()
|
||||
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.add_do_property(_cel, "object_properties", new_objects)
|
||||
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:
|
||||
var undo_redo: UndoRedo = Global.current_project.undo_redo
|
||||
var undo_redo := Global.current_project.undo_redo
|
||||
var new_properties := _cel.object_properties.duplicate()
|
||||
new_properties[object.id] = object.serialize()
|
||||
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
|
||||
# drawn if it can (except for the generic brush, when it's actually drawing them)
|
||||
## 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)
|
||||
func _draw_tool(pos: Vector2) -> PackedVector2Array:
|
||||
if !Global.current_project.layers[Global.current_project.current_layer].can_layer_get_drawn():
|
||||
return PackedVector2Array() # empty fallback
|
||||
|
|
|
@ -28,13 +28,13 @@ func _input(event: InputEvent) -> void:
|
|||
return
|
||||
visible = true
|
||||
if event is InputEventMouseMotion:
|
||||
var tmp_transform = get_canvas_transform().affine_inverse()
|
||||
var tmp_position = Global.main_viewport.get_local_mouse_position()
|
||||
var mouse_point = (tmp_transform.basis_xform(tmp_position) + tmp_transform.origin).snapped(
|
||||
var tmp_transform := get_canvas_transform().affine_inverse()
|
||||
var tmp_position := Global.main_viewport.get_local_mouse_position()
|
||||
var mouse_point := (tmp_transform.basis_xform(tmp_position) + tmp_transform.origin).snapped(
|
||||
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):
|
||||
visible = true
|
||||
else:
|
||||
|
@ -51,11 +51,11 @@ func _input(event: InputEvent) -> void:
|
|||
|
||||
func _draw() -> void:
|
||||
width = Global.camera.zoom.x * 2
|
||||
var viewport_size: Vector2 = Global.main_viewport.size
|
||||
var zoom: Vector2 = Global.camera.zoom
|
||||
var viewport_size := Global.main_viewport.size
|
||||
var zoom := Global.camera.zoom
|
||||
|
||||
# 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)
|
||||
]
|
||||
# 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)
|
||||
|
||||
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
|
||||
if change == clamp(change, 0, project.frames.size() - 1):
|
||||
if change == clampi(change, 0, project.frames.size() - 1):
|
||||
var layer_i := 0
|
||||
for cel in project.frames[change].cels:
|
||||
var layer: BaseLayer = project.layers[layer_i]
|
||||
|
|
|
@ -14,7 +14,9 @@ var image_exports: Array[Export.FileFormat] = [
|
|||
Export.FileFormat.GIF,
|
||||
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 checker: ColorRect = $"%TransparentChecker"
|
||||
|
@ -158,7 +160,6 @@ func create_preview_container() -> VBoxContainer:
|
|||
|
||||
func create_preview_rect() -> TextureRect:
|
||||
var preview := TextureRect.new()
|
||||
preview.expand = true
|
||||
preview.size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||
preview.size_flags_vertical = Control.SIZE_EXPAND_FILL
|
||||
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.
|
||||
## 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
|
||||
file_format_options.clear()
|
||||
var needs_update := true
|
||||
|
@ -362,8 +363,8 @@ func _on_FileFormat_item_selected(idx: int) -> void:
|
|||
set_preview()
|
||||
|
||||
|
||||
## Overwrite existing file
|
||||
func _on_FileExistsAlert_confirmed() -> void:
|
||||
# Overwrite existing file
|
||||
file_exists_alert_popup.dialog_text = Export.file_exists_alert
|
||||
Export.stop_export = false
|
||||
resume_export_function.emit()
|
||||
|
|
Loading…
Reference in a new issue