diff --git a/lib/api/applications.rb b/lib/api/applications.rb index 1caa77a..29f6195 100644 --- a/lib/api/applications.rb +++ b/lib/api/applications.rb @@ -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 diff --git a/lib/application_manager.rb b/lib/application_manager.rb index d7beea7..ea9879b 100644 --- a/lib/application_manager.rb +++ b/lib/application_manager.rb @@ -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}\"") diff --git a/lib/application_manager/task.rb b/lib/application_manager/task.rb index 42180b7..7930774 100644 --- a/lib/application_manager/task.rb +++ b/lib/application_manager/task.rb @@ -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 diff --git a/lib/pages/download_manager.rb b/lib/pages/download_manager.rb index 52d4a80..bb682b5 100644 --- a/lib/pages/download_manager.rb +++ b/lib/pages/download_manager.rb @@ -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 diff --git a/lib/pages/games.rb b/lib/pages/games.rb index 3a6984b..6fccc12 100644 --- a/lib/pages/games.rb +++ b/lib/pages/games.rb @@ -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 diff --git a/lib/pages/server_browser.rb b/lib/pages/server_browser.rb index 0f3f219..eb57ff7 100644 --- a/lib/pages/server_browser.rb +++ b/lib/pages/server_browser.rb @@ -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 diff --git a/lib/states/boot.rb b/lib/states/boot.rb index 82d22e0..387d61e 100644 --- a/lib/states/boot.rb +++ b/lib/states/boot.rb @@ -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