100 lines
3.2 KiB
GDScript
100 lines
3.2 KiB
GDScript
extends Node
|
|
|
|
var default_path: String = "https://tmusic.sanplex.tech"
|
|
var selected_server: int = 1
|
|
|
|
var is_local: bool = false
|
|
|
|
var stop_after_current: bool = true
|
|
var hide_next_track: bool = true
|
|
var add_to_stats: bool = true
|
|
var use_low_played_mode: bool = false
|
|
var winning_score: int = 20
|
|
var fullscreen: bool = false
|
|
var play_local: bool = false
|
|
|
|
var number_of_players: int = 0
|
|
|
|
var version: String = "0.9.0-Beta"
|
|
|
|
var whats_new: String = "Changelog:
|
|
0.9.0-Beta: Fixed settings and updated the player view
|
|
0.8.0-Beta: Fixed reset buttons and some other small things
|
|
0.7.8-Beta: Added shortcuts. Added dialog for winner. Started cleaning code.
|
|
0.7.5-Beta: Added settings menu, most things don't do anythig yet
|
|
0.7-Beta: Can now hop between songs"
|
|
|
|
var whats_left: String = "Things left to do:
|
|
Fix graphics in lists
|
|
Fix layout
|
|
Fix for local play
|
|
Change some buttons to icons"
|
|
|
|
var shortcuts: String = "Shortcuts:
|
|
Alt + S = Search
|
|
Alt + A = Add Players
|
|
Alt + Z = Reset
|
|
Alt + X = Play/Pause
|
|
Alt + C = Next Song
|
|
Alt + V = Show Answer"
|
|
|
|
#play = X
|
|
#nästa = c
|
|
#visa svar = v
|
|
#lägga till poäng? 1, 2, 3, 4, 5, 6
|
|
|
|
func get_next_player_id() -> int:
|
|
number_of_players += 1
|
|
return number_of_players
|
|
|
|
func make_request2(address: String, func_name: Callable, expect_data: bool) -> void:
|
|
print("func_name: ", func_name.get_method())
|
|
print("get_object: ", func_name.get_object())
|
|
var error_handling: Callable = func(_result: int, response_code: int, _headers: PackedStringArray, body: PackedByteArray) -> void:
|
|
print("request done to address: ", default_path + address)
|
|
if response_code == 200:
|
|
if !expect_data:
|
|
func_name.call()
|
|
else:
|
|
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 type: ", typeof(data_received))
|
|
if typeof(data_received) == TYPE_ARRAY:
|
|
func_name.call(data_received)
|
|
elif func_name != null:
|
|
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.
|
|
print("address: ", 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()
|