godot-psd-training/UI/station_keys/station_keys_window.gd
2024-04-28 18:03:50 +08:00

56 lines
1.6 KiB
GDScript

extends Window
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):
current_focus = node
print("node : ", current_focus.name, " focus")
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:
print("使用钥匙:", current_focus.name)
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 _on_close_requested():
self.hide()
func onShowWindow(togetherWindow:WindowType,lcbKeyName = ''):
current_together_window = togetherWindow
current_lcb_keyname = lcbKeyName
self.show()