Only show friend lobbies
This commit is contained in:
parent
2d2f87df88
commit
a996951932
@ -43,23 +43,42 @@ func _on_show_lobbies():
|
|||||||
|
|
||||||
|
|
||||||
func _on_lobbies_received(these_lobbies: Array):
|
func _on_lobbies_received(these_lobbies: Array):
|
||||||
for this_lobby in these_lobbies:
|
var friend_count = Steam.getFriendCount()
|
||||||
# Pull lobby data from Steam, these are specific to our example
|
var friend_steam_ids = []
|
||||||
var lobby_name: String = Steam.getLobbyData(this_lobby, "name")
|
for i in range(friend_count):
|
||||||
var lobby_mode: String = Steam.getLobbyData(this_lobby, "mode")
|
friend_steam_ids.append(Steam.getFriendByIndex(i, Steam.FRIEND_FLAG_ALL))
|
||||||
|
|
||||||
# Get the current number of members
|
var friend_lobbies = []
|
||||||
var lobby_num_members: int = Steam.getNumLobbyMembers(this_lobby)
|
for lobby in these_lobbies:
|
||||||
|
if Steam.getLobbyOwner(lobby) in friend_steam_ids:
|
||||||
|
friend_lobbies.append(lobby)
|
||||||
|
|
||||||
# Create a button for the lobby
|
# Clear the lobby list box before adding new lobbies
|
||||||
var lobby_button: Button = Button.new()
|
for child in lobby_list_box.get_children():
|
||||||
lobby_button.set_text("Lobby %s: %s [%s] - %s Player(s)" % [this_lobby, lobby_name, lobby_mode, lobby_num_members])
|
child.queue_free()
|
||||||
lobby_button.set_size(Vector2(800, 50))
|
|
||||||
lobby_button.set_name("lobby_%s" % this_lobby)
|
|
||||||
lobby_button.connect("pressed", Callable(self, "join_lobby").bind(this_lobby))
|
|
||||||
|
|
||||||
# Add the new lobby to the list
|
if friend_lobbies.size() == 0:
|
||||||
lobby_list_box.add_child(lobby_button)
|
var no_lobbies_label = Label.new()
|
||||||
|
no_lobbies_label.text = "No lobbies available"
|
||||||
|
lobby_list_box.add_child(no_lobbies_label)
|
||||||
|
else:
|
||||||
|
for this_lobby in friend_lobbies:
|
||||||
|
# Pull lobby data from Steam, these are specific to our example
|
||||||
|
var lobby_name: String = Steam.getLobbyData(this_lobby, "name")
|
||||||
|
var lobby_mode: String = Steam.getLobbyData(this_lobby, "mode")
|
||||||
|
|
||||||
|
# Get the current number of members
|
||||||
|
var lobby_num_members: int = Steam.getNumLobbyMembers(this_lobby)
|
||||||
|
|
||||||
|
# Create a button for the lobby
|
||||||
|
var lobby_button: Button = Button.new()
|
||||||
|
lobby_button.set_text("Lobby %s: %s [%s] - %s Player(s)" % [this_lobby, lobby_name, lobby_mode, lobby_num_members])
|
||||||
|
lobby_button.set_size(Vector2(800, 50))
|
||||||
|
lobby_button.set_name("lobby_%s" % this_lobby)
|
||||||
|
lobby_button.connect("pressed", Callable(self, "join_lobby").bind(this_lobby))
|
||||||
|
|
||||||
|
# Add the new lobby to the list
|
||||||
|
lobby_list_box.add_child(lobby_button)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user