Added icons, a lot of refactoring and optimising
This commit is contained in:
35
Settings.gd
35
Settings.gd
@@ -1,7 +1,7 @@
|
||||
extends Node
|
||||
|
||||
var default_path: String = "https://tmusic.sanplex.tech"
|
||||
var selected_server = 0
|
||||
var selected_server: int = 0
|
||||
|
||||
var is_local: bool = false
|
||||
|
||||
@@ -11,6 +11,7 @@ var add_to_stats: bool = false
|
||||
var use_low_played_mode: bool = false
|
||||
var winning_score: int = 20
|
||||
var fullscreen: bool = false
|
||||
var play_local: bool = false
|
||||
|
||||
var version: String = "0.9.0-Beta"
|
||||
|
||||
@@ -39,26 +40,46 @@ Alt + V = Show Answer"
|
||||
#visa svar = v
|
||||
#lägga till poäng? 1, 2, 3, 4, 5, 6
|
||||
|
||||
|
||||
func make_request2(address: String, func_name: Callable, expect_data: bool) -> void:
|
||||
var error_handling = func(_result: int, response_code: int, _headers: PackedStringArray, body: PackedByteArray):
|
||||
var error_handling: Callable = func(_result: int, response_code: int, _headers: PackedStringArray, body: PackedByteArray) -> void:
|
||||
if response_code == 200:
|
||||
if !expect_data:
|
||||
func_name.call()
|
||||
else:
|
||||
var json = JSON.new()
|
||||
var error = json.parse(body.get_string_from_utf8())
|
||||
var json: JSON = JSON.new()
|
||||
var error: int = json.parse(body.get_string_from_utf8())
|
||||
if error == OK:
|
||||
var data_received = json.get_data()
|
||||
print("data_received: ", data_received)
|
||||
#print("data_received: ", data_received)
|
||||
print("data_received type: ", typeof(data_received))
|
||||
func_name.call(data_received)
|
||||
else:
|
||||
print("song_received")
|
||||
func_name.call(body)
|
||||
|
||||
var http_request: HTTPRequest = HTTPRequest.new()
|
||||
add_child(http_request)
|
||||
http_request.request_completed.connect(error_handling)
|
||||
|
||||
# Perform a GET request. The URL below returns JSON as of writing.
|
||||
var request_error = http_request.request(default_path + address)
|
||||
var request_error: int = http_request.request(default_path + address)
|
||||
if request_error != OK:
|
||||
push_error("An error occurred in the HTTP request.")
|
||||
|
||||
func make_request3(address: String) -> void:
|
||||
var error_handling: Callable = func(_result: int, response_code: int, _headers: PackedStringArray, _body: PackedByteArray) -> void:
|
||||
if response_code != 200:
|
||||
print("Error: " + str(response_code))
|
||||
|
||||
var http_request: HTTPRequest = HTTPRequest.new()
|
||||
add_child(http_request)
|
||||
http_request.request_completed.connect(error_handling)
|
||||
# Perform a GET request. The URL below returns JSON as of writing.
|
||||
var request_error: int = http_request.request(default_path + address)
|
||||
if request_error != OK:
|
||||
push_error("An error occurred in the HTTP request.")
|
||||
|
||||
func delete_children(node: Node) -> void:
|
||||
for n: Node in node.get_children():
|
||||
node.remove_child(n)
|
||||
n.queue_free()
|
||||
|
||||
Reference in New Issue
Block a user