Skip to content

Commit 6fcaf71

Browse files
committed
Merge pull request #101739 from Hilderin/fix-embedding-with-user-arguments
Fix Embedded Game Window with user arguments
2 parents 7a63dc9 + f216efd commit 6fcaf71

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

editor/plugins/game_view_plugin.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,7 @@ void GameView::_update_arguments_for_instance(int p_idx, List<String> &r_argumen
616616

617617
// Remove duplicates/unwanted parameters.
618618
List<String>::Element *E = r_arguments.front();
619+
List<String>::Element *user_args_element = nullptr;
619620
while (E) {
620621
List<String>::Element *N = E->next();
621622

@@ -629,23 +630,26 @@ void GameView::_update_arguments_for_instance(int p_idx, List<String> &r_argumen
629630
}
630631
} else if (E->get() == "-f" || E->get() == "--fullscreen" || E->get() == "-m" || E->get() == "--maximized" || E->get() == "-t" || E->get() == "-always-on-top") {
631632
r_arguments.erase(E);
633+
} else if (E->get() == "--" || E->get() == "++") {
634+
user_args_element = E;
635+
break;
632636
}
633637

634638
E = N;
635639
}
636640

637641
// Add the editor window's native ID so the started game can directly set it as its parent.
638-
r_arguments.push_back("--wid");
639-
r_arguments.push_back(itos(DisplayServer::get_singleton()->window_get_native_handle(DisplayServer::WINDOW_HANDLE, get_window()->get_window_id())));
642+
List<String>::Element *N = r_arguments.insert_before(user_args_element, "--wid");
643+
N = r_arguments.insert_after(N, itos(DisplayServer::get_singleton()->window_get_native_handle(DisplayServer::WINDOW_HANDLE, get_window()->get_window_id())));
640644

641645
// Be sure to have the correct window size in the embedded_process control.
642646
_update_embed_window_size();
643647

644648
Rect2i rect = embedded_process->get_screen_embedded_window_rect();
645-
r_arguments.push_back("--position");
646-
r_arguments.push_back(itos(rect.position.x) + "," + itos(rect.position.y));
647-
r_arguments.push_back("--resolution");
648-
r_arguments.push_back(itos(rect.size.x) + "x" + itos(rect.size.y));
649+
N = r_arguments.insert_after(N, "--position");
650+
N = r_arguments.insert_after(N, itos(rect.position.x) + "," + itos(rect.position.y));
651+
N = r_arguments.insert_after(N, "--resolution");
652+
r_arguments.insert_after(N, itos(rect.size.x) + "x" + itos(rect.size.y));
649653
}
650654

651655
void GameView::_window_before_closing() {

0 commit comments

Comments
 (0)