gamepad detect

This commit is contained in:
Page Asgardius 2024-09-07 09:25:58 -07:00
parent 9ceb77e2f9
commit 4cd9cd4925
21 changed files with 144 additions and 13 deletions

View file

@ -1,10 +1,14 @@
extends Node2D
var presscontinue
const gamepadtest = preload("res://gamepad.gd")
var rmusic := AudioStreamPlayer.new()
var wait
# Called when the node enters the scene tree for the first time.
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
presscontinue = $Label2
updatehud()
#Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
add_child(rmusic)
var titlemusic = load(Global.musictracks[1])
rmusic.stream = titlemusic
@ -20,6 +24,8 @@ func _process(delta):
pass
func _input(event):
gamepadtest.new(event)
updatehud()
# Mouse in viewport coordinates.
if Input.is_action_just_pressed("ui_accept"):
#print("Mouse Click/Unclick at: ", event.position)
@ -36,3 +42,13 @@ func _title():
#get_tree().root.add_child(title)
#get_tree().root.remove_child(boot)
#boot.queue_free()
func updatehud():
if Global.gamepad == 0:
presscontinue.set_text(tr("TEXT_CONTINUE_KB"))
elif Global.gamepad == 1:
presscontinue.set_text(tr("TEXT_CONTINUE_US"))
elif Global.gamepad == 2:
presscontinue.set_text(tr("TEXT_CONTINUE_JA"))
elif Global.gamepad == 3:
presscontinue.set_text(tr("TEXT_CONTINUE_GEO"))

View file

@ -1,9 +1,12 @@
extends Node2D
var presscontinue
var rmusic := AudioStreamPlayer.new()
var wait
# Called when the node enters the scene tree for the first time.
func _ready():
presscontinue = $Label2
updatehud()
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
add_child(rmusic)
var titlemusic = load(Global.musictracks[7])
@ -19,6 +22,7 @@ func _process(delta):
pass
func _input(event):
updatehud()
# Mouse in viewport coordinates.
if Input.is_action_just_pressed("ui_accept"):
#print("Mouse Click/Unclick at: ", event.position)
@ -34,3 +38,13 @@ func _title():
#get_tree().root.add_child(title)
#get_tree().root.remove_child(boot)
#boot.queue_free()
func updatehud():
if Global.gamepad == 0:
presscontinue.set_text(tr("TEXT_CONTINUE_KB"))
elif Global.gamepad == 1:
presscontinue.set_text(tr("TEXT_CONTINUE_US"))
elif Global.gamepad == 2:
presscontinue.set_text(tr("TEXT_CONTINUE_JA"))
elif Global.gamepad == 3:
presscontinue.set_text(tr("TEXT_CONTINUE_GEO"))

View file

@ -1,10 +1,13 @@
extends Node2D
var presscontinue
var rmusic := AudioStreamPlayer.new()
var wait
# Called when the node enters the scene tree for the first time.
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
presscontinue = $Label2
updatehud()
#Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
add_child(rmusic)
var titlemusic = load(Global.musictracks[1])
rmusic.stream = titlemusic
@ -19,6 +22,7 @@ func _process(delta):
pass
func _input(event):
updatehud()
# Mouse in viewport coordinates.
if Input.is_action_just_pressed("ui_accept"):
#print("Mouse Click/Unclick at: ", event.position)
@ -34,3 +38,13 @@ func _title():
#get_tree().root.add_child(title)
#get_tree().root.remove_child(boot)
#boot.queue_free()
func updatehud():
if Global.gamepad == 0:
presscontinue.set_text(tr("TEXT_CONTINUE_KB"))
elif Global.gamepad == 1:
presscontinue.set_text(tr("TEXT_CONTINUE_US"))
elif Global.gamepad == 2:
presscontinue.set_text(tr("TEXT_CONTINUE_JA"))
elif Global.gamepad == 3:
presscontinue.set_text(tr("TEXT_CONTINUE_GEO"))

View file

@ -7,7 +7,7 @@ func _init(event):
Global.gamepad = 2
elif str(Input.get_joy_name(0)).begins_with("Sony Computer Entertainment") || str(Input.get_joy_name(0)).begins_with("PS4") || str(Input.get_joy_name(0)).begins_with("PS5"):
Global.gamepad = 3
elif Global.gamepad == 0 && str(Input.get_joy_name(0)).is_empty():
elif !str(Input.get_joy_name(0)).is_empty():
Global.gamepad = 1
if event is InputEventMouse:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)

View file

@ -1,4 +1,5 @@
extends Control
const gamepadtest = preload("res://gamepad.gd")
var bgsound := AudioStreamPlayer.new()
var fl
var fr
@ -27,6 +28,7 @@ func _ready() -> void:
bgsound.play(0)
func _input(event):
gamepadtest.new(event)
# Mouse in viewport coordinates.
if Input.is_action_just_pressed("ui_cancel"):
get_tree().change_scene_to_file("res://levels/ui/soundtest.tscn")

View file

@ -1,6 +1,7 @@
extends Control
const gamepadtest = preload("res://gamepad.gd")
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
#Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
$VBoxContainer/L20.grab_focus()
# Called every frame. 'delta' is the elapsed time since the previous frame.
@ -24,6 +25,7 @@ func _level():
#boot.queue_free()
func _input(event):
gamepadtest.new(event)
# Mouse in viewport coordinates.
if Input.is_action_just_pressed("ui_cancel"):
_on_back_pressed()

View file

@ -1,6 +1,7 @@
extends Control
const gamepadtest = preload("res://gamepad.gd")
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
#Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
$"VBoxContainer/Disclaimer".grab_focus()
# Called every frame. 'delta' is the elapsed time since the previous frame.
@ -24,6 +25,7 @@ func _level():
#boot.queue_free()
func _input(event):
gamepadtest.new(event)
# Mouse in viewport coordinates.
if Input.is_action_just_pressed("ui_cancel"):
_on_back_pressed()

View file

@ -1,7 +1,8 @@
extends Control
const gamepadtest = preload("res://gamepad.gd")
func _ready():
_statrebase()
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
#Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
Global.debug = true
$"VBoxContainer/Gamepad Test".grab_focus()
@ -26,6 +27,7 @@ func _level():
#boot.queue_free()
func _input(event):
gamepadtest.new(event)
# Mouse in viewport coordinates.
if Input.is_action_just_pressed("ui_cancel"):
_on_back_pressed()

View file

@ -0,0 +1,27 @@
[gd_scene format=3 uid="uid://cbeya2ihapatq"]
[node name="Missinggamepad" type="Node2D"]
[node name="ColorRect" type="ColorRect" parent="."]
offset_left = 105.0
offset_top = 211.0
offset_right = 1177.0
offset_bottom = 511.0
color = Color(0, 0, 0, 1)
[node name="Label" type="Label" parent="."]
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = 105.0
offset_top = 211.0
offset_right = 1177.0
offset_bottom = 511.0
grow_horizontal = 2
grow_vertical = 2
theme_override_font_sizes/font_size = 40
text = "TEXT_GAMEPAD_DISCONNECTED"
horizontal_alignment = 1
vertical_alignment = 1

View file

@ -1,10 +1,11 @@
extends Control
const gamepadtest = preload("res://gamepad.gd")
var player := AudioStreamPlayer.new()
var infobox
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
#Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
add_child(player)
player.mix_target = 1
player.bus = &"Music"
@ -33,6 +34,7 @@ func _level():
#boot.queue_free()
func _input(event):
gamepadtest.new(event)
# Mouse in viewport coordinates.
if Input.is_action_just_pressed("ui_cancel"):
_on_back_pressed()

View file

@ -1,6 +1,7 @@
extends Control
const gamepadtest = preload("res://gamepad.gd")
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
#Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
$VBoxContainer/Thisfirst.grab_focus()
# Called every frame. 'delta' is the elapsed time since the previous frame.
@ -24,6 +25,7 @@ func _level():
#boot.queue_free()
func _input(event):
gamepadtest.new(event)
if Input.is_action_just_pressed("ui_cancel"):
get_tree().change_scene_to_file("res://levels/ui/tmenu.tscn")
# Mouse in viewport coordinates.

View file

@ -1,4 +1,5 @@
extends Control
const gamepadtest = preload("res://gamepad.gd")
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
$"VBoxContainer/Disclaimer".grab_focus()
@ -24,6 +25,7 @@ func _level():
#boot.queue_free()
func _input(event):
gamepadtest.new(event)
# Mouse in viewport coordinates.
if Input.is_action_just_pressed("ui_cancel"):
_on_back_pressed()

View file

@ -1,4 +1,5 @@
extends Control
const gamepadtest = preload("res://gamepad.gd")
var player := AudioStreamPlayer.new()
@ -31,6 +32,7 @@ func _level():
#boot.queue_free()
func _input(event):
gamepadtest.new(event)
# Mouse in viewport coordinates.
if Input.is_action_just_pressed("ui_cancel"):
_on_back_pressed()

View file

@ -1,7 +1,8 @@
extends Control
const gamepadtest = preload("res://gamepad.gd")
var alsatest
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
#Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
alsatest = $VBoxContainer/ALSA
$"VBoxContainer/Music".grab_focus()
if OS.get_name() == "Linux":
@ -13,6 +14,7 @@ func _process(delta):
func _input(event):
gamepadtest.new(event)
# Mouse in viewport coordinates.
if Input.is_action_just_pressed("ui_cancel"):
_on_back_pressed()

View file

@ -1,6 +1,7 @@
extends Control
const gamepadtest = preload("res://gamepad.gd")
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
#Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
$"VBoxContainer/Testspawn".grab_focus()
# Called every frame. 'delta' is the elapsed time since the previous frame.
@ -24,6 +25,7 @@ func _level():
#boot.queue_free()
func _input(event):
gamepadtest.new(event)
# Mouse in viewport coordinates.
if Input.is_action_just_pressed("ui_cancel"):
_on_back_pressed()

View file

@ -1,4 +1,5 @@
extends Control
const gamepadtest = preload("res://gamepad.gd")
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
$VBoxContainer/Start.grab_focus()
@ -24,6 +25,7 @@ func _level():
#boot.queue_free()
func _input(event):
gamepadtest.new(event)
if Input.is_action_just_pressed("ui_cancel"):
get_tree().change_scene_to_file("res://title.tscn")
# Mouse in viewport coordinates.

View file

@ -4,6 +4,7 @@ var stage = 0
var bg
# Called when the node enters the scene tree for the first time.
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
bg = $TextureRect
bg.texture = load(backgrounds[stage])
#pass # Replace with function body.

16
main.gd
View file

@ -1,4 +1,6 @@
extends Node
var presscontinue
const gamepadtest = preload("res://gamepad.gd")
const loadgame = preload("res://load.gd")
const savegame = preload("res://save.gd")
@ -6,6 +8,8 @@ const savegame = preload("res://save.gd")
# Called when the node enters the scene tree for the first time.
func _ready():
presscontinue = $Label
updatehud()
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
#OS.get_data_dir().rsplit("/", true, 7)[2]
#loadgame.new()
@ -22,6 +26,9 @@ func _process(delta):
pass
func _input(event):
gamepadtest.new(event)
updatehud()
# Mouse in viewport coordinates.
if !Global.sk && Input.is_action_just_pressed("ui_accept"):
#print("Mouse Click/Unclick at: ", event.position)
@ -34,3 +41,12 @@ func _title():
#get_tree().root.add_child(title)
#get_tree().root.remove_child(boot)
#boot.queue_free()
func updatehud():
if Global.gamepad == 0:
presscontinue.set_text(tr("TEXT_CONTINUE_KB"))
elif Global.gamepad == 1:
presscontinue.set_text(tr("TEXT_CONTINUE_US"))
elif Global.gamepad == 2:
presscontinue.set_text(tr("TEXT_CONTINUE_JA"))
elif Global.gamepad == 3:
presscontinue.set_text(tr("TEXT_CONTINUE_GEO"))

View file

@ -103,6 +103,7 @@ Pause={
[internationalization]
locale/translations=PackedStringArray("res://text.en.translation", "res://text.es.translation", "res://text.ja.translation")
locale/test="en"
[physics]

View file

@ -1,5 +1,6 @@
;en;es;ja
TEXT_DISCLAIMER;Disclaimer\nPlaying with fireworks inside a videogame can give hours of fun,\nbut in real life is dangerous\nLife insurance exists only on fiction;Descargo de responsabilidad\nJugar con explosivos dentro de un videojuego puede dar horas de diversión\npero en la vida real es peligroso\nLos seguros de vida solamente existen en la ficción;免責事項\nビデオゲームの中で花火で遊ぶと何時間も楽しめます。\nしかし現実では危険である\n生命保険はフィクションの上にのみ存在する
TEXT_GAMEPAD_DISCONNECTED;Game Controller was disconnected\nPlease connect you game controller again\nand press any button\nor press Enter to continue with keyboard; El mando de juego ha sido desconectado\nFavor de conectar el mando y presione cualquier botón\no presione Intro para continuar con el teclado;ゲーム コントローラが切断されました\nゲーム コントローラを再度接続し、任意のボタンを押す\nか、キーボードで Enter キーを押して続行してください。
TEXT_WIP;This game is under development\nMore content will be added in following releases;Este juego está en desarrollo\nMás contenido se agregará en los siguientes lanzamientos;このゲームは現在開発中です\n今後のリリースではさらにコンテンツが追加される予定です
TEXT_CONTINUE;Press Enter or B to continue;Presiona Intro o B para continuar;Enter または B を押して続行します
TEXT_CONTINUE_KB;Press Enter to continue;Presiona Intro para continuar;Enterを押して続行します
@ -132,8 +133,8 @@ CUTSCENE_0_0;most underrated children will be the best magicians\nFalcighol Arch
CUTSCENE_0_1;Hello, my name is Midori Asgardius, I am a 15 year old elf girl;Hola, mi nombre es Midori Asgardius,\nSoy una niña elfo de 15 años;こんにちは、私の名前はミドリ・アスガルディウスです。\n15歳のエルフの女の子です
CUTSCENE_0_2;They say I run around here and there as if fear didn't exist;Dicen que corro de aquí para allá como si el miedo no existiera;まるで恐怖が存在しないかのように、私はあちこち走り回っていると彼らは言う
CUTSCENE_0_3;But I'm actually a pretty shy and reserved girl;Pero en realidad soy una niña bastante tímida y reservada;でも実際は私はかなり内気で控えめな女の子です
CUTSCENE_0_4;I love reading, when I concentrate\nno one will bother me;Me encanta leer, cuando me\nconcentro nadie me molestará;私は読書が大好きです。集中すれば誰にも邪魔されません
CUTSCENE_0_5;A very funny anecdote was when I set fire to\nmy adoptive mother's, trophy room;Una anécdota muy divertida fue cuando incendié la\nsala de trofeos de mi madre adoptiva;とても面白い逸話は、\n私が養母のトロフィールームに火をつけた時のことです
CUTSCENE_0_4;I love reading, when I concentrate\nnobody will bother me;Me encanta leer, cuando me\nconcentro nadie me molestará;私は読書が大好きです。集中すれば誰にも邪魔されません
CUTSCENE_0_5;A very funny anecdote was when I set fire to\nmy adoptive mother's trophy room;Una anécdota muy divertida fue cuando incendié la\nsala de trofeos de mi madre adoptiva;とても面白い逸話は、\n私が養母のトロフィールームに火をつけた時のことです
CUTSCENE_1_0;The punishment that day was very painful\nI was crying for the rest of the day;El castigo de ese dia fue muy doloroso\nEstuve llorando el resto del dia;その日の罰はとても痛かった\n私は一日中泣いていた
CUTSCENE_1_1;According to my father, my adoptive mother was crying as well;Segun mi padre, mi madre adoptiva también estuvo llorando;父によると、養母も泣いていたそうです
CUTSCENE_1_2;Tonight the asteroid in the sky looks beautiful;Esta noche el asteroide en el cielo se ve hermoso;今夜、空の小惑星は美しく見える

1 en es ja
2 TEXT_DISCLAIMER Disclaimer\nPlaying with fireworks inside a videogame can give hours of fun,\nbut in real life is dangerous\nLife insurance exists only on fiction Descargo de responsabilidad\nJugar con explosivos dentro de un videojuego puede dar horas de diversión\npero en la vida real es peligroso\nLos seguros de vida solamente existen en la ficción 免責事項\nビデオゲームの中で花火で遊ぶと何時間も楽しめます。\nしかし現実では危険である\n生命保険はフィクションの上にのみ存在する
3 TEXT_GAMEPAD_DISCONNECTED Game Controller was disconnected\nPlease connect you game controller again\nand press any button\nor press Enter to continue with keyboard El mando de juego ha sido desconectado\nFavor de conectar el mando y presione cualquier botón\no presione Intro para continuar con el teclado ゲーム コントローラが切断されました\nゲーム コントローラを再度接続し、任意のボタンを押す\nか、キーボードで Enter キーを押して続行してください。
4 TEXT_WIP This game is under development\nMore content will be added in following releases Este juego está en desarrollo\nMás contenido se agregará en los siguientes lanzamientos このゲームは現在開発中です\n今後のリリースではさらにコンテンツが追加される予定です
5 TEXT_CONTINUE Press Enter or B to continue Presiona Intro o B para continuar Enter または B を押して続行します
6 TEXT_CONTINUE_KB Press Enter to continue Presiona Intro para continuar Enterを押して続行します
133 CUTSCENE_0_1 Hello, my name is Midori Asgardius, I am a 15 year old elf girl Hola, mi nombre es Midori Asgardius,\nSoy una niña elfo de 15 años こんにちは、私の名前はミドリ・アスガルディウスです。\n15歳のエルフの女の子です
134 CUTSCENE_0_2 They say I run around here and there as if fear didn't exist Dicen que corro de aquí para allá como si el miedo no existiera まるで恐怖が存在しないかのように、私はあちこち走り回っていると彼らは言う
135 CUTSCENE_0_3 But I'm actually a pretty shy and reserved girl Pero en realidad soy una niña bastante tímida y reservada でも実際は私はかなり内気で控えめな女の子です
136 CUTSCENE_0_4 I love reading, when I concentrate\nno one will bother me I love reading, when I concentrate\nnobody will bother me Me encanta leer, cuando me\nconcentro nadie me molestará 私は読書が大好きです。集中すれば誰にも邪魔されません
137 CUTSCENE_0_5 A very funny anecdote was when I set fire to\nmy adoptive mother's, trophy room A very funny anecdote was when I set fire to\nmy adoptive mother's trophy room Una anécdota muy divertida fue cuando incendié la\nsala de trofeos de mi madre adoptiva とても面白い逸話は、\n私が養母のトロフィールームに火をつけた時のことです
138 CUTSCENE_1_0 The punishment that day was very painful\nI was crying for the rest of the day El castigo de ese dia fue muy doloroso\nEstuve llorando el resto del dia その日の罰はとても痛かった\n私は一日中泣いていた
139 CUTSCENE_1_1 According to my father, my adoptive mother was crying as well Segun mi padre, mi madre adoptiva también estuvo llorando 父によると、養母も泣いていたそうです
140 CUTSCENE_1_2 Tonight the asteroid in the sky looks beautiful Esta noche el asteroide en el cielo se ve hermoso 今夜、空の小惑星は美しく見える

View file

@ -1,5 +1,6 @@
extends Control
var presscontinue
var pressexit
# Called when the node enters the scene tree for the first time.
var bgsound := AudioStreamPlayer.new()
@ -9,6 +10,9 @@ const gamepadtest = preload("res://gamepad.gd")
#var wormhole = preload("res://backgounds/wormhole.tscn").instantiate()
func _ready():
presscontinue = $start
pressexit = $exit
updatehud()
#Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
#if (OS.get_name() != "Linux" && !OS.get_name().ends_with("BSD")) || OS.get_distribution_name().contains("Kali") || !OS.get_data_dir().begins_with("/home") || OS.get_environment("WSL_DISTRO_NAME").length() < 0:
# Global.sk = true
@ -30,6 +34,7 @@ func _process(delta):
func _input(event):
# Mouse in viewport coordinates.
gamepadtest.new(event)
updatehud()
if Input.is_action_just_pressed("ui_accept"):
#print("Mouse Click/Unclick at: ", event.position)
get_tree().change_scene_to_file("res://levels/ui/tmenu.tscn")
@ -52,3 +57,17 @@ func _level():
#get_tree().root.add_child(title)
#get_tree().root.remove_child(boot)
#boot.queue_free()
func updatehud():
if Global.gamepad == 0:
presscontinue.set_text(tr("TEXT_START_KB"))
pressexit.set_text(tr("TEXT_EXIT_KB"))
elif Global.gamepad == 1:
presscontinue.set_text(tr("TEXT_START_US"))
pressexit.set_text(tr("TEXT_EXIT_US"))
elif Global.gamepad == 2:
presscontinue.set_text(tr("TEXT_START_JA"))
pressexit.set_text(tr("TEXT_EXIT_JA"))
elif Global.gamepad == 3:
presscontinue.set_text(tr("TEXT_START_GEO"))
pressexit.set_text(tr("TEXT_EXIT_GEO"))