aboutsummaryrefslogtreecommitdiff
path: root/client/menu/controller_buttons
diff options
context:
space:
mode:
Diffstat (limited to 'client/menu/controller_buttons')
-rw-r--r--client/menu/controller_buttons/a.svg6
-rw-r--r--client/menu/controller_buttons/a.svg.import37
-rw-r--r--client/menu/controller_buttons/controller_button.gd39
-rw-r--r--client/menu/controller_buttons/controller_button.tscn9
4 files changed, 91 insertions, 0 deletions
diff --git a/client/menu/controller_buttons/a.svg b/client/menu/controller_buttons/a.svg
new file mode 100644
index 00000000..3b660d91
--- /dev/null
+++ b/client/menu/controller_buttons/a.svg
@@ -0,0 +1,6 @@
+<svg width="64" height="64" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <defs/>
+ <g>
+ <path stroke="none" fill="#7DB700" d="M56 32 Q56 42 48.95 48.95 42 56 32 56 22.05 56 15 48.95 8 42 8 32 8 22.05 15 15 22.05 8 32 8 42 8 48.95 15 56 22.05 56 32 M38 42 L42 42 34 22 30 22 22 42 26 42 27.6 38 36.4 38 38 42 M32 27 L34.8 34 29.2 34 32 27"/>
+ </g>
+</svg> \ No newline at end of file
diff --git a/client/menu/controller_buttons/a.svg.import b/client/menu/controller_buttons/a.svg.import
new file mode 100644
index 00000000..236e085f
--- /dev/null
+++ b/client/menu/controller_buttons/a.svg.import
@@ -0,0 +1,37 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://bgkhnp15u1utp"
+path="res://.godot/imported/a.svg-207eeddefe74f1190424a9aa1808de8f.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://menu/controller_buttons/a.svg"
+dest_files=["res://.godot/imported/a.svg-207eeddefe74f1190424a9aa1808de8f.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1
+svg/scale=1.0
+editor/scale_with_editor_scale=false
+editor/convert_colors_with_editor_theme=false
diff --git a/client/menu/controller_buttons/controller_button.gd b/client/menu/controller_buttons/controller_button.gd
new file mode 100644
index 00000000..4fa70b5a
--- /dev/null
+++ b/client/menu/controller_buttons/controller_button.gd
@@ -0,0 +1,39 @@
+# Undercooked - a game about cooking
+# Copyright 2024 tpart
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, version 3 of the License only.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+#
+
+extends Button
+class_name ControllerButton
+
+@export var controller_texture: Texture2D
+@export var press_action: String
+
+func _ready():
+ set_texture_enabled(Global.using_joypad)
+ Global.using_joypad_change.connect(set_texture_enabled)
+
+func _input(event):
+ if press_action == null:
+ return
+ if not is_visible_in_tree():
+ return
+ if Input.is_action_just_pressed(press_action):
+ pressed.emit()
+
+func set_texture_enabled(b: bool):
+ if b:
+ icon = controller_texture
+ else:
+ icon = null
diff --git a/client/menu/controller_buttons/controller_button.tscn b/client/menu/controller_buttons/controller_button.tscn
new file mode 100644
index 00000000..c5d745ba
--- /dev/null
+++ b/client/menu/controller_buttons/controller_button.tscn
@@ -0,0 +1,9 @@
+[gd_scene load_steps=2 format=3 uid="uid://b1f7bgn65j7b5"]
+
+[ext_resource type="Script" path="res://menu/controller_buttons/controller_button.gd" id="1_p2m8i"]
+
+[node name="ControllerButton" type="Button"]
+offset_right = 8.0
+offset_bottom = 8.0
+focus_mode = 0
+script = ExtResource("1_p2m8i")