Fixed light icons. Made the search "better". Added more shortcuts and tried to fix som bugs.
This commit is contained in:
@@ -133,7 +133,15 @@ var current_player: Node
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
next_button.pressed.connect(music_player_container.fetch_next_song)
|
||||
var is_debug := OS.has_feature("debug")
|
||||
var is_mac := OS.has_feature("macos")
|
||||
if is_debug:
|
||||
print("is_debug")
|
||||
Settings.default_path = "http://localhost:8080"
|
||||
Settings.selected_server = 3
|
||||
if is_mac:
|
||||
print("is_mac")
|
||||
next_button.pressed.connect(next_track)
|
||||
show_answer_button.pressed.connect(show_answer_pressed)
|
||||
search_button.pressed.connect(show_search)
|
||||
sync_button.pressed.connect(sync_games)
|
||||
@@ -147,6 +155,7 @@ func _ready() -> void:
|
||||
character_select.connect("character_selected", _on_character_selected)
|
||||
new_player_name_field.connect("enter_key_pressed", add_player)
|
||||
music_player_container.connect("add_to_queue", _on_add_to_queue)
|
||||
music_player_container.connect("show_answer", show_answer_pressed)
|
||||
|
||||
add_players_button.pressed.connect(add_players)
|
||||
add_player_button.pressed.connect(add_player)
|
||||
@@ -154,18 +163,39 @@ func _ready() -> void:
|
||||
|
||||
get_suggestion_list()
|
||||
fetch_full_music_list_at_start()
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventKey and event.pressed:
|
||||
if event.alt_pressed && event.keycode == KEY_UP:
|
||||
print("Alt + UP pressed")
|
||||
music_player_container.change_volume(0.05)
|
||||
if event.alt_pressed && event.keycode == KEY_DOWN:
|
||||
print("Alt + DOWN pressed")
|
||||
music_player_container.change_volume(-0.05)
|
||||
if event.alt_pressed && event.keycode == KEY_LEFT:
|
||||
print("Alt + LEFT pressed")
|
||||
music_player_container.seek(-5)
|
||||
if event.alt_pressed && event.keycode == KEY_RIGHT:
|
||||
print("Alt + RIGHT pressed")
|
||||
music_player_container.seek(5)
|
||||
|
||||
func next_track() -> void:
|
||||
next_button.disabled = true
|
||||
music_player_container.fetch_next_song()
|
||||
|
||||
func reset_playlist() -> void:
|
||||
print("reset_playlist")
|
||||
Settings.make_request2("/music/reset", fetch_full_music_list_at_start, false)
|
||||
|
||||
func reset_points() -> void:
|
||||
print("reset_points")
|
||||
var players_to_reset: Array = players.get_children()
|
||||
for player_to_reset: Node in players_to_reset:
|
||||
if player_to_reset.has_method("reset_points"):
|
||||
player_to_reset.reset_points()
|
||||
|
||||
func show_about() -> void:
|
||||
print("show_about")
|
||||
about_popup.visible = true
|
||||
version_label.text = Settings.version
|
||||
whats_new_label.text = Settings.whats_new
|
||||
@@ -173,32 +203,43 @@ func show_about() -> void:
|
||||
coming_label.text = Settings.whats_left
|
||||
|
||||
func show_settings() -> void:
|
||||
print("show_settings")
|
||||
settings_popup.visible = true
|
||||
|
||||
func get_statistics() -> void:
|
||||
print("get_statistics")
|
||||
statistic_popup.visible = true
|
||||
statistic_label.text = "Total amount of games in the playlist: " + str(games.size())
|
||||
|
||||
func _on_add_to_queue() -> void:
|
||||
print("add_to_queue")
|
||||
print("_on_add_to_queue")
|
||||
next_button.disabled = false
|
||||
Settings.make_request2("/music/addQue", fetched, false)
|
||||
game_label.text = "????????"
|
||||
song_label.text = "??????"
|
||||
|
||||
func sync_games() -> void:
|
||||
var games_synced: Callable = func() -> void:
|
||||
print("sync_games")
|
||||
sync_button.disabled = true
|
||||
var games_synced: Callable = func games_synced() -> void:
|
||||
sync_button.disabled = false
|
||||
sync_popup.visible = true
|
||||
print("games_synced")
|
||||
reset_playlist()
|
||||
get_suggestion_list()
|
||||
search_view.get_list_of_games()
|
||||
Settings.make_request2("/sync", games_synced, false)
|
||||
|
||||
func get_suggestion_list() -> void:
|
||||
var populate_list: Callable = func(array: Array) -> void:
|
||||
print("get_suggestion_list")
|
||||
var populate_list: Callable = func(array) -> void:
|
||||
if typeof(array) == TYPE_ARRAY:
|
||||
games = []
|
||||
games.append_array(array)
|
||||
for game: String in games:
|
||||
var inspiration_label: Label= Label.new()
|
||||
inspiration_label.set_texture_filter(TextureFilter.TEXTURE_FILTER_NEAREST)
|
||||
inspiration_label.add_theme_font_size_override("font_size", 20)
|
||||
inspiration_label.text = game
|
||||
inspiration_label.autowrap_mode = TextServer.AUTOWRAP_WORD
|
||||
inspiration_list.add_child(inspiration_label)
|
||||
@@ -208,13 +249,16 @@ func get_suggestion_list() -> void:
|
||||
Settings.make_request2("/music/all", populate_list, true)
|
||||
|
||||
func add_players() -> void:
|
||||
print("add_players")
|
||||
add_player_container.visible = !add_player_container.visible
|
||||
new_player_name_field.grab_focus()
|
||||
|
||||
func add_player() -> void:
|
||||
print("add_player")
|
||||
var new_player: Node = player.instantiate()
|
||||
new_player.player_name = new_player_name_field.text
|
||||
new_player.player_score = new_player_name_field.text + ": 0"
|
||||
new_player.id = Settings.get_next_player_id()
|
||||
new_player_name_field.text = ""
|
||||
players.add_child(new_player)
|
||||
new_player.connect("change_character_clicked", _on_player_change_character_clicked.bind(new_player))
|
||||
@@ -224,17 +268,20 @@ func add_player() -> void:
|
||||
new_player.connect("player_removed", _on_player_removed.bind(new_player))
|
||||
|
||||
func _on_player_won(player_name: String) -> void:
|
||||
print("_on_player_won")
|
||||
winner_popup.visible = true
|
||||
winner_label.text = player_name + " won!!"
|
||||
music_player_container.play_sound(preload("res://sounds/winning.mp3"))
|
||||
|
||||
func show_search() -> void:
|
||||
print("show_search")
|
||||
if search_view.visible == false:
|
||||
search_view.visible = true
|
||||
else:
|
||||
search_view.visible = false
|
||||
|
||||
func show_answer_pressed() -> void:
|
||||
print("show_answer_pressed")
|
||||
var show_fetched: Callable = func(data_received: Dictionary) -> void:
|
||||
print("show_fetched data_received: ", data_received)
|
||||
game_label.text = data_received.Game
|
||||
@@ -243,12 +290,14 @@ func show_answer_pressed() -> void:
|
||||
var actual_string: String = format_string % [(data_received.SongNo+1), data_received.Game, data_received.Song]
|
||||
if next_label == null:
|
||||
next_label = Label.new()
|
||||
next_label.set_texture_filter(TextureFilter.TEXTURE_FILTER_NEAREST)
|
||||
next_label.add_theme_font_size_override("font_size", 20)
|
||||
next_label.text = actual_string
|
||||
Settings.make_request2("/music/info", show_fetched, true)
|
||||
|
||||
func fetch_full_music_list_at_start() -> void:
|
||||
print("fetch_full_music_list_at_start")
|
||||
var show_music_list_at_start: Callable = func(data: Array) -> void:
|
||||
var show_music_list_at_start: Callable = func(data) -> void:
|
||||
if data == null:
|
||||
song_list = []
|
||||
Settings.delete_children(music_list)
|
||||
@@ -256,8 +305,12 @@ func fetch_full_music_list_at_start() -> void:
|
||||
if typeof(data) == TYPE_ARRAY:
|
||||
song_list = []
|
||||
song_list.append_array(data)
|
||||
print("song_list", song_list)
|
||||
for song: Dictionary in song_list:
|
||||
var music_list_label: Label = Label.new()
|
||||
music_list_label.set_texture_filter(TextureFilter.TEXTURE_FILTER_NEAREST)
|
||||
music_list_label.add_theme_font_size_override("font_size", 20)
|
||||
music_list_label.autowrap_mode = TextServer.AUTOWRAP_WORD
|
||||
var format_string: String = "%d. %s - %s"
|
||||
var actual_string: String = format_string % [(song.SongNo+1), song.Game, song.Song]
|
||||
music_list_label.text = actual_string
|
||||
@@ -269,14 +322,17 @@ func fetch_full_music_list_at_start() -> void:
|
||||
Settings.make_request2("/music/list", show_music_list_at_start, true)
|
||||
|
||||
func fetch_full_music_list(event: InputEvent, song_no: int) -> void:
|
||||
print("fetch_full_music_list")
|
||||
if (event is InputEventMouseButton && event.pressed && event.button_index == MOUSE_BUTTON_LEFT):
|
||||
var show_music_list: Callable = func(data_received: Array) -> void:
|
||||
var show_music_list: Callable = func(data_received) -> void:
|
||||
if typeof(data_received) == TYPE_ARRAY:
|
||||
song_list = []
|
||||
song_list.append_array(data_received)
|
||||
Settings.delete_children(music_list)
|
||||
for song: Dictionary in song_list:
|
||||
var music_label: Label= Label.new()
|
||||
music_label.set_texture_filter(TextureFilter.TEXTURE_FILTER_NEAREST)
|
||||
music_label.add_theme_font_size_override("font_size", 20)
|
||||
game_label.text = song.Game
|
||||
song_label.text = song.Song
|
||||
var format_string: String = "%d. %s - %s"
|
||||
@@ -294,13 +350,14 @@ func fetch_full_music_list(event: InputEvent, song_no: int) -> void:
|
||||
Settings.make_request2("/music?song=" + str(song_no), music_player_container.play_song, true)
|
||||
Settings.make_request2("/music/info", show_answer, true)
|
||||
|
||||
func show_answer(answer: JSON) -> void:
|
||||
print("show_answer1: ", answer)
|
||||
game_label.text = answer.Game
|
||||
song_label.text = answer.Song
|
||||
func show_answer(answer: Dictionary) -> void:
|
||||
print("show_answer1: ", answer)
|
||||
game_label.text = answer.Game
|
||||
song_label.text = answer.Song
|
||||
|
||||
func fetched() -> void:
|
||||
var show_fetched_list: Callable = func(data_received: Array) -> void:
|
||||
print("fetched")
|
||||
var show_fetched_list: Callable = func(data_received) -> void:
|
||||
if typeof(data_received) == TYPE_ARRAY:
|
||||
song_list = []
|
||||
song_list.append_array(data_received)
|
||||
@@ -308,6 +365,8 @@ func fetched() -> void:
|
||||
song_list.remove_at(song_list.size() - 1)
|
||||
for song: Dictionary in song_list:
|
||||
var fetched_song_label: Label = Label.new()
|
||||
fetched_song_label.set_texture_filter(TextureFilter.TEXTURE_FILTER_NEAREST)
|
||||
fetched_song_label.add_theme_font_size_override("font_size", 20)
|
||||
var format_string: String = "%d. %s - %s"
|
||||
var actual_string: String = format_string % [(song.SongNo+1), song.Game, song.Song]
|
||||
fetched_song_label.text = actual_string
|
||||
@@ -319,6 +378,8 @@ func fetched() -> void:
|
||||
for song: Label in songs:
|
||||
song.remove_theme_color_override("font_color")
|
||||
next_label = Label.new()
|
||||
next_label.set_texture_filter(TextureFilter.TEXTURE_FILTER_NEAREST)
|
||||
next_label.add_theme_font_size_override("font_size", 20)
|
||||
next_label.add_theme_color_override("font_color", Color(1, 0.5, 0))
|
||||
next_label.text = "??? - ???"
|
||||
next_label.mouse_filter = Control.MOUSE_FILTER_PASS
|
||||
@@ -329,6 +390,7 @@ func fetched() -> void:
|
||||
Settings.make_request2("/music/list", show_fetched_list, true)
|
||||
|
||||
func song_clicked(event: InputEvent, clicked_song_label: Label, song_no: int) -> void:
|
||||
print("song_clicked")
|
||||
if (event is InputEventMouseButton && event.pressed && event.button_index == MOUSE_BUTTON_LEFT):
|
||||
print("Song Clicked: " + str(song_no))
|
||||
songs = music_list.get_children()
|
||||
@@ -339,6 +401,7 @@ func song_clicked(event: InputEvent, clicked_song_label: Label, song_no: int) ->
|
||||
Settings.make_request2("/music/info", show_answer, true)
|
||||
|
||||
func _on_player_removed(new_player: Node) -> void:
|
||||
print("_on_player_removed")
|
||||
players.remove_child(new_player)
|
||||
|
||||
func _on_player_change_character_clicked(new_player: Node) -> void:
|
||||
@@ -368,6 +431,7 @@ func dir_contents(path: String) -> void:
|
||||
dir.list_dir_begin()
|
||||
var file_name: String = dir.get_next()
|
||||
songs.clear()
|
||||
games = []
|
||||
while file_name != "":
|
||||
if dir.current_is_dir():
|
||||
#print("Found directory: " + file_name)
|
||||
|
||||
Reference in New Issue
Block a user