mirror of
https://github.com/Steffo99/pineapple-surf.git
synced 2024-11-21 15:34:17 +00:00
Fix username input
This commit is contained in:
parent
23747addd1
commit
29a901f360
3 changed files with 43 additions and 5 deletions
25
menu/Menu.gd
25
menu/Menu.gd
|
@ -3,14 +3,31 @@ extends Control
|
|||
signal play_pressed()
|
||||
|
||||
|
||||
var username_regex
|
||||
|
||||
|
||||
var username: String:
|
||||
get:
|
||||
return Singletons.username
|
||||
set(value):
|
||||
value = value.strip_escapes()
|
||||
value = value.to_lower()
|
||||
value = username_regex.sub(value, "-", true)
|
||||
Singletons.username = value
|
||||
var caret = $Content/Inputs/NameInput.caret_column
|
||||
$Content/Inputs/NameInput.text = value
|
||||
$Content/Inputs/NameInput.caret_column = caret
|
||||
%PlayButton.disabled = len(value) <= 0
|
||||
|
||||
|
||||
func play():
|
||||
print("Player ", Singletons.username, " started playing!")
|
||||
emit_signal("play_pressed")
|
||||
|
||||
|
||||
func _on_name_input_text_changed():
|
||||
Singletons.username = $Content/Inputs/NameInput.text
|
||||
%PlayButton.disabled = false
|
||||
func _on_name_input_text_changed(new_text):
|
||||
if username != $Content/Inputs/NameInput.text:
|
||||
username = $Content/Inputs/NameInput.text
|
||||
|
||||
|
||||
func _on_fetched_scores():
|
||||
|
@ -19,5 +36,7 @@ func _on_fetched_scores():
|
|||
|
||||
|
||||
func _ready():
|
||||
username_regex = RegEx.new()
|
||||
username_regex.compile("[^a-z0-9]")
|
||||
$"/root/BaseScene/ScoreboardContainer".connect("fetched_scores", _on_fetched_scores)
|
||||
$"/root/BaseScene/ScoreboardContainer".fetch_scores(false)
|
||||
|
|
|
@ -52,7 +52,7 @@ layout_mode = 2
|
|||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 6
|
||||
|
||||
[node name="NameInput" type="TextEdit" parent="Content/Inputs"]
|
||||
[node name="NameInput" type="LineEdit" parent="Content/Inputs"]
|
||||
custom_minimum_size = Vector2(140, 28)
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_resource type="Theme" load_steps=11 format=3 uid="uid://c5a1nyqumj46j"]
|
||||
[gd_resource type="Theme" load_steps=13 format=3 uid="uid://c5a1nyqumj46j"]
|
||||
|
||||
[ext_resource type="FontFile" uid="uid://dvfq5l72ynw4s" path="res://assets/pixel_operator.ttf" id="1_tst0x"]
|
||||
|
||||
|
@ -49,6 +49,21 @@ corner_detail = 2
|
|||
shadow_color = Color(1, 1, 1, 1)
|
||||
anti_aliasing = false
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_06vbp"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_0e8xu"]
|
||||
bg_color = Color(0.156863, 0.207843, 0.25098, 1)
|
||||
border_width_left = 2
|
||||
border_width_top = 2
|
||||
border_width_right = 2
|
||||
border_width_bottom = 2
|
||||
border_color = Color(0.388235, 0.670588, 0.247059, 1)
|
||||
corner_radius_top_left = 2
|
||||
corner_radius_top_right = 2
|
||||
corner_radius_bottom_right = 2
|
||||
corner_radius_bottom_left = 2
|
||||
anti_aliasing = false
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_20p1w"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jo6pk"]
|
||||
|
@ -88,6 +103,10 @@ Label/colors/font_color = Color(1, 1, 1, 1)
|
|||
Label/constants/line_spacing = 2
|
||||
Label/font_sizes/font_size = 16
|
||||
Label/fonts/font = ExtResource("1_tst0x")
|
||||
LineEdit/font_sizes/font_size = 16
|
||||
LineEdit/fonts/font = ExtResource("1_tst0x")
|
||||
LineEdit/styles/focus = SubResource("StyleBoxEmpty_06vbp")
|
||||
LineEdit/styles/normal = SubResource("StyleBoxFlat_0e8xu")
|
||||
TextEdit/font_sizes/font_size = 16
|
||||
TextEdit/fonts/font = ExtResource("1_tst0x")
|
||||
TextEdit/styles/focus = SubResource("StyleBoxEmpty_20p1w")
|
||||
|
|
Loading…
Reference in a new issue