Ver código fonte

Add a node warning using NinePatchRect's Tile or Tile Fit modes in GLES2

jmb462 4 anos atrás
pai
commit
a9d0baa4f4
2 arquivos alterados com 19 adições e 0 exclusões
  1. 17 0
      scene/gui/nine_patch_rect.cpp
  2. 2 0
      scene/gui/nine_patch_rect.h

+ 17 - 0
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;

+ 2 - 0
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();
 };