Доработка. Подсказка теперь отображает состояние включено/отключено
This commit is contained in:
@@ -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
|
||||
|
||||
17
scripts/switch.gd
Normal file
17
scripts/switch.gd
Normal 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)
|
||||
Reference in New Issue
Block a user