You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-24 15:26:15 +00:00
Add Embed Game Window hotkeys support and pause/next frame shortcuts
This commit is contained in:
@@ -97,6 +97,12 @@ void GameViewDebugger::_session_started(Ref<EditorDebuggerSession> p_session) {
|
||||
mute_audio_data.append(mute_audio);
|
||||
p_session->send_message("scene:debug_mute_audio", mute_audio_data);
|
||||
|
||||
Dictionary shortcut_settings;
|
||||
shortcut_settings["editor/suspend_resume_embedded_project"] = DebuggerMarshalls::serialize_key_shortcut(ED_GET_SHORTCUT("editor/suspend_resume_embedded_project"));
|
||||
shortcut_settings["editor/next_frame_embedded_project"] = DebuggerMarshalls::serialize_key_shortcut(ED_GET_SHORTCUT("editor/next_frame_embedded_project"));
|
||||
|
||||
p_session->send_message("scene:setup_embedded_shortcuts", { shortcut_settings });
|
||||
|
||||
emit_signal(SNAME("session_started"));
|
||||
}
|
||||
|
||||
@@ -419,6 +425,23 @@ void GameView::_update_debugger_buttons() {
|
||||
next_frame_button->set_disabled(!suspend_button->is_pressed());
|
||||
}
|
||||
|
||||
void GameView::_handle_shortcut_requested(int p_embed_action) {
|
||||
switch (p_embed_action) {
|
||||
case ScriptEditorDebugger::EMBED_SUSPEND_TOGGLE: {
|
||||
_toggle_suspend_button();
|
||||
} break;
|
||||
case ScriptEditorDebugger::EMBED_NEXT_FRAME: {
|
||||
debugger->next_frame();
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void GameView::_toggle_suspend_button() {
|
||||
const bool new_pressed = !suspend_button->is_pressed();
|
||||
suspend_button->set_pressed(new_pressed);
|
||||
_suspend_button_toggled(new_pressed);
|
||||
}
|
||||
|
||||
void GameView::_suspend_button_toggled(bool p_pressed) {
|
||||
_update_debugger_buttons();
|
||||
|
||||
@@ -773,12 +796,14 @@ void GameView::_attach_script_debugger() {
|
||||
|
||||
if (embedded_script_debugger) {
|
||||
embedded_script_debugger->connect("remote_window_title_changed", callable_mp(this, &GameView::_remote_window_title_changed));
|
||||
embedded_script_debugger->connect("embed_shortcut_requested", callable_mp(this, &GameView::_handle_shortcut_requested));
|
||||
}
|
||||
}
|
||||
|
||||
void GameView::_detach_script_debugger() {
|
||||
if (embedded_script_debugger) {
|
||||
embedded_script_debugger->disconnect("remote_window_title_changed", callable_mp(this, &GameView::_remote_window_title_changed));
|
||||
embedded_script_debugger->disconnect("embed_shortcut_requested", callable_mp(this, &GameView::_handle_shortcut_requested));
|
||||
embedded_script_debugger = nullptr;
|
||||
}
|
||||
}
|
||||
@@ -930,6 +955,9 @@ GameView::GameView(Ref<GameViewDebugger> p_debugger, WindowWrapper *p_wrapper) {
|
||||
suspend_button->connect(SceneStringName(toggled), callable_mp(this, &GameView::_suspend_button_toggled));
|
||||
suspend_button->set_tooltip_text(TTR("Suspend"));
|
||||
suspend_button->set_accessibility_name(TTRC("Suspend"));
|
||||
ED_SHORTCUT("editor/suspend_resume_embedded_project", TTRC("Suspend/Resume Embedded Project"), Key::F9);
|
||||
ED_SHORTCUT_OVERRIDE("editor/suspend_resume_embedded_project", "macos", KeyModifierMask::META | KeyModifierMask::SHIFT | Key::B);
|
||||
suspend_button->set_shortcut(ED_GET_SHORTCUT("editor/suspend_resume_embedded_project"));
|
||||
|
||||
next_frame_button = memnew(Button);
|
||||
main_menu_hbox->add_child(next_frame_button);
|
||||
@@ -937,6 +965,7 @@ GameView::GameView(Ref<GameViewDebugger> p_debugger, WindowWrapper *p_wrapper) {
|
||||
next_frame_button->connect(SceneStringName(pressed), callable_mp(*debugger, &GameViewDebugger::next_frame));
|
||||
next_frame_button->set_tooltip_text(TTR("Next Frame"));
|
||||
next_frame_button->set_accessibility_name(TTRC("Next Frame"));
|
||||
next_frame_button->set_shortcut(ED_SHORTCUT("editor/next_frame_embedded_project", TTRC("Next Frame"), Key::F10));
|
||||
|
||||
main_menu_hbox->add_child(memnew(VSeparator));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user