Skip to content

Commit 0d7a287

Browse files
Add Timeline Shortcut Cheat Sheet (#2529)
* Further fix native file dialog * Implement shortcut cheat-sheet for timeline editor * Fix #1382 * Small adjustments to shortcut sheet
1 parent 4bba927 commit 0d7a287

File tree

5 files changed

+224
-88
lines changed

5 files changed

+224
-88
lines changed

addons/dialogic/Editor/TimelineEditor/TextEditor/timeline_editor_text.gd

Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ func _gui_input(event):
8080
"Ctrl+K":
8181
toggle_comment()
8282
"Alt+Up":
83-
move_line(-1)
83+
move_lines_up()
8484
"Alt+Down":
85-
move_line(1)
86-
"Ctrl+Shift+D":
87-
duplicate_line()
85+
move_lines_down()
86+
"Ctrl+Shift+D", "Ctrl+D":
87+
duplicate_lines()
8888
_:
8989
return
9090
get_viewport().set_input_as_handled()
@@ -128,59 +128,6 @@ func toggle_comment() -> void:
128128
text_changed.emit()
129129

130130

131-
# Move the selected lines up or down
132-
func move_line(offset: int) -> void:
133-
offset = clamp(offset, -1, 1)
134-
135-
var cursor: Vector2 = Vector2(get_caret_column(), get_caret_line())
136-
var reselect: bool = false
137-
var from: int = cursor.y
138-
var to: int = cursor.y
139-
if has_selection():
140-
reselect = true
141-
from = get_selection_from_line()
142-
to = get_selection_to_line()
143-
144-
var lines := text.split("\n")
145-
146-
if from + offset < 0 or to + offset >= lines.size(): return
147-
148-
var target_from_index: int = from - 1 if offset == -1 else to + 1
149-
var target_to_index: int = to if offset == -1 else from
150-
var line_to_move: String = lines[target_from_index]
151-
lines.remove_at(target_from_index)
152-
lines.insert(target_to_index, line_to_move)
153-
154-
text = "\n".join(lines)
155-
156-
cursor.y += offset
157-
from += offset
158-
to += offset
159-
if reselect:
160-
select(from, 0, to, get_line_width(to))
161-
set_caret_line(cursor.y)
162-
set_caret_column(cursor.x)
163-
text_changed.emit()
164-
165-
166-
func duplicate_line() -> void:
167-
var cursor: Vector2 = Vector2(get_caret_column(), get_caret_line())
168-
var from: int = cursor.y
169-
var to: int = cursor.y+1
170-
if has_selection():
171-
from = get_selection_from_line()
172-
to = get_selection_to_line()+1
173-
174-
var lines := text.split("\n")
175-
var lines_to_dupl: PackedStringArray = lines.slice(from, to)
176-
177-
text = "\n".join(lines.slice(0, from)+lines_to_dupl+lines.slice(from))
178-
179-
set_caret_line(cursor.y+to-from)
180-
set_caret_column(cursor.x)
181-
text_changed.emit()
182-
183-
184131
# Allows dragging files into the editor
185132
func _can_drop_data(at_position:Vector2, data:Variant) -> bool:
186133
if typeof(data) == TYPE_DICTIONARY and 'files' in data.keys() and len(data.files) == 1:
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
@tool
2+
extends PanelContainer
3+
4+
5+
var shortcuts := [
6+
7+
{"shortcut":"Ctrl+T", "text":"Add Text event", "editor":"VisualEditor"},
8+
{"shortcut":"Ctrl+Shift+T", "text":"Add Text event with current character", "editor":"VisualEditor"},
9+
{"shortcut":"Ctrl+Alt/Opt+T", "text":"Add Text event with previous character", "editor":"VisualEditor"},
10+
{"shortcut":"Ctrl+E", "text":"Add Character join event", "editor":"VisualEditor"},
11+
{"shortcut":"Ctrl+Shift+E", "text":"Add Character update event", "editor":"VisualEditor"},
12+
{"shortcut":"Ctrl+Alt/Opt+E", "text":"Add Character leave event", "editor":"VisualEditor"},
13+
{"shortcut":"Ctrl+J", "text":"Add Jump event", "editor":"VisualEditor"},
14+
{"shortcut":"Ctrl+L", "text":"Add Label event", "editor":"VisualEditor"},
15+
{},
16+
{"shortcut":"Alt/Opt+Up", "text":"Move selected events/lines up"},
17+
{"shortcut":"Alt/Opt+Down", "text":"Move selected events/lines down"},
18+
{},
19+
{"shortcut":"Ctrl+F", "text":"Search"},
20+
21+
{},
22+
{"shortcut":"Ctrl+C", "text":"Copy"},
23+
{"shortcut":"Ctrl+V", "text":"Paste"},
24+
{"shortcut":"Ctrl+D", "text":"Duplicate selected events/lines"},
25+
{"shortcut":"Ctrl+X", "text":"Cut selected events/lines"},
26+
{"shortcut":"Ctrl+#", "text":"Toggle Comment" , "editor":"TextEditor"},
27+
{"shortcut":"Delete", "text":"Delete events", "editor":"VisualEditor"},
28+
{},
29+
{"shortcut":"Ctrl+A", "text":"Select All"},
30+
{"shortcut":"Ctrl+Shift+A", "text":"Select Nothing", "editor":"VisualEditor"},
31+
{"shortcut":"Up", "text":"Select previous event", "editor":"VisualEditor"},
32+
{"shortcut":"Down", "text":"Select next event", "editor":"VisualEditor"},
33+
{},
34+
{"shortcut":"Ctrl+Z", "text":"Undo"},
35+
{"shortcut":"Ctrl+Shift+Z", "text":"Redo"},
36+
{},
37+
]
38+
39+
40+
# Called when the node enters the scene tree for the first time.
41+
func _ready() -> void:
42+
%CloseShortcutPanel.icon = get_theme_icon("Close", "EditorIcons")
43+
get_theme_stylebox("panel").bg_color = get_theme_color("dark_color_3", "Editor")
44+
45+
func reload_shortcuts() -> void:
46+
for i in %ShortcutList.get_children():
47+
i.queue_free()
48+
49+
50+
var is_text_editor: bool = %TextEditor.visible
51+
for i in shortcuts:
52+
if i.is_empty():
53+
%ShortcutList.add_child(HSeparator.new())
54+
%ShortcutList.add_child(HSeparator.new())
55+
continue
56+
if "editor" in i and not get_node("%"+i.editor).visible:
57+
continue
58+
59+
var hbox := HBoxContainer.new()
60+
hbox.add_theme_constant_override("separation", 0)
61+
for key_text in i.shortcut.split("+"):
62+
if hbox.get_child_count():
63+
var plus_l := Label.new()
64+
plus_l.text = "+"
65+
hbox.add_child(plus_l)
66+
67+
68+
69+
var key := Button.new()
70+
if key_text == "Up":
71+
key.icon = get_theme_icon("ArrowUp", "EditorIcons")
72+
elif key_text == "Down":
73+
key.icon = get_theme_icon("ArrowDown", "EditorIcons")
74+
else:
75+
key.text = key_text
76+
key.disabled = true
77+
key.theme_type_variation = "ShortcutKeyLabel"
78+
hbox.add_child(key)
79+
80+
%ShortcutList.add_child(hbox)
81+
82+
var text := Label.new()
83+
text.text = i.text.replace("events/lines", "lines" if is_text_editor else "events")
84+
text.theme_type_variation = "DialogicHintText2"
85+
%ShortcutList.add_child(text)
86+
87+
88+
func open():
89+
if visible:
90+
close()
91+
return
92+
93+
reload_shortcuts()
94+
95+
show()
96+
size = get_parent().size - Vector2(200, 200)*DialogicUtil.get_editor_scale()
97+
size.x = %ShortcutList.get_minimum_size().x + 100
98+
global_position = get_parent().global_position+get_parent().size/2-size/2
99+
100+
101+
func _on_close_shortcut_panel_pressed() -> void:
102+
close()
103+
104+
func close() -> void:
105+
hide()

addons/dialogic/Editor/TimelineEditor/timeline_editor.gd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ func _ready() -> void:
186186
%SwitchEditorMode.pressed.connect(toggle_editor_mode)
187187
%SwitchEditorMode.custom_minimum_size.x = 200 * DialogicUtil.get_editor_scale()
188188

189+
%Shortcuts.icon = get_theme_icon("InputEventShortcut", "EditorIcons")
190+
%Shortcuts.pressed.connect(%ShortcutsPanel.open)
191+
189192
%SearchClose.icon = get_theme_icon("Close", "EditorIcons")
190193
%SearchUp.icon = get_theme_icon("MoveUp", "EditorIcons")
191194
%SearchDown.icon = get_theme_icon("MoveDown", "EditorIcons")

0 commit comments

Comments
 (0)