mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-03-22 12:16:15 +00:00
Compare commits
8 Commits
3e4b25f0d4
...
developmen
| Author | SHA1 | Date | |
|---|---|---|---|
| a856dd5dd4 | |||
| 38a882179c | |||
| f350a9a937 | |||
| 2d429cb834 | |||
| d72142a409 | |||
| 9cb41a8693 | |||
| f024109327 | |||
| 287022f2b8 |
27
Gemfile
27
Gemfile
@@ -1,15 +1,26 @@
|
|||||||
source "https://rubygems.org"
|
source "https://rubygems.org"
|
||||||
|
|
||||||
|
# "standard lib" gems
|
||||||
gem "base64"
|
gem "base64"
|
||||||
|
gem "rexml"
|
||||||
|
gem "logger"
|
||||||
|
|
||||||
|
# networking libs
|
||||||
gem "async-http"
|
gem "async-http"
|
||||||
gem "async-websocket"
|
gem "async-websocket"
|
||||||
|
|
||||||
|
# "game" library gem
|
||||||
gem "cyberarm_engine"
|
gem "cyberarm_engine"
|
||||||
gem "sdl2-bindings"
|
gem "sdl2-bindings"
|
||||||
gem "libui", platforms: [:windows]
|
|
||||||
|
# misc. libs
|
||||||
gem "digest-crc"
|
gem "digest-crc"
|
||||||
gem "ircparser"
|
gem "ircparser"
|
||||||
gem "rexml"
|
|
||||||
gem "rubyzip"
|
gem "rubyzip"
|
||||||
|
|
||||||
|
# file selection dialogs on windows (SDL3 has these built-in, but we're on SDL2)
|
||||||
|
gem "libui", platforms: [:windows]
|
||||||
|
# misc. windows only gems
|
||||||
gem "win32-process", platforms: [:windows]
|
gem "win32-process", platforms: [:windows]
|
||||||
gem "win32-security", platforms: [:windows]
|
gem "win32-security", platforms: [:windows]
|
||||||
|
|
||||||
@@ -18,9 +29,9 @@ gem "win32-security", platforms: [:windows]
|
|||||||
# use `bundle _x.y.z_ COMMAND` to use this one...
|
# use `bundle _x.y.z_ COMMAND` to use this one...
|
||||||
# NOTE: Releasy needs to be installed as a system gem i.e. `rake install`
|
# NOTE: Releasy needs to be installed as a system gem i.e. `rake install`
|
||||||
# NOTE: contents of the `gemhome` folder in the packaged folder need to be moved into the lib/ruby/gems\<RUBY_VERSION> folder
|
# NOTE: contents of the `gemhome` folder in the packaged folder need to be moved into the lib/ruby/gems\<RUBY_VERSION> folder
|
||||||
# group :windows_packaging do
|
# group :windows_packaging do
|
||||||
# gem "bundler", "~>2.4.3"
|
# gem "bundler", "~>2.4.3"
|
||||||
# gem "rake"
|
# gem "rake"
|
||||||
# gem "ocran"
|
# gem "ocran"
|
||||||
# gem "releasy"#, path: "../releasy"
|
# gem "releasy"#, path: "../releasy"
|
||||||
# end
|
# end
|
||||||
|
|||||||
28
Gemfile.lock
28
Gemfile.lock
@@ -1,13 +1,13 @@
|
|||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
async (2.35.2)
|
async (2.38.1)
|
||||||
console (~> 1.29)
|
console (~> 1.29)
|
||||||
fiber-annotation
|
fiber-annotation
|
||||||
io-event (~> 1.11)
|
io-event (~> 1.11)
|
||||||
metrics (~> 0.12)
|
metrics (~> 0.12)
|
||||||
traces (~> 0.18)
|
traces (~> 0.18)
|
||||||
async-http (0.94.0)
|
async-http (0.94.2)
|
||||||
async (>= 2.10.2)
|
async (>= 2.10.2)
|
||||||
async-pool (~> 0.11)
|
async-pool (~> 0.11)
|
||||||
io-endpoint (~> 0.14)
|
io-endpoint (~> 0.14)
|
||||||
@@ -18,7 +18,7 @@ GEM
|
|||||||
protocol-http2 (~> 0.22)
|
protocol-http2 (~> 0.22)
|
||||||
protocol-url (~> 0.2)
|
protocol-url (~> 0.2)
|
||||||
traces (~> 0.10)
|
traces (~> 0.10)
|
||||||
async-pool (0.11.1)
|
async-pool (0.11.2)
|
||||||
async (>= 2.0)
|
async (>= 2.0)
|
||||||
async-websocket (0.30.0)
|
async-websocket (0.30.0)
|
||||||
async-http (~> 0.76)
|
async-http (~> 0.76)
|
||||||
@@ -26,11 +26,11 @@ GEM
|
|||||||
protocol-rack (~> 0.7)
|
protocol-rack (~> 0.7)
|
||||||
protocol-websocket (~> 0.17)
|
protocol-websocket (~> 0.17)
|
||||||
base64 (0.3.0)
|
base64 (0.3.0)
|
||||||
console (1.34.2)
|
console (1.34.3)
|
||||||
fiber-annotation
|
fiber-annotation
|
||||||
fiber-local (~> 1.1)
|
fiber-local (~> 1.1)
|
||||||
json
|
json
|
||||||
cyberarm_engine (0.25.0)
|
cyberarm_engine (0.25.1)
|
||||||
gosu (~> 1.1)
|
gosu (~> 1.1)
|
||||||
digest-crc (0.7.0)
|
digest-crc (0.7.0)
|
||||||
rake (>= 12.0.0, < 14.0.0)
|
rake (>= 12.0.0, < 14.0.0)
|
||||||
@@ -43,29 +43,30 @@ GEM
|
|||||||
fiber-storage (1.0.1)
|
fiber-storage (1.0.1)
|
||||||
fiddle (1.1.8)
|
fiddle (1.1.8)
|
||||||
gosu (1.4.6)
|
gosu (1.4.6)
|
||||||
io-endpoint (0.16.0)
|
io-endpoint (0.17.2)
|
||||||
io-event (1.14.2)
|
io-event (1.14.4)
|
||||||
io-stream (0.11.1)
|
io-stream (0.11.1)
|
||||||
ircparser (1.0.0)
|
ircparser (1.0.0)
|
||||||
json (2.18.0)
|
json (2.19.2)
|
||||||
libui (0.2.0-x64-mingw-ucrt)
|
libui (0.2.0-x64-mingw-ucrt)
|
||||||
fiddle
|
fiddle
|
||||||
|
logger (1.7.0)
|
||||||
metrics (0.15.0)
|
metrics (0.15.0)
|
||||||
protocol-hpack (1.5.1)
|
protocol-hpack (1.5.1)
|
||||||
protocol-http (0.58.0)
|
protocol-http (0.60.0)
|
||||||
protocol-http1 (0.36.0)
|
protocol-http1 (0.37.0)
|
||||||
protocol-http (~> 0.58)
|
protocol-http (~> 0.58)
|
||||||
protocol-http2 (0.24.0)
|
protocol-http2 (0.24.0)
|
||||||
protocol-hpack (~> 1.4)
|
protocol-hpack (~> 1.4)
|
||||||
protocol-http (~> 0.47)
|
protocol-http (~> 0.47)
|
||||||
protocol-rack (0.21.0)
|
protocol-rack (0.22.0)
|
||||||
io-stream (>= 0.10)
|
io-stream (>= 0.10)
|
||||||
protocol-http (~> 0.58)
|
protocol-http (~> 0.58)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
protocol-url (0.4.0)
|
protocol-url (0.4.0)
|
||||||
protocol-websocket (0.20.2)
|
protocol-websocket (0.20.2)
|
||||||
protocol-http (~> 0.2)
|
protocol-http (~> 0.2)
|
||||||
rack (3.2.4)
|
rack (3.2.5)
|
||||||
rake (13.3.1)
|
rake (13.3.1)
|
||||||
rexml (3.4.4)
|
rexml (3.4.4)
|
||||||
rubyzip (3.2.2)
|
rubyzip (3.2.2)
|
||||||
@@ -90,6 +91,7 @@ DEPENDENCIES
|
|||||||
digest-crc
|
digest-crc
|
||||||
ircparser
|
ircparser
|
||||||
libui
|
libui
|
||||||
|
logger
|
||||||
rexml
|
rexml
|
||||||
rubyzip
|
rubyzip
|
||||||
sdl2-bindings
|
sdl2-bindings
|
||||||
@@ -97,4 +99,4 @@ DEPENDENCIES
|
|||||||
win32-security
|
win32-security
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
2.6.8
|
4.0.3
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ class W3DHub
|
|||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@tasks = [] # :installer, :importer, :repairer, :uninstaller
|
@tasks = [] # :installer, :importer, :repairer, :uninstaller
|
||||||
|
@running_applications = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
def install(app_id, channel)
|
def install(app_id, channel)
|
||||||
@@ -22,9 +23,7 @@ class W3DHub
|
|||||||
# unpack packages
|
# unpack packages
|
||||||
# install dependencies (e.g. visual C runtime)
|
# install dependencies (e.g. visual C runtime)
|
||||||
|
|
||||||
installer = Installer.new(app_id, channel)
|
@tasks.push(Installer.new(app_id, channel))
|
||||||
|
|
||||||
@tasks.push(installer)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update(app_id, channel)
|
def update(app_id, channel)
|
||||||
@@ -32,9 +31,7 @@ class W3DHub
|
|||||||
|
|
||||||
return false unless installed?(app_id, channel)
|
return false unless installed?(app_id, channel)
|
||||||
|
|
||||||
updater = Updater.new(app_id, channel)
|
@tasks.push(Updater.new(app_id, channel))
|
||||||
|
|
||||||
@tasks.push(updater)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def import(app_id, channel)
|
def import(app_id, channel)
|
||||||
@@ -169,11 +166,16 @@ 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].to_s.empty?
|
"\"#{Store.settings[:wine_command]}\" "
|
||||||
"WINEPREFIX=\"#{Store.settings[:wine_prefix]}\" \"#{Store.settings[:wine_command]}\" "
|
|
||||||
else
|
|
||||||
"#{Store.settings[:wine_command]} "
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def wine_enviroment_variables(app_id, channel)
|
||||||
|
vars = {}
|
||||||
|
return vars if W3DHub.windows?
|
||||||
|
|
||||||
|
vars["WINEPREFIX"] = Store.settings[:wine_prefix] unless Store.settings[:wine_prefix].to_s.empty?
|
||||||
|
|
||||||
|
vars
|
||||||
end
|
end
|
||||||
|
|
||||||
def mangohud_command(app_id, channel)
|
def mangohud_command(app_id, channel)
|
||||||
@@ -188,6 +190,13 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mangohud_enviroment_variables(app_id, channel)
|
||||||
|
vars = {}
|
||||||
|
return vars if W3DHub.windows?
|
||||||
|
|
||||||
|
vars
|
||||||
|
end
|
||||||
|
|
||||||
def dxvk_command(app_id, channel)
|
def dxvk_command(app_id, channel)
|
||||||
return "" if W3DHub.windows?
|
return "" if W3DHub.windows?
|
||||||
|
|
||||||
@@ -201,6 +210,13 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def dxvk_enviroment_variables(app_id, channel)
|
||||||
|
vars = {}
|
||||||
|
return vars if W3DHub.windows?
|
||||||
|
|
||||||
|
vars
|
||||||
|
end
|
||||||
|
|
||||||
def start_command(path, exe)
|
def start_command(path, exe)
|
||||||
if W3DHub.windows?
|
if W3DHub.windows?
|
||||||
"start /D \"#{path}\" /B #{exe}"
|
"start /D \"#{path}\" /B #{exe}"
|
||||||
@@ -212,16 +228,32 @@ 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))
|
||||||
install_directory = app_data[:install_directory]
|
install_directory = app_data[:install_directory]
|
||||||
exe_path = app_id == "ecw" ? "#{install_directory}/game500.exe" : "#{install_directory}/game.exe"
|
exe_path = app_id == "ecw" ? "#{install_directory}/game500.exe" : app_data[:install_path]
|
||||||
exe_path.gsub!("/", "\\") if W3DHub.windows?
|
exe_path.gsub!("/", "\\") if W3DHub.windows?
|
||||||
exe_path.gsub!("\\", "/") if W3DHub.unix?
|
exe_path.gsub!("\\", "/") if W3DHub.unix?
|
||||||
|
|
||||||
exe = File.basename(exe_path)
|
exe = File.basename(exe_path)
|
||||||
path = File.dirname(exe_path)
|
path = File.dirname(exe_path)
|
||||||
|
|
||||||
|
env = {}
|
||||||
|
if W3DHub.unix?
|
||||||
|
env.merge!(
|
||||||
|
dxvk_enviroment_variables(app_id, channel),
|
||||||
|
mangohud_enviroment_variables(app_id, channel),
|
||||||
|
wine_enviroment_variables(app_id, channel)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
attempted = false
|
attempted = false
|
||||||
begin
|
begin
|
||||||
pid = Process.spawn("#{dxvk_command(app_id, channel)}#{mangohud_command(app_id, channel)}#{wine_command(app_id, channel)}#{attempted ? start_command(path, exe) : "\"#{exe_path}\""} -launcher #{args.join(' ')}")
|
pid = Process.spawn(
|
||||||
|
env,
|
||||||
|
"#{dxvk_command(app_id, channel)}"\
|
||||||
|
"#{mangohud_command(app_id, channel)}"\
|
||||||
|
"#{wine_command(app_id, channel)}"\
|
||||||
|
"#{attempted ? start_command(path, exe) : "\"#{exe_path}\""} "\
|
||||||
|
"-launcher #{args.join(' ')}"
|
||||||
|
)
|
||||||
Process.detach(pid)
|
Process.detach(pid)
|
||||||
rescue Errno::EINVAL => e
|
rescue Errno::EINVAL => e
|
||||||
retryable = !attempted
|
retryable = !attempted
|
||||||
@@ -236,13 +268,15 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
|
|
||||||
def join_server(app_id, channel, server, username = Store.settings[:server_list_username], password = nil, multi = false)
|
def join_server(app_id, channel, server, username = Store.settings[:server_list_username], password = nil, multi = false)
|
||||||
if installed?(app_id, channel) && username.to_s.length.positive?
|
return unless installed?(app_id, channel) && username.to_s.length.positive?
|
||||||
|
|
||||||
run(
|
run(
|
||||||
app_id, channel,
|
app_id, channel,
|
||||||
"+connect #{server.address}:#{server.port} +netplayername #{username}#{password ? " +password \"#{password}\"" : ""}#{multi ? " +multi" : ""}"
|
"+connect #{server.address}:#{server.port} "\
|
||||||
|
"+netplayername #{username}#{password ? " +password \"#{password}\"" : ""}"\
|
||||||
|
"#{multi ? " +multi" : ""}"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def play_now_server(app_id, channel)
|
def play_now_server(app_id, channel)
|
||||||
app_data = installed?(app_id, channel)
|
app_data = installed?(app_id, channel)
|
||||||
@@ -255,13 +289,18 @@ class W3DHub
|
|||||||
!server.status.password &&
|
!server.status.password &&
|
||||||
server.status.player_count < server.status.max_players
|
server.status.player_count < server.status.max_players
|
||||||
end
|
end
|
||||||
|
# sort by player count HIGH to LOW
|
||||||
|
# and by ping LOW to HIGH
|
||||||
|
server_options.sort! do |a, b|
|
||||||
|
[b.status.player_count, a.ping] <=> [a.status.player_count, b.ping]
|
||||||
|
end
|
||||||
|
|
||||||
# try to find server with lowest ping and matching version
|
# try to find server with lowest ping and matching version
|
||||||
found_server = server_options.find { |server| server.version == app_data[:installed_version] }
|
found_server = server_options.find { |server| server.version == app_data[:installed_version] }
|
||||||
# try to find server with lowest ping and undefined version
|
# try to find server with lowest ping and undefined version
|
||||||
found_server ||= server_options.find { |server| server.version == Api::ServerListServer::NO_OR_DEFAULT_VERSION }
|
found_server ||= server_options.find { |server| server.version == Api::ServerListServer::NO_OR_DEFAULT_VERSION }
|
||||||
|
|
||||||
found_server ? found_server : nil
|
found_server
|
||||||
end
|
end
|
||||||
|
|
||||||
def play_now(app_id, channel)
|
def play_now(app_id, channel)
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
|
|
||||||
def save_config(config = @config)
|
def save_config(config = @config)
|
||||||
File.write(CONFIG_PATH, config.to_json)
|
File.write(CONFIG_PATH, JSON.pretty_generate(config))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -61,10 +61,8 @@ class W3DHub
|
|||||||
prefill: Store.settings[:server_list_username],
|
prefill: Store.settings[:server_list_username],
|
||||||
accept_callback: accept_callback,
|
accept_callback: accept_callback,
|
||||||
cancel_callback: cancel_callback,
|
cancel_callback: cancel_callback,
|
||||||
# See: https://gitlab.com/danpaul88/brenbot/-/blob/master/Source/renlog.pm#L136-175
|
|
||||||
valid_callback: proc do |entry|
|
valid_callback: proc do |entry|
|
||||||
entry.length > 1 && entry.length < 30 && (entry =~ /(:|!|&|%| )/i).nil? &&
|
entry.length.between?(3, 40) && (entry =~ /^[a-z0-9_\-\[\]]+$/i)
|
||||||
(entry =~ /[\001\002\037]/).nil? && (entry =~ /\\/).nil?
|
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@@ -123,7 +121,6 @@ class W3DHub
|
|||||||
process_info = Process.create(**hash)
|
process_info = Process.create(**hash)
|
||||||
|
|
||||||
pid = process_info.process_id
|
pid = process_info.process_id
|
||||||
status = -1
|
|
||||||
|
|
||||||
until (status = Process.get_exitcode(pid))
|
until (status = Process.get_exitcode(pid))
|
||||||
if block
|
if block
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ class W3DHub
|
|||||||
class HardwareSurvey
|
class HardwareSurvey
|
||||||
attr_reader :data
|
attr_reader :data
|
||||||
|
|
||||||
def initialize
|
def initialize(displays_only: false)
|
||||||
@data = {
|
@data = {
|
||||||
displays: [],
|
displays: [],
|
||||||
system: {
|
system: {
|
||||||
@@ -26,8 +26,6 @@ class W3DHub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Hardware survey only works on Windows atm
|
|
||||||
|
|
||||||
if Gem::win_platform?
|
if Gem::win_platform?
|
||||||
lib_dir = File.dirname($LOADED_FEATURES.find { |file| file.include?("gosu.so") })
|
lib_dir = File.dirname($LOADED_FEATURES.find { |file| file.include?("gosu.so") })
|
||||||
SDL.load_lib("#{lib_dir}64/SDL2.dll")
|
SDL.load_lib("#{lib_dir}64/SDL2.dll")
|
||||||
@@ -36,11 +34,13 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
|
|
||||||
query_displays
|
query_displays
|
||||||
|
unless displays_only
|
||||||
query_motherboard
|
query_motherboard
|
||||||
query_operating_system
|
query_operating_system
|
||||||
query_cpus
|
query_cpus
|
||||||
query_ram
|
query_ram
|
||||||
query_gpus
|
query_gpus
|
||||||
|
end
|
||||||
|
|
||||||
@data.freeze
|
@data.freeze
|
||||||
end
|
end
|
||||||
@@ -68,8 +68,8 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
|
|
||||||
def query_motherboard
|
def query_motherboard
|
||||||
return unless Gem::win_platform?
|
if Gem::win_platform?
|
||||||
|
begin
|
||||||
Win32::Registry::HKEY_LOCAL_MACHINE.open("HARDWARE\\DESCRIPTION\\System\\BIOS", Win32::Registry::KEY_READ) do |reg|
|
Win32::Registry::HKEY_LOCAL_MACHINE.open("HARDWARE\\DESCRIPTION\\System\\BIOS", Win32::Registry::KEY_READ) do |reg|
|
||||||
@data[:system][:motherboard][:manufacturer] = safe_reg(reg, "SystemManufacturer")
|
@data[:system][:motherboard][:manufacturer] = safe_reg(reg, "SystemManufacturer")
|
||||||
@data[:system][:motherboard][:model] = safe_reg(reg, "SystemProductName")
|
@data[:system][:motherboard][:model] = safe_reg(reg, "SystemProductName")
|
||||||
@@ -84,10 +84,16 @@ class W3DHub
|
|||||||
@data[:system][:motherboard][:bios_release_date] = "Unknown"
|
@data[:system][:motherboard][:bios_release_date] = "Unknown"
|
||||||
@data[:system][:motherboard][:bios_version] = "Unknown"
|
@data[:system][:motherboard][:bios_version] = "Unknown"
|
||||||
end
|
end
|
||||||
|
else # unix
|
||||||
|
@data[:system][:motherboard][:manufacturer] = safe_file("/sys/devices/virtual/dmi/id/board_vendor")
|
||||||
|
@data[:system][:motherboard][:model] = safe_file("/sys/devices/virtual/dmi/id/board_name")
|
||||||
|
@data[:system][:motherboard][:bios_version] = safe_file("/sys/devices/virtual/dmi/id/board_version")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def query_operating_system
|
def query_operating_system
|
||||||
return unless Gem::win_platform?
|
if Gem::win_platform?
|
||||||
|
begin
|
||||||
Win32::Registry::HKEY_LOCAL_MACHINE.open("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", Win32::Registry::KEY_READ) do |reg|
|
Win32::Registry::HKEY_LOCAL_MACHINE.open("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", Win32::Registry::KEY_READ) do |reg|
|
||||||
@data[:system][:operating_system][:name] = safe_reg(reg, "ProductName")
|
@data[:system][:operating_system][:name] = safe_reg(reg, "ProductName")
|
||||||
@data[:system][:operating_system][:build] = safe_reg(reg, "CurrentBuild")
|
@data[:system][:operating_system][:build] = safe_reg(reg, "CurrentBuild")
|
||||||
@@ -100,6 +106,14 @@ class W3DHub
|
|||||||
@data[:system][:operating_system][:version] = "Unknown"
|
@data[:system][:operating_system][:version] = "Unknown"
|
||||||
@data[:system][:operating_system][:edition] = "Unknown"
|
@data[:system][:operating_system][:edition] = "Unknown"
|
||||||
end
|
end
|
||||||
|
else # unix
|
||||||
|
release_info = query_release_info
|
||||||
|
@data[:system][:operating_system][:name] = release_info["pretty_name"] || release_info["name"] || "Unknown"
|
||||||
|
@data[:system][:operating_system][:build] = release_info["version_codename"] || release_info["build_id"] || "Unknown"
|
||||||
|
@data[:system][:operating_system][:version] = release_info["version_id"] || release_info["build_id"] || "Unknown"
|
||||||
|
@data[:system][:operating_system][:edition] = release_info["id"] || release_info["id_like"] || "Unknown"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def query_cpus
|
def query_cpus
|
||||||
if Gem::win_platform?
|
if Gem::win_platform?
|
||||||
@@ -122,6 +136,16 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
rescue Win32::Registry::Error
|
rescue Win32::Registry::Error
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
cpu_info = query_cpu_info
|
||||||
|
cpu_info.each do |cpu|
|
||||||
|
@data[:system][:cpus] << {
|
||||||
|
manufacturer: cpu["manufacturer"] || "Unknown",
|
||||||
|
model: cpu["model"] || "Unknown",
|
||||||
|
mhz: cpu["mhz"] || "Unknown",
|
||||||
|
family: cpu["family"] || "Unknown"
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
instruction_sets = %w[ HasRDTSC HasAltiVec HasMMX Has3DNow HasSSE HasSSE2 HasSSE3 HasSSE41 HasSSE42 HasAVX HasAVX2 HasAVX512F HasARMSIMD HasNEON ] # HasLSX HasLASX # These cause a crash atm
|
instruction_sets = %w[ HasRDTSC HasAltiVec HasMMX Has3DNow HasSSE HasSSE2 HasSSE3 HasSSE41 HasSSE42 HasAVX HasAVX2 HasAVX512F HasARMSIMD HasNEON ] # HasLSX HasLASX # These cause a crash atm
|
||||||
@@ -140,8 +164,8 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
|
|
||||||
def query_gpus
|
def query_gpus
|
||||||
return unless Gem::win_platform?
|
if Gem::win_platform?
|
||||||
|
begin
|
||||||
Win32::Registry::HKEY_LOCAL_MACHINE.open("SYSTEM\\ControlSet001\\Control\\Class\\{4d36e968-e325-11ce-bfc1-08002be10318}", Win32::Registry::KEY_READ) do |reg|
|
Win32::Registry::HKEY_LOCAL_MACHINE.open("SYSTEM\\ControlSet001\\Control\\Class\\{4d36e968-e325-11ce-bfc1-08002be10318}", Win32::Registry::KEY_READ) do |reg|
|
||||||
i = 0
|
i = 0
|
||||||
|
|
||||||
@@ -179,11 +203,149 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
rescue Win32::Registry::Error
|
rescue Win32::Registry::Error
|
||||||
end
|
end
|
||||||
|
else # unix
|
||||||
|
gpu_info = query_glx_info
|
||||||
|
gpu_info.each do |gpu|
|
||||||
|
@data[:system][:gpus] << {
|
||||||
|
manufacturer: gpu["manufacturer"] || "Unknown",
|
||||||
|
model: gpu["model"] || "Unknown",
|
||||||
|
vram: gpu["vram"].to_i,
|
||||||
|
driver_date: gpu["driver_date"] || "Unknown",
|
||||||
|
driver_version: gpu["driver_version"] || "Unknown"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def safe_reg(reg, key, default_value = "Unknown")
|
def safe_reg(reg, key, default_value = "Unknown")
|
||||||
reg[key]
|
reg[key]
|
||||||
rescue Win32::Registry::Error
|
rescue Win32::Registry::Error
|
||||||
default_value
|
default_value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def safe_file(path, default_value = "Unknown")
|
||||||
|
value = File.read(path).to_s.strip
|
||||||
|
return default_value if value.downcase == "default string"
|
||||||
|
|
||||||
|
value
|
||||||
|
rescue
|
||||||
|
default_value
|
||||||
|
end
|
||||||
|
|
||||||
|
def query_release_info
|
||||||
|
hash = {}
|
||||||
|
|
||||||
|
File.open("/etc/os-release") do |f|
|
||||||
|
f.each_line do |line|
|
||||||
|
line = line.strip
|
||||||
|
|
||||||
|
key, value = line.split("=", 2)
|
||||||
|
value.gsub!('"', "")
|
||||||
|
|
||||||
|
hash[key.downcase] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
hash
|
||||||
|
rescue
|
||||||
|
hash
|
||||||
|
end
|
||||||
|
|
||||||
|
def query_cpu_info
|
||||||
|
cpus = []
|
||||||
|
|
||||||
|
cpu = {}
|
||||||
|
File.open("/proc/cpuinfo") do |f|
|
||||||
|
f.each_line do |line|
|
||||||
|
line = line.strip
|
||||||
|
|
||||||
|
if line.empty?
|
||||||
|
cpu["family"] = format(
|
||||||
|
"%s Family %s Model %s Stepping %s",
|
||||||
|
cpu["manufacturer"] || "Unknown",
|
||||||
|
cpu["_family"] || "Unknown",
|
||||||
|
cpu["_model"] || "Unknown",
|
||||||
|
cpu["_stepping"] || "Unknown",
|
||||||
|
)
|
||||||
|
|
||||||
|
cpus << cpu
|
||||||
|
cpu = {}
|
||||||
|
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
|
key, value = line.split(":", 2).map(&:strip)
|
||||||
|
|
||||||
|
case key.downcase
|
||||||
|
when "vendor_id"
|
||||||
|
cpu["manufacturer"] = value
|
||||||
|
when "model name"
|
||||||
|
cpu["model"] = value
|
||||||
|
when "cpu mhz"
|
||||||
|
cpu["mhz"] = value
|
||||||
|
|
||||||
|
when "cpu family"
|
||||||
|
cpu["_family"] = value
|
||||||
|
when "model"
|
||||||
|
cpu["_model"] = value
|
||||||
|
when "stepping"
|
||||||
|
cpu["_stepping"] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
cpus
|
||||||
|
rescue
|
||||||
|
cpus
|
||||||
|
end
|
||||||
|
|
||||||
|
def query_glx_info
|
||||||
|
gpus = []
|
||||||
|
glxinfo = `glxinfo`
|
||||||
|
|
||||||
|
return gpus if glxinfo.empty?
|
||||||
|
|
||||||
|
gpu = {}
|
||||||
|
glxinfo.lines do |line|
|
||||||
|
line = line.strip
|
||||||
|
|
||||||
|
next if line.empty?
|
||||||
|
|
||||||
|
key, value = line.split(":", 2).map(&:strip)
|
||||||
|
|
||||||
|
mesa_info = false
|
||||||
|
gpu_memory_info = false
|
||||||
|
case key.downcase
|
||||||
|
when "opengl vendor string"
|
||||||
|
if mesa_info
|
||||||
|
gpus << gpu
|
||||||
|
gpu = {}
|
||||||
|
|
||||||
|
break
|
||||||
|
end
|
||||||
|
when /extended renderer info \(GLX_MESA_query_renderer\)/i
|
||||||
|
# Joy and happiness
|
||||||
|
mesa_info = true
|
||||||
|
when /Memory info \(GL_NVX_gpu_memory_info\)/i
|
||||||
|
# Happiness and joy
|
||||||
|
gpu_memory_info = true
|
||||||
|
when "vendor", "opengl vendor string"
|
||||||
|
gpu["manufacturer"] = value
|
||||||
|
when "device", "opengl renderer string"
|
||||||
|
gpu["model"] = value
|
||||||
|
when "version"
|
||||||
|
gpu["driver_version"] = value
|
||||||
|
when "video memory", "dedicated video memory"
|
||||||
|
gpu["vram"] = value.gsub(/[\D]+/, "")
|
||||||
|
when "opengl version string"
|
||||||
|
gpus << gpu
|
||||||
|
gpu = {}
|
||||||
|
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
gpus
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -123,7 +123,6 @@ class W3DHub
|
|||||||
background_image_path = Cache.package_path(game.category, game.id, "background.png", "")
|
background_image_path = Cache.package_path(game.category, game.id, "background.png", "")
|
||||||
if File.exist?(background_image_path)
|
if File.exist?(background_image_path)
|
||||||
States::Interface.instance&.instance_variable_get(:"@interface_container")&.style&.background_image = get_image(background_image_path)
|
States::Interface.instance&.instance_variable_get(:"@interface_container")&.style&.background_image = get_image(background_image_path)
|
||||||
States::Interface.instance&.instance_variable_get(:"@interface_container")&.style&.default[:background_image] = get_image(background_image_path)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Game Stuff
|
# Game Stuff
|
||||||
|
|||||||
@@ -271,9 +271,8 @@ class W3DHub
|
|||||||
def stylize_selected_server(server_container)
|
def stylize_selected_server(server_container)
|
||||||
server_container.style.background = @selected_color
|
server_container.style.background = @selected_color
|
||||||
|
|
||||||
server_container.style.default[:background] = @selected_color
|
server_container.style.hover.background = @selected_color
|
||||||
server_container.style.hover[:background] = @selected_color
|
server_container.style.active.background = @selected_color
|
||||||
server_container.style.active[:background] = @selected_color
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def reorder_server_list
|
def reorder_server_list
|
||||||
@@ -284,11 +283,11 @@ class W3DHub
|
|||||||
end.reverse!.each_with_index do |child, i|
|
end.reverse!.each_with_index do |child, i|
|
||||||
next if @selected_server_container && child == @selected_server_container
|
next if @selected_server_container && child == @selected_server_container
|
||||||
|
|
||||||
child.style.hover[:background] = 0xaa_555566
|
child.style.hover.background = 0xaa_555566
|
||||||
child.style.hover[:active] = 0xaa_555588
|
child.style.active.background = 0xaa_555588
|
||||||
|
|
||||||
child.style.default[:background] = 0xaa_333333 if i.even?
|
child.style.background = 0xaa_333333 if i.even?
|
||||||
child.style.default[:background] = 0x00_000000 if i.odd?
|
child.style.background = 0x00_000000 if i.odd?
|
||||||
end
|
end
|
||||||
|
|
||||||
@server_list_container.recalculate
|
@server_list_container.recalculate
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
|
|
||||||
def save_settings
|
def save_settings
|
||||||
File.write(SETTINGS_FILE_PATH, @settings.to_json)
|
File.write(SETTINGS_FILE_PATH, JSON.pretty_generate(@settings))
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_application_cache(json)
|
def save_application_cache(json)
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ class W3DHub
|
|||||||
Api.on_thread(:_applications) do |applications|
|
Api.on_thread(:_applications) do |applications|
|
||||||
if applications
|
if applications
|
||||||
Store.applications = applications
|
Store.applications = applications
|
||||||
Store.settings.save_application_cache(applications.data.to_json)
|
Store.settings.save_application_cache(JSON.pretty_generate(applications.data))
|
||||||
@tasks[:applications][:complete] = true
|
@tasks[:applications][:complete] = true
|
||||||
else
|
else
|
||||||
# FIXME: Failed to retreive!
|
# FIXME: Failed to retreive!
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ class W3DHub
|
|||||||
@service_status = @options[:service_status]
|
@service_status = @options[:service_status]
|
||||||
@applications = @options[:applications]
|
@applications = @options[:applications]
|
||||||
|
|
||||||
|
@account_expire = Gosu.milliseconds
|
||||||
@applications_expire = Gosu.milliseconds + APPLICATIONS_UPDATE_INTERVAL # ten minutes
|
@applications_expire = Gosu.milliseconds + APPLICATIONS_UPDATE_INTERVAL # ten minutes
|
||||||
@server_list_expire = Gosu.milliseconds + SERVER_LIST_UPDATE_INTERVAL # 5 minutes
|
@server_list_expire = Gosu.milliseconds + SERVER_LIST_UPDATE_INTERVAL # 5 minutes
|
||||||
|
|
||||||
@@ -59,25 +60,21 @@ class W3DHub
|
|||||||
|
|
||||||
link I18n.t(:"interface.servers").upcase, text_size: 34, font: BOLD_FONT, margin_left: 12 do
|
link I18n.t(:"interface.servers").upcase, text_size: 34, font: BOLD_FONT, margin_left: 12 do
|
||||||
@interface_container.style.background_image = DEFAULT_BACKGROUND_IMAGE
|
@interface_container.style.background_image = DEFAULT_BACKGROUND_IMAGE
|
||||||
@interface_container.style.default[:background_image] = DEFAULT_BACKGROUND_IMAGE
|
|
||||||
page(W3DHub::Pages::ServerBrowser)
|
page(W3DHub::Pages::ServerBrowser)
|
||||||
end
|
end
|
||||||
|
|
||||||
link I18n.t(:"interface.community").upcase, text_size: 34, font: BOLD_FONT, margin_left: 12 do
|
link I18n.t(:"interface.community").upcase, text_size: 34, font: BOLD_FONT, margin_left: 12 do
|
||||||
@interface_container.style.background_image = DEFAULT_BACKGROUND_IMAGE
|
@interface_container.style.background_image = DEFAULT_BACKGROUND_IMAGE
|
||||||
@interface_container.style.default[:background_image] = DEFAULT_BACKGROUND_IMAGE
|
|
||||||
page(W3DHub::Pages::Community)
|
page(W3DHub::Pages::Community)
|
||||||
end
|
end
|
||||||
|
|
||||||
link I18n.t(:"interface.downloads").upcase, text_size: 34, font: BOLD_FONT, margin_left: 12 do
|
link I18n.t(:"interface.downloads").upcase, text_size: 34, font: BOLD_FONT, margin_left: 12 do
|
||||||
@interface_container.style.background_image = DEFAULT_BACKGROUND_IMAGE
|
@interface_container.style.background_image = DEFAULT_BACKGROUND_IMAGE
|
||||||
@interface_container.style.default[:background_image] = DEFAULT_BACKGROUND_IMAGE
|
|
||||||
page(W3DHub::Pages::DownloadManager)
|
page(W3DHub::Pages::DownloadManager)
|
||||||
end
|
end
|
||||||
|
|
||||||
link I18n.t(:"interface.settings").upcase, text_size: 34, font: BOLD_FONT, margin_left: 12 do
|
link I18n.t(:"interface.settings").upcase, text_size: 34, font: BOLD_FONT, margin_left: 12 do
|
||||||
@interface_container.style.background_image = DEFAULT_BACKGROUND_IMAGE
|
@interface_container.style.background_image = DEFAULT_BACKGROUND_IMAGE
|
||||||
@interface_container.style.default[:background_image] = DEFAULT_BACKGROUND_IMAGE
|
|
||||||
page(W3DHub::Pages::Settings)
|
page(W3DHub::Pages::Settings)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -132,6 +129,13 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
|
|
||||||
hide_application_taskbar
|
hide_application_taskbar
|
||||||
|
|
||||||
|
every(3_000) do
|
||||||
|
# NOTE: each method called, internally checks whether it should act.
|
||||||
|
refresh_account_token
|
||||||
|
refresh_applications
|
||||||
|
refresh_server_list
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def draw
|
def draw
|
||||||
@@ -146,36 +150,6 @@ class W3DHub
|
|||||||
@page&.update
|
@page&.update
|
||||||
|
|
||||||
update_interface_task_status(@interface_task_update_pending) if @interface_task_update_pending
|
update_interface_task_status(@interface_task_update_pending) if @interface_task_update_pending
|
||||||
|
|
||||||
if Gosu.milliseconds >= @applications_expire
|
|
||||||
@applications_expire = Gosu.milliseconds + 30_000
|
|
||||||
|
|
||||||
Api.on_thread(:_applications) do |applications|
|
|
||||||
if applications
|
|
||||||
@applications_expire = Gosu.milliseconds + APPLICATIONS_UPDATE_INTERVAL # ten minutes
|
|
||||||
|
|
||||||
Store.applications = applications
|
|
||||||
|
|
||||||
# TODO: Signal Games and ServerBrowser that applications have been updated
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if Gosu.milliseconds >= @server_list_expire
|
|
||||||
@server_list_expire = Gosu.milliseconds + 30_000
|
|
||||||
|
|
||||||
Api.on_thread(:server_list, 2) do |list|
|
|
||||||
if list
|
|
||||||
@server_list_expire = Gosu.milliseconds + SERVER_LIST_UPDATE_INTERVAL # five minutes
|
|
||||||
|
|
||||||
Store.server_list_last_fetch = Gosu.milliseconds
|
|
||||||
|
|
||||||
Api::ServerListUpdater.instance.refresh_server_list(list)
|
|
||||||
|
|
||||||
BackgroundWorker.foreground_job(-> {}, ->(_) { States::Interface.instance&.update_server_browser(nil, :refresh_all) })
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def button_down(id)
|
def button_down(id)
|
||||||
@@ -274,6 +248,63 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def refresh_account_token
|
||||||
|
return if Gosu.milliseconds < @account_expire
|
||||||
|
return unless account = Store.account
|
||||||
|
|
||||||
|
@account_expire = Gosu.milliseconds + 30_000
|
||||||
|
|
||||||
|
if (account.access_token_expiry - Time.now) / 60 <= 60 * 3 # Refresh if token expires within 3 hours
|
||||||
|
logger.info(LOG_TAG) { "Refreshing user login..." }
|
||||||
|
|
||||||
|
Api.on_thread(:refresh_user_login, account.refresh_token) do |refreshed_account|
|
||||||
|
if refreshed_account
|
||||||
|
Store.account = refreshed_account
|
||||||
|
|
||||||
|
Store.settings[:account][:data] = refreshed_account
|
||||||
|
else
|
||||||
|
Store.settings[:account] = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
Store.settings.save_settings
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def refresh_applications
|
||||||
|
return if Gosu.milliseconds < @applications_expire
|
||||||
|
|
||||||
|
@applications_expire = Gosu.milliseconds + 30_000
|
||||||
|
|
||||||
|
Api.on_thread(:_applications) do |applications|
|
||||||
|
if applications
|
||||||
|
@applications_expire = Gosu.milliseconds + APPLICATIONS_UPDATE_INTERVAL # ten minutes
|
||||||
|
|
||||||
|
Store.applications = applications
|
||||||
|
|
||||||
|
# TODO: Signal Games and ServerBrowser that applications have been updated
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def refresh_server_list
|
||||||
|
return if Gosu.milliseconds < @server_list_expire
|
||||||
|
|
||||||
|
@server_list_expire = Gosu.milliseconds + 30_000
|
||||||
|
|
||||||
|
Api.on_thread(:server_list, 2) do |list|
|
||||||
|
if list
|
||||||
|
@server_list_expire = Gosu.milliseconds + SERVER_LIST_UPDATE_INTERVAL # five minutes
|
||||||
|
|
||||||
|
Store.server_list_last_fetch = Gosu.milliseconds
|
||||||
|
|
||||||
|
Api::ServerListUpdater.instance.refresh_server_list(list)
|
||||||
|
|
||||||
|
BackgroundWorker.foreground_job(-> {}, ->(_) { States::Interface.instance&.update_server_browser(nil, :refresh_all) })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class W3DHub
|
class W3DHub
|
||||||
DIR_NAME = "W3DHubAlt".freeze
|
DIR_NAME = "W3DHubAlt".freeze
|
||||||
VERSION = "0.9.1".freeze
|
VERSION = "0.9.2".freeze
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user