From 8252ff66b85bb0501eb8dc51f4e34ac55f022f3e Mon Sep 17 00:00:00 2001 From: Haze Weathers Date: Mon, 9 Dec 2024 14:50:19 -0500 Subject: [PATCH] level select menu indicator --- autoloads/scene_manager.gd | 8 ++++++ menus/level_select_scholar.tscn | 39 ++++++++++++++++++++++++++- objects/hud/gamepad_buttons.atlastex | Bin 238 -> 238 bytes scripts/show_button.gd | 22 +++++++++++++++ 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 scripts/show_button.gd diff --git a/autoloads/scene_manager.gd b/autoloads/scene_manager.gd index ea1b353..f6c8a67 100644 --- a/autoloads/scene_manager.gd +++ b/autoloads/scene_manager.gd @@ -19,6 +19,14 @@ var resolution: Vector2 var current_scene: Node setget change_scene +var last_input_gamepad: bool = true + +func _input(event: InputEvent) -> void: + if event is InputEventJoypadButton: + last_input_gamepad = true + elif event is InputEventKey: + last_input_gamepad = false + ## change the current scene func change_scene(new_scene: Node) -> void: # remove current scene if it exists diff --git a/menus/level_select_scholar.tscn b/menus/level_select_scholar.tscn index 8af7178..d7c178b 100644 --- a/menus/level_select_scholar.tscn +++ b/menus/level_select_scholar.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=53 format=2] +[gd_scene load_steps=56 format=2] [ext_resource path="res://menus/level_select_scholar.gd" type="Script" id=1] [ext_resource path="res://graphics/level_select/world_map.png" type="Texture" id=2] @@ -21,6 +21,8 @@ [ext_resource path="res://objects/hud/menu_sounds.tscn" type="PackedScene" id=19] [ext_resource path="res://scripts/randomize_particle_start.gd" type="Script" id=20] [ext_resource path="res://graphics/particles/shine.png" type="Texture" id=21] +[ext_resource path="res://graphics/hud/gamepad_buttons.png" type="Texture" id=22] +[ext_resource path="res://scripts/show_button.gd" type="Script" id=23] [sub_resource type="AtlasTexture" id=33] atlas = ExtResource( 15 ) @@ -952,6 +954,11 @@ tracks/1/keys = { "values": [ Vector2( 0, 0.02 ), Vector2( 1, 0.02 ), Vector2( 1, 1 ) ] } +[sub_resource type="AtlasTexture" id=37] +resource_local_to_scene = true +atlas = ExtResource( 22 ) +region = Rect2( 0, 0, 12, 10 ) + [node name="LevelSelect" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 @@ -1469,6 +1476,36 @@ theme = ExtResource( 4 ) custom_fonts/font = ExtResource( 12 ) text = "72" +[node name="MenuIndicator" type="HBoxContainer" parent="."] +margin_left = 3.0 +margin_top = 23.0 +margin_right = 47.0 +margin_bottom = 33.0 +custom_constants/separation = 2 +script = ExtResource( 23 ) +action = "ui_cancel" + +[node name="Label" type="Label" parent="MenuIndicator"] +margin_right = 35.0 +margin_bottom = 10.0 +custom_fonts/font = ExtResource( 12 ) +text = "Menu:" + +[node name="KeyboardButton" type="Label" parent="MenuIndicator"] +margin_left = 37.0 +margin_right = 44.0 +margin_bottom = 10.0 +custom_fonts/font = ExtResource( 12 ) +text = "X" + +[node name="GamepadButton" type="TextureRect" parent="MenuIndicator"] +visible = false +margin_left = 46.0 +margin_right = 58.0 +margin_bottom = 10.0 +size_flags_vertical = 4 +texture = SubResource( 37 ) + [node name="Shard" parent="." instance=ExtResource( 11 )] position = Vector2( 4, 5 ) diff --git a/objects/hud/gamepad_buttons.atlastex b/objects/hud/gamepad_buttons.atlastex index 328c5d18266ca7d3097309658bda27d39fb99c49..d9d5e079b3d67329e5edbebd2e4308cf0305b3e7 100644 GIT binary patch delta 173 zcmV;e08;<%0qy~i9)FTbA|XJhRtEr0P~A<$v{v$@crCdcSGUz%lsHEX-a*gC`_L%? zi~zGV{srKP{{`hIB+R4jUR%(>2YV614|dN+IT{yImYn${UhRo0SxOOh4BoNH#j&}i zoqVGE+yekUqxu?P3L6IbG1HU2;NR`Cs{u_zue1(GIY>Uj8o(|C2u& bk*+TkYsqt%E9WQo7AMzA)&sx-Qd2`io void: + if SceneManager.last_input_gamepad: + keyboard_button.visible = false + gamepad_button.visible = true + var button = Controls.get_button(action) + if button >= 0: + gamepad_button.texture.region.position.x = float(button % 8) * 12.0 + gamepad_button.texture.region.position.y = float(button / 8) * 10.0 + else: + keyboard_button.visible = true + gamepad_button.visible = false + keyboard_button.text = OS.get_scancode_string(Controls.get_key(action))