瀏覽代碼

Add more project window placement options

It is now possible to use the previous or next monitor (relative to
the editor) to display running projects. If either end is reached,
it will wrap around to the last or first monitor (respectively).

This closes #20283.
Hugo Locurcio 7 年之前
父節點
當前提交
475a46c59c
共有 2 個文件被更改,包括 17 次插入2 次删除
  1. 16 1
      editor/editor_run.cpp
  2. 1 1
      editor/editor_settings.cpp

+ 16 - 1
editor/editor_run.cpp

@@ -68,9 +68,24 @@ Error EditorRun::run(const String &p_scene, const String p_custom_args, const Li
 
 
 	int screen = EditorSettings::get_singleton()->get("run/window_placement/screen");
 	int screen = EditorSettings::get_singleton()->get("run/window_placement/screen");
 	if (screen == 0) {
 	if (screen == 0) {
+		// Same as editor
 		screen = OS::get_singleton()->get_current_screen();
 		screen = OS::get_singleton()->get_current_screen();
+	} else if (screen == 1) {
+		// Previous monitor (wrap to the other end if needed)
+		screen = Math::wrapi(
+				OS::get_singleton()->get_current_screen() - 1,
+				0,
+				OS::get_singleton()->get_screen_count());
+	} else if (screen == 2) {
+		// Next monitor (wrap to the other end if needed)
+		screen = Math::wrapi(
+				OS::get_singleton()->get_current_screen() + 1,
+				0,
+				OS::get_singleton()->get_screen_count());
 	} else {
 	} else {
-		screen--;
+		// Fixed monitor ID
+		// There are 3 special options, so decrement the option ID by 3 to get the monitor ID
+		screen -= 3;
 	}
 	}
 
 
 	if (OS::get_singleton()->is_disable_crash_handler()) {
 	if (OS::get_singleton()->is_disable_crash_handler()) {

+ 1 - 1
editor/editor_settings.cpp

@@ -492,7 +492,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
 
 
 	_initial_set("run/window_placement/rect", 1);
 	_initial_set("run/window_placement/rect", 1);
 	hints["run/window_placement/rect"] = PropertyInfo(Variant::INT, "run/window_placement/rect", PROPERTY_HINT_ENUM, "Top Left,Centered,Custom Position,Force Maximized,Force Fullscreen");
 	hints["run/window_placement/rect"] = PropertyInfo(Variant::INT, "run/window_placement/rect", PROPERTY_HINT_ENUM, "Top Left,Centered,Custom Position,Force Maximized,Force Fullscreen");
-	String screen_hints = TTR("Default (Same as Editor)");
+	String screen_hints = "Same as Editor,Previous Monitor,Next Monitor";
 	for (int i = 0; i < OS::get_singleton()->get_screen_count(); i++) {
 	for (int i = 0; i < OS::get_singleton()->get_screen_count(); i++) {
 		screen_hints += ",Monitor " + itos(i + 1);
 		screen_hints += ",Monitor " + itos(i + 1);
 	}
 	}