2020-06-13 14:59:57 +00:00
|
|
|
extends Panel
|
|
|
|
|
|
|
|
|
2021-01-20 14:59:42 +00:00
|
|
|
enum FileMenuId {NEW, OPEN, OPEN_LAST_PROJECT, SAVE, SAVE_AS, EXPORT, EXPORT_AS, QUIT}
|
|
|
|
enum EditMenuId {UNDO, REDO, COPY, CUT, PASTE, DELETE, CLEAR_SELECTION, PREFERENCES}
|
2021-03-06 13:59:26 +00:00
|
|
|
enum ViewMenuId {TILE_MODE, WINDOW_TRANSPARENCY, PANEL_LAYOUT, MIRROR_VIEW, SHOW_GRID, SHOW_PIXEL_GRID, SHOW_RULERS, SHOW_GUIDES, SHOW_ANIMATION_TIMELINE, ZEN_MODE, FULLSCREEN_MODE}
|
2021-01-26 14:03:38 +00:00
|
|
|
enum ImageMenuId {SCALE_IMAGE,CENTRALIZE_IMAGE, CROP_IMAGE, RESIZE_CANVAS, FLIP, ROTATE, INVERT_COLORS, DESATURATION, OUTLINE, HSV, GRADIENT, SHADER}
|
2021-01-20 14:59:42 +00:00
|
|
|
enum HelpMenuId {VIEW_SPLASH_SCREEN, ONLINE_DOCS, ISSUE_TRACKER, CHANGELOG, ABOUT_PIXELORAMA}
|
2021-01-16 18:24:46 +00:00
|
|
|
|
2020-06-13 14:59:57 +00:00
|
|
|
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:
|
2021-01-20 14:59:42 +00:00
|
|
|
var file_menu_items := { # order as in FileMenuId enum
|
2020-06-13 14:59:57 +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(),
|
|
|
|
'Open last project...' : 0,
|
2020-10-29 20:33:15 +00:00
|
|
|
"Recent projects": 0,
|
2020-06-13 14:59:57 +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(),
|
|
|
|
"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():
|
2020-10-26 20:51:55 +00:00
|
|
|
if item == "Recent projects":
|
|
|
|
setup_recent_projects_submenu(item)
|
|
|
|
else:
|
|
|
|
file_menu.add_item(item, i, file_menu_items[item])
|
|
|
|
i += 1
|
2020-10-27 21:03:43 +00:00
|
|
|
|
2020-06-13 14:59:57 +00:00
|
|
|
file_menu.connect("id_pressed", self, "file_menu_id_pressed")
|
2020-10-27 21:03:43 +00:00
|
|
|
|
2020-07-15 15:36:46 +00:00
|
|
|
if OS.get_name() == "HTML5":
|
2021-01-20 14:59:42 +00:00
|
|
|
file_menu.set_item_disabled(FileMenuId.OPEN_LAST_PROJECT, true)
|
|
|
|
file_menu.set_item_disabled(FileMenuId.SAVE, true)
|
2020-07-15 15:36:46 +00:00
|
|
|
|
2020-06-13 14:59:57 +00:00
|
|
|
|
2020-10-26 20:51:55 +00:00
|
|
|
func setup_recent_projects_submenu(item : String) -> void:
|
|
|
|
Global.recent_projects_submenu.connect("id_pressed", self, "on_recent_projects_submenu_id_pressed")
|
|
|
|
Global.update_recent_projects_submenu()
|
2020-10-27 21:03:43 +00:00
|
|
|
|
2020-10-26 20:51:55 +00:00
|
|
|
file_menu.add_child(Global.recent_projects_submenu)
|
|
|
|
file_menu.add_submenu_item(item, Global.recent_projects_submenu.get_name())
|
|
|
|
|
|
|
|
|
2020-06-13 14:59:57 +00:00
|
|
|
func setup_edit_menu() -> void:
|
2021-01-20 14:59:42 +00:00
|
|
|
var edit_menu_items := { # order as in EditMenuId enum
|
2020-06-13 14:59:57 +00:00
|
|
|
"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(),
|
2021-02-17 17:53:01 +00:00
|
|
|
"Clear Selection" : InputMap.get_action_list("clear_selection")[0].get_scancode_with_modifiers(),
|
2020-06-13 14:59:57 +00:00
|
|
|
"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:
|
2021-01-20 14:59:42 +00:00
|
|
|
var view_menu_items := { # order as in ViewMenuId enum
|
2020-11-13 18:12:20 +00:00
|
|
|
"Tile Mode" : 0,
|
2021-02-02 15:29:19 +00:00
|
|
|
"Window Transparency" : 0,
|
2021-03-06 13:59:26 +00:00
|
|
|
"Panel Layout" : 0,
|
2020-11-23 16:53:21 +00:00
|
|
|
"Mirror View" : InputMap.get_action_list("mirror_view")[0].get_scancode_with_modifiers(),
|
2020-06-13 14:59:57 +00:00
|
|
|
"Show Grid" : InputMap.get_action_list("show_grid")[0].get_scancode_with_modifiers(),
|
2021-01-16 18:24:46 +00:00
|
|
|
"Show Pixel Grid" : InputMap.get_action_list("show_pixel_grid")[0].get_scancode_with_modifiers(),
|
2020-06-13 14:59:57 +00:00
|
|
|
"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():
|
2020-11-13 18:12:20 +00:00
|
|
|
if item == "Tile Mode":
|
|
|
|
setup_tile_mode_submenu(item)
|
2021-02-02 15:29:19 +00:00
|
|
|
elif item == "Window Transparency":
|
|
|
|
setup_window_transparency_submenu(item)
|
2021-03-06 13:59:26 +00:00
|
|
|
elif item == "Panel Layout":
|
|
|
|
setup_panel_layout_submenu(item)
|
2020-11-13 18:12:20 +00:00
|
|
|
else:
|
|
|
|
view_menu.add_check_item(item, i, view_menu_items[item])
|
2020-06-13 14:59:57 +00:00
|
|
|
i += 1
|
2021-01-20 14:59:42 +00:00
|
|
|
view_menu.set_item_checked(ViewMenuId.SHOW_RULERS, true)
|
|
|
|
view_menu.set_item_checked(ViewMenuId.SHOW_GUIDES, true)
|
|
|
|
view_menu.set_item_checked(ViewMenuId.SHOW_ANIMATION_TIMELINE, true)
|
2020-06-13 14:59:57 +00:00
|
|
|
view_menu.hide_on_checkable_item_selection = false
|
|
|
|
view_menu.connect("id_pressed", self, "view_menu_id_pressed")
|
2021-02-02 17:17:56 +00:00
|
|
|
if OS.get_name() == "HTML5":
|
|
|
|
view_menu.set_item_disabled(ViewMenuId.WINDOW_TRANSPARENCY, true)
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
|
2020-11-13 18:12:20 +00:00
|
|
|
func setup_tile_mode_submenu(item : String):
|
|
|
|
Global.tile_mode_submenu.connect("id_pressed", self, "tile_mode_submenu_id_pressed")
|
|
|
|
view_menu.add_child(Global.tile_mode_submenu)
|
|
|
|
view_menu.add_submenu_item(item, Global.tile_mode_submenu.get_name())
|
|
|
|
|
|
|
|
|
2021-02-02 15:29:19 +00:00
|
|
|
func setup_window_transparency_submenu(item : String):
|
|
|
|
Global.window_transparency_submenu.connect("id_pressed", self, "window_transparency_submenu_id_pressed")
|
|
|
|
view_menu.add_child(Global.window_transparency_submenu)
|
|
|
|
view_menu.add_submenu_item(item, Global.window_transparency_submenu.get_name())
|
|
|
|
|
|
|
|
|
2021-03-06 13:59:26 +00:00
|
|
|
func setup_panel_layout_submenu(item : String):
|
|
|
|
Global.panel_layout_submenu.connect("id_pressed", self, "panel_layout_submenu_id_pressed")
|
|
|
|
view_menu.add_child(Global.panel_layout_submenu)
|
|
|
|
view_menu.add_submenu_item(item, Global.panel_layout_submenu.get_name())
|
|
|
|
|
|
|
|
|
2020-06-13 14:59:57 +00:00
|
|
|
func setup_image_menu() -> void:
|
2021-01-20 14:59:42 +00:00
|
|
|
var image_menu_items := { # order as in ImageMenuId enum
|
2020-06-13 14:59:57 +00:00
|
|
|
"Scale Image" : 0,
|
2021-01-26 14:03:38 +00:00
|
|
|
"Centralize Image" : 0,
|
2020-06-13 14:59:57 +00:00
|
|
|
"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])
|
2021-01-20 14:59:42 +00:00
|
|
|
if i == ImageMenuId.RESIZE_CANVAS:
|
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:
|
2021-01-20 14:59:42 +00:00
|
|
|
var help_menu_items := { # order as in HelpMenuId enum
|
2020-06-13 14:59:57 +00:00
|
|
|
"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:
|
2021-01-20 14:59:42 +00:00
|
|
|
FileMenuId.NEW:
|
2020-06-13 14:59:57 +00:00
|
|
|
on_new_project_file_menu_option_pressed()
|
2021-01-20 14:59:42 +00:00
|
|
|
FileMenuId.OPEN:
|
2020-06-13 14:59:57 +00:00
|
|
|
open_project_file()
|
2021-01-20 14:59:42 +00:00
|
|
|
FileMenuId.OPEN_LAST_PROJECT:
|
2020-06-13 14:59:57 +00:00
|
|
|
on_open_last_project_file_menu_option_pressed()
|
2021-01-20 14:59:42 +00:00
|
|
|
FileMenuId.SAVE:
|
2020-06-13 14:59:57 +00:00
|
|
|
save_project_file()
|
2021-01-20 14:59:42 +00:00
|
|
|
FileMenuId.SAVE_AS:
|
2020-06-13 14:59:57 +00:00
|
|
|
save_project_file_as()
|
2021-01-20 14:59:42 +00:00
|
|
|
FileMenuId.EXPORT:
|
2020-06-13 14:59:57 +00:00
|
|
|
export_file()
|
2021-01-20 14:59:42 +00:00
|
|
|
FileMenuId.EXPORT_AS:
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.export_dialog.popup_centered()
|
|
|
|
Global.dialog_open(true)
|
2021-01-20 14:59:42 +00:00
|
|
|
FileMenuId.QUIT:
|
2020-06-13 14:59:57 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
2020-10-26 20:51:55 +00:00
|
|
|
func on_recent_projects_submenu_id_pressed(id : int) -> void:
|
|
|
|
Global.control.load_recent_project_file(Global.recent_projects[id])
|
|
|
|
|
|
|
|
|
2020-06-13 14:59:57 +00:00
|
|
|
func edit_menu_id_pressed(id : int) -> void:
|
|
|
|
match id:
|
2021-01-20 14:59:42 +00:00
|
|
|
EditMenuId.UNDO:
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.current_project.undo_redo.undo()
|
2021-01-20 14:59:42 +00:00
|
|
|
EditMenuId.REDO:
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.control.redone = true
|
|
|
|
Global.current_project.undo_redo.redo()
|
|
|
|
Global.control.redone = false
|
2021-01-20 14:59:42 +00:00
|
|
|
EditMenuId.COPY:
|
2020-07-09 12:22:17 +00:00
|
|
|
Global.selection_rectangle.copy()
|
2021-01-20 14:59:42 +00:00
|
|
|
EditMenuId.CUT:
|
2020-10-08 15:05:33 +00:00
|
|
|
Global.selection_rectangle.cut()
|
2021-01-20 14:59:42 +00:00
|
|
|
EditMenuId.PASTE:
|
2020-07-09 12:22:17 +00:00
|
|
|
Global.selection_rectangle.paste()
|
2021-01-20 14:59:42 +00:00
|
|
|
EditMenuId.DELETE:
|
2020-07-09 12:22:17 +00:00
|
|
|
Global.selection_rectangle.delete()
|
2021-01-20 14:59:42 +00:00
|
|
|
EditMenuId.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()
|
2021-01-20 14:59:42 +00:00
|
|
|
EditMenuId.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:
|
2021-01-20 14:59:42 +00:00
|
|
|
ViewMenuId.MIRROR_VIEW:
|
2020-11-23 16:53:21 +00:00
|
|
|
toggle_mirror_view()
|
2021-01-20 14:59:42 +00:00
|
|
|
ViewMenuId.SHOW_GRID:
|
2020-06-13 14:59:57 +00:00
|
|
|
toggle_show_grid()
|
2021-01-20 14:59:42 +00:00
|
|
|
ViewMenuId.SHOW_PIXEL_GRID:
|
2021-01-16 18:24:46 +00:00
|
|
|
toggle_show_pixel_grid()
|
2021-01-20 14:59:42 +00:00
|
|
|
ViewMenuId.SHOW_RULERS:
|
2020-06-13 14:59:57 +00:00
|
|
|
toggle_show_rulers()
|
2021-01-20 14:59:42 +00:00
|
|
|
ViewMenuId.SHOW_GUIDES:
|
2020-06-13 14:59:57 +00:00
|
|
|
toggle_show_guides()
|
2021-01-20 14:59:42 +00:00
|
|
|
ViewMenuId.SHOW_ANIMATION_TIMELINE:
|
2020-06-13 14:59:57 +00:00
|
|
|
toggle_show_anim_timeline()
|
2021-01-20 14:59:42 +00:00
|
|
|
ViewMenuId.ZEN_MODE:
|
2020-06-13 14:59:57 +00:00
|
|
|
toggle_zen_mode()
|
2021-01-20 14:59:42 +00:00
|
|
|
ViewMenuId.FULLSCREEN_MODE:
|
2020-07-21 19:11:25 +00:00
|
|
|
toggle_fullscreen()
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.canvas.update()
|
|
|
|
|
|
|
|
|
2020-12-03 01:49:53 +00:00
|
|
|
func tile_mode_submenu_id_pressed(id : int) -> void:
|
2021-01-16 18:24:46 +00:00
|
|
|
Global.current_project.tile_mode = id
|
2021-01-28 19:21:48 +00:00
|
|
|
Global.transparent_checker.fit_rect(Global.current_project.get_tile_mode_rect())
|
2021-01-20 14:59:42 +00:00
|
|
|
for i in Global.TileMode.values():
|
2021-01-16 18:24:46 +00:00
|
|
|
Global.tile_mode_submenu.set_item_checked(i, i == id)
|
2020-11-13 18:12:20 +00:00
|
|
|
Global.canvas.tile_mode.update()
|
2021-01-16 18:24:46 +00:00
|
|
|
Global.canvas.pixel_grid.update()
|
2021-01-18 20:59:26 +00:00
|
|
|
Global.canvas.grid.update()
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
|
2021-02-02 15:29:19 +00:00
|
|
|
func window_transparency_submenu_id_pressed(id : float) -> void:
|
|
|
|
if OS.window_fullscreen:
|
|
|
|
for i in 11:
|
|
|
|
Global.window_transparency_submenu.set_item_checked(i, i == 10)
|
|
|
|
window_transparency(1)
|
|
|
|
else:
|
|
|
|
for i in 11:
|
|
|
|
Global.window_transparency_submenu.set_item_checked(i, i == id)
|
|
|
|
window_transparency(id/10)
|
|
|
|
|
|
|
|
|
2021-03-06 13:59:26 +00:00
|
|
|
func panel_layout_submenu_id_pressed(id : int) -> void:
|
|
|
|
Global.panel_layout = id
|
|
|
|
for i in Global.PanelLayout.values():
|
|
|
|
Global.panel_layout_submenu.set_item_checked(i, i == id)
|
|
|
|
get_tree().get_root().get_node("Control").handle_resize()
|
|
|
|
|
|
|
|
|
2021-02-02 15:29:19 +00:00
|
|
|
func window_transparency(value :float) -> void:
|
|
|
|
if value == 1:
|
|
|
|
get_node("../../AlternateTransparentBackground").visible = false
|
|
|
|
else:
|
|
|
|
get_node("../../AlternateTransparentBackground").visible = true
|
|
|
|
var checker :ColorRect = get_parent().get_node("UI/CanvasAndTimeline/ViewportAndRulers/HSplitContainer/ViewportandVerticalRuler/ViewportContainer/Viewport/TransparentChecker")
|
|
|
|
var color :Color = Global.control.theme.get_stylebox("panel", "PanelContainer").bg_color
|
|
|
|
color.a = value
|
|
|
|
get_node("../../AlternateTransparentBackground").color = color
|
|
|
|
checker.transparency(value)
|
|
|
|
|
|
|
|
|
2020-11-23 16:53:21 +00:00
|
|
|
func toggle_mirror_view() -> void:
|
|
|
|
Global.mirror_view = !Global.mirror_view
|
2021-01-20 14:59:42 +00:00
|
|
|
view_menu.set_item_checked(ViewMenuId.MIRROR_VIEW, Global.mirror_view)
|
2020-11-23 16:53:21 +00:00
|
|
|
|
|
|
|
|
2020-06-13 14:59:57 +00:00
|
|
|
func toggle_show_grid() -> void:
|
|
|
|
Global.draw_grid = !Global.draw_grid
|
2021-01-20 14:59:42 +00:00
|
|
|
view_menu.set_item_checked(ViewMenuId.SHOW_GRID, Global.draw_grid)
|
2020-08-17 19:54:33 +00:00
|
|
|
Global.canvas.grid.update()
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
|
2021-01-16 18:24:46 +00:00
|
|
|
func toggle_show_pixel_grid() -> void:
|
|
|
|
Global.draw_pixel_grid = !Global.draw_pixel_grid
|
2021-01-20 14:59:42 +00:00
|
|
|
view_menu.set_item_checked(ViewMenuId.SHOW_PIXEL_GRID, Global.draw_pixel_grid)
|
2021-01-16 18:24:46 +00:00
|
|
|
Global.canvas.pixel_grid.update()
|
|
|
|
|
|
|
|
|
2020-06-13 14:59:57 +00:00
|
|
|
func toggle_show_rulers() -> void:
|
|
|
|
Global.show_rulers = !Global.show_rulers
|
2021-01-20 14:59:42 +00:00
|
|
|
view_menu.set_item_checked(ViewMenuId.SHOW_RULERS, Global.show_rulers)
|
2020-06-13 14:59:57 +00:00
|
|
|
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
|
2021-01-20 14:59:42 +00:00
|
|
|
view_menu.set_item_checked(ViewMenuId.SHOW_GUIDES, Global.show_guides)
|
2020-06-13 14:59:57 +00:00
|
|
|
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
|
2021-01-20 14:59:42 +00:00
|
|
|
view_menu.set_item_checked(ViewMenuId.SHOW_ANIMATION_TIMELINE, Global.show_animation_timeline)
|
2020-06-13 14:59:57 +00:00
|
|
|
Global.animation_timeline.visible = Global.show_animation_timeline
|
|
|
|
|
|
|
|
|
|
|
|
func toggle_zen_mode() -> void:
|
|
|
|
if Global.show_animation_timeline:
|
|
|
|
Global.animation_timeline.visible = zen_mode
|
2021-03-06 13:59:26 +00:00
|
|
|
Global.tool_panel.visible = zen_mode
|
|
|
|
Global.right_panel.visible = zen_mode
|
|
|
|
Global.tabs_container.visible = zen_mode
|
2020-06-13 14:59:57 +00:00
|
|
|
zen_mode = !zen_mode
|
2021-01-20 14:59:42 +00:00
|
|
|
view_menu.set_item_checked(ViewMenuId.ZEN_MODE, zen_mode)
|
2020-06-13 14:59:57 +00:00
|
|
|
|
|
|
|
|
2020-07-21 19:11:25 +00:00
|
|
|
func toggle_fullscreen() -> void:
|
|
|
|
OS.window_fullscreen = !OS.window_fullscreen
|
2021-01-20 14:59:42 +00:00
|
|
|
view_menu.set_item_checked(ViewMenuId.FULLSCREEN_MODE, OS.window_fullscreen)
|
2021-02-02 15:29:19 +00:00
|
|
|
# if window is fullscreen then reset transparency
|
|
|
|
if OS.window_fullscreen:
|
|
|
|
window_transparency_submenu_id_pressed(10)
|
2020-07-21 19:11:25 +00:00
|
|
|
|
|
|
|
|
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:
|
2021-01-20 14:59:42 +00:00
|
|
|
ImageMenuId.SCALE_IMAGE:
|
2020-06-13 14:59:57 +00:00
|
|
|
show_scale_image_popup()
|
|
|
|
|
2021-01-26 14:03:38 +00:00
|
|
|
ImageMenuId.CENTRALIZE_IMAGE:
|
|
|
|
DrawingAlgos.centralize()
|
|
|
|
|
2021-01-20 14:59:42 +00:00
|
|
|
ImageMenuId.CROP_IMAGE:
|
2020-06-13 15:57:28 +00:00
|
|
|
DrawingAlgos.crop_image(image)
|
2020-06-13 14:59:57 +00:00
|
|
|
|
2021-01-20 14:59:42 +00:00
|
|
|
ImageMenuId.RESIZE_CANVAS:
|
2020-06-13 17:22:25 +00:00
|
|
|
show_resize_canvas_popup()
|
|
|
|
|
2021-01-20 14:59:42 +00:00
|
|
|
ImageMenuId.FLIP:
|
2020-07-29 21:01:04 +00:00
|
|
|
Global.control.get_node("Dialogs/ImageEffects/FlipImageDialog").popup_centered()
|
|
|
|
Global.dialog_open(true)
|
2020-06-13 14:59:57 +00:00
|
|
|
|
2021-01-20 14:59:42 +00:00
|
|
|
ImageMenuId.ROTATE:
|
2020-06-13 14:59:57 +00:00
|
|
|
show_rotate_image_popup()
|
|
|
|
|
2021-01-20 14:59:42 +00:00
|
|
|
ImageMenuId.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
|
|
|
|
2021-01-20 14:59:42 +00:00
|
|
|
ImageMenuId.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
|
|
|
|
2021-01-20 14:59:42 +00:00
|
|
|
ImageMenuId.OUTLINE:
|
2020-06-13 14:59:57 +00:00
|
|
|
show_add_outline_popup()
|
|
|
|
|
2021-01-20 14:59:42 +00:00
|
|
|
ImageMenuId.HSV:
|
2020-06-13 14:59:57 +00:00
|
|
|
show_hsv_configuration_popup()
|
2020-07-29 21:01:04 +00:00
|
|
|
|
2021-01-20 14:59:42 +00:00
|
|
|
ImageMenuId.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
|
|
|
|
2021-01-20 14:59:42 +00:00
|
|
|
ImageMenuId.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:
|
2021-01-20 14:59:42 +00:00
|
|
|
HelpMenuId.VIEW_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)
|
2021-01-20 14:59:42 +00:00
|
|
|
HelpMenuId.ONLINE_DOCS:
|
2020-06-13 14:59:57 +00:00
|
|
|
OS.shell_open("https://orama-interactive.github.io/Pixelorama-Docs/")
|
2021-01-20 14:59:42 +00:00
|
|
|
HelpMenuId.ISSUE_TRACKER:
|
2020-06-13 14:59:57 +00:00
|
|
|
OS.shell_open("https://github.com/Orama-Interactive/Pixelorama/issues")
|
2021-01-20 14:59:42 +00:00
|
|
|
HelpMenuId.CHANGELOG:
|
2020-07-01 00:08:50 +00:00
|
|
|
if OS.get_name() == "OSX":
|
2020-12-12 14:55:13 +00:00
|
|
|
# Issue #275 - remove when macOS builds use Godot 3.2.3
|
2020-07-01 00:08:50 +00:00
|
|
|
OS.shell_open("https://github.com/Orama-Interactive/Pixelorama/blob/master/CHANGELOG.md")
|
|
|
|
else:
|
2020-12-12 14:55:13 +00:00
|
|
|
OS.shell_open("https://github.com/Orama-Interactive/Pixelorama/blob/master/CHANGELOG.md#v082---2020-12-12")
|
2021-01-20 14:59:42 +00:00
|
|
|
HelpMenuId.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)
|