From 80e04a9043c510104b312e4db99a9a5eb6aea2f1 Mon Sep 17 00:00:00 2001 From: voylin <0voylin0@gmail.com> Date: Fri, 8 Mar 2024 12:06:27 +0900 Subject: [PATCH] Layout shortcuts --- build.sh | 2 +- src/project.godot | 58 +++++++++++++++++++++++ src/ui/screen_editor/scripts/editor_ui.gd | 19 +++++++- 3 files changed, 77 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 9e39eb1..3e5a1d1 100755 --- a/build.sh +++ b/build.sh @@ -57,7 +57,7 @@ function compile_gdextension() { ;; *) echo "Choosing platform=linuxbsd as no (valid) argument was given." - platform=linuxbsd + platform=linux ;; esac echo "Select build taget:" diff --git a/src/project.godot b/src/project.godot index aa1683e..7992255 100644 --- a/src/project.godot +++ b/src/project.godot @@ -75,6 +75,64 @@ path/configs/effects="user://effect_configs/" path/configs/transitions="user://transition_configs/" path/configs/render_profiles="user://render_profile_configs/" +[input] + +editor_layout_1={ +"deadzone": 0.5, +"events": [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":49,"key_label":0,"unicode":49,"echo":false,"script":null) +] +} +editor_layout_2={ +"deadzone": 0.5, +"events": [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":50,"key_label":0,"unicode":50,"echo":false,"script":null) +] +} +editor_layout_3={ +"deadzone": 0.5, +"events": [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":51,"key_label":0,"unicode":51,"echo":false,"script":null) +] +} +editor_layout_4={ +"deadzone": 0.5, +"events": [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":52,"key_label":0,"unicode":52,"echo":false,"script":null) +] +} +editor_layout_5={ +"deadzone": 0.5, +"events": [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":53,"key_label":0,"unicode":53,"echo":false,"script":null) +] +} +editor_layout_6={ +"deadzone": 0.5, +"events": [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":54,"key_label":0,"unicode":54,"echo":false,"script":null) +] +} +editor_layout_7={ +"deadzone": 0.5, +"events": [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":55,"key_label":0,"unicode":55,"echo":false,"script":null) +] +} +editor_layout_8={ +"deadzone": 0.5, +"events": [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":56,"key_label":0,"unicode":56,"echo":false,"script":null) +] +} +editor_layout_9={ +"deadzone": 0.5, +"events": [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":57,"key_label":0,"unicode":57,"echo":false,"script":null) +] +} +editor_layout_prev={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194323,"key_label":0,"unicode":0,"echo":false,"script":null) +] +} +editor_layout_next={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194324,"key_label":0,"unicode":0,"echo":false,"script":null) +] +} + [internationalization] locale/translations=PackedStringArray("res://translations/de.mo", "res://translations/en.mo", "res://translations/fr.mo", "res://translations/ja.mo", "res://translations/nl.mo", "res://translations/pl_PL.mo", "res://translations/pt_BR.mo", "res://translations/ru_RU.mo", "res://translations/uk_UA.mo", "res://translations/zh_TW.mo") diff --git a/src/ui/screen_editor/scripts/editor_ui.gd b/src/ui/screen_editor/scripts/editor_ui.gd index 4780083..566f628 100644 --- a/src/ui/screen_editor/scripts/editor_ui.gd +++ b/src/ui/screen_editor/scripts/editor_ui.gd @@ -14,9 +14,9 @@ class_name EditorUI extends HBoxContainer # TODO: # - Figure out re-ordering buttons in sidebar; (Right click shows menu for 'move up' and 'move down'?) # - Adding new layouts to sidebar (Right menu click?); -# - Shortcuts for easily switching between different layouts (ctrl+number?); # - Make it possible to set custom icons (Right click menu); + var instance: EditorUI var config := ConfigFile.new() @@ -41,6 +41,23 @@ func _ready(): add_layout("render_menu") +func _input(event) -> void: + ## Shortcuts for changing the editor layout. + # TODO: Make it possible to change these shortcuts + for layout_id in range(1,10): + if event.is_action_pressed("editor_layout_%s" % layout_id): + change_layout(layout_id) + if event.is_action_pressed("editor_layout_prev"): + change_layout(clamp(%LayoutContainer.current_tab - 1, 1,9)) + if event.is_action_pressed("editor_layout_prev"): + change_layout(clamp(%LayoutContainer.current_tab + 1, 1,9)) + + +func change_layout(id: int) -> void: + if id <= (%LayoutContainer.get_child_count() - 1): + %LayoutContainer.current_tab = id + + ## Loading in all layouts func load_layouts() -> void: # First load in all custom layouts