Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add primary and secondary interactions #209

Merged
merged 2 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions godot/src/ui/components/button_touch_action/button_touch_action.gd
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)
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"]
11 changes: 2 additions & 9 deletions godot/src/ui/components/pointer_tooltip/tooltip_label.gd
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,10 @@ func set_tooltip_data(text_pet_down: String, text_pet_up, action: String):
elif index != -1:
var event = InputMap.action_get_events(InputMap.get_actions()[index])[0]
if event is InputEventKey:
key = (
(
icon_interactive_pointer as Variant
if Global.is_mobile()
else char(event.unicode).to_upper()
)
as Variant
)
key = char(event.unicode).to_upper()
elif event is InputEventMouseButton:
if event.button_index == 1:
key = icon_left_click
key = icon_interactive_pointer if Global.is_mobile() else icon_left_click

if key != null:
show()
Expand Down
48 changes: 38 additions & 10 deletions godot/src/ui/explorer.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=23 format=3 uid="uid://deq5v42fmh0y7"]
[gd_scene load_steps=24 format=3 uid="uid://deq5v42fmh0y7"]

[ext_resource type="Script" path="res://src/ui/explorer.gd" id="1_5n8xk"]
[ext_resource type="Texture2D" uid="uid://by286h7kaeqr3" path="res://assets/empty-scenes/Floor_Grass.png" id="2_7jksa"]
Expand All @@ -7,6 +7,7 @@
[ext_resource type="PackedScene" uid="uid://cul43nr1eb422" path="res://src/ui/components/minimap/minimap.tscn" id="4_6aqla"]
[ext_resource type="Script" path="res://src/ui/components/safe_margin_container/safe_margin_container.gd" id="5_c8ksg"]
[ext_resource type="PackedScene" uid="uid://co44hxd7jbcjs" path="res://src/ui/components/menu/menu.tscn" id="5_mso44"]
[ext_resource type="PackedScene" uid="uid://nn0iih4xpn2e" path="res://src/ui/components/button_touch_action/button_touch_action.tscn" id="7_oofwd"]
[ext_resource type="Texture2D" uid="uid://v1avum5r3l4s" path="res://assets/themes/dark_dcl_theme/icons/JumpButton.svg" id="8_ttlm2"]
[ext_resource type="PackedScene" uid="uid://bl6h58asl377" path="res://src/ui/components/chat/chat.tscn" id="9_4ktln"]
[ext_resource type="Texture2D" uid="uid://c5h83d44qsbhr" path="res://assets/themes/dark_dcl_theme/icons/Chat.svg" id="9_hj43f"]
Expand Down Expand Up @@ -90,6 +91,36 @@ grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2

[node name="Button_PrimaryAction" parent="UI/SafeMarginContainer/InteractableHUD/MobileUI" instance=ExtResource("7_oofwd")]
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -216.0
offset_top = -277.0
offset_right = -136.0
offset_bottom = -197.0
grow_horizontal = 0
grow_vertical = 0

[node name="Button_SecondaryAction" parent="UI/SafeMarginContainer/InteractableHUD/MobileUI" instance=ExtResource("7_oofwd")]
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -274.0
offset_top = -201.0
offset_right = -194.0
offset_bottom = -121.0
grow_horizontal = 0
grow_vertical = 0
text_letter = "F"
trigger_action = "ia_secondary"

[node name="Button_Jump" type="TextureButton" parent="UI/SafeMarginContainer/InteractableHUD/MobileUI"]
modulate = Color(1, 1, 1, 0.501961)
layout_mode = 1
Expand Down Expand Up @@ -213,20 +244,17 @@ offset_bottom = 390.0
[node name="Label_FPS" type="Label" parent="UI/SafeMarginContainer/InteractableHUD"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -173.0
offset_top = 3.0
offset_right = -20.0
offset_bottom = 18.0
grow_horizontal = 0
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_top = -15.0
offset_right = 153.0
grow_vertical = 0
theme_override_colors/font_color = Color(1, 1, 1, 0.705882)
theme_override_colors/font_outline_color = Color(0.501961, 0.501961, 0.501961, 0.705882)
theme_override_constants/outline_size = 4
theme_override_font_sizes/font_size = 12
text = "ALPHA - FPS"
horizontal_alignment = 2

[node name="Label_RAM" type="Label" parent="UI/SafeMarginContainer/InteractableHUD"]
unique_name_in_owner = true
Expand Down
Loading