45 lines
974 B
GDScript
45 lines
974 B
GDScript
extends VBoxContainer
|
|
|
|
@export var keySwitchHasKey:bool
|
|
|
|
@export var lightText:String
|
|
|
|
@export var keyText:String
|
|
|
|
|
|
signal clickKeySwitchSignal(openLight:bool,keySwitch)
|
|
|
|
signal removeKey(keyName)
|
|
|
|
func _ready() -> void:
|
|
$Light/MarginContainer/Label.text=lightText
|
|
if keySwitchHasKey:
|
|
$Key.visible = true
|
|
$Key/MarginContainer/Label.text=keyText
|
|
else:
|
|
$Key.visible = false
|
|
|
|
|
|
func shouHandleKey() -> void:
|
|
$Key/Key.visible = true
|
|
$Key/Right_Rotate.visible = true
|
|
|
|
func hideHandleKey() -> void:
|
|
$Key/Key.visible = false
|
|
$Key/Right_Rotate.visible = false
|
|
|
|
|
|
##拔钥匙相关
|
|
func _on_key_gui_input(event: InputEvent) -> void:
|
|
if event.button_mask == MouseButtonMask.MOUSE_BUTTON_MASK_LEFT:
|
|
removeKey.emit(self.name)
|
|
hideHandleKey()
|
|
|
|
|
|
func _on_key_mouse_entered() -> void:
|
|
$Key/Key.set_default_cursor_shape(Control.CursorShape.CURSOR_POINTING_HAND)
|
|
|
|
|
|
func _on_key_mouse_exited() -> void:
|
|
$Key/Key.set_default_cursor_shape(Control.CursorShape.CURSOR_ARROW)
|