summaryrefslogtreecommitdiff
path: root/addons/escoria-core/testing
diff options
context:
space:
mode:
Diffstat (limited to 'addons/escoria-core/testing')
-rw-r--r--addons/escoria-core/testing/NotoSans-Regular.ttfbin0 -> 313144 bytes
-rw-r--r--addons/escoria-core/testing/NotoSans-Regular.ttf.import36
-rw-r--r--addons/escoria-core/testing/README8
-rw-r--r--addons/escoria-core/testing/player_angles_finder.gd231
-rw-r--r--addons/escoria-core/testing/player_angles_finder.gd.uid1
-rw-r--r--addons/escoria-core/testing/player_angles_finder.tscn137
-rw-r--r--addons/escoria-core/testing/rtl_screen_offset_testing.gd174
-rw-r--r--addons/escoria-core/testing/rtl_screen_offset_testing.gd.uid1
-rw-r--r--addons/escoria-core/testing/rtl_screen_offset_testing.tscn73
9 files changed, 661 insertions, 0 deletions
diff --git a/addons/escoria-core/testing/NotoSans-Regular.ttf b/addons/escoria-core/testing/NotoSans-Regular.ttf
new file mode 100644
index 0000000..0a01a06
--- /dev/null
+++ b/addons/escoria-core/testing/NotoSans-Regular.ttf
Binary files differ
diff --git a/addons/escoria-core/testing/NotoSans-Regular.ttf.import b/addons/escoria-core/testing/NotoSans-Regular.ttf.import
new file mode 100644
index 0000000..2c5fd00
--- /dev/null
+++ b/addons/escoria-core/testing/NotoSans-Regular.ttf.import
@@ -0,0 +1,36 @@
+[remap]
+
+importer="font_data_dynamic"
+type="FontFile"
+uid="uid://el1rp51n7kpd"
+path="res://.godot/imported/NotoSans-Regular.ttf-3d2825f96eb34e3bdf9d923048c8a54f.fontdata"
+
+[deps]
+
+source_file="res://addons/escoria-core/testing/NotoSans-Regular.ttf"
+dest_files=["res://.godot/imported/NotoSans-Regular.ttf-3d2825f96eb34e3bdf9d923048c8a54f.fontdata"]
+
+[params]
+
+Rendering=null
+antialiasing=1
+generate_mipmaps=false
+disable_embedded_bitmaps=true
+multichannel_signed_distance_field=false
+msdf_pixel_range=8
+msdf_size=48
+allow_system_fallback=true
+force_autohinter=false
+modulate_color_glyphs=false
+hinting=1
+subpixel_positioning=4
+keep_rounding_remainders=true
+oversampling=0.0
+Fallbacks=null
+fallbacks=[]
+Compress=null
+compress=true
+preload=[]
+language_support={}
+script_support={}
+opentype_features={}
diff --git a/addons/escoria-core/testing/README b/addons/escoria-core/testing/README
new file mode 100644
index 0000000..b81e0cb
--- /dev/null
+++ b/addons/escoria-core/testing/README
@@ -0,0 +1,8 @@
+In this folder, you can find various scenes and tools to test some of the scenes of your actual game project.
+
+These scenes are not intended to be shipped with your game, you may want to use them only for testing purposes, such as:
+
+- RichTextLabels screen clamping (rtl_screen_clamping.tscn)
+ This scene helps you test the RichTextLabels used in your game, such as labels used when pointing an item or NPC or dialogs.
+ To use this testing scene, simply add your actual label scene as a child of the root node and set the path to this node in it.
+ You can then run the scene, move your mouse around the edges of the screen and see if the label reacts properly.
diff --git a/addons/escoria-core/testing/player_angles_finder.gd b/addons/escoria-core/testing/player_angles_finder.gd
new file mode 100644
index 0000000..e47b83c
--- /dev/null
+++ b/addons/escoria-core/testing/player_angles_finder.gd
@@ -0,0 +1,231 @@
+extends Node2D
+
+# This scenes purpose is to help determining the angles between X and Y axis
+# when clicking somewhere on the screen.
+# Let us consider that player position is always 0,0.
+# Clicking right above his head is angle 0.
+# Clicking on the right is angle 90.
+# Clicking under his feet is angle 180.
+# etc.
+
+var number_of_directions: int
+var angle_horizontal_axes: float
+var angle_vertical_axes: float
+var angle_diagonal_axes: float
+const POLYGON_DISTANCE = 400
+
+enum Directions {
+ NORTH, # 0
+ NORTHEAST, # 1
+ EAST, # 2
+ SOUTHEAST, # 3
+ SOUTH, # 4
+ SOUTHWEST, # 5
+ WEST, # 6
+ NORTHWEST # 7
+}
+
+const starting_angles = [
+ 0, # 0 NORTH
+ PI/4, # 1 NORTHEAST
+ PI/2, # 2 EAST
+ 3*PI/4, # 3 SOUTHEAST
+ PI, # 4 SOUTH
+ 5*PI/4, # 5 SOUTHWEST
+ 3*PI/2, # 6 WEST
+ 7*PI/4, # 7 NORTHWEST
+]
+
+var colors = [
+ Color("red"), # 0 NORTH
+ Color("green"), # 1 NORTHEAST
+ Color("blue"), # 2 EAST
+ Color("black"), # 3 SOUTHEAST
+ Color("yellow"), # 4 SOUTH
+ Color("cyan"), # 5 SOUTHWEST
+ Color("white"), # 6 WEST
+ Color("purple") # 7 NORTHWEST
+]
+
+var result_angles = []
+
+#onready var result_angles_anim = {
+# "angle_offset_rad": PI/2,
+# Directions.NORTH: {
+# "direction_base_angle_rad": 0,
+# "angle_start_deg": 0,
+# "angle_area_deg": 0,
+# "animations": {}
+# },
+# Directions.NORTHEAST: {
+# "direction_base_angle_rad": PI/4,
+# "angle_start_deg": 0,
+# "angle_area_deg": 0,
+# "animation": ""
+# },
+# Directions.EAST: {
+# "direction_base_angle_rad": PI/2,
+# "angle_start_deg": 0,
+# "angle_area_deg": 0,
+# "animation": ""
+# },
+# Directions.SOUTHEAST: {
+# "direction_base_angle_rad": 3*PI/4,
+# "angle_start_deg": 0,
+# "angle_area_deg": 0,
+# "animation": ""
+# },
+# Directions.SOUTH: {
+# "direction_base_angle_rad": PI,
+# "angle_start_deg": 0,
+# "angle_area_deg": 0,
+# "animation": ""
+#
+# },
+# Directions.SOUTHWEST: {
+# "direction_base_angle_rad": 5*PI/4,
+# "angle_start_deg": 0,
+# "angle_area_deg": 0,
+# "animation": ""
+# },
+# Directions.WEST: {
+# "direction_base_angle_rad": 3*PI/2,
+# "angle_start_deg": 0,
+# "angle_area_deg": 0,
+# "animation": ""
+# },
+# Directions.NORTHWEST: {
+# "direction_base_angle_rad": 7*PI/4,
+# "angle_start_deg": 0,
+# "angle_area_deg": 0,
+# "animation": ""
+# }
+# }
+
+
+
+func _ready():
+ # Find player animations
+ $player_animations.add_item("")
+ for anim_name in $player.get_animation_player().get_animations():
+ $player_animations.add_item(anim_name)
+
+ # Set initial angles
+ var initial_angle: float = 360.0 / 8.0
+ $VBoxContainer/angle_x/angle_horiz.text = str(40)
+ $VBoxContainer/angle_y/angle_vert.text = str(40)
+ $VBoxContainer/angle_diag/angle_diag.text = str(50)
+ angle_horizontal_axes = 40
+ angle_vertical_axes = 40
+ angle_diagonal_axes = 50
+
+ calculate_areas()
+
+
+func _on_number_of_directions_text_changed(new_text: String):
+ if !new_text.is_valid_int():
+ return
+ number_of_directions = int(new_text)
+ calculate_areas(number_of_directions)
+
+
+func clear_areas_node():
+ for n in $areas.get_children():
+ n.queue_free()
+
+
+func calculate_areas(nb_directions: int = 8):
+ clear_areas_node()
+ var angles = []
+ for i in range(nb_directions):
+ var angle_area: float = 0.0
+ var start_angle: float = 0.0
+ # MANUAL
+ match i:
+ Directions.EAST,Directions.WEST:
+ angle_area = deg_to_rad(angle_horizontal_axes)
+ Directions.NORTH,Directions.SOUTH:
+ angle_area = deg_to_rad(angle_vertical_axes)
+ Directions.NORTHEAST,Directions.NORTHWEST,Directions.SOUTHEAST,Directions.SOUTHWEST:
+ angle_area = deg_to_rad(angle_diagonal_axes)
+
+ # Since angles start from EAST, offset by -PI/2 (= -90°) to start on up direction
+ # Then minus angle_area/2 to align on direction
+ start_angle = PI/2 + angle_area / 2
+
+ var angle_start = starting_angles[i] - start_angle
+ var angle_end = angle_start + angle_area
+ angles.push_back([angle_start, angle_end])
+
+ result_angles.push_back([clamp360(rad_to_deg(angle_start) + rad_to_deg(PI/2)),clamp360(rad_to_deg(angle_area))])
+
+ $VBoxContainer/VBoxContainer/angles/angle_array.text = str(result_angles)
+ construct_scene_nodes(angles)
+
+
+func construct_scene_nodes(angles):
+ var areas_nodes = []
+ for i in angles.size():
+ var polygon_node = Polygon2D.new()
+ polygon_node.color = colors[i]
+ var area_node = Area2D.new()
+ area_node.name = Directions.keys()[i]
+ area_node.connect("input_event", Callable(self, "_on_area_click").bind(area_node.name))
+ polygon_node.add_child(area_node)
+
+ var collision = CollisionShape2D.new()
+ var collision_shape = ConvexPolygonShape2D.new()
+
+ var p_points = []
+ p_points.push_back($player.position)
+ p_points.push_back(POLYGON_DISTANCE * Vector2.from_angle(angles[i][0]) + $player.position)
+ p_points.push_back(POLYGON_DISTANCE * Vector2.from_angle(angles[i][1]) + $player.position)
+ polygon_node.polygon = p_points
+ collision_shape.points = p_points
+ collision.set_shape(collision_shape)
+ area_node.add_child(collision)
+
+ $areas.add_child(polygon_node)
+
+
+func _on_angle_horiz_text_changed(new_text: String):
+ if !new_text.is_valid_float():
+ return
+ angle_horizontal_axes = float(new_text)
+# result_angles_anim.Directions.EAST.angle_area_deg = clamp360(angle_horizontal_axes)
+# result_angles_anim.Directions.WEST.angle_area_deg = clamp360(angle_horizontal_axes)
+ calculate_areas()
+
+
+func _on_angle_vert_text_changed(new_text: String):
+ if !new_text.is_valid_float():
+ return
+ angle_vertical_axes = float(new_text)
+# result_angles_anim.Directions.NORTH.angle_area_deg = clamp360(angle_vertical_axes)
+# result_angles_anim.Directions.SOUTH.angle_area_deg = clamp360(angle_vertical_axes)
+ calculate_areas()
+
+
+func _on_angle_diag_text_changed(new_text: String):
+ if !new_text.is_valid_float():
+ return
+ angle_diagonal_axes = float(new_text)
+# result_angles_anim.Directions.NORTHEAST.angle_area_deg = clamp360(angle_diagonal_axes)
+# result_angles_anim.Directions.SOUTHEAST.angle_area_deg = clamp360(angle_diagonal_axes)
+# result_angles_anim.Directions.NORTHWEST.angle_area_deg = clamp360(angle_diagonal_axes)
+# result_angles_anim.Directions.SOUTHWEST.angle_area_deg = clamp360(angle_diagonal_axes)
+ calculate_areas()
+
+
+func _on_area_click(viewport: Object, event: InputEvent, shape_idx: int, area_name: String):
+ if event is InputEventMouseButton and event.is_pressed():
+ pass
+
+func clamp360(angle: float):
+ if angle < 0.0:
+ while angle < 0.0:
+ angle += 360.0
+ elif angle >= 360.0:
+ while angle >= 360.0:
+ angle -= 360.0
+ return angle
diff --git a/addons/escoria-core/testing/player_angles_finder.gd.uid b/addons/escoria-core/testing/player_angles_finder.gd.uid
new file mode 100644
index 0000000..cef4f64
--- /dev/null
+++ b/addons/escoria-core/testing/player_angles_finder.gd.uid
@@ -0,0 +1 @@
+uid://grwlokhruew6
diff --git a/addons/escoria-core/testing/player_angles_finder.tscn b/addons/escoria-core/testing/player_angles_finder.tscn
new file mode 100644
index 0000000..3817db0
--- /dev/null
+++ b/addons/escoria-core/testing/player_angles_finder.tscn
@@ -0,0 +1,137 @@
+[gd_scene load_steps=3 format=3 uid="uid://cj02p2rfv12br"]
+
+[ext_resource type="PackedScene" uid="uid://chf3qovs1q8kr" path="res://game/characters/mark/mark.tscn" id="1"]
+[ext_resource type="Script" uid="uid://grwlokhruew6" path="res://addons/escoria-core/testing/player_angles_finder.gd" id="2"]
+
+[node name="player_angles_finder" type="Node2D"]
+script = ExtResource("2")
+
+[node name="areas" type="Node2D" parent="."]
+
+[node name="player" parent="." instance=ExtResource("1")]
+position = Vector2(640, 480)
+dialog_position_node = NodePath("../../player_angles_finder/player/dialog_position")
+
+[node name="x_axis" type="Line2D" parent="."]
+points = PackedVector2Array(-10, 480, 1300, 480)
+width = 2.0
+default_color = Color(0.980392, 0.00392157, 0.00392157, 1)
+
+[node name="y_axis" type="Line2D" parent="."]
+points = PackedVector2Array(640, -20, 640, 810)
+width = 2.0
+default_color = Color(0.156863, 0.0117647, 0.984314, 1)
+
+[node name="three" type="Node2D" parent="."]
+visible = false
+
+[node name="Line2D" type="Line2D" parent="three"]
+points = PackedVector2Array(160, 0, 1120, 960)
+width = 2.0
+default_color = Color(1, 1, 1, 1)
+
+[node name="Line2D2" type="Line2D" parent="three"]
+points = PackedVector2Array(160, 960, 1120, 0)
+width = 2.0
+default_color = Color(1, 1, 1, 1)
+
+[node name="six" type="Node2D" parent="."]
+visible = false
+
+[node name="Line2D" type="Line2D" parent="six"]
+points = PackedVector2Array(0, 210, 640, 480)
+width = 2.0
+default_color = Color(1, 1, 1, 1)
+
+[node name="Line2D4" type="Line2D" parent="six"]
+points = PackedVector2Array(320, 0, 640, 480)
+width = 2.0
+default_color = Color(1, 1, 1, 1)
+
+[node name="Line2D2" type="Line2D" parent="six"]
+points = PackedVector2Array(640, 480, 1280, 210)
+width = 2.0
+default_color = Color(1, 1, 1, 1)
+
+[node name="Line2D3" type="Line2D" parent="six"]
+points = PackedVector2Array(640, 480, 960, 0)
+width = 2.0
+default_color = Color(1, 1, 1, 1)
+
+[node name="VBoxContainer" type="VBoxContainer" parent="."]
+offset_right = 370.0
+offset_bottom = 170.0
+
+[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
+visible = false
+layout_mode = 2
+
+[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer"]
+layout_mode = 2
+text = "Number of directions"
+
+[node name="number_of_directions" type="LineEdit" parent="VBoxContainer/HBoxContainer"]
+layout_mode = 2
+
+[node name="angle_x" type="HBoxContainer" parent="VBoxContainer"]
+layout_mode = 2
+
+[node name="Label" type="Label" parent="VBoxContainer/angle_x"]
+layout_mode = 2
+text = "Angle on horizontal axis (X)"
+
+[node name="angle_horiz" type="LineEdit" parent="VBoxContainer/angle_x"]
+layout_mode = 2
+
+[node name="angle_y" type="HBoxContainer" parent="VBoxContainer"]
+layout_mode = 2
+
+[node name="Label" type="Label" parent="VBoxContainer/angle_y"]
+layout_mode = 2
+text = "Angle on vertical axis (Y)"
+
+[node name="angle_vert" type="LineEdit" parent="VBoxContainer/angle_y"]
+layout_mode = 2
+
+[node name="angle_diag" type="HBoxContainer" parent="VBoxContainer"]
+layout_mode = 2
+
+[node name="Label" type="Label" parent="VBoxContainer/angle_diag"]
+layout_mode = 2
+text = "Angle on diagonal axes"
+
+[node name="angle_diag" type="LineEdit" parent="VBoxContainer/angle_diag"]
+layout_mode = 2
+
+[node name="HSeparator" type="HSeparator" parent="VBoxContainer"]
+layout_mode = 2
+
+[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer"]
+layout_mode = 2
+size_flags_vertical = 3
+
+[node name="angles" type="HBoxContainer" parent="VBoxContainer/VBoxContainer"]
+layout_mode = 2
+size_flags_vertical = 3
+
+[node name="Label" type="Label" parent="VBoxContainer/VBoxContainer/angles"]
+layout_mode = 2
+text = "Angles array"
+
+[node name="angle_array" type="TextEdit" parent="VBoxContainer/VBoxContainer/angles"]
+layout_mode = 2
+size_flags_horizontal = 3
+size_flags_vertical = 3
+
+[node name="player_animations" type="OptionButton" parent="."]
+visible = false
+offset_left = 470.0
+offset_top = 10.0
+offset_right = 638.0
+offset_bottom = 33.0
+
+[connection signal="text_changed" from="VBoxContainer/HBoxContainer/number_of_directions" to="." method="_on_number_of_directions_text_changed"]
+[connection signal="text_changed" from="VBoxContainer/angle_x/angle_horiz" to="." method="_on_angle_horiz_text_changed"]
+[connection signal="text_changed" from="VBoxContainer/angle_y/angle_vert" to="." method="_on_angle_vert_text_changed"]
+[connection signal="text_changed" from="VBoxContainer/angle_diag/angle_diag" to="." method="_on_angle_diag_text_changed"]
+[connection signal="text_changed" from="VBoxContainer/VBoxContainer/angles/angle_array" to="." method="_on_angle_diag_text_changed"]
diff --git a/addons/escoria-core/testing/rtl_screen_offset_testing.gd b/addons/escoria-core/testing/rtl_screen_offset_testing.gd
new file mode 100644
index 0000000..4083bbe
--- /dev/null
+++ b/addons/escoria-core/testing/rtl_screen_offset_testing.gd
@@ -0,0 +1,174 @@
+extends Control
+
+@onready var screen_width = get_tree().get_root().get_viewport().size.x
+@onready var screen_height = get_tree().get_root().get_viewport().size.y
+var global_distance_to_clamp = 40: get = get_global_dist_clamp, set = set_global_dist_clamp
+
+signal mouse_moved(position)
+signal text_selected(text)
+
+@export var path_to_richtextlabel: NodePath
+const ONE_LINE_HEIGHT = 16
+@export var max_width: int = 200
+const MIN_HEIGHT = 30
+const MAX_HEIGHT = 500
+
+func _ready():
+ assert(!path_to_richtextlabel.is_empty())
+ $VBoxContainer/HBoxContainer/clamp_distance.text = str(global_distance_to_clamp)
+
+ var button_group = ButtonGroup.new()
+ $HBoxContainer2/foo.button_group = button_group
+ $HBoxContainer2/foobar.button_group = button_group
+ $HBoxContainer2/whatisit.button_group = button_group
+
+
+ # Add a white TextureRect behind the RTL to see its actual size
+ var texturerect_node = TextureRect.new()
+ get_node(path_to_richtextlabel).add_child(texturerect_node)
+ texturerect_node.texture = load("res://addons/escoria-core/game/assets/images/white.png")
+ texturerect_node.expand = true
+ texturerect_node.stretch_mode = TextureRect.STRETCH_TILE
+ texturerect_node.size_flags_horizontal = SIZE_EXPAND_FILL
+ texturerect_node.size_flags_vertical = SIZE_EXPAND_FILL
+ texturerect_node.show_behind_parent = true
+ texturerect_node.anchor_right = 1.0
+ texturerect_node.anchor_bottom = 1.0
+ move_child(get_node(path_to_richtextlabel), 1)
+
+ update_line2d()
+ _on_new_text_pressed()
+ set_process_input(true)
+
+func set_path_to_richtextlabel(path):
+ path_to_richtextlabel = path
+
+
+func _input(event):
+ if event is InputEventMouseMotion:
+ mouse_moved.emit(event.position)
+
+func set_global_dist_clamp(d):
+ global_distance_to_clamp = d
+ update_line2d()
+
+func get_global_dist_clamp():
+ return global_distance_to_clamp
+
+func update_line2d():
+ $Line2D.clear_points()
+ $Line2D.add_point(Vector2(global_distance_to_clamp, global_distance_to_clamp))
+ $Line2D.add_point(Vector2(global_distance_to_clamp, screen_height - global_distance_to_clamp))
+ $Line2D.add_point(Vector2(screen_width - global_distance_to_clamp, screen_height - global_distance_to_clamp))
+ $Line2D.add_point(Vector2(screen_width - global_distance_to_clamp, global_distance_to_clamp))
+ $Line2D.add_point(Vector2(global_distance_to_clamp, global_distance_to_clamp))
+
+
+func _on_new_text_pressed():
+ var pressed_button = $HBoxContainer2/foo.button_group.get_pressed_button()
+ if pressed_button == null:
+ return
+ printt(pressed_button.name, pressed_button.text)
+ text_selected.emit(pressed_button.text)
+
+
+func tooltip_distance_to_edge_top(position: Vector2):
+ return position.y
+
+func tooltip_distance_to_edge_bottom(position: Vector2):
+ return screen_height - position.y
+
+func tooltip_distance_to_edge_left(position: Vector2):
+ return position.x
+
+func tooltip_distance_to_edge_right(position: Vector2):
+ return screen_width - position.x
+
+func _on_Control_mouse_moved(mouse_pos):
+# printt("mousepos", mouse_pos)
+# printt("label_container_pos", rect_position)
+
+ #var corrected_position = _offset(new_pos)
+ var corrected_position = mouse_pos
+
+ # clamp TOP
+ if tooltip_distance_to_edge_top(mouse_pos) <= global_distance_to_clamp:
+ corrected_position.y = global_distance_to_clamp
+
+ # clamp BOTTOM
+ if tooltip_distance_to_edge_bottom(mouse_pos + get_node(path_to_richtextlabel).size) <= global_distance_to_clamp:
+ corrected_position.y = screen_height - global_distance_to_clamp - get_node(path_to_richtextlabel).size.y
+
+ # clamp LEFT
+ if tooltip_distance_to_edge_left(mouse_pos - get_node(path_to_richtextlabel).size/2) <= global_distance_to_clamp:
+ corrected_position.x = global_distance_to_clamp
+
+ # clamp RIGHT
+ if tooltip_distance_to_edge_right(mouse_pos + get_node(path_to_richtextlabel).size/2) <= global_distance_to_clamp:
+ corrected_position.x = screen_width - global_distance_to_clamp - get_node(path_to_richtextlabel).size.x
+
+ get_node(path_to_richtextlabel).anchor_right = 0.2
+ get_node(path_to_richtextlabel).position = corrected_position
+
+
+func _on_Control_text_selected(text):
+ get_node(path_to_richtextlabel).text = "[color=red]" + text.replace("<br>", "\n") + "[/color]"
+ update_size()
+
+func _on_clamp_distance_text_changed(new_text):
+ global_distance_to_clamp = int(new_text)
+ update_line2d()
+
+
+func _offset(position):
+ var center_offset_x = size.x / 2
+ var offset_y = 5
+
+ position.x -= center_offset_x
+ position.y += offset_y
+ return position
+
+
+func update_size():
+ ## RECT_SIZE ##
+ var rtl_node = get_node(path_to_richtextlabel)
+ var rtl_width = rtl_node.size.x
+ var rtl_height = rtl_node.size.y
+ var content_height = rtl_node.get_content_height()
+ var nb_visible_characters = rtl_node.visible_characters
+ var nb_visible_lines = rtl_node.get_visible_line_count()
+
+ printt("BEFORE", "text_height", content_height, "rtl_height", rtl_node.size.y)
+
+ # if text is too long and is wrapped
+# var nblines = float(rtl_node.get_content_height()) / float(ONE_LINE_HEIGHT)
+ var nblines = nb_visible_lines
+ if nblines >= 1:
+
+ await get_tree().process_frame
+ await get_tree().process_frame
+ var text_height = rtl_node.get_content_height()
+ if text_height > MAX_HEIGHT:
+ text_height = MAX_HEIGHT
+ if text_height <= MIN_HEIGHT:
+ text_height = MIN_HEIGHT
+
+ var parent_width = rtl_node.size.x
+
+ # first, try to increase width until it goes above max_width
+ while parent_width < max_width && float(text_height) / float(ONE_LINE_HEIGHT) > 1.0:
+ rtl_node.size.x += 1
+ parent_width = rtl_node.size.x
+
+
+ rtl_node.size.y = text_height
+
+ if rtl_node.size.x >= max_width:
+ rtl_node.size.x = max_width
+
+ ## END RECT_SIZE ##
+ rtl_node.anchor_top = 0.0
+ rtl_node.anchor_right = 0.0
+ rtl_node.anchor_bottom = 0.0
+ rtl_node.anchor_left = 0.0
+ printt("AFTER", "text_height", get_node(path_to_richtextlabel).get_content_height(), "rtl_height", rtl_node.size.y)
diff --git a/addons/escoria-core/testing/rtl_screen_offset_testing.gd.uid b/addons/escoria-core/testing/rtl_screen_offset_testing.gd.uid
new file mode 100644
index 0000000..ab281ea
--- /dev/null
+++ b/addons/escoria-core/testing/rtl_screen_offset_testing.gd.uid
@@ -0,0 +1 @@
+uid://cgtqofwnv18rn
diff --git a/addons/escoria-core/testing/rtl_screen_offset_testing.tscn b/addons/escoria-core/testing/rtl_screen_offset_testing.tscn
new file mode 100644
index 0000000..04abfaf
--- /dev/null
+++ b/addons/escoria-core/testing/rtl_screen_offset_testing.tscn
@@ -0,0 +1,73 @@
+[gd_scene load_steps=3 format=3 uid="uid://diq5rsixfcxri"]
+
+[ext_resource type="Script" uid="uid://cgtqofwnv18rn" path="res://addons/escoria-core/testing/rtl_screen_offset_testing.gd" id="1"]
+[ext_resource type="PackedScene" uid="uid://b3hru28v8y36i" path="res://addons/escoria-ui-simplemouse/tooltip/target_tooltip.tscn" id="2"]
+
+[node name="rtl_screen_offset" type="Control"]
+layout_mode = 3
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+offset_right = -1280.0
+offset_bottom = -800.0
+script = ExtResource("1")
+path_to_richtextlabel = NodePath("tooltip")
+
+[node name="Line2D" type="Line2D" parent="."]
+points = PackedVector2Array(40, 40, 40, 976, 1808, 976, 1808, 40, 40, 40)
+width = 2.51
+texture_mode = 116
+
+[node name="VBoxContainer" type="VBoxContainer" parent="."]
+layout_mode = 0
+offset_left = 315.72
+offset_top = 269.104
+offset_right = 475.72
+offset_bottom = 321.104
+
+[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
+layout_mode = 2
+
+[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer"]
+layout_mode = 2
+text = "Clamp distance"
+
+[node name="clamp_distance" type="LineEdit" parent="VBoxContainer/HBoxContainer"]
+layout_mode = 2
+text = "40"
+max_length = 4
+
+[node name="HBoxContainer2" type="VBoxContainer" parent="."]
+layout_mode = 0
+offset_left = 310.0
+offset_top = 340.0
+offset_right = 470.0
+offset_bottom = 380.0
+
+[node name="foo" type="CheckBox" parent="HBoxContainer2"]
+layout_mode = 2
+text = "Foo"
+
+[node name="foobar" type="CheckBox" parent="HBoxContainer2"]
+layout_mode = 2
+text = "Foo bar"
+
+[node name="whatisit" type="CheckBox" parent="HBoxContainer2"]
+layout_mode = 2
+text = "A super extremely long sentence to test<br>the behaviour of that RichTextLabel node..."
+
+[node name="tooltip" parent="." instance=ExtResource("2")]
+custom_minimum_size = Vector2(400, 0)
+layout_mode = 0
+offset_left = 238.815
+offset_top = 131.18
+offset_right = 638.815
+offset_bottom = 231.18
+text = "[center][color=#200606][/color][/center]"
+
+[connection signal="mouse_moved" from="." to="." method="_on_Control_mouse_moved"]
+[connection signal="text_selected" from="." to="." method="_on_Control_text_selected"]
+[connection signal="text_changed" from="VBoxContainer/HBoxContainer/clamp_distance" to="." method="_on_clamp_distance_text_changed"]
+[connection signal="pressed" from="HBoxContainer2/foo" to="." method="_on_new_text_pressed"]
+[connection signal="pressed" from="HBoxContainer2/foobar" to="." method="_on_new_text_pressed"]
+[connection signal="pressed" from="HBoxContainer2/whatisit" to="." method="_on_new_text_pressed"]