mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-09-19 14:53:49 +00:00
Fix up app filters on server browser, make it possible to join server from server browser
This commit is contained in:
@@ -24,11 +24,23 @@ module W3DHubLauncher
|
||||
env,
|
||||
"#{wine_command(app)}#{exe_path} -launcher #{args.join(' ')}"
|
||||
)
|
||||
|
||||
Process.detach(pid)
|
||||
end
|
||||
|
||||
def self.join_server(app, server, password: nil, token: nil)
|
||||
def self.join_server(app, server, password: nil, token: nil, multi: false)
|
||||
parameters = []
|
||||
|
||||
parameters << format("+connect %s:%s", server.address, server.port)
|
||||
parameters << format("+netplayername \"%s\"", "cyberarm")
|
||||
parameters << format("+password \"%s\"", password) if password
|
||||
parameters << format("+userkey \"%s\"", token) if token
|
||||
parameters << "+multi" if multi
|
||||
|
||||
run(
|
||||
app,
|
||||
parameters.join(" ")
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,15 +16,16 @@ module W3DHubLauncher
|
||||
|
||||
w.subscribe(:clicked_left_mouse_button) do
|
||||
@games_filter.clear
|
||||
@app_filters_container.children.each { |c| c.enabled = true }
|
||||
populate_server_list
|
||||
end
|
||||
end
|
||||
|
||||
flow(fill: true, height: 1.0, background_nine_slice: NINE_SLICE_ROUNDED, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: ALPHA_GRAY, margin_left: PADDING) do
|
||||
@app_filters_container = flow(fill: true, height: 1.0, background_nine_slice: NINE_SLICE_ROUNDED, background_nine_slice_from_edge: NINE_SLICE_EDGE, background_nine_slice_color: ALPHA_GRAY, margin_left: PADDING) do
|
||||
MemCache[:applications].each do |app|
|
||||
next unless app.game?
|
||||
|
||||
button(safe_get_image("#{CACHE_PATH}/icon_#{app.id}.png"), style_class: [:app_icon_button], tip: app.name) do |btn|
|
||||
button(safe_get_image("#{CACHE_PATH}/icon_#{app.id}.png"), style_class: [:app_icon_button], tag: :"app_filter_#{app.id}", tip: app.name) do |btn|
|
||||
if shift_down?
|
||||
@games_filter << app.id
|
||||
@games_filter.uniq!
|
||||
@@ -33,6 +34,10 @@ module W3DHubLauncher
|
||||
@games_filter << app.id
|
||||
end
|
||||
|
||||
buttons = btn.parent.children
|
||||
filters = @games_filter.map { |f| :"app_filter_#{f}" }
|
||||
buttons.each { |e| e.enabled = !filters.include?(e.style.tag) }
|
||||
|
||||
btn.enabled = false
|
||||
|
||||
populate_server_list
|
||||
|
||||
@@ -159,14 +159,16 @@ module W3DHubLauncher
|
||||
def populate_server_information(server)
|
||||
return unless @server_details_container.visible?
|
||||
|
||||
application = MemCache[:settings].applications.find { |app| app.id == server.game && app.channel == server.channel }
|
||||
|
||||
@server_details_container.clear do
|
||||
tagline server.name, width: 1.0, text_wrap: :none, tip: server.name
|
||||
image safe_get_image("#{ROOT_PATH}/media/default_map_preview.png"), width: 1.0, tip: server.current_map, margin_bottom: PADDING
|
||||
image safe_get_image("#{ROOT_PATH}/media/default_map_preview.png"), width: 1.0, aspect_ratio: 16 / 9.0, tip: server.current_map, margin_bottom: PADDING
|
||||
|
||||
flow(width: 1.0) do
|
||||
stack(fill: true)
|
||||
button "JOIN SERVER", **CTA_BUTTON_THEME, width: 1.0, enabled: false, tip: "Game not installed I guess..."
|
||||
stack(fill: true)
|
||||
button "JOIN SERVER", **CTA_BUTTON_THEME, width: 1.0, enabled: !application.nil?, tip: application.nil? ? "Application not installed" : "" do
|
||||
ApplicationHelper.join_server(application, server)
|
||||
end
|
||||
end
|
||||
|
||||
stack(width: 1.0, fill: true, scroll: true, margin_top: PADDING) do
|
||||
|
||||
Reference in New Issue
Block a user