diff options
Diffstat (limited to 'scene/main')
-rw-r--r-- | scene/main/multiplayer_api.cpp | 16 | ||||
-rw-r--r-- | scene/main/multiplayer_api.h | 8 | ||||
-rw-r--r-- | scene/main/multiplayer_peer.cpp | 2 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 19 | ||||
-rw-r--r-- | scene/main/viewport.h | 3 | ||||
-rw-r--r-- | scene/main/window.cpp | 1 |
6 files changed, 35 insertions, 14 deletions
diff --git a/scene/main/multiplayer_api.cpp b/scene/main/multiplayer_api.cpp index c54e61580f..950eb2809c 100644 --- a/scene/main/multiplayer_api.cpp +++ b/scene/main/multiplayer_api.cpp @@ -329,9 +329,9 @@ void MultiplayerAPI::_bind_methods() { /// MultiplayerAPIExtension Error MultiplayerAPIExtension::poll() { - int err = OK; + Error err = OK; GDVIRTUAL_CALL(_poll, err); - return (Error)err; + return err; } void MultiplayerAPIExtension::set_multiplayer_peer(const Ref<MultiplayerPeer> &p_peer) { @@ -364,9 +364,9 @@ Error MultiplayerAPIExtension::rpcp(Object *p_obj, int p_peer_id, const StringNa for (int i = 0; i < p_argcount; i++) { args.push_back(*p_arg[i]); } - int ret = FAILED; + Error ret = FAILED; GDVIRTUAL_CALL(_rpc, p_peer_id, p_obj, p_method, args, ret); - return (Error)ret; + return ret; } int MultiplayerAPIExtension::get_remote_sender_id() { @@ -376,15 +376,15 @@ int MultiplayerAPIExtension::get_remote_sender_id() { } Error MultiplayerAPIExtension::object_configuration_add(Object *p_object, Variant p_config) { - int err = ERR_UNAVAILABLE; + Error err = ERR_UNAVAILABLE; GDVIRTUAL_CALL(_object_configuration_add, p_object, p_config, err); - return (Error)err; + return err; } Error MultiplayerAPIExtension::object_configuration_remove(Object *p_object, Variant p_config) { - int err = ERR_UNAVAILABLE; + Error err = ERR_UNAVAILABLE; GDVIRTUAL_CALL(_object_configuration_remove, p_object, p_config, err); - return (Error)err; + return err; } void MultiplayerAPIExtension::_bind_methods() { diff --git a/scene/main/multiplayer_api.h b/scene/main/multiplayer_api.h index 0b107ee50b..a578e6f2f1 100644 --- a/scene/main/multiplayer_api.h +++ b/scene/main/multiplayer_api.h @@ -101,15 +101,15 @@ public: virtual Error object_configuration_remove(Object *p_object, Variant p_config) override; // Extensions - GDVIRTUAL0R(int, _poll); + GDVIRTUAL0R(Error, _poll); GDVIRTUAL1(_set_multiplayer_peer, Ref<MultiplayerPeer>); GDVIRTUAL0R(Ref<MultiplayerPeer>, _get_multiplayer_peer); GDVIRTUAL0RC(int, _get_unique_id); GDVIRTUAL0RC(PackedInt32Array, _get_peer_ids); - GDVIRTUAL4R(int, _rpc, int, Object *, StringName, Array); + GDVIRTUAL4R(Error, _rpc, int, Object *, StringName, Array); GDVIRTUAL0RC(int, _get_remote_sender_id); - GDVIRTUAL2R(int, _object_configuration_add, Object *, Variant); - GDVIRTUAL2R(int, _object_configuration_remove, Object *, Variant); + GDVIRTUAL2R(Error, _object_configuration_add, Object *, Variant); + GDVIRTUAL2R(Error, _object_configuration_remove, Object *, Variant); }; #endif // MULTIPLAYER_API_H diff --git a/scene/main/multiplayer_peer.cpp b/scene/main/multiplayer_peer.cpp index 83555966d7..f3e56a1455 100644 --- a/scene/main/multiplayer_peer.cpp +++ b/scene/main/multiplayer_peer.cpp @@ -163,7 +163,7 @@ Error MultiplayerPeerExtension::put_packet(const uint8_t *p_buffer, int p_buffer if (!GDVIRTUAL_CALL(_put_packet_script, a, err)) { return FAILED; } - return (Error)err; + return err; } WARN_PRINT_ONCE("MultiplayerPeerExtension::_put_packet_native is unimplemented!"); return FAILED; diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index b6bcbe04a3..fe82fed2f7 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -4114,9 +4114,26 @@ Viewport::~Viewport() { ///////////////////////////////// void SubViewport::set_size(const Size2i &p_size) { - _set_size(p_size, _get_size_2d_override(), Rect2i(), _stretch_transform(), true); + _internal_set_size(p_size); +} +void SubViewport::set_size_force(const Size2i &p_size) { + // Use only for setting the size from the parent SubViewportContainer with enabled stretch mode. + // Don't expose function to scripting. + _internal_set_size(p_size, true); +} + +void SubViewport::_internal_set_size(const Size2i &p_size, bool p_force) { SubViewportContainer *c = Object::cast_to<SubViewportContainer>(get_parent()); + if (!p_force && c && c->is_stretch_enabled()) { +#ifdef DEBUG_ENABLED + WARN_PRINT("Can't change the size of a `SubViewport` with a `SubViewportContainer` parent that has `stretch` enabled. Set `SubViewportContainer.stretch` to `false` to allow changing the size manually."); +#endif // DEBUG_ENABLED + return; + } + + _set_size(p_size, _get_size_2d_override(), Rect2i(), _stretch_transform(), true); + if (c) { c->update_minimum_size(); } diff --git a/scene/main/viewport.h b/scene/main/viewport.h index e081013fde..2a4ddc422f 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -754,6 +754,8 @@ private: ClearMode clear_mode = CLEAR_MODE_ALWAYS; bool size_2d_override_stretch = false; + void _internal_set_size(const Size2i &p_size, bool p_force = false); + protected: static void _bind_methods(); virtual DisplayServer::WindowID get_window_id() const override; @@ -763,6 +765,7 @@ protected: public: void set_size(const Size2i &p_size); Size2i get_size() const; + void set_size_force(const Size2i &p_size); void set_size_2d_override(const Size2i &p_size); Size2i get_size_2d_override() const; diff --git a/scene/main/window.cpp b/scene/main/window.cpp index b1f2bc65dc..5fd39dfc68 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -2344,6 +2344,7 @@ void Window::_bind_methods() { ADD_SIGNAL(MethodInfo("visibility_changed")); ADD_SIGNAL(MethodInfo("about_to_popup")); ADD_SIGNAL(MethodInfo("theme_changed")); + ADD_SIGNAL(MethodInfo("dpi_changed")); ADD_SIGNAL(MethodInfo("titlebar_changed")); BIND_CONSTANT(NOTIFICATION_VISIBILITY_CHANGED); |