-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add primary and secondary interactions (#209)
- Loading branch information
Showing
4 changed files
with
136 additions
and
19 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
godot/src/ui/components/button_touch_action/button_touch_action.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
@tool | ||
extends TextureButton | ||
|
||
@export var text_color = Color.WHITE: | ||
set(new_value): | ||
$Label.add_theme_color_override("font_color", new_value) | ||
text_color = new_value | ||
|
||
@export var text_letter = "E": | ||
set(new_value): | ||
$Label.text = new_value | ||
text_letter = new_value | ||
|
||
@export var trigger_action = "ia_primary" | ||
|
||
|
||
func _on_button_down(): | ||
Input.action_press(trigger_action) | ||
|
||
|
||
func _on_button_up(): | ||
Input.action_release(trigger_action) |
74 changes: 74 additions & 0 deletions
74
godot/src/ui/components/button_touch_action/button_touch_action.tscn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
[gd_scene load_steps=4 format=3 uid="uid://nn0iih4xpn2e"] | ||
|
||
[ext_resource type="Texture2D" uid="uid://dnenlhbcgxgph" path="res://assets/themes/dark_dcl_theme/icons/Ellipse.svg" id="1_57o7r"] | ||
[ext_resource type="Script" path="res://src/ui/components/button_touch_action/button_touch_action.gd" id="2_c0jk1"] | ||
[ext_resource type="FontFile" uid="uid://ckaye4autekyg" path="res://assets/themes/fonts/inter/Inter-ExtraBold.ttf" id="2_h4q5h"] | ||
|
||
[node name="Button_TouchAction" type="TextureButton"] | ||
modulate = Color(1, 1, 1, 0.501961) | ||
offset_right = 80.0 | ||
offset_bottom = 80.0 | ||
texture_normal = ExtResource("1_57o7r") | ||
ignore_texture_size = true | ||
stretch_mode = 4 | ||
script = ExtResource("2_c0jk1") | ||
|
||
[node name="ShadowOutter" type="TextureRect" parent="."] | ||
self_modulate = Color(0, 0, 0, 1) | ||
show_behind_parent = true | ||
layout_mode = 1 | ||
anchors_preset = 3 | ||
anchor_left = 1.0 | ||
anchor_top = 1.0 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
offset_left = -82.0 | ||
offset_top = -82.0 | ||
offset_right = 2.0 | ||
offset_bottom = 2.0 | ||
grow_horizontal = 0 | ||
grow_vertical = 0 | ||
mouse_filter = 2 | ||
texture = ExtResource("1_57o7r") | ||
expand_mode = 1 | ||
stretch_mode = 4 | ||
|
||
[node name="ShadowInner" type="TextureRect" parent="."] | ||
self_modulate = Color(0, 0, 0, 1) | ||
show_behind_parent = true | ||
layout_mode = 1 | ||
anchors_preset = 3 | ||
anchor_left = 1.0 | ||
anchor_top = 1.0 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
offset_left = -78.0 | ||
offset_top = -78.0 | ||
offset_right = -2.0 | ||
offset_bottom = -2.0 | ||
grow_horizontal = 0 | ||
grow_vertical = 0 | ||
mouse_filter = 2 | ||
texture = ExtResource("1_57o7r") | ||
expand_mode = 1 | ||
stretch_mode = 4 | ||
|
||
[node name="Label" type="Label" parent="."] | ||
layout_mode = 1 | ||
anchors_preset = 15 | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
grow_horizontal = 2 | ||
grow_vertical = 2 | ||
theme_override_colors/font_color = Color(1, 1, 1, 1) | ||
theme_override_colors/font_shadow_color = Color(0, 0, 0, 1) | ||
theme_override_colors/font_outline_color = Color(0, 0, 0, 1) | ||
theme_override_constants/outline_size = 2 | ||
theme_override_fonts/font = ExtResource("2_h4q5h") | ||
theme_override_font_sizes/font_size = 32 | ||
text = "E" | ||
horizontal_alignment = 1 | ||
vertical_alignment = 1 | ||
|
||
[connection signal="button_down" from="." to="." method="_on_button_down"] | ||
[connection signal="button_up" from="." to="." method="_on_button_up"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters