mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2025-12-16 01:02:34 +00:00
Fixed token refresh happening to often at startup, replace missing game icon image with question mark, add support for more wwconfig.exe naming funkiness...
This commit is contained in:
@@ -9,7 +9,7 @@ class W3DHub
|
||||
@games = []
|
||||
|
||||
games.each { |hash| @games << Game.new(hash) }
|
||||
@games.sort_by! { |a| a.slot }.reverse
|
||||
@games.sort_by! { |a| a.name }.reverse
|
||||
end
|
||||
|
||||
def games
|
||||
@@ -17,13 +17,11 @@ class W3DHub
|
||||
end
|
||||
|
||||
class Game
|
||||
attr_reader :slot, :id, :name, :type, :category, :studio_id, :channels, :web_links, :color
|
||||
attr_reader :id, :name, :type, :category, :studio_id, :channels, :web_links, :color
|
||||
|
||||
def initialize(hash)
|
||||
@data = hash
|
||||
|
||||
@slot = slot_index(@data[:id])
|
||||
|
||||
@id = @data[:id]
|
||||
@name = @data[:name]
|
||||
@type = @data[:type]
|
||||
@@ -40,23 +38,6 @@ class W3DHub
|
||||
@color = "ff#{color}".to_i(16)
|
||||
end
|
||||
|
||||
private def slot_index(app_id)
|
||||
case app_id
|
||||
when "ren"
|
||||
1
|
||||
when "ecw"
|
||||
2
|
||||
when "ia"
|
||||
3
|
||||
when "apb"
|
||||
4
|
||||
when "tsr"
|
||||
5
|
||||
else
|
||||
-10
|
||||
end
|
||||
end
|
||||
|
||||
class Channel
|
||||
attr_reader :id, :name, :user_level, :current_version
|
||||
|
||||
|
||||
@@ -52,8 +52,15 @@ class W3DHub
|
||||
# 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}"
|
||||
exe = if File.exist?("#{app_data[:install_directory]}/wwconfig.exe")
|
||||
"#{app_data[:install_directory]}/wwconfig.exe"
|
||||
|
||||
elsif File.exist?("#{app_data[:install_directory]}/WWConfig.exe")
|
||||
"#{app_data[:install_directory]}/WWConfig.exe"
|
||||
|
||||
elsif File.exist?("#{app_data[:install_directory]}/config.exe")
|
||||
"#{app_data[:install_directory]}/config.exe"
|
||||
end
|
||||
|
||||
if File.exist?(exe)
|
||||
pid = Process.spawn("#{wine_command(app_id, channel)}\"#{exe}\"")
|
||||
|
||||
@@ -115,10 +115,13 @@ class W3DHub
|
||||
|
||||
# Quick checks before network and computational work starts
|
||||
def fail_fast
|
||||
# Have enough disk space
|
||||
|
||||
# tar present?
|
||||
bsdtar_present = system("#{W3DHub.tar_command} --help")
|
||||
fail!("FAIL FAST: `#{W3DHub.tar_command} --help` command failed, #{W3DHub.tar_command} is not installed. Will be unable to unpack packages.") unless bsdtar_present
|
||||
|
||||
# Wine present?
|
||||
if W3DHub.unix?
|
||||
wine_present = system("which #{Store.settings[:wine_command]}")
|
||||
fail!("FAIL FAST: `which #{Store.settings[:wine_command]}` command failed, wine is not installed. Will be unable to create prefixes or launch games.") unless wine_present
|
||||
|
||||
@@ -28,7 +28,7 @@ class W3DHub
|
||||
background task.application.color
|
||||
|
||||
flow(width: 0.70, height: 1.0) do
|
||||
image_path = File.exist?("#{GAME_ROOT_PATH}/media/icons/#{task.app_id}.png") ? "#{GAME_ROOT_PATH}/media/icons/#{task.app_id}.png" : "#{GAME_ROOT_PATH}/media/icons/app.png"
|
||||
image_path = File.exist?("#{GAME_ROOT_PATH}/media/icons/#{task.app_id}.png") ? "#{GAME_ROOT_PATH}/media/icons/#{task.app_id}.png" : "#{GAME_ROOT_PATH}/media/ui_icons/question.png"
|
||||
@application_image = image image_path, height: 1.0
|
||||
|
||||
stack(margin_left: 8, width: 0.75) do
|
||||
|
||||
@@ -40,7 +40,7 @@ class W3DHub
|
||||
image "#{GAME_ROOT_PATH}/media/ui_icons/return.png", width: 1.0, color: Gosu::Color::GRAY if Store.application_manager.updateable?(game.id, game.channels.first.id)
|
||||
image "#{GAME_ROOT_PATH}/media/ui_icons/import.png", width: 0.5, color: 0x88_ffffff unless Store.application_manager.installed?(game.id, game.channels.first.id)
|
||||
end
|
||||
image_path = File.exist?("#{GAME_ROOT_PATH}/media/icons/#{game.id}.png") ? "#{GAME_ROOT_PATH}/media/icons/#{game.id}.png" : "#{GAME_ROOT_PATH}/media/icons/app.png"
|
||||
image_path = File.exist?("#{GAME_ROOT_PATH}/media/icons/#{game.id}.png") ? "#{GAME_ROOT_PATH}/media/icons/#{game.id}.png" : "#{GAME_ROOT_PATH}/media/ui_icons/question.png"
|
||||
|
||||
image image_path, height: 48, color: Store.application_manager.installed?(game.id, game.channels.first.id) ? 0xff_ffffff : 0x88_ffffff
|
||||
end
|
||||
|
||||
@@ -26,7 +26,7 @@ class W3DHub
|
||||
@filters.each do |app_id, enabled|
|
||||
app = Store.applications.games.find { |a| a.id == app_id.to_s }
|
||||
|
||||
image_path = File.exist?("#{GAME_ROOT_PATH}/media/icons/#{app_id}.png") ? "#{GAME_ROOT_PATH}/media/icons/#{app_id}.png" : "#{GAME_ROOT_PATH}/media/icons/app.png"
|
||||
image_path = File.exist?("#{GAME_ROOT_PATH}/media/icons/#{app_id}.png") ? "#{GAME_ROOT_PATH}/media/icons/#{app_id}.png" : "#{GAME_ROOT_PATH}/media/ui_icons/question.png"
|
||||
|
||||
image image_path, tip: "#{app.name}", height: 1.0,
|
||||
border_thickness_bottom: 1, border_color_bottom: 0x00_000000,
|
||||
@@ -361,7 +361,7 @@ class W3DHub
|
||||
end
|
||||
|
||||
def game_icon(server)
|
||||
image_path = File.exist?("#{GAME_ROOT_PATH}/media/icons/#{server.game.nil? ? 'ren' : server.game}.png") ? "#{GAME_ROOT_PATH}/media/icons/#{server.game.nil? ? 'ren' : server.game}.png" : "#{GAME_ROOT_PATH}/media/icons/app.png"
|
||||
image_path = File.exist?("#{GAME_ROOT_PATH}/media/icons/#{server.game.nil? ? 'ren' : server.game}.png") ? "#{GAME_ROOT_PATH}/media/icons/#{server.game.nil? ? 'ren' : server.game}.png" : "#{GAME_ROOT_PATH}/media/ui_icons/question.png"
|
||||
|
||||
if server.status.password
|
||||
@server_locked_icons[server.game] ||= Gosu.render(96, 96) do
|
||||
|
||||
@@ -63,7 +63,8 @@ class W3DHub
|
||||
if Store.settings[:account, :data]
|
||||
account = Api::Account.new(Store.settings[:account, :data], {})
|
||||
|
||||
if (Time.now.to_i - account.access_token_expiry.to_i) >= 60 * 3 # Older than 3 hours then refresh
|
||||
if (account.access_token_expiry - Time.now) / 60 <= 60 * 3 # Refresh if token expires within 3 hours
|
||||
puts "Refreshing user login..."
|
||||
@account = Api.refresh_user_login(account.refresh_token)
|
||||
else
|
||||
@account = account
|
||||
|
||||
Reference in New Issue
Block a user