mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-03-21 19:56:14 +00:00
Improve wine settings, fixup wineprefix usage
This commit is contained in:
@@ -86,15 +86,15 @@ class W3DHub
|
|||||||
|
|
||||||
# open wwconfig.exe or config.exe for ecw
|
# open wwconfig.exe or config.exe for ecw
|
||||||
|
|
||||||
if (app_data = installed?(app_id, channel) && W3DHub.unix?)
|
return unless (app_data = installed?(app_id, channel) && W3DHub.unix?)
|
||||||
exe = if Store.settings[:wine_prefix]
|
|
||||||
|
exe = if !Store.settings[:wine_prefix].to_s.empty?
|
||||||
"WINEPREFIX=\"#{Store.settings[:wine_prefix]}\" winecfg"
|
"WINEPREFIX=\"#{Store.settings[:wine_prefix]}\" winecfg"
|
||||||
else
|
else
|
||||||
"winecfg"
|
"winecfg"
|
||||||
end
|
end
|
||||||
|
|
||||||
Process.spawn("#{exe}")
|
Process.spawn(exe)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def repair(app_id, channel)
|
def repair(app_id, channel)
|
||||||
@@ -169,7 +169,7 @@ class W3DHub
|
|||||||
def wine_command(app_id, channel)
|
def wine_command(app_id, channel)
|
||||||
return "" if W3DHub.windows?
|
return "" if W3DHub.windows?
|
||||||
|
|
||||||
if Store.settings[:wine_prefix]
|
if !Store.settings[:wine_prefix].to_s.empty?
|
||||||
"WINEPREFIX=\"#{Store.settings[:wine_prefix]}\" \"#{Store.settings[:wine_command]}\" "
|
"WINEPREFIX=\"#{Store.settings[:wine_prefix]}\" \"#{Store.settings[:wine_command]}\" "
|
||||||
else
|
else
|
||||||
"#{Store.settings[:wine_command]} "
|
"#{Store.settings[:wine_command]} "
|
||||||
|
|||||||
@@ -140,8 +140,7 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
|
|
||||||
status.zero?
|
status.zero?
|
||||||
else
|
elsif block
|
||||||
if block
|
|
||||||
IO.popen(command, "r") do |io|
|
IO.popen(command, "r") do |io|
|
||||||
io.each_line do |line|
|
io.each_line do |line|
|
||||||
block&.call(line)
|
block&.call(line)
|
||||||
@@ -153,16 +152,17 @@ class W3DHub
|
|||||||
system(command)
|
system(command)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def self.home_directory
|
def self.home_directory
|
||||||
File.expand_path("~")
|
File.expand_path("~")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.ask_file(title: "Open File", filter: "*game*.exe")
|
def self.ask_file(title: "Open File", filter: "*game*.exe", filters: [])
|
||||||
|
filters << filter if filters.empty?
|
||||||
|
|
||||||
if W3DHub.unix?
|
if W3DHub.unix?
|
||||||
# search for command
|
# search for command
|
||||||
cmds = %w{ zenity matedialog qarma kdialog }
|
cmds = %w[zenity matedialog qarma kdialog]
|
||||||
|
|
||||||
command = cmds.find do |cmd|
|
command = cmds.find do |cmd|
|
||||||
cmd if system("which #{cmd}")
|
cmd if system("which #{cmd}")
|
||||||
@@ -170,9 +170,10 @@ class W3DHub
|
|||||||
|
|
||||||
path = case File.basename(command)
|
path = case File.basename(command)
|
||||||
when "zenity", "matedialog", "qarma"
|
when "zenity", "matedialog", "qarma"
|
||||||
`#{command} --file-selection --title "#{title}" --file-filter "#{filter}"`
|
options = filters.map { |s| format("--file-filter=\"%s\"", s) }.join(" ")
|
||||||
|
`#{command} --file-selection --title \"#{title}\" #{options}`
|
||||||
when "kdialog"
|
when "kdialog"
|
||||||
`#{command} --title "#{title}" --getopenfilename . "#{filter}"`
|
`#{command} --title "#{title}" --getopenfilename . "#{filters.join(" ")}"`
|
||||||
else
|
else
|
||||||
raise "No known command found for system file selection dialog!"
|
raise "No known command found for system file selection dialog!"
|
||||||
end
|
end
|
||||||
@@ -189,7 +190,7 @@ class W3DHub
|
|||||||
def self.ask_folder(title: "Open Folder")
|
def self.ask_folder(title: "Open Folder")
|
||||||
if W3DHub.unix?
|
if W3DHub.unix?
|
||||||
# search for command
|
# search for command
|
||||||
cmds = %w{ zenity matedialog qarma kdialog }
|
cmds = %w[zenity matedialog qarma kdialog]
|
||||||
|
|
||||||
command = cmds.find do |cmd|
|
command = cmds.find do |cmd|
|
||||||
cmd if system("which #{cmd}")
|
cmd if system("which #{cmd}")
|
||||||
|
|||||||
@@ -7,17 +7,14 @@ class W3DHub
|
|||||||
background 0xaa_252525
|
background 0xaa_252525
|
||||||
|
|
||||||
stack(width: 1.0, fill: true, max_width: 720, h_align: :center, scroll: true) do
|
stack(width: 1.0, fill: true, max_width: 720, h_align: :center, scroll: true) do
|
||||||
stack(width: 1.0, height: 112) do
|
|
||||||
tagline "Launcher Language"
|
tagline "Launcher Language"
|
||||||
@language_menu = list_box items: I18n.available_locales.map { |l| expand_language_code(l.to_s) }, choose: expand_language_code(Store.settings[:language]), width: 1.0, margin_left: 16
|
@language_menu = list_box items: I18n.available_locales.map { |l| expand_language_code(l.to_s) }, choose: expand_language_code(Store.settings[:language]), width: 1.0, margin_left: 16
|
||||||
para "Select the UI language you'd like to use in the W3D Hub Launcher.", margin_left: 16
|
para "Select the UI language you'd like to use in the W3D Hub Launcher.", margin_left: 16
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
stack(width: 1.0, height: 200, margin_top: 16) do
|
tagline "Launcher Directories", margin_top: 16
|
||||||
tagline "Launcher Directories"
|
|
||||||
caption "Applications Install Directory", margin_left: 16
|
caption "Applications Install Directory", margin_left: 16
|
||||||
flow(width: 1.0, fill: true, margin_left: 16) do
|
flow(width: 1.0, margin_left: 16) do
|
||||||
@app_install_dir_input = edit_line Store.settings[:app_install_dir], fill: true
|
@app_install_dir_input = edit_line Store.settings[:app_install_dir], fill: true
|
||||||
button "Browse...", width: 128, tip: "Browse for applications install directory" do
|
button "Browse...", width: 128, tip: "Browse for applications install directory" do
|
||||||
path = W3DHub.ask_folder
|
path = W3DHub.ask_folder
|
||||||
@@ -26,28 +23,54 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
|
|
||||||
caption "Package Cache Directory", margin_left: 16, margin_top: 16
|
caption "Package Cache Directory", margin_left: 16, margin_top: 16
|
||||||
flow(width: 1.0, fill: true, margin_left: 16) do
|
flow(width: 1.0, margin_left: 16) do
|
||||||
@package_cache_dir_input = edit_line Store.settings[:package_cache_dir], fill: true
|
@package_cache_dir_input = edit_line Store.settings[:package_cache_dir], fill: true
|
||||||
button "Browse...", width: 128, tip: "Browse for package cache directory" do
|
button "Browse...", width: 128, tip: "Browse for package cache directory" do
|
||||||
path = W3DHub.ask_folder
|
path = W3DHub.ask_folder
|
||||||
@package_cache_dir_input.value = path unless path.empty?
|
@package_cache_dir_input.value = path unless path.empty?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if W3DHub.unix?
|
if W3DHub.unix?
|
||||||
stack(width: 1.0, height: 224, margin_top: 16) do
|
tagline "Wine - Windows compatibility layer", margin_top: 16
|
||||||
tagline "Wine - Windows compatibility layer"
|
|
||||||
caption "Wine Command", margin_left: 16
|
caption "Wine Command", margin_left: 16
|
||||||
@wine_command_input = edit_line Store.settings[:wine_command], width: 1.0, margin_left: 16
|
flow(width: 1.0, margin_left: 16) do
|
||||||
|
@wine_command_input = edit_line Store.settings[:wine_command], fill: true
|
||||||
|
button "Browse...", width: 128, tip: "Browse for wine executable" do
|
||||||
|
path = W3DHub.ask_file(filters: %w[wine proton])
|
||||||
|
@wine_command_input.value = path unless path.empty?
|
||||||
|
end
|
||||||
|
end
|
||||||
para "Command to use to for Windows compatiblity layer.", margin_left: 16
|
para "Command to use to for Windows compatiblity layer.", margin_left: 16
|
||||||
|
|
||||||
caption "Wine Prefix", margin_left: 16, margin_top: 16
|
caption "Wine Prefix", margin_left: 16, margin_top: 16
|
||||||
flow(width: 1.0, height: 48, margin_left: 16) do
|
flow(width: 1.0, margin_left: 16) do
|
||||||
@wine_prefix_toggle = toggle_button checked: Store.settings[:wine_prefix], enabled: false
|
@wine_prefix_input = edit_line Store.settings[:wine_prefix], fill: true
|
||||||
para "Whether each game gets its own prefix. Uses global/default prefix by default."
|
button "Browse...", width: 128, tip: "Browse for wine prefix directory" do
|
||||||
|
path = W3DHub.ask_folder
|
||||||
|
@wine_prefix_input.value = path unless path.empty?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
para "Leave empty to use default global prefix.", margin_left: 16
|
||||||
|
|
||||||
|
|
||||||
|
tagline "Winetricks", margin_top: 16
|
||||||
|
caption "Winetricks Command", margin_left: 16
|
||||||
|
flow(width: 1.0, margin_left: 16) do
|
||||||
|
@winetricks_command_input = edit_line Store.settings[:winetricks_command], fill: true, enabled: false
|
||||||
|
button "Browse...", width: 128, tip: "Browse for winetricks executable", enabled: false do
|
||||||
|
path = W3DHub.ask_file(filters: %w[winetricks protontricks])
|
||||||
|
@winetricks_command_input.value = path unless path.empty?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
caption "Fixups", margin_left: 16, margin_top: 16
|
||||||
|
button "Install d3dcompiler_47", margin_left: 16, enabled: false
|
||||||
|
para "Fixes games instantly crashing at startup due to not being able to compile shaders.", margin_left: 16
|
||||||
|
|
||||||
|
button "Install DXVK", margin_left: 16, margin_top: 16, enabled: false
|
||||||
|
para "Use Vulkan-based DirectX translation layers.", margin_left: 16
|
||||||
|
para "WARNING: Games will stop working if your hardware does not support Vulkan!", margin_left: 16
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -55,10 +78,9 @@ class W3DHub
|
|||||||
button "Save", width: 1.0 do
|
button "Save", width: 1.0 do
|
||||||
save_settings!
|
save_settings!
|
||||||
end
|
end
|
||||||
|
|
||||||
flow(fill: true)
|
flow(fill: true)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
button("Clear package cache: #{W3DHub.format_size(Dir.glob("#{Store.settings[:package_cache_dir]}/**/**").map { |f| File.file?(f) ? File.size(f) : 0}.sum)}", tip: "Purge #{Store.settings[:package_cache_dir]}", **DANGEROUS_BUTTON) do |btn|
|
button("Clear package cache: #{W3DHub.format_size(Dir.glob("#{Store.settings[:package_cache_dir]}/**/**").map { |f| File.file?(f) ? File.size(f) : 0}.sum)}", tip: "Purge #{Store.settings[:package_cache_dir]}", **DANGEROUS_BUTTON) do |btn|
|
||||||
logger.info(LOG_TAG) { "Purging cache (#{Store.settings[:package_cache_dir]})..." }
|
logger.info(LOG_TAG) { "Purging cache (#{Store.settings[:package_cache_dir]})..." }
|
||||||
FileUtils.remove_dir(Store.settings[:package_cache_dir], force: true)
|
FileUtils.remove_dir(Store.settings[:package_cache_dir], force: true)
|
||||||
@@ -106,7 +128,9 @@ class W3DHub
|
|||||||
Store.settings[:package_cache_dir] = @package_cache_dir_input.value
|
Store.settings[:package_cache_dir] = @package_cache_dir_input.value
|
||||||
|
|
||||||
Store.settings[:wine_command] = @wine_command_input.value
|
Store.settings[:wine_command] = @wine_command_input.value
|
||||||
Store.settings[:wine_prefix] = @wine_prefix_toggle.value
|
Store.settings[:wine_prefix] = @wine_prefix_input.value
|
||||||
|
|
||||||
|
Store.settings[:winetricks_command] = @winetricks_command_input.value
|
||||||
|
|
||||||
Store.settings.save_settings
|
Store.settings.save_settings
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ class W3DHub
|
|||||||
package_cache_dir: default_package_cache_dir,
|
package_cache_dir: default_package_cache_dir,
|
||||||
parallel_downloads: 4,
|
parallel_downloads: 4,
|
||||||
wine_command: "wine",
|
wine_command: "wine",
|
||||||
create_wine_prefixes: true,
|
wine_prefix: "",
|
||||||
|
winetricks_command: "winetricks",
|
||||||
allow_diagnostic_reports: false,
|
allow_diagnostic_reports: false,
|
||||||
server_list_username: "",
|
server_list_username: "",
|
||||||
server_list_filters: {},
|
server_list_filters: {},
|
||||||
@@ -66,6 +67,14 @@ class W3DHub
|
|||||||
|
|
||||||
def load_settings
|
def load_settings
|
||||||
@settings = JSON.parse(File.read(SETTINGS_FILE_PATH), symbolize_names: true)
|
@settings = JSON.parse(File.read(SETTINGS_FILE_PATH), symbolize_names: true)
|
||||||
|
|
||||||
|
# FIXUPS
|
||||||
|
# FOR: v0.9.0
|
||||||
|
@settings.delete(:create_wine_prefixes)
|
||||||
|
@settings[:wine_prefix] ||= ""
|
||||||
|
@settings[:winetricks_command] ||= "winetricks"
|
||||||
|
|
||||||
|
@settings
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_settings
|
def save_settings
|
||||||
|
|||||||
Reference in New Issue
Block a user