2020-06-13 14:59:57 +00:00
|
|
|
extends Panel
|
|
|
|
|
|
|
|
|
|
|
|
var file_menu : PopupMenu
|
|
|
|
var view_menu : PopupMenu
|
|
|
|
var zen_mode := false
|
|
|
|
|
|
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
setup_file_menu()
|
|
|
|
setup_edit_menu()
|
|
|
|
setup_view_menu()
|
|
|
|
setup_image_menu()
|
|
|
|
setup_help_menu()
|
|
|
|
|
|
|
|
|
|
|
|
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(),
|
|
|
|
"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()
|
|
|
|
var i := 0
|
|
|
|
|
|
|
|
for item in file_menu_items.keys():
|
|
|
|
file_menu.add_item(item, i, file_menu_items[item])
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
file_menu.connect("id_pressed", self, "file_menu_id_pressed")
|
|
|
|
|
2020-07-15 15:36:46 +00:00
|
|
|
if OS.get_name() == "HTML5":
|
|
|
|
file_menu.set_item_disabled(2, true)
|
|
|
|
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
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(),
|
2020-07-09 12:22:17 +00:00
|
|
|
"Copy" : InputMap.get_action_list("copy")[0].get_scancode_with_modifiers(),
|
2020-10-08 15:05:33 +00:00
|
|
|
"Cut" : InputMap.get_action_list("cut")[0].get_scancode_with_modifiers(),
|
2020-07-09 12:22:17 +00:00
|
|
|
"Paste" : InputMap.get_action_list("paste")[0].get_scancode_with_modifiers(),
|
|
|
|
"Delete" : InputMap.get_action_list("delete")[0].get_scancode_with_modifiers(),
|
2020-06-13 14:59:57 +00:00
|
|
|
"Clear Selection" : 0,
|
|
|
|
"Preferences" : 0
|
|
|
|
}
|
|
|
|
var edit_menu : PopupMenu = Global.edit_menu.get_popup()
|
|
|
|
var i := 0
|
|
|
|
|
|
|
|
for item in edit_menu_items.keys():
|
|
|
|
edit_menu.add_item(item, i, edit_menu_items[item])
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
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,
|
2020-07-21 19:11:25 +00:00
|
|
|
"Zen Mode" : InputMap.get_action_list("zen_mode")[0].get_scancode_with_modifiers(),
|
|
|
|
"Fullscreen Mode" : InputMap.get_action_list("toggle_fullscreen")[0].get_scancode_with_modifiers(),
|
2020-06-13 14:59:57 +00:00
|
|
|
}
|
|
|
|
view_menu = Global.view_menu.get_popup()
|
|
|
|
|
|
|
|
var i := 0
|
|
|
|
for item in view_menu_items.keys():
|
|
|
|
view_menu.add_check_item(item, i, view_menu_items[item])
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
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
|
|
|
|
view_menu.hide_on_checkable_item_selection = false
|
|
|
|
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,
|
2020-06-13 17:22:25 +00:00
|
|
|
"Resize Canvas" : 0,
|
2020-07-29 21:01:04 +00:00
|
|
|
"Flip" : 0,
|
2020-06-13 14:59:57 +00:00
|
|
|
"Rotate Image" : 0,
|
2020-06-24 00:21:44 +00:00
|
|
|
"Invert Colors" : 0,
|
2020-06-13 14:59:57 +00:00
|
|
|
"Desaturation" : 0,
|
|
|
|
"Outline" : 0,
|
2020-07-18 14:23:36 +00:00
|
|
|
"Adjust Hue/Saturation/Value" : 0,
|
2020-07-25 13:26:57 +00:00
|
|
|
"Gradient" : 0,
|
2020-09-05 10:39:32 +00:00
|
|
|
# "Shader" : 0
|
2020-06-13 14:59:57 +00:00
|
|
|
}
|
|
|
|
var image_menu : PopupMenu = Global.image_menu.get_popup()
|
|
|
|
|
|
|
|
var i := 0
|
|
|
|
for item in image_menu_items.keys():
|
|
|
|
image_menu.add_item(item, i, image_menu_items[item])
|
2020-06-24 00:21:44 +00:00
|
|
|
if i == 2:
|
2020-06-13 14:59:57 +00:00
|
|
|
image_menu.add_separator()
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
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" : InputMap.get_action_list("open_docs")[0].get_scancode_with_modifiers(),
|
|
|
|
"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():
|
|
|
|
help_menu.add_item(item, i, help_menu_items[item])
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
help_menu.connect("id_pressed", self, "help_menu_id_pressed")
|
|
|
|
|
|
|
|
|
|
|
|
func file_menu_id_pressed(id : int) -> void:
|
|
|
|
match id:
|
|
|
|
0: # New
|
|
|
|
on_new_project_file_menu_option_pressed()
|
|
|
|
1: # Open
|
|
|
|
open_project_file()
|
|
|
|
2: # Open last project
|
|
|
|
on_open_last_project_file_menu_option_pressed()
|
|
|
|
3: # Save
|
|
|
|
save_project_file()
|
|
|
|
4: # Save as
|
|
|
|
save_project_file_as()
|
|
|
|
5: # Export
|
|
|
|
export_file()
|
|
|
|
6: # Export as
|
|
|
|
Global.export_dialog.popup_centered()
|
|
|
|
Global.dialog_open(true)
|
|
|
|
7: # Quit
|
|
|
|
Global.control.show_quit_dialog()
|
|
|
|
|
|
|
|
|
|
|
|
func on_new_project_file_menu_option_pressed() -> void:
|
|
|
|
Global.new_image_dialog.popup_centered()
|
|
|
|
Global.dialog_open(true)
|
|
|
|
|
|
|
|
|
|
|
|
func open_project_file() -> void:
|
2020-06-30 19:29:24 +00:00
|
|
|
if OS.get_name() == "HTML5":
|
|
|
|
Html5FileExchange.load_image()
|
|
|
|
else:
|
|
|
|
Global.open_sprites_dialog.popup_centered()
|
|
|
|
Global.dialog_open(true)
|
|
|
|
Global.control.opensprite_file_selected = false
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
func on_open_last_project_file_menu_option_pressed() -> void:
|
|
|
|
# Check if last project path is set and if yes then open
|
|
|
|
if Global.config_cache.has_section_key("preferences", "last_project_path"):
|
|
|
|
Global.control.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:
|
|
|
|
Global.control.is_quitting_on_save = false
|
2020-06-30 17:25:43 +00:00
|
|
|
var path = OpenSave.current_save_paths[Global.current_project_index]
|
|
|
|
if path == "":
|
|
|
|
if OS.get_name() == "HTML5":
|
|
|
|
Global.save_sprites_html5_dialog.popup_centered()
|
|
|
|
else:
|
|
|
|
Global.save_sprites_dialog.popup_centered()
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.dialog_open(true)
|
|
|
|
else:
|
2020-06-30 17:25:43 +00:00
|
|
|
Global.control._on_SaveSprite_file_selected(path)
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
func save_project_file_as() -> void:
|
|
|
|
Global.control.is_quitting_on_save = false
|
2020-06-30 17:25:43 +00:00
|
|
|
if OS.get_name() == "HTML5":
|
|
|
|
Global.save_sprites_html5_dialog.popup_centered()
|
|
|
|
else:
|
|
|
|
Global.save_sprites_dialog.popup_centered()
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.dialog_open(true)
|
|
|
|
|
|
|
|
|
|
|
|
func export_file() -> void:
|
2020-07-31 20:26:52 +00:00
|
|
|
if Export.was_exported == false:
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.export_dialog.popup_centered()
|
|
|
|
Global.dialog_open(true)
|
|
|
|
else:
|
2020-08-28 15:05:49 +00:00
|
|
|
Export.external_export()
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
func edit_menu_id_pressed(id : int) -> void:
|
|
|
|
match id:
|
|
|
|
0: # Undo
|
|
|
|
Global.current_project.undo_redo.undo()
|
|
|
|
1: # Redo
|
|
|
|
Global.control.redone = true
|
|
|
|
Global.current_project.undo_redo.redo()
|
|
|
|
Global.control.redone = false
|
2020-07-09 12:22:17 +00:00
|
|
|
2: # Copy
|
|
|
|
Global.selection_rectangle.copy()
|
2020-10-08 15:05:33 +00:00
|
|
|
3: # cut
|
|
|
|
Global.selection_rectangle.cut()
|
|
|
|
4: # paste
|
2020-07-09 12:22:17 +00:00
|
|
|
Global.selection_rectangle.paste()
|
2020-10-08 15:05:33 +00:00
|
|
|
5: # Delete
|
2020-07-09 12:22:17 +00:00
|
|
|
Global.selection_rectangle.delete()
|
2020-10-08 15:05:33 +00:00
|
|
|
6: # Clear selection
|
2020-07-09 12:22:17 +00:00
|
|
|
Global.selection_rectangle.set_rect(Rect2(0, 0, 0, 0))
|
|
|
|
Global.selection_rectangle.select_rect()
|
2020-10-08 15:05:33 +00:00
|
|
|
7: # Preferences
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.preferences_dialog.popup_centered(Vector2(400, 280))
|
|
|
|
Global.dialog_open(true)
|
|
|
|
|
|
|
|
|
|
|
|
func view_menu_id_pressed(id : int) -> void:
|
|
|
|
match id:
|
|
|
|
0: # Tile mode
|
|
|
|
toggle_tile_mode()
|
|
|
|
1: # Show grid
|
|
|
|
toggle_show_grid()
|
|
|
|
2: # Show rulers
|
|
|
|
toggle_show_rulers()
|
|
|
|
3: # Show guides
|
|
|
|
toggle_show_guides()
|
|
|
|
4: # Show animation timeline
|
|
|
|
toggle_show_anim_timeline()
|
2020-07-21 19:11:25 +00:00
|
|
|
5: # Zen mode
|
2020-06-13 14:59:57 +00:00
|
|
|
toggle_zen_mode()
|
2020-07-21 19:11:25 +00:00
|
|
|
6: # Fullscreen mode
|
|
|
|
toggle_fullscreen()
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
Global.canvas.update()
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
2020-08-17 19:54:33 +00:00
|
|
|
Global.canvas.grid.update()
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
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 guide in Global.canvas.get_children():
|
2020-07-16 02:05:40 +00:00
|
|
|
if guide is Guide and guide in Global.current_project.guides:
|
2020-06-13 14:59:57 +00:00
|
|
|
guide.visible = Global.show_guides
|
2020-07-16 02:05:40 +00:00
|
|
|
if guide is SymmetryGuide:
|
|
|
|
if guide.type == Guide.Types.HORIZONTAL:
|
|
|
|
guide.visible = Global.show_x_symmetry_axis and Global.show_guides
|
|
|
|
else:
|
|
|
|
guide.visible = Global.show_y_symmetry_axis and Global.show_guides
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
func toggle_show_anim_timeline() -> void:
|
|
|
|
if zen_mode:
|
|
|
|
return
|
|
|
|
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 toggle_zen_mode() -> void:
|
|
|
|
if Global.show_animation_timeline:
|
|
|
|
Global.animation_timeline.visible = zen_mode
|
|
|
|
Global.control.get_node("MenuAndUI/UI/ToolPanel").visible = zen_mode
|
|
|
|
Global.control.get_node("MenuAndUI/UI/RightPanel").visible = zen_mode
|
|
|
|
Global.control.get_node("MenuAndUI/UI/CanvasAndTimeline/ViewportAndRulers/TabsContainer").visible = zen_mode
|
|
|
|
zen_mode = !zen_mode
|
|
|
|
view_menu.set_item_checked(5, zen_mode)
|
|
|
|
|
|
|
|
|
2020-07-21 19:11:25 +00:00
|
|
|
func toggle_fullscreen() -> void:
|
|
|
|
OS.window_fullscreen = !OS.window_fullscreen
|
|
|
|
view_menu.set_item_checked(6, OS.window_fullscreen)
|
|
|
|
|
|
|
|
|
2020-06-13 14:59:57 +00:00
|
|
|
func image_menu_id_pressed(id : int) -> void:
|
|
|
|
if Global.current_project.layers[Global.current_project.current_layer].locked: # No changes if the layer is locked
|
|
|
|
return
|
2020-07-25 16:35:46 +00:00
|
|
|
var image : Image = Global.current_project.frames[Global.current_project.current_frame].cels[Global.current_project.current_layer].image
|
2020-06-13 14:59:57 +00:00
|
|
|
match id:
|
|
|
|
0: # Scale Image
|
|
|
|
show_scale_image_popup()
|
|
|
|
|
|
|
|
1: # Crop Image
|
2020-06-13 15:57:28 +00:00
|
|
|
DrawingAlgos.crop_image(image)
|
2020-06-13 14:59:57 +00:00
|
|
|
|
2020-06-13 17:22:25 +00:00
|
|
|
2: # Resize Canvas
|
|
|
|
show_resize_canvas_popup()
|
|
|
|
|
2020-07-29 21:01:04 +00:00
|
|
|
3: # Flip
|
|
|
|
Global.control.get_node("Dialogs/ImageEffects/FlipImageDialog").popup_centered()
|
|
|
|
Global.dialog_open(true)
|
2020-06-13 14:59:57 +00:00
|
|
|
|
2020-07-29 21:01:04 +00:00
|
|
|
4: # Rotate
|
2020-06-13 14:59:57 +00:00
|
|
|
show_rotate_image_popup()
|
|
|
|
|
2020-07-29 21:01:04 +00:00
|
|
|
5: # Invert Colors
|
2020-07-31 00:39:46 +00:00
|
|
|
Global.control.get_node("Dialogs/ImageEffects/InvertColorsDialog").popup_centered()
|
|
|
|
Global.dialog_open(true)
|
2020-06-13 14:59:57 +00:00
|
|
|
|
2020-07-29 21:01:04 +00:00
|
|
|
6: # Desaturation
|
2020-08-01 01:24:11 +00:00
|
|
|
Global.control.get_node("Dialogs/ImageEffects/DesaturateDialog").popup_centered()
|
|
|
|
Global.dialog_open(true)
|
2020-06-13 14:59:57 +00:00
|
|
|
|
2020-07-29 21:01:04 +00:00
|
|
|
7: # Outline
|
2020-06-13 14:59:57 +00:00
|
|
|
show_add_outline_popup()
|
|
|
|
|
2020-07-29 21:01:04 +00:00
|
|
|
8: # HSV
|
2020-06-13 14:59:57 +00:00
|
|
|
show_hsv_configuration_popup()
|
2020-07-29 21:01:04 +00:00
|
|
|
|
|
|
|
9: # Gradient
|
2020-07-23 01:15:18 +00:00
|
|
|
Global.control.get_node("Dialogs/ImageEffects/GradientDialog").popup_centered()
|
2020-07-18 14:23:36 +00:00
|
|
|
Global.dialog_open(true)
|
2020-07-29 21:01:04 +00:00
|
|
|
|
|
|
|
10: # Shader
|
2020-07-25 13:26:57 +00:00
|
|
|
Global.control.get_node("Dialogs/ImageEffects/ShaderEffect").popup_centered()
|
|
|
|
Global.dialog_open(true)
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
func show_scale_image_popup() -> void:
|
2020-07-23 01:15:18 +00:00
|
|
|
Global.control.get_node("Dialogs/ImageEffects/ScaleImage").popup_centered()
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.dialog_open(true)
|
|
|
|
|
|
|
|
|
2020-06-13 17:22:25 +00:00
|
|
|
func show_resize_canvas_popup() -> void:
|
2020-07-23 01:15:18 +00:00
|
|
|
Global.control.get_node("Dialogs/ImageEffects/ResizeCanvas").popup_centered()
|
2020-06-13 17:22:25 +00:00
|
|
|
Global.dialog_open(true)
|
|
|
|
|
|
|
|
|
2020-06-13 14:59:57 +00:00
|
|
|
func show_rotate_image_popup() -> void:
|
2020-07-23 01:15:18 +00:00
|
|
|
Global.control.get_node("Dialogs/ImageEffects/RotateImage").popup_centered()
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.dialog_open(true)
|
|
|
|
|
|
|
|
|
|
|
|
func show_add_outline_popup() -> void:
|
2020-07-23 01:15:18 +00:00
|
|
|
Global.control.get_node("Dialogs/ImageEffects/OutlineDialog").popup_centered()
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.dialog_open(true)
|
|
|
|
|
|
|
|
|
|
|
|
func show_hsv_configuration_popup() -> void:
|
2020-07-23 01:15:18 +00:00
|
|
|
Global.control.get_node("Dialogs/ImageEffects/HSVDialog").popup_centered()
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.dialog_open(true)
|
|
|
|
|
|
|
|
|
|
|
|
func help_menu_id_pressed(id : int) -> void:
|
|
|
|
match id:
|
|
|
|
0: # Splash Screen
|
2020-07-17 23:27:47 +00:00
|
|
|
Global.control.get_node("Dialogs/SplashDialog").popup_centered()
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.dialog_open(true)
|
|
|
|
1: # Online Docs
|
|
|
|
OS.shell_open("https://orama-interactive.github.io/Pixelorama-Docs/")
|
|
|
|
2: # Issue Tracker
|
|
|
|
OS.shell_open("https://github.com/Orama-Interactive/Pixelorama/issues")
|
|
|
|
3: # Changelog
|
2020-07-01 00:08:50 +00:00
|
|
|
if OS.get_name() == "OSX":
|
|
|
|
OS.shell_open("https://github.com/Orama-Interactive/Pixelorama/blob/master/CHANGELOG.md")
|
|
|
|
else:
|
2020-09-23 13:51:08 +00:00
|
|
|
OS.shell_open("https://github.com/Orama-Interactive/Pixelorama/blob/master/CHANGELOG.md#v08---2020-09-23")
|
2020-06-13 14:59:57 +00:00
|
|
|
4: # About Pixelorama
|
2020-07-17 23:27:47 +00:00
|
|
|
Global.control.get_node("Dialogs/AboutDialog").popup_centered()
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.dialog_open(true)
|