mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2025-12-16 09:12:35 +00:00
Fixed win32 version of captured_command erroring on exit status, fixed auto import overwriting application details when the stored version is newer then the registry, added unused registry writer for updating application version- requires UAC, fixed ServerBrowser#find_element_by_tag erroring sometimes, added application manager to sleeper party.
This commit is contained in:
@@ -298,12 +298,19 @@ class W3DHub
|
|||||||
exe_path = app_id == "ecw" ? "#{install_path}/game750.exe" : "#{install_path}/game.exe"
|
exe_path = app_id == "ecw" ? "#{install_path}/game750.exe" : "#{install_path}/game.exe"
|
||||||
|
|
||||||
if File.exist?(exe_path)
|
if File.exist?(exe_path)
|
||||||
installed_version = reg["InstalledVersion"] unless app_id == "ren"
|
installed_version = app_id == "ren" ? "1.0.0.0" : reg["InstalledVersion"]
|
||||||
|
|
||||||
|
if (installed_app = installed?(app_id, channel_id))
|
||||||
|
current_version = Gem::Version.new(installed_app[:installed_version])
|
||||||
|
listed_version = installed_version
|
||||||
|
|
||||||
|
next if current_version >= listed_version
|
||||||
|
end
|
||||||
|
|
||||||
application_data = {
|
application_data = {
|
||||||
name: game.name,
|
name: game.name,
|
||||||
install_directory: install_path,
|
install_directory: install_path,
|
||||||
installed_version: app_id == "ren" ? "1.0.0.0" : installed_version,
|
installed_version: installed_version,
|
||||||
install_path: exe_path,
|
install_path: exe_path,
|
||||||
wine_prefix: nil
|
wine_prefix: nil
|
||||||
}
|
}
|
||||||
@@ -327,6 +334,33 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def write_application_version_to_win32_registry(app_id, channel_id, version)
|
||||||
|
# TODO: Figure out how to trigger UAC, but only for this so games DO NOT spawn with admin privileges.
|
||||||
|
return
|
||||||
|
return unless W3DHub.windows?
|
||||||
|
return if app_id == "ren"
|
||||||
|
|
||||||
|
require "win32/registry"
|
||||||
|
|
||||||
|
registry_path ||= "SOFTWARE\\W3D Hub\\games\\#{app_id}-#{channel_id}"
|
||||||
|
reg_type = Win32::Registry::KEY_ALL_ACCESS
|
||||||
|
|
||||||
|
Win32::Registry::HKEY_LOCAL_MACHINE.open(registry_path, reg_type) do |reg|
|
||||||
|
reg.write_s("InstalledVersion", version)
|
||||||
|
end
|
||||||
|
|
||||||
|
rescue => e
|
||||||
|
puts e.class, e.message, e.backtrace
|
||||||
|
if Win32::Registry::Error
|
||||||
|
logger.warn(LOG_TAG) { " Failed to update #{app_id}-#{channel_id} version in the registry" }
|
||||||
|
else
|
||||||
|
logger.warn(LOG_TAG) { " An error occurred while tying to update #{app_id}-#{channel_id} version in the registry" }
|
||||||
|
logger.warn(LOG_TAG) { e }
|
||||||
|
end
|
||||||
|
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
def imported!(task, exe_path)
|
def imported!(task, exe_path)
|
||||||
application_data = {
|
application_data = {
|
||||||
name: task.application.name,
|
name: task.application.name,
|
||||||
@@ -359,6 +393,8 @@ class W3DHub
|
|||||||
Store.settings[:games] ||= {}
|
Store.settings[:games] ||= {}
|
||||||
Store.settings[:games][:"#{task.app_id}_#{task.release_channel}"] = application_data
|
Store.settings[:games][:"#{task.app_id}_#{task.release_channel}"] = application_data
|
||||||
Store.settings.save_settings
|
Store.settings.save_settings
|
||||||
|
|
||||||
|
write_application_version_to_win32_registry(task.app_id, task.release_channel, task.target_version)
|
||||||
end
|
end
|
||||||
|
|
||||||
def installed?(app_id, channel)
|
def installed?(app_id, channel)
|
||||||
|
|||||||
@@ -57,8 +57,9 @@ class W3DHub
|
|||||||
)
|
)
|
||||||
|
|
||||||
pid = process_info.process_id
|
pid = process_info.process_id
|
||||||
|
status = -1
|
||||||
|
|
||||||
until Process.get_exitcode(pid)
|
until (status = Process.get_exitcode(pid))
|
||||||
readable, _writable, _errorable = IO.select([stdout_read], [], [], 1)
|
readable, _writable, _errorable = IO.select([stdout_read], [], [], 1)
|
||||||
|
|
||||||
readable&.each do |io|
|
readable&.each do |io|
|
||||||
@@ -71,7 +72,7 @@ class W3DHub
|
|||||||
stdout_read.close
|
stdout_read.close
|
||||||
stdout_write.close
|
stdout_write.close
|
||||||
|
|
||||||
Process.get_exitcode(pid).zero?
|
status.zero?
|
||||||
else
|
else
|
||||||
IO.popen(command) do |io|
|
IO.popen(command) do |io|
|
||||||
io.each_line do |line|
|
io.each_line do |line|
|
||||||
|
|||||||
@@ -218,6 +218,8 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
|
|
||||||
def find_element_by_tag(container, tag, list = [])
|
def find_element_by_tag(container, tag, list = [])
|
||||||
|
return unless container
|
||||||
|
|
||||||
container.children.each do |child|
|
container.children.each do |child|
|
||||||
list << child if child.style.tag == tag
|
list << child if child.style.tag == tag
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Manually sleep main thread so that the BackgroundWorker thread can be scheduled
|
# Manually sleep main thread so that the BackgroundWorker thread can be scheduled
|
||||||
sleep(update_interval / 1000.0) if W3DHub::BackgroundWorker.busy?
|
sleep(update_interval / 1000.0) if W3DHub::BackgroundWorker.busy? || Store.application_manager.busy?
|
||||||
end
|
end
|
||||||
|
|
||||||
def gain_focus
|
def gain_focus
|
||||||
|
|||||||
Reference in New Issue
Block a user