From 056cb76a46c71e1a7f4ac632b713a23a74e71b70 Mon Sep 17 00:00:00 2001 From: Manolis Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Sat, 6 Nov 2021 17:23:54 +0200 Subject: [PATCH] Minor code cleanups --- src/UI/Canvas/CameraMovement.gd | 10 ++++++---- src/UI/TopMenuContainer.gd | 19 ++++++------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/UI/Canvas/CameraMovement.gd b/src/UI/Canvas/CameraMovement.gd index 8cdc5639e..430fba014 100644 --- a/src/UI/Canvas/CameraMovement.gd +++ b/src/UI/Canvas/CameraMovement.gd @@ -25,7 +25,7 @@ func _ready() -> void: Global.zoom_level_spinbox.get_child(0).connect("focus_exited", self, "zoom_focus_exited") -func zoom_label_clicked(event :InputEvent): +func zoom_label_clicked(event :InputEvent) -> void: if event is InputEventMouseButton and event.button_index == BUTTON_LEFT: if event.doubleclick: Global.zoom_level_label.visible = false @@ -35,12 +35,12 @@ func zoom_label_clicked(event :InputEvent): Global.zoom_level_spinbox.get_child(0).grab_focus() #since the actual lineedit is the first child of spinbox -func zoom_value_changed(value): +func zoom_value_changed(value) -> void: if name == "Camera2D": zoom_camera_percent(value) -func zoom_focus_exited(): +func zoom_focus_exited() -> void: if Global.zoom_level_spinbox.value != round(100 / zoom.x): #If user pressed enter while editing if name == "Camera2D": zoom_camera_percent(Global.zoom_level_spinbox.value) @@ -207,7 +207,8 @@ func zoom_camera(dir : int) -> void: offset = offset + (-0.5 * viewport_size + mouse_pos) * (prev_zoom - zoom) zoom_changed() -func zoom_camera_percent(value :float): + +func zoom_camera_percent(value : float) -> void: var percent :float = (100.0 / value) var new_zoom = Vector2(percent, percent) if Global.smooth_zoom: @@ -217,6 +218,7 @@ func zoom_camera_percent(value :float): zoom = new_zoom zoom_changed() + func zoom_changed() -> void: update_transparent_checker_offset() if name == "Camera2D": diff --git a/src/UI/TopMenuContainer.gd b/src/UI/TopMenuContainer.gd index 03fb5d60c..ddc3bd593 100644 --- a/src/UI/TopMenuContainer.gd +++ b/src/UI/TopMenuContainer.gd @@ -8,12 +8,12 @@ enum ImageMenuId {SCALE_IMAGE, CENTRALIZE_IMAGE, CROP_IMAGE, RESIZE_CANVAS, FLIP enum SelectMenuId {SELECT_ALL, CLEAR_SELECTION, INVERT} enum HelpMenuId {VIEW_SPLASH_SCREEN, ONLINE_DOCS, ISSUE_TRACKER, OPEN_LOGS_FOLDER, CHANGELOG, ABOUT_PIXELORAMA} -var file_menu_button : MenuButton -var edit_menu_button : MenuButton -var view_menu_button : MenuButton -var image_menu_button : MenuButton -var select_menu_button : MenuButton -var help_menu_button : MenuButton +onready var file_menu_button : MenuButton = find_node("FileMenu") +onready var edit_menu_button : MenuButton = find_node("EditMenu") +onready var view_menu_button : MenuButton = find_node("ViewMenu") +onready var image_menu_button : MenuButton = find_node("ImageMenu") +onready var select_menu_button : MenuButton = find_node("SelectMenu") +onready var help_menu_button : MenuButton = find_node("HelpMenu") var file_menu : PopupMenu var view_menu : PopupMenu @@ -21,13 +21,6 @@ var zen_mode := false func _ready() -> void: - file_menu_button = find_node("FileMenu") - edit_menu_button = find_node("EditMenu") - view_menu_button = find_node("ViewMenu") - image_menu_button = find_node("ImageMenu") - select_menu_button = find_node("SelectMenu") - help_menu_button = find_node("HelpMenu") - setup_file_menu() setup_edit_menu() setup_view_menu()