From f4c7f4474ce6bcf1d98ad63a73f88a9c45b249a0 Mon Sep 17 00:00:00 2001 From: joylink_fanyuhong <18706759286@163.com> Date: Thu, 16 May 2024 10:22:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E8=AE=A1=E7=AE=97=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trainings/trainTip.gd | 47 +++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/trainings/trainTip.gd b/trainings/trainTip.gd index b65fe96..2786163 100644 --- a/trainings/trainTip.gd +++ b/trainings/trainTip.gd @@ -18,37 +18,28 @@ func setTrainingTip(text): $PanelContainer/Label.text = text if text!= '': 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') + var position = computed_position() + self.position = position + self.size = self.get_contents_minimum_size() 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 - $PanelContainer.theme = right_theme_resource - else: - position.x = position.x - $PanelContainer.size.x + 10 - position.y = position.y - $PanelContainer.size.y - 10 - $PanelContainer.theme = left_theme_resource - self.position = position - self.size = self.get_contents_minimum_size() + var cp = computed_position() + if self.position.x != cp.x or self.position.y != cp.y: + self.position = cp + self.size = self.get_contents_minimum_size() + +func computed_position(): + var position = $"../total".allClickEquipmentPostion($"..".currentStep[$"..".stepIndex]) + if position.x - $PanelContainer.size.x < 0: + position.x = position.x - 10 + position.y = position.y + 10 + $PanelContainer.theme = right_theme_resource + else: + position.x = position.x - $PanelContainer.size.x + 10 + position.y = position.y - $PanelContainer.size.y - 10 + $PanelContainer.theme = left_theme_resource + return position