TD-66 Add login scene, Userinput, HttpRequest
This commit is contained in:
parent
fd00046f84
commit
70cb3b5923
7 changed files with 201 additions and 2 deletions
92
scenes/login.tscn
Normal file
92
scenes/login.tscn
Normal file
|
@ -0,0 +1,92 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://dtaaw31x3n22f"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/v_box_container.gd" id="1_xvh5p"]
|
||||
[ext_resource type="Script" path="res://scripts/Login/login_button.gd" id="2_lg3ab"]
|
||||
[ext_resource type="Script" path="res://scenes/username_label.gd" id="2_sxlqo"]
|
||||
[ext_resource type="Script" path="res://scenes/username_input.gd" id="3_q2601"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_d0bbp"]
|
||||
|
||||
[node name="Login" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="Panel" type="Panel" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_d0bbp")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Panel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -150.0
|
||||
offset_top = -108.0
|
||||
offset_right = 150.0
|
||||
offset_bottom = 108.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/separation = 16
|
||||
script = ExtResource("1_xvh5p")
|
||||
|
||||
[node name="Header" type="RichTextLabel" parent="Panel/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/normal_font_size = 30
|
||||
text = "Login"
|
||||
fit_content = true
|
||||
scroll_active = false
|
||||
autowrap_mode = 0
|
||||
|
||||
[node name="InputContainer" type="VBoxContainer" parent="Panel/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 8
|
||||
|
||||
[node name="UsernameContainer" type="VBoxContainer" parent="Panel/VBoxContainer/InputContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="UsernameLabel" type="RichTextLabel" parent="Panel/VBoxContainer/InputContainer/UsernameContainer"]
|
||||
layout_mode = 2
|
||||
text = "Username:
|
||||
"
|
||||
fit_content = true
|
||||
scroll_active = false
|
||||
script = ExtResource("2_sxlqo")
|
||||
|
||||
[node name="UsernameInput" type="LineEdit" parent="Panel/VBoxContainer/InputContainer/UsernameContainer"]
|
||||
layout_mode = 2
|
||||
script = ExtResource("3_q2601")
|
||||
|
||||
[node name="PasswordContainer" type="VBoxContainer" parent="Panel/VBoxContainer/InputContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="PaswordLabel" type="RichTextLabel" parent="Panel/VBoxContainer/InputContainer/PasswordContainer"]
|
||||
layout_mode = 2
|
||||
text = "Password:"
|
||||
fit_content = true
|
||||
scroll_active = false
|
||||
|
||||
[node name="PasswordInput" type="LineEdit" parent="Panel/VBoxContainer/InputContainer/PasswordContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Button" type="Button" parent="Panel/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Login"
|
||||
script = ExtResource("2_lg3ab")
|
||||
|
||||
[node name="HTTPRequest" type="HTTPRequest" parent="Panel/VBoxContainer"]
|
||||
|
||||
[connection signal="text_changed" from="Panel/VBoxContainer/InputContainer/UsernameContainer/UsernameInput" to="Panel/VBoxContainer" method="_on_username_input_text_changed"]
|
||||
[connection signal="text_changed" from="Panel/VBoxContainer/InputContainer/PasswordContainer/PasswordInput" to="Panel/VBoxContainer" method="_on_password_input_text_changed"]
|
||||
[connection signal="button_up" from="Panel/VBoxContainer/Button" to="Panel/VBoxContainer" method="_on_button_button_up"]
|
||||
[connection signal="request_completed" from="Panel/VBoxContainer/HTTPRequest" to="Panel/VBoxContainer" method="_on_http_request_request_completed"]
|
|
@ -7,6 +7,8 @@
|
|||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = -1.0
|
||||
offset_right = -1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("1_6qgep")
|
||||
|
@ -30,13 +32,19 @@ clip_contents = false
|
|||
layout_mode = 2
|
||||
size_flags_stretch_ratio = 7.45
|
||||
theme_override_font_sizes/normal_font_size = 64
|
||||
text = "Hello World"
|
||||
text = "Epic TD Deluxe"
|
||||
fit_content = true
|
||||
scroll_active = false
|
||||
autowrap_mode = 0
|
||||
|
||||
[node name="Button" type="Button" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Theme Test Scene"
|
||||
text = "Login"
|
||||
script = ExtResource("2_c477a")
|
||||
scene_name = "login"
|
||||
|
||||
[node name="Button2" type="Button" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Testszene"
|
||||
script = ExtResource("2_c477a")
|
||||
scene_name = "theme_test"
|
||||
|
|
11
scenes/username_input.gd
Normal file
11
scenes/username_input.gd
Normal file
|
@ -0,0 +1,11 @@
|
|||
extends LineEdit
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
11
scenes/username_label.gd
Normal file
11
scenes/username_label.gd
Normal file
|
@ -0,0 +1,11 @@
|
|||
extends RichTextLabel
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
47
scenes/v_box_container.gd
Normal file
47
scenes/v_box_container.gd
Normal file
|
@ -0,0 +1,47 @@
|
|||
extends VBoxContainer
|
||||
|
||||
var username = ""
|
||||
var password = ""
|
||||
var url: String = "http://localhost:8080/api/v1/player/login"
|
||||
var headers = ["Content-Type: application/json"]
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _on_username_input_text_changed(new_text: String) -> void:
|
||||
username = new_text
|
||||
pass
|
||||
|
||||
|
||||
func _on_password_input_text_changed(new_text: String) -> void:
|
||||
password = new_text
|
||||
pass
|
||||
|
||||
|
||||
func _on_button_button_up() -> void:
|
||||
var loginData = {"username": username, "password": password}
|
||||
var json = JSON.stringify(loginData)
|
||||
|
||||
print(username)
|
||||
print(password)
|
||||
#$HTTPRequest.request("https://catfact.ninja/fact")
|
||||
$HTTPRequest.request(url, headers, HTTPClient.METHOD_POST, json)
|
||||
print(json)
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func _on_http_request_request_completed(result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray) -> void:
|
||||
print(body.get_string_from_utf8())
|
19
scripts/Login/login_button.gd
Normal file
19
scripts/Login/login_button.gd
Normal file
|
@ -0,0 +1,19 @@
|
|||
extends Node
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _on_button_up() -> void:
|
||||
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func _on_username_input_text_changed(new_text: String) -> void:
|
||||
pass # Replace with function body.
|
11
test.gd
Normal file
11
test.gd
Normal file
|
@ -0,0 +1,11 @@
|
|||
extends Control
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
Loading…
Add table
Reference in a new issue