mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-09-20 15:23:53 +00:00
47 lines
1.4 KiB
Ruby
47 lines
1.4 KiB
Ruby
module W3DHubLauncher
|
|
class ApplicationHelper
|
|
def self.wine_command(app)
|
|
# FIXME: account for the cursed whitespace and wrap in quotes
|
|
format("%s ", MemCache[:settings]&.preferences&.wine_command || "wine")
|
|
end
|
|
def self.wine_prefix(app)
|
|
# TODO: fallback from app specific prefix to launcher prefix to global prefix
|
|
# format("%s ", app&.wine_prefix_path || MemCache[:settings]&.preferences&.wine_prefix_path || "")
|
|
|
|
""
|
|
end
|
|
|
|
def self.run(app, *args)
|
|
exe_path = app.id == "ecw" ? format("%s/game500.exe", app.installation_path) : format("%s/game.exe", app.installation_path)
|
|
|
|
env = {}
|
|
unless wine_prefix(app).to_s.empty?
|
|
env["WINEPREFIX"] = wine_prefix(app).to_s
|
|
end
|
|
env["DXVK_HUD"] = "full"
|
|
|
|
pid = Process.spawn(
|
|
env,
|
|
"#{wine_command(app)}#{exe_path} -launcher #{args.join(' ')}"
|
|
)
|
|
|
|
Process.detach(pid)
|
|
end
|
|
|
|
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
|