diff --git a/trainings/trainTip.gd b/trainings/trainTip.gd index 5b6b87b..b65fe96 100644 --- a/trainings/trainTip.gd +++ b/trainings/trainTip.gd @@ -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() diff --git a/trainings/trainTip.tscn b/trainings/trainTip.tscn index f1a0bab..f838713 100644 --- a/trainings/trainTip.tscn +++ b/trainings/trainTip.tscn @@ -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"]