校验当前点击是否正确,如果不正确,点击无效

This commit is contained in:
joylink_zhaoerwei 2024-05-13 15:44:09 +08:00
parent 57a259af49
commit cd1a1ec377
16 changed files with 91 additions and 25 deletions

View File

@ -26,7 +26,9 @@ func _input(event):
var flag2 = test_enter() var flag2 = test_enter()
if flag2 and event.button_index == MOUSE_BUTTON_LEFT: if flag2 and event.button_index == MOUSE_BUTTON_LEFT:
# 处理点击事件 # 处理点击事件
$"..".allClickJJTCSignal.emit('JJTCLeftRotate') $"..".allClickJJTCSignal.emit('JJTCLeftRotate',$"..")
if !$"..".allowHandle :
return
$"../JJTC_Right_Rotate".hide() $"../JJTC_Right_Rotate".hide()
self.hide() self.hide()
$"../JJTC_Key".hide() $"../JJTC_Key".hide()

View File

@ -27,7 +27,9 @@ func _input(event):
if flag2 and event.button_index == MOUSE_BUTTON_LEFT: if flag2 and event.button_index == MOUSE_BUTTON_LEFT:
# 处理点击事件 # 处理点击事件
#self.modulate = Color(0, 1, 1, 1);$".." #self.modulate = Color(0, 1, 1, 1);$".."
$"..".allClickJJTCSignal.emit('JJTCRightRotate') $"..".allClickJJTCSignal.emit('JJTCRightRotate',$"..")
if !$"..".allowHandle :
return
$"../PanelContainer/VBoxContainer/MarginContainer/JJTC_Box".jjtc_state = $"../PanelContainer/VBoxContainer/MarginContainer/JJTC_Box".JJTC_STATE.OPEN $"../PanelContainer/VBoxContainer/MarginContainer/JJTC_Box".jjtc_state = $"../PanelContainer/VBoxContainer/MarginContainer/JJTC_Box".JJTC_STATE.OPEN
$"../JJTC_Box_Voice".play() $"../JJTC_Box_Voice".play()
$"../JJTC_Key".hide() $"../JJTC_Key".hide()

View File

@ -1,9 +1,14 @@
extends Window extends Window
##是否允许操作
var allowHandle :bool = true
func _on_jjtc_click_jjtc_signal(): func _on_jjtc_click_jjtc_signal():
allClickJJTCSignal.emit('JJTC',$".")
if !allowHandle :
return
self.show() self.show()
$"../stationKeys".onShowWindow(StationKeyWindow.WindowType.JJTC) $"../stationKeys".onShowWindow(StationKeyWindow.WindowType.JJTC)
$"..".allClickPlatformSignal.emit('JJTC')
func _on_close_requested(): func _on_close_requested():
@ -23,7 +28,9 @@ func shouJJTCKey():
func _on_jjtc_button_gui_input(event): func _on_jjtc_button_gui_input(event):
if event.button_mask == MouseButtonMask.MOUSE_BUTTON_MASK_LEFT: if event.button_mask == MouseButtonMask.MOUSE_BUTTON_MASK_LEFT:
allClickJJTCSignal.emit('JJTCButton') allClickJJTCSignal.emit('JJTCButton',$".")
if !allowHandle :
return
func _on_jjtc_button_mouse_entered(): func _on_jjtc_button_mouse_entered():

View File

@ -27,6 +27,9 @@ func _input(event):
if flag2 and event.button_index == MOUSE_BUTTON_LEFT: if flag2 and event.button_index == MOUSE_BUTTON_LEFT:
# 处理点击事件 # 处理点击事件
#self.modulate = Color(0, 1, 1, 1);$".." #self.modulate = Color(0, 1, 1, 1);$".."
$"..".allClickLCBSignal.emit($"..".title+"LeftRotate",$"..")
if !$"..".allowHandle :
return
if $"..".knob_state == $"..".KNOB_STATE.AUTO: if $"..".knob_state == $"..".KNOB_STATE.AUTO:
$"../LCBRotateAnimation".play("AutoToIsolate", -1, 10) $"../LCBRotateAnimation".play("AutoToIsolate", -1, 10)
$"..".change_knob_state($"..".KNOB_STATE.ISOLATE) $"..".change_knob_state($"..".KNOB_STATE.ISOLATE)
@ -36,4 +39,3 @@ func _input(event):
elif $"..".knob_state == $"..".KNOB_STATE.OPEN: elif $"..".knob_state == $"..".KNOB_STATE.OPEN:
$"../LCBRotateAnimation".play("OpenToClose", -1, 10) $"../LCBRotateAnimation".play("OpenToClose", -1, 10)
$"..".change_knob_state($"..".KNOB_STATE.CLOSE) $"..".change_knob_state($"..".KNOB_STATE.CLOSE)
$"..".allClickLCBSignal.emit($"..".title+"LeftRotate", $"..".knob_state)

View File

@ -27,6 +27,9 @@ func _input(event):
if flag2 and event.button_index == MOUSE_BUTTON_LEFT: if flag2 and event.button_index == MOUSE_BUTTON_LEFT:
# 处理点击事件 # 处理点击事件
#self.modulate = Color(0, 1, 1, 1);$".." #self.modulate = Color(0, 1, 1, 1);$".."
$"..".allClickLCBSignal.emit($"..".title+"RightRotate",$"..")
if !$"..".allowHandle :
return
if $"..".knob_state == $"..".KNOB_STATE.AUTO: if $"..".knob_state == $"..".KNOB_STATE.AUTO:
$"../LCBRotateAnimation".play("AutoToClose", -1, 10) $"../LCBRotateAnimation".play("AutoToClose", -1, 10)
$"..".change_knob_state($"..".KNOB_STATE.CLOSE) $"..".change_knob_state($"..".KNOB_STATE.CLOSE)
@ -36,4 +39,3 @@ func _input(event):
elif $"..".knob_state == $"..".KNOB_STATE.CLOSE: elif $"..".knob_state == $"..".KNOB_STATE.CLOSE:
$"../LCBRotateAnimation".play("CloseToOpen", -1, 10) $"../LCBRotateAnimation".play("CloseToOpen", -1, 10)
$"..".change_knob_state($"..".KNOB_STATE.OPEN) $"..".change_knob_state($"..".KNOB_STATE.OPEN)
$"..".allClickLCBSignal.emit($"..".title+"RightRotate", $"..".knob_state)

View File

@ -3,15 +3,20 @@ extends Window
##lcb面板 ##lcb面板
class_name LcbWindow class_name LcbWindow
##是否允许操作
var allowHandle :bool = true
var currenScreenDoor:ScreenDoor=null var currenScreenDoor:ScreenDoor=null
func _on_screen_door_click_lcb_signal(screenDoor: Variant) -> void: func _on_screen_door_click_lcb_signal(screenDoor: Variant) -> void:
allClickLCBSignal.emit(self.title,$".")
if !allowHandle :
return
var screenDoorName=String(screenDoor.name) var screenDoorName=String(screenDoor.name)
self.title='LCB'+screenDoorName[screenDoorName.length() - 1] self.title='LCB'+screenDoorName[screenDoorName.length() - 1]
self.show() self.show()
$"../stationKeys".onShowWindow(StationKeyWindow.WindowType.LCB,screenDoor.lcbKey.keyName) $"../stationKeys".onShowWindow(StationKeyWindow.WindowType.LCB,screenDoor.lcbKey.keyName)
currenScreenDoor=screenDoor currenScreenDoor=screenDoor
resetState(screenDoor.lcbKey) resetState(screenDoor.lcbKey)
$"..".allClickPlatformSignal.emit(self.title,screenDoor)
@ -87,10 +92,12 @@ func _on_open_key_window_mouse_exited() -> void:
##拔钥匙相关 ##拔钥匙相关
func _on_texture_rect_2_gui_input(event: InputEvent) -> void: func _on_texture_rect_2_gui_input(event: InputEvent) -> void:
if event.button_mask == MouseButtonMask.MOUSE_BUTTON_MASK_LEFT: if event.button_mask == MouseButtonMask.MOUSE_BUTTON_MASK_LEFT:
allClickLCBSignal.emit('removeKeyOfWindow'+self.title,$".")
if !allowHandle :
return
hideHandleKey() hideHandleKey()
$"../stationKeys".showKeyAfterRemoveKey(currenScreenDoor.lcbKey.keyName) $"../stationKeys".showKeyAfterRemoveKey(currenScreenDoor.lcbKey.keyName)
currenScreenDoor.lcbKey.keyName = '' currenScreenDoor.lcbKey.keyName = ''
allClickLCBSignal.emit('removeKeyOfWindow'+self.title)
func _on_texture_rect_2_mouse_entered() -> void: func _on_texture_rect_2_mouse_entered() -> void:

View File

@ -26,4 +26,6 @@ func _input(event):
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed: if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
var flag2 = test_enter() var flag2 = test_enter()
if flag2: if flag2:
if !$"../..".allowHandle :
return
$"../..".clickButtonSignal.emit(true,$"../..") $"../..".clickButtonSignal.emit(true,$"../..")

View File

@ -1,5 +1,8 @@
extends VBoxContainer extends VBoxContainer
##是否允许操作
var allowHandle :bool = true
enum ButtonType{ enum ButtonType{
green,# 绿色按钮 green,# 绿色按钮
red,#红色按钮 red,#红色按钮

View File

@ -18,6 +18,9 @@ func _input(event):
# 如果鼠标在Sprite2D上点击则处理事件 # 如果鼠标在Sprite2D上点击则处理事件
var flag2 = test_enter() var flag2 = test_enter()
if flag2: if flag2:
$"../..".clickKeySwitchSignal.emit(open_light.visible,$"../..")
if !$"../..".allowHandle :
return
if $"../Key".rotation+PI/6<0.001: if $"../Key".rotation+PI/6<0.001:
$"../Key".rotation=PI/6 $"../Key".rotation=PI/6
$"../Keyhole".rotation=PI/6 $"../Keyhole".rotation=PI/6
@ -25,4 +28,3 @@ func _input(event):
$"../Key".rotation=-PI/6 $"../Key".rotation=-PI/6
$"../Keyhole".rotation=-PI/6 $"../Keyhole".rotation=-PI/6
open_light.visible = !open_light.visible open_light.visible = !open_light.visible
$"../..".clickKeySwitchSignal.emit(open_light.visible,$"../..")

View File

@ -6,10 +6,13 @@ extends VBoxContainer
@export var keyText:String @export var keyText:String
##是否允许操作
var allowHandle :bool = true
signal clickKeySwitchSignal(openLight:bool,keySwitch) signal clickKeySwitchSignal(openLight:bool,keySwitch)
signal removeKey(keyName) signal removeKey(keySwitch)
func _ready() -> void: func _ready() -> void:
$Light/MarginContainer/Label.text=lightText $Light/MarginContainer/Label.text=lightText
@ -32,7 +35,9 @@ func hideHandleKey() -> void:
##拔钥匙相关 ##拔钥匙相关
func _on_key_gui_input(event: InputEvent) -> void: func _on_key_gui_input(event: InputEvent) -> void:
if event.button_mask == MouseButtonMask.MOUSE_BUTTON_MASK_LEFT: if event.button_mask == MouseButtonMask.MOUSE_BUTTON_MASK_LEFT:
removeKey.emit(self.name) removeKey.emit(self)
if !allowHandle :
return
hideHandleKey() hideHandleKey()

View File

@ -1,14 +1,18 @@
extends Window extends Window
##是否允许操作
var allowHandle :bool = true
func _on_psl_click_signal() -> void: func _on_psl_click_signal() -> void:
allClickPslSignal.emit('PSL',$".")
if !allowHandle :
return
self.show() self.show()
$"../stationKeys".onShowWindow(StationKeyWindow.WindowType.PSL) $"../stationKeys".onShowWindow(StationKeyWindow.WindowType.PSL)
if !$"../stationKeys".hsjcKeyVisible() : if !$"../stationKeys".hsjcKeyVisible() :
hideInterlockReleaseSwitchHandleKey() hideInterlockReleaseSwitchHandleKey()
if !$"../stationKeys".pslKeyVisible() : if !$"../stationKeys".pslKeyVisible() :
hidePSLAllowHandleKey() hidePSLAllowHandleKey()
$"..".allClickPlatformSignal.emit('PSL')
func _on_close_requested(): func _on_close_requested():
@ -17,7 +21,7 @@ func _on_close_requested():
##点击按钮或钥匙 ##点击按钮或钥匙
func onHandleSignal(openLight: bool, keySwitch: Variant) -> void: func onHandleSignal(openLight: bool, keySwitch: Variant) -> void:
$"..".allClickPlatformSignal.emit(keySwitch.name,keySwitch) allClickPslSignal.emit(keySwitch.name,keySwitch)
##显影psl相关钥匙操作 ##显影psl相关钥匙操作
func shouPSLAllowHandleKey(): func shouPSLAllowHandleKey():
@ -35,15 +39,16 @@ func hideInterlockReleaseSwitchHandleKey():
$MarginContainer/GridContainer/InterlockReleaseSwitch.hideHandleKey() $MarginContainer/GridContainer/InterlockReleaseSwitch.hideHandleKey()
func remove_key(keyName: Variant) -> void: func remove_key(keySwitch: Variant) -> void:
var name = '' var name = ''
if keyName == 'PSLAllow' : if keySwitch.name == 'PSLAllow' :
name = 'PSL_Key' name = 'PSL_Key'
allClickPslSignal.emit('removePSLKeyOfWindowPsl') allClickPslSignal.emit('removePSLKeyOfWindowPsl',keySwitch)
elif keyName == 'InterlockReleaseSwitch' : elif keySwitch.name == 'InterlockReleaseSwitch' :
name = 'HSJC_Key' name = 'HSJC_Key'
allClickPslSignal.emit('removeHSJCKeyOfWindowPsl') allClickPslSignal.emit('removeHSJCKeyOfWindowPsl',keySwitch)
$"../stationKeys".showKeyAfterRemoveKey(name) if keySwitch.allowHandle :
$"../stationKeys".showKeyAfterRemoveKey(name)
##打开钥匙盒相关 ##打开钥匙盒相关

View File

@ -1,11 +1,17 @@
extends Window extends Window
##是否允许操作
var allowHandle :bool = true
var currenScreenDoor:ScreenDoor=null var currenScreenDoor:ScreenDoor=null
@onready var isolation_strip: Button = $PanelContainer/MarginContainer/VBoxContainer/IsolationStrip/IsolationStrip @onready var isolation_strip: Button = $PanelContainer/MarginContainer/VBoxContainer/IsolationStrip/IsolationStrip
func _on_screen_door_click_signal(screenDoor:ScreenDoor,mousePosition) -> void: func _on_screen_door_click_signal(screenDoor:ScreenDoor,mousePosition) -> void:
allClickScreenDoorSignal.emit(screenDoor.name+'RightClick',$".")
if !allowHandle :
return
position = Vector2(mousePosition.x-100,mousePosition.y) position = Vector2(mousePosition.x-100,mousePosition.y)
currenScreenDoor = screenDoor currenScreenDoor = screenDoor
show() show()
@ -13,16 +19,17 @@ func _on_screen_door_click_signal(screenDoor:ScreenDoor,mousePosition) -> void:
isolation_strip.text = '撤下隔离带' isolation_strip.text = '撤下隔离带'
else : else :
isolation_strip.text = '放置隔离带' isolation_strip.text = '放置隔离带'
$"..".allClickPlatformSignal.emit(screenDoor.name+'RightClick',screenDoor)
func _on_close_requested() -> void: func _on_close_requested() -> void:
hide() hide()
##粘胶带 ##粘胶带
func _on_adhesive_tape_button_down() -> void: func _on_adhesive_tape_button_down() -> void:
allClickScreenDoorSignal.emit('clickAdhesiveTapeOf'+currenScreenDoor.name,$".")
if !allowHandle :
return
currenScreenDoor.adhesiveTape() currenScreenDoor.adhesiveTape()
hide() hide()
allClickScreenDoorSignal.emit('clickAdhesiveTapeOf'+currenScreenDoor.name)
func _on_adhesive_tape_mouse_entered() -> void: func _on_adhesive_tape_mouse_entered() -> void:
$PanelContainer/MarginContainer/VBoxContainer/MarginContainer/AdhesiveTape/AdhesiveTape.set_default_cursor_shape(Control.CursorShape.CURSOR_POINTING_HAND) $PanelContainer/MarginContainer/VBoxContainer/MarginContainer/AdhesiveTape/AdhesiveTape.set_default_cursor_shape(Control.CursorShape.CURSOR_POINTING_HAND)
@ -33,9 +40,11 @@ func _on_adhesive_tape_mouse_exited() -> void:
##隔离带 ##隔离带
func _on_isolation_strip_button_down() -> void: func _on_isolation_strip_button_down() -> void:
allClickScreenDoorSignal.emit('clickIsolationStripOf'+currenScreenDoor.name,$".")
if !allowHandle :
return
currenScreenDoor.isSetIsolationStrip = !currenScreenDoor.isSetIsolationStrip currenScreenDoor.isSetIsolationStrip = !currenScreenDoor.isSetIsolationStrip
hide() hide()
allClickScreenDoorSignal.emit('clickIsolationStripOf'+currenScreenDoor.name)
func _on_isolation_strip_mouse_entered() -> void: func _on_isolation_strip_mouse_entered() -> void:

View File

@ -3,6 +3,9 @@ extends Window
##钥匙面板 ##钥匙面板
class_name StationKeyWindow class_name StationKeyWindow
##是否允许操作
var allowHandle :bool = true
var current_focus: CanvasItem var current_focus: CanvasItem
## 打开的面板类型枚举 ## 打开的面板类型枚举
@ -17,15 +20,20 @@ var current_together_window: WindowType
var current_lcb_keyname: String='' var current_lcb_keyname: String=''
func _on_key_focus_entered(node): func _on_key_focus_entered(node):
allClickStationKeysSignal.emit(node.name)
if !allowHandle :
return
current_focus = node current_focus = node
$"..".allClickPlatformSignal.emit(current_focus.name)
func _on_button_pressed(): 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')): 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("请选择钥匙") print("请选择钥匙")
else: else:
$"..".allClickPlatformSignal.emit('confirmUseKey',current_focus.name) allClickStationKeysSignal.emit('confirmUseKey')
if !allowHandle :
return
if current_focus.name.contains('LCB') : if current_focus.name.contains('LCB') :
$"../LCB".shouHandleKey(current_focus.name) $"../LCB".shouHandleKey(current_focus.name)
$"../LCB".grab_focus() $"../LCB".grab_focus()
@ -65,3 +73,6 @@ func onShowWindow(togetherWindow:WindowType,lcbKeyName = ''):
current_together_window = togetherWindow current_together_window = togetherWindow
current_lcb_keyname = lcbKeyName current_lcb_keyname = lcbKeyName
self.show() self.show()
##所有StationKeys点击操作汇总
signal allClickStationKeysSignal(equipmentName:String)

View File

@ -46,6 +46,9 @@ func _on_close_click_area_mouse_exited():
func _on_close_click_area_gui_input(event): func _on_close_click_area_gui_input(event):
if event.button_mask == MouseButtonMask.MOUSE_BUTTON_MASK_LEFT && jjtc_state == JJTC_STATE.OPEN: if event.button_mask == MouseButtonMask.MOUSE_BUTTON_MASK_LEFT && jjtc_state == JJTC_STATE.OPEN:
$"../../../..".allClickJJTCSignal.emit('JJTCCloseBox',$"../../../..")
if !$"../../../..".allowHandle :
return
jjtc_state = JJTC_STATE.CLOSE jjtc_state = JJTC_STATE.CLOSE
$"../../../../JJTC_Box_Voice".play() $"../../../../JJTC_Box_Voice".play()
$"../../../../JJTC_Key".show() $"../../../../JJTC_Key".show()
@ -53,7 +56,6 @@ func _on_close_click_area_gui_input(event):
$"../../../../JJTC_Left_Rotate".show() $"../../../../JJTC_Left_Rotate".show()
$"../../../../Close_Click_Area".hide() $"../../../../Close_Click_Area".hide()
$"../../../../JJTC_Button".hide() $"../../../../JJTC_Button".hide()
$"../../../..".allClickJJTCSignal.emit('JJTCCloseBox')
func _on_station_keys_mouse_entered(): func _on_station_keys_mouse_entered():

View File

@ -65,3 +65,7 @@ func _on_jjtc_all_click_jjtc_signal(equipmentName: String, equipmentInfo: Varian
func _on_screen_door_operate_all_click_screen_door_signal(equipmentName: String, equipmentInfo: Variant=null) -> void: func _on_screen_door_operate_all_click_screen_door_signal(equipmentName: String, equipmentInfo: Variant=null) -> void:
allClickPlatformSignal.emit(equipmentName,equipmentInfo) allClickPlatformSignal.emit(equipmentName,equipmentInfo)
func _on_station_keys_all_click_station_keys_signal(equipmentName: String) -> void:
allClickPlatformSignal.emit(equipmentName,$stationKeys)

View File

@ -43,6 +43,7 @@ visible = false
[connection signal="clickJJTCSignal" from="JJTC" to="jjtc" method="_on_jjtc_click_jjtc_signal"] [connection signal="clickJJTCSignal" from="JJTC" to="jjtc" method="_on_jjtc_click_jjtc_signal"]
[connection signal="allClickLCBSignal" from="LCB" to="." method="_on_lcb_all_click_lcb_signal"] [connection signal="allClickLCBSignal" from="LCB" to="." method="_on_lcb_all_click_lcb_signal"]
[connection signal="close_requested" from="LCB" to="LCB" method="_on_close_requested"] [connection signal="close_requested" from="LCB" to="LCB" method="_on_close_requested"]
[connection signal="allClickStationKeysSignal" from="stationKeys" to="." method="_on_station_keys_all_click_station_keys_signal"]
[connection signal="allClickPslSignal" from="psl" to="." method="_on_psl_all_click_psl_signal"] [connection signal="allClickPslSignal" from="psl" to="." method="_on_psl_all_click_psl_signal"]
[connection signal="allClickJJTCSignal" from="jjtc" to="." method="_on_jjtc_all_click_jjtc_signal"] [connection signal="allClickJJTCSignal" from="jjtc" to="." method="_on_jjtc_all_click_jjtc_signal"]
[connection signal="close_requested" from="jjtc" to="jjtc" method="_on_close_requested"] [connection signal="close_requested" from="jjtc" to="jjtc" method="_on_close_requested"]