实训提示位置计算调整

This commit is contained in:
joylink_fanyuhong 2024-05-16 09:55:16 +08:00
parent dccb91220c
commit f51ec0c5b2
2 changed files with 26 additions and 4 deletions

View File

@ -17,9 +17,31 @@ var left_theme_resource = load("res://training_tip_left.tres")
func setTrainingTip(text):
$PanelContainer/Label.text = text
if text!= '':
var position = $"../total".allClickEquipmentPostion($"..".currentStep[$"..".stepIndex])
self.show()
#var position = $"../total".allClickEquipmentPostion($"..".currentStep[$"..".stepIndex])
#print(position, '11', position.x - $PanelContainer.size.x)
#if position.x - $PanelContainer.size.x < 0:
#position.x = position.x - 10
#position.y = position.y + 10
#$PanelContainer.theme = right_theme_resource
#print(position, '22')
#else:
#position.x = position.x - $PanelContainer.size.x + 10
#position.y = position.y - $PanelContainer.size.y - 10
#$PanelContainer.theme = left_theme_resource
#print(position, '33', $PanelContainer.size)
#self.position = position
#self.size = self.get_contents_minimum_size()
#print(self.position, '44')
else:
self.hide()
func _on_panel_container_resized():
print('resized')
if $PanelContainer/Label.text != "":
var position = $"../total".allClickEquipmentPostion($"..".currentStep[$"..".stepIndex])
print(position, '11111')
if position.x - $PanelContainer.size.x < 0:
position.x = position.x - 10
position.y = position.y + 10
@ -30,5 +52,3 @@ func setTrainingTip(text):
$PanelContainer.theme = left_theme_resource
self.position = position
self.size = self.get_contents_minimum_size()
else:
self.hide()

View File

@ -20,3 +20,5 @@ theme = ExtResource("2_3b4sf")
[node name="Label" type="Label" parent="PanelContainer"]
layout_mode = 2
[connection signal="resized" from="PanelContainer" to="." method="_on_panel_container_resized"]