level select menu indicator
This commit is contained in:
parent
93656bdcfa
commit
8252ff66b8
4 changed files with 68 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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 )
|
||||
|
||||
|
|
Binary file not shown.
22
scripts/show_button.gd
Normal file
22
scripts/show_button.gd
Normal file
|
@ -0,0 +1,22 @@
|
|||
extends Control
|
||||
|
||||
|
||||
export var action: String
|
||||
|
||||
|
||||
onready var keyboard_button: Label = $KeyboardButton
|
||||
onready var gamepad_button: TextureRect = $GamepadButton
|
||||
|
||||
|
||||
func _process(delta: float) -> 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))
|
Loading…
Add table
Add a link
Reference in a new issue