Доработка. Подсказка теперь отображает состояние включено/отключено

This commit is contained in:
sasha80
2024-11-22 09:34:50 +03:00
parent 835b42942a
commit d214e3d4cf
2 changed files with 19 additions and 1 deletions

17
scripts/switch.gd Normal file
View File

@@ -0,0 +1,17 @@
extends CheckButton
@export var off_tip: String = '(отключено)'
@export var on_tip: String = '(включено)'
func _ready() -> void:
if not (tooltip_text.contains(off_tip) or tooltip_text.contains(on_tip)):
tooltip_text += ' '
tooltip_text += on_tip if button_pressed else off_tip
connect('toggled', _on_toggled)
func _on_toggled(state: bool):
var s = tooltip_text
tooltip_text = s.replace(off_tip, on_tip) if state else s.replace(on_tip, off_tip)