2019-08-18 09:28:38 +00:00
|
|
|
extends Control
|
|
|
|
|
|
|
|
var opensprite_file_selected := false
|
2019-12-28 01:07:48 +00:00
|
|
|
var file_menu : PopupMenu
|
2019-09-18 21:10:23 +00:00
|
|
|
var view_menu : PopupMenu
|
2019-10-22 23:54:29 +00:00
|
|
|
var tools := []
|
2019-11-13 13:45:55 +00:00
|
|
|
var redone := false
|
2020-02-22 22:52:51 +00:00
|
|
|
var is_quitting_on_save := false
|
2019-12-24 18:49:07 +00:00
|
|
|
var previous_left_color := Color.black
|
|
|
|
var previous_right_color := Color.white
|
2019-08-18 09:28:38 +00:00
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready() -> void:
|
2019-12-04 17:16:18 +00:00
|
|
|
get_tree().set_auto_accept_quit(false)
|
2019-09-14 19:55:33 +00:00
|
|
|
# Set a minimum window size to prevent UI elements from collapsing on each other.
|
|
|
|
# This property is only available in 3.2alpha or later, so use `set()` to fail gracefully if it doesn't exist.
|
2020-04-04 21:45:19 +00:00
|
|
|
OS.set("min_window_size", Vector2(1024, 576))
|
2019-10-29 21:22:38 +00:00
|
|
|
|
2019-12-17 11:10:42 +00:00
|
|
|
# `TranslationServer.get_loaded_locales()` was added in 3.2beta and in 3.1.2
|
2019-12-14 22:19:58 +00:00
|
|
|
# The `has_method()` check and the `else` branch can be removed once 3.2 is released.
|
|
|
|
if TranslationServer.has_method("get_loaded_locales"):
|
2019-12-18 16:12:44 +00:00
|
|
|
Global.loaded_locales = TranslationServer.get_loaded_locales()
|
2019-12-14 22:19:58 +00:00
|
|
|
else:
|
|
|
|
# Hardcoded list of locales
|
2020-03-25 02:42:03 +00:00
|
|
|
Global.loaded_locales = ["de_DE", "el_GR", "en_US", "eo_UY", "es_ES", "fr_FR", "it_IT", "lv_LV", "pl_PL", "pt_BR", "ru_RU", "zh_CN","zh_TW"]
|
2019-12-14 22:19:58 +00:00
|
|
|
|
2019-12-10 23:00:26 +00:00
|
|
|
# Make sure locales are always sorted, in the same order
|
2019-12-18 16:12:44 +00:00
|
|
|
Global.loaded_locales.sort()
|
2019-12-07 15:45:48 +00:00
|
|
|
|
|
|
|
# Restore the window position/size if values are present in the configuration cache
|
2019-12-18 16:12:44 +00:00
|
|
|
if Global.config_cache.has_section_key("window", "screen"):
|
|
|
|
OS.current_screen = Global.config_cache.get_value("window", "screen")
|
|
|
|
if Global.config_cache.has_section_key("window", "maximized"):
|
|
|
|
OS.window_maximized = Global.config_cache.get_value("window", "maximized")
|
2019-11-19 21:36:37 +00:00
|
|
|
|
|
|
|
if !OS.window_maximized:
|
2019-12-18 16:12:44 +00:00
|
|
|
if Global.config_cache.has_section_key("window", "position"):
|
|
|
|
OS.window_position = Global.config_cache.get_value("window", "position")
|
|
|
|
if Global.config_cache.has_section_key("window", "size"):
|
|
|
|
OS.window_size = Global.config_cache.get_value("window", "size")
|
2019-11-19 21:36:37 +00:00
|
|
|
|
2019-08-18 09:28:38 +00:00
|
|
|
var file_menu_items := {
|
2020-04-07 22:56:05 +00:00
|
|
|
"New..." : InputMap.get_action_list("new_file")[0].get_scancode_with_modifiers(),
|
|
|
|
"Open..." : InputMap.get_action_list("open_file")[0].get_scancode_with_modifiers(),
|
2020-04-21 17:45:02 +00:00
|
|
|
'Open last project...' : 0,
|
2020-04-07 22:56:05 +00:00
|
|
|
"Save..." : InputMap.get_action_list("save_file")[0].get_scancode_with_modifiers(),
|
|
|
|
"Save as..." : InputMap.get_action_list("save_file_as")[0].get_scancode_with_modifiers(),
|
|
|
|
"Import..." : InputMap.get_action_list("import_file")[0].get_scancode_with_modifiers(),
|
|
|
|
"Export..." : InputMap.get_action_list("export_file")[0].get_scancode_with_modifiers(),
|
|
|
|
"Export as..." : InputMap.get_action_list("export_file_as")[0].get_scancode_with_modifiers(),
|
|
|
|
"Quit" : InputMap.get_action_list("quit")[0].get_scancode_with_modifiers(),
|
2019-08-18 09:28:38 +00:00
|
|
|
}
|
2019-09-03 19:51:14 +00:00
|
|
|
var edit_menu_items := {
|
2020-04-07 22:56:05 +00:00
|
|
|
"Undo" : InputMap.get_action_list("undo")[0].get_scancode_with_modifiers(),
|
|
|
|
"Redo" : InputMap.get_action_list("redo")[0].get_scancode_with_modifiers(),
|
2019-12-10 23:00:26 +00:00
|
|
|
"Clear Selection" : 0,
|
|
|
|
"Preferences" : 0
|
2019-09-03 19:51:14 +00:00
|
|
|
}
|
2019-09-18 21:10:23 +00:00
|
|
|
var view_menu_items := {
|
2020-04-07 22:56:05 +00:00
|
|
|
"Tile Mode" : InputMap.get_action_list("tile_mode")[0].get_scancode_with_modifiers(),
|
|
|
|
"Show Grid" : InputMap.get_action_list("show_grid")[0].get_scancode_with_modifiers(),
|
|
|
|
"Show Rulers" : InputMap.get_action_list("show_rulers")[0].get_scancode_with_modifiers(),
|
|
|
|
"Show Guides" : InputMap.get_action_list("show_guides")[0].get_scancode_with_modifiers(),
|
2020-02-15 01:30:40 +00:00
|
|
|
"Show Animation Timeline" : 0
|
2019-09-25 19:59:48 +00:00
|
|
|
}
|
2019-12-24 14:48:07 +00:00
|
|
|
var image_menu_items := {
|
2019-12-24 23:43:21 +00:00
|
|
|
"Scale Image" : 0,
|
|
|
|
"Crop Image" : 0,
|
2020-04-07 22:56:05 +00:00
|
|
|
"Flip Horizontal" : InputMap.get_action_list("image_flip_horizontal")[0].get_scancode_with_modifiers(),
|
|
|
|
"Flip Vertical" : InputMap.get_action_list("image_flip_vertical")[0].get_scancode_with_modifiers(),
|
2020-02-04 16:29:34 +00:00
|
|
|
"Rotate Image" : 0,
|
2019-12-31 18:10:10 +00:00
|
|
|
"Invert colors" : 0,
|
2019-12-27 22:57:28 +00:00
|
|
|
"Desaturation" : 0,
|
2020-04-13 14:10:17 +00:00
|
|
|
"Outline" : 0,
|
2020-04-15 16:54:59 +00:00
|
|
|
"Adjust Hue/Saturation/Value" : 0
|
2019-12-24 14:48:07 +00:00
|
|
|
}
|
2019-09-25 19:59:48 +00:00
|
|
|
var help_menu_items := {
|
2019-12-31 16:36:57 +00:00
|
|
|
"View Splash Screen" : 0,
|
2019-12-31 12:40:44 +00:00
|
|
|
"Issue Tracker" : 0,
|
2019-12-31 16:36:57 +00:00
|
|
|
"Changelog" : 0,
|
2019-12-10 23:00:26 +00:00
|
|
|
"About Pixelorama" : 0
|
2019-09-18 21:10:23 +00:00
|
|
|
}
|
2019-12-10 12:28:19 +00:00
|
|
|
|
|
|
|
# Load language
|
2019-12-18 16:12:44 +00:00
|
|
|
if Global.config_cache.has_section_key("preferences", "locale"):
|
|
|
|
var saved_locale : String = Global.config_cache.get_value("preferences", "locale")
|
2019-12-10 12:28:19 +00:00
|
|
|
TranslationServer.set_locale(saved_locale)
|
|
|
|
|
|
|
|
# Set the language option menu's default selected option to the loaded locale
|
2019-12-27 22:00:24 +00:00
|
|
|
var locale_index: int = Global.loaded_locales.find(saved_locale)
|
2020-04-15 17:44:34 +00:00
|
|
|
$PreferencesDialog.languages.get_child(0).pressed = false # Unset System Language option in preferences
|
|
|
|
$PreferencesDialog.languages.get_child(locale_index + 1).pressed = true
|
2019-12-10 12:28:19 +00:00
|
|
|
else: # If the user doesn't have a language preference, set it to their OS' locale
|
|
|
|
TranslationServer.set_locale(OS.get_locale())
|
|
|
|
|
2020-01-02 14:46:31 +00:00
|
|
|
if "zh" in TranslationServer.get_locale():
|
2020-01-05 14:03:04 +00:00
|
|
|
theme.default_font = preload("res://Assets/Fonts/CJK/NotoSansCJKtc-Regular.tres")
|
2019-12-17 17:52:09 +00:00
|
|
|
else:
|
|
|
|
theme.default_font = preload("res://Assets/Fonts/Roboto-Regular.tres")
|
|
|
|
|
|
|
|
|
2019-12-28 01:07:48 +00:00
|
|
|
file_menu = Global.file_menu.get_popup()
|
2019-08-18 09:28:38 +00:00
|
|
|
var edit_menu : PopupMenu = Global.edit_menu.get_popup()
|
2019-09-18 21:10:23 +00:00
|
|
|
view_menu = Global.view_menu.get_popup()
|
2019-12-24 14:48:07 +00:00
|
|
|
var image_menu : PopupMenu = Global.image_menu.get_popup()
|
2019-09-25 19:59:48 +00:00
|
|
|
var help_menu : PopupMenu = Global.help_menu.get_popup()
|
2019-10-29 21:22:38 +00:00
|
|
|
|
2019-08-18 09:28:38 +00:00
|
|
|
var i = 0
|
|
|
|
for item in file_menu_items.keys():
|
|
|
|
file_menu.add_item(item, i, file_menu_items[item])
|
|
|
|
i += 1
|
2019-09-03 19:51:14 +00:00
|
|
|
i = 0
|
|
|
|
for item in edit_menu_items.keys():
|
|
|
|
edit_menu.add_item(item, i, edit_menu_items[item])
|
|
|
|
i += 1
|
2019-09-18 21:10:23 +00:00
|
|
|
i = 0
|
|
|
|
for item in view_menu_items.keys():
|
|
|
|
view_menu.add_check_item(item, i, view_menu_items[item])
|
|
|
|
i += 1
|
2020-02-16 13:19:01 +00:00
|
|
|
view_menu.set_item_checked(2, true) # Show Rulers
|
|
|
|
view_menu.set_item_checked(3, true) # Show Guides
|
|
|
|
view_menu.set_item_checked(4, true) # Show Animation Timeline
|
2019-12-19 21:14:08 +00:00
|
|
|
view_menu.hide_on_checkable_item_selection = false
|
2019-09-25 19:59:48 +00:00
|
|
|
i = 0
|
2019-12-24 14:48:07 +00:00
|
|
|
for item in image_menu_items.keys():
|
|
|
|
image_menu.add_item(item, i, image_menu_items[item])
|
2020-02-04 16:29:34 +00:00
|
|
|
if i == 4:
|
2019-12-25 00:53:45 +00:00
|
|
|
image_menu.add_separator()
|
2019-12-24 14:48:07 +00:00
|
|
|
i += 1
|
|
|
|
i = 0
|
2019-09-25 19:59:48 +00:00
|
|
|
for item in help_menu_items.keys():
|
|
|
|
help_menu.add_item(item, i, help_menu_items[item])
|
|
|
|
i += 1
|
2019-10-29 21:22:38 +00:00
|
|
|
|
2019-08-18 09:28:38 +00:00
|
|
|
file_menu.connect("id_pressed", self, "file_menu_id_pressed")
|
2019-09-03 19:51:14 +00:00
|
|
|
edit_menu.connect("id_pressed", self, "edit_menu_id_pressed")
|
2019-09-18 21:10:23 +00:00
|
|
|
view_menu.connect("id_pressed", self, "view_menu_id_pressed")
|
2019-12-24 14:48:07 +00:00
|
|
|
image_menu.connect("id_pressed", self, "image_menu_id_pressed")
|
2019-09-25 19:59:48 +00:00
|
|
|
help_menu.connect("id_pressed", self, "help_menu_id_pressed")
|
2019-10-29 21:22:38 +00:00
|
|
|
|
2019-09-18 21:10:23 +00:00
|
|
|
var root = get_tree().get_root()
|
2019-12-24 14:48:07 +00:00
|
|
|
# Node, left mouse shortcut, right mouse shortcut
|
2019-10-22 23:54:29 +00:00
|
|
|
tools.append([Global.find_node_by_name(root, "Pencil"), "left_pencil_tool", "right_pencil_tool"])
|
|
|
|
tools.append([Global.find_node_by_name(root, "Eraser"), "left_eraser_tool", "right_eraser_tool"])
|
2019-11-19 21:23:43 +00:00
|
|
|
tools.append([Global.find_node_by_name(root, "Bucket"), "left_fill_tool", "right_fill_tool"])
|
2019-10-22 23:54:29 +00:00
|
|
|
tools.append([Global.find_node_by_name(root, "LightenDarken"), "left_lightdark_tool", "right_lightdark_tool"])
|
|
|
|
tools.append([Global.find_node_by_name(root, "RectSelect"), "left_rectangle_select_tool", "right_rectangle_select_tool"])
|
2019-12-04 15:22:21 +00:00
|
|
|
tools.append([Global.find_node_by_name(root, "ColorPicker"), "left_colorpicker_tool", "right_colorpicker_tool"])
|
2020-04-13 02:07:52 +00:00
|
|
|
tools.append([Global.find_node_by_name(root, "Zoom"), "left_zoom_tool", "right_zoom_tool"])
|
2019-10-29 21:22:38 +00:00
|
|
|
|
2019-10-22 23:54:29 +00:00
|
|
|
for t in tools:
|
|
|
|
t[0].connect("pressed", self, "_on_Tool_pressed", [t[0]])
|
2019-10-29 21:22:38 +00:00
|
|
|
|
2020-04-11 21:08:45 +00:00
|
|
|
Global.update_hint_tooltips()
|
|
|
|
|
2020-01-01 13:00:46 +00:00
|
|
|
# Checks to see if it's 3.1.x
|
2020-03-28 03:15:09 +00:00
|
|
|
if Engine.get_version_info().major == 3 and Engine.get_version_info().minor < 2:
|
2020-01-01 13:00:46 +00:00
|
|
|
Global.left_color_picker.get_picker().move_child(Global.left_color_picker.get_picker().get_child(0), 1)
|
|
|
|
Global.right_color_picker.get_picker().move_child(Global.right_color_picker.get_picker().get_child(0), 1)
|
2019-12-16 13:36:33 +00:00
|
|
|
|
2020-02-09 16:06:03 +00:00
|
|
|
if OS.get_cmdline_args():
|
|
|
|
for arg in OS.get_cmdline_args():
|
|
|
|
if arg.get_extension().to_lower() == "pxo":
|
|
|
|
_on_OpenSprite_file_selected(arg)
|
|
|
|
else:
|
|
|
|
$ImportSprites._on_ImportSprites_files_selected([arg])
|
|
|
|
|
2020-02-22 15:21:52 +00:00
|
|
|
Global.window_title = "(" + tr("untitled") + ") - Pixelorama"
|
2020-02-09 16:06:03 +00:00
|
|
|
|
2020-01-19 18:03:32 +00:00
|
|
|
Global.layers[0][0] = tr("Layer") + " 0"
|
2020-02-28 01:27:22 +00:00
|
|
|
Global.layers_container.get_child(0).label.text = Global.layers[0][0]
|
|
|
|
Global.layers_container.get_child(0).line_edit.text = Global.layers[0][0]
|
2020-02-09 16:06:03 +00:00
|
|
|
|
2020-04-11 22:36:58 +00:00
|
|
|
Import.import_brushes(Global.directory_module.get_brushes_search_path_in_order())
|
2020-02-22 15:14:32 +00:00
|
|
|
|
2020-03-27 01:40:23 +00:00
|
|
|
Global.left_color_picker.get_picker().presets_visible = false
|
|
|
|
Global.right_color_picker.get_picker().presets_visible = false
|
2020-02-23 00:11:52 +00:00
|
|
|
$QuitAndSaveDialog.add_button("Save & Exit", false, "Save")
|
|
|
|
$QuitAndSaveDialog.get_ok().text = "Exit without saving"
|
|
|
|
|
2020-02-22 15:14:32 +00:00
|
|
|
|
2020-01-01 18:04:13 +00:00
|
|
|
if not Global.config_cache.has_section_key("preferences", "startup"):
|
|
|
|
Global.config_cache.set_value("preferences", "startup", true)
|
2020-02-18 23:13:29 +00:00
|
|
|
if Global.config_cache.get_value("preferences", "startup"):
|
|
|
|
# Wait for the window to adjust itself, so the popup is correctly centered
|
|
|
|
yield(get_tree().create_timer(0.01), "timeout")
|
|
|
|
$SplashDialog.popup_centered() # Splash screen
|
|
|
|
else:
|
|
|
|
Global.can_draw = true
|
2020-01-14 03:44:16 +00:00
|
|
|
|
2020-04-21 17:45:02 +00:00
|
|
|
if not Global.config_cache.has_section_key("preferences", "open_last_project"):
|
|
|
|
Global.config_cache.set_value("preferences", "open_last_project", true)
|
|
|
|
if Global.config_cache.get_value("preferences", "open_last_project"):
|
|
|
|
Global.open_last_project = Global.config_cache.get_value("preferences", "open_last_project")
|
|
|
|
load_last_project()
|
|
|
|
|
2019-12-05 23:48:29 +00:00
|
|
|
func _input(event : InputEvent) -> void:
|
2019-12-10 23:00:26 +00:00
|
|
|
Global.left_cursor.position = get_global_mouse_position() + Vector2(-32, 32)
|
2019-12-10 17:56:16 +00:00
|
|
|
Global.left_cursor.texture = Global.left_cursor_tool_texture
|
2019-12-10 23:00:26 +00:00
|
|
|
Global.right_cursor.position = get_global_mouse_position() + Vector2(32, 32)
|
2019-12-10 17:56:16 +00:00
|
|
|
Global.right_cursor.texture = Global.right_cursor_tool_texture
|
2020-03-14 19:40:10 +00:00
|
|
|
|
2020-03-28 03:15:09 +00:00
|
|
|
if event is InputEventKey and (event.scancode == KEY_ENTER or event.scancode == KEY_KP_ENTER):
|
2020-03-13 18:51:39 +00:00
|
|
|
if get_focus_owner() is LineEdit:
|
|
|
|
get_focus_owner().release_focus()
|
2020-03-14 19:40:10 +00:00
|
|
|
|
2019-11-19 21:33:37 +00:00
|
|
|
if event.is_action_pressed("toggle_fullscreen"):
|
|
|
|
OS.window_fullscreen = !OS.window_fullscreen
|
|
|
|
|
2019-12-24 14:48:07 +00:00
|
|
|
if event.is_action_pressed("redo_secondary"): # Shift + Ctrl + Z
|
2019-12-19 15:07:26 +00:00
|
|
|
redone = true
|
|
|
|
Global.undo_redo.redo()
|
|
|
|
redone = false
|
|
|
|
|
Import brushes from folder
- A new type of custom brush has been added, brushes from files! Basically there's a "Brushes" folder where Pixelorama can get brushes from, and, unlike the previous brushes, these are for all projects and are not saved in .pxo files. These brushes get loaded on the _ready() method of Main.gd, and are ignored by Godot.
- There are now 2 containers for the two types of custom brushes. The main pixel brush is with the brushes from files.
- Fixed bug where, if you had selected a custom "project" brush and loaded a .pxo file, the brush would still be selected, causing potential problems
- Fixed bug where you could save a project brush that was completely transparent
- Fixed bug where, if you named a file, some shortcuts would be activated.
- export_presets.cfg is now ignored.
2019-11-11 02:20:09 +00:00
|
|
|
if Global.has_focus:
|
2020-04-14 14:03:16 +00:00
|
|
|
if event.is_action_pressed("undo") or event.is_action_pressed("redo") or event.is_action_pressed("redo_secondary"):
|
|
|
|
return
|
2019-12-24 14:48:07 +00:00
|
|
|
for t in tools: # Handle tool shortcuts
|
|
|
|
if event.is_action_pressed(t[2]): # Shortcut for right button (with Alt)
|
Import brushes from folder
- A new type of custom brush has been added, brushes from files! Basically there's a "Brushes" folder where Pixelorama can get brushes from, and, unlike the previous brushes, these are for all projects and are not saved in .pxo files. These brushes get loaded on the _ready() method of Main.gd, and are ignored by Godot.
- There are now 2 containers for the two types of custom brushes. The main pixel brush is with the brushes from files.
- Fixed bug where, if you had selected a custom "project" brush and loaded a .pxo file, the brush would still be selected, causing potential problems
- Fixed bug where you could save a project brush that was completely transparent
- Fixed bug where, if you named a file, some shortcuts would be activated.
- export_presets.cfg is now ignored.
2019-11-11 02:20:09 +00:00
|
|
|
_on_Tool_pressed(t[0], false, false)
|
2019-12-24 14:48:07 +00:00
|
|
|
elif event.is_action_pressed(t[1]): # Shortcut for left button
|
Import brushes from folder
- A new type of custom brush has been added, brushes from files! Basically there's a "Brushes" folder where Pixelorama can get brushes from, and, unlike the previous brushes, these are for all projects and are not saved in .pxo files. These brushes get loaded on the _ready() method of Main.gd, and are ignored by Godot.
- There are now 2 containers for the two types of custom brushes. The main pixel brush is with the brushes from files.
- Fixed bug where, if you had selected a custom "project" brush and loaded a .pxo file, the brush would still be selected, causing potential problems
- Fixed bug where you could save a project brush that was completely transparent
- Fixed bug where, if you named a file, some shortcuts would be activated.
- export_presets.cfg is now ignored.
2019-11-11 02:20:09 +00:00
|
|
|
_on_Tool_pressed(t[0], false, true)
|
2019-08-18 09:28:38 +00:00
|
|
|
|
2019-12-05 23:48:29 +00:00
|
|
|
func _notification(what : int) -> void:
|
2019-12-24 14:48:07 +00:00
|
|
|
if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST: # Handle exit
|
2020-02-23 00:11:52 +00:00
|
|
|
show_quit_dialog()
|
2019-12-04 17:16:18 +00:00
|
|
|
|
2019-08-18 09:28:38 +00:00
|
|
|
func file_menu_id_pressed(id : int) -> void:
|
|
|
|
match id:
|
2019-12-24 14:48:07 +00:00
|
|
|
0: # New
|
2020-04-02 09:56:26 +00:00
|
|
|
if(!Global.saved):
|
|
|
|
$UnsavedCanvasDialog.popup_centered()
|
|
|
|
else:
|
|
|
|
$CreateNewImage.popup_centered()
|
2019-08-18 09:28:38 +00:00
|
|
|
Global.can_draw = false
|
2019-12-24 14:48:07 +00:00
|
|
|
1: # Open
|
2019-08-18 09:28:38 +00:00
|
|
|
$OpenSprite.popup_centered()
|
|
|
|
Global.can_draw = false
|
|
|
|
opensprite_file_selected = false
|
2020-04-21 17:45:02 +00:00
|
|
|
2: # Open last project
|
|
|
|
# Check if last project path is set and if yes then open
|
|
|
|
if Global.config_cache.has_section_key("preferences", "last_project_path"):
|
|
|
|
load_last_project()
|
|
|
|
else: # if not then warn user that he didn't edit any project yet
|
|
|
|
$NoProjectEditedOrCreatedAlertDialog.popup_centered()
|
|
|
|
3: # Save
|
2020-02-22 22:52:51 +00:00
|
|
|
is_quitting_on_save = false
|
2020-04-09 20:54:05 +00:00
|
|
|
if OpenSave.current_save_path == "":
|
2019-08-18 09:28:38 +00:00
|
|
|
$SaveSprite.popup_centered()
|
|
|
|
Global.can_draw = false
|
|
|
|
else:
|
2020-04-09 20:54:05 +00:00
|
|
|
_on_SaveSprite_file_selected(OpenSave.current_save_path)
|
2020-04-21 17:45:02 +00:00
|
|
|
4: # Save as
|
2020-02-22 22:52:51 +00:00
|
|
|
is_quitting_on_save = false
|
2019-08-18 09:28:38 +00:00
|
|
|
$SaveSprite.popup_centered()
|
|
|
|
Global.can_draw = false
|
2020-04-21 17:45:02 +00:00
|
|
|
5: # Import
|
2019-09-14 19:55:33 +00:00
|
|
|
$ImportSprites.popup_centered()
|
|
|
|
Global.can_draw = false
|
|
|
|
opensprite_file_selected = false
|
2020-04-21 17:45:02 +00:00
|
|
|
6: # Export
|
2020-03-23 22:09:37 +00:00
|
|
|
if $ExportDialog.was_exported == false:
|
|
|
|
$ExportDialog.popup_centered()
|
2019-09-14 19:55:33 +00:00
|
|
|
Global.can_draw = false
|
|
|
|
else:
|
2020-03-23 22:09:37 +00:00
|
|
|
$ExportDialog.external_export()
|
2020-04-21 17:45:02 +00:00
|
|
|
7: # Export as
|
2020-03-23 22:09:37 +00:00
|
|
|
$ExportDialog.popup_centered()
|
2019-09-14 19:55:33 +00:00
|
|
|
Global.can_draw = false
|
2020-04-21 17:45:02 +00:00
|
|
|
8: # Quit
|
2020-02-23 00:11:52 +00:00
|
|
|
show_quit_dialog()
|
2019-08-18 09:28:38 +00:00
|
|
|
|
2019-09-03 19:51:14 +00:00
|
|
|
func edit_menu_id_pressed(id : int) -> void:
|
|
|
|
match id:
|
2019-12-24 14:48:07 +00:00
|
|
|
0: # Undo
|
2019-11-04 17:12:35 +00:00
|
|
|
Global.undo_redo.undo()
|
2019-12-24 14:48:07 +00:00
|
|
|
1: # Redo
|
2019-11-13 13:45:55 +00:00
|
|
|
redone = true
|
2019-11-04 17:12:35 +00:00
|
|
|
Global.undo_redo.redo()
|
2019-11-13 13:45:55 +00:00
|
|
|
redone = false
|
2019-12-24 23:43:21 +00:00
|
|
|
2: # Clear selection
|
|
|
|
Global.canvas.handle_undo("Rectangle Select")
|
|
|
|
Global.selection_rectangle.polygon[0] = Vector2.ZERO
|
|
|
|
Global.selection_rectangle.polygon[1] = Vector2.ZERO
|
|
|
|
Global.selection_rectangle.polygon[2] = Vector2.ZERO
|
|
|
|
Global.selection_rectangle.polygon[3] = Vector2.ZERO
|
|
|
|
Global.selected_pixels.clear()
|
|
|
|
Global.canvas.handle_redo("Rectangle Select")
|
|
|
|
3: # Preferences
|
2020-02-07 22:10:33 +00:00
|
|
|
$PreferencesDialog.popup_centered(Vector2(400, 280))
|
2019-12-24 23:43:21 +00:00
|
|
|
Global.can_draw = false
|
|
|
|
|
|
|
|
func view_menu_id_pressed(id : int) -> void:
|
|
|
|
match id:
|
|
|
|
0: # Tile mode
|
|
|
|
Global.tile_mode = !Global.tile_mode
|
|
|
|
view_menu.set_item_checked(0, Global.tile_mode)
|
|
|
|
1: # Show grid
|
|
|
|
Global.draw_grid = !Global.draw_grid
|
|
|
|
view_menu.set_item_checked(1, Global.draw_grid)
|
|
|
|
2: # Show rulers
|
|
|
|
Global.show_rulers = !Global.show_rulers
|
|
|
|
view_menu.set_item_checked(2, Global.show_rulers)
|
|
|
|
Global.horizontal_ruler.visible = Global.show_rulers
|
|
|
|
Global.vertical_ruler.visible = Global.show_rulers
|
|
|
|
3: # Show guides
|
|
|
|
Global.show_guides = !Global.show_guides
|
|
|
|
view_menu.set_item_checked(3, Global.show_guides)
|
|
|
|
for canvas in Global.canvases:
|
|
|
|
for guide in canvas.get_children():
|
|
|
|
if guide is Guide:
|
|
|
|
guide.visible = Global.show_guides
|
2020-02-15 01:30:40 +00:00
|
|
|
4: # Show animation timeline
|
|
|
|
Global.show_animation_timeline = !Global.show_animation_timeline
|
|
|
|
view_menu.set_item_checked(4, Global.show_animation_timeline)
|
2020-02-16 13:19:01 +00:00
|
|
|
Global.animation_timeline.visible = Global.show_animation_timeline
|
2019-12-24 23:43:21 +00:00
|
|
|
|
2019-12-27 22:57:28 +00:00
|
|
|
Global.canvas.update()
|
|
|
|
|
2019-12-24 23:43:21 +00:00
|
|
|
func image_menu_id_pressed(id : int) -> void:
|
2020-03-09 23:42:50 +00:00
|
|
|
if Global.layers[Global.current_layer][2]: # No changes if the layer is locked
|
|
|
|
return
|
2019-12-24 23:43:21 +00:00
|
|
|
match id:
|
|
|
|
0: # Scale Image
|
2019-09-09 22:57:46 +00:00
|
|
|
$ScaleImage.popup_centered()
|
|
|
|
Global.can_draw = false
|
2019-12-24 23:43:21 +00:00
|
|
|
1: # Crop Image
|
2019-12-24 14:48:07 +00:00
|
|
|
# Use first layer as a starting rectangle
|
2019-09-25 19:59:48 +00:00
|
|
|
var used_rect : Rect2 = Global.canvas.layers[0][0].get_used_rect()
|
2019-12-24 14:48:07 +00:00
|
|
|
# However, if first layer is empty, loop through all layers until we find one that isn't
|
2019-09-25 19:59:48 +00:00
|
|
|
var i := 0
|
2020-03-28 03:15:09 +00:00
|
|
|
while(i < Global.canvas.layers.size() - 1 and Global.canvas.layers[i][0].get_used_rect() == Rect2(0, 0, 0, 0)):
|
2019-09-25 19:59:48 +00:00
|
|
|
i += 1
|
|
|
|
used_rect = Global.canvas.layers[i][0].get_used_rect()
|
2019-10-29 21:22:38 +00:00
|
|
|
|
2019-12-24 14:48:07 +00:00
|
|
|
# Merge all layers with content
|
2019-09-25 19:59:48 +00:00
|
|
|
for j in range(Global.canvas.layers.size() - 1, i, -1):
|
|
|
|
if Global.canvas.layers[j][0].get_used_rect() != Rect2(0, 0, 0, 0):
|
|
|
|
used_rect = used_rect.merge(Global.canvas.layers[j][0].get_used_rect())
|
2019-10-29 21:22:38 +00:00
|
|
|
|
2019-12-24 14:48:07 +00:00
|
|
|
# If no layer has any content, just return
|
2019-09-25 19:59:48 +00:00
|
|
|
if used_rect == Rect2(0, 0, 0, 0):
|
|
|
|
return
|
2019-10-29 21:22:38 +00:00
|
|
|
|
2019-11-05 01:14:03 +00:00
|
|
|
var width := used_rect.size.x
|
|
|
|
var height := used_rect.size.y
|
|
|
|
Global.undos += 1
|
|
|
|
Global.undo_redo.create_action("Scale")
|
|
|
|
Global.undo_redo.add_do_property(Global.canvas, "size", Vector2(width, height).floor())
|
2019-12-24 14:48:07 +00:00
|
|
|
# Loop through all the layers to crop them
|
2019-09-25 19:59:48 +00:00
|
|
|
for j in range(Global.canvas.layers.size() - 1, -1, -1):
|
2019-11-05 01:14:03 +00:00
|
|
|
var sprite : Image = Global.canvas.layers[j][0].get_rect(used_rect)
|
|
|
|
Global.undo_redo.add_do_property(Global.canvas.layers[j][0], "data", sprite.data)
|
|
|
|
Global.undo_redo.add_undo_property(Global.canvas.layers[j][0], "data", Global.canvas.layers[j][0].data)
|
|
|
|
|
|
|
|
Global.undo_redo.add_undo_property(Global.canvas, "size", Global.canvas.size)
|
2019-11-05 16:19:41 +00:00
|
|
|
Global.undo_redo.add_undo_method(Global, "undo", [Global.canvas])
|
|
|
|
Global.undo_redo.add_do_method(Global, "redo", [Global.canvas])
|
2019-11-05 01:14:03 +00:00
|
|
|
Global.undo_redo.commit_action()
|
2019-12-24 23:43:21 +00:00
|
|
|
2: # Flip Horizontal
|
2019-11-04 17:12:35 +00:00
|
|
|
var canvas : Canvas = Global.canvas
|
|
|
|
canvas.handle_undo("Draw")
|
2020-02-29 00:12:03 +00:00
|
|
|
canvas.layers[Global.current_layer][0].unlock()
|
|
|
|
canvas.layers[Global.current_layer][0].flip_x()
|
|
|
|
canvas.layers[Global.current_layer][0].lock()
|
2019-11-04 17:12:35 +00:00
|
|
|
canvas.handle_redo("Draw")
|
2019-12-24 23:43:21 +00:00
|
|
|
3: # Flip Vertical
|
2019-11-04 17:12:35 +00:00
|
|
|
var canvas : Canvas = Global.canvas
|
|
|
|
canvas.handle_undo("Draw")
|
2020-02-29 00:12:03 +00:00
|
|
|
canvas.layers[Global.current_layer][0].unlock()
|
|
|
|
canvas.layers[Global.current_layer][0].flip_y()
|
|
|
|
canvas.layers[Global.current_layer][0].lock()
|
2019-11-04 17:12:35 +00:00
|
|
|
canvas.handle_redo("Draw")
|
2020-02-04 16:29:34 +00:00
|
|
|
4: # Rotate
|
2020-02-29 00:12:03 +00:00
|
|
|
var image : Image = Global.canvas.layers[Global.current_layer][0]
|
2020-02-04 16:29:34 +00:00
|
|
|
$RotateImage.set_sprite(image)
|
|
|
|
$RotateImage.popup_centered()
|
2020-04-07 15:13:35 +00:00
|
|
|
Global.can_draw = false
|
2020-02-04 16:29:34 +00:00
|
|
|
5: # Invert Colors
|
2020-02-29 00:12:03 +00:00
|
|
|
var image : Image = Global.canvas.layers[Global.current_layer][0]
|
2019-12-24 17:38:36 +00:00
|
|
|
Global.canvas.handle_undo("Draw")
|
|
|
|
for xx in image.get_size().x:
|
|
|
|
for yy in image.get_size().y:
|
|
|
|
var px_color = image.get_pixel(xx, yy).inverted()
|
|
|
|
if px_color.a == 0:
|
|
|
|
continue
|
|
|
|
image.set_pixel(xx, yy, px_color)
|
|
|
|
Global.canvas.handle_redo("Draw")
|
2020-02-04 16:29:34 +00:00
|
|
|
6: # Desaturation
|
2020-02-29 00:12:03 +00:00
|
|
|
var image : Image = Global.canvas.layers[Global.current_layer][0]
|
2019-12-24 23:43:21 +00:00
|
|
|
Global.canvas.handle_undo("Draw")
|
|
|
|
for xx in image.get_size().x:
|
|
|
|
for yy in image.get_size().y:
|
|
|
|
var px_color = image.get_pixel(xx, yy)
|
|
|
|
if px_color.a == 0:
|
|
|
|
continue
|
2019-12-25 00:53:45 +00:00
|
|
|
var gray = image.get_pixel(xx, yy).v
|
2019-12-24 23:43:21 +00:00
|
|
|
px_color = Color(gray, gray, gray, px_color.a)
|
|
|
|
image.set_pixel(xx, yy, px_color)
|
|
|
|
Global.canvas.handle_redo("Draw")
|
2020-02-04 16:29:34 +00:00
|
|
|
7: # Outline
|
2019-12-24 14:48:07 +00:00
|
|
|
$OutlineDialog.popup_centered()
|
2020-04-07 15:13:35 +00:00
|
|
|
Global.can_draw = false
|
2020-04-13 14:10:17 +00:00
|
|
|
8: # HSV
|
|
|
|
$HSVDialog.popup_centered()
|
|
|
|
Global.can_draw = false
|
2019-12-24 14:48:07 +00:00
|
|
|
|
2019-09-25 19:59:48 +00:00
|
|
|
func help_menu_id_pressed(id : int) -> void:
|
|
|
|
match id:
|
2019-12-31 16:36:57 +00:00
|
|
|
0: # Splash Screen
|
2020-03-09 00:17:49 +00:00
|
|
|
$SplashDialog.popup_centered()
|
2019-12-31 16:36:57 +00:00
|
|
|
Global.can_draw = false
|
|
|
|
1: # Issue Tracker
|
2019-12-31 12:40:44 +00:00
|
|
|
OS.shell_open("https://github.com/Orama-Interactive/Pixelorama/issues")
|
2019-12-31 16:36:57 +00:00
|
|
|
2: # Changelog
|
2020-02-17 14:38:24 +00:00
|
|
|
OS.shell_open("https://github.com/Orama-Interactive/Pixelorama/blob/master/Changelog.md#v062---17-02-2020")
|
2019-12-31 16:36:57 +00:00
|
|
|
3: # About Pixelorama
|
2019-09-25 19:59:48 +00:00
|
|
|
$AboutDialog.popup_centered()
|
|
|
|
Global.can_draw = false
|
|
|
|
|
2020-04-21 17:45:02 +00:00
|
|
|
func load_last_project():
|
|
|
|
# Check if any project was saved or opened last time
|
|
|
|
if Global.config_cache.has_section_key("preferences", "last_project_path"):
|
|
|
|
# Check if file still exists on disk
|
|
|
|
var file_path = Global.config_cache.get_value("preferences", "last_project_path")
|
|
|
|
var file_check := File.new()
|
|
|
|
if file_check.file_exists(file_path): # If yes then load the file
|
|
|
|
_on_OpenSprite_file_selected(file_path)
|
|
|
|
else:
|
|
|
|
# If file doesn't exist on disk then warn user about this
|
|
|
|
$OpenLastProjectAlertDialog.popup_centered()
|
|
|
|
|
2020-04-02 12:28:47 +00:00
|
|
|
|
|
|
|
func _on_UnsavedCanvasDialog_confirmed() -> void:
|
|
|
|
$CreateNewImage.popup_centered()
|
|
|
|
|
|
|
|
|
2019-11-21 19:13:15 +00:00
|
|
|
func _on_OpenSprite_file_selected(path : String) -> void:
|
2020-04-09 20:54:05 +00:00
|
|
|
OpenSave.open_pxo_file(path)
|
2019-11-10 01:25:25 +00:00
|
|
|
|
2020-02-16 16:18:12 +00:00
|
|
|
$SaveSprite.current_path = path
|
2020-04-21 17:45:02 +00:00
|
|
|
# Set last opened project path and save
|
|
|
|
Global.config_cache.set_value("preferences", "last_project_path", path)
|
|
|
|
Global.config_cache.save("user://cache.ini")
|
2020-03-23 22:09:37 +00:00
|
|
|
$ExportDialog.file_name = path.get_file().trim_suffix(".pxo")
|
|
|
|
$ExportDialog.directory_path = path.get_base_dir()
|
|
|
|
$ExportDialog.was_exported = false
|
2020-04-21 17:45:02 +00:00
|
|
|
file_menu.set_item_text(3, tr("Save") + " %s" % path.get_file())
|
|
|
|
file_menu.set_item_text(6, tr("Export"))
|
2020-02-22 15:14:32 +00:00
|
|
|
|
2019-11-21 19:13:15 +00:00
|
|
|
|
2020-01-10 14:21:46 +00:00
|
|
|
func _on_SaveSprite_file_selected(path : String) -> void:
|
2020-04-09 20:54:05 +00:00
|
|
|
OpenSave.save_pxo_file(path)
|
|
|
|
|
2020-04-21 17:45:02 +00:00
|
|
|
# Set last opened project path and save
|
|
|
|
Global.config_cache.set_value("preferences", "last_project_path", path)
|
|
|
|
Global.config_cache.save("user://cache.ini")
|
2020-03-23 22:09:37 +00:00
|
|
|
$ExportDialog.file_name = path.get_file().trim_suffix(".pxo")
|
|
|
|
$ExportDialog.directory_path = path.get_base_dir()
|
|
|
|
$ExportDialog.was_exported = false
|
2020-04-21 17:45:02 +00:00
|
|
|
file_menu.set_item_text(3, tr("Save") + " %s" % path.get_file())
|
2020-04-09 20:54:05 +00:00
|
|
|
|
2020-02-22 22:52:51 +00:00
|
|
|
if is_quitting_on_save:
|
|
|
|
_on_QuitDialog_confirmed()
|
2019-09-14 19:55:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_ImportSprites_popup_hide() -> void:
|
2019-08-18 09:28:38 +00:00
|
|
|
if !opensprite_file_selected:
|
|
|
|
Global.can_draw = true
|
|
|
|
|
|
|
|
func _on_ViewportContainer_mouse_entered() -> void:
|
|
|
|
Global.has_focus = true
|
|
|
|
|
|
|
|
func _on_ViewportContainer_mouse_exited() -> void:
|
|
|
|
Global.has_focus = false
|
2019-10-29 21:22:38 +00:00
|
|
|
|
2019-08-18 09:28:38 +00:00
|
|
|
func _can_draw_true() -> void:
|
|
|
|
Global.can_draw = true
|
|
|
|
func _can_draw_false() -> void:
|
|
|
|
Global.can_draw = false
|
|
|
|
|
|
|
|
func _on_Tool_pressed(tool_pressed : BaseButton, mouse_press := true, key_for_left := true) -> void:
|
|
|
|
var current_action := tool_pressed.name
|
2020-03-28 03:15:09 +00:00
|
|
|
if (mouse_press and Input.is_action_just_released("left_mouse")) or (!mouse_press and key_for_left):
|
2019-08-18 09:28:38 +00:00
|
|
|
Global.current_left_tool = current_action
|
2019-12-03 16:36:28 +00:00
|
|
|
|
2020-04-07 21:43:43 +00:00
|
|
|
# Start from 1, so the label won't get invisible
|
|
|
|
for i in range(1, Global.left_tool_options_container.get_child_count()):
|
2019-12-03 16:36:28 +00:00
|
|
|
Global.left_tool_options_container.get_child(i).visible = false
|
|
|
|
|
2020-04-11 15:45:32 +00:00
|
|
|
Global.left_tool_options_container.get_node("EmptySpacer").visible = true
|
|
|
|
|
2019-12-25 19:42:01 +00:00
|
|
|
# Tool options visible depending on the selected tool
|
2019-12-03 16:36:28 +00:00
|
|
|
if current_action == "Pencil":
|
|
|
|
Global.left_brush_type_container.visible = true
|
2020-04-07 21:43:43 +00:00
|
|
|
Global.left_brush_size_slider.visible = true
|
2019-12-03 16:36:28 +00:00
|
|
|
Global.left_mirror_container.visible = true
|
2020-03-28 03:15:09 +00:00
|
|
|
if Global.current_left_brush_type == Global.Brush_Types.FILE or Global.current_left_brush_type == Global.Brush_Types.CUSTOM or Global.current_left_brush_type == Global.Brush_Types.RANDOM_FILE:
|
2019-12-03 16:36:28 +00:00
|
|
|
Global.left_color_interpolation_container.visible = true
|
|
|
|
elif current_action == "Eraser":
|
|
|
|
Global.left_brush_type_container.visible = true
|
2020-04-07 21:43:43 +00:00
|
|
|
Global.left_brush_size_slider.visible = true
|
2019-12-03 16:36:28 +00:00
|
|
|
Global.left_mirror_container.visible = true
|
|
|
|
elif current_action == "Bucket":
|
2020-04-07 21:43:43 +00:00
|
|
|
Global.left_brush_type_container.visible = true
|
|
|
|
Global.left_brush_size_slider.visible = true
|
2019-12-03 22:14:14 +00:00
|
|
|
Global.left_fill_area_container.visible = true
|
2019-12-03 16:36:28 +00:00
|
|
|
Global.left_mirror_container.visible = true
|
2020-03-28 03:15:09 +00:00
|
|
|
if Global.current_left_brush_type == Global.Brush_Types.FILE or Global.current_left_brush_type == Global.Brush_Types.CUSTOM or Global.current_left_brush_type == Global.Brush_Types.RANDOM_FILE:
|
|
|
|
Global.left_color_interpolation_container.visible = true
|
2019-12-03 16:36:28 +00:00
|
|
|
elif current_action == "LightenDarken":
|
2020-04-07 21:43:43 +00:00
|
|
|
Global.left_brush_type_container.visible = true
|
|
|
|
Global.left_brush_size_slider.visible = true
|
2019-12-03 23:01:37 +00:00
|
|
|
Global.left_ld_container.visible = true
|
2019-12-03 16:36:28 +00:00
|
|
|
Global.left_mirror_container.visible = true
|
2020-01-10 20:44:29 +00:00
|
|
|
elif current_action == "ColorPicker":
|
|
|
|
Global.left_colorpicker_container.visible = true
|
2020-04-13 02:07:52 +00:00
|
|
|
elif current_action == "Zoom":
|
|
|
|
Global.left_zoom_container.visible = true
|
2019-12-03 16:36:28 +00:00
|
|
|
|
2020-03-28 03:15:09 +00:00
|
|
|
elif (mouse_press and Input.is_action_just_released("right_mouse")) or (!mouse_press and !key_for_left):
|
2019-08-18 09:28:38 +00:00
|
|
|
Global.current_right_tool = current_action
|
2020-04-07 21:43:43 +00:00
|
|
|
# Start from 1, so the label won't get invisible
|
|
|
|
for i in range(1, Global.right_tool_options_container.get_child_count()):
|
2019-12-03 16:36:28 +00:00
|
|
|
Global.right_tool_options_container.get_child(i).visible = false
|
|
|
|
|
2020-04-11 15:45:32 +00:00
|
|
|
Global.right_tool_options_container.get_node("EmptySpacer").visible = true
|
|
|
|
|
2019-12-25 19:42:01 +00:00
|
|
|
# Tool options visible depending on the selected tool
|
2019-12-03 16:36:28 +00:00
|
|
|
if current_action == "Pencil":
|
|
|
|
Global.right_brush_type_container.visible = true
|
2020-04-07 21:43:43 +00:00
|
|
|
Global.right_brush_size_slider.visible = true
|
2019-12-03 16:36:28 +00:00
|
|
|
Global.right_mirror_container.visible = true
|
2020-03-28 03:15:09 +00:00
|
|
|
if Global.current_right_brush_type == Global.Brush_Types.FILE or Global.current_right_brush_type == Global.Brush_Types.CUSTOM or Global.current_right_brush_type == Global.Brush_Types.RANDOM_FILE:
|
2019-12-03 16:36:28 +00:00
|
|
|
Global.right_color_interpolation_container.visible = true
|
|
|
|
elif current_action == "Eraser":
|
|
|
|
Global.right_brush_type_container.visible = true
|
2020-04-07 21:43:43 +00:00
|
|
|
Global.right_brush_size_slider.visible = true
|
2019-12-03 16:36:28 +00:00
|
|
|
Global.right_mirror_container.visible = true
|
|
|
|
elif current_action == "Bucket":
|
2020-04-07 21:43:43 +00:00
|
|
|
Global.right_brush_type_container.visible = true
|
|
|
|
Global.right_brush_size_slider.visible = true
|
2019-12-03 22:14:14 +00:00
|
|
|
Global.right_fill_area_container.visible = true
|
2019-12-03 16:36:28 +00:00
|
|
|
Global.right_mirror_container.visible = true
|
2020-03-28 03:15:09 +00:00
|
|
|
if Global.current_right_brush_type == Global.Brush_Types.FILE or Global.current_right_brush_type == Global.Brush_Types.CUSTOM or Global.current_right_brush_type == Global.Brush_Types.RANDOM_FILE:
|
|
|
|
Global.right_color_interpolation_container.visible = true
|
2019-12-03 16:36:28 +00:00
|
|
|
elif current_action == "LightenDarken":
|
2020-04-07 21:43:43 +00:00
|
|
|
Global.right_brush_type_container.visible = true
|
|
|
|
Global.right_brush_size_slider.visible = true
|
2019-12-03 23:01:37 +00:00
|
|
|
Global.right_ld_container.visible = true
|
2019-12-03 16:36:28 +00:00
|
|
|
Global.right_mirror_container.visible = true
|
2020-01-10 20:44:29 +00:00
|
|
|
elif current_action == "ColorPicker":
|
|
|
|
Global.right_colorpicker_container.visible = true
|
2020-04-13 02:07:52 +00:00
|
|
|
elif current_action == "Zoom":
|
|
|
|
Global.right_zoom_container.visible = true
|
2019-11-19 21:23:43 +00:00
|
|
|
|
|
|
|
for t in tools:
|
|
|
|
var tool_name : String = t[0].name
|
2020-03-28 03:15:09 +00:00
|
|
|
if tool_name == Global.current_left_tool and tool_name == Global.current_right_tool:
|
2019-12-21 01:17:37 +00:00
|
|
|
t[0].texture_normal = load("res://Assets/Graphics/%s Themes/Tools/%s_l_r.png" % [Global.theme_type, tool_name])
|
2019-11-19 21:23:43 +00:00
|
|
|
elif tool_name == Global.current_left_tool:
|
2019-12-21 01:17:37 +00:00
|
|
|
t[0].texture_normal = load("res://Assets/Graphics/%s Themes/Tools/%s_l.png" % [Global.theme_type, tool_name])
|
2019-11-19 21:23:43 +00:00
|
|
|
elif tool_name == Global.current_right_tool:
|
2019-12-21 01:17:37 +00:00
|
|
|
t[0].texture_normal = load("res://Assets/Graphics/%s Themes/Tools/%s_r.png" % [Global.theme_type, tool_name])
|
2019-11-19 21:23:43 +00:00
|
|
|
else:
|
2019-12-21 01:17:37 +00:00
|
|
|
t[0].texture_normal = load("res://Assets/Graphics/%s Themes/Tools/%s.png" % [Global.theme_type, tool_name])
|
2019-08-18 09:28:38 +00:00
|
|
|
|
2019-12-28 16:35:53 +00:00
|
|
|
Global.left_cursor_tool_texture.create_from_image(load("res://Assets/Graphics/Tool Cursors/%s_Cursor.png" % Global.current_left_tool), 0)
|
|
|
|
Global.right_cursor_tool_texture.create_from_image(load("res://Assets/Graphics/Tool Cursors/%s_Cursor.png" % Global.current_right_tool), 0)
|
2019-12-10 17:56:16 +00:00
|
|
|
|
2020-01-13 01:41:17 +00:00
|
|
|
|
2019-11-29 22:41:34 +00:00
|
|
|
func _on_LeftBrushTypeButton_pressed() -> void:
|
|
|
|
Global.brushes_popup.popup(Rect2(Global.left_brush_type_button.rect_global_position, Vector2(226, 72)))
|
2019-12-16 00:02:49 +00:00
|
|
|
Global.brush_type_window_position = "left"
|
2019-11-29 22:41:34 +00:00
|
|
|
|
|
|
|
func _on_RightBrushTypeButton_pressed() -> void:
|
|
|
|
Global.brushes_popup.popup(Rect2(Global.right_brush_type_button.rect_global_position, Vector2(226, 72)))
|
2019-12-16 00:02:49 +00:00
|
|
|
Global.brush_type_window_position = "right"
|
2019-11-29 22:41:34 +00:00
|
|
|
|
2019-11-10 01:25:25 +00:00
|
|
|
func _on_LeftBrushSizeEdit_value_changed(value) -> void:
|
2019-12-25 19:17:29 +00:00
|
|
|
Global.left_brush_size_edit.value = value
|
|
|
|
Global.left_brush_size_slider.value = value
|
2019-11-10 01:25:25 +00:00
|
|
|
var new_size = int(value)
|
|
|
|
Global.left_brush_size = new_size
|
|
|
|
update_left_custom_brush()
|
|
|
|
|
|
|
|
func _on_RightBrushSizeEdit_value_changed(value) -> void:
|
2019-12-25 19:17:29 +00:00
|
|
|
Global.right_brush_size_edit.value = value
|
|
|
|
Global.right_brush_size_slider.value = value
|
2019-11-10 01:25:25 +00:00
|
|
|
var new_size = int(value)
|
|
|
|
Global.right_brush_size = new_size
|
|
|
|
update_right_custom_brush()
|
2019-08-18 09:28:38 +00:00
|
|
|
|
2020-04-17 17:03:52 +00:00
|
|
|
func _on_Brush_Selected() -> void:
|
|
|
|
$BrushesPopup.hide()
|
2019-09-03 19:51:14 +00:00
|
|
|
|
2019-11-30 22:52:58 +00:00
|
|
|
func _on_ColorSwitch_pressed() -> void:
|
2019-12-27 22:00:24 +00:00
|
|
|
var temp: Color = Global.left_color_picker.color
|
2019-11-30 22:52:58 +00:00
|
|
|
Global.left_color_picker.color = Global.right_color_picker.color
|
|
|
|
Global.right_color_picker.color = temp
|
|
|
|
update_left_custom_brush()
|
|
|
|
update_right_custom_brush()
|
|
|
|
|
2020-04-13 02:07:52 +00:00
|
|
|
|
2019-11-30 22:52:58 +00:00
|
|
|
func _on_ColorDefaults_pressed() -> void:
|
|
|
|
Global.left_color_picker.color = Color.black
|
|
|
|
Global.right_color_picker.color = Color.white
|
|
|
|
update_left_custom_brush()
|
|
|
|
update_right_custom_brush()
|
|
|
|
|
2020-04-13 02:07:52 +00:00
|
|
|
|
2019-09-27 17:05:24 +00:00
|
|
|
func _on_LeftColorPickerButton_color_changed(color : Color) -> void:
|
2019-12-24 18:49:07 +00:00
|
|
|
# If the color changed while it's on full transparency, make it opaque (GH issue #54)
|
|
|
|
if color.a == 0:
|
2020-03-28 03:15:09 +00:00
|
|
|
if previous_left_color.r != color.r or previous_left_color.g != color.g or previous_left_color.b != color.b:
|
2019-12-24 18:49:07 +00:00
|
|
|
Global.left_color_picker.color.a = 1
|
2019-09-27 17:05:24 +00:00
|
|
|
update_left_custom_brush()
|
2019-12-24 18:49:07 +00:00
|
|
|
previous_left_color = color
|
2019-09-27 17:05:24 +00:00
|
|
|
|
2020-04-13 02:07:52 +00:00
|
|
|
|
2019-09-27 17:05:24 +00:00
|
|
|
func _on_RightColorPickerButton_color_changed(color : Color) -> void:
|
2019-12-24 18:49:07 +00:00
|
|
|
# If the color changed while it's on full transparency, make it opaque (GH issue #54)
|
|
|
|
if color.a == 0:
|
2020-03-28 03:15:09 +00:00
|
|
|
if previous_right_color.r != color.r or previous_right_color.g != color.g or previous_right_color.b != color.b:
|
2019-12-24 18:49:07 +00:00
|
|
|
Global.right_color_picker.color.a = 1
|
2019-09-27 17:05:24 +00:00
|
|
|
update_right_custom_brush()
|
2019-12-24 18:49:07 +00:00
|
|
|
previous_right_color = color
|
2019-09-27 17:05:24 +00:00
|
|
|
|
2020-04-13 02:07:52 +00:00
|
|
|
|
2019-09-27 17:05:24 +00:00
|
|
|
func _on_LeftInterpolateFactor_value_changed(value : float) -> void:
|
2019-12-25 19:42:01 +00:00
|
|
|
Global.left_interpolate_spinbox.value = value
|
|
|
|
Global.left_interpolate_slider.value = value
|
2019-09-27 17:05:24 +00:00
|
|
|
update_left_custom_brush()
|
|
|
|
|
2020-04-13 02:07:52 +00:00
|
|
|
|
2019-09-27 17:05:24 +00:00
|
|
|
func _on_RightInterpolateFactor_value_changed(value : float) -> void:
|
2019-12-25 19:42:01 +00:00
|
|
|
Global.right_interpolate_spinbox.value = value
|
|
|
|
Global.right_interpolate_slider.value = value
|
2019-09-27 17:05:24 +00:00
|
|
|
update_right_custom_brush()
|
|
|
|
|
2020-04-13 02:07:52 +00:00
|
|
|
|
2019-09-27 17:05:24 +00:00
|
|
|
func update_left_custom_brush() -> void:
|
|
|
|
Global.update_left_custom_brush()
|
2020-04-13 02:07:52 +00:00
|
|
|
|
|
|
|
|
2019-09-27 17:05:24 +00:00
|
|
|
func update_right_custom_brush() -> void:
|
2019-10-23 21:34:08 +00:00
|
|
|
Global.update_right_custom_brush()
|
|
|
|
|
2020-04-13 02:07:52 +00:00
|
|
|
|
2019-12-03 22:14:14 +00:00
|
|
|
func _on_LeftFillAreaOptions_item_selected(ID : int) -> void:
|
|
|
|
Global.left_fill_area = ID
|
|
|
|
|
2020-04-13 02:07:52 +00:00
|
|
|
|
2019-12-03 22:14:14 +00:00
|
|
|
func _on_RightFillAreaOptions_item_selected(ID : int) -> void:
|
|
|
|
Global.right_fill_area = ID
|
|
|
|
|
2020-04-13 02:07:52 +00:00
|
|
|
|
2019-12-03 23:01:37 +00:00
|
|
|
func _on_LeftLightenDarken_item_selected(ID : int) -> void:
|
|
|
|
Global.left_ld = ID
|
2020-04-13 02:07:52 +00:00
|
|
|
|
|
|
|
|
2019-12-03 23:01:37 +00:00
|
|
|
func _on_LeftLDAmountSpinbox_value_changed(value : float) -> void:
|
2019-12-17 02:01:38 +00:00
|
|
|
Global.left_ld_amount = value / 100
|
2019-12-25 19:42:01 +00:00
|
|
|
Global.left_ld_amount_slider.value = value
|
|
|
|
Global.left_ld_amount_spinbox.value = value
|
2019-12-03 23:01:37 +00:00
|
|
|
|
2020-04-13 02:07:52 +00:00
|
|
|
|
2019-12-03 23:01:37 +00:00
|
|
|
func _on_RightLightenDarken_item_selected(ID : int) -> void:
|
|
|
|
Global.right_ld = ID
|
2020-04-13 02:07:52 +00:00
|
|
|
|
|
|
|
|
2019-12-03 23:01:37 +00:00
|
|
|
func _on_RightLDAmountSpinbox_value_changed(value : float) -> void:
|
2019-12-17 02:01:38 +00:00
|
|
|
Global.right_ld_amount = value / 100
|
2019-12-25 19:42:01 +00:00
|
|
|
Global.right_ld_amount_slider.value = value
|
|
|
|
Global.right_ld_amount_spinbox.value = value
|
2019-12-03 23:01:37 +00:00
|
|
|
|
2020-04-13 02:07:52 +00:00
|
|
|
|
2020-01-10 20:44:29 +00:00
|
|
|
func _on_LeftForColorOptions_item_selected(ID : int) -> void:
|
|
|
|
Global.left_color_picker_for = ID
|
|
|
|
|
2020-04-13 02:07:52 +00:00
|
|
|
|
2020-01-10 20:44:29 +00:00
|
|
|
func _on_RightForColorOptions_item_selected(ID : int) -> void:
|
|
|
|
Global.right_color_picker_for = ID
|
|
|
|
|
2020-04-13 02:07:52 +00:00
|
|
|
|
|
|
|
func _on_LeftZoomModeOptions_item_selected(ID : int) -> void:
|
|
|
|
Global.left_zoom_mode = ID
|
|
|
|
|
|
|
|
|
|
|
|
func _on_RightZoomModeOptions_item_selected(ID : int) -> void:
|
|
|
|
Global.right_zoom_mode = ID
|
|
|
|
|
|
|
|
|
|
|
|
func _on_FitToFrameButton_pressed() -> void:
|
2020-04-16 15:34:57 +00:00
|
|
|
var bigger_canvas_axis = max(Global.canvas.size.x, Global.canvas.size.y)
|
|
|
|
var smaller_viewport_axis = min(Global.main_viewport.rect_size.x, Global.main_viewport.rect_size.y)
|
|
|
|
Global.camera.zoom = Vector2(bigger_canvas_axis, bigger_canvas_axis) / smaller_viewport_axis
|
2020-04-13 02:07:52 +00:00
|
|
|
Global.camera.offset = Global.canvas.size / 2
|
|
|
|
Global.zoom_level_label.text = str(round(100 / Global.camera.zoom.x)) + " %"
|
2020-04-20 15:52:05 +00:00
|
|
|
Global.horizontal_ruler.update()
|
|
|
|
Global.vertical_ruler.update()
|
2020-04-13 02:07:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_100ZoomButton_pressed() -> void:
|
|
|
|
Global.camera.zoom = Vector2.ONE
|
|
|
|
Global.camera.offset = Global.canvas.size / 2
|
|
|
|
Global.zoom_level_label.text = str(round(100 / Global.camera.zoom.x)) + " %"
|
2020-04-20 15:52:05 +00:00
|
|
|
Global.horizontal_ruler.update()
|
|
|
|
Global.vertical_ruler.update()
|
2020-04-13 02:07:52 +00:00
|
|
|
|
|
|
|
|
2019-10-23 21:34:08 +00:00
|
|
|
func _on_LeftHorizontalMirroring_toggled(button_pressed) -> void:
|
|
|
|
Global.left_horizontal_mirror = button_pressed
|
2020-04-13 02:07:52 +00:00
|
|
|
|
|
|
|
|
2019-10-23 21:34:08 +00:00
|
|
|
func _on_LeftVerticalMirroring_toggled(button_pressed) -> void:
|
|
|
|
Global.left_vertical_mirror = button_pressed
|
|
|
|
|
2020-04-13 02:07:52 +00:00
|
|
|
|
2019-10-23 21:34:08 +00:00
|
|
|
func _on_RightHorizontalMirroring_toggled(button_pressed) -> void:
|
|
|
|
Global.right_horizontal_mirror = button_pressed
|
2020-04-13 02:07:52 +00:00
|
|
|
|
|
|
|
|
2019-10-23 21:34:08 +00:00
|
|
|
func _on_RightVerticalMirroring_toggled(button_pressed) -> void:
|
2019-10-25 14:38:38 +00:00
|
|
|
Global.right_vertical_mirror = button_pressed
|
2019-11-19 21:36:37 +00:00
|
|
|
|
2020-04-13 02:07:52 +00:00
|
|
|
|
2020-02-23 00:11:52 +00:00
|
|
|
func show_quit_dialog() -> void:
|
|
|
|
if !$QuitDialog.visible:
|
|
|
|
if Global.saved:
|
|
|
|
$QuitDialog.call_deferred("popup_centered")
|
|
|
|
else:
|
|
|
|
$QuitAndSaveDialog.call_deferred("popup_centered")
|
2020-04-13 02:07:52 +00:00
|
|
|
|
2020-02-23 00:11:52 +00:00
|
|
|
Global.can_draw = false
|
|
|
|
|
2020-04-13 02:07:52 +00:00
|
|
|
|
2020-02-23 00:11:52 +00:00
|
|
|
func _on_QuitAndSaveDialog_custom_action(action : String) -> void:
|
2020-02-22 15:02:56 +00:00
|
|
|
if action == "Save":
|
2020-02-22 22:52:51 +00:00
|
|
|
is_quitting_on_save = true
|
2020-02-22 15:02:56 +00:00
|
|
|
$SaveSprite.popup_centered()
|
2020-02-22 15:14:32 +00:00
|
|
|
$QuitDialog.hide()
|
2020-02-22 15:02:56 +00:00
|
|
|
Global.can_draw = false
|
|
|
|
|
2020-04-13 02:07:52 +00:00
|
|
|
|
2020-02-22 22:52:51 +00:00
|
|
|
func _on_QuitDialog_confirmed() -> void:
|
|
|
|
# Darken the UI to denote that the application is currently exiting
|
|
|
|
# (it won't respond to user input in this state).
|
|
|
|
modulate = Color(0.5, 0.5, 0.5)
|
|
|
|
|
|
|
|
get_tree().quit()
|