1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 09:09:47 +00:00

Add an underscore to private method's names

As a way to differentiate between public and private methods, as per the official GDScript naming convention. Haven't changed all of the codebase yet, just some scripts that had a lot of public methods. This fixed 4 of the 7 errors of the linter.
This commit is contained in:
Manolis Papadeas 2021-11-29 17:12:30 +02:00
parent 8a4a2ed188
commit e2a68c4ba4
8 changed files with 235 additions and 235 deletions

View file

@ -9,14 +9,14 @@ enum IconColorFrom { THEME, CUSTOM }
enum ButtonSize { SMALL, BIG }
var root_directory := "."
var window_title := "" setget title_changed # Why doesn't Godot have get_window_title()?
var window_title := "" setget _title_changed # Why doesn't Godot have get_window_title()?
var config_cache := ConfigFile.new()
var XDGDataPaths = preload("res://src/XDGDataPaths.gd")
var directory_module: Reference
var projects := [] # Array of Projects
var current_project: Project
var current_project_index := 0 setget project_changed
var current_project_index := 0 setget _project_changed
var panel_layout = PanelLayout.AUTO
var ui_tooltips := {}
@ -299,12 +299,12 @@ func redo(_frame_index := -1, _layer_index := -1, project: Project = current_pro
self.window_title = window_title + "(*)"
func title_changed(value: String) -> void:
func _title_changed(value: String) -> void:
window_title = value
OS.set_window_title(value)
func project_changed(value: int) -> void:
func _project_changed(value: int) -> void:
canvas.selection.transform_content_confirm()
current_project_index = value
current_project = projects[value]

View file

@ -24,7 +24,7 @@ var right_selected_color := -1
func _ready() -> void:
load_palettes()
_load_palettes()
func get_palettes() -> Dictionary:
@ -46,7 +46,7 @@ func does_palette_exist(palette_name: String) -> bool:
func select_palette(palette_path: String) -> void:
current_palette = palettes.get(palette_path)
clear_selected_colors()
_clear_selected_colors()
Global.config_cache.set_value("data", "last_palette", current_palette.name)
@ -56,14 +56,14 @@ func is_any_palette_selected() -> bool:
return false
func current_palette_save() -> String:
var save_path = ""
func _current_palette_save() -> String:
var save_path := ""
if current_palette:
save_path = save_palette(self.current_palette)
save_path = _save_palette(self.current_palette)
return save_path
func save_palette(palette: Palette) -> String:
func _save_palette(palette: Palette) -> String:
Global.directory_module.ensure_xdg_user_dirs_exist()
var palettes_write_path: String = Global.directory_module.get_palette_write_path()
@ -74,7 +74,7 @@ func save_palette(palette: Palette) -> String:
# If resource name changed remove the old palette file
if old_resource_name != palette.resource_name:
var old_palette = palettes_write_path.plus_file(old_resource_name) + ".tres"
delete_palette(old_palette)
_delete_palette(old_palette)
# Save palette
var save_path = palettes_write_path.plus_file(palette.resource_name) + ".tres"
@ -94,40 +94,40 @@ func create_new_palette(
add_alpha_colors: bool,
get_colors_from: int
) -> void:
check_palette_settings_values(name, width, height)
_check_palette_settings_values(name, width, height)
match preset:
NewPalettePresetType.EMPTY:
create_new_empty_palette(name, comment, width, height)
_create_new_empty_palette(name, comment, width, height)
NewPalettePresetType.FROM_CURRENT_PALETTE:
create_new_palette_from_current_palette(name, comment)
_create_new_palette_from_current_palette(name, comment)
NewPalettePresetType.FROM_CURRENT_SPRITE:
create_new_palette_from_current_sprite(
_create_new_palette_from_current_sprite(
name, comment, width, height, add_alpha_colors, get_colors_from
)
NewPalettePresetType.FROM_CURRENT_SELECTION:
create_new_palette_from_current_selection(
_create_new_palette_from_current_selection(
name, comment, width, height, add_alpha_colors, get_colors_from
)
func create_new_empty_palette(name: String, comment: String, width: int, height: int) -> void:
func _create_new_empty_palette(name: String, comment: String, width: int, height: int) -> void:
var new_palette: Palette = Palette.new(name, width, height, comment)
var palette_path := save_palette(new_palette)
var palette_path := _save_palette(new_palette)
palettes[palette_path] = new_palette
select_palette(palette_path)
func create_new_palette_from_current_palette(name: String, comment: String) -> void:
func _create_new_palette_from_current_palette(name: String, comment: String) -> void:
var new_palette: Palette = current_palette.duplicate()
new_palette.name = name
new_palette.comment = comment
new_palette.set_resource_name(name)
var palette_path := save_palette(new_palette)
var palette_path := _save_palette(new_palette)
palettes[palette_path] = new_palette
select_palette(palette_path)
func create_new_palette_from_current_selection(
func _create_new_palette_from_current_selection(
name: String,
comment: String,
width: int,
@ -143,10 +143,10 @@ func create_new_palette_from_current_selection(
var pos := Vector2(x, y)
if current_project.selection_bitmap.get_bit(pos):
pixels.append(pos)
fill_new_palette_with_colors(pixels, new_palette, add_alpha_colors, get_colors_from)
_fill_new_palette_with_colors(pixels, new_palette, add_alpha_colors, get_colors_from)
func create_new_palette_from_current_sprite(
func _create_new_palette_from_current_sprite(
name: String,
comment: String,
width: int,
@ -160,10 +160,10 @@ func create_new_palette_from_current_sprite(
for x in current_project.size.x:
for y in current_project.size.y:
pixels.append(Vector2(x, y))
fill_new_palette_with_colors(pixels, new_palette, add_alpha_colors, get_colors_from)
_fill_new_palette_with_colors(pixels, new_palette, add_alpha_colors, get_colors_from)
func fill_new_palette_with_colors(
func _fill_new_palette_with_colors(
pixels: Array, new_palette: Palette, add_alpha_colors: bool, get_colors_from: int
):
var current_project = Global.current_project
@ -196,26 +196,26 @@ func fill_new_palette_with_colors(
new_palette.add_color(color)
cel_image.unlock()
var palette_path := save_palette(new_palette)
var palette_path := _save_palette(new_palette)
palettes[palette_path] = new_palette
select_palette(palette_path)
func current_palette_edit(name: String, comment: String, width: int, height: int) -> void:
check_palette_settings_values(name, width, height)
_check_palette_settings_values(name, width, height)
current_palette.edit(name, width, height, comment)
var palette_path = current_palette_save()
var palette_path = _current_palette_save()
palettes[palette_path] = current_palette
func delete_palette(path: String) -> void:
func _delete_palette(path: String) -> void:
var dir = Directory.new()
dir.remove(path)
palettes.erase(path)
func current_palete_delete() -> void:
delete_palette(current_palette.resource_path)
_delete_palette(current_palette.resource_path)
if palettes.size() > 0:
select_palette(palettes.keys()[0])
@ -231,7 +231,7 @@ func current_palette_add_color(mouse_button: int, start_index: int = 0) -> void:
# Get color on left or right tool
var color = Tools.get_assigned_color(mouse_button)
current_palette.add_color(color, start_index)
current_palette_save()
_current_palette_save()
func current_palette_get_color(index: int) -> Color:
@ -240,30 +240,30 @@ func current_palette_get_color(index: int) -> Color:
func current_palette_set_color(index: int, color: Color) -> void:
current_palette.set_color(index, color)
current_palette_save()
_current_palette_save()
func current_palette_delete_color(index: int) -> void:
current_palette.remove_color(index)
current_palette_save()
_current_palette_save()
func current_palette_swap_colors(source_index: int, target_index: int) -> void:
current_palette.swap_colors(source_index, target_index)
select_color(BUTTON_LEFT, target_index)
current_palette_save()
_select_color(BUTTON_LEFT, target_index)
_current_palette_save()
func current_palette_copy_colors(from: int, to: int) -> void:
current_palette.copy_colors(from, to)
current_palette_save()
_current_palette_save()
func current_palette_insert_color(from: int, to: int) -> void:
var from_color = current_palette.colors[from]
current_palette.remove_color(from)
current_palette.insert_color(to, from_color.color)
current_palette_save()
_current_palette_save()
func current_palette_get_selected_color_index(mouse_button: int) -> int:
@ -287,10 +287,10 @@ func current_palette_select_color(mouse_button: int, index: int) -> void:
BUTTON_RIGHT:
Tools.assign_color(color, mouse_button)
select_color(mouse_button, index)
_select_color(mouse_button, index)
func select_color(mouse_button: int, index: int) -> void:
func _select_color(mouse_button: int, index: int) -> void:
match mouse_button:
BUTTON_LEFT:
left_selected_color = index
@ -298,7 +298,7 @@ func select_color(mouse_button: int, index: int) -> void:
right_selected_color = index
func clear_selected_colors() -> void:
func _clear_selected_colors() -> void:
left_selected_color = -1
right_selected_color = -1
@ -311,7 +311,7 @@ func current_palette_is_full() -> bool:
return current_palette.is_full()
func check_palette_settings_values(name: String, width: int, height: int) -> bool:
func _check_palette_settings_values(name: String, width: int, height: int) -> bool:
# Just in case. These values should be not allowed in gui.
if name.length() <= 0 or width <= 0 or height <= 0:
printerr("Palette width, height and name length must be greater than 0!")
@ -319,10 +319,10 @@ func check_palette_settings_values(name: String, width: int, height: int) -> boo
return true
func load_palettes() -> void:
func _load_palettes() -> void:
Global.directory_module.ensure_xdg_user_dirs_exist()
var search_locations = Global.directory_module.get_palette_search_path_in_order()
var priority_ordered_files := get_palette_priority_file_map(search_locations)
var priority_ordered_files := _get_palette_priority_file_map(search_locations)
var palettes_write_path: String = Global.directory_module.get_palette_write_path()
# Iterate backwards, so any palettes defined in default files
@ -345,7 +345,7 @@ func load_palettes() -> void:
if palette:
if make_copy:
# Makes a copy of the palette
save_palette(palette)
_save_palette(palette)
palette.resource_name = palette.resource_path.get_file().trim_suffix(".tres")
# On Windows for some reason paths can contain "res://" in front of them which breaks saving
palette.resource_path = palette.resource_path.trim_prefix("res://")
@ -372,13 +372,13 @@ func load_palettes() -> void:
# in particular, this also means you can run backwards on the result
# so that palettes with the given palette name in the higher priority
# directories override those set in lower priority directories :)
func get_palette_priority_file_map(looking_paths: Array) -> Array:
func _get_palette_priority_file_map(looking_paths: Array) -> Array:
var final_list := []
# Holds pattern files already found
var working_file_set: Dictionary = {}
for search_directory in looking_paths:
var to_add_files := []
var files = get_palette_files(search_directory)
var files = _get_palette_files(search_directory)
# files to check
for maybe_to_add in files:
if not maybe_to_add in working_file_set:
@ -391,7 +391,7 @@ func get_palette_priority_file_map(looking_paths: Array) -> Array:
# Get the palette files in a single directory.
# if it does not exist, return []
func get_palette_files(path: String) -> Array:
func _get_palette_files(path: String) -> Array:
var dir := Directory.new()
var results = []
@ -418,8 +418,8 @@ func get_palette_files(path: String) -> Array:
# Locate the highest priority palette by the given relative filename
# If none is found in the directories, then do nothing and return null
func get_best_palette_file_location(looking_paths: Array, fname: String): # -> String:
var priority_fmap: Array = get_palette_priority_file_map(looking_paths)
func _get_best_palette_file_location(looking_paths: Array, fname: String): # -> String:
var priority_fmap: Array = _get_palette_priority_file_map(looking_paths)
for i in range(len(looking_paths)):
var base_path: String = looking_paths[i]
var the_files: Array = priority_fmap[i]
@ -465,7 +465,7 @@ func import_palette(path: String) -> void:
palette = import_json_palette(text)
if palette:
var palette_path := save_palette(palette)
var palette_path := _save_palette(palette)
palettes[palette_path] = palette
select_palette(palette_path)
Global.palette_panel.setup_palettes_selector()

View file

@ -2,20 +2,20 @@ class_name Project
extends Reference
# A class for project properties.
var name := "" setget name_changed
var size: Vector2 setget size_changed
var name := "" setget _name_changed
var size: Vector2 setget _size_changed
var undo_redo: UndoRedo
var tile_mode: int = Global.TileMode.NONE
var tile_mode_rects := [] # Cached to avoid recalculation
var undos := 0 # The number of times we added undo properties
var has_changed := false setget has_changed_changed
var frames := [] setget frames_changed # Array of Frames (that contain Cels)
var layers := [] setget layers_changed # Array of Layers
var current_frame := 0 setget frame_changed
var current_layer := 0 setget layer_changed
var has_changed := false setget _has_changed_changed
var frames := [] setget _frames_changed # Array of Frames (that contain Cels)
var layers := [] setget _layers_changed # Array of Layers
var current_frame := 0 setget _frame_changed
var current_layer := 0 setget _layer_changed
var selected_cels := [[0, 0]] # Array of Arrays of 2 integers (frame & layer)
var animation_tags := [] setget animation_tags_changed # Array of AnimationTags
var animation_tags := [] setget _animation_tags_changed # Array of AnimationTags
var guides := [] # Array of Guides
var brushes := [] # Array of Images
var fps := 6.0
@ -54,7 +54,7 @@ func _init(_frames := [], _name := tr("untitled"), _size := Vector2(64, 64)) ->
name = _name
size = _size
selection_bitmap.create(size)
update_tile_mode_rects()
_update_tile_mode_rects()
undo_redo = UndoRedo.new()
@ -124,7 +124,7 @@ func change_project() -> void:
for container in Global.layers_container.get_children():
container.queue_free()
remove_cel_buttons()
_remove_cel_buttons()
for frame_id in Global.frame_ids.get_children():
Global.frame_ids.remove_child(frame_id)
@ -176,8 +176,8 @@ func change_project() -> void:
Global.disable_button(
Global.move_right_frame_button, frames.size() == 1 or current_frame == frames.size() - 1
)
toggle_layer_buttons_layers()
toggle_layer_buttons_current_layer()
_toggle_layer_buttons_layers()
_toggle_layer_buttons_current_layer()
self.animation_tags = animation_tags
@ -352,7 +352,7 @@ func deserialize(dict: Dictionary) -> void:
if dict.has("size_x") and dict.has("size_y"):
size.x = dict.size_x
size.y = dict.size_y
update_tile_mode_rects()
_update_tile_mode_rects()
selection_bitmap = resize_bitmap(selection_bitmap, size)
if dict.has("save_path"):
OpenSave.current_save_paths[Global.projects.find(self)] = dict.save_path
@ -424,21 +424,21 @@ func deserialize(dict: Dictionary) -> void:
fps = dict.fps
func name_changed(value: String) -> void:
func _name_changed(value: String) -> void:
name = value
Global.tabs.set_tab_title(Global.tabs.current_tab, name)
func size_changed(value: Vector2) -> void:
func _size_changed(value: Vector2) -> void:
size = value
update_tile_mode_rects()
_update_tile_mode_rects()
func frames_changed(value: Array) -> void:
func _frames_changed(value: Array) -> void:
Global.canvas.selection.transform_content_confirm()
frames = value
selected_cels.clear()
remove_cel_buttons()
_remove_cel_buttons()
for frame_id in Global.frame_ids.get_children():
Global.frame_ids.remove_child(frame_id)
@ -462,10 +462,10 @@ func frames_changed(value: Array) -> void:
layers[i].frame_container.add_child(cel_button)
set_timeline_first_and_last_frames()
_set_timeline_first_and_last_frames()
func layers_changed(value: Array) -> void:
func _layers_changed(value: Array) -> void:
layers = value
if Global.layers_changed_skip:
Global.layers_changed_skip = false
@ -476,7 +476,7 @@ func layers_changed(value: Array) -> void:
for container in Global.layers_container.get_children():
container.queue_free()
remove_cel_buttons()
_remove_cel_buttons()
for i in range(layers.size() - 1, -1, -1):
var layer_container = layer_button_node.instance()
@ -502,10 +502,10 @@ func layers_changed(value: Array) -> void:
)
layer_button.pressed = true
self.current_frame = current_frame # Call frame_changed to update UI
toggle_layer_buttons_layers()
_toggle_layer_buttons_layers()
func remove_cel_buttons() -> void:
func _remove_cel_buttons() -> void:
for container in Global.frames_container.get_children():
for button in container.get_children():
container.remove_child(button)
@ -513,7 +513,7 @@ func remove_cel_buttons() -> void:
Global.frames_container.remove_child(container)
func frame_changed(value: int) -> void:
func _frame_changed(value: int) -> void:
Global.canvas.selection.transform_content_confirm()
current_frame = value
Global.current_frame_mark_label.text = "%s/%s" % [str(current_frame + 1), frames.size()]
@ -560,11 +560,11 @@ func frame_changed(value: int) -> void:
Global.transparent_checker.update_rect()
func layer_changed(value: int) -> void:
func _layer_changed(value: int) -> void:
Global.canvas.selection.transform_content_confirm()
current_layer = value
toggle_layer_buttons_current_layer()
_toggle_layer_buttons_current_layer()
yield(Global.get_tree().create_timer(0.01), "timeout")
self.current_frame = current_frame # Call frame_changed to update UI
@ -580,7 +580,7 @@ func layer_changed(value: int) -> void:
layer_button.pressed = true
func toggle_layer_buttons_layers() -> void:
func _toggle_layer_buttons_layers() -> void:
if !layers:
return
if layers[current_layer].locked:
@ -595,7 +595,7 @@ func toggle_layer_buttons_layers() -> void:
Global.disable_button(Global.remove_layer_button, false)
func toggle_layer_buttons_current_layer() -> void:
func _toggle_layer_buttons_current_layer() -> void:
if current_layer < layers.size() - 1:
Global.disable_button(Global.move_up_layer_button, false)
else:
@ -616,7 +616,7 @@ func toggle_layer_buttons_current_layer() -> void:
Global.disable_button(Global.remove_layer_button, false)
func animation_tags_changed(value: Array) -> void:
func _animation_tags_changed(value: Array) -> void:
animation_tags = value
for child in Global.tag_container.get_children():
child.queue_free()
@ -641,10 +641,10 @@ func animation_tags_changed(value: Array) -> void:
tag_c.get_node("Line2D").points[2] = Vector2(tag_c.rect_min_size.x, 0)
tag_c.get_node("Line2D").points[3] = Vector2(tag_c.rect_min_size.x, 32)
set_timeline_first_and_last_frames()
_set_timeline_first_and_last_frames()
func set_timeline_first_and_last_frames() -> void:
func _set_timeline_first_and_last_frames() -> void:
# This is useful in case tags get modified DURING the animation is playing
# otherwise, this code is useless in this context, since these values are being set
# when the play buttons get pressed anyway
@ -657,7 +657,7 @@ func set_timeline_first_and_last_frames() -> void:
Global.animation_timeline.last_frame = min(frames.size() - 1, tag.to - 1)
func has_changed_changed(value: bool) -> void:
func _has_changed_changed(value: bool) -> void:
has_changed = value
if value:
Global.tabs.set_tab_title(Global.tabs.current_tab, name + "(*)")
@ -669,7 +669,7 @@ func get_tile_mode_rect() -> Rect2:
return tile_mode_rects[tile_mode]
func update_tile_mode_rects() -> void:
func _update_tile_mode_rects() -> void:
tile_mode_rects.resize(Global.TileMode.size())
tile_mode_rects[Global.TileMode.NONE] = Rect2(Vector2.ZERO, size)
tile_mode_rects[Global.TileMode.BOTH] = Rect2(Vector2(-1, -1) * size, Vector2(3, 3) * size)

View file

@ -39,12 +39,12 @@ func _ready() -> void:
alternate_transparent_background.anchor_bottom = ANCHOR_END
get_tree().set_auto_accept_quit(false)
setup_application_window_size()
_setup_application_window_size()
handle_resize()
get_tree().get_root().connect("size_changed", self, "handle_resize")
if OS.get_name() == "OSX":
use_osx_shortcuts()
_use_osx_shortcuts()
Input.set_custom_mouse_cursor(cursor_image, Input.CURSOR_CROSS, Vector2(15, 15))
Global.window_title = tr("untitled") + " - Pixelorama " + Global.current_version
@ -86,7 +86,7 @@ func _ready() -> void:
zstd_checkbox.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
Global.save_sprites_dialog.get_vbox().add_child(zstd_checkbox)
handle_backup()
_handle_backup()
# If the user wants to run Pixelorama with arguments in terminal mode
# or open files with Pixelorama directly, then handle that
@ -97,7 +97,7 @@ func _ready() -> void:
if OS.get_name() == "Android":
OS.request_permissions()
show_splash_screen()
_show_splash_screen()
func handle_resize() -> void:
@ -109,12 +109,12 @@ func handle_resize() -> void:
(aspect_ratio <= 3.0 / 4.0 and Global.panel_layout != Global.PanelLayout.WIDESCREEN)
or Global.panel_layout == Global.PanelLayout.TALLSCREEN
):
change_ui_layout("tallscreen")
_change_ui_layout("tallscreen")
else:
change_ui_layout("widescreen")
_change_ui_layout("widescreen")
func change_ui_layout(mode: String) -> void:
func _change_ui_layout(mode: String) -> void:
var colorpicker_is_switched = (
true
if tool_and_palette_vsplit.has_node("ScrollContainer")
@ -127,14 +127,14 @@ func change_ui_layout(mode: String) -> void:
if !Global.top_menu_container.zen_mode:
tallscreen_hsplit.visible = true
tallscreen_hsplit.split_offset = tools_and_canvas.split_offset
reparent_node_to(Global.animation_timeline, tallscreen_hsplit.get_node("BottomPanel"), 0)
reparent_node_to(right_panel, bottom_panel, 0)
_reparent_node_to(Global.animation_timeline, tallscreen_hsplit.get_node("BottomPanel"), 0)
_reparent_node_to(right_panel, bottom_panel, 0)
right_panel.rect_min_size.y = 322
reparent_node_to(canvas_preview_container, tool_and_palette_vsplit, 1)
tool_and_palette_vsplit = replace_node_with(tool_and_palette_vsplit, HBoxContainer.new())
_reparent_node_to(canvas_preview_container, tool_and_palette_vsplit, 1)
tool_and_palette_vsplit = _replace_node_with(tool_and_palette_vsplit, HBoxContainer.new())
tool_and_palette_vsplit.set("custom_constants/separation", 8)
color_and_tool_options.rect_min_size.x = 280
reparent_node_to(tool_panel, tallscreen_hsplit, 0)
_reparent_node_to(tool_panel, tallscreen_hsplit, 0)
var right_panel_margin: MarginContainer = right_panel.find_node(
"MarginContainer", true, false
@ -147,18 +147,18 @@ func change_ui_layout(mode: String) -> void:
elif mode == "widescreen" and tallscreen_is_active:
tallscreen_is_active = false
# Reparenting and hiding nodes to adjust wide-screen
reparent_node_to(
_reparent_node_to(
Global.animation_timeline, ui.get_node("ToolsAndCanvas/CanvasAndTimeline"), 1
)
tallscreen_hsplit.visible = false
tools_and_canvas.split_offset = tallscreen_hsplit.split_offset
reparent_node_to(right_panel, ui, -1)
_reparent_node_to(right_panel, ui, -1)
right_panel.rect_min_size.y = 0
reparent_node_to(canvas_preview_container, right_panel.find_node("PreviewAndPalettes"), 0)
tool_and_palette_vsplit = replace_node_with(tool_and_palette_vsplit, VSplitContainer.new())
_reparent_node_to(canvas_preview_container, right_panel.find_node("PreviewAndPalettes"), 0)
tool_and_palette_vsplit = _replace_node_with(tool_and_palette_vsplit, VSplitContainer.new())
color_and_tool_options.rect_min_size.x = 0
canvas_preview_container.visible = true
reparent_node_to(tool_panel, ui.find_node("ToolsAndCanvas"), 0)
_reparent_node_to(tool_panel, ui.find_node("ToolsAndCanvas"), 0)
var right_panel_margin: MarginContainer = right_panel.find_node(
"MarginContainer", true, false
@ -174,28 +174,28 @@ func change_ui_layout(mode: String) -> void:
canvas_preview_container.visible = true
if not colorpicker_is_switched and canvas_preview_container.visible and mode == "tallscreen":
reparent_node_to(scroll_container, tool_and_palette_vsplit, 0)
_reparent_node_to(scroll_container, tool_and_palette_vsplit, 0)
scroll_container.rect_min_size = Vector2(268, 196)
color_and_tool_options.set("custom_constants/separation", 20)
reparent_node_to(canvas_preview_container, color_and_tool_options, -1)
_reparent_node_to(canvas_preview_container, color_and_tool_options, -1)
elif colorpicker_is_switched and (not canvas_preview_container.visible or mode != "tallscreen"):
reparent_node_to(scroll_container, color_and_tool_options, -1)
_reparent_node_to(scroll_container, color_and_tool_options, -1)
scroll_container.rect_min_size = Vector2(0, 0)
color_and_tool_options.set("custom_constants/separation", 8)
if mode == "widescreen":
reparent_node_to(
_reparent_node_to(
canvas_preview_container,
right_panel.find_node("PreviewAndPalettes", true, false),
0
)
else:
reparent_node_to(canvas_preview_container, tool_and_palette_vsplit, 1)
_reparent_node_to(canvas_preview_container, tool_and_palette_vsplit, 1)
# helper function (change_ui_layout)
# helper function (_change_ui_layout)
# warning: this doesn't really copy any sort of attributes, except a few that
# were needed in my particular case
func replace_node_with(old: Node, new: Node) -> Node:
func _replace_node_with(old: Node, new: Node) -> Node:
var tempname = old.name
old.name = "old"
new.name = tempname
@ -207,14 +207,14 @@ func replace_node_with(old: Node, new: Node) -> Node:
new.set("custom_constants/separation", 20)
old.get_parent().add_child(new)
for n in old.get_children():
reparent_node_to(n, new, -1)
_reparent_node_to(n, new, -1)
old.get_parent().remove_child(old)
old.queue_free()
return new
# helper function (change_ui_layout)
func reparent_node_to(node: Node, dest: Node, pos: int) -> bool:
# helper function (_change_ui_layout)
func _reparent_node_to(node: Node, dest: Node, pos: int) -> bool:
if dest is Node and node is Node:
node.get_parent().remove_child(node)
dest.add_child(node)
@ -255,7 +255,7 @@ func _input(event: InputEvent) -> void:
Global.current_project.commit_undo()
func setup_application_window_size() -> void:
func _setup_application_window_size() -> void:
if OS.get_name() == "HTML5":
return
# Set a minimum window size to prevent UI elements from collapsing on each other.
@ -281,7 +281,7 @@ func setup_application_window_size() -> void:
OS.window_size = Global.config_cache.get_value("window", "size")
func show_splash_screen() -> void:
func _show_splash_screen() -> void:
if not Global.config_cache.has_section_key("preferences", "startup"):
Global.config_cache.set_value("preferences", "startup", true)
@ -296,7 +296,7 @@ func show_splash_screen() -> void:
Global.can_draw = true
func handle_backup() -> void:
func _handle_backup() -> void:
# If backup file exists, Pixelorama was not closed properly (probably crashed) - reopen backup
var backup_confirmation: ConfirmationDialog = $Dialogs/BackupConfirmation
backup_confirmation.get_cancel().text = tr("Delete")
@ -487,7 +487,7 @@ func _on_BackupConfirmation_popup_hide() -> void:
OpenSave.autosave_timer.start()
func use_osx_shortcuts() -> void:
func _use_osx_shortcuts() -> void:
var inputmap := InputMap
for action in inputmap.get_actions():

View file

@ -35,13 +35,13 @@ func _ready() -> void:
# Make sure locales are always sorted, in the same order
loaded_locales.sort()
var button_group = get_child(0).group
var button_group: ButtonGroup = get_child(0).group
# Create radiobuttons for each language
for locale in loaded_locales:
if !locale in LANGUAGES_DICT:
continue
var button = CheckBox.new()
var button := CheckBox.new()
button.text = LANGUAGES_DICT[locale][0] + " [%s]" % [locale]
button.name = LANGUAGES_DICT[locale][1]
button.hint_tooltip = LANGUAGES_DICT[locale][1]

View file

@ -37,20 +37,20 @@ func _ready() -> void:
update_transparent_checker_offset()
# signals regarding rotation stats
Global.rotation_level_button.connect("pressed", self, "rotation_button_pressed")
Global.rotation_level_spinbox.connect("value_changed", self, "rotation_value_changed")
Global.rotation_level_button.connect("pressed", self, "_rotation_button_pressed")
Global.rotation_level_spinbox.connect("value_changed", self, "_rotation_value_changed")
Global.rotation_level_spinbox.get_child(0).connect(
"focus_exited", self, "rotation_focus_exited"
"focus_exited", self, "_rotation_focus_exited"
)
# signals regarding zoom stats
Global.zoom_level_button.connect("pressed", self, "zoom_button_pressed")
Global.zoom_level_spinbox.connect("value_changed", self, "zoom_value_changed")
Global.zoom_level_button.connect("pressed", self, "_zoom_button_pressed")
Global.zoom_level_spinbox.connect("value_changed", self, "_zoom_value_changed")
Global.zoom_level_spinbox.max_value = 100.0 / zoom_min.x
Global.zoom_level_spinbox.get_child(0).connect("focus_exited", self, "zoom_focus_exited")
Global.zoom_level_spinbox.get_child(0).connect("focus_exited", self, "_zoom_focus_exited")
func rotation_button_pressed() -> void:
func _rotation_button_pressed() -> void:
Global.rotation_level_button.visible = false
Global.rotation_level_spinbox.visible = true
Global.rotation_level_spinbox.editable = true
@ -61,22 +61,22 @@ func rotation_button_pressed() -> void:
Global.rotation_level_spinbox.get_child(0).grab_focus()
func rotation_value_changed(value) -> void:
func _rotation_value_changed(value) -> void:
if index == Cameras.MAIN:
set_camera_rotation_degrees(-value) # Negative makes going up rotate clockwise
_set_camera_rotation_degrees(-value) # Negative makes going up rotate clockwise
func rotation_focus_exited() -> void:
func _rotation_focus_exited() -> void:
if Global.rotation_level_spinbox.value != rotation: # If user pressed enter while editing
if index == Cameras.MAIN:
# Negative makes going up rotate clockwise
set_camera_rotation_degrees(-Global.rotation_level_spinbox.value)
_set_camera_rotation_degrees(-Global.rotation_level_spinbox.value)
Global.rotation_level_button.visible = true
Global.rotation_level_spinbox.visible = false
Global.rotation_level_spinbox.editable = false
func zoom_button_pressed() -> void:
func _zoom_button_pressed() -> void:
Global.zoom_level_button.visible = false
Global.zoom_level_spinbox.visible = true
Global.zoom_level_spinbox.editable = true
@ -85,12 +85,12 @@ func zoom_button_pressed() -> void:
Global.zoom_level_spinbox.get_child(0).grab_focus()
func zoom_value_changed(value) -> void:
func _zoom_value_changed(value) -> void:
if index == Cameras.MAIN:
zoom_camera_percent(value)
func zoom_focus_exited() -> void:
func _zoom_focus_exited() -> void:
if Global.zoom_level_spinbox.value != round(100 / zoom.x): # If user pressed enter while editing
if index == Cameras.MAIN:
zoom_camera_percent(Global.zoom_level_spinbox.value)
@ -108,7 +108,7 @@ func update_transparent_checker_offset() -> void:
# Get the speed multiplier for when you've pressed
# a movement key for the given amount of time
func dir_move_zoom_multiplier(press_time: float) -> float:
func _dir_move_zoom_multiplier(press_time: float) -> float:
if press_time < 0:
return 0.0
if Input.is_key_pressed(KEY_SHIFT) and Input.is_key_pressed(KEY_CONTROL):
@ -123,12 +123,12 @@ func dir_move_zoom_multiplier(press_time: float) -> float:
return 0.0
func reset_dir_move_time(direction) -> void:
func _reset_dir_move_time(direction) -> void:
key_move_press_time[direction] = 0.0
# Check if an event is a ui_up/down/left/right event-press :)
func is_action_direction_pressed(event: InputEvent, allow_echo: bool = true) -> bool:
func _is_action_direction_pressed(event: InputEvent, allow_echo: bool = true) -> bool:
for slot in Tools._slots.values():
if slot.tool_node is SelectionTool:
return false
@ -139,7 +139,7 @@ func is_action_direction_pressed(event: InputEvent, allow_echo: bool = true) ->
# Check if an event is a ui_up/down/left/right event release nya
func is_action_direction_released(event: InputEvent) -> bool:
func _is_action_direction_released(event: InputEvent) -> bool:
for slot in Tools._slots.values():
if slot.tool_node is SelectionTool:
return false
@ -151,7 +151,7 @@ func is_action_direction_released(event: InputEvent) -> bool:
# get the Direction associated with the event.
# if not a direction event return null
func get_action_direction(event: InputEvent): # -> Optional[Direction]
func _get_action_direction(event: InputEvent): # -> Optional[Direction]
if event.is_action("ui_up"):
return Direction.UP
elif event.is_action("ui_down"):
@ -165,29 +165,29 @@ func get_action_direction(event: InputEvent): # -> Optional[Direction]
# Process an action event for a pressed direction
# action
func process_direction_action_pressed(event: InputEvent) -> void:
var dir = get_action_direction(event)
func _process_direction_action_pressed(event: InputEvent) -> void:
var dir = _get_action_direction(event)
if dir == null:
return
var increment := get_process_delta_time()
# Count the total time we've been doing this ^.^
key_move_press_time[dir] += increment
var this_direction_press_time: float = key_move_press_time[dir]
var move_speed := dir_move_zoom_multiplier(this_direction_press_time)
var move_speed := _dir_move_zoom_multiplier(this_direction_press_time)
offset = (
offset
+ move_speed * increment * DIRECTIONAL_SIGN_MULTIPLIERS[dir].rotated(rotation) * zoom
)
update_rulers()
_update_rulers()
update_transparent_checker_offset()
# Process an action for a release direction action
func process_direction_action_released(event: InputEvent) -> void:
var dir = get_action_direction(event)
func _process_direction_action_released(event: InputEvent) -> void:
var dir = _get_action_direction(event)
if dir == null:
return
reset_dir_move_time(dir)
_reset_dir_move_time(dir)
func _input(event: InputEvent) -> void:
@ -219,24 +219,24 @@ func _input(event: InputEvent) -> void:
elif event is InputEventMouseMotion && drag:
offset = offset - event.relative.rotated(rotation) * zoom
update_transparent_checker_offset()
update_rulers()
_update_rulers()
elif event is InputEventKey:
if is_action_direction_pressed(event):
process_direction_action_pressed(event)
elif is_action_direction_released(event):
process_direction_action_released(event)
if _is_action_direction_pressed(event):
_process_direction_action_pressed(event)
elif _is_action_direction_released(event):
_process_direction_action_released(event)
save_values_to_project()
# Rotate Camera
func rotate_camera_around_point(degrees: float, point: Vector2) -> void:
func _rotate_camera_around_point(degrees: float, point: Vector2) -> void:
offset = (offset - point).rotated(deg2rad(degrees)) + point
rotation_degrees = wrapf(rotation_degrees + degrees, -180, 180)
rotation_changed()
func set_camera_rotation_degrees(degrees: float) -> void:
func _set_camera_rotation_degrees(degrees: float) -> void:
var difference := degrees - rotation_degrees
var canvas_center: Vector2 = Global.current_project.size / 2
offset = (offset - canvas_center).rotated(deg2rad(difference)) + canvas_center
@ -248,7 +248,7 @@ func rotation_changed() -> void:
if index == Cameras.MAIN:
# Negative to make going up in value clockwise, and match the spinbox which does the same
Global.rotation_level_button.text = str(wrapi(round(-rotation_degrees), -180, 180)) + " °"
update_rulers()
_update_rulers()
# Zoom Camera
@ -301,7 +301,7 @@ func zoom_changed() -> void:
if index == Cameras.MAIN:
Global.zoom_level_button.text = str(round(100 / zoom.x)) + " %"
Global.canvas.pixel_grid.update()
update_rulers()
_update_rulers()
for guide in Global.current_project.guides:
guide.width = zoom.x * 2
@ -311,7 +311,7 @@ func zoom_changed() -> void:
Global.preview_zoom_slider.value = -zoom.x
func update_rulers() -> void:
func _update_rulers() -> void:
Global.horizontal_ruler.update()
Global.vertical_ruler.update()

View file

@ -88,7 +88,7 @@ func _input(event: InputEvent) -> void:
elif Input.is_action_just_pressed("escape"):
transform_content_cancel()
move_with_arrow_keys(event)
_move_with_arrow_keys(event)
elif event is InputEventMouse:
var gizmo: Gizmo
@ -157,12 +157,12 @@ func _input(event: InputEvent) -> void:
if dragged_gizmo:
if dragged_gizmo.type == Gizmo.Type.SCALE:
gizmo_resize()
_gizmo_resize()
else:
gizmo_rotate()
_gizmo_rotate()
func move_with_arrow_keys(event: InputEvent) -> void:
func _move_with_arrow_keys(event: InputEvent) -> void:
var selection_tool_selected := false
for slot in Tools._slots.values():
if slot.tool_node is SelectionTool:
@ -174,18 +174,18 @@ func move_with_arrow_keys(event: InputEvent) -> void:
if Global.current_project.has_selection:
if !Global.current_project.layers[Global.current_project.current_layer].can_layer_get_drawn():
return
if is_action_direction_pressed(event) and !arrow_key_move:
if _is_action_direction_pressed(event) and !arrow_key_move:
arrow_key_move = true
if Input.is_key_pressed(KEY_ALT):
transform_content_confirm()
move_borders_start()
else:
transform_content_start()
if is_action_direction_released(event) and arrow_key_move:
if _is_action_direction_released(event) and arrow_key_move:
arrow_key_move = false
move_borders_end()
if is_action_direction(event) and arrow_key_move:
if _is_action_direction(event) and arrow_key_move:
var step := Vector2.ONE
if Input.is_key_pressed(KEY_CONTROL):
step = Vector2(Global.grid_width, Global.grid_height)
@ -196,7 +196,7 @@ func move_with_arrow_keys(event: InputEvent) -> void:
# Check if an event is a ui_up/down/left/right event-press
func is_action_direction_pressed(event: InputEvent) -> bool:
func _is_action_direction_pressed(event: InputEvent) -> bool:
for action in KEY_MOVE_ACTION_NAMES:
if event.is_action_pressed(action):
return true
@ -204,7 +204,7 @@ func is_action_direction_pressed(event: InputEvent) -> bool:
# Check if an event is a ui_up/down/left/right event release
func is_action_direction(event: InputEvent) -> bool:
func _is_action_direction(event: InputEvent) -> bool:
for action in KEY_MOVE_ACTION_NAMES:
if event.is_action(action):
return true
@ -212,7 +212,7 @@ func is_action_direction(event: InputEvent) -> bool:
# Check if an event is a ui_up/down/left/right event release
func is_action_direction_released(event: InputEvent) -> bool:
func _is_action_direction_released(event: InputEvent) -> bool:
for action in KEY_MOVE_ACTION_NAMES:
if event.is_action_released(action):
return true
@ -245,10 +245,10 @@ func _big_bounding_rectangle_changed(value: Rect2) -> void:
for slot in Tools._slots.values():
if slot.tool_node is SelectionTool:
slot.tool_node.set_spinbox_values()
update_gizmos()
_update_gizmos()
func update_gizmos() -> void:
func _update_gizmos() -> void:
var rect_pos: Vector2 = big_bounding_rectangle.position
var rect_end: Vector2 = big_bounding_rectangle.end
var size: Vector2 = Vector2.ONE * Global.camera.zoom * 10
@ -283,10 +283,10 @@ func update_on_zoom(zoom: float) -> void:
for gizmo in gizmos:
if gizmo.rect.size == Vector2.ZERO:
return
update_gizmos()
_update_gizmos()
func gizmo_resize() -> void:
func _gizmo_resize() -> void:
var dir := dragged_gizmo.direction
if Input.is_action_pressed("ctrl"):
@ -300,7 +300,7 @@ func gizmo_resize() -> void:
temp_rect = Rect2(-1.0 * temp_rect.size / 2 + temp_rect_pivot, temp_rect.size)
else:
resize_rect(Global.canvas.current_pixel, dir)
_resize_rect(Global.canvas.current_pixel, dir)
if Input.is_action_pressed("shift"): # Maintain aspect ratio
var end_y = temp_rect.end.y
@ -354,7 +354,7 @@ func gizmo_resize() -> void:
update()
func resize_rect(pos: Vector2, dir: Vector2) -> void:
func _resize_rect(pos: Vector2, dir: Vector2) -> void:
if dir.x > 0:
temp_rect.size.x = pos.x - temp_rect.position.x
elif dir.x < 0:
@ -374,7 +374,7 @@ func resize_rect(pos: Vector2, dir: Vector2) -> void:
temp_rect.size.y = temp_rect_size.y
func gizmo_rotate() -> void: # Does not work properly yet
func _gizmo_rotate() -> void: # Does not work properly yet
var angle: float = Global.canvas.current_pixel.angle_to_point(mouse_pos_on_gizmo_drag)
angle = deg2rad(floor(rad2deg(angle)))
if angle == prev_angle:
@ -477,7 +477,7 @@ func transform_content_start() -> void:
undo_data = get_undo_data(true)
temp_rect = big_bounding_rectangle
temp_bitmap = Global.current_project.selection_bitmap
get_preview_image()
_get_preview_image()
if original_preview_image.is_empty():
undo_data = get_undo_data(false)
return
@ -507,7 +507,7 @@ func transform_content_confirm() -> void:
not is_pasting
and not (frame == project.current_frame and layer == project.current_layer)
):
src = get_selected_image(cel_image, clear_in_selected_cels)
src = _get_selected_image(cel_image, clear_in_selected_cels)
src.resize(
big_bounding_rectangle.size.x,
big_bounding_rectangle.size.y,
@ -805,7 +805,7 @@ func clear_selection(use_undo := false) -> void:
commit_undo("Clear Selection", undo_data_tmp)
func get_preview_image() -> void:
func _get_preview_image() -> void:
var project: Project = Global.current_project
var cel_image: Image = project.frames[project.current_frame].cels[project.current_layer].image
if original_preview_image.is_empty():
@ -842,7 +842,7 @@ func get_preview_image() -> void:
Global.canvas.update_texture(project.current_layer)
func get_selected_image(cel_image: Image, clear := true) -> Image:
func _get_selected_image(cel_image: Image, clear := true) -> Image:
var project: Project = Global.current_project
var image := Image.new()
image = cel_image.get_rect(original_big_bounding_rectangle)

View file

@ -59,15 +59,15 @@ onready var recent_projects_submenu := PopupMenu.new()
func _ready() -> void:
setup_file_menu()
setup_edit_menu()
setup_view_menu()
setup_image_menu()
setup_select_menu()
setup_help_menu()
_setup_file_menu()
_setup_edit_menu()
_setup_view_menu()
_setup_image_menu()
_setup_select_menu()
_setup_help_menu()
func setup_file_menu() -> void:
func _setup_file_menu() -> void:
var file_menu_items := { # order as in FileMenuId enum
"New...": InputMap.get_action_list("new_file")[0].get_scancode_with_modifiers(),
"Open...": InputMap.get_action_list("open_file")[0].get_scancode_with_modifiers(),
@ -84,7 +84,7 @@ func setup_file_menu() -> void:
for item in file_menu_items.keys():
if item == "Recent projects":
setup_recent_projects_submenu(item)
_setup_recent_projects_submenu(item)
else:
file_menu.add_item(item, i, file_menu_items[item])
i += 1
@ -96,9 +96,9 @@ func setup_file_menu() -> void:
file_menu.set_item_disabled(FileMenuId.SAVE, true)
func setup_recent_projects_submenu(item: String) -> void:
func _setup_recent_projects_submenu(item: String) -> void:
recent_projects = Global.config_cache.get_value("data", "recent_projects", [])
recent_projects_submenu.connect("id_pressed", self, "on_recent_projects_submenu_id_pressed")
recent_projects_submenu.connect("id_pressed", self, "_on_recent_projects_submenu_id_pressed")
update_recent_projects_submenu()
file_menu.add_child(recent_projects_submenu)
@ -110,7 +110,7 @@ func update_recent_projects_submenu() -> void:
recent_projects_submenu.add_item(project.get_file())
func setup_edit_menu() -> void:
func _setup_edit_menu() -> void:
var edit_menu_items := { # order as in EditMenuId enum
"Undo": InputMap.get_action_list("undo")[0].get_scancode_with_modifiers(),
"Redo": InputMap.get_action_list("redo")[0].get_scancode_with_modifiers(),
@ -132,7 +132,7 @@ func setup_edit_menu() -> void:
edit_menu.connect("id_pressed", self, "edit_menu_id_pressed")
func setup_view_menu() -> void:
func _setup_view_menu() -> void:
var view_menu_items := { # order as in ViewMenuId enum
"Tile Mode": 0,
"Window Opacity": 0,
@ -153,11 +153,11 @@ func setup_view_menu() -> void:
var i := 0
for item in view_menu_items.keys():
if item == "Tile Mode":
setup_tile_mode_submenu(item)
_setup_tile_mode_submenu(item)
elif item == "Window Opacity":
view_menu.add_item(item, i, view_menu_items[item])
elif item == "Panel Layout":
setup_panel_layout_submenu(item)
_setup_panel_layout_submenu(item)
else:
view_menu.add_check_item(item, i, view_menu_items[item])
i += 1
@ -173,7 +173,7 @@ func setup_view_menu() -> void:
)
func setup_tile_mode_submenu(item: String):
func _setup_tile_mode_submenu(item: String) -> void:
tile_mode_submenu.set_name("tile_mode_submenu")
tile_mode_submenu.add_radio_check_item("None", Global.TileMode.NONE)
tile_mode_submenu.set_item_checked(Global.TileMode.NONE, true)
@ -182,12 +182,12 @@ func setup_tile_mode_submenu(item: String):
tile_mode_submenu.add_radio_check_item("Tiled In Y Axis", Global.TileMode.Y_AXIS)
tile_mode_submenu.hide_on_checkable_item_selection = false
tile_mode_submenu.connect("id_pressed", self, "tile_mode_submenu_id_pressed")
tile_mode_submenu.connect("id_pressed", self, "_tile_mode_submenu_id_pressed")
view_menu.add_child(tile_mode_submenu)
view_menu.add_submenu_item(item, tile_mode_submenu.get_name())
func setup_panel_layout_submenu(item: String):
func _setup_panel_layout_submenu(item: String) -> void:
panel_layout_submenu.set_name("panel_layout_submenu")
panel_layout_submenu.add_radio_check_item("Auto", Global.PanelLayout.AUTO)
panel_layout_submenu.add_radio_check_item("Widescreen", Global.PanelLayout.WIDESCREEN)
@ -195,12 +195,12 @@ func setup_panel_layout_submenu(item: String):
panel_layout_submenu.hide_on_checkable_item_selection = false
panel_layout_submenu.set_item_checked(Global.panel_layout, true)
panel_layout_submenu.connect("id_pressed", self, "panel_layout_submenu_id_pressed")
panel_layout_submenu.connect("id_pressed", self, "_panel_layout_submenu_id_pressed")
view_menu.add_child(panel_layout_submenu)
view_menu.add_submenu_item(item, panel_layout_submenu.get_name())
func setup_image_menu() -> void:
func _setup_image_menu() -> void:
var image_menu_items := { # order as in ImageMenuId enum
"Scale Image": 0,
"Centralize Image": 0,
@ -227,7 +227,7 @@ func setup_image_menu() -> void:
image_menu.connect("id_pressed", self, "image_menu_id_pressed")
func setup_select_menu() -> void:
func _setup_select_menu() -> void:
var select_menu_items := { # order as in EditMenuId enum
"All": InputMap.get_action_list("select_all")[0].get_scancode_with_modifiers(),
"Clear": InputMap.get_action_list("clear_selection")[0].get_scancode_with_modifiers(),
@ -243,7 +243,7 @@ func setup_select_menu() -> void:
select_menu.connect("id_pressed", self, "select_menu_id_pressed")
func setup_help_menu() -> void:
func _setup_help_menu() -> void:
var help_menu_items := { # order as in HelpMenuId enum
"View Splash Screen": 0,
"Online Docs": InputMap.get_action_list("open_docs")[0].get_scancode_with_modifiers(),
@ -265,17 +265,17 @@ func setup_help_menu() -> void:
func file_menu_id_pressed(id: int) -> void:
match id:
FileMenuId.NEW:
on_new_project_file_menu_option_pressed()
_on_new_project_file_menu_option_pressed()
FileMenuId.OPEN:
open_project_file()
_open_project_file()
FileMenuId.OPEN_LAST_PROJECT:
on_open_last_project_file_menu_option_pressed()
_on_open_last_project_file_menu_option_pressed()
FileMenuId.SAVE:
save_project_file()
_save_project_file()
FileMenuId.SAVE_AS:
save_project_file_as()
_save_project_file_as()
FileMenuId.EXPORT:
export_file()
_export_file()
FileMenuId.EXPORT_AS:
Global.export_dialog.popup_centered()
Global.dialog_open(true)
@ -283,12 +283,12 @@ func file_menu_id_pressed(id: int) -> void:
Global.control.show_quit_dialog()
func on_new_project_file_menu_option_pressed() -> void:
func _on_new_project_file_menu_option_pressed() -> void:
new_image_dialog.popup_centered()
Global.dialog_open(true)
func open_project_file() -> void:
func _open_project_file() -> void:
if OS.get_name() == "HTML5":
Html5FileExchange.load_image()
else:
@ -297,7 +297,7 @@ func open_project_file() -> void:
Global.control.opensprite_file_selected = false
func on_open_last_project_file_menu_option_pressed() -> void:
func _on_open_last_project_file_menu_option_pressed() -> void:
if Global.config_cache.has_section_key("preferences", "last_project_path"):
Global.control.load_last_project()
else:
@ -306,7 +306,7 @@ func on_open_last_project_file_menu_option_pressed() -> void:
Global.dialog_open(true)
func save_project_file() -> void:
func _save_project_file() -> void:
Global.control.is_quitting_on_save = false
var path = OpenSave.current_save_paths[Global.current_project_index]
if path == "":
@ -323,7 +323,7 @@ func save_project_file() -> void:
Global.control.save_project(path)
func save_project_file_as() -> void:
func _save_project_file_as() -> void:
Global.control.is_quitting_on_save = false
if OS.get_name() == "HTML5":
var save_dialog: ConfirmationDialog = Global.save_sprites_html5_dialog
@ -336,7 +336,7 @@ func save_project_file_as() -> void:
Global.dialog_open(true)
func export_file() -> void:
func _export_file() -> void:
if Export.was_exported == false:
Global.export_dialog.popup_centered()
Global.dialog_open(true)
@ -344,7 +344,7 @@ func export_file() -> void:
Export.external_export()
func on_recent_projects_submenu_id_pressed(id: int) -> void:
func _on_recent_projects_submenu_id_pressed(id: int) -> void:
Global.control.load_recent_project_file(recent_projects[id])
@ -375,25 +375,25 @@ func view_menu_id_pressed(id: int) -> void:
window_opacity_dialog.popup_centered()
Global.dialog_open(true)
ViewMenuId.MIRROR_VIEW:
toggle_mirror_view()
_toggle_mirror_view()
ViewMenuId.SHOW_GRID:
toggle_show_grid()
_toggle_show_grid()
ViewMenuId.SHOW_PIXEL_GRID:
toggle_show_pixel_grid()
_toggle_show_pixel_grid()
ViewMenuId.SHOW_RULERS:
toggle_show_rulers()
_toggle_show_rulers()
ViewMenuId.SHOW_GUIDES:
toggle_show_guides()
_toggle_show_guides()
ViewMenuId.SHOW_ANIMATION_TIMELINE:
toggle_show_anim_timeline()
_toggle_show_anim_timeline()
ViewMenuId.ZEN_MODE:
toggle_zen_mode()
_toggle_zen_mode()
ViewMenuId.FULLSCREEN_MODE:
toggle_fullscreen()
_toggle_fullscreen()
Global.canvas.update()
func tile_mode_submenu_id_pressed(id: int) -> void:
func _tile_mode_submenu_id_pressed(id: int) -> void:
Global.current_project.tile_mode = id
Global.transparent_checker.fit_rect(Global.current_project.get_tile_mode_rect())
for i in Global.TileMode.values():
@ -403,14 +403,14 @@ func tile_mode_submenu_id_pressed(id: int) -> void:
Global.canvas.grid.update()
func panel_layout_submenu_id_pressed(id: int) -> void:
func _panel_layout_submenu_id_pressed(id: int) -> void:
Global.panel_layout = id
for i in Global.PanelLayout.values():
panel_layout_submenu.set_item_checked(i, i == id)
get_tree().get_root().get_node("Control").handle_resize()
func toggle_mirror_view() -> void:
func _toggle_mirror_view() -> void:
Global.mirror_view = !Global.mirror_view
var marching_ants_outline: Sprite = Global.canvas.selection.marching_ants_outline
marching_ants_outline.scale.x = -marching_ants_outline.scale.x
@ -425,26 +425,26 @@ func toggle_mirror_view() -> void:
view_menu.set_item_checked(ViewMenuId.MIRROR_VIEW, Global.mirror_view)
func toggle_show_grid() -> void:
func _toggle_show_grid() -> void:
Global.draw_grid = !Global.draw_grid
view_menu.set_item_checked(ViewMenuId.SHOW_GRID, Global.draw_grid)
Global.canvas.grid.update()
func toggle_show_pixel_grid() -> void:
func _toggle_show_pixel_grid() -> void:
Global.draw_pixel_grid = !Global.draw_pixel_grid
view_menu.set_item_checked(ViewMenuId.SHOW_PIXEL_GRID, Global.draw_pixel_grid)
Global.canvas.pixel_grid.update()
func toggle_show_rulers() -> void:
func _toggle_show_rulers() -> void:
Global.show_rulers = !Global.show_rulers
view_menu.set_item_checked(ViewMenuId.SHOW_RULERS, Global.show_rulers)
Global.horizontal_ruler.visible = Global.show_rulers
Global.vertical_ruler.visible = Global.show_rulers
func toggle_show_guides() -> void:
func _toggle_show_guides() -> void:
Global.show_guides = !Global.show_guides
view_menu.set_item_checked(ViewMenuId.SHOW_GUIDES, Global.show_guides)
for guide in Global.canvas.get_children():
@ -457,7 +457,7 @@ func toggle_show_guides() -> void:
guide.visible = Global.show_y_symmetry_axis and Global.show_guides
func toggle_show_anim_timeline() -> void:
func _toggle_show_anim_timeline() -> void:
if zen_mode:
return
Global.show_animation_timeline = !Global.show_animation_timeline
@ -465,7 +465,7 @@ func toggle_show_anim_timeline() -> void:
Global.animation_timeline.visible = Global.show_animation_timeline
func toggle_zen_mode() -> void:
func _toggle_zen_mode() -> void:
if Global.show_animation_timeline:
Global.animation_timeline.visible = zen_mode
Global.tool_panel.visible = zen_mode
@ -476,7 +476,7 @@ func toggle_zen_mode() -> void:
view_menu.set_item_checked(ViewMenuId.ZEN_MODE, zen_mode)
func toggle_fullscreen() -> void:
func _toggle_fullscreen() -> void:
OS.window_fullscreen = !OS.window_fullscreen
view_menu.set_item_checked(ViewMenuId.FULLSCREEN_MODE, OS.window_fullscreen)
if OS.window_fullscreen: # If window is fullscreen then reset transparency
@ -486,7 +486,7 @@ func toggle_fullscreen() -> void:
func image_menu_id_pressed(id: int) -> void:
match id:
ImageMenuId.SCALE_IMAGE:
show_scale_image_popup()
_show_scale_image_popup()
ImageMenuId.CENTRALIZE_IMAGE:
DrawingAlgos.centralize()
@ -495,14 +495,14 @@ func image_menu_id_pressed(id: int) -> void:
DrawingAlgos.crop_image()
ImageMenuId.RESIZE_CANVAS:
show_resize_canvas_popup()
_show_resize_canvas_popup()
ImageMenuId.FLIP:
Global.control.get_node("Dialogs/ImageEffects/FlipImageDialog").popup_centered()
Global.dialog_open(true)
ImageMenuId.ROTATE:
show_rotate_image_popup()
_show_rotate_image_popup()
ImageMenuId.INVERT_COLORS:
Global.control.get_node("Dialogs/ImageEffects/InvertColorsDialog").popup_centered()
@ -513,10 +513,10 @@ func image_menu_id_pressed(id: int) -> void:
Global.dialog_open(true)
ImageMenuId.OUTLINE:
show_add_outline_popup()
_show_add_outline_popup()
ImageMenuId.HSV:
show_hsv_configuration_popup()
_show_hsv_configuration_popup()
ImageMenuId.GRADIENT:
Global.control.get_node("Dialogs/ImageEffects/GradientDialog").popup_centered()
@ -527,27 +527,27 @@ func image_menu_id_pressed(id: int) -> void:
Global.dialog_open(true)
func show_scale_image_popup() -> void:
func _show_scale_image_popup() -> void:
Global.control.get_node("Dialogs/ImageEffects/ScaleImage").popup_centered()
Global.dialog_open(true)
func show_resize_canvas_popup() -> void:
func _show_resize_canvas_popup() -> void:
Global.control.get_node("Dialogs/ImageEffects/ResizeCanvas").popup_centered()
Global.dialog_open(true)
func show_rotate_image_popup() -> void:
func _show_rotate_image_popup() -> void:
Global.control.get_node("Dialogs/ImageEffects/RotateImage").popup_centered()
Global.dialog_open(true)
func show_add_outline_popup() -> void:
func _show_add_outline_popup() -> void:
Global.control.get_node("Dialogs/ImageEffects/OutlineDialog").popup_centered()
Global.dialog_open(true)
func show_hsv_configuration_popup() -> void:
func _show_hsv_configuration_popup() -> void:
Global.control.get_node("Dialogs/ImageEffects/HSVDialog").popup_centered()
Global.dialog_open(true)