2024-05-15 17:47:35 +08:00
|
|
|
extends Window
|
2024-05-13 15:55:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready():
|
2024-05-15 17:47:35 +08:00
|
|
|
self.hide()
|
|
|
|
self.transparent_bg = true
|
2024-05-13 15:55:11 +08:00
|
|
|
pass # Replace with function body.
|
|
|
|
|
|
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
|
|
func _process(delta):
|
|
|
|
pass
|
|
|
|
|
2024-05-14 17:52:24 +08:00
|
|
|
var right_theme_resource = load("res://training_tip_right.tres")
|
|
|
|
var left_theme_resource = load("res://training_tip_left.tres")
|
2024-05-13 15:55:11 +08:00
|
|
|
func setTrainingTip(text):
|
|
|
|
$PanelContainer/Label.text = text
|
|
|
|
if text!= '':
|
2024-05-15 17:47:35 +08:00
|
|
|
self.show()
|
2024-05-16 10:22:00 +08:00
|
|
|
var position = computed_position()
|
|
|
|
self.position = position
|
|
|
|
self.size = self.get_contents_minimum_size()
|
2024-05-16 09:55:16 +08:00
|
|
|
else:
|
|
|
|
self.hide()
|
|
|
|
|
|
|
|
|
|
|
|
func _on_panel_container_resized():
|
|
|
|
if $PanelContainer/Label.text != "":
|
2024-05-16 10:22:00 +08:00
|
|
|
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():
|
2024-05-21 11:09:24 +08:00
|
|
|
var position = $"../total".allClickEquipmentPostion($"..".stepOperation[$"..".stepOperationIndex])
|
2024-06-04 15:20:33 +08:00
|
|
|
if $"..".stepOperation[$"..".stepOperationIndex] in ['PSLAllowLeftRotate','PSLAllowRightRotate','InterlockReleaseSwitchLeftRotate','InterlockReleaseSwitchRightRotate','CloseDoorButton','OpenDoorButton','LightTestButton','trainDepartsButton','interconnectedCloseButton','interconnectedOpenButton','removePSLKeyOfWindowPsl','removeHSJCKeyOfWindowPsl']:
|
|
|
|
$PanelContainer.theme = left_theme_resource
|
|
|
|
position.x = position.x - $PanelContainer.size.x + 10
|
|
|
|
position.y = position.y - $PanelContainer.size.y - 10
|
|
|
|
return position
|
2024-05-16 10:22:00 +08:00
|
|
|
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
|