Compare commits

..

9 Commits

Author SHA1 Message Date
Sebastian Lohff e48271ed95 Better player tones, back button 2025-04-14 03:09:23 +02:00
Sebastian Lohff aca5a97162 Autoconnect, reconnect, connection display
We can now autoconnect via parameter on web, e.g. `freq=430.200`, which
then autoconnects to that frequency, creating it when it is not already
created. We also now reconnect on connection failure and display the
connection state down below.
2025-04-14 02:46:15 +02:00
Sebastian Lohff 5dda7af184 CW server: send out messages in parallel
We now send out messages to all participants at the same time (or more
or less, as asyncio permits). To not fail in case we can't send the
message to one player, we ignore send-exceptions in these occasions and
hope that the `for data in self.websocket` in _handle_client() will
throw an error and kick the client out of our game.
2025-04-13 20:07:06 +02:00
Sebastian Lohff f3732b09d5 Also add Utils script 2025-04-13 18:34:24 +02:00
Sebastian Lohff 0e6ab98c6f MP: Logging, test js parameters (broken) 2025-04-13 18:09:00 +02:00
Sebastian Lohff fb500705ef Working Multiplayer
...now with a GUI Theme! Players can leave a room as well. Actually
usable on mobile!
2025-04-13 00:20:10 +02:00
Sebastian Lohff 970f5d951b WIP: Current state 2025-04-10 01:16:05 +02:00
Sebastian Lohff cd8befccba WIP: Multiplayer broken state 2025-04-09 21:50:13 +02:00
Sebastian Lohff e59a36a922 WIP: Multiplayer test 2025-03-21 01:41:49 +01:00
4 changed files with 13 additions and 49 deletions

View File

@ -93,11 +93,6 @@ text = "Freq:"
unique_name_in_owner = true unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
[node name="LeaveButton" type="Button" parent="VBoxContainer/MorseView/VBoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 10
text = "Leave Frequency"
[node name="PlayerContainer" type="VBoxContainer" parent="VBoxContainer/MorseView/VBoxContainer"] [node name="PlayerContainer" type="VBoxContainer" parent="VBoxContainer/MorseView/VBoxContainer"]
unique_name_in_owner = true unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
@ -109,6 +104,10 @@ size_flags_vertical = 3
size_flags_stretch_ratio = 2.0 size_flags_stretch_ratio = 2.0
text = "MORSE" text = "MORSE"
[node name="LeaveButton" type="Button" parent="VBoxContainer/MorseView/VBoxContainer"]
layout_mode = 2
text = "Leave Frequency"
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"] [node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
layout_mode = 2 layout_mode = 2
@ -146,8 +145,8 @@ autowrap_mode = 2
[connection signal="pressed" from="VBoxContainer/ConnectView/VBoxContainer/HBoxContainer/BackButton" to="." method="_on_back_button_pressed"] [connection signal="pressed" from="VBoxContainer/ConnectView/VBoxContainer/HBoxContainer/BackButton" to="." method="_on_back_button_pressed"]
[connection signal="pressed" from="VBoxContainer/ConnectView/VBoxContainer/RefreshButton" to="." method="_on_refresh_button_pressed"] [connection signal="pressed" from="VBoxContainer/ConnectView/VBoxContainer/RefreshButton" to="." method="_on_refresh_button_pressed"]
[connection signal="item_clicked" from="VBoxContainer/ConnectView/VBoxContainer/FreqList" to="." method="_on_freq_list_join"] [connection signal="item_clicked" from="VBoxContainer/ConnectView/VBoxContainer/FreqList" to="." method="_on_freq_list_join"]
[connection signal="pressed" from="VBoxContainer/MorseView/VBoxContainer/HBoxContainer/LeaveButton" to="." method="_on_leave_button_pressed"]
[connection signal="button_down" from="VBoxContainer/MorseView/VBoxContainer/MorseButton" to="." method="_on_morse_button_button_down"] [connection signal="button_down" from="VBoxContainer/MorseView/VBoxContainer/MorseButton" to="." method="_on_morse_button_button_down"]
[connection signal="button_up" from="VBoxContainer/MorseView/VBoxContainer/MorseButton" to="." method="_on_morse_button_button_up"] [connection signal="button_up" from="VBoxContainer/MorseView/VBoxContainer/MorseButton" to="." method="_on_morse_button_button_up"]
[connection signal="pressed" from="VBoxContainer/MorseView/VBoxContainer/LeaveButton" to="." method="_on_leave_button_pressed"]
[connection signal="gui_input" from="VBoxContainer/HBoxContainer/HBoxContainer2/Label" to="." method="_on_error_label_gui_input"] [connection signal="gui_input" from="VBoxContainer/HBoxContainer/HBoxContainer2/Label" to="." method="_on_error_label_gui_input"]
[connection signal="gui_input" from="VBoxContainer/HBoxContainer/HBoxContainer2/ErrorLabel" to="." method="_on_error_label_gui_input"] [connection signal="gui_input" from="VBoxContainer/HBoxContainer/HBoxContainer2/ErrorLabel" to="." method="_on_error_label_gui_input"]

View File

@ -20,31 +20,25 @@ func fill_buffer():
phase = fmod(phase + increment, 1.0) phase = fmod(phase + increment, 1.0)
func _ready(): func _ready():
match OS.get_name():
"Android":
%WavButton.text = "Share Wav"
"Web":
%WavButton.text = "Download Wav"
$Player.stream.mix_rate = sample_hz $Player.stream.mix_rate = sample_hz
$Player.volume_db = -100 $Player.volume_db = -100
$Player.play() $Player.play()
playback = $Player.get_stream_playback() playback = $Player.get_stream_playback()
fill_buffer() fill_buffer()
if OS.get_name() != "Web":
OS.open_midi_inputs()
print(OS.get_connected_midi_inputs())
else:
%MidiButton.visible = true
if multiplayer_enabled: if multiplayer_enabled:
%MultiplayerButton.visible = true %MultiplayerButton.visible = true
print("External freq: ", Utils.get_external_freq_param())
if Utils.get_external_freq_param(): if Utils.get_external_freq_param():
print("Direct connect to external freq: ", Utils.get_external_freq_param())
_on_multiplayer_button_pressed() _on_multiplayer_button_pressed()
# FIXME: make this dependant on button
OS.open_midi_inputs()
print(OS.get_connected_midi_inputs())
func set_morse_state(state: bool): func set_morse_state(state: bool):
MorseState.set_state(state) MorseState.set_state(state)
morse_state = state morse_state = state
@ -165,8 +159,3 @@ func _on_reset_button_pressed() -> void:
func _on_multiplayer_button_pressed() -> void: func _on_multiplayer_button_pressed() -> void:
get_tree().change_scene_to_file("res://scenes/MultiplayerConnect.tscn") get_tree().change_scene_to_file("res://scenes/MultiplayerConnect.tscn")
func _on_midi_button_pressed() -> void:
OS.open_midi_inputs()
print(OS.get_connected_midi_inputs())

View File

@ -55,23 +55,14 @@ size_flags_stretch_ratio = 2.0
text = "MORSE" text = "MORSE"
[node name="WavButton" type="Button" parent="VBoxContainer"] [node name="WavButton" type="Button" parent="VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
size_flags_vertical = 3 size_flags_vertical = 3
text = "Save Wav" text = "Write Wav"
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"] [node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
layout_mode = 2 layout_mode = 2
size_flags_vertical = 3 size_flags_vertical = 3
[node name="MidiButton" type="Button" parent="VBoxContainer/HBoxContainer"]
unique_name_in_owner = true
visible = false
layout_mode = 2
size_flags_stretch_ratio = 0.25
text = "Open
Midi"
[node name="ResetButton" type="Button" parent="VBoxContainer/HBoxContainer"] [node name="ResetButton" type="Button" parent="VBoxContainer/HBoxContainer"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
@ -97,6 +88,5 @@ script = ExtResource("3_sugp2")
[connection signal="button_down" from="VBoxContainer/MorseButton" to="." method="_on_morse_button_down"] [connection signal="button_down" from="VBoxContainer/MorseButton" to="." method="_on_morse_button_down"]
[connection signal="button_up" from="VBoxContainer/MorseButton" to="." method="_on_morse_button_up"] [connection signal="button_up" from="VBoxContainer/MorseButton" to="." method="_on_morse_button_up"]
[connection signal="pressed" from="VBoxContainer/WavButton" to="." method="_on_wav_button_pressed"] [connection signal="pressed" from="VBoxContainer/WavButton" to="." method="_on_wav_button_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/MidiButton" to="." method="_on_midi_button_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/ResetButton" to="." method="_on_reset_button_pressed"] [connection signal="pressed" from="VBoxContainer/HBoxContainer/ResetButton" to="." method="_on_reset_button_pressed"]
[connection signal="pressed" from="VBoxContainer/HBoxContainer/MultiplayerButton" to="." method="_on_multiplayer_button_pressed"] [connection signal="pressed" from="VBoxContainer/HBoxContainer/MultiplayerButton" to="." method="_on_multiplayer_button_pressed"]

View File

@ -225,20 +225,6 @@ func _on_morse_button_button_up() -> void:
return return
set_morse_state(false) set_morse_state(false)
func _input(input_event):
if input_event is InputEventMIDI:
_process_midi_event(input_event)
func _process_midi_event(midi_event):
if not mmb_self:
return
if midi_event.channel in [0, 9]:
if midi_event.message == MIDI_MESSAGE_NOTE_ON:
set_morse_state(true)
elif midi_event.message == MIDI_MESSAGE_NOTE_OFF:
set_morse_state(false)
func _on_leave_button_pressed() -> void: func _on_leave_button_pressed() -> void:
send_data({"cmd": "leave"}) send_data({"cmd": "leave"})