parent
699905b2ef
commit
a325679c95
After Width: | Height: | Size: 5.0 MiB |
@ -0,0 +1,34 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dbdlo6usavqqc"
|
||||||
|
path="res://.godot/imported/Gymzaal.png-963f5a16292a195c271b39340fcd1863.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/Background/Gymzaal.png"
|
||||||
|
dest_files=["res://.godot/imported/Gymzaal.png-963f5a16292a195c271b39340fcd1863.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
@ -0,0 +1,78 @@
|
|||||||
|
extends HTTPRequest
|
||||||
|
|
||||||
|
const Response = preload("../util/Response.gd")
|
||||||
|
|
||||||
|
var _callback : Callable
|
||||||
|
var auth_token: String
|
||||||
|
var base_address: String
|
||||||
|
|
||||||
|
# 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 post_http_request(url: String, request_data: String) -> Response:
|
||||||
|
return await _send_http_request_sync(url, HTTPClient.METHOD_POST, request_data)
|
||||||
|
|
||||||
|
func patch_http_request(url: String, request_data: String) -> Response:
|
||||||
|
return await _send_http_request_sync(url, HTTPClient.METHOD_PATCH, request_data)
|
||||||
|
|
||||||
|
func get_http_request(url: String, callback : Callable) -> bool:
|
||||||
|
return _send_http_request(url, HTTPClient.METHOD_GET, callback)
|
||||||
|
|
||||||
|
func get_http_request_sync(url: String) -> Response:
|
||||||
|
return await _send_http_request_sync(url, HTTPClient.METHOD_GET)
|
||||||
|
|
||||||
|
func _send_http_request_sync(url: String, method: HTTPClient.Method, request_data: String = "") -> Response:
|
||||||
|
var result: Response = Response.new()
|
||||||
|
result.status = FAILED
|
||||||
|
result.code = HTTPClient.ResponseCode.RESPONSE_BAD_REQUEST
|
||||||
|
result.data = {}
|
||||||
|
|
||||||
|
var lambda = func(response):
|
||||||
|
result.status = response.status
|
||||||
|
result.code = response.code
|
||||||
|
result.data = response.data
|
||||||
|
|
||||||
|
if !_send_http_request(url, method, lambda, request_data):
|
||||||
|
return result
|
||||||
|
|
||||||
|
await request_completed
|
||||||
|
return result
|
||||||
|
|
||||||
|
func _send_http_request(url: String, method: HTTPClient.Method, callback : Callable, request_data : String = "") -> bool:
|
||||||
|
_callback = callback
|
||||||
|
|
||||||
|
var _url = "{address}/{url}".format({"address": base_address, "url": url})
|
||||||
|
|
||||||
|
print_debug("%s request on %s with: %s" % [method, _url, request_data])
|
||||||
|
|
||||||
|
var headers = ["X-AUTH-TOKEN: %s" % auth_token, "accept: application/json"]
|
||||||
|
if method == HTTPClient.METHOD_PATCH:
|
||||||
|
headers.append("Content-Type: application/merge-patch+json")
|
||||||
|
elif method == HTTPClient.METHOD_POST:
|
||||||
|
headers.append("Content-Type: application/json")
|
||||||
|
|
||||||
|
var error = request(_url, headers, method, request_data)
|
||||||
|
|
||||||
|
return error == OK
|
||||||
|
|
||||||
|
func _on_request_completed(result, response_code, headers, body):
|
||||||
|
var response : Response = Response.new()
|
||||||
|
response.status = FAILED
|
||||||
|
response.code = response_code
|
||||||
|
response.data = {}
|
||||||
|
|
||||||
|
## Where to get the response to?
|
||||||
|
if result == HTTPRequest.RESULT_SUCCESS and response_code / 100 == 2:
|
||||||
|
response.status = OK
|
||||||
|
var json = JSON.new()
|
||||||
|
json.parse(body.get_string_from_utf8())
|
||||||
|
response.data = json.get_data()
|
||||||
|
|
||||||
|
_callback.call(response)
|
@ -1,68 +1,60 @@
|
|||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
@onready var http_request = $HTTPRequest
|
@onready var _http_request = $HTTPRequest
|
||||||
|
|
||||||
# var base_address = "https://animegame.eu/api"
|
const Response = preload("../util/Response.gd")
|
||||||
var base_address = "http://localhost:8000/api"
|
|
||||||
var auth_token = null
|
|
||||||
var user_name = "FooBar"
|
|
||||||
|
|
||||||
func create_dojo(dojo_name : String):
|
var user_name : String = "FooBar"
|
||||||
## Maybe get the HTTPRequest via parameter?
|
var _dojo : Dictionary = {}
|
||||||
|
var _user: Dictionary = {}
|
||||||
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", "X-AUTH-TOKEN: %s" % auth_token], 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.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
print_debug("Global Scene is ready!")
|
_http_request.base_address = "http://localhost:8000/api"
|
||||||
|
_http_request.auth_token = "_sGFrChRV6ML0eWZC2qSUZzEGNLPbAhP4dwmnWhQ5bQ9xIi2pwHWQ1CzybFPDLeK8dTNx6GgWdR-Jcz-Z9_aC0hlY2h0fDIwMjQtMDYtMTNUMTk6MTU6MzkrMDA6MDA="
|
||||||
|
|
||||||
for argument in OS.get_cmdline_user_args():
|
for argument in OS.get_cmdline_user_args():
|
||||||
print_debug("argument: %s" % argument)
|
print_debug("argument: %s" % argument)
|
||||||
var key_value = argument.split("=", true, 1)
|
var key_value = argument.split("=", true, 1)
|
||||||
if "--token" == key_value[0]:
|
if "--token" == key_value[0]:
|
||||||
print_debug("key_value[0]: %s" % key_value[0])
|
_http_request.auth_token = key_value[1]
|
||||||
print_debug("key_value[1]: %s" % key_value[1])
|
elif "--env" == key_value[0]:
|
||||||
self.auth_token = key_value[1]
|
if key_value[1] == "dev":
|
||||||
|
_http_request.base_address = "http://localhost:8000/api"
|
||||||
# replace \-_ with /\+
|
else:
|
||||||
print_debug("auth_token before: %s", self.auth_token)
|
_http_request.base_address = "https://dojo.animegame.eu/api"
|
||||||
print_debug("auth_token after: %s", self.auth_token.replace("\\", "/").replace("-", "\\").replace("_", "+"))
|
|
||||||
|
var tmp = _http_request.auth_token.replace("-", "/").replace("_", "+")
|
||||||
var chunks = Marshalls.base64_to_raw(self.auth_token.replace("\\", "/").replace("-", "\\").replace("_", "+"))
|
|
||||||
self.user_name = chunks.slice(64).get_string_from_utf8().split('|')[0]
|
|
||||||
|
|
||||||
print_debug("user name: %s" % self.user_name)
|
|
||||||
|
|
||||||
|
|
||||||
|
# replace \-_ with /\+
|
||||||
|
var chunks = Marshalls.base64_to_raw(tmp)
|
||||||
|
user_name = chunks.slice(64).get_string_from_utf8().split('|')[0]
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func _on_http_request_request_completed(_result, _response_code, headers, body):
|
func create_dojo(dojo_name : String) -> Response:
|
||||||
## Where to get the response to?
|
var body = JSON.stringify({"name": dojo_name})
|
||||||
|
return await _http_request.post_http_request("dojos", body)
|
||||||
print("Completed?")
|
|
||||||
|
func update_user_preferences(values: Dictionary) -> Response:
|
||||||
var json = JSON.new()
|
var body = JSON.stringify({"properties": values})
|
||||||
json.parse(body.get_string_from_utf8())
|
var user = await get_user()
|
||||||
var response = json.get_data()
|
return await _http_request.patch_http_request("users/%s" % user["id"], body)
|
||||||
|
|
||||||
# Will print the user agent string used by the HTTPRequest node (as recognized by httpbin.org).
|
func get_dojo() -> Dictionary:
|
||||||
print(headers)
|
if _dojo.is_empty():
|
||||||
print(response)
|
var result: Response = await _http_request.get_http_request_sync("dojo")
|
||||||
|
if result.status == OK:
|
||||||
|
_dojo = result.data
|
||||||
|
|
||||||
|
return _dojo
|
||||||
|
|
||||||
|
func get_user() -> Dictionary:
|
||||||
|
if _user.is_empty():
|
||||||
|
var result = await _http_request.get_http_request_sync("users/authName/%s" % user_name)
|
||||||
|
if result.status == OK:
|
||||||
|
_user = result.data
|
||||||
|
return _user
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
[gd_scene load_steps=2 format=3 uid="uid://3qgip1nsocyh"]
|
[gd_scene load_steps=3 format=3 uid="uid://3qgip1nsocyh"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scenes/Global/Global.gd" id="1_yoteo"]
|
[ext_resource type="Script" path="res://scenes/Global/Global.gd" id="1_yoteo"]
|
||||||
|
[ext_resource type="Script" path="res://scenes/Global/APIRequest.gd" id="2_jxuea"]
|
||||||
|
|
||||||
[node name="Global" type="Node2D"]
|
[node name="Global" type="Node2D"]
|
||||||
script = ExtResource("1_yoteo")
|
script = ExtResource("1_yoteo")
|
||||||
|
|
||||||
[node name="HTTPRequest" type="HTTPRequest" parent="."]
|
[node name="HTTPRequest" type="HTTPRequest" parent="."]
|
||||||
|
script = ExtResource("2_jxuea")
|
||||||
|
|
||||||
[connection signal="request_completed" from="HTTPRequest" to="." method="_on_http_request_request_completed"]
|
[connection signal="request_completed" from="HTTPRequest" to="HTTPRequest" method="_on_request_completed"]
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
var status : Error
|
||||||
|
var code : HTTPClient.ResponseCode
|
||||||
|
var data : Dictionary
|
@ -1,13 +1,52 @@
|
|||||||
|
[background arg="res://assets/Background/Gymzaal.png" fade="0.0"]
|
||||||
join Master 0
|
join Master 0
|
||||||
if {dojo} != null:
|
if {dojo} == "":
|
||||||
Master: Hallo ehrwürdiger Schutzgeist {user}. Willkommen in unserem bescheidenen Dorf.
|
Master: Hallo ehrwürdiger Schutzgeist {user}. Willkommen in unserem bescheidenen Dorf.
|
||||||
- Schutzeist, Dorf?
|
- Schutzgeist, Dorf?
|
||||||
Master: Haha, ich sehe schon das du dich noch an diese Welt gewöhnen musst. Aber keiner Sorge, ich werde dir helfen dich hier zurecht zu finden,
|
Master: Haha, ich sehe schon das du dich noch an diese Welt gewöhnen musst. Aber keiner Sorge, ich werde dir helfen dich hier zurecht zu finden,
|
||||||
label SelectDojoName
|
label SelectDojoName
|
||||||
Master: Zuerst, welchen Namen soll dein Dojo bekommen?
|
Master: Zuerst, welchen Namen soll dein Dojo bekommen?
|
||||||
[text_input var="newdojo"]
|
[text_input var="newdojo"]
|
||||||
[signal arg="create_dojo"]
|
[signal arg="create_dojo"]
|
||||||
if {newdojo} != "WTF":
|
if {dojo} != {newdojo}:
|
||||||
Master: Irgendwas ging schief. Probiers gleich nochmal...
|
Master: Irgendwas ging schief. Probiers gleich nochmal...
|
||||||
jump SelectDojoName
|
jump SelectDojoName
|
||||||
Master: Dann werden wir nun am Aufbau von {newdojo} arbeiten!
|
Master: Dann werden wir nun am Aufbau von {dojo} arbeiten!
|
||||||
|
leave Master
|
||||||
|
Ich hoffe euch hat die interaktive Dojo erstellung gefallen. Keine Sorge, das Animegame wird keine Visual Novel werden. Ich dachte mir, wenn wir schon eine Game-Engine nutzen, dann können wir auch spröde Menüs damit etwas aufpeppen.
|
||||||
|
Im neue Animegame könnt ihr wieder in Turnieren gegeneinander antreten. Es wird auch eine Welt geben. Die Spieler werden in verschiedene (virtuelle) Länder aufgeteilt. Die Besten jedes dieser Länder treten gegeneinander im Weltturnier an.
|
||||||
|
Um die erste Einteilung der Spielewelt zu erleichtern haben wir ein paar Fragen an dich.
|
||||||
|
if {bg.country} == "":
|
||||||
|
Aus welchem Land kommst du?
|
||||||
|
- Deutschland
|
||||||
|
set {bg.country} = "D"
|
||||||
|
- Österreich
|
||||||
|
set {bg.country} = "A"
|
||||||
|
- Niederlande
|
||||||
|
set {bg.country} = "NL"
|
||||||
|
- Sonstiges
|
||||||
|
[text_input var="bg.country"]
|
||||||
|
if {bg.community} == "":
|
||||||
|
Von welcher Community kann man dich zuordnen?
|
||||||
|
- DBBG & NBG
|
||||||
|
set {bg.community} = "DBBG"
|
||||||
|
- Animegame 1.0
|
||||||
|
set {bg.community} = "OAG"
|
||||||
|
- Andere
|
||||||
|
[text_input var="bg.community"]
|
||||||
|
if {bg.username} == "":
|
||||||
|
Warst du im alten AG registriert?
|
||||||
|
- Ja
|
||||||
|
Unter welchem Benutzernamen kennen dich die meisten?
|
||||||
|
[text_input var="bg.username"]
|
||||||
|
- Nein
|
||||||
|
set {bg.username} = "N/A"
|
||||||
|
if {bg.clan} == "":
|
||||||
|
if {bg.username} != "N/A":
|
||||||
|
In welchem Clan warst du?
|
||||||
|
[text_input var="bg.clan"]
|
||||||
|
Vielen Dank für die Informationen!
|
||||||
|
[signal arg="update_preferences"]
|
||||||
|
Das wars leider schon wieder! \:(
|
||||||
|
[signal arg="the_end"]
|
||||||
|
[end_timeline]
|
||||||
|
Loading…
Reference in new issue