godot-psd-training/UI/station_keys/station_keys_window.gd

79 lines
2.1 KiB
GDScript

extends Window
##钥匙面板
class_name StationKeyWindow
##是否允许操作
var allowHandle :bool = true
var current_focus: CanvasItem
## 打开的面板类型枚举
enum WindowType{
LCB,
PSL,
JJTC,
}
var current_together_window: WindowType
var current_lcb_keyname: String=''
func _on_key_focus_entered(node):
allClickStationKeysSignal.emit(node.name)
if !allowHandle :
return
current_focus = node
func _on_button_pressed():
if current_focus == null or (current_together_window==WindowType.LCB and (!current_focus.name.contains('LCB') or current_lcb_keyname)) or (current_together_window==WindowType.PSL and (!current_focus.name.contains('PSL') and !current_focus.name.contains('HSJC') )) or (current_together_window==WindowType.JJTC and !current_focus.name.contains('JJTC')):
print("请选择钥匙")
else:
allClickStationKeysSignal.emit('confirmUseKey')
if !allowHandle :
return
if current_focus.name.contains('LCB') :
$"../LCB".shouHandleKey(current_focus.name)
$"../LCB".grab_focus()
current_lcb_keyname = current_focus.name
elif current_focus.name.contains('PSL'):
$"../psl".shouPSLAllowHandleKey()
$"../psl".grab_focus()
elif current_focus.name.contains('HSJC'):
$"../psl".shouInterlockReleaseSwitchHandleKey()
$"../psl".grab_focus()
elif (current_focus.name.contains('JJTC')):
$"../jjtc".shouJJTCKey()
$"../jjtc".grab_focus()
current_focus.hide_key()
$AudioStreamPlayer.play()
func showKeyAfterRemoveKey(keyName):
$PanelContainer/VBoxContainer/GridContainer.find_child(keyName).show_key()
$AudioStreamPlayer.play()
current_lcb_keyname = ''
func hsjcKeyVisible ()-> bool:
return $PanelContainer/VBoxContainer/GridContainer/HSJC_Key.visible
func pslKeyVisible ()-> bool:
return $PanelContainer/VBoxContainer/GridContainer/PSL_Key.visible
func _on_close_requested():
self.hide()
func onShowWindow(togetherWindow:WindowType,lcbKeyName = ''):
current_together_window = togetherWindow
current_lcb_keyname = lcbKeyName
self.show()
##所有StationKeys点击操作汇总
signal allClickStationKeysSignal(equipmentName:String)