mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2025-12-16 09:12:35 +00:00
Added support for auto importing games on Windows
This commit is contained in:
@@ -39,7 +39,16 @@ class W3DHub
|
|||||||
def settings(app_id, channel)
|
def settings(app_id, channel)
|
||||||
puts "Settings Request: #{app_id}-#{channel}"
|
puts "Settings Request: #{app_id}-#{channel}"
|
||||||
|
|
||||||
# open wwconfig
|
# open wwconfig.exe or config.exe for ecw
|
||||||
|
|
||||||
|
if (app_data = installed?(app_id, channel))
|
||||||
|
config_exe = app_id == "ecw" ? "config.exe" : "wwconfig.exe"
|
||||||
|
exe = "#{app_data[:install_directory]}/#{config_exe}"
|
||||||
|
|
||||||
|
if File.exist?(exe)
|
||||||
|
Process.spawn("\"#{exe}\"")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def repair(app_id, channel)
|
def repair(app_id, channel)
|
||||||
@@ -79,7 +88,7 @@ class W3DHub
|
|||||||
|
|
||||||
def run(app_id, channel, *args)
|
def run(app_id, channel, *args)
|
||||||
if (app_data = installed?(app_id, channel))
|
if (app_data = installed?(app_id, channel))
|
||||||
Process.spawn(app_data[:install_path], *args)
|
Process.spawn("\"#{app_data[:install_path]}\"", *args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -94,6 +103,65 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def auto_import
|
||||||
|
return unless W3DHub.windows?
|
||||||
|
|
||||||
|
# Renegade
|
||||||
|
auto_import_win32_registry("ren", "release", 'SOFTWARE\Westwood\Renegade')
|
||||||
|
|
||||||
|
# Red Alert: A Path Beyond
|
||||||
|
auto_import_win32_registry("apb", "release")
|
||||||
|
|
||||||
|
# Expansive Civilian Warfare
|
||||||
|
auto_import_win32_registry("ecw", "release")
|
||||||
|
|
||||||
|
# Interim Apex
|
||||||
|
auto_import_win32_registry("ia", "release")
|
||||||
|
|
||||||
|
# Tiberian Sun: Reborn
|
||||||
|
auto_import_win32_registry("tsr", "release")
|
||||||
|
end
|
||||||
|
|
||||||
|
def auto_import_win32_registry(app_id, channel_id, registry_path = nil)
|
||||||
|
return unless W3DHub.windows?
|
||||||
|
return if installed?(app_id, channel_id)
|
||||||
|
|
||||||
|
puts "Importing: #{app_id}-#{channel_id}"
|
||||||
|
|
||||||
|
require "win32/registry"
|
||||||
|
|
||||||
|
registry_path ||= "SOFTWARE\\W3D Hub\\games\\#{app_id}-#{channel_id}"
|
||||||
|
reg_type = Win32::Registry::KEY_READ
|
||||||
|
|
||||||
|
reg_constant = app_id == "ren" ? Win32::Registry::HKEY_CURRENT_USER : Win32::Registry::HKEY_LOCAL_MACHINE
|
||||||
|
|
||||||
|
begin
|
||||||
|
reg_constant.open(registry_path, reg_type) do |reg|
|
||||||
|
if (install_path = reg["InstallPath"])
|
||||||
|
if File.exist?(install_path) || (app_id == "ecw" && File.exist?("#{File.dirname(install_path)}/game750.exe"))
|
||||||
|
install_path.gsub!("\\", "/")
|
||||||
|
installed_version = reg["InstalledVersion"] unless app_id == "ren"
|
||||||
|
|
||||||
|
application_data = {
|
||||||
|
install_directory: File.dirname(install_path),
|
||||||
|
installed_version: app_id == "ren" ? "1.0.0.0" : installed_version,
|
||||||
|
install_path: app_id == "ecw" ? "#{File.dirname(install_path)}/game750.exe" : install_path,
|
||||||
|
wine_prefix: nil
|
||||||
|
}
|
||||||
|
|
||||||
|
window.settings[:games] ||= {}
|
||||||
|
window.settings[:games][:"#{app_id}_#{channel_id}"] = application_data
|
||||||
|
window.settings.save_settings
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rescue => e
|
||||||
|
puts e.message, e.backtrace
|
||||||
|
|
||||||
|
false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def installed!(task)
|
def installed!(task)
|
||||||
# install_dir
|
# install_dir
|
||||||
# installed_version
|
# installed_version
|
||||||
@@ -109,7 +177,7 @@ class W3DHub
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.settings[:games] ||= {}
|
window.settings[:games] ||= {}
|
||||||
window.settings[:games,][:"#{task.app_id}_#{task.release_channel}"] = application_data
|
window.settings[:games][:"#{task.app_id}_#{task.release_channel}"] = application_data
|
||||||
window.settings.save_settings
|
window.settings.save_settings
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ class W3DHub
|
|||||||
|
|
||||||
@main_thread_queue = []
|
@main_thread_queue = []
|
||||||
|
|
||||||
|
window.application_manager.auto_import
|
||||||
|
|
||||||
theme(W3DHub::THEME)
|
theme(W3DHub::THEME)
|
||||||
|
|
||||||
stack(width: 1.0, height: 1.0, border_thickness: 1, border_color: 0xff_aaaaaa) do
|
stack(width: 1.0, height: 1.0, border_thickness: 1, border_color: 0xff_aaaaaa) do
|
||||||
|
|||||||
Reference in New Issue
Block a user