51 lines
1.8 KiB
GDScript
51 lines
1.8 KiB
GDScript
extends Window
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
self.hide()
|
|
self.transparent_bg = true
|
|
pass # Replace with function body.
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta):
|
|
pass
|
|
|
|
var right_theme_resource = load("res://training_tip_right.tres")
|
|
var left_theme_resource = load("res://training_tip_left.tres")
|
|
func setTrainingTip(text):
|
|
$PanelContainer/Label.text = text
|
|
if text!= '':
|
|
self.show()
|
|
var position = computed_position()
|
|
self.position = position
|
|
self.size = self.get_contents_minimum_size()
|
|
else:
|
|
self.hide()
|
|
|
|
|
|
func _on_panel_container_resized():
|
|
if $PanelContainer/Label.text != "":
|
|
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($"..".stepOperation[$"..".stepOperationIndex])
|
|
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
|
|
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
|