diff --git a/scenes/pribor-uyep/sch3.tscn b/scenes/pribor-uyep/sch3.tscn index 72dd4c05..da34fc03 100644 --- a/scenes/pribor-uyep/sch3.tscn +++ b/scenes/pribor-uyep/sch3.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=3 uid="uid://dlkvu6bp6w5u7"] +[gd_scene load_steps=11 format=3 uid="uid://dlkvu6bp6w5u7"] [ext_resource type="Script" path="res://scenes/pribor-uyep/sch3-view.gd" id="1_ln7ac"] [ext_resource type="Texture2D" uid="uid://c6nve6f8sfyj2" path="res://data/состояние-исправности-0.png" id="2_ln52a"] @@ -6,6 +6,7 @@ [ext_resource type="Texture2D" uid="uid://c6booa8753u5t" path="res://data/состояние-исправности-2.png" id="4_nijdy"] [ext_resource type="Texture2D" uid="uid://c4mdrmk7h638f" path="res://data/nine-patch-round.png" id="5_skqdl"] [ext_resource type="Shader" path="res://shaders/color-invers.gdshader" id="6_ypnlb"] +[ext_resource type="Script" path="res://scripts/switch.gd" id="7_l6esm"] [sub_resource type="GDScript" id="GDScript_45hqb"] script/source = "@tool diff --git a/scripts/switch.gd b/scripts/switch.gd new file mode 100644 index 00000000..10710372 --- /dev/null +++ b/scripts/switch.gd @@ -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)