mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-11-03 16:44:05 +00:00
JOIN button now pulls up a dialog with the auto selected game server to confirm player wants to join that server; TODO: If only one server exists then join that one directly, if multiple exist the offer the 'best' three or something, don't crash if we somehow get a server update without the server list being nil
This commit is contained in:
@@ -57,12 +57,12 @@ module W3DHubLauncher
|
|||||||
channel = MemCache[:applications].find { |appl| appl.id == app.id }&.channels&.find { |c| c.id == app.channel }
|
channel = MemCache[:applications].find { |appl| appl.id == app.id }&.channels&.find { |c| c.id == app.channel }
|
||||||
return nil unless channel
|
return nil unless channel
|
||||||
|
|
||||||
server_options = MemCache[:servers].select do |server|
|
server_options = (MemCache[:servers]&.select do |server|
|
||||||
server.game == app.id &&
|
server.game == app.id &&
|
||||||
server.channel == channel.server_channel &&
|
server.channel == channel.server_channel &&
|
||||||
!server.password? &&
|
!server.password? &&
|
||||||
server.player_count < server.max_players
|
server.player_count < server.max_players
|
||||||
end.sort_by do |s|
|
end || []).sort_by do |s|
|
||||||
[s.player_count, -s.ping]
|
[s.player_count, -s.ping]
|
||||||
end.reverse
|
end.reverse
|
||||||
|
|
||||||
|
|||||||
@@ -4,32 +4,38 @@ module W3DHubLauncher
|
|||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
|
|
||||||
|
application = @options[:application]
|
||||||
|
server = @options[:server]
|
||||||
|
|
||||||
stack(width: 1.0, max_width: 600, height: 1.0, max_height: 600, style_class: [:dialog]) do
|
stack(width: 1.0, max_width: 600, height: 1.0, max_height: 600, style_class: [:dialog]) do
|
||||||
flow(width: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_TOP, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: 0) do
|
flow(width: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_TOP, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: 0) do
|
||||||
banner "Downloads", width: 1.0, text_align: :center
|
banner "Join Server", width: 1.0, text_align: :center
|
||||||
|
title server.name, width: 1.0, text_align: :center
|
||||||
end
|
end
|
||||||
|
|
||||||
stack(style_class: [:dialog_container]) do
|
stack(style_class: [:dialog_container]) do
|
||||||
50.times do
|
caption "Ping: #{server.ping}ms"
|
||||||
stack(width: 1.0, margin_top: HALF_PADDING, margin_bottom: HALF_PADDING) do
|
caption "Region: #{server.region}"
|
||||||
flow(width: 1.0) do
|
caption "Players: #{server.player_count} / #{server.max_players}", margin_bottom: HALF_PADDING
|
||||||
para "PACKAGE_NAME.mix"
|
|
||||||
flow(fill: true)
|
caption "Current Map: #{server.current_map}"
|
||||||
para ["Downloading...", "Pending...", "Done.", "Patching...", "Unpacking..."].sample
|
caption "Next Map: #{server.next_map}", margin_bottom: HALF_PADDING
|
||||||
end
|
|
||||||
progress(width: 1.0, fraction: rand)
|
caption "Time Elapsed: #{server.time_elapsed}"
|
||||||
end
|
caption "Time Remaining: #{server.time_remaining}"
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
flow(width: 1.0, padding: PADDING, background_nine_slice: NINE_SLICE_ROUNDED_BOTTOM, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: 0) do
|
flow(width: 1.0, padding: PADDING, background_nine_slice: NINE_SLICE_ROUNDED_BOTTOM, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: 0) do
|
||||||
flow(fill: true)
|
button "Cancel" do
|
||||||
|
|
||||||
button "Close", **CTA_BUTTON_THEME do
|
|
||||||
pop_state
|
pop_state
|
||||||
end
|
end
|
||||||
|
|
||||||
flow(fill: true)
|
flow(fill: true)
|
||||||
|
|
||||||
|
button "Join", **CTA_BUTTON_THEME do
|
||||||
|
pop_state
|
||||||
|
ApplicationHelper.join_server(application, server)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -194,28 +194,30 @@ module W3DHubLauncher
|
|||||||
|
|
||||||
flow(width: 1.0, height: 60) do
|
flow(width: 1.0, height: 60) do
|
||||||
if application
|
if application
|
||||||
if @current_channel.update_available?(application.version)
|
if @current_channel.update_available?(application.version)
|
||||||
button "Update", tip: "Update application from v#{application.version} to v#{@current_channel.version}", fill: true, height: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_LEFT, **UPDATE_BUTTON_THEME do |btn|
|
button "Update", tip: "Update application from v#{application.version} to v#{@current_channel.version}", fill: true, height: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_LEFT, **UPDATE_BUTTON_THEME do |btn|
|
||||||
btn.enabled = false
|
btn.enabled = false
|
||||||
|
|
||||||
Worker::Api.update_application(@current_app.id, @current_channel.id) do |result, status|
|
Worker::Api.update_application(@current_app.id, @current_channel.id) do |result, status|
|
||||||
handle_task_update(result, status)
|
handle_task_update(result, status)
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
button "JOIN", tip: "Join most populated or lowest ping server", fill: true, height: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_LEFT, **CTA_BUTTON_THEME do |btn|
|
|
||||||
server = ApplicationHelper.play_now_server(application)
|
|
||||||
|
|
||||||
if server
|
|
||||||
ApplicationHelper.join_server(application, server)
|
|
||||||
else
|
|
||||||
puts "No server available."
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
button "JOIN", tip: "Join most populated or lowest ping server", fill: true, height: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_LEFT, **CTA_BUTTON_THEME do |btn|
|
||||||
|
server = ApplicationHelper.play_now_server(application)
|
||||||
|
|
||||||
|
if server
|
||||||
|
dialog(Dialog::Server, application: application, server: server)
|
||||||
|
else
|
||||||
|
puts "No server available."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
button safe_get_image("#{ROOT_PATH}/media/icons/singleplayer.png"), tip: "Single player", image_height: 1.0, background_nine_slice: NINE_SLICE_SQUARE, **CTA_BUTTON_THEME do
|
button safe_get_image("#{ROOT_PATH}/media/icons/singleplayer.png"), tip: "Single player", image_height: 1.0, background_nine_slice: NINE_SLICE_SQUARE, **CTA_BUTTON_THEME do
|
||||||
ApplicationHelper.run(application)
|
ApplicationHelper.run(application)
|
||||||
end
|
end
|
||||||
|
|
||||||
button safe_get_image("#{ROOT_PATH}/media/icons/gear.png"), tip: "Options", image_height: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_RIGHT, **CTA_BUTTON_THEME do |btn|
|
button safe_get_image("#{ROOT_PATH}/media/icons/gear.png"), tip: "Options", image_height: 1.0, background_nine_slice: NINE_SLICE_ROUNDED_RIGHT, **CTA_BUTTON_THEME do |btn|
|
||||||
menu(parent: btn) do
|
menu(parent: btn) do
|
||||||
menu_item("v#{application.version}", enabled: false, disabled: { color: 0xdd_ffffff }, tip: "Installed application version")
|
menu_item("v#{application.version}", enabled: false, disabled: { color: 0xdd_ffffff }, tip: "Installed application version")
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ module W3DHubLauncher
|
|||||||
if existing_game_server
|
if existing_game_server
|
||||||
MemCache[:servers][MemCache[:servers].index(existing_game_server)] = game_server
|
MemCache[:servers][MemCache[:servers].index(existing_game_server)] = game_server
|
||||||
else
|
else
|
||||||
|
MemCache[:servers] ||= []
|
||||||
MemCache[:servers] << game_server
|
MemCache[:servers] << game_server
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -32,6 +33,7 @@ module W3DHubLauncher
|
|||||||
if existing_game_server
|
if existing_game_server
|
||||||
MemCache[:servers][MemCache[:servers].index(existing_game_server)] = game_server
|
MemCache[:servers][MemCache[:servers].index(existing_game_server)] = game_server
|
||||||
else
|
else
|
||||||
|
MemCache[:servers] ||= []
|
||||||
MemCache[:servers] << game_server
|
MemCache[:servers] << game_server
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user