Restructured code base and added a UI

main
Hecht 3 weeks ago
parent ea58339b63
commit b8984833c3

@ -1,11 +0,0 @@
extends Control
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass

@ -1,17 +0,0 @@
[gd_scene load_steps=2 format=3 uid="uid://b2bsdrkc45qco"]
[ext_resource type="Script" path="res://MainUI.gd" id="1_lc711"]
[node name="Control" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_lc711")
[node name="Label" type="Label" parent="."]
layout_mode = 0
offset_right = 40.0
offset_bottom = 23.0

@ -11,11 +11,15 @@ config_version=5
[application]
config/name="Animegame-Client"
run/main_scene="res://fight.tscn"
config/features=PackedStringArray("4.1", "GL Compatibility")
run/main_scene="res://scenes/UI/Welcome/MainUI.tscn"
config/features=PackedStringArray("4.2", "GL Compatibility")
boot_splash/image="res://assets/Splash/splash_b.png"
config/icon="res://icon.svg"
[autoload]
Global="*res://scenes/Global/Global.tscn"
[display]
window/size/viewport_width=640

@ -1,6 +1,6 @@
[gd_scene load_steps=9 format=3 uid="uid://blhw157wwm02k"]
[ext_resource type="Script" path="res://DamageLabel.gd" id="1_bkmpf"]
[ext_resource type="Script" path="res://scenes/Fight/DamageLabel.gd" id="1_bkmpf"]
[ext_resource type="Texture2D" uid="uid://lrlnbd1xfm00" path="res://assets/Sprites/DamageBubble.png" id="1_hhymi"]
[sub_resource type="Animation" id="Animation_o4lh5"]

@ -1,9 +1,9 @@
[gd_scene load_steps=20 format=3 uid="uid://di8on8rry21wa"]
[ext_resource type="Script" path="res://Fighter.gd" id="1_k2s5v"]
[ext_resource type="Script" path="res://scenes/Fight/Fighter.gd" id="1_k2s5v"]
[ext_resource type="Shader" path="res://assets/Shader/aura.gdshader" id="2_tgww4"]
[ext_resource type="Texture2D" uid="uid://cgshiy0fb84fy" path="res://assets/Sprites/red hood itch free Copy-Sheet.png" id="2_y8862"]
[ext_resource type="PackedScene" uid="uid://blhw157wwm02k" path="res://DamageLabel.tscn" id="3_nllc3"]
[ext_resource type="PackedScene" uid="uid://blhw157wwm02k" path="res://scenes/Fight/DamageLabel.tscn" id="3_nllc3"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_r07wr"]
resource_local_to_scene = true
@ -254,10 +254,10 @@ metadata/_aseprite_wizard_config_ = {
}
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
speed_scale = 1.5
libraries = {
"": SubResource("AnimationLibrary_jbrqc")
}
speed_scale = 1.5
[node name="DamageLabel" parent="." instance=ExtResource("3_nllc3")]
position = Vector2(-9, -5)

@ -1,15 +1,15 @@
[gd_scene load_steps=14 format=3 uid="uid://c6k2qn8l56rf5"]
[ext_resource type="PackedScene" uid="uid://di8on8rry21wa" path="res://Fighter.tscn" id="1_1yg04"]
[ext_resource type="Script" path="res://fight.gd" id="1_3edp6"]
[ext_resource type="PackedScene" uid="uid://di8on8rry21wa" path="res://scenes/Fight/Fighter.tscn" id="1_1yg04"]
[ext_resource type="Script" path="res://scenes/Fight/fight.gd" id="1_3edp6"]
[ext_resource type="Texture2D" uid="uid://ddsu16o54xyph" path="res://assets/Sprites/086-OtcZb45.png" id="2_h40sr"]
[ext_resource type="Script" path="res://Background.gd" id="3_dsftl"]
[ext_resource type="Script" path="res://FpsLabel.gd" id="3_xkxlv"]
[ext_resource type="Script" path="res://scenes/Fight/Background.gd" id="3_dsftl"]
[ext_resource type="Script" path="res://scenes/Fight/FpsLabel.gd" id="3_xkxlv"]
[ext_resource type="Script" path="res://UserLabel.gd" id="4_beyjo"]
[ext_resource type="Texture2D" uid="uid://c6aahxuqcgcnp" path="res://assets/Sprites/texture-bar-progress-0001.png" id="5_fa5wd"]
[ext_resource type="Texture2D" uid="uid://bg5m7faciqihv" path="res://assets/Sprites/texture-bar-outer-0001.png" id="6_gxbv2"]
[ext_resource type="Script" path="res://HpBar.gd" id="7_po066"]
[ext_resource type="Script" path="res://CountDownLabel.gd" id="8_nagyd"]
[ext_resource type="Script" path="res://scenes/Fight/HpBar.gd" id="7_po066"]
[ext_resource type="Script" path="res://scenes/Fight/CountDownLabel.gd" id="8_nagyd"]
[sub_resource type="Animation" id="Animation_cemsf"]
length = 0.001

@ -0,0 +1,51 @@
extends Node2D
@onready var http_request = $HTTPRequest
# var base_address = "https://animegame.eu/api"
var base_address = "http://localhost:8000/api"
var auth_token = null
func create_dojo(dojo_name : String):
## Maybe get the HTTPRequest via parameter?
var body = JSON.stringify({"name": dojo_name})
if http_request.get_http_client_status():
# Prevent simultaneous request!
push_error("Busy with ongoing transaction!")
return
# _create_dojo_request.request_completed.connect(self._http_request_completed)
var error = http_request.request("{address}/dojos".format({"address": base_address}), ["Content-Type: application/json"], HTTPClient.METHOD_POST, body)
if error != OK:
push_error("An error occurred in the HTTP request.")
else:
print("Okay?")
print("Amount of children %s" % get_child_count())
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
pass
func _on_http_request_request_completed(_result, _response_code, headers, body):
## Where to get the response to?
print("Completed?")
var json = JSON.new()
json.parse(body.get_string_from_utf8())
var response = json.get_data()
# Will print the user agent string used by the HTTPRequest node (as recognized by httpbin.org).
print(headers)
print(response)

@ -0,0 +1,10 @@
[gd_scene load_steps=2 format=3 uid="uid://cuxlued7m7m4h"]
[ext_resource type="Script" path="res://scenes/Global/Global.gd" id="1_yoteo"]
[node name="Global" type="Node2D"]
script = ExtResource("1_yoteo")
[node name="HTTPRequest" type="HTTPRequest" parent="."]
[connection signal="request_completed" from="HTTPRequest" to="." method="_on_http_request_request_completed"]

@ -0,0 +1,29 @@
extends Control
@onready var _submit_button = $Button
@onready var _dojo_name_input = $LineEdit
@onready var _error_label = $RichTextLabel
@onready var _global_scn = get_node("/root/Global")
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func _on_submit_button_button_up():
if (_submit_button.is_hovered()):
var regex = RegEx.new()
regex.compile("^\\w[\\w\\d]+$")
var result = regex.search(_dojo_name_input.text)
if result:
_error_label.visible = false
_global_scn.create_dojo(_dojo_name_input.text)
else:
_error_label.visible = true
_error_label.text = "[color=red][b]Kein gültiger Name :P[/b][/color]"

@ -0,0 +1,16 @@
extends Control
@onready var welcome_screen = $WelcomeScreen
@onready var create_dojo_screen = $CreateDojoScreen
# Called when the node enters the scene tree for the first time.
func _ready():
# TODO: Request the users dojo (if not open the account creation wizard
welcome_screen.visible = false
create_dojo_screen.visible = true
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass

@ -0,0 +1,82 @@
[gd_scene load_steps=3 format=3 uid="uid://b2bsdrkc45qco"]
[ext_resource type="Script" path="res://scenes/UI/Welcome/MainUI.gd" id="1_lc711"]
[ext_resource type="Script" path="res://scenes/UI/Welcome/CreateDojoScreen.gd" id="2_nllj2"]
[node name="Control" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -3.0
offset_top = 1.0
offset_right = 1.0
offset_bottom = -9.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_lc711")
[node name="WelcomeScreen" type="Control" parent="."]
anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0
[node name="LanguageScreen" type="Control" parent="."]
visible = false
anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0
[node name="AlumniQuestionScreen" type="Control" parent="."]
visible = false
anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0
[node name="AlumniQuestionsScreen" type="Control" parent="."]
visible = false
anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0
[node name="CreateDojoScreen" type="Control" parent="."]
visible = false
anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0
script = ExtResource("2_nllj2")
[node name="Label" type="Label" parent="CreateDojoScreen"]
layout_mode = 0
offset_left = 207.0
offset_top = 143.0
offset_right = 349.0
offset_bottom = 171.0
text = "Name des Dojo:"
[node name="LineEdit" type="LineEdit" parent="CreateDojoScreen"]
layout_mode = 0
offset_left = 209.0
offset_top = 166.0
offset_right = 332.0
offset_bottom = 199.0
[node name="Button" type="Button" parent="CreateDojoScreen"]
layout_mode = 0
offset_left = 209.0
offset_top = 205.0
offset_right = 334.0
offset_bottom = 236.0
text = "submit"
[node name="RichTextLabel" type="RichTextLabel" parent="CreateDojoScreen"]
visible = false
layout_mode = 0
offset_left = 209.0
offset_top = 239.0
offset_right = 333.0
offset_bottom = 279.0
bbcode_enabled = true
text = "[b]Fooo[/b]"
[connection signal="button_up" from="CreateDojoScreen/Button" to="CreateDojoScreen" method="_on_submit_button_button_up"]
Loading…
Cancel
Save