mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2025-12-15 16:52:34 +00:00
Show server name with player count to be joined in tooltip for 'Play Now' button
This commit is contained in:
@@ -203,12 +203,20 @@ class W3DHub
|
||||
end
|
||||
end
|
||||
|
||||
def play_now(app_id, channel)
|
||||
def play_now_server(app_id, channel)
|
||||
app_data = installed?(app_id, channel)
|
||||
|
||||
return false unless app_data
|
||||
return nil unless app_data
|
||||
|
||||
server = Store.server_list.select { |server| server.game == app_id && server.channel == channel && !server.status.password }&.first
|
||||
found_server = Store.server_list.select do |server|
|
||||
server.game == app_id && server.channel == channel && !server.status.password
|
||||
end&.first
|
||||
|
||||
found_server ? found_server : nil
|
||||
end
|
||||
|
||||
def play_now(app_id, channel)
|
||||
server = play_now_server(app_id, channel)
|
||||
|
||||
return false unless server
|
||||
|
||||
|
||||
@@ -152,9 +152,16 @@ class W3DHub
|
||||
Store.application_manager.update(game.id, channel.id)
|
||||
end
|
||||
else
|
||||
button "<b>#{I18n.t(:"interface.play")}</b>", fill: true, text_size: 32 do
|
||||
play_now_server = Store.application_manager.play_now_server(game.id, channel.id)
|
||||
play_now_button = button "<b>#{I18n.t(:"interface.play")}</b>", fill: true, text_size: 32, enabled: !play_now_server.nil? do
|
||||
Store.application_manager.play_now(game.id, channel.id)
|
||||
end
|
||||
|
||||
play_now_button.subscribe(:enter) do |btn|
|
||||
server = Store.application_manager.play_now_server(game.id, channel.id)
|
||||
btn.enabled = !server.nil?
|
||||
btn.instance_variable_set(:"@tip", server ? "#{server.status.name} [#{server.status.player_count}/#{server.status.max_players}]" : "")
|
||||
end
|
||||
end
|
||||
|
||||
button get_image("#{GAME_ROOT_PATH}/media/ui_icons/singleplayer.png"), tip: I18n.t(:"interface.single_player"), image_height: 32, margin_left: 0 do
|
||||
|
||||
Reference in New Issue
Block a user