develop #30
16
godot/monitor/EnterButton.gd
Normal file
16
godot/monitor/EnterButton.gd
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
extends Button
|
||||||
|
|
||||||
|
|
||||||
|
signal input_validated(player)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Button_pressed() -> void:
|
||||||
|
var name = get_node("%Name")
|
||||||
|
var rut = get_node("%Rut")
|
||||||
|
var email = get_node("%Email")
|
||||||
|
var player: Dictionary = {
|
||||||
|
"name" : name.text,
|
||||||
|
"rut" : rut.text,
|
||||||
|
"email" : email.text
|
||||||
|
}
|
||||||
|
emit_signal("input_validated", player)
|
238
godot/monitor/GUI.tscn
Normal file
238
godot/monitor/GUI.tscn
Normal file
@ -0,0 +1,238 @@
|
|||||||
|
[gd_scene load_steps=18 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://assets/fonts/data/PixelOperator.tres" type="DynamicFontData" id=1]
|
||||||
|
[ext_resource path="res://assets/fonts/data/PixelOperator-Bold.tres" type="DynamicFontData" id=2]
|
||||||
|
[ext_resource path="res://monitor/Rut.gd" type="Script" id=3]
|
||||||
|
[ext_resource path="res://monitor/Text.gd" type="Script" id=4]
|
||||||
|
[ext_resource path="res://monitor/EnterButton.gd" type="Script" id=5]
|
||||||
|
|
||||||
|
[sub_resource type="DynamicFont" id=1]
|
||||||
|
font_data = ExtResource( 1 )
|
||||||
|
|
||||||
|
[sub_resource type="DynamicFont" id=2]
|
||||||
|
size = 12
|
||||||
|
font_data = ExtResource( 2 )
|
||||||
|
|
||||||
|
[sub_resource type="DynamicFont" id=3]
|
||||||
|
size = 12
|
||||||
|
font_data = ExtResource( 2 )
|
||||||
|
|
||||||
|
[sub_resource type="DynamicFont" id=4]
|
||||||
|
size = 12
|
||||||
|
font_data = ExtResource( 2 )
|
||||||
|
|
||||||
|
[sub_resource type="DynamicFont" id=9]
|
||||||
|
size = 8
|
||||||
|
extra_spacing_top = 2
|
||||||
|
font_data = ExtResource( 1 )
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id=5]
|
||||||
|
content_margin_left = 5.0
|
||||||
|
content_margin_right = 5.0
|
||||||
|
bg_color = Color( 0.313726, 0.290196, 0.290196, 0.752941 )
|
||||||
|
border_blend = true
|
||||||
|
corner_radius_top_left = 5
|
||||||
|
corner_radius_top_right = 5
|
||||||
|
corner_radius_bottom_right = 5
|
||||||
|
corner_radius_bottom_left = 5
|
||||||
|
|
||||||
|
[sub_resource type="DynamicFont" id=10]
|
||||||
|
size = 8
|
||||||
|
extra_spacing_top = 2
|
||||||
|
font_data = ExtResource( 1 )
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id=6]
|
||||||
|
content_margin_left = 5.0
|
||||||
|
content_margin_right = 5.0
|
||||||
|
bg_color = Color( 0.313726, 0.290196, 0.290196, 0.752941 )
|
||||||
|
corner_radius_top_left = 5
|
||||||
|
corner_radius_top_right = 5
|
||||||
|
corner_radius_bottom_right = 5
|
||||||
|
corner_radius_bottom_left = 5
|
||||||
|
|
||||||
|
[sub_resource type="DynamicFont" id=8]
|
||||||
|
size = 8
|
||||||
|
extra_spacing_top = 2
|
||||||
|
font_data = ExtResource( 1 )
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id=7]
|
||||||
|
content_margin_left = 5.0
|
||||||
|
content_margin_right = 5.0
|
||||||
|
bg_color = Color( 0.313726, 0.290196, 0.290196, 0.752941 )
|
||||||
|
corner_radius_top_left = 5
|
||||||
|
corner_radius_top_right = 5
|
||||||
|
corner_radius_bottom_right = 5
|
||||||
|
corner_radius_bottom_left = 5
|
||||||
|
|
||||||
|
[sub_resource type="DynamicFont" id=11]
|
||||||
|
size = 12
|
||||||
|
extra_spacing_top = 2
|
||||||
|
extra_spacing_bottom = 2
|
||||||
|
extra_spacing_char = 2
|
||||||
|
extra_spacing_space = 2
|
||||||
|
font_data = ExtResource( 2 )
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id=12]
|
||||||
|
content_margin_left = 5.0
|
||||||
|
content_margin_right = 5.0
|
||||||
|
content_margin_top = 5.0
|
||||||
|
content_margin_bottom = 5.0
|
||||||
|
bg_color = Color( 0.313726, 0.290196, 0.290196, 0.752941 )
|
||||||
|
corner_radius_top_left = 5
|
||||||
|
corner_radius_top_right = 5
|
||||||
|
corner_radius_bottom_right = 5
|
||||||
|
corner_radius_bottom_left = 5
|
||||||
|
|
||||||
|
[node name="MonitorGUI" type="CanvasLayer"]
|
||||||
|
pause_mode = 2
|
||||||
|
|
||||||
|
[node name="ColorRect" type="ColorRect" parent="."]
|
||||||
|
margin_right = 40.0
|
||||||
|
margin_bottom = 40.0
|
||||||
|
rect_min_size = Vector2( 512, 288 )
|
||||||
|
color = Color( 0.0117647, 0.00784314, 0.00784314, 0.376471 )
|
||||||
|
|
||||||
|
[node name="GUI" type="Control" parent="."]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
rect_min_size = Vector2( 512, 0 )
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="GUI"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
||||||
|
[node name="CenterContainer" type="CenterContainer" parent="GUI/VBoxContainer"]
|
||||||
|
margin_right = 512.0
|
||||||
|
margin_bottom = 96.0
|
||||||
|
rect_min_size = Vector2( 0, 96 )
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="GUI/VBoxContainer/CenterContainer"]
|
||||||
|
margin_top = 30.0
|
||||||
|
margin_right = 512.0
|
||||||
|
margin_bottom = 65.0
|
||||||
|
rect_min_size = Vector2( 512, 0 )
|
||||||
|
custom_fonts/font = SubResource( 1 )
|
||||||
|
text = "Ingresa su nombre completo, RUT y email por favor!"
|
||||||
|
align = 1
|
||||||
|
autowrap = true
|
||||||
|
|
||||||
|
[node name="CenterContainer2" type="CenterContainer" parent="GUI/VBoxContainer"]
|
||||||
|
margin_top = 100.0
|
||||||
|
margin_right = 512.0
|
||||||
|
margin_bottom = 196.0
|
||||||
|
rect_min_size = Vector2( 0, 96 )
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="GUI/VBoxContainer/CenterContainer2"]
|
||||||
|
margin_left = 6.0
|
||||||
|
margin_top = 14.0
|
||||||
|
margin_right = 506.0
|
||||||
|
margin_bottom = 82.0
|
||||||
|
rect_min_size = Vector2( 500, 0 )
|
||||||
|
size_flags_horizontal = 13
|
||||||
|
size_flags_vertical = 13
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="GUI/VBoxContainer/CenterContainer2/HBoxContainer"]
|
||||||
|
margin_right = 74.0
|
||||||
|
margin_bottom = 68.0
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="GUI/VBoxContainer/CenterContainer2/HBoxContainer/VBoxContainer"]
|
||||||
|
margin_top = 3.0
|
||||||
|
margin_right = 74.0
|
||||||
|
margin_bottom = 16.0
|
||||||
|
size_flags_vertical = 6
|
||||||
|
custom_fonts/font = SubResource( 2 )
|
||||||
|
text = "Nombre"
|
||||||
|
align = 2
|
||||||
|
|
||||||
|
[node name="Label2" type="Label" parent="GUI/VBoxContainer/CenterContainer2/HBoxContainer/VBoxContainer"]
|
||||||
|
margin_top = 27.0
|
||||||
|
margin_right = 74.0
|
||||||
|
margin_bottom = 40.0
|
||||||
|
size_flags_vertical = 6
|
||||||
|
custom_fonts/font = SubResource( 3 )
|
||||||
|
text = "RUT"
|
||||||
|
align = 2
|
||||||
|
|
||||||
|
[node name="Label3" type="Label" parent="GUI/VBoxContainer/CenterContainer2/HBoxContainer/VBoxContainer"]
|
||||||
|
margin_top = 51.0
|
||||||
|
margin_right = 74.0
|
||||||
|
margin_bottom = 64.0
|
||||||
|
size_flags_vertical = 6
|
||||||
|
custom_fonts/font = SubResource( 4 )
|
||||||
|
text = "Email"
|
||||||
|
align = 2
|
||||||
|
|
||||||
|
[node name="VBoxContainer2" type="VBoxContainer" parent="GUI/VBoxContainer/CenterContainer2/HBoxContainer"]
|
||||||
|
margin_left = 78.0
|
||||||
|
margin_right = 500.0
|
||||||
|
margin_bottom = 68.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="Name" type="TextEdit" parent="GUI/VBoxContainer/CenterContainer2/HBoxContainer/VBoxContainer2"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
margin_right = 422.0
|
||||||
|
margin_bottom = 20.0
|
||||||
|
rect_min_size = Vector2( 300, 20 )
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
custom_fonts/font = SubResource( 9 )
|
||||||
|
custom_styles/normal = SubResource( 5 )
|
||||||
|
text = "Christopher Barry Cromer"
|
||||||
|
caret_blink = true
|
||||||
|
script = ExtResource( 4 )
|
||||||
|
|
||||||
|
[node name="Rut" type="TextEdit" parent="GUI/VBoxContainer/CenterContainer2/HBoxContainer/VBoxContainer2"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
margin_top = 24.0
|
||||||
|
margin_right = 422.0
|
||||||
|
margin_bottom = 44.0
|
||||||
|
rect_min_size = Vector2( 0, 20 )
|
||||||
|
custom_fonts/font = SubResource( 10 )
|
||||||
|
custom_styles/normal = SubResource( 6 )
|
||||||
|
text = "23.660.457-8"
|
||||||
|
caret_blink = true
|
||||||
|
script = ExtResource( 3 )
|
||||||
|
|
||||||
|
[node name="Email" type="TextEdit" parent="GUI/VBoxContainer/CenterContainer2/HBoxContainer/VBoxContainer2"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
margin_top = 48.0
|
||||||
|
margin_right = 422.0
|
||||||
|
margin_bottom = 68.0
|
||||||
|
rect_min_size = Vector2( 0, 20 )
|
||||||
|
custom_fonts/font = SubResource( 8 )
|
||||||
|
custom_styles/normal = SubResource( 7 )
|
||||||
|
text = "christohper.cromer1501@alumnos.ubiobio.cl"
|
||||||
|
caret_blink = true
|
||||||
|
script = ExtResource( 4 )
|
||||||
|
|
||||||
|
[node name="CenterContainer3" type="CenterContainer" parent="GUI/VBoxContainer"]
|
||||||
|
margin_top = 200.0
|
||||||
|
margin_right = 512.0
|
||||||
|
margin_bottom = 296.0
|
||||||
|
rect_min_size = Vector2( 0, 96 )
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
||||||
|
[node name="Button" type="Button" parent="GUI/VBoxContainer/CenterContainer3"]
|
||||||
|
margin_left = 197.0
|
||||||
|
margin_top = 34.0
|
||||||
|
margin_right = 314.0
|
||||||
|
margin_bottom = 61.0
|
||||||
|
focus_mode = 0
|
||||||
|
custom_fonts/font = SubResource( 11 )
|
||||||
|
custom_styles/normal = SubResource( 12 )
|
||||||
|
enabled_focus_mode = 0
|
||||||
|
text = "Ingresar"
|
||||||
|
script = ExtResource( 5 )
|
||||||
|
|
||||||
|
[connection signal="text_changed" from="GUI/VBoxContainer/CenterContainer2/HBoxContainer/VBoxContainer2/Name" to="GUI/VBoxContainer/CenterContainer2/HBoxContainer/VBoxContainer2/Name" method="_on_text_changed"]
|
||||||
|
[connection signal="focus_exited" from="GUI/VBoxContainer/CenterContainer2/HBoxContainer/VBoxContainer2/Rut" to="GUI/VBoxContainer/CenterContainer2/HBoxContainer/VBoxContainer2/Rut" method="_on_Rut_focus_exited"]
|
||||||
|
[connection signal="text_changed" from="GUI/VBoxContainer/CenterContainer2/HBoxContainer/VBoxContainer2/Rut" to="GUI/VBoxContainer/CenterContainer2/HBoxContainer/VBoxContainer2/Rut" method="_on_Rut_text_changed"]
|
||||||
|
[connection signal="text_changed" from="GUI/VBoxContainer/CenterContainer2/HBoxContainer/VBoxContainer2/Email" to="GUI/VBoxContainer/CenterContainer2/HBoxContainer/VBoxContainer2/Email" method="_on_text_changed"]
|
||||||
|
[connection signal="pressed" from="GUI/VBoxContainer/CenterContainer3/Button" to="GUI/VBoxContainer/CenterContainer3/Button" method="_on_Button_pressed"]
|
@ -49,9 +49,9 @@ var game: Dictionary = {}
|
|||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
game_version = get_parent().game_version
|
game_version = get_parent().game_version
|
||||||
|
|
||||||
player["rut"] = "23.660.457-8"
|
player["rut"] = ""
|
||||||
player["name"] = "Chris Cromer"
|
player["name"] = ""
|
||||||
player["email"] = "chris@cromer.cl"
|
player["email"] = ""
|
||||||
|
|
||||||
var os_name = OS.get_name()
|
var os_name = OS.get_name()
|
||||||
if os_name == "Android":
|
if os_name == "Android":
|
||||||
@ -94,6 +94,10 @@ func _ready() -> void:
|
|||||||
if err != OK:
|
if err != OK:
|
||||||
print(err)
|
print(err)
|
||||||
|
|
||||||
|
err = $MonitorGUI.find_node("Button").connect("input_validated", self, "_on_input_validated")
|
||||||
|
if err != OK:
|
||||||
|
print(err)
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(_delta: float) -> void:
|
func _physics_process(_delta: float) -> void:
|
||||||
if enabled:
|
if enabled:
|
||||||
@ -117,6 +121,12 @@ func _physics_process(_delta: float) -> void:
|
|||||||
start_monitor()
|
start_monitor()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_input_validated(validated_player: Dictionary) -> void:
|
||||||
|
$MonitorGUI.queue_free()
|
||||||
|
get_tree().paused = false
|
||||||
|
player = validated_player.duplicate(true)
|
||||||
|
|
||||||
|
|
||||||
func _object_created(name: String, state: String, position: Vector2, velocity: Vector2) -> void:
|
func _object_created(name: String, state: String, position: Vector2, velocity: Vector2) -> void:
|
||||||
if enabled and started:
|
if enabled and started:
|
||||||
add_object(name, state, position, velocity)
|
add_object(name, state, position, velocity)
|
||||||
@ -211,9 +221,57 @@ func clean_rut(rut: String) -> String:
|
|||||||
rut = rut.to_lower()
|
rut = rut.to_lower()
|
||||||
rut = rut.replace(".", "")
|
rut = rut.replace(".", "")
|
||||||
rut = rut.replace("-", "")
|
rut = rut.replace("-", "")
|
||||||
|
|
||||||
|
var rutTemp: String = rut.substr(0, rut.length() - 1)
|
||||||
|
var verifier: String = rut.substr(rut.length() - 1, 1)
|
||||||
|
|
||||||
|
var regex = RegEx.new()
|
||||||
|
regex.compile("\\D")
|
||||||
|
rutTemp = regex.sub(rutTemp, "", true)
|
||||||
|
|
||||||
|
regex.compile("[^kK\\d]")
|
||||||
|
verifier = regex.sub(verifier, "", true)
|
||||||
|
|
||||||
|
rut = rutTemp + verifier
|
||||||
|
|
||||||
return rut
|
return rut
|
||||||
|
|
||||||
|
|
||||||
|
func pretty_rut(rut: String) -> String:
|
||||||
|
rut = clean_rut(rut)
|
||||||
|
|
||||||
|
var rutTemp: String = rut.substr(0, rut.length() - 1)
|
||||||
|
var verifier: String = rut.substr(rut.length() - 1, 1)
|
||||||
|
|
||||||
|
var regex = RegEx.new()
|
||||||
|
regex.compile("[^kK\\d]")
|
||||||
|
verifier = regex.sub(verifier, "", true)
|
||||||
|
|
||||||
|
var byteArray = rutTemp.to_utf8()
|
||||||
|
byteArray.invert()
|
||||||
|
|
||||||
|
var newByteArray: PoolByteArray = PoolByteArray()
|
||||||
|
var i = 1
|
||||||
|
for symbol in byteArray:
|
||||||
|
newByteArray.append(symbol)
|
||||||
|
if i == 3:
|
||||||
|
newByteArray.append(".".to_utf8()[0])
|
||||||
|
i = 0
|
||||||
|
i = i + 1
|
||||||
|
if newByteArray.size() > 0 and newByteArray[newByteArray.size() - 1] == ".".to_utf8()[0]:
|
||||||
|
newByteArray.resize(newByteArray.size() - 1)
|
||||||
|
|
||||||
|
newByteArray.invert()
|
||||||
|
rutTemp = newByteArray.get_string_from_utf8()
|
||||||
|
|
||||||
|
if rutTemp.length() == 0 and verifier.length() > 0:
|
||||||
|
rutTemp = verifier
|
||||||
|
elif rutTemp.length() > 0 and verifier.length() > 0:
|
||||||
|
rutTemp = rutTemp + "-" + verifier
|
||||||
|
|
||||||
|
return rutTemp
|
||||||
|
|
||||||
|
|
||||||
func is_rut_valid(rut: String) -> bool:
|
func is_rut_valid(rut: String) -> bool:
|
||||||
rut = clean_rut(rut)
|
rut = clean_rut(rut)
|
||||||
if rut.length() < 8 or rut.length() > 9:
|
if rut.length() < 8 or rut.length() > 9:
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
[gd_scene load_steps=3 format=2]
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://monitor/Monitor.gd" type="Script" id=1]
|
[ext_resource path="res://monitor/Monitor.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://monitor/Player.gd" type="Script" id=2]
|
[ext_resource path="res://monitor/GUI.tscn" type="PackedScene" id=3]
|
||||||
|
|
||||||
[node name="Monitor" type="Node"]
|
[node name="Monitor" type="Node"]
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
use_development_url = true
|
use_development_url = true
|
||||||
|
|
||||||
[node name="Player" type="Node" parent="."]
|
[node name="MonitorGUI" parent="." instance=ExtResource( 3 )]
|
||||||
script = ExtResource( 2 )
|
|
||||||
|
|
||||||
[node name="HTTPRequest" type="HTTPRequest" parent="."]
|
[node name="HTTPRequest" type="HTTPRequest" parent="."]
|
||||||
|
13
godot/monitor/Rut.gd
Normal file
13
godot/monitor/Rut.gd
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
extends TextEdit
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Rut_text_changed() -> void:
|
||||||
|
_on_Rut_focus_exited()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Rut_focus_exited() -> void:
|
||||||
|
var monitor = get_tree().get_current_scene().get_node("Monitor")
|
||||||
|
if text.length() > 12:
|
||||||
|
text = text.substr(0, 12)
|
||||||
|
text = monitor.pretty_rut(text)
|
||||||
|
cursor_set_column(text.length())
|
14
godot/monitor/Text.gd
Normal file
14
godot/monitor/Text.gd
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
extends TextEdit
|
||||||
|
|
||||||
|
|
||||||
|
onready var previousText: String = text
|
||||||
|
|
||||||
|
|
||||||
|
func _on_text_changed() -> void:
|
||||||
|
var col = cursor_get_column()
|
||||||
|
# if a scroll bar appears, reset to the previous good string
|
||||||
|
if text.length() > 50:
|
||||||
|
text = previousText
|
||||||
|
col = col - 1
|
||||||
|
previousText = text
|
||||||
|
cursor_set_column(col)
|
Loading…
Reference in New Issue
Block a user