diff --git a/lib/application_manager/task.rb b/lib/application_manager/task.rb
index fa75f04..090ba74 100644
--- a/lib/application_manager/task.rb
+++ b/lib/application_manager/task.rb
@@ -1,6 +1,9 @@
class W3DHub
class ApplicationManager
class Task
+ class FailFast < RuntimeError
+ end
+
include CyberarmEngine::Common
attr_reader :app_id, :release_channel, :application, :channel,
@@ -59,6 +62,8 @@ class W3DHub
rescue RuntimeError => e
status = false
@task_failure_reason = e.message[0..512]
+ rescue FailFast
+ # no-op
end
# Force free some bytes
@@ -74,7 +79,8 @@ class W3DHub
end
end
- def execute_task; end
+ def execute_task
+ end
# Suspend operation, if possible
def pause
@@ -111,6 +117,8 @@ class W3DHub
@task_failure_reason = reason.to_s
hide_application_taskbar
+
+ raise FailFast, @task_failure_reason
end
def fail_silently!
@@ -119,6 +127,20 @@ class W3DHub
# Quick checks before network and computational work starts
def fail_fast
+ # Have write permissions to target directory
+ path = Cache.install_path(@application, @channel)
+ path = Store.settings[:app_install_dir] unless File.exist?(path)
+
+ begin
+ File.write("#{path}/___can_write.wlh", "")
+ File.delete("#{path}/___can_write.wlh")
+
+ Dir.mkdir("#{path}/__can_write")
+ Dir.rmdir("#{path}/__can_write")
+ rescue Errno::EACCES
+ fail!("FAIL FAST: Cannot write to #{path}")
+ end
+
# Have enough disk space
# tar present?
@@ -133,7 +155,7 @@ class W3DHub
end
def run_on_main_thread(block)
- window.main_thread_queue << block
+ Store.main_thread_queue << block
end
def send_message_dialog(type, title, message)
diff --git a/lib/background_worker.rb b/lib/background_worker.rb
index 8911bb1..e2e975f 100644
--- a/lib/background_worker.rb
+++ b/lib/background_worker.rb
@@ -71,7 +71,7 @@ class W3DHub
def deliver(result)
if @deliver_to_queue
- $window.main_thread_queue << -> { @callback.call(result) }
+ Store.main_thread_queue << -> { @callback.call(result) }
else
@callback.call(result)
end
diff --git a/lib/page.rb b/lib/page.rb
index 25410ec..13cd42d 100644
--- a/lib/page.rb
+++ b/lib/page.rb
@@ -15,10 +15,6 @@ class W3DHub
@options = {}
end
- def main_thread_queue
- @host.main_thread_queue
- end
-
def options=(options)
@options = options
end
diff --git a/lib/pages/server_browser.rb b/lib/pages/server_browser.rb
index 176d319..840aaa6 100644
--- a/lib/pages/server_browser.rb
+++ b/lib/pages/server_browser.rb
@@ -170,7 +170,7 @@ class W3DHub
Store.server_list.each do |server|
next unless @filters[server.game.to_sym]
next unless server.region == @filter_region || @filter_region == "Any"
- next unless server.channel == "release"
+ # next unless server.channel == "release"
i += 1
@@ -251,7 +251,7 @@ class W3DHub
game_updatable = Store.application_manager.updateable?(server.game, server.channel)
style = server.channel != "release" ? TESTING_BUTTON : {}
- button "#{I18n.t(:"server_browser.join_server")}", enabled: (game_installed && !game_updatable), **style do
+ button "#{I18n.t(:"server_browser.join_server")}", margin_left: 96, enabled: (game_installed && !game_updatable), **style do
# Check for nickname
# prompt for nickname
# !abort unless nickname set
@@ -310,19 +310,24 @@ class W3DHub
game_balance = server_game_balance(server)
- flow(width: 1.0, height: 0.05) do
- stack(width: 0.465, height: 1.0) do
- para "#{server.status.teams[0].name}", width: 1.0, text_align: :center
+ flow(width: 1.0, height: 0.1, border_thickness_bottom: 2, border_color_bottom: 0x44_ffffff) do
+ stack(width: 0.4, height: 1.0) do
+ para "#{server.status.teams[0].name} (#{server.status.players.select { |pl| pl.team == 0 }.count})", width: 1.0, text_align: :center
+ para game_balance[:team_0_score].to_i.to_s, width: 1.0, text_align: :center
end
- image game_balance[:icon], height: 1.0, tip: game_balance[:message], color: game_balance[:color]
+ stack(width: 0.2, height: 1.0) do
+ image game_balance[:icon], height: 0.5, margin_left: 20, tip: game_balance[:message], color: game_balance[:color]
+ para game_balance[:ratio].round(2).to_s, width: 1.0, text_align: :center
+ end
- stack(width: 0.46, height: 1.0) do
- para "#{server.status.teams[1].name}", width: 1.0, text_align: :center
+ stack(width: 0.4, height: 1.0) do
+ para "#{server.status.teams[1].name} (#{server.status.players.select { |pl| pl.team == 1 }.count})", width: 1.0, text_align: :center
+ para game_balance[:team_1_score].to_i.to_s, width: 1.0, text_align: :center
end
end
- flow(width: 1.0, height: 0.65, scroll: true) do
+ flow(width: 1.0, height: 0.60, scroll: true) do
stack(width: 0.5) do
server.status.players.select { |ply| ply.team == 0 }.sort_by { |ply| ply.score }.reverse.each do |player|
flow(width: 1.0, height: 18) do
@@ -392,14 +397,24 @@ class W3DHub
}
# team 0 is left side
- team_0_score = server.status.players.select { |ply| ply.team == 0 }.map(&:score).sum.to_f
+ team_0_score = server.status.teams[0].score
+ team_0_score = nil if team_0_score.zero?
+ team_0_score ||= server.status.players.select { |ply| ply.team == 0 }.map(&:score).sum
+ team_0_score = team_0_score.to_f
# team 1 is right side
- team_1_score = server.status.players.select { |ply| ply.team == 1 }.map(&:score).sum.to_f
+ team_1_score = server.status.teams[1].score
+ team_1_score = nil if team_1_score.zero?
+ team_1_score ||= server.status.players.select { |ply| ply.team == 1 }.map(&:score).sum
+ team_1_score = team_1_score.to_f
ratio = 1.0 / (team_0_score / team_1_score)
ratio = 1.0 if ratio.to_s == "NaN"
+ data[:ratio] = ratio
+ data[:team_0_score] = team_0_score
+ data[:team_1_score] = team_1_score
+
data[:icon] = if server.status.players.size < 20 && server.game != "ren"
data[:color] = 0xff_600000
data[:message] = "Too few players for a balanced game"
diff --git a/lib/pages/settings.rb b/lib/pages/settings.rb
index dc12aeb..8833078 100644
--- a/lib/pages/settings.rb
+++ b/lib/pages/settings.rb
@@ -5,18 +5,18 @@ class W3DHub
body.clear do
stack(width: 1.0, height: 1.0, padding: 16, scroll: true) do
para "Language"
- flow(width: 1.0) do
- para "Launcher Language", width: 0.249
+ flow(width: 1.0, height: 0.12) do
+ para "Launcher Language", width: 0.249, margin_left: 32, margin_top: 12
stack(width: 0.75) do
@language_menu = list_box items: I18n.available_locales.map { |l| expand_language_code(l.to_s) }, choose: expand_language_code(Store.settings[:language]), width: 1.0
- inscription "Select the UI language you'd like to use in the W3D Hub Launcher. You should restart the launcher after changing this setting before the UI will update"
+ inscription "Select the UI language you'd like to use in the W3D Hub Launcher."
end
end
- para "Folder Paths", margin_top: 32
- stack(width: 1.0) do
- flow(width: 1.0) do
- para "App Install Folder", width: 0.249
+ para "Folder Paths", margin_top: 8, padding_top: 8, border_thickness_top: 2, border_color_top: 0xee_ffffff, width: 1.0
+ stack(width: 1.0, height: 0.3) do
+ flow(width: 1.0, height: 0.5) do
+ para "App Install Folder", width: 0.249, margin_left: 32, margin_top: 12
stack(width: 0.75) do
@app_install_dir_input = edit_line Store.settings[:app_install_dir], width: 1.0
@@ -25,7 +25,7 @@ class W3DHub
end
flow(width: 1.0, margin_top: 16) do
- para "Package Cache Folder", width: 0.249
+ para "Package Cache Folder", width: 0.249, margin_left: 32, margin_top: 12
stack(width: 0.75) do
@package_cache_dir_input = edit_line Store.settings[:package_cache_dir], width: 1.0
@@ -35,17 +35,17 @@ class W3DHub
end
if true # W3DHub.unix?
- para "Wine", margin_top: 32
- flow(width: 1.0) do
- para "Wine Command", width: 0.249
+ para "Wine", margin_top: 8, padding_top: 8, border_thickness_top: 2, border_color_top: 0xee_ffffff, width: 1.0
+ flow(width: 1.0, height: 0.12) do
+ para "Wine Command", width: 0.249, margin_left: 32, margin_top: 12
stack(width: 0.75) do
@wine_command_input = edit_line Store.settings[:wine_command], width: 1.0
inscription "Command to use to for Windows compatiblity layer"
end
end
- flow(width: 1.0, margin_top: 16) do
- para "Wine Prefix", width: 0.249
+ flow(width: 1.0, height: 0.13, margin_top: 16) do
+ para "Wine Prefix", width: 0.249, margin_left: 32, margin_top: 12
stack(width: 0.75) do
@wine_prefix_toggle = toggle_button checked: Store.settings[:wine_prefix]
inscription "Whether each game gets its own prefix. Uses global/default prefix by default."
diff --git a/lib/states/boot.rb b/lib/states/boot.rb
index 7141791..b8301a1 100644
--- a/lib/states/boot.rb
+++ b/lib/states/boot.rb
@@ -153,10 +153,7 @@ class W3DHub
end
if regenerate
- ico = ICO.new(file: path)
- image = ico.images.max_by(&:width)
-
- ico.save(image, generated_icon_path)
+ BackgroundWorker.foreground_job(-> { ICO.new(file: path) }, ->(result) { result.save(result.images.max_by(&:width), generated_icon_path) })
end
end
diff --git a/lib/states/interface.rb b/lib/states/interface.rb
index cdeb27f..2ead488 100644
--- a/lib/states/interface.rb
+++ b/lib/states/interface.rb
@@ -1,7 +1,6 @@
class W3DHub
class States
class Interface < CyberarmEngine::GuiState
- attr_reader :main_thread_queue
attr_accessor :interface_task_update_pending
@@instance = nil
@@ -24,8 +23,6 @@ class W3DHub
@page = nil
@pages = {}
- @main_thread_queue = []
-
Store.application_manager.auto_import
theme(W3DHub::THEME)
@@ -122,10 +119,6 @@ class W3DHub
@page&.update
- while(block = @main_thread_queue.shift)
- block&.call
- end
-
update_interface_task_status(@interface_task_update_pending) if @interface_task_update_pending
end
diff --git a/lib/window.rb b/lib/window.rb
index f585a72..1383398 100644
--- a/lib/window.rb
+++ b/lib/window.rb
@@ -7,6 +7,8 @@ class W3DHub
Store[:settings] = Settings.new
Store[:application_manager] = ApplicationManager.new
+ Store[:main_thread_queue] = []
+
Store.settings.save_settings
begin
@@ -23,6 +25,10 @@ class W3DHub
super
Store.application_manager.start_next_available_task if Store.application_manager.idle?
+
+ while (block = Store.main_thread_queue.shift)
+ block&.call
+ end
end
def gain_focus
@@ -52,13 +58,7 @@ class W3DHub
end
def main_thread_queue
- if current_state.is_a?(W3DHub::States::Interface)
- current_state.main_thread_queue
- else
- warn "Task will not be run for:"
- warn caller
- []
- end
+ Store.main_thread_queue
end
end
end