feat: updated engine version to 4.4-rc1

This commit is contained in:
Sara 2025-02-23 14:38:14 +01:00
parent ee00efde1f
commit 21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions

View file

@ -34,6 +34,17 @@
#include "scene/resources/texture.h"
#include "servers/display_server_headless.h"
#if defined(VULKAN_ENABLED)
#include "drivers/vulkan/rendering_context_driver_vulkan.h"
#undef CursorShape
#endif
#if defined(D3D12_ENABLED)
#include "drivers/d3d12/rendering_context_driver_d3d12.h"
#endif
#if defined(METAL_ENABLED)
#include "drivers/metal/rendering_context_driver_metal.h"
#endif
DisplayServer *DisplayServer::singleton = nullptr;
bool DisplayServer::hidpi_allowed = false;
@ -490,6 +501,22 @@ DisplayServer::MouseMode DisplayServer::mouse_get_mode() const {
return MOUSE_MODE_VISIBLE;
}
void DisplayServer::mouse_set_mode_override(MouseMode p_mode) {
WARN_PRINT("Mouse is not supported by this display server.");
}
DisplayServer::MouseMode DisplayServer::mouse_get_mode_override() const {
return MOUSE_MODE_VISIBLE;
}
void DisplayServer::mouse_set_mode_override_enabled(bool p_override_enabled) {
WARN_PRINT("Mouse is not supported by this display server.");
}
bool DisplayServer::mouse_is_mode_override_enabled() const {
return false;
}
void DisplayServer::warp_mouse(const Point2i &p_position) {
}
@ -539,7 +566,7 @@ DisplayServer::ScreenOrientation DisplayServer::screen_get_orientation(int p_scr
float DisplayServer::screen_get_scale(int p_screen) const {
return 1.0f;
};
}
bool DisplayServer::is_touchscreen_available() const {
return Input::get_singleton() && Input::get_singleton()->is_emulating_touch_from_mouse();
@ -607,7 +634,7 @@ Point2i DisplayServer::ime_get_selection() const {
}
String DisplayServer::ime_get_text() const {
ERR_FAIL_V_MSG(String(), "IME or NOTIFICATION_WM_IME_UPDATEnot supported by this display server.");
ERR_FAIL_V_MSG(String(), "IME or NOTIFICATION_WM_IME_UPDATE not supported by this display server.");
}
void DisplayServer::virtual_keyboard_show(const String &p_existing_text, const Rect2 &p_screen_rect, VirtualKeyboardType p_type, int p_max_length, int p_cursor_start, int p_cursor_end) {
@ -620,7 +647,12 @@ void DisplayServer::virtual_keyboard_hide() {
// returns height of the currently shown keyboard (0 if keyboard is hidden)
int DisplayServer::virtual_keyboard_get_height() const {
ERR_FAIL_V_MSG(0, "Virtual keyboard not supported by this display server.");
WARN_PRINT("Virtual keyboard not supported by this display server.");
return 0;
}
bool DisplayServer::has_hardware_keyboard() const {
return true;
}
void DisplayServer::cursor_set_shape(CursorShape p_shape) {
@ -642,6 +674,26 @@ bool DisplayServer::get_swap_cancel_ok() {
void DisplayServer::enable_for_stealing_focus(OS::ProcessID pid) {
}
Error DisplayServer::embed_process(WindowID p_window, OS::ProcessID p_pid, const Rect2i &p_rect, bool p_visible, bool p_grab_focus) {
WARN_PRINT("Embedded process not supported by this display server.");
return ERR_UNAVAILABLE;
}
Error DisplayServer::request_close_embedded_process(OS::ProcessID p_pid) {
WARN_PRINT("Embedded process not supported by this display server.");
return ERR_UNAVAILABLE;
}
Error DisplayServer::remove_embedded_process(OS::ProcessID p_pid) {
WARN_PRINT("Embedded process not supported by this display server.");
return ERR_UNAVAILABLE;
}
OS::ProcessID DisplayServer::get_focused_process_id() {
WARN_PRINT("Embedded process not supported by this display server.");
return 0;
}
Error DisplayServer::dialog_show(String p_title, String p_description, Vector<String> p_buttons, const Callable &p_callback) {
WARN_PRINT("Native dialogs not supported by this display server.");
return ERR_UNAVAILABLE;
@ -662,6 +714,9 @@ Error DisplayServer::file_dialog_with_options_show(const String &p_title, const
return ERR_UNAVAILABLE;
}
void DisplayServer::beep() const {
}
int DisplayServer::keyboard_get_layout_count() const {
return 0;
}
@ -689,6 +744,9 @@ Key DisplayServer::keyboard_get_label_from_physical(Key p_keycode) const {
ERR_FAIL_V_MSG(p_keycode, "Not supported by this display server.");
}
void DisplayServer::show_emoji_and_symbol_picker() const {
}
void DisplayServer::force_process_and_drop_events() {
}
@ -880,11 +938,12 @@ void DisplayServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("screen_get_usable_rect", "screen"), &DisplayServer::screen_get_usable_rect, DEFVAL(SCREEN_OF_MAIN_WINDOW));
ClassDB::bind_method(D_METHOD("screen_get_dpi", "screen"), &DisplayServer::screen_get_dpi, DEFVAL(SCREEN_OF_MAIN_WINDOW));
ClassDB::bind_method(D_METHOD("screen_get_scale", "screen"), &DisplayServer::screen_get_scale, DEFVAL(SCREEN_OF_MAIN_WINDOW));
ClassDB::bind_method(D_METHOD("is_touchscreen_available"), &DisplayServer::is_touchscreen_available, DEFVAL(SCREEN_OF_MAIN_WINDOW));
ClassDB::bind_method(D_METHOD("is_touchscreen_available"), &DisplayServer::is_touchscreen_available);
ClassDB::bind_method(D_METHOD("screen_get_max_scale"), &DisplayServer::screen_get_max_scale);
ClassDB::bind_method(D_METHOD("screen_get_refresh_rate", "screen"), &DisplayServer::screen_get_refresh_rate, DEFVAL(SCREEN_OF_MAIN_WINDOW));
ClassDB::bind_method(D_METHOD("screen_get_pixel", "position"), &DisplayServer::screen_get_pixel);
ClassDB::bind_method(D_METHOD("screen_get_image", "screen"), &DisplayServer::screen_get_image, DEFVAL(SCREEN_OF_MAIN_WINDOW));
ClassDB::bind_method(D_METHOD("screen_get_image_rect", "rect"), &DisplayServer::screen_get_image_rect);
ClassDB::bind_method(D_METHOD("screen_set_orientation", "orientation", "screen"), &DisplayServer::screen_set_orientation, DEFVAL(SCREEN_OF_MAIN_WINDOW));
ClassDB::bind_method(D_METHOD("screen_get_orientation", "screen"), &DisplayServer::screen_get_orientation, DEFVAL(SCREEN_OF_MAIN_WINDOW));
@ -957,6 +1016,9 @@ void DisplayServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("window_maximize_on_title_dbl_click"), &DisplayServer::window_maximize_on_title_dbl_click);
ClassDB::bind_method(D_METHOD("window_minimize_on_title_dbl_click"), &DisplayServer::window_minimize_on_title_dbl_click);
ClassDB::bind_method(D_METHOD("window_start_drag", "window_id"), &DisplayServer::window_start_drag, DEFVAL(MAIN_WINDOW_ID));
ClassDB::bind_method(D_METHOD("window_start_resize", "edge", "window_id"), &DisplayServer::window_start_resize, DEFVAL(MAIN_WINDOW_ID));
ClassDB::bind_method(D_METHOD("ime_get_selection"), &DisplayServer::ime_get_selection);
ClassDB::bind_method(D_METHOD("ime_get_text"), &DisplayServer::ime_get_text);
@ -965,6 +1027,8 @@ void DisplayServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("virtual_keyboard_get_height"), &DisplayServer::virtual_keyboard_get_height);
ClassDB::bind_method(D_METHOD("has_hardware_keyboard"), &DisplayServer::has_hardware_keyboard);
ClassDB::bind_method(D_METHOD("cursor_set_shape", "shape"), &DisplayServer::cursor_set_shape);
ClassDB::bind_method(D_METHOD("cursor_get_shape"), &DisplayServer::cursor_get_shape);
ClassDB::bind_method(D_METHOD("cursor_set_custom_image", "cursor", "shape", "hotspot"), &DisplayServer::cursor_set_custom_image, DEFVAL(CURSOR_ARROW), DEFVAL(Vector2()));
@ -979,6 +1043,8 @@ void DisplayServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("file_dialog_show", "title", "current_directory", "filename", "show_hidden", "mode", "filters", "callback"), &DisplayServer::file_dialog_show);
ClassDB::bind_method(D_METHOD("file_dialog_with_options_show", "title", "current_directory", "root", "filename", "show_hidden", "mode", "filters", "options", "callback"), &DisplayServer::file_dialog_with_options_show);
ClassDB::bind_method(D_METHOD("beep"), &DisplayServer::beep);
ClassDB::bind_method(D_METHOD("keyboard_get_layout_count"), &DisplayServer::keyboard_get_layout_count);
ClassDB::bind_method(D_METHOD("keyboard_get_current_layout"), &DisplayServer::keyboard_get_current_layout);
ClassDB::bind_method(D_METHOD("keyboard_set_current_layout", "index"), &DisplayServer::keyboard_set_current_layout);
@ -987,6 +1053,8 @@ void DisplayServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("keyboard_get_keycode_from_physical", "keycode"), &DisplayServer::keyboard_get_keycode_from_physical);
ClassDB::bind_method(D_METHOD("keyboard_get_label_from_physical", "keycode"), &DisplayServer::keyboard_get_label_from_physical);
ClassDB::bind_method(D_METHOD("show_emoji_and_symbol_picker"), &DisplayServer::show_emoji_and_symbol_picker);
ClassDB::bind_method(D_METHOD("process_events"), &DisplayServer::process_events);
ClassDB::bind_method(D_METHOD("force_process_and_drop_events"), &DisplayServer::force_process_and_drop_events);
@ -1039,12 +1107,19 @@ void DisplayServer::_bind_methods() {
BIND_ENUM_CONSTANT(FEATURE_NATIVE_HELP);
BIND_ENUM_CONSTANT(FEATURE_NATIVE_DIALOG_INPUT);
BIND_ENUM_CONSTANT(FEATURE_NATIVE_DIALOG_FILE);
BIND_ENUM_CONSTANT(FEATURE_NATIVE_DIALOG_FILE_EXTRA);
BIND_ENUM_CONSTANT(FEATURE_WINDOW_DRAG);
BIND_ENUM_CONSTANT(FEATURE_SCREEN_EXCLUDE_FROM_CAPTURE);
BIND_ENUM_CONSTANT(FEATURE_WINDOW_EMBEDDING);
BIND_ENUM_CONSTANT(FEATURE_NATIVE_DIALOG_FILE_MIME);
BIND_ENUM_CONSTANT(FEATURE_EMOJI_AND_SYMBOL_PICKER);
BIND_ENUM_CONSTANT(MOUSE_MODE_VISIBLE);
BIND_ENUM_CONSTANT(MOUSE_MODE_HIDDEN);
BIND_ENUM_CONSTANT(MOUSE_MODE_CAPTURED);
BIND_ENUM_CONSTANT(MOUSE_MODE_CONFINED);
BIND_ENUM_CONSTANT(MOUSE_MODE_CONFINED_HIDDEN);
BIND_ENUM_CONSTANT(MOUSE_MODE_MAX);
BIND_CONSTANT(SCREEN_WITH_MOUSE_FOCUS);
BIND_CONSTANT(SCREEN_WITH_KEYBOARD_FOCUS);
@ -1111,6 +1186,8 @@ void DisplayServer::_bind_methods() {
BIND_ENUM_CONSTANT(WINDOW_FLAG_POPUP);
BIND_ENUM_CONSTANT(WINDOW_FLAG_EXTEND_TO_TITLE);
BIND_ENUM_CONSTANT(WINDOW_FLAG_MOUSE_PASSTHROUGH);
BIND_ENUM_CONSTANT(WINDOW_FLAG_SHARP_CORNERS);
BIND_ENUM_CONSTANT(WINDOW_FLAG_EXCLUDE_FROM_CAPTURE);
BIND_ENUM_CONSTANT(WINDOW_FLAG_MAX);
BIND_ENUM_CONSTANT(WINDOW_EVENT_MOUSE_ENTER);
@ -1122,6 +1199,16 @@ void DisplayServer::_bind_methods() {
BIND_ENUM_CONSTANT(WINDOW_EVENT_DPI_CHANGE);
BIND_ENUM_CONSTANT(WINDOW_EVENT_TITLEBAR_CHANGE);
BIND_ENUM_CONSTANT(WINDOW_EDGE_TOP_LEFT);
BIND_ENUM_CONSTANT(WINDOW_EDGE_TOP);
BIND_ENUM_CONSTANT(WINDOW_EDGE_TOP_RIGHT);
BIND_ENUM_CONSTANT(WINDOW_EDGE_LEFT);
BIND_ENUM_CONSTANT(WINDOW_EDGE_RIGHT);
BIND_ENUM_CONSTANT(WINDOW_EDGE_BOTTOM_LEFT);
BIND_ENUM_CONSTANT(WINDOW_EDGE_BOTTOM);
BIND_ENUM_CONSTANT(WINDOW_EDGE_BOTTOM_RIGHT);
BIND_ENUM_CONSTANT(WINDOW_EDGE_MAX);
BIND_ENUM_CONSTANT(VSYNC_DISABLED);
BIND_ENUM_CONSTANT(VSYNC_ENABLED);
BIND_ENUM_CONSTANT(VSYNC_ADAPTIVE);
@ -1131,6 +1218,8 @@ void DisplayServer::_bind_methods() {
BIND_ENUM_CONSTANT(WINDOW_HANDLE);
BIND_ENUM_CONSTANT(WINDOW_VIEW);
BIND_ENUM_CONSTANT(OPENGL_CONTEXT);
BIND_ENUM_CONSTANT(EGL_DISPLAY);
BIND_ENUM_CONSTANT(EGL_CONFIG);
BIND_ENUM_CONSTANT(TTS_UTTERANCE_STARTED);
BIND_ENUM_CONSTANT(TTS_UTTERANCE_ENDED);
@ -1186,9 +1275,9 @@ Vector<String> DisplayServer::get_create_function_rendering_drivers(int p_index)
return server_create_functions[p_index].get_rendering_drivers_function();
}
DisplayServer *DisplayServer::create(int p_index, const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, Context p_context, Error &r_error) {
DisplayServer *DisplayServer::create(int p_index, const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, Context p_context, int64_t p_parent_window, Error &r_error) {
ERR_FAIL_INDEX_V(p_index, server_create_count, nullptr);
return server_create_functions[p_index].create_function(p_rendering_driver, p_mode, p_vsync_mode, p_flags, p_position, p_resolution, p_screen, p_context, r_error);
return server_create_functions[p_index].create_function(p_rendering_driver, p_mode, p_vsync_mode, p_flags, p_position, p_resolution, p_screen, p_context, p_parent_window, r_error);
}
void DisplayServer::_input_set_mouse_mode(Input::MouseMode p_mode) {
@ -1199,6 +1288,22 @@ Input::MouseMode DisplayServer::_input_get_mouse_mode() {
return Input::MouseMode(singleton->mouse_get_mode());
}
void DisplayServer::_input_set_mouse_mode_override(Input::MouseMode p_mode) {
singleton->mouse_set_mode_override(MouseMode(p_mode));
}
Input::MouseMode DisplayServer::_input_get_mouse_mode_override() {
return Input::MouseMode(singleton->mouse_get_mode_override());
}
void DisplayServer::_input_set_mouse_mode_override_enabled(bool p_enabled) {
singleton->mouse_set_mode_override_enabled(p_enabled);
}
bool DisplayServer::_input_is_mouse_mode_override_enabled() {
return singleton->mouse_is_mode_override_enabled();
}
void DisplayServer::_input_warp(const Vector2 &p_to_pos) {
singleton->warp_mouse(p_to_pos);
}
@ -1207,14 +1312,83 @@ Input::CursorShape DisplayServer::_input_get_current_cursor_shape() {
return (Input::CursorShape)singleton->cursor_get_shape();
}
void DisplayServer::_input_set_custom_mouse_cursor_func(const Ref<Resource> &p_image, Input::CursorShape p_shape, const Vector2 &p_hostspot) {
singleton->cursor_set_custom_image(p_image, (CursorShape)p_shape, p_hostspot);
void DisplayServer::_input_set_custom_mouse_cursor_func(const Ref<Resource> &p_image, Input::CursorShape p_shape, const Vector2 &p_hotspot) {
singleton->cursor_set_custom_image(p_image, (CursorShape)p_shape, p_hotspot);
}
bool DisplayServer::can_create_rendering_device() {
if (get_singleton()->get_name() == "headless") {
return false;
}
#if defined(RD_ENABLED)
RenderingDevice *device = RenderingDevice::get_singleton();
if (device) {
return true;
}
if (created_rendering_device == RenderingDeviceCreationStatus::SUCCESS) {
return true;
} else if (created_rendering_device == RenderingDeviceCreationStatus::FAILURE) {
return false;
}
Error err;
RenderingContextDriver *rcd = nullptr;
#if defined(VULKAN_ENABLED)
rcd = memnew(RenderingContextDriverVulkan);
#endif
#ifdef D3D12_ENABLED
if (rcd == nullptr) {
rcd = memnew(RenderingContextDriverD3D12);
}
#endif
#ifdef METAL_ENABLED
if (rcd == nullptr) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability"
// Eliminate "RenderingContextDriverMetal is only available on iOS 14.0 or newer".
rcd = memnew(RenderingContextDriverMetal);
#pragma clang diagnostic pop
}
#endif
if (rcd != nullptr) {
err = rcd->initialize();
if (err == OK) {
RenderingDevice *rd = memnew(RenderingDevice);
err = rd->initialize(rcd);
memdelete(rd);
rd = nullptr;
if (err == OK) {
// Creating a RenderingDevice is quite slow.
// Cache the result for future usage, so that it's much faster on subsequent calls.
created_rendering_device = RenderingDeviceCreationStatus::SUCCESS;
memdelete(rcd);
rcd = nullptr;
return true;
} else {
created_rendering_device = RenderingDeviceCreationStatus::FAILURE;
}
}
memdelete(rcd);
rcd = nullptr;
}
#endif // RD_ENABLED
return false;
}
DisplayServer::DisplayServer() {
singleton = this;
Input::set_mouse_mode_func = _input_set_mouse_mode;
Input::get_mouse_mode_func = _input_get_mouse_mode;
Input::set_mouse_mode_override_func = _input_set_mouse_mode_override;
Input::get_mouse_mode_override_func = _input_get_mouse_mode_override;
Input::set_mouse_mode_override_enabled_func = _input_set_mouse_mode_override_enabled;
Input::is_mouse_mode_override_enabled_func = _input_is_mouse_mode_override_enabled;
Input::warp_mouse_func = _input_warp;
Input::get_current_cursor_shape_func = _input_get_current_cursor_shape;
Input::set_custom_mouse_cursor_func = _input_set_custom_mouse_cursor_func;