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

68 lines
1.9 KiB
GDScript3
Raw Normal View History

2024-04-12 11:06:25 +08:00
extends Window
##钥匙面板
class_name StationKeyWindow
2024-04-12 11:06:25 +08:00
var current_focus: CanvasItem
## 打开的面板类型枚举
enum WindowType{
LCB,
PSL,
JJTC,
}
var current_together_window: WindowType
var current_lcb_keyname: String=''
2024-04-12 11:06:25 +08:00
func _on_key_focus_entered(node):
current_focus = node
print("node : ", current_focus.name, " focus")
2024-04-17 15:26:37 +08:00
2024-04-12 11:06:25 +08:00
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')):
2024-04-12 11:06:25 +08:00
print("请选择钥匙")
else:
print("使用钥匙:", current_focus.name)
if current_focus.name.contains('LCB') :
$"../LCB".shouHandleKey(current_focus.name)
2024-04-23 17:20:15 +08:00
$"../LCB".grab_focus()
current_lcb_keyname = current_focus.name
elif current_focus.name.contains('PSL'):
2024-04-22 15:32:19 +08:00
$"../psl".shouPSLAllowHandleKey()
2024-04-23 17:20:15 +08:00
$"../psl".grab_focus()
elif current_focus.name.contains('HSJC'):
2024-04-26 16:54:17 +08:00
$"../psl".shouInterlockReleaseSwitchHandleKey()
$"../psl".grab_focus()
2024-04-28 11:21:59 +08:00
elif (current_focus.name.contains('JJTC')):
$"../jjtc".shouJJTCKey()
$"../jjtc".grab_focus()
current_focus.hide_key()
$AudioStreamPlayer.play()
2024-04-29 11:03:01 +08:00
func showKeyAfterRemoveKey(keyName):
$PanelContainer/VBoxContainer/GridContainer.find_child(keyName).show_key()
2024-04-28 18:03:50 +08:00
$AudioStreamPlayer.play()
current_lcb_keyname = ''
2024-04-12 11:06:25 +08:00
2024-04-29 11:03:01 +08:00
func hsjcKeyVisible ()-> bool:
return $PanelContainer/VBoxContainer/GridContainer/HSJC_Key.visible
func pslKeyVisible ()-> bool:
return $PanelContainer/VBoxContainer/GridContainer/PSL_Key.visible
2024-04-12 11:06:25 +08:00
func _on_close_requested():
self.hide()
func onShowWindow(togetherWindow:WindowType,lcbKeyName = ''):
current_together_window = togetherWindow
current_lcb_keyname = lcbKeyName
2024-04-12 11:06:25 +08:00
self.show()