diff --git a/project.godot b/project.godot index c64c136cd..35ca2ee8d 100644 --- a/project.godot +++ b/project.godot @@ -888,6 +888,16 @@ gaussian_blur={ "deadzone": 0.5, "events": [] } +next_project={ +"deadzone": 0.5, +"events": [null, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":true,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194306,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +previous_project={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":true,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194306,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} [input_devices] diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index 28fc249c8..4f0ce33d0 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -787,6 +787,8 @@ func _initialize_keychain() -> void: &"open_editor_data_folder": Keychain.InputAction.new("", "Help menu", true), &"changelog": Keychain.InputAction.new("", "Help menu", true), &"about_pixelorama": Keychain.InputAction.new("", "Help menu", true), + &"previous_project": Keychain.InputAction.new("", "Canvas"), + &"next_project": Keychain.InputAction.new("", "Canvas"), &"zoom_in": Keychain.InputAction.new("", "Canvas"), &"zoom_out": Keychain.InputAction.new("", "Canvas"), &"camera_left": Keychain.InputAction.new("", "Canvas"), diff --git a/src/UI/Tabs.gd b/src/UI/Tabs.gd index a5260d6c3..3b8ab3f4e 100644 --- a/src/UI/Tabs.gd +++ b/src/UI/Tabs.gd @@ -4,6 +4,35 @@ extends TabBar var unsaved_changes_dialog: ConfirmationDialog = Global.control.find_child("UnsavedCanvasDialog") +func _input(_event: InputEvent) -> void: + # NOTE: This feature has an unavoidable bug which sometimes causes the undoredo + # system to fail, because user is trying to draw while switching project simultaneously. + # This is because the current project has changed and the system tries to commit to the + # wrong undoredo. + var tab_idx = current_tab + # If a project is currently worked upon, then don't switch it. + # This doesn't stop the bug completely but significantly reduces it's chances + # of appearing. + if ( + Input.is_action_pressed("activate_left_tool") + or Input.is_action_pressed("activate_right_tool") + ): + return + # Due to the bug mentioned above, we will use is_action_just_released + # instead of is_action_just_pressed. This won't remove the bug completely + # but will significantly reduce it's chancce of appearing. + if Input.is_action_just_released(&"next_project", true): + tab_idx += 1 + if tab_idx >= tab_count: + tab_idx = 0 + elif Input.is_action_just_released(&"previous_project", true): + tab_idx = current_tab - 1 + if tab_idx < 0: + tab_idx -= 1 + if tab_idx != current_tab: + current_tab = tab_idx + + ## Handles closing tab with middle-click ## Thanks to https://github.com/godotengine/godot/issues/64498#issuecomment-1217992089 func _gui_input(event: InputEvent) -> void: