Compare commits
No commits in common. "0e6ab98c6febf8db8bb8bb8aff2960e038460c85" and "970f5d951b2b0be30f6c8165122a48ab49abf30b" have entirely different histories.
0e6ab98c6f
...
970f5d951b
|
@ -20,7 +20,6 @@ config/icon="res://icon.svg"
|
||||||
[autoload]
|
[autoload]
|
||||||
|
|
||||||
MorseState="*res://autoloads/morse_state.gd"
|
MorseState="*res://autoloads/morse_state.gd"
|
||||||
Utils="*res://autoloads/utils.gd"
|
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
[gd_resource type="Theme" format=3 uid="uid://xxoc27tvaiut"]
|
|
||||||
|
|
||||||
[resource]
|
|
||||||
default_font_size = 30
|
|
|
@ -1,6 +1,5 @@
|
||||||
[gd_scene load_steps=3 format=3 uid="uid://dnxcrx04kl3xy"]
|
[gd_scene load_steps=2 format=3 uid="uid://dnxcrx04kl3xy"]
|
||||||
|
|
||||||
[ext_resource type="Theme" uid="uid://xxoc27tvaiut" path="res://scenes/GUITheme.tres" id="1_2wc0w"]
|
|
||||||
[ext_resource type="Script" uid="uid://di8r70441xdms" path="res://scenes/multiplayer_connect.gd" id="1_uyd8l"]
|
[ext_resource type="Script" uid="uid://di8r70441xdms" path="res://scenes/multiplayer_connect.gd" id="1_uyd8l"]
|
||||||
|
|
||||||
[node name="MultiplayerConnect" type="Control"]
|
[node name="MultiplayerConnect" type="Control"]
|
||||||
|
@ -10,7 +9,6 @@ anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
theme = ExtResource("1_2wc0w")
|
|
||||||
script = ExtResource("1_uyd8l")
|
script = ExtResource("1_uyd8l")
|
||||||
|
|
||||||
[node name="ConnectView" type="Control" parent="."]
|
[node name="ConnectView" type="Control" parent="."]
|
||||||
|
@ -37,7 +35,6 @@ layout_mode = 2
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
custom_minimum_size = Vector2(100, 0)
|
custom_minimum_size = Vector2(100, 0)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_font_sizes/font_size = 20
|
|
||||||
text = "430.200"
|
text = "430.200"
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="ConnectView/VBoxContainer/HBoxContainer"]
|
[node name="Label" type="Label" parent="ConnectView/VBoxContainer/HBoxContainer"]
|
||||||
|
@ -45,7 +42,6 @@ layout_mode = 2
|
||||||
text = "MHz"
|
text = "MHz"
|
||||||
|
|
||||||
[node name="CreateButton" type="Button" parent="ConnectView/VBoxContainer/HBoxContainer"]
|
[node name="CreateButton" type="Button" parent="ConnectView/VBoxContainer/HBoxContainer"]
|
||||||
custom_minimum_size = Vector2(0, 100)
|
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_stretch_ratio = 2.41
|
size_flags_stretch_ratio = 2.41
|
||||||
text = "Create Frequency"
|
text = "Create Frequency"
|
||||||
|
@ -62,20 +58,14 @@ size_flags_vertical = 3
|
||||||
[node name="MorseView" type="Control" parent="."]
|
[node name="MorseView" type="Control" parent="."]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
visible = false
|
visible = false
|
||||||
layout_mode = 1
|
anchors_preset = 0
|
||||||
anchors_preset = 15
|
offset_right = 40.0
|
||||||
anchor_right = 1.0
|
offset_bottom = 40.0
|
||||||
anchor_bottom = 1.0
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="MorseView"]
|
[node name="VBoxContainer" type="VBoxContainer" parent="MorseView"]
|
||||||
layout_mode = 1
|
layout_mode = 0
|
||||||
anchors_preset = 15
|
offset_right = 40.0
|
||||||
anchor_right = 1.0
|
offset_bottom = 40.0
|
||||||
anchor_bottom = 1.0
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
|
|
||||||
[node name="HBoxContainer" type="HBoxContainer" parent="MorseView/VBoxContainer"]
|
[node name="HBoxContainer" type="HBoxContainer" parent="MorseView/VBoxContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
@ -91,7 +81,6 @@ layout_mode = 2
|
||||||
[node name="PlayerContainer" type="VBoxContainer" parent="MorseView/VBoxContainer"]
|
[node name="PlayerContainer" type="VBoxContainer" parent="MorseView/VBoxContainer"]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_vertical = 3
|
|
||||||
|
|
||||||
[node name="MorseButton" type="Button" parent="MorseView/VBoxContainer"]
|
[node name="MorseButton" type="Button" parent="MorseView/VBoxContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
@ -99,13 +88,8 @@ 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="MorseView/VBoxContainer"]
|
|
||||||
layout_mode = 2
|
|
||||||
text = "Leave Frequency"
|
|
||||||
|
|
||||||
[connection signal="pressed" from="ConnectView/VBoxContainer/HBoxContainer/CreateButton" to="." method="_on_create_button_pressed"]
|
[connection signal="pressed" from="ConnectView/VBoxContainer/HBoxContainer/CreateButton" to="." method="_on_create_button_pressed"]
|
||||||
[connection signal="pressed" from="ConnectView/VBoxContainer/RefreshButton" to="." method="_on_refresh_button_pressed"]
|
[connection signal="pressed" from="ConnectView/VBoxContainer/RefreshButton" to="." method="_on_refresh_button_pressed"]
|
||||||
[connection signal="item_clicked" from="ConnectView/VBoxContainer/FreqList" to="." method="_on_freq_list_join"]
|
[connection signal="item_clicked" from="ConnectView/VBoxContainer/FreqList" to="." method="_on_freq_list_join"]
|
||||||
[connection signal="button_down" from="MorseView/VBoxContainer/MorseButton" to="." method="_on_morse_button_button_down"]
|
[connection signal="button_down" from="MorseView/VBoxContainer/MorseButton" to="." method="_on_morse_button_button_down"]
|
||||||
[connection signal="button_up" from="MorseView/VBoxContainer/MorseButton" to="." method="_on_morse_button_button_up"]
|
[connection signal="button_up" from="MorseView/VBoxContainer/MorseButton" to="." method="_on_morse_button_button_up"]
|
||||||
[connection signal="pressed" from="MorseView/VBoxContainer/LeaveButton" to="." method="_on_leave_button_pressed"]
|
|
||||||
|
|
|
@ -27,16 +27,8 @@ func _ready():
|
||||||
fill_buffer()
|
fill_buffer()
|
||||||
|
|
||||||
if multiplayer_enabled:
|
if multiplayer_enabled:
|
||||||
%MultiplayerButton.visible = true
|
$VBoxContainer/MultiplayerButton.visible = true
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print("External freq: ", Utils.get_external_freq_param())
|
|
||||||
if Utils.get_external_freq_param():
|
|
||||||
|
|
||||||
_on_multiplayer_button_pressed()
|
|
||||||
|
|
||||||
# FIXME: make this dependant on button
|
|
||||||
OS.open_midi_inputs()
|
OS.open_midi_inputs()
|
||||||
print(OS.get_connected_midi_inputs())
|
print(OS.get_connected_midi_inputs())
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
[gd_scene load_steps=6 format=3 uid="uid://ctak1goemnnc5"]
|
[gd_scene load_steps=5 format=3 uid="uid://ctak1goemnnc5"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://dmeokosn7gr27" path="res://scenes/main.gd" id="1_8bx00"]
|
[ext_resource type="Script" uid="uid://dmeokosn7gr27" path="res://scenes/main.gd" id="1_8bx00"]
|
||||||
[ext_resource type="Theme" uid="uid://xxoc27tvaiut" path="res://scenes/GUITheme.tres" id="1_jyhfs"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://xqic6oa5d7oc" path="res://scenes/MorseBanner.tscn" id="2_v02md"]
|
[ext_resource type="PackedScene" uid="uid://xqic6oa5d7oc" path="res://scenes/MorseBanner.tscn" id="2_v02md"]
|
||||||
[ext_resource type="Script" uid="uid://bjt60u6r1hqf7" path="res://addons/SharePlugin/Share.gd" id="3_sugp2"]
|
[ext_resource type="Script" uid="uid://bjt60u6r1hqf7" path="res://addons/SharePlugin/Share.gd" id="3_sugp2"]
|
||||||
|
|
||||||
|
@ -16,7 +15,6 @@ anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
theme = ExtResource("1_jyhfs")
|
|
||||||
script = ExtResource("1_8bx00")
|
script = ExtResource("1_8bx00")
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||||
|
@ -59,23 +57,15 @@ layout_mode = 2
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
text = "Write Wav"
|
text = "Write Wav"
|
||||||
|
|
||||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
|
[node name="ResetButton" type="Button" parent="VBoxContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
|
|
||||||
[node name="ResetButton" type="Button" parent="VBoxContainer/HBoxContainer"]
|
|
||||||
layout_mode = 2
|
|
||||||
size_flags_horizontal = 3
|
|
||||||
size_flags_vertical = 3
|
|
||||||
size_flags_stretch_ratio = 0.5
|
size_flags_stretch_ratio = 0.5
|
||||||
text = "Reset"
|
text = "Reset"
|
||||||
|
|
||||||
[node name="MultiplayerButton" type="Button" parent="VBoxContainer/HBoxContainer"]
|
[node name="MultiplayerButton" type="Button" parent="VBoxContainer"]
|
||||||
unique_name_in_owner = true
|
|
||||||
visible = false
|
visible = false
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
|
||||||
size_flags_stretch_ratio = 0.5
|
|
||||||
text = "Connect to Frequency"
|
text = "Connect to Frequency"
|
||||||
|
|
||||||
[node name="Player" type="AudioStreamPlayer" parent="."]
|
[node name="Player" type="AudioStreamPlayer" parent="."]
|
||||||
|
@ -88,5 +78,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/ResetButton" to="." method="_on_reset_button_pressed"]
|
[connection signal="pressed" from="VBoxContainer/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/MultiplayerButton" to="." method="_on_multiplayer_button_pressed"]
|
||||||
|
|
|
@ -2,8 +2,6 @@ extends Control
|
||||||
|
|
||||||
var server := "seba-geek.de"
|
var server := "seba-geek.de"
|
||||||
var port := "3784"
|
var port := "3784"
|
||||||
var ws_url := "wss://seba-geek.de/godot/cw-generator-ws/"
|
|
||||||
var IS_DEBUG = false
|
|
||||||
var ws := WebSocketPeer.new()
|
var ws := WebSocketPeer.new()
|
||||||
|
|
||||||
var available_freqs = []
|
var available_freqs = []
|
||||||
|
@ -32,13 +30,8 @@ func _ready() -> void:
|
||||||
# FIXME: status / error messages
|
# FIXME: status / error messages
|
||||||
# FIXME: randomize default join frquency
|
# FIXME: randomize default join frquency
|
||||||
# FIXME: automatic refresh
|
# FIXME: automatic refresh
|
||||||
if not IS_DEBUG:
|
print("ws://%s:%s" % [server, port])
|
||||||
print(ws_url)
|
ws.connect_to_url("ws://%s:%s" % [server, port])
|
||||||
ws.connect_to_url(ws_url)
|
|
||||||
else:
|
|
||||||
print("ws://%s:%s" % [server, port])
|
|
||||||
ws.connect_to_url("ws://%s:%s" % [server, port])
|
|
||||||
|
|
||||||
|
|
||||||
func refresh_list() -> void:
|
func refresh_list() -> void:
|
||||||
pass
|
pass
|
||||||
|
@ -50,8 +43,6 @@ func _process(_delta: float) -> void:
|
||||||
# print("moin ", state)
|
# print("moin ", state)
|
||||||
while state == WebSocketPeer.STATE_OPEN and ws.get_available_packet_count():
|
while state == WebSocketPeer.STATE_OPEN and ws.get_available_packet_count():
|
||||||
_handle_packet()
|
_handle_packet()
|
||||||
if state != WebSocketPeer.STATE_OPEN:
|
|
||||||
print("Error: websocket in state", state)
|
|
||||||
|
|
||||||
func _handle_packet() -> void:
|
func _handle_packet() -> void:
|
||||||
var data := ws.get_packet().get_string_from_utf8()
|
var data := ws.get_packet().get_string_from_utf8()
|
||||||
|
@ -110,16 +101,7 @@ func _handle_packet() -> void:
|
||||||
print("Error: player not part of freq ", player)
|
print("Error: player not part of freq ", player)
|
||||||
return
|
return
|
||||||
remove_player(parsed["player"])
|
remove_player(parsed["player"])
|
||||||
"leave":
|
|
||||||
%MorseView.hide()
|
|
||||||
mmb_self.set_morse_state(false)
|
|
||||||
for mmb: MultiMorseBanner in mmb_others.values():
|
|
||||||
mmb.set_morse_state(false)
|
|
||||||
mmb_self = null
|
|
||||||
mmb_others.clear()
|
|
||||||
for child in %PlayerContainer.get_children():
|
|
||||||
%PlayerContainer.remove_child(child)
|
|
||||||
%ConnectView.show()
|
|
||||||
_:
|
_:
|
||||||
print("Unhandled message: ", parsed["type"])
|
print("Unhandled message: ", parsed["type"])
|
||||||
|
|
||||||
|
@ -190,7 +172,3 @@ func _on_morse_button_button_up() -> void:
|
||||||
if not mmb_self:
|
if not mmb_self:
|
||||||
return
|
return
|
||||||
set_morse_state(false)
|
set_morse_state(false)
|
||||||
|
|
||||||
|
|
||||||
func _on_leave_button_pressed() -> void:
|
|
||||||
send_data({"cmd": "leave"})
|
|
||||||
|
|
|
@ -1,18 +1,11 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import datetime
|
|
||||||
import json
|
import json
|
||||||
import logging
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from websockets.asyncio.server import serve
|
from websockets.asyncio.server import serve
|
||||||
|
|
||||||
__VERSION__ = "0.0.1"
|
__VERSION__ = "0.0.1"
|
||||||
|
|
||||||
logging.basicConfig(
|
|
||||||
level=logging.INFO,
|
|
||||||
format="%(asctime)s %(name)s %(levelname)s %(message)s"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class Client:
|
class Client:
|
||||||
freqs = {}
|
freqs = {}
|
||||||
|
@ -60,7 +53,7 @@ class Client:
|
||||||
await self._send_error("Invalid format in json")
|
await self._send_error("Invalid format in json")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
print(f"{datetime.datetime.now()} {self.client} wrote:", data)
|
print(f"{self.client} wrote:", data)
|
||||||
|
|
||||||
match data["cmd"]:
|
match data["cmd"]:
|
||||||
case "quit":
|
case "quit":
|
||||||
|
@ -69,8 +62,6 @@ class Client:
|
||||||
await self._create_room(data)
|
await self._create_room(data)
|
||||||
case "join":
|
case "join":
|
||||||
await self._join_room(data)
|
await self._join_room(data)
|
||||||
case "leave":
|
|
||||||
await self._leave_room()
|
|
||||||
case "list":
|
case "list":
|
||||||
freqs = [{"freq": freq, "players": len(players)}
|
freqs = [{"freq": freq, "players": len(players)}
|
||||||
for freq, players in self.freqs.items()]
|
for freq, players in self.freqs.items()]
|
||||||
|
@ -140,10 +131,6 @@ class Client:
|
||||||
await other._send(type="morse-state", state=data["state"], from_player=self.id)
|
await other._send(type="morse-state", state=data["state"], from_player=self.id)
|
||||||
|
|
||||||
async def _leave_room(self):
|
async def _leave_room(self):
|
||||||
if not self.curr_freq:
|
|
||||||
self._send_error("You are not on a frequency")
|
|
||||||
return
|
|
||||||
|
|
||||||
for other in self._others(self.curr_freq):
|
for other in self._others(self.curr_freq):
|
||||||
await other._send(type="player-left", player=self.id)
|
await other._send(type="player-left", player=self.id)
|
||||||
try:
|
try:
|
||||||
|
@ -154,11 +141,6 @@ class Client:
|
||||||
del self.freqs[self.curr_freq]
|
del self.freqs[self.curr_freq]
|
||||||
self.curr_freq = None
|
self.curr_freq = None
|
||||||
|
|
||||||
try:
|
|
||||||
await self._send(type="leave")
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def _others(self, freq):
|
def _others(self, freq):
|
||||||
return [c for c in self.freqs[freq] if c.id != self.id]
|
return [c for c in self.freqs[freq] if c.id != self.id]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue