From a9d0baa4f4a1d21bf3212e94c8f6c6745170250c Mon Sep 17 00:00:00 2001 From: jmb462 Date: Wed, 15 Sep 2021 23:15:25 +0200 Subject: [PATCH] Add a node warning using NinePatchRect's Tile or Tile Fit modes in GLES2 --- scene/gui/nine_patch_rect.cpp | 17 +++++++++++++++++ scene/gui/nine_patch_rect.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/scene/gui/nine_patch_rect.cpp b/scene/gui/nine_patch_rect.cpp index 61aba83433a..cf374fec8a9 100644 --- a/scene/gui/nine_patch_rect.cpp +++ b/scene/gui/nine_patch_rect.cpp @@ -156,6 +156,7 @@ bool NinePatchRect::is_draw_center_enabled() const { void NinePatchRect::set_h_axis_stretch_mode(AxisStretchMode p_mode) { axis_h = p_mode; + update_configuration_warning(); update(); } @@ -165,6 +166,7 @@ NinePatchRect::AxisStretchMode NinePatchRect::get_h_axis_stretch_mode() const { void NinePatchRect::set_v_axis_stretch_mode(AxisStretchMode p_mode) { axis_v = p_mode; + update_configuration_warning(); update(); } @@ -172,6 +174,21 @@ NinePatchRect::AxisStretchMode NinePatchRect::get_v_axis_stretch_mode() const { return axis_v; } +String NinePatchRect::get_configuration_warning() const { + String warning = Control::get_configuration_warning(); + + if (String(GLOBAL_GET("rendering/quality/driver/driver_name")) == "GLES2") { + if (axis_v > AXIS_STRETCH_MODE_STRETCH || axis_h > AXIS_STRETCH_MODE_STRETCH) { + if (!warning.empty()) { + warning += "\n\n"; + } + warning += TTR("The Tile and Tile Fit options for Axis Stretch properties are only effective when using the GLES3 rendering backend.\nThe GLES2 backend is currently in use, so these modes will act like Stretch instead."); + } + } + + return warning; +} + NinePatchRect::NinePatchRect() { margin[MARGIN_LEFT] = 0; margin[MARGIN_RIGHT] = 0; diff --git a/scene/gui/nine_patch_rect.h b/scene/gui/nine_patch_rect.h index 7e07b0d2244..8dd0771ade0 100644 --- a/scene/gui/nine_patch_rect.h +++ b/scene/gui/nine_patch_rect.h @@ -74,6 +74,8 @@ public: void set_v_axis_stretch_mode(AxisStretchMode p_mode); AxisStretchMode get_v_axis_stretch_mode() const; + String get_configuration_warning() const; + NinePatchRect(); ~NinePatchRect(); };