Very crude initial support for starting app from launcher

This commit is contained in:
2026-09-17 22:53:14 -05:00
parent 09ef9d613f
commit 56699bb644
4 changed files with 43 additions and 3 deletions

34
lib/application_helper.rb Normal file
View File

@@ -0,0 +1,34 @@
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)
end
end
end