forked from team-sg/hero-mark-2
gamepad buttons
This commit is contained in:
parent
35b757cd22
commit
85a331ed37
5 changed files with 51 additions and 6 deletions
BIN
graphics/hud/gamepad_buttons.png
Normal file
BIN
graphics/hud/gamepad_buttons.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
35
graphics/hud/gamepad_buttons.png.import
Normal file
35
graphics/hud/gamepad_buttons.png.import
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/gamepad_buttons.png-2be301e9c2e67e54b73d3d64156de301.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://graphics/hud/gamepad_buttons.png"
|
||||||
|
dest_files=[ "res://.import/gamepad_buttons.png-2be301e9c2e67e54b73d3d64156de301.stex" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_mode=0
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
flags/repeat=0
|
||||||
|
flags/filter=false
|
||||||
|
flags/mipmaps=false
|
||||||
|
flags/anisotropic=false
|
||||||
|
flags/srgb=2
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/invert_color=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=true
|
||||||
|
svg/scale=1.0
|
BIN
objects/hud/gamepad_buttons.atlastex
Normal file
BIN
objects/hud/gamepad_buttons.atlastex
Normal file
Binary file not shown.
|
@ -83,11 +83,12 @@ margin_bottom = 32.0
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
margin_top = 36.0
|
margin_top = 36.0
|
||||||
margin_right = 218.0
|
margin_right = 218.0
|
||||||
margin_bottom = 64.0
|
margin_bottom = 146.0
|
||||||
focus_mode = 2
|
focus_mode = 2
|
||||||
tabs_visible = false
|
tabs_visible = false
|
||||||
|
|
||||||
[node name="Game" type="VBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs"]
|
[node name="Game" type="VBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs"]
|
||||||
|
visible = false
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
focus_next = NodePath("Rumble/SelectRumble")
|
focus_next = NodePath("Rumble/SelectRumble")
|
||||||
|
@ -446,7 +447,6 @@ script = ExtResource( 3 )
|
||||||
options = [ "off", "on" ]
|
options = [ "off", "on" ]
|
||||||
|
|
||||||
[node name="Input" type="VBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs"]
|
[node name="Input" type="VBoxContainer" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs"]
|
||||||
visible = false
|
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
focus_next = NodePath("Left/Keyboard")
|
focus_next = NodePath("Left/Keyboard")
|
||||||
|
@ -509,6 +509,7 @@ margin_right = 218.0
|
||||||
margin_bottom = 10.0
|
margin_bottom = 10.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
text = "-"
|
text = "-"
|
||||||
|
icon_align = 1
|
||||||
script = ExtResource( 9 )
|
script = ExtResource( 9 )
|
||||||
action = "move_left"
|
action = "move_left"
|
||||||
options_screen = NodePath("../../../../../../../..")
|
options_screen = NodePath("../../../../../../../..")
|
||||||
|
@ -675,9 +676,9 @@ options_screen = NodePath("../../../../../../../..")
|
||||||
|
|
||||||
[node name="DefaultControls" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input"]
|
[node name="DefaultControls" type="Button" parent="CenterContainer/PanelContainer/MarginContainer/VBoxContainer/Tabs/Input"]
|
||||||
margin_left = 81.0
|
margin_left = 81.0
|
||||||
margin_top = 32.0
|
margin_top = 100.0
|
||||||
margin_right = 137.0
|
margin_right = 137.0
|
||||||
margin_bottom = 42.0
|
margin_bottom = 110.0
|
||||||
size_flags_horizontal = 4
|
size_flags_horizontal = 4
|
||||||
text = "defaults"
|
text = "defaults"
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,18 @@ extends Button
|
||||||
|
|
||||||
|
|
||||||
const BLINK_SPEED: int = 150
|
const BLINK_SPEED: int = 150
|
||||||
|
const GAMEPAD_BUTTONS: AtlasTexture = preload("res://objects/hud/gamepad_buttons.atlastex")
|
||||||
|
|
||||||
export var action: String
|
export var action: String
|
||||||
export var options_screen: NodePath
|
export var options_screen: NodePath
|
||||||
|
|
||||||
|
|
||||||
var listen := false
|
var listen := false
|
||||||
|
var gamepad_buttons := GAMEPAD_BUTTONS.duplicate()
|
||||||
|
|
||||||
|
|
||||||
func _init() -> void:
|
func _init() -> void:
|
||||||
|
icon_align = Button.ALIGN_CENTER
|
||||||
connect("pressed", self, "_on_pressed")
|
connect("pressed", self, "_on_pressed")
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +30,14 @@ func _process(delta: float) -> void:
|
||||||
|
|
||||||
|
|
||||||
func _update_text() -> void:
|
func _update_text() -> void:
|
||||||
text = str(Controls.get_button(action))
|
var button = Controls.get_button(action)
|
||||||
|
if button >= 0:
|
||||||
|
gamepad_buttons.region.position.x = float(button % 8) * 12.0
|
||||||
|
gamepad_buttons.region.position.y = float(button / 8) * 10.0
|
||||||
|
icon = gamepad_buttons
|
||||||
|
text = ""
|
||||||
|
else:
|
||||||
|
text = "-"
|
||||||
modulate.a = 1.0
|
modulate.a = 1.0
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue