diff --git a/MainUI.gd b/MainUI.gd deleted file mode 100644 index a1bbfe7..0000000 --- a/MainUI.gd +++ /dev/null @@ -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 diff --git a/MainUI.tscn b/MainUI.tscn deleted file mode 100644 index 671bca5..0000000 --- a/MainUI.tscn +++ /dev/null @@ -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 diff --git a/project.godot b/project.godot index 853416a..cd92595 100644 --- a/project.godot +++ b/project.godot @@ -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 diff --git a/Background.gd b/scenes/Fight/Background.gd similarity index 100% rename from Background.gd rename to scenes/Fight/Background.gd diff --git a/CountDownLabel.gd b/scenes/Fight/CountDownLabel.gd similarity index 100% rename from CountDownLabel.gd rename to scenes/Fight/CountDownLabel.gd diff --git a/DamageLabel.gd b/scenes/Fight/DamageLabel.gd similarity index 100% rename from DamageLabel.gd rename to scenes/Fight/DamageLabel.gd diff --git a/DamageLabel.tscn b/scenes/Fight/DamageLabel.tscn similarity index 97% rename from DamageLabel.tscn rename to scenes/Fight/DamageLabel.tscn index a464f91..979f66e 100644 --- a/DamageLabel.tscn +++ b/scenes/Fight/DamageLabel.tscn @@ -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"] diff --git a/Fighter.gd b/scenes/Fight/Fighter.gd similarity index 100% rename from Fighter.gd rename to scenes/Fight/Fighter.gd diff --git a/Fighter.tscn b/scenes/Fight/Fighter.tscn similarity index 98% rename from Fighter.tscn rename to scenes/Fight/Fighter.tscn index 2c131b1..db216e0 100644 --- a/Fighter.tscn +++ b/scenes/Fight/Fighter.tscn @@ -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) diff --git a/FpsLabel.gd b/scenes/Fight/FpsLabel.gd similarity index 100% rename from FpsLabel.gd rename to scenes/Fight/FpsLabel.gd diff --git a/HpBar.gd b/scenes/Fight/HpBar.gd similarity index 100% rename from HpBar.gd rename to scenes/Fight/HpBar.gd diff --git a/fight.gd b/scenes/Fight/fight.gd similarity index 100% rename from fight.gd rename to scenes/Fight/fight.gd diff --git a/fight.tscn b/scenes/Fight/fight.tscn similarity index 93% rename from fight.tscn rename to scenes/Fight/fight.tscn index 385a4e0..b1889dc 100644 --- a/fight.tscn +++ b/scenes/Fight/fight.tscn @@ -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 diff --git a/scenes/Global/Global.gd b/scenes/Global/Global.gd new file mode 100644 index 0000000..77b169f --- /dev/null +++ b/scenes/Global/Global.gd @@ -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) diff --git a/scenes/Global/Global.tscn b/scenes/Global/Global.tscn new file mode 100644 index 0000000..4bb0b74 --- /dev/null +++ b/scenes/Global/Global.tscn @@ -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"] diff --git a/scenes/UI/Welcome/CreateDojoScreen.gd b/scenes/UI/Welcome/CreateDojoScreen.gd new file mode 100644 index 0000000..096c9a9 --- /dev/null +++ b/scenes/UI/Welcome/CreateDojoScreen.gd @@ -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]" diff --git a/scenes/UI/Welcome/MainUI.gd b/scenes/UI/Welcome/MainUI.gd new file mode 100644 index 0000000..896599d --- /dev/null +++ b/scenes/UI/Welcome/MainUI.gd @@ -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 diff --git a/scenes/UI/Welcome/MainUI.tscn b/scenes/UI/Welcome/MainUI.tscn new file mode 100644 index 0000000..1db47a2 --- /dev/null +++ b/scenes/UI/Welcome/MainUI.tscn @@ -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"] diff --git a/test.txt b/test.txt deleted file mode 100644 index e69de29..0000000