mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-31 07:29:49 +00:00
Refactoring Main.gd. Mostly cutting big methods into smaller ones. (#244)
* Refactoring Main.gd. Mostly cutting big methods into smaller one. - Reduced size of _ready method in Main.gd - Moved code from certain parts of old _ready method into seperate methods - Fixed the translation bug related to CurrentFrame node in TopMenuContainer scene. The CurrentFrame node wasn't updating the language when I was changing language. I've also changed the translation file for this. - Fixed Global.palette_option_button.selected related warning. Because of some unknown reasons, git didn't push completed line there. - Moved code from file_menu_id_pressed and view_menu_id_pressed method in Main.gd to separate methods to make it more readable. * Removed window_title changes from Main.tscn Co-authored-by: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com>
This commit is contained in:
parent
852e249143
commit
aae3ae0cf4
|
@ -732,9 +732,6 @@ msgstr ""
|
||||||
msgid "Current frame:"
|
msgid "Current frame:"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Current frame: 1/1"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "Jump to the first frame\n"
|
msgid "Jump to the first frame\n"
|
||||||
"(%s)"
|
"(%s)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
|
@ -234,7 +234,7 @@ var animation_timeline : Panel
|
||||||
|
|
||||||
var animation_timer : Timer
|
var animation_timer : Timer
|
||||||
var frame_ids : HBoxContainer
|
var frame_ids : HBoxContainer
|
||||||
var current_frame_label : Label
|
var current_frame_mark_label : Label
|
||||||
var onion_skinning_button : BaseButton
|
var onion_skinning_button : BaseButton
|
||||||
var loop_animation_button : BaseButton
|
var loop_animation_button : BaseButton
|
||||||
var play_forward : BaseButton
|
var play_forward : BaseButton
|
||||||
|
@ -372,7 +372,7 @@ func _ready() -> void:
|
||||||
frames_container = find_node_by_name(animation_timeline, "FramesContainer")
|
frames_container = find_node_by_name(animation_timeline, "FramesContainer")
|
||||||
animation_timer = find_node_by_name(animation_timeline, "AnimationTimer")
|
animation_timer = find_node_by_name(animation_timeline, "AnimationTimer")
|
||||||
frame_ids = find_node_by_name(animation_timeline, "FrameIDs")
|
frame_ids = find_node_by_name(animation_timeline, "FrameIDs")
|
||||||
current_frame_label = find_node_by_name(control, "CurrentFrame")
|
current_frame_mark_label = find_node_by_name(control, "CurrentFrameMark")
|
||||||
onion_skinning_button = find_node_by_name(animation_timeline, "OnionSkinning")
|
onion_skinning_button = find_node_by_name(animation_timeline, "OnionSkinning")
|
||||||
loop_animation_button = find_node_by_name(animation_timeline, "LoopAnim")
|
loop_animation_button = find_node_by_name(animation_timeline, "LoopAnim")
|
||||||
play_forward = find_node_by_name(animation_timeline, "PlayForward")
|
play_forward = find_node_by_name(animation_timeline, "PlayForward")
|
||||||
|
@ -625,7 +625,7 @@ func layers_changed(value : Array) -> void:
|
||||||
|
|
||||||
func frame_changed(value : int) -> void:
|
func frame_changed(value : int) -> void:
|
||||||
current_frame = value
|
current_frame = value
|
||||||
current_frame_label.text = tr("Current frame:") + " %s/%s" % [str(current_frame + 1), canvases.size()]
|
current_frame_mark_label.text = "%s/%s" % [str(current_frame + 1), canvases.size()]
|
||||||
|
|
||||||
var i := 0
|
var i := 0
|
||||||
for c in canvases: # De-select all the other canvases/frames
|
for c in canvases: # De-select all the other canvases/frames
|
||||||
|
|
399
src/Main.gd
399
src/Main.gd
|
@ -11,13 +11,63 @@ var is_quitting_on_save := false
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
get_tree().set_auto_accept_quit(false)
|
get_tree().set_auto_accept_quit(false)
|
||||||
|
setup_application_window_size()
|
||||||
|
|
||||||
|
setup_translation_settings()
|
||||||
|
|
||||||
|
setup_file_menu()
|
||||||
|
setup_edit_menu()
|
||||||
|
setup_view_menu()
|
||||||
|
setup_image_menu()
|
||||||
|
setup_help_menu()
|
||||||
|
|
||||||
|
Global.window_title = "(" + tr("untitled") + ") - Pixelorama " + Global.current_version
|
||||||
|
|
||||||
|
Global.layers[0][0] = tr("Layer") + " 0"
|
||||||
|
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]
|
||||||
|
|
||||||
|
Import.import_brushes(Global.directory_module.get_brushes_search_path_in_order())
|
||||||
|
Import.import_patterns(Global.directory_module.get_patterns_search_path_in_order())
|
||||||
|
|
||||||
|
Global.left_color_picker.get_picker().presets_visible = false
|
||||||
|
Global.right_color_picker.get_picker().presets_visible = false
|
||||||
|
|
||||||
|
$QuitAndSaveDialog.add_button("Save & Exit", false, "Save")
|
||||||
|
$QuitAndSaveDialog.get_ok().text = "Exit without saving"
|
||||||
|
|
||||||
|
if not Global.config_cache.has_section_key("preferences", "startup"):
|
||||||
|
Global.config_cache.set_value("preferences", "startup", true)
|
||||||
|
show_splash_screen()
|
||||||
|
|
||||||
|
handle_backup()
|
||||||
|
|
||||||
|
handle_running_pixelorama_with_arguments()
|
||||||
|
|
||||||
|
|
||||||
|
func _input(event : InputEvent) -> void:
|
||||||
|
Global.left_cursor.position = get_global_mouse_position() + Vector2(-32, 32)
|
||||||
|
Global.left_cursor.texture = Global.left_cursor_tool_texture
|
||||||
|
Global.right_cursor.position = get_global_mouse_position() + Vector2(32, 32)
|
||||||
|
Global.right_cursor.texture = Global.right_cursor_tool_texture
|
||||||
|
|
||||||
|
if event is InputEventKey and (event.scancode == KEY_ENTER or event.scancode == KEY_KP_ENTER):
|
||||||
|
if get_focus_owner() is LineEdit:
|
||||||
|
get_focus_owner().release_focus()
|
||||||
|
|
||||||
|
if event.is_action_pressed("toggle_fullscreen"):
|
||||||
|
OS.window_fullscreen = !OS.window_fullscreen
|
||||||
|
|
||||||
|
if event.is_action_pressed("redo_secondary"): # Shift + Ctrl + Z
|
||||||
|
redone = true
|
||||||
|
Global.undo_redo.redo()
|
||||||
|
redone = false
|
||||||
|
|
||||||
|
|
||||||
|
func setup_application_window_size() -> void:
|
||||||
# Set a minimum window size to prevent UI elements from collapsing on each other.
|
# 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.
|
# This property is only available in 3.2alpha or later, so use `set()` to fail gracefully if it doesn't exist.
|
||||||
OS.set("min_window_size", Vector2(1024, 576))
|
OS.set("min_window_size", Vector2(1024, 576))
|
||||||
Global.loaded_locales = TranslationServer.get_loaded_locales()
|
|
||||||
|
|
||||||
# Make sure locales are always sorted, in the same order
|
|
||||||
Global.loaded_locales.sort()
|
|
||||||
|
|
||||||
# Restore the window position/size if values are present in the configuration cache
|
# Restore the window position/size if values are present in the configuration cache
|
||||||
if Global.config_cache.has_section_key("window", "screen"):
|
if Global.config_cache.has_section_key("window", "screen"):
|
||||||
|
@ -31,48 +81,12 @@ func _ready() -> void:
|
||||||
if Global.config_cache.has_section_key("window", "size"):
|
if Global.config_cache.has_section_key("window", "size"):
|
||||||
OS.window_size = Global.config_cache.get_value("window", "size")
|
OS.window_size = Global.config_cache.get_value("window", "size")
|
||||||
|
|
||||||
var file_menu_items := {
|
|
||||||
"New..." : InputMap.get_action_list("new_file")[0].get_scancode_with_modifiers(),
|
func setup_translation_settings() -> void:
|
||||||
"Open..." : InputMap.get_action_list("open_file")[0].get_scancode_with_modifiers(),
|
Global.loaded_locales = TranslationServer.get_loaded_locales()
|
||||||
'Open last project...' : 0,
|
|
||||||
"Save..." : InputMap.get_action_list("save_file")[0].get_scancode_with_modifiers(),
|
# Make sure locales are always sorted, in the same order
|
||||||
"Save as..." : InputMap.get_action_list("save_file_as")[0].get_scancode_with_modifiers(),
|
Global.loaded_locales.sort()
|
||||||
"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(),
|
|
||||||
}
|
|
||||||
var edit_menu_items := {
|
|
||||||
"Undo" : InputMap.get_action_list("undo")[0].get_scancode_with_modifiers(),
|
|
||||||
"Redo" : InputMap.get_action_list("redo")[0].get_scancode_with_modifiers(),
|
|
||||||
"Clear Selection" : 0,
|
|
||||||
"Preferences" : 0
|
|
||||||
}
|
|
||||||
var view_menu_items := {
|
|
||||||
"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(),
|
|
||||||
"Show Animation Timeline" : 0
|
|
||||||
}
|
|
||||||
var image_menu_items := {
|
|
||||||
"Scale Image" : 0,
|
|
||||||
"Crop Image" : 0,
|
|
||||||
"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(),
|
|
||||||
"Rotate Image" : 0,
|
|
||||||
"Invert colors" : 0,
|
|
||||||
"Desaturation" : 0,
|
|
||||||
"Outline" : 0,
|
|
||||||
"Adjust Hue/Saturation/Value" : 0
|
|
||||||
}
|
|
||||||
var help_menu_items := {
|
|
||||||
"View Splash Screen" : 0,
|
|
||||||
"Online Docs" : 0,
|
|
||||||
"Issue Tracker" : 0,
|
|
||||||
"Changelog" : 0,
|
|
||||||
"About Pixelorama" : 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# Load language
|
# Load language
|
||||||
if Global.config_cache.has_section_key("preferences", "locale"):
|
if Global.config_cache.has_section_key("preferences", "locale"):
|
||||||
|
@ -92,67 +106,110 @@ func _ready() -> void:
|
||||||
theme.default_font = preload("res://assets/fonts/Roboto-Regular.tres")
|
theme.default_font = preload("res://assets/fonts/Roboto-Regular.tres")
|
||||||
|
|
||||||
|
|
||||||
|
func setup_file_menu() -> void:
|
||||||
|
var file_menu_items := {
|
||||||
|
"New..." : InputMap.get_action_list("new_file")[0].get_scancode_with_modifiers(),
|
||||||
|
"Open..." : InputMap.get_action_list("open_file")[0].get_scancode_with_modifiers(),
|
||||||
|
'Open last project...' : 0,
|
||||||
|
"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(),
|
||||||
|
}
|
||||||
file_menu = Global.file_menu.get_popup()
|
file_menu = Global.file_menu.get_popup()
|
||||||
var edit_menu : PopupMenu = Global.edit_menu.get_popup()
|
var i := 0
|
||||||
view_menu = Global.view_menu.get_popup()
|
|
||||||
var image_menu : PopupMenu = Global.image_menu.get_popup()
|
|
||||||
var help_menu : PopupMenu = Global.help_menu.get_popup()
|
|
||||||
|
|
||||||
var i = 0
|
|
||||||
for item in file_menu_items.keys():
|
for item in file_menu_items.keys():
|
||||||
file_menu.add_item(item, i, file_menu_items[item])
|
file_menu.add_item(item, i, file_menu_items[item])
|
||||||
i += 1
|
i += 1
|
||||||
i = 0
|
|
||||||
|
file_menu.connect("id_pressed", self, "file_menu_id_pressed")
|
||||||
|
|
||||||
|
|
||||||
|
func setup_edit_menu() -> void:
|
||||||
|
var edit_menu_items := {
|
||||||
|
"Undo" : InputMap.get_action_list("undo")[0].get_scancode_with_modifiers(),
|
||||||
|
"Redo" : InputMap.get_action_list("redo")[0].get_scancode_with_modifiers(),
|
||||||
|
"Clear Selection" : 0,
|
||||||
|
"Preferences" : 0
|
||||||
|
}
|
||||||
|
var edit_menu : PopupMenu = Global.edit_menu.get_popup()
|
||||||
|
var i := 0
|
||||||
|
|
||||||
for item in edit_menu_items.keys():
|
for item in edit_menu_items.keys():
|
||||||
edit_menu.add_item(item, i, edit_menu_items[item])
|
edit_menu.add_item(item, i, edit_menu_items[item])
|
||||||
i += 1
|
i += 1
|
||||||
i = 0
|
|
||||||
|
edit_menu.connect("id_pressed", self, "edit_menu_id_pressed")
|
||||||
|
|
||||||
|
|
||||||
|
func setup_view_menu() -> void:
|
||||||
|
var view_menu_items := {
|
||||||
|
"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(),
|
||||||
|
"Show Animation Timeline" : 0
|
||||||
|
}
|
||||||
|
view_menu = Global.view_menu.get_popup()
|
||||||
|
|
||||||
|
var i := 0
|
||||||
for item in view_menu_items.keys():
|
for item in view_menu_items.keys():
|
||||||
view_menu.add_check_item(item, i, view_menu_items[item])
|
view_menu.add_check_item(item, i, view_menu_items[item])
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
view_menu.set_item_checked(2, true) # Show Rulers
|
view_menu.set_item_checked(2, true) # Show Rulers
|
||||||
view_menu.set_item_checked(3, true) # Show Guides
|
view_menu.set_item_checked(3, true) # Show Guides
|
||||||
view_menu.set_item_checked(4, true) # Show Animation Timeline
|
view_menu.set_item_checked(4, true) # Show Animation Timeline
|
||||||
view_menu.hide_on_checkable_item_selection = false
|
view_menu.hide_on_checkable_item_selection = false
|
||||||
i = 0
|
view_menu.connect("id_pressed", self, "view_menu_id_pressed")
|
||||||
|
|
||||||
|
|
||||||
|
func setup_image_menu() -> void:
|
||||||
|
var image_menu_items := {
|
||||||
|
"Scale Image" : 0,
|
||||||
|
"Crop Image" : 0,
|
||||||
|
"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(),
|
||||||
|
"Rotate Image" : 0,
|
||||||
|
"Invert colors" : 0,
|
||||||
|
"Desaturation" : 0,
|
||||||
|
"Outline" : 0,
|
||||||
|
"Adjust Hue/Saturation/Value" : 0
|
||||||
|
}
|
||||||
|
var image_menu : PopupMenu = Global.image_menu.get_popup()
|
||||||
|
|
||||||
|
var i := 0
|
||||||
for item in image_menu_items.keys():
|
for item in image_menu_items.keys():
|
||||||
image_menu.add_item(item, i, image_menu_items[item])
|
image_menu.add_item(item, i, image_menu_items[item])
|
||||||
if i == 4:
|
if i == 4:
|
||||||
image_menu.add_separator()
|
image_menu.add_separator()
|
||||||
i += 1
|
i += 1
|
||||||
i = 0
|
|
||||||
|
image_menu.connect("id_pressed", self, "image_menu_id_pressed")
|
||||||
|
|
||||||
|
|
||||||
|
func setup_help_menu() -> void:
|
||||||
|
var help_menu_items := {
|
||||||
|
"View Splash Screen" : 0,
|
||||||
|
"Online Docs" : 0,
|
||||||
|
"Issue Tracker" : 0,
|
||||||
|
"Changelog" : 0,
|
||||||
|
"About Pixelorama" : 0
|
||||||
|
}
|
||||||
|
var help_menu : PopupMenu = Global.help_menu.get_popup()
|
||||||
|
|
||||||
|
var i := 0
|
||||||
for item in help_menu_items.keys():
|
for item in help_menu_items.keys():
|
||||||
help_menu.add_item(item, i, help_menu_items[item])
|
help_menu.add_item(item, i, help_menu_items[item])
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
file_menu.connect("id_pressed", self, "file_menu_id_pressed")
|
|
||||||
edit_menu.connect("id_pressed", self, "edit_menu_id_pressed")
|
|
||||||
view_menu.connect("id_pressed", self, "view_menu_id_pressed")
|
|
||||||
image_menu.connect("id_pressed", self, "image_menu_id_pressed")
|
|
||||||
help_menu.connect("id_pressed", self, "help_menu_id_pressed")
|
help_menu.connect("id_pressed", self, "help_menu_id_pressed")
|
||||||
|
|
||||||
# Checks to see if it's 3.1.x
|
|
||||||
if Engine.get_version_info().major == 3 and Engine.get_version_info().minor < 2:
|
|
||||||
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)
|
|
||||||
|
|
||||||
Global.window_title = "(" + tr("untitled") + ") - Pixelorama " + Global.current_version
|
|
||||||
|
|
||||||
Global.layers[0][0] = tr("Layer") + " 0"
|
|
||||||
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]
|
|
||||||
|
|
||||||
Import.import_brushes(Global.directory_module.get_brushes_search_path_in_order())
|
|
||||||
Import.import_patterns(Global.directory_module.get_patterns_search_path_in_order())
|
|
||||||
|
|
||||||
Global.left_color_picker.get_picker().presets_visible = false
|
|
||||||
Global.right_color_picker.get_picker().presets_visible = false
|
|
||||||
$QuitAndSaveDialog.add_button("Save & Exit", false, "Save")
|
|
||||||
$QuitAndSaveDialog.get_ok().text = "Exit without saving"
|
|
||||||
|
|
||||||
if not Global.config_cache.has_section_key("preferences", "startup"):
|
|
||||||
Global.config_cache.set_value("preferences", "startup", true)
|
|
||||||
|
|
||||||
|
func show_splash_screen() -> void:
|
||||||
# Wait for the window to adjust itself, so the popup is correctly centered
|
# Wait for the window to adjust itself, so the popup is correctly centered
|
||||||
yield(get_tree().create_timer(0.01), "timeout")
|
yield(get_tree().create_timer(0.01), "timeout")
|
||||||
if Global.config_cache.get_value("preferences", "startup"):
|
if Global.config_cache.get_value("preferences", "startup"):
|
||||||
|
@ -161,6 +218,8 @@ func _ready() -> void:
|
||||||
else:
|
else:
|
||||||
Global.can_draw = true
|
Global.can_draw = true
|
||||||
|
|
||||||
|
|
||||||
|
func handle_backup() -> void:
|
||||||
# If backup file exists then Pixelorama was not closed properly (probably crashed) - reopen backup
|
# If backup file exists then Pixelorama was not closed properly (probably crashed) - reopen backup
|
||||||
$BackupConfirmation.get_cancel().text = tr("Delete")
|
$BackupConfirmation.get_cancel().text = tr("Delete")
|
||||||
if Global.config_cache.has_section("backups"):
|
if Global.config_cache.has_section("backups"):
|
||||||
|
@ -184,6 +243,9 @@ func _ready() -> void:
|
||||||
if Global.open_last_project:
|
if Global.open_last_project:
|
||||||
load_last_project()
|
load_last_project()
|
||||||
|
|
||||||
|
|
||||||
|
func handle_running_pixelorama_with_arguments() -> void:
|
||||||
|
# If user want to run Pixelorama with arguments in terminal mode then handle that
|
||||||
if OS.get_cmdline_args():
|
if OS.get_cmdline_args():
|
||||||
for arg in OS.get_cmdline_args():
|
for arg in OS.get_cmdline_args():
|
||||||
if arg.get_extension().to_lower() == "pxo":
|
if arg.get_extension().to_lower() == "pxo":
|
||||||
|
@ -195,77 +257,86 @@ func _ready() -> void:
|
||||||
$ImportSprites.new_frame = true
|
$ImportSprites.new_frame = true
|
||||||
|
|
||||||
|
|
||||||
func _input(event : InputEvent) -> void:
|
|
||||||
Global.left_cursor.position = get_global_mouse_position() + Vector2(-32, 32)
|
|
||||||
Global.left_cursor.texture = Global.left_cursor_tool_texture
|
|
||||||
Global.right_cursor.position = get_global_mouse_position() + Vector2(32, 32)
|
|
||||||
Global.right_cursor.texture = Global.right_cursor_tool_texture
|
|
||||||
|
|
||||||
if event is InputEventKey and (event.scancode == KEY_ENTER or event.scancode == KEY_KP_ENTER):
|
|
||||||
if get_focus_owner() is LineEdit:
|
|
||||||
get_focus_owner().release_focus()
|
|
||||||
|
|
||||||
if event.is_action_pressed("toggle_fullscreen"):
|
|
||||||
OS.window_fullscreen = !OS.window_fullscreen
|
|
||||||
|
|
||||||
if event.is_action_pressed("redo_secondary"): # Shift + Ctrl + Z
|
|
||||||
redone = true
|
|
||||||
Global.undo_redo.redo()
|
|
||||||
redone = false
|
|
||||||
|
|
||||||
|
|
||||||
func _notification(what : int) -> void:
|
func _notification(what : int) -> void:
|
||||||
if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST: # Handle exit
|
if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST: # Handle exit
|
||||||
show_quit_dialog()
|
show_quit_dialog()
|
||||||
|
|
||||||
|
|
||||||
|
func on_new_project_file_menu_option_pressed(id : int) -> void:
|
||||||
|
if Global.project_has_changed:
|
||||||
|
unsaved_canvas_state = id
|
||||||
|
$UnsavedCanvasDialog.popup_centered()
|
||||||
|
else:
|
||||||
|
$CreateNewImage.popup_centered()
|
||||||
|
Global.dialog_open(true)
|
||||||
|
|
||||||
|
|
||||||
|
func open_project_file() -> void:
|
||||||
|
$OpenSprite.popup_centered()
|
||||||
|
Global.dialog_open(true)
|
||||||
|
opensprite_file_selected = false
|
||||||
|
|
||||||
|
|
||||||
|
func on_open_last_project_file_menu_option_pressed(id : int) -> void:
|
||||||
|
# Check if last project path is set and if yes then open
|
||||||
|
if Global.config_cache.has_section_key("preferences", "last_project_path"):
|
||||||
|
if Global.project_has_changed:
|
||||||
|
unsaved_canvas_state = id
|
||||||
|
$UnsavedCanvasDialog.popup_centered()
|
||||||
|
Global.dialog_open(true)
|
||||||
|
else:
|
||||||
|
load_last_project()
|
||||||
|
else: # if not then warn user that he didn't edit any project yet
|
||||||
|
Global.error_dialog.set_text("You haven't saved or opened any project in Pixelorama yet!")
|
||||||
|
Global.error_dialog.popup_centered()
|
||||||
|
Global.dialog_open(true)
|
||||||
|
|
||||||
|
|
||||||
|
func save_project_file() -> void:
|
||||||
|
is_quitting_on_save = false
|
||||||
|
if OpenSave.current_save_path == "":
|
||||||
|
$SaveSprite.popup_centered()
|
||||||
|
Global.dialog_open(true)
|
||||||
|
else:
|
||||||
|
_on_SaveSprite_file_selected(OpenSave.current_save_path)
|
||||||
|
|
||||||
|
|
||||||
|
func save_project_file_as() -> void:
|
||||||
|
is_quitting_on_save = false
|
||||||
|
$SaveSprite.popup_centered()
|
||||||
|
Global.dialog_open(true)
|
||||||
|
|
||||||
|
|
||||||
|
func import_file() -> void:
|
||||||
|
$ImportSprites.popup_centered()
|
||||||
|
Global.dialog_open(true)
|
||||||
|
opensprite_file_selected = false
|
||||||
|
|
||||||
|
|
||||||
|
func export_file() -> void:
|
||||||
|
if $ExportDialog.was_exported == false:
|
||||||
|
$ExportDialog.popup_centered()
|
||||||
|
Global.dialog_open(true)
|
||||||
|
else:
|
||||||
|
$ExportDialog.external_export()
|
||||||
|
|
||||||
|
|
||||||
func file_menu_id_pressed(id : int) -> void:
|
func file_menu_id_pressed(id : int) -> void:
|
||||||
match id:
|
match id:
|
||||||
0: # New
|
0: # New
|
||||||
if Global.project_has_changed:
|
on_new_project_file_menu_option_pressed(id)
|
||||||
unsaved_canvas_state = id
|
|
||||||
$UnsavedCanvasDialog.popup_centered()
|
|
||||||
else:
|
|
||||||
$CreateNewImage.popup_centered()
|
|
||||||
Global.dialog_open(true)
|
|
||||||
1: # Open
|
1: # Open
|
||||||
$OpenSprite.popup_centered()
|
open_project_file()
|
||||||
Global.dialog_open(true)
|
|
||||||
opensprite_file_selected = false
|
|
||||||
2: # Open last project
|
2: # Open last project
|
||||||
# Check if last project path is set and if yes then open
|
on_open_last_project_file_menu_option_pressed(id)
|
||||||
if Global.config_cache.has_section_key("preferences", "last_project_path"):
|
|
||||||
if Global.project_has_changed:
|
|
||||||
unsaved_canvas_state = id
|
|
||||||
$UnsavedCanvasDialog.popup_centered()
|
|
||||||
Global.dialog_open(true)
|
|
||||||
else:
|
|
||||||
load_last_project()
|
|
||||||
else: # if not then warn user that he didn't edit any project yet
|
|
||||||
Global.error_dialog.set_text("You haven't saved or opened any project in Pixelorama yet!")
|
|
||||||
Global.error_dialog.popup_centered()
|
|
||||||
Global.dialog_open(true)
|
|
||||||
3: # Save
|
3: # Save
|
||||||
is_quitting_on_save = false
|
save_project_file()
|
||||||
if OpenSave.current_save_path == "":
|
|
||||||
$SaveSprite.popup_centered()
|
|
||||||
Global.dialog_open(true)
|
|
||||||
else:
|
|
||||||
_on_SaveSprite_file_selected(OpenSave.current_save_path)
|
|
||||||
4: # Save as
|
4: # Save as
|
||||||
is_quitting_on_save = false
|
save_project_file_as()
|
||||||
$SaveSprite.popup_centered()
|
|
||||||
Global.dialog_open(true)
|
|
||||||
5: # Import
|
5: # Import
|
||||||
$ImportSprites.popup_centered()
|
import_file()
|
||||||
Global.dialog_open(true)
|
|
||||||
opensprite_file_selected = false
|
|
||||||
6: # Export
|
6: # Export
|
||||||
if $ExportDialog.was_exported == false:
|
export_file()
|
||||||
$ExportDialog.popup_centered()
|
|
||||||
Global.dialog_open(true)
|
|
||||||
else:
|
|
||||||
$ExportDialog.external_export()
|
|
||||||
7: # Export as
|
7: # Export as
|
||||||
$ExportDialog.popup_centered()
|
$ExportDialog.popup_centered()
|
||||||
Global.dialog_open(true)
|
Global.dialog_open(true)
|
||||||
|
@ -294,30 +365,50 @@ func edit_menu_id_pressed(id : int) -> void:
|
||||||
Global.dialog_open(true)
|
Global.dialog_open(true)
|
||||||
|
|
||||||
|
|
||||||
|
func toggle_tile_mode() -> void:
|
||||||
|
Global.tile_mode = !Global.tile_mode
|
||||||
|
view_menu.set_item_checked(0, Global.tile_mode)
|
||||||
|
|
||||||
|
|
||||||
|
func toggle_show_grid() -> void:
|
||||||
|
Global.draw_grid = !Global.draw_grid
|
||||||
|
view_menu.set_item_checked(1, Global.draw_grid)
|
||||||
|
|
||||||
|
|
||||||
|
func toggle_show_rulers() -> void:
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
func toggle_show_guides() -> void:
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
func toggle_show_anim_timeline() -> void:
|
||||||
|
Global.show_animation_timeline = !Global.show_animation_timeline
|
||||||
|
view_menu.set_item_checked(4, Global.show_animation_timeline)
|
||||||
|
Global.animation_timeline.visible = Global.show_animation_timeline
|
||||||
|
|
||||||
|
|
||||||
func view_menu_id_pressed(id : int) -> void:
|
func view_menu_id_pressed(id : int) -> void:
|
||||||
match id:
|
match id:
|
||||||
0: # Tile mode
|
0: # Tile mode
|
||||||
Global.tile_mode = !Global.tile_mode
|
toggle_tile_mode()
|
||||||
view_menu.set_item_checked(0, Global.tile_mode)
|
|
||||||
1: # Show grid
|
1: # Show grid
|
||||||
Global.draw_grid = !Global.draw_grid
|
toggle_show_grid()
|
||||||
view_menu.set_item_checked(1, Global.draw_grid)
|
|
||||||
2: # Show rulers
|
2: # Show rulers
|
||||||
Global.show_rulers = !Global.show_rulers
|
toggle_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
|
3: # Show guides
|
||||||
Global.show_guides = !Global.show_guides
|
toggle_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
|
|
||||||
4: # Show animation timeline
|
4: # Show animation timeline
|
||||||
Global.show_animation_timeline = !Global.show_animation_timeline
|
toggle_show_anim_timeline()
|
||||||
view_menu.set_item_checked(4, Global.show_animation_timeline)
|
|
||||||
Global.animation_timeline.visible = Global.show_animation_timeline
|
|
||||||
|
|
||||||
Global.canvas.update()
|
Global.canvas.update()
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,7 @@ func _load_palettes() -> void:
|
||||||
# You need these two lines because when you remove a palette
|
# You need these two lines because when you remove a palette
|
||||||
# Then this just won't work and _on_PaletteOptionButton_item_selected
|
# Then this just won't work and _on_PaletteOptionButton_item_selected
|
||||||
# method won't fire.
|
# method won't fire.
|
||||||
Global.palette_option_button.selected
|
Global.palette_option_button.selected = index
|
||||||
on_palette_select("Default")
|
on_palette_select("Default")
|
||||||
Global.palette_option_button.select(index)
|
Global.palette_option_button.select(index)
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,9 @@ margin_right = 1280.0
|
||||||
margin_bottom = 28.0
|
margin_bottom = 28.0
|
||||||
rect_min_size = Vector2( 0, 28 )
|
rect_min_size = Vector2( 0, 28 )
|
||||||
custom_styles/panel = ExtResource( 1 )
|
custom_styles/panel = ExtResource( 1 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
[node name="MenuItems" type="HBoxContainer" parent="."]
|
[node name="MenuItems" type="HBoxContainer" parent="."]
|
||||||
margin_left = 2.0
|
margin_left = 2.0
|
||||||
|
@ -17,40 +20,40 @@ __meta__ = {
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="FileMenu" type="MenuButton" parent="MenuItems"]
|
[node name="FileMenu" type="MenuButton" parent="MenuItems"]
|
||||||
margin_right = 29.0
|
margin_right = 35.0
|
||||||
margin_bottom = 21.0
|
margin_bottom = 20.0
|
||||||
mouse_default_cursor_shape = 2
|
mouse_default_cursor_shape = 2
|
||||||
text = "File"
|
text = "File"
|
||||||
switch_on_hover = true
|
switch_on_hover = true
|
||||||
|
|
||||||
[node name="EditMenu" type="MenuButton" parent="MenuItems"]
|
[node name="EditMenu" type="MenuButton" parent="MenuItems"]
|
||||||
margin_left = 33.0
|
margin_left = 39.0
|
||||||
margin_right = 64.0
|
margin_right = 75.0
|
||||||
margin_bottom = 21.0
|
margin_bottom = 20.0
|
||||||
mouse_default_cursor_shape = 2
|
mouse_default_cursor_shape = 2
|
||||||
text = "Edit"
|
text = "Edit"
|
||||||
switch_on_hover = true
|
switch_on_hover = true
|
||||||
|
|
||||||
[node name="ViewMenu" type="MenuButton" parent="MenuItems"]
|
[node name="ViewMenu" type="MenuButton" parent="MenuItems"]
|
||||||
margin_left = 68.0
|
margin_left = 79.0
|
||||||
margin_right = 104.0
|
margin_right = 121.0
|
||||||
margin_bottom = 21.0
|
margin_bottom = 20.0
|
||||||
mouse_default_cursor_shape = 2
|
mouse_default_cursor_shape = 2
|
||||||
text = "View"
|
text = "View"
|
||||||
switch_on_hover = true
|
switch_on_hover = true
|
||||||
|
|
||||||
[node name="ImageMenu" type="MenuButton" parent="MenuItems"]
|
[node name="ImageMenu" type="MenuButton" parent="MenuItems"]
|
||||||
margin_left = 108.0
|
margin_left = 125.0
|
||||||
margin_right = 152.0
|
margin_right = 177.0
|
||||||
margin_bottom = 21.0
|
margin_bottom = 20.0
|
||||||
mouse_default_cursor_shape = 2
|
mouse_default_cursor_shape = 2
|
||||||
text = "Image"
|
text = "Image"
|
||||||
switch_on_hover = true
|
switch_on_hover = true
|
||||||
|
|
||||||
[node name="HelpMenu" type="MenuButton" parent="MenuItems"]
|
[node name="HelpMenu" type="MenuButton" parent="MenuItems"]
|
||||||
margin_left = 156.0
|
margin_left = 181.0
|
||||||
margin_right = 191.0
|
margin_right = 223.0
|
||||||
margin_bottom = 21.0
|
margin_bottom = 20.0
|
||||||
mouse_default_cursor_shape = 2
|
mouse_default_cursor_shape = 2
|
||||||
text = "Help"
|
text = "Help"
|
||||||
switch_on_hover = true
|
switch_on_hover = true
|
||||||
|
@ -67,7 +70,7 @@ __meta__ = {
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="ZoomLevel" type="Label" parent="TopLabels"]
|
[node name="ZoomLevel" type="Label" parent="TopLabels"]
|
||||||
margin_top = 6.0
|
margin_top = 7.0
|
||||||
margin_right = 60.0
|
margin_right = 60.0
|
||||||
margin_bottom = 21.0
|
margin_bottom = 21.0
|
||||||
rect_min_size = Vector2( 60, 0 )
|
rect_min_size = Vector2( 60, 0 )
|
||||||
|
@ -76,8 +79,8 @@ align = 2
|
||||||
|
|
||||||
[node name="CursorPosition" type="Label" parent="TopLabels"]
|
[node name="CursorPosition" type="Label" parent="TopLabels"]
|
||||||
margin_left = 80.0
|
margin_left = 80.0
|
||||||
margin_top = 6.0
|
margin_top = 7.0
|
||||||
margin_right = 120.0
|
margin_right = 128.0
|
||||||
margin_bottom = 21.0
|
margin_bottom = 21.0
|
||||||
text = "[64×64]"
|
text = "[64×64]"
|
||||||
align = 2
|
align = 2
|
||||||
|
@ -98,12 +101,20 @@ __meta__ = {
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="CurrentFrame" type="Label" parent="HBoxContainer"]
|
[node name="CurrentFrame" type="Label" parent="HBoxContainer"]
|
||||||
margin_left = 113.0
|
margin_left = 106.0
|
||||||
margin_top = 6.0
|
margin_right = 198.0
|
||||||
margin_right = 216.0
|
margin_bottom = 28.0
|
||||||
margin_bottom = 21.0
|
size_flags_vertical = 1
|
||||||
text = "Current Frame: 1/1"
|
text = "Current frame:"
|
||||||
valign = 1
|
valign = 1
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[node name="CurrentFrameMark" type="Label" parent="HBoxContainer"]
|
||||||
|
margin_left = 202.0
|
||||||
|
margin_right = 223.0
|
||||||
|
margin_bottom = 28.0
|
||||||
|
size_flags_vertical = 1
|
||||||
|
text = "1/2"
|
||||||
|
valign = 1
|
||||||
|
|
Loading…
Reference in a new issue