소스 검색

[DisplayServer] Add separate feature flags for different native dialog types.

bruvzg 1 년 전
부모
커밋
dc01658ee9

+ 11 - 5
doc/classes/DisplayServer.xml

@@ -103,7 +103,7 @@
 			<param index="3" name="callback" type="Callable" />
 			<param index="3" name="callback" type="Callable" />
 			<description>
 			<description>
 				Shows a text input dialog which uses the operating system's native look-and-feel. [param callback] should accept a single [String] parameter which contains the text field's contents.
 				Shows a text input dialog which uses the operating system's native look-and-feel. [param callback] should accept a single [String] parameter which contains the text field's contents.
-				[b]Note:[/b] This method is implemented only on macOS and Windows.
+				[b]Note:[/b] This method is implemented if the display server has the [constant FEATURE_NATIVE_DIALOG_INPUT] feature. Supported platforms include macOS and Windows.
 			</description>
 			</description>
 		</method>
 		</method>
 		<method name="dialog_show">
 		<method name="dialog_show">
@@ -114,7 +114,7 @@
 			<param index="3" name="callback" type="Callable" />
 			<param index="3" name="callback" type="Callable" />
 			<description>
 			<description>
 				Shows a text dialog which uses the operating system's native look-and-feel. [param callback] should accept a single [int] parameter which corresponds to the index of the pressed button.
 				Shows a text dialog which uses the operating system's native look-and-feel. [param callback] should accept a single [int] parameter which corresponds to the index of the pressed button.
-				[b]Note:[/b] This method is implemented only on macOS and Windows.
+				[b]Note:[/b] This method is implemented if the display server has the [constant FEATURE_NATIVE_DIALOG] feature. Supported platforms include macOS and Windows.
 			</description>
 			</description>
 		</method>
 		</method>
 		<method name="enable_for_stealing_focus">
 		<method name="enable_for_stealing_focus">
@@ -138,7 +138,7 @@
 				Displays OS native dialog for selecting files or directories in the file system.
 				Displays OS native dialog for selecting files or directories in the file system.
 				Each filter string in the [param filters] array should be formatted like this: [code]*.txt,*.doc;Text Files[/code]. The description text of the filter is optional and can be omitted. See also [member FileDialog.filters].
 				Each filter string in the [param filters] array should be formatted like this: [code]*.txt,*.doc;Text Files[/code]. The description text of the filter is optional and can be omitted. See also [member FileDialog.filters].
 				Callbacks have the following arguments: [code]status: bool, selected_paths: PackedStringArray, selected_filter_index: int[/code].
 				Callbacks have the following arguments: [code]status: bool, selected_paths: PackedStringArray, selected_filter_index: int[/code].
-				[b]Note:[/b] This method is implemented if the display server has the [constant FEATURE_NATIVE_DIALOG] feature. Supported platforms include Linux (X11/Wayland), Windows, and macOS.
+				[b]Note:[/b] This method is implemented if the display server has the [constant FEATURE_NATIVE_DIALOG_FILE] feature. Supported platforms include Linux (X11/Wayland), Windows, and macOS.
 				[b]Note:[/b] [param current_directory] might be ignored.
 				[b]Note:[/b] [param current_directory] might be ignored.
 				[b]Note:[/b] On Linux, [param show_hidden] is ignored.
 				[b]Note:[/b] On Linux, [param show_hidden] is ignored.
 				[b]Note:[/b] On macOS, native file dialogs have no title.
 				[b]Note:[/b] On macOS, native file dialogs have no title.
@@ -164,7 +164,7 @@
 				- [code]"values"[/code] - [PackedStringArray] of values. If empty, boolean option (check box) is used.
 				- [code]"values"[/code] - [PackedStringArray] of values. If empty, boolean option (check box) is used.
 				- [code]"default"[/code] - default selected option index ([int]) or default boolean value ([bool]).
 				- [code]"default"[/code] - default selected option index ([int]) or default boolean value ([bool]).
 				Callbacks have the following arguments: [code]status: bool, selected_paths: PackedStringArray, selected_filter_index: int, selected_option: Dictionary[/code].
 				Callbacks have the following arguments: [code]status: bool, selected_paths: PackedStringArray, selected_filter_index: int, selected_option: Dictionary[/code].
-				[b]Note:[/b] This method is implemented if the display server has the [constant FEATURE_NATIVE_DIALOG] feature. Supported platforms include Linux (X11/Wayland), Windows, and macOS.
+				[b]Note:[/b] This method is implemented if the display server has the [constant FEATURE_NATIVE_DIALOG_FILE] feature. Supported platforms include Linux (X11/Wayland), Windows, and macOS.
 				[b]Note:[/b] [param current_directory] might be ignored.
 				[b]Note:[/b] [param current_directory] might be ignored.
 				[b]Note:[/b] On Linux (X11), [param show_hidden] is ignored.
 				[b]Note:[/b] On Linux (X11), [param show_hidden] is ignored.
 				[b]Note:[/b] On macOS, native file dialogs have no title.
 				[b]Note:[/b] On macOS, native file dialogs have no title.
@@ -1784,7 +1784,7 @@
 			Display server supports setting the mouse cursor shape to a custom image. [b]Windows, macOS, Linux (X11/Wayland), Web[/b]
 			Display server supports setting the mouse cursor shape to a custom image. [b]Windows, macOS, Linux (X11/Wayland), Web[/b]
 		</constant>
 		</constant>
 		<constant name="FEATURE_NATIVE_DIALOG" value="9" enum="Feature">
 		<constant name="FEATURE_NATIVE_DIALOG" value="9" enum="Feature">
-			Display server supports spawning dialogs using the operating system's native look-and-feel. [b]Windows, macOS, Linux (X11/Wayland)[/b]
+			Display server supports spawning text dialogs using the operating system's native look-and-feel. See [method dialog_show]. [b]Windows, macOS[/b]
 		</constant>
 		</constant>
 		<constant name="FEATURE_IME" value="10" enum="Feature">
 		<constant name="FEATURE_IME" value="10" enum="Feature">
 			Display server supports [url=https://en.wikipedia.org/wiki/Input_method]Input Method Editor[/url], which is commonly used for inputting Chinese/Japanese/Korean text. This is handled by the operating system, rather than by Godot. [b]Windows, macOS, Linux (X11)[/b]
 			Display server supports [url=https://en.wikipedia.org/wiki/Input_method]Input Method Editor[/url], which is commonly used for inputting Chinese/Japanese/Korean text. This is handled by the operating system, rather than by Godot. [b]Windows, macOS, Linux (X11)[/b]
@@ -1825,6 +1825,12 @@
 		<constant name="FEATURE_NATIVE_HELP" value="23" enum="Feature">
 		<constant name="FEATURE_NATIVE_HELP" value="23" enum="Feature">
 			Display server supports native help system search callbacks. See [method help_set_search_callbacks].
 			Display server supports native help system search callbacks. See [method help_set_search_callbacks].
 		</constant>
 		</constant>
+		<constant name="FEATURE_NATIVE_DIALOG_INPUT" value="24" enum="Feature">
+			Display server supports spawning text input dialogs using the operating system's native look-and-feel. See [method dialog_input_text]. [b]Windows, macOS[/b]
+		</constant>
+		<constant name="FEATURE_NATIVE_DIALOG_FILE" value="25" enum="Feature">
+			Display server supports spawning dialogs for selecting files or directories using the operating system's native look-and-feel. See [method file_dialog_show] and [method file_dialog_with_options_show]. [b]Windows, macOS, Linux (X11/Wayland)[/b]
+		</constant>
 		<constant name="MOUSE_MODE_VISIBLE" value="0" enum="MouseMode">
 		<constant name="MOUSE_MODE_VISIBLE" value="0" enum="MouseMode">
 			Makes the mouse cursor visible if it is hidden.
 			Makes the mouse cursor visible if it is hidden.
 		</constant>
 		</constant>

+ 2 - 0
platform/android/display_server_android.cpp

@@ -71,6 +71,8 @@ bool DisplayServerAndroid::has_feature(Feature p_feature) const {
 		case FEATURE_MOUSE:
 		case FEATURE_MOUSE:
 		//case FEATURE_MOUSE_WARP:
 		//case FEATURE_MOUSE_WARP:
 		//case FEATURE_NATIVE_DIALOG:
 		//case FEATURE_NATIVE_DIALOG:
+		//case FEATURE_NATIVE_DIALOG_INPUT:
+		//case FEATURE_NATIVE_DIALOG_FILE:
 		//case FEATURE_NATIVE_ICON:
 		//case FEATURE_NATIVE_ICON:
 		//case FEATURE_WINDOW_TRANSPARENCY:
 		//case FEATURE_WINDOW_TRANSPARENCY:
 		case FEATURE_CLIPBOARD:
 		case FEATURE_CLIPBOARD:

+ 2 - 0
platform/ios/display_server_ios.mm

@@ -328,6 +328,8 @@ bool DisplayServerIOS::has_feature(Feature p_feature) const {
 		// case FEATURE_MOUSE:
 		// case FEATURE_MOUSE:
 		// case FEATURE_MOUSE_WARP:
 		// case FEATURE_MOUSE_WARP:
 		// case FEATURE_NATIVE_DIALOG:
 		// case FEATURE_NATIVE_DIALOG:
+		// case FEATURE_NATIVE_DIALOG_INPUT:
+		// case FEATURE_NATIVE_DIALOG_FILE:
 		// case FEATURE_NATIVE_ICON:
 		// case FEATURE_NATIVE_ICON:
 		// case FEATURE_WINDOW_TRANSPARENCY:
 		// case FEATURE_WINDOW_TRANSPARENCY:
 		case FEATURE_CLIPBOARD:
 		case FEATURE_CLIPBOARD:

+ 3 - 1
platform/linuxbsd/wayland/display_server_wayland.cpp

@@ -210,8 +210,10 @@ bool DisplayServerWayland::has_feature(Feature p_feature) const {
 			return true;
 			return true;
 		} break;
 		} break;
 
 
+		//case FEATURE_NATIVE_DIALOG:
+		//case FEATURE_NATIVE_DIALOG_INPUT:
 #ifdef DBUS_ENABLED
 #ifdef DBUS_ENABLED
-		case FEATURE_NATIVE_DIALOG: {
+		case FEATURE_NATIVE_DIALOG_FILE: {
 			return true;
 			return true;
 		} break;
 		} break;
 #endif
 #endif

+ 3 - 1
platform/linuxbsd/x11/display_server_x11.cpp

@@ -128,8 +128,10 @@ bool DisplayServerX11::has_feature(Feature p_feature) const {
 		//case FEATURE_HIDPI:
 		//case FEATURE_HIDPI:
 		case FEATURE_ICON:
 		case FEATURE_ICON:
 #ifdef DBUS_ENABLED
 #ifdef DBUS_ENABLED
-		case FEATURE_NATIVE_DIALOG:
+		case FEATURE_NATIVE_DIALOG_FILE:
 #endif
 #endif
+		//case FEATURE_NATIVE_DIALOG:
+		//case FEATURE_NATIVE_DIALOG_INPUT:
 		//case FEATURE_NATIVE_ICON:
 		//case FEATURE_NATIVE_ICON:
 		case FEATURE_SWAP_BUFFERS:
 		case FEATURE_SWAP_BUFFERS:
 #ifdef DBUS_ENABLED
 #ifdef DBUS_ENABLED

+ 2 - 0
platform/macos/display_server_macos.mm

@@ -755,6 +755,8 @@ bool DisplayServerMacOS::has_feature(Feature p_feature) const {
 		case FEATURE_CURSOR_SHAPE:
 		case FEATURE_CURSOR_SHAPE:
 		case FEATURE_CUSTOM_CURSOR_SHAPE:
 		case FEATURE_CUSTOM_CURSOR_SHAPE:
 		case FEATURE_NATIVE_DIALOG:
 		case FEATURE_NATIVE_DIALOG:
+		case FEATURE_NATIVE_DIALOG_INPUT:
+		case FEATURE_NATIVE_DIALOG_FILE:
 		case FEATURE_IME:
 		case FEATURE_IME:
 		case FEATURE_WINDOW_TRANSPARENCY:
 		case FEATURE_WINDOW_TRANSPARENCY:
 		case FEATURE_HIDPI:
 		case FEATURE_HIDPI:

+ 2 - 0
platform/web/display_server_web.cpp

@@ -1128,6 +1128,8 @@ bool DisplayServerWeb::has_feature(Feature p_feature) const {
 			return true;
 			return true;
 		//case FEATURE_MOUSE_WARP:
 		//case FEATURE_MOUSE_WARP:
 		//case FEATURE_NATIVE_DIALOG:
 		//case FEATURE_NATIVE_DIALOG:
+		//case FEATURE_NATIVE_DIALOG_INPUT:
+		//case FEATURE_NATIVE_DIALOG_FILE:
 		//case FEATURE_NATIVE_ICON:
 		//case FEATURE_NATIVE_ICON:
 		//case FEATURE_WINDOW_TRANSPARENCY:
 		//case FEATURE_WINDOW_TRANSPARENCY:
 		//case FEATURE_KEEP_SCREEN_ON:
 		//case FEATURE_KEEP_SCREEN_ON:

+ 2 - 0
platform/windows/display_server_windows.cpp

@@ -114,6 +114,8 @@ bool DisplayServerWindows::has_feature(Feature p_feature) const {
 		case FEATURE_ICON:
 		case FEATURE_ICON:
 		case FEATURE_NATIVE_ICON:
 		case FEATURE_NATIVE_ICON:
 		case FEATURE_NATIVE_DIALOG:
 		case FEATURE_NATIVE_DIALOG:
+		case FEATURE_NATIVE_DIALOG_INPUT:
+		case FEATURE_NATIVE_DIALOG_FILE:
 		case FEATURE_SWAP_BUFFERS:
 		case FEATURE_SWAP_BUFFERS:
 		case FEATURE_KEEP_SCREEN_ON:
 		case FEATURE_KEEP_SCREEN_ON:
 		case FEATURE_TEXT_TO_SPEECH:
 		case FEATURE_TEXT_TO_SPEECH:

+ 2 - 2
scene/gui/file_dialog.cpp

@@ -68,7 +68,7 @@ void FileDialog::popup(const Rect2i &p_rect) {
 	}
 	}
 #endif
 #endif
 
 
-	if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_DIALOG) && (use_native_dialog || OS::get_singleton()->is_sandboxed())) {
+	if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_DIALOG_FILE) && (use_native_dialog || OS::get_singleton()->is_sandboxed())) {
 		String root;
 		String root;
 		if (access == ACCESS_RESOURCES) {
 		if (access == ACCESS_RESOURCES) {
 			root = ProjectSettings::get_singleton()->get_resource_path();
 			root = ProjectSettings::get_singleton()->get_resource_path();
@@ -91,7 +91,7 @@ void FileDialog::set_visible(bool p_visible) {
 	}
 	}
 #endif
 #endif
 
 
-	if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_DIALOG) && (use_native_dialog || OS::get_singleton()->is_sandboxed())) {
+	if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_NATIVE_DIALOG_FILE) && (use_native_dialog || OS::get_singleton()->is_sandboxed())) {
 		if (p_visible) {
 		if (p_visible) {
 			String root;
 			String root;
 			if (access == ACCESS_RESOURCES) {
 			if (access == ACCESS_RESOURCES) {

+ 2 - 0
servers/display_server.cpp

@@ -1014,6 +1014,8 @@ void DisplayServer::_bind_methods() {
 	BIND_ENUM_CONSTANT(FEATURE_SCREEN_CAPTURE);
 	BIND_ENUM_CONSTANT(FEATURE_SCREEN_CAPTURE);
 	BIND_ENUM_CONSTANT(FEATURE_STATUS_INDICATOR);
 	BIND_ENUM_CONSTANT(FEATURE_STATUS_INDICATOR);
 	BIND_ENUM_CONSTANT(FEATURE_NATIVE_HELP);
 	BIND_ENUM_CONSTANT(FEATURE_NATIVE_HELP);
+	BIND_ENUM_CONSTANT(FEATURE_NATIVE_DIALOG_INPUT);
+	BIND_ENUM_CONSTANT(FEATURE_NATIVE_DIALOG_FILE);
 
 
 	BIND_ENUM_CONSTANT(MOUSE_MODE_VISIBLE);
 	BIND_ENUM_CONSTANT(MOUSE_MODE_VISIBLE);
 	BIND_ENUM_CONSTANT(MOUSE_MODE_HIDDEN);
 	BIND_ENUM_CONSTANT(MOUSE_MODE_HIDDEN);

+ 2 - 0
servers/display_server.h

@@ -140,6 +140,8 @@ public:
 		FEATURE_SCREEN_CAPTURE,
 		FEATURE_SCREEN_CAPTURE,
 		FEATURE_STATUS_INDICATOR,
 		FEATURE_STATUS_INDICATOR,
 		FEATURE_NATIVE_HELP,
 		FEATURE_NATIVE_HELP,
+		FEATURE_NATIVE_DIALOG_INPUT,
+		FEATURE_NATIVE_DIALOG_FILE,
 	};
 	};
 
 
 	virtual bool has_feature(Feature p_feature) const = 0;
 	virtual bool has_feature(Feature p_feature) const = 0;