mirror of
https://codeberg.org/sunder/sunder.git
synced 2026-07-15 22:14:33 +00:00
first commit 🎉
This commit is contained in:
commit
6e724f67fe
805 changed files with 62098 additions and 0 deletions
|
|
@ -0,0 +1,42 @@
|
|||
# This file is part of sunder.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
class_name JoinPanel extends MarginContainer
|
||||
|
||||
@export var join_button : Button
|
||||
@export var menu_button : Button
|
||||
@export var quit_button : Button
|
||||
@export var join_address : LineEdit
|
||||
|
||||
var _addr:RegEx = RegEx.new()
|
||||
|
||||
func _ready() -> void:
|
||||
# see https://datatracker.ietf.org/doc/html/rfc1700
|
||||
_addr.compile(r'^(?<host>(?![0-9]+$)[a-zA-Z0-9.-]+)(?::(?<port>:102[4-9]|10[3-9]\d|1[1-9]\d{2}|[2-9]\d{3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5]))?$')
|
||||
|
||||
## This method gets an array of validated host and port as specified in the
|
||||
## join panel or returns an array of default values from configuration if invalid
|
||||
func get_addr() -> Array:
|
||||
if join_address.text:
|
||||
var result:RegExMatch = _addr.search(join_address.text)
|
||||
if result:
|
||||
var host:String = result.get_string("host")
|
||||
var port:int = result.get_string("port").to_int()
|
||||
prints("join", host, port)
|
||||
if port == 0:
|
||||
port = Settings.get_value("server", "port", 9000)
|
||||
return [host, port]
|
||||
else:
|
||||
push_warning("join address is invalid")
|
||||
return [ Settings.get_value("server", "host", "localhost"), Settings.get_value("server", "port", 9000) ]
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://ffilb2d365hu
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://cfegls11p6wav"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://ffilb2d365hu" path="res://scenes/interfaces/menus/boot/multiplayer/join_panel/join_panel.gd" id="1_svm4h"]
|
||||
|
||||
[node name="JoinPanel" type="MarginContainer" node_paths=PackedStringArray("join_button", "menu_button", "quit_button", "join_address")]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/margin_left = 20
|
||||
theme_override_constants/margin_top = 20
|
||||
theme_override_constants/margin_right = 20
|
||||
theme_override_constants/margin_bottom = 20
|
||||
script = ExtResource("1_svm4h")
|
||||
join_button = NodePath("HBoxContainer/LeftBox/Top/Join")
|
||||
menu_button = NodePath("HBoxContainer/LeftBox/Bottom/Menu")
|
||||
quit_button = NodePath("HBoxContainer/LeftBox/Bottom/Quit")
|
||||
join_address = NodePath("HBoxContainer/RightBox/JoinAddress")
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 20
|
||||
|
||||
[node name="LeftBox" type="VBoxContainer" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_stretch_ratio = 0.25
|
||||
|
||||
[node name="Top" type="VBoxContainer" parent="HBoxContainer/LeftBox"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_stretch_ratio = 0.25
|
||||
|
||||
[node name="Join" type="Button" parent="HBoxContainer/LeftBox/Top"]
|
||||
layout_mode = 2
|
||||
text = "Join"
|
||||
|
||||
[node name="Bottom" type="VBoxContainer" parent="HBoxContainer/LeftBox"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 10
|
||||
|
||||
[node name="Menu" type="Button" parent="HBoxContainer/LeftBox/Bottom"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Main Menu
|
||||
"
|
||||
|
||||
[node name="Quit" type="Button" parent="HBoxContainer/LeftBox/Bottom"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "Quit"
|
||||
|
||||
[node name="RightBox" type="VBoxContainer" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="JoinAddress" type="LineEdit" parent="HBoxContainer/RightBox"]
|
||||
layout_mode = 2
|
||||
placeholder_text = "localhost"
|
||||
Loading…
Add table
Add a link
Reference in a new issue