mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-09-19 23:03:53 +00:00
Very crude initial support for starting app from launcher
This commit is contained in:
34
lib/application_helper.rb
Normal file
34
lib/application_helper.rb
Normal 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
|
||||||
@@ -156,8 +156,7 @@ module W3DHubLauncher
|
|||||||
end
|
end
|
||||||
|
|
||||||
def populate_game_info
|
def populate_game_info
|
||||||
# FIXME: We should be able to query an api to figure out the installation state, instead of explictly writing it out like this...
|
application = MemCache[:settings].application_installed?(@current_app, @current_channel)
|
||||||
application = MemCache[:settings].applications.find { |app| app.id == @current_app.id && app.channel == @current_channel&.id }
|
|
||||||
# pp application
|
# pp application
|
||||||
|
|
||||||
@game_info_container.clear do
|
@game_info_container.clear do
|
||||||
@@ -187,7 +186,9 @@ module W3DHubLauncher
|
|||||||
flow(width: 1.0, height: 60) do
|
flow(width: 1.0, height: 60) do
|
||||||
if application
|
if application
|
||||||
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
|
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
|
||||||
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
|
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)
|
||||||
|
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("Game Settings")
|
menu_item("Game Settings")
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ module W3DHubLauncher
|
|||||||
}.to_json(options)
|
}.to_json(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def application_installed?(application, channel)
|
||||||
|
applications.find { |app| app.id == application&.id && app.channel == channel&.id }
|
||||||
|
end
|
||||||
|
|
||||||
# User explictly set options
|
# User explictly set options
|
||||||
class Preferences
|
class Preferences
|
||||||
SCHEMA = 0
|
SCHEMA = 0
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ require_relative "lib/dialogs/account"
|
|||||||
require_relative "lib/states/boot"
|
require_relative "lib/states/boot"
|
||||||
require_relative "lib/states/interface"
|
require_relative "lib/states/interface"
|
||||||
require_relative "lib/window"
|
require_relative "lib/window"
|
||||||
|
require_relative "lib/application_helper"
|
||||||
|
|
||||||
require_relative "lib/ico"
|
require_relative "lib/ico"
|
||||||
require_relative "lib/ww_mix"
|
require_relative "lib/ww_mix"
|
||||||
|
|||||||
Reference in New Issue
Block a user