mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2025-12-16 01:02:34 +00:00
Game settings no longer crashes on linux (still need to sort out how to load/save wine registry from outside of wine enviroment), updated gems.
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -1,6 +1,7 @@
|
|||||||
source "https://rubygems.org"
|
source "https://rubygems.org"
|
||||||
|
|
||||||
gem "cyberarm_engine"
|
gem "cyberarm_engine"
|
||||||
|
gem "sdl2-bindings"
|
||||||
gem "digest-crc"
|
gem "digest-crc"
|
||||||
gem "i18n"
|
gem "i18n"
|
||||||
gem "ircparser"
|
gem "ircparser"
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ GEM
|
|||||||
rake (13.1.0)
|
rake (13.1.0)
|
||||||
rexml (3.2.6)
|
rexml (3.2.6)
|
||||||
rubyzip (2.3.2)
|
rubyzip (2.3.2)
|
||||||
|
sdl2-bindings (0.2.2)
|
||||||
|
ffi (~> 1.15)
|
||||||
websocket (1.2.10)
|
websocket (1.2.10)
|
||||||
websocket-client-simple (0.8.0)
|
websocket-client-simple (0.8.0)
|
||||||
event_emitter
|
event_emitter
|
||||||
@@ -43,6 +45,7 @@ DEPENDENCIES
|
|||||||
ircparser
|
ircparser
|
||||||
rexml
|
rexml
|
||||||
rubyzip
|
rubyzip
|
||||||
|
sdl2-bindings
|
||||||
websocket-client-simple
|
websocket-client-simple
|
||||||
win32-process
|
win32-process
|
||||||
win32-security
|
win32-security
|
||||||
|
|||||||
@@ -6,8 +6,19 @@ class W3DHub
|
|||||||
@data = {
|
@data = {
|
||||||
displays: [],
|
displays: [],
|
||||||
system: {
|
system: {
|
||||||
motherboard: {},
|
motherboard: {
|
||||||
operating_system: {},
|
manufacturer: "Unknown",
|
||||||
|
model: "Unknown",
|
||||||
|
bios_vendor: "Unknown",
|
||||||
|
bios_release_date: "Unknown",
|
||||||
|
bios_version: "Unknown"
|
||||||
|
},
|
||||||
|
operating_system: {
|
||||||
|
name: "Unknown",
|
||||||
|
build: "Unknown",
|
||||||
|
version: "Unknown",
|
||||||
|
edition: "Unknown"
|
||||||
|
},
|
||||||
cpus: [],
|
cpus: [],
|
||||||
cpu_instruction_sets: {},
|
cpu_instruction_sets: {},
|
||||||
ram: 0,
|
ram: 0,
|
||||||
@@ -16,12 +27,13 @@ class W3DHub
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Hardware survey only works on Windows atm
|
# Hardware survey only works on Windows atm
|
||||||
return unless RbConfig::CONFIG["host_os"] =~ /mswin|msys|mingw|cygwin/
|
|
||||||
|
|
||||||
lib_dir = File.dirname($LOADED_FEATURES.find { |file| file.include?("gosu.so") })
|
if Gem::win_platform?
|
||||||
SDL.load_lib("#{lib_dir}64/SDL2.dll")
|
lib_dir = File.dirname($LOADED_FEATURES.find { |file| file.include?("gosu.so") })
|
||||||
# Gosu already handles this
|
SDL.load_lib("#{lib_dir}64/SDL2.dll")
|
||||||
# SDL.VideoInit(nil)
|
else
|
||||||
|
SDL.load_lib("libSDL2")
|
||||||
|
end
|
||||||
|
|
||||||
query_displays
|
query_displays
|
||||||
query_motherboard
|
query_motherboard
|
||||||
@@ -56,6 +68,8 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
|
|
||||||
def query_motherboard
|
def query_motherboard
|
||||||
|
return unless Gem::win_platform?
|
||||||
|
|
||||||
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")
|
||||||
@@ -72,6 +86,8 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
|
|
||||||
def query_operating_system
|
def query_operating_system
|
||||||
|
return unless Gem::win_platform?
|
||||||
|
|
||||||
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")
|
||||||
@@ -86,24 +102,26 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
|
|
||||||
def query_cpus
|
def query_cpus
|
||||||
begin
|
if Gem::win_platform?
|
||||||
Win32::Registry::HKEY_LOCAL_MACHINE.open("HARDWARE\\DESCRIPTION\\System\\CentralProcessor", Win32::Registry::KEY_READ) do |reg|
|
begin
|
||||||
i = 0
|
Win32::Registry::HKEY_LOCAL_MACHINE.open("HARDWARE\\DESCRIPTION\\System\\CentralProcessor", Win32::Registry::KEY_READ) do |reg|
|
||||||
|
i = 0
|
||||||
|
|
||||||
reg.each_key do |key|
|
reg.each_key do |key|
|
||||||
reg.open(key) do |cpu|
|
reg.open(key) do |cpu|
|
||||||
@data[:system][:cpus] << {
|
@data[:system][:cpus] << {
|
||||||
manufacturer: safe_reg(cpu, "VendorIdentifier", "Unknown"),
|
manufacturer: safe_reg(cpu, "VendorIdentifier", "Unknown"),
|
||||||
model: safe_reg(cpu, "ProcessorNameString").strip,
|
model: safe_reg(cpu, "ProcessorNameString").strip,
|
||||||
mhz: safe_reg(cpu, "~MHz"),
|
mhz: safe_reg(cpu, "~MHz"),
|
||||||
family: safe_reg(cpu, "Identifier")
|
family: safe_reg(cpu, "Identifier")
|
||||||
}
|
}
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
rescue Win32::Registry::Error
|
||||||
end
|
end
|
||||||
rescue Win32::Registry::Error
|
|
||||||
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
|
||||||
@@ -122,6 +140,8 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
|
|
||||||
def query_gpus
|
def query_gpus
|
||||||
|
return unless Gem::win_platform?
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|||||||
110
lib/win32_stub.rb
Normal file
110
lib/win32_stub.rb
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
module Win32
|
||||||
|
class Registry
|
||||||
|
module Constants
|
||||||
|
HKEY_CLASSES_ROOT = 0x80000000
|
||||||
|
HKEY_CURRENT_USER = 0x80000001
|
||||||
|
HKEY_LOCAL_MACHINE = 0x80000002
|
||||||
|
HKEY_USERS = 0x80000003
|
||||||
|
HKEY_PERFORMANCE_DATA = 0x80000004
|
||||||
|
HKEY_PERFORMANCE_TEXT = 0x80000050
|
||||||
|
HKEY_PERFORMANCE_NLSTEXT = 0x80000060
|
||||||
|
HKEY_CURRENT_CONFIG = 0x80000005
|
||||||
|
HKEY_DYN_DATA = 0x80000006
|
||||||
|
|
||||||
|
REG_NONE = 0
|
||||||
|
REG_SZ = 1
|
||||||
|
REG_EXPAND_SZ = 2
|
||||||
|
REG_BINARY = 3
|
||||||
|
REG_DWORD = 4
|
||||||
|
REG_DWORD_LITTLE_ENDIAN = 4
|
||||||
|
REG_DWORD_BIG_ENDIAN = 5
|
||||||
|
REG_LINK = 6
|
||||||
|
REG_MULTI_SZ = 7
|
||||||
|
REG_RESOURCE_LIST = 8
|
||||||
|
REG_FULL_RESOURCE_DESCRIPTOR = 9
|
||||||
|
REG_RESOURCE_REQUIREMENTS_LIST = 10
|
||||||
|
REG_QWORD = 11
|
||||||
|
REG_QWORD_LITTLE_ENDIAN = 11
|
||||||
|
|
||||||
|
STANDARD_RIGHTS_READ = 0x00020000
|
||||||
|
STANDARD_RIGHTS_WRITE = 0x00020000
|
||||||
|
KEY_QUERY_VALUE = 0x0001
|
||||||
|
KEY_SET_VALUE = 0x0002
|
||||||
|
KEY_CREATE_SUB_KEY = 0x0004
|
||||||
|
KEY_ENUMERATE_SUB_KEYS = 0x0008
|
||||||
|
KEY_NOTIFY = 0x0010
|
||||||
|
KEY_CREATE_LINK = 0x0020
|
||||||
|
KEY_READ = STANDARD_RIGHTS_READ |
|
||||||
|
KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY
|
||||||
|
KEY_WRITE = STANDARD_RIGHTS_WRITE |
|
||||||
|
KEY_SET_VALUE | KEY_CREATE_SUB_KEY
|
||||||
|
KEY_EXECUTE = KEY_READ
|
||||||
|
KEY_ALL_ACCESS = KEY_READ | KEY_WRITE | KEY_CREATE_LINK
|
||||||
|
|
||||||
|
REG_OPTION_RESERVED = 0x0000
|
||||||
|
REG_OPTION_NON_VOLATILE = 0x0000
|
||||||
|
REG_OPTION_VOLATILE = 0x0001
|
||||||
|
REG_OPTION_CREATE_LINK = 0x0002
|
||||||
|
REG_OPTION_BACKUP_RESTORE = 0x0004
|
||||||
|
REG_OPTION_OPEN_LINK = 0x0008
|
||||||
|
REG_LEGAL_OPTION = REG_OPTION_RESERVED |
|
||||||
|
REG_OPTION_NON_VOLATILE | REG_OPTION_CREATE_LINK |
|
||||||
|
REG_OPTION_BACKUP_RESTORE | REG_OPTION_OPEN_LINK
|
||||||
|
|
||||||
|
REG_CREATED_NEW_KEY = 1
|
||||||
|
REG_OPENED_EXISTING_KEY = 2
|
||||||
|
|
||||||
|
REG_WHOLE_HIVE_VOLATILE = 0x0001
|
||||||
|
REG_REFRESH_HIVE = 0x0002
|
||||||
|
REG_NO_LAZY_FLUSH = 0x0004
|
||||||
|
REG_FORCE_RESTORE = 0x0008
|
||||||
|
|
||||||
|
MAX_KEY_LENGTH = 514
|
||||||
|
MAX_VALUE_LENGTH = 32768
|
||||||
|
end
|
||||||
|
include Constants
|
||||||
|
include Enumerable
|
||||||
|
|
||||||
|
class Error < ::StandardError
|
||||||
|
attr_reader :code
|
||||||
|
end
|
||||||
|
|
||||||
|
class PredefinedKey < Registry
|
||||||
|
def initialize(hkey, keyname)
|
||||||
|
@hkey = hkey
|
||||||
|
@parent = nil
|
||||||
|
@keyname = keyname
|
||||||
|
@disposition = REG_OPENED_EXISTING_KEY
|
||||||
|
end
|
||||||
|
|
||||||
|
# Predefined keys cannot be closed
|
||||||
|
def close
|
||||||
|
raise Error.new(5) ## ERROR_ACCESS_DENIED
|
||||||
|
end
|
||||||
|
|
||||||
|
# Fake #class method for Registry#open, Registry#create
|
||||||
|
def class
|
||||||
|
Registry
|
||||||
|
end
|
||||||
|
|
||||||
|
# Make all
|
||||||
|
Constants.constants.grep(/^HKEY_/) do |c|
|
||||||
|
Registry.const_set c, new(Constants.const_get(c), c.to_s)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def open(*args)
|
||||||
|
raise Win32::Registry::Error
|
||||||
|
end
|
||||||
|
|
||||||
|
def create(*args)
|
||||||
|
Stub.new
|
||||||
|
end
|
||||||
|
|
||||||
|
class Stub
|
||||||
|
def write_i(*arg)
|
||||||
|
# No OP
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -78,6 +78,8 @@ I18n.default_locale = :en
|
|||||||
# GUI_DEBUG = true
|
# GUI_DEBUG = true
|
||||||
require_relative "lib/gui_state_ext"
|
require_relative "lib/gui_state_ext"
|
||||||
|
|
||||||
|
require_relative "lib/win32_stub" unless Gem.win_platform?
|
||||||
|
|
||||||
require_relative "lib/version"
|
require_relative "lib/version"
|
||||||
require_relative "lib/theme"
|
require_relative "lib/theme"
|
||||||
require_relative "lib/common"
|
require_relative "lib/common"
|
||||||
|
|||||||
Reference in New Issue
Block a user