Created ESCGame class to force game.tscn scene to have empty functions by inheritance.

Also continued some tests about tooltip following mouse.
Fixed project settings wrongly set.
This commit is contained in:
Julian Murgia
2021-02-11 07:15:55 +01:00
parent 6aa466d6d2
commit 52d19c34bd
19 changed files with 204 additions and 67 deletions

View File

@@ -10,6 +10,8 @@ signal text_selected(text)
export(NodePath) var path_to_richtextlabel
const ONE_LINE_HEIGHT = 16
export(int) var max_width = 200
const MIN_HEIGHT = 30
const MAX_HEIGHT = 500
func _ready():
assert(!path_to_richtextlabel.is_empty())
@@ -139,28 +141,28 @@ func update_size():
# var nblines = float(rtl_node.get_content_height()) / float(ONE_LINE_HEIGHT)
var nblines = nb_visible_lines
if nblines >= 1:
# reset size
#get_parent().rect_size.x = 10
#get_parent().rect_size.y = ONE_LINE_HEIGHT
yield(get_tree(), "idle_frame")
yield(get_tree(), "idle_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.rect_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.rect_size.x += 1
parent_width = rtl_node.rect_size.x
yield(get_tree(), "idle_frame")
yield(get_tree(), "idle_frame")
# text_height = get_parent().rect_size.y
rtl_node.rect_size.y = text_height
if rtl_node.rect_size.x >= max_width:
rtl_node.rect_size.x = max_width
## END RECT_SIZE ##
rtl_node.anchor_top = 0.0
rtl_node.anchor_right = 0.0

View File

@@ -1,7 +1,7 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://addons/escoria-core/testing/rtl_screen_offset_testing.gd" type="Script" id=1]
[ext_resource path="res://addons/escoria-core/template_scenes/label/target_tooltip.tscn" type="PackedScene" id=2]
[ext_resource path="res://game/ui/ui_mouse_icons/tooltip/target_tooltip.tscn" type="PackedScene" id=2]
[sub_resource type="ButtonGroup" id=1]
@@ -72,7 +72,7 @@ margin_top = 56.0
margin_right = 624.0
margin_bottom = 80.0
group = SubResource( 1 )
text = "Une phrase extremement<br>longue pour tester<br>le comportement de ce RichTextLabel..."
text = "A super extremely long sentence to test<br>the behaviour of that RichTextLabel node..."
[node name="tooltip" parent="." instance=ExtResource( 2 )]
margin_left = 238.815
@@ -81,7 +81,8 @@ margin_right = 638.815
margin_bottom = 231.18
rect_min_size = Vector2( 400, 0 )
bbcode_text = "Tooltip content"
fit_content_height = true
text = "Tooltip content"
[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"]