extends Window ##lcb面板 class_name LcbWindow ##是否允许操作 var allowHandle :bool = true var currenScreenDoor:ScreenDoor=null func _on_screen_door_click_lcb_signal(screenDoor: Variant) -> void: var screenDoorName=String(screenDoor.name) self.title='LCB'+screenDoorName[screenDoorName.length() - 1] allClickLCBSignal.emit(self.title,$".") if !allowHandle : return self.show() $"../stationKeys".onShowWindow(StationKeyWindow.WindowType.LCB,screenDoor.lcbKey.keyName) currenScreenDoor=screenDoor resetState(screenDoor.lcbKey) func _on_close_requested() -> void: self.hide() $"../stationKeys".hide() ## 旋钮的状态枚举 enum KNOB_STATE{ ISOLATE,# 隔离 AUTO,# 自动 OPEN,# 开门 CLOSE,# 关门 } @onready var knob_state : KNOB_STATE = KNOB_STATE.AUTO : set(value): knob_state = value func change_knob_state(state): knob_state = state currenScreenDoor.lcbKey.keyState = knob_state if knob_state==KNOB_STATE.OPEN: currenScreenDoor.openScreenDoor(true) elif knob_state==KNOB_STATE.CLOSE: currenScreenDoor.closeScreenDoor(true) ##展示控制的钥匙 func shouHandleKey(keyName:String): currenScreenDoor.lcbKey.keyName = keyName $TextureRect2.visible=true $LCB2_Right_Rotate.visible=true $LCB2_Left_Rotate.visible=true ##隐藏控制的钥匙 func hideHandleKey(): $TextureRect2.visible=false $LCB2_Right_Rotate.visible=false $LCB2_Left_Rotate.visible=false ##重置面板 func resetState(lcbKey): if(lcbKey.keyName): shouHandleKey(currenScreenDoor.lcbKey.keyName) knob_state = lcbKey.keyState match lcbKey.keyState: KNOB_STATE.ISOLATE: $TextureRect2.rotation = -PI*62/180 KNOB_STATE.AUTO: $TextureRect2.rotation = 0 KNOB_STATE.CLOSE: $TextureRect2.rotation = PI*59/180 KNOB_STATE.OPEN: $TextureRect2.rotation = PI/2 else: change_knob_state(KNOB_STATE.AUTO) $TextureRect2.rotation = 0 hideHandleKey() ##打开钥匙盒相关 func _on_open_key_window_gui_input(event: InputEvent) -> void: if event.button_mask == MouseButtonMask.MOUSE_BUTTON_MASK_LEFT: $"../stationKeys".onShowWindow(StationKeyWindow.WindowType.LCB,currenScreenDoor.lcbKey.keyName) func _on_open_key_window_mouse_entered() -> void: $openKeyWindow.set_default_cursor_shape(Control.CursorShape.CURSOR_POINTING_HAND) func _on_open_key_window_mouse_exited() -> void: $openKeyWindow.set_default_cursor_shape(Control.CursorShape.CURSOR_ARROW) ##拔钥匙相关 func _on_texture_rect_2_gui_input(event: InputEvent) -> void: if event.button_mask == MouseButtonMask.MOUSE_BUTTON_MASK_LEFT: allClickLCBSignal.emit('removeKeyOfWindow'+self.title,$".") if !allowHandle : return hideHandleKey() $"../stationKeys".showKeyAfterRemoveKey(currenScreenDoor.lcbKey.keyName) currenScreenDoor.lcbKey.keyName = '' func _on_texture_rect_2_mouse_entered() -> void: $TextureRect2.set_default_cursor_shape(Control.CursorShape.CURSOR_POINTING_HAND) func _on_texture_rect_2_mouse_exited() -> void: $TextureRect2.set_default_cursor_shape(Control.CursorShape.CURSOR_ARROW) ##所有LCB点击操作汇总 signal allClickLCBSignal(equipmentName:String,equipmentInfo)