From 3ea7f0eeb957e1a49efeb3fe26d1ba99e7a3cdf3 Mon Sep 17 00:00:00 2001 From: TsubakiLoL <2789646812@qq.com> Date: Mon, 16 Dec 2024 11:19:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=89=E9=92=AE=E9=97=AA=E7=83=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Robo-Bus-A31-HMI/Modules/language_tabs.gd | 2 +- Robo-Bus-A31-HMI/Modules/setting.tscn | 5 --- Robo-Bus-A31-HMI/Modules/settingButtonItem.gd | 36 +++++++++++++++++-- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/Robo-Bus-A31-HMI/Modules/language_tabs.gd b/Robo-Bus-A31-HMI/Modules/language_tabs.gd index dae18da..73d9bd8 100644 --- a/Robo-Bus-A31-HMI/Modules/language_tabs.gd +++ b/Robo-Bus-A31-HMI/Modules/language_tabs.gd @@ -30,7 +30,7 @@ func _ready() -> void: if !OnClickIsCooling: SelectNode = _node OnClickIsCooling = true - Onclick.emit(_node.index) + Onclick.emit(_node.get_index()) ) pass # Replace with function body. diff --git a/Robo-Bus-A31-HMI/Modules/setting.tscn b/Robo-Bus-A31-HMI/Modules/setting.tscn index b0fe252..bdc90a2 100644 --- a/Robo-Bus-A31-HMI/Modules/setting.tscn +++ b/Robo-Bus-A31-HMI/Modules/setting.tscn @@ -110,7 +110,6 @@ script = ExtResource("10_jyc6b") TextureNormal = ExtResource("3_t55mh") TexturePressed = ExtResource("3_r83c5") styleBox = SubResource("StyleBoxTexture_bqmim") -is_Scale = true [node name="TextureRect" type="TextureRect" parent="HBoxContainer/margin/VBoxContainer/GridContainer/Record"] custom_minimum_size = Vector2(74, 74) @@ -147,7 +146,6 @@ script = ExtResource("10_jyc6b") TextureNormal = ExtResource("6_q5g71") TexturePressed = ExtResource("7_3wr4h") styleBox = SubResource("StyleBoxTexture_bqmim") -is_Scale = true [node name="TextureRect" type="TextureRect" parent="HBoxContainer/margin/VBoxContainer/GridContainer/Build"] custom_minimum_size = Vector2(74, 74) @@ -185,7 +183,6 @@ script = ExtResource("10_jyc6b") TextureNormal = ExtResource("8_0e4lg") TexturePressed = ExtResource("9_gdew3") styleBox = SubResource("StyleBoxTexture_bqmim") -is_Scale = true [node name="TextureRect" type="TextureRect" parent="HBoxContainer/margin/VBoxContainer/GridContainer/Export"] custom_minimum_size = Vector2(74, 74) @@ -237,7 +234,6 @@ script = ExtResource("10_jyc6b") TextureNormal = ExtResource("11_px13j") TexturePressed = ExtResource("12_ljpgt") styleBox = SubResource("StyleBoxTexture_bqmim") -is_Scale = true [node name="TextureRect" type="TextureRect" parent="HBoxContainer/margin/VBoxContainer/GridContainer/Download"] custom_minimum_size = Vector2(74, 74) @@ -275,7 +271,6 @@ script = ExtResource("10_jyc6b") TextureNormal = ExtResource("13_8lrx3") TexturePressed = ExtResource("15_f66s7") styleBox = SubResource("StyleBoxTexture_bqmim") -is_Scale = true [node name="TextureRect" type="TextureRect" parent="HBoxContainer/margin/VBoxContainer/GridContainer/Upload"] custom_minimum_size = Vector2(74, 74) diff --git a/Robo-Bus-A31-HMI/Modules/settingButtonItem.gd b/Robo-Bus-A31-HMI/Modules/settingButtonItem.gd index 11f1551..9230f9a 100644 --- a/Robo-Bus-A31-HMI/Modules/settingButtonItem.gd +++ b/Robo-Bus-A31-HMI/Modules/settingButtonItem.gd @@ -2,12 +2,14 @@ extends BaseControl @export var TextureNormal :Texture2D @export var TexturePressed : Texture2D - +#用来播放动画的tween +var animation_tween func _ready() -> void: super._ready() self.button_down.connect(_on_button_down) self.button_up.connect(_on_button_up) + self.on_click.connect(_on_click) $TextureRect.texture=TextureNormal self.flat=true @@ -22,4 +24,34 @@ func _on_button_up() -> void: $TextureRect.texture=TextureNormal pass # Replace with function body. -var is_selected +var is_select:bool: + set(value): + + if is_select!=value: + if value: + if animation_tween!=null: + animation_tween.kill() + animation_tween=create_tween() + animation_tween.tween_callback(set_texture.bind(TexturePressed)).set_delay(0.15) + animation_tween.tween_callback(set_texture.bind(TextureNormal)).set_delay(0.15) + animation_tween.tween_callback(set_texture.bind(TexturePressed)).set_delay(0.15) + animation_tween.tween_callback(set_texture.bind(TextureNormal)).set_delay(0.15) + animation_tween.tween_callback(set_texture.bind(TexturePressed)).set_delay(0.15) + else: + if animation_tween!=null: + animation_tween.kill() + animation_tween=null + set_texture(TextureNormal) + pass + + is_select=value + + +func set_texture(texture:Texture2D): + $TextureRect.texture=texture + +func _on_click(node): + is_select=not is_select + + + pass