mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2025-12-16 09:12:35 +00:00
Changes, made server browser refresh button have a hard 30 second minimum refresh interval, settings are now saved!
This commit is contained in:
@@ -7,7 +7,13 @@ class W3DHub
|
|||||||
@download_package_info ||= {}
|
@download_package_info ||= {}
|
||||||
@task = Store.application_manager.current_task
|
@task = Store.application_manager.current_task
|
||||||
|
|
||||||
return unless @task
|
unless @task
|
||||||
|
body.clear do
|
||||||
|
tagline "No operations pending.", width: 1.0, text_align: :center, margin: 128
|
||||||
|
end
|
||||||
|
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
body.clear do
|
body.clear do
|
||||||
stack(width: 1.0, height: 1.0) do
|
stack(width: 1.0, height: 1.0) do
|
||||||
@@ -16,11 +22,11 @@ class W3DHub
|
|||||||
background @task.application.color
|
background @task.application.color
|
||||||
|
|
||||||
flow(width: 0.70, height: 1.0) do
|
flow(width: 0.70, height: 1.0) do
|
||||||
image "#{GAME_ROOT_PATH}/media/icons/#{@task.app_id}.png", height: 1.0
|
@application_image = image "#{GAME_ROOT_PATH}/media/icons/#{@task.app_id}.png", height: 1.0
|
||||||
|
|
||||||
stack(margin_left: 8) do
|
stack(margin_left: 8) do
|
||||||
$bug_1 = tagline "#{@task.application.name}"
|
@application_name_label = tagline "#{@task.application.name}"
|
||||||
$bug_2 = inscription "Version: #{@task.channel.current_version} (#{@task.channel.id})"
|
@application_version_label = inscription "Version: #{@task.channel.current_version} (#{@task.channel.id})"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -29,7 +35,7 @@ class W3DHub
|
|||||||
flow(width: 0.30, height: 1.0) do
|
flow(width: 0.30, height: 1.0) do
|
||||||
stack(width: 0.499, height: 1.0) do
|
stack(width: 0.499, height: 1.0) do
|
||||||
para "Download Speed", width: 1.0, text_align: :center
|
para "Download Speed", width: 1.0, text_align: :center
|
||||||
inscription "10 MB/s", width: 1.0, text_align: :center
|
@download_speed_label = inscription "0 b/s", width: 1.0, text_align: :center
|
||||||
end
|
end
|
||||||
|
|
||||||
stack(width: 0.5, height: 1.0) do
|
stack(width: 0.5, height: 1.0) do
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Game Stuff
|
# Game Stuff
|
||||||
flow(width: 1.0, height: 0.89) do
|
flow(width: 1.0, height: 0.88) do
|
||||||
# background 0xff_9999ff
|
# background 0xff_9999ff
|
||||||
|
|
||||||
# Game options
|
# Game options
|
||||||
@@ -124,7 +124,7 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Play buttons
|
# Play buttons
|
||||||
flow(width: 1.0, height: 0.08) do
|
flow(width: 1.0, height: 0.09, padding_top: 6) do
|
||||||
# background 0xff_551100
|
# background 0xff_551100
|
||||||
|
|
||||||
if Store.application_manager.installed?(game.id, channel.id)
|
if Store.application_manager.installed?(game.id, channel.id)
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class W3DHub
|
|||||||
populate_server_list
|
populate_server_list
|
||||||
end
|
end
|
||||||
|
|
||||||
button get_image("#{GAME_ROOT_PATH}/media/ui_icons/return.png"), image_height: 1.0, margin_left: 16, padding_left: 2, padding_right: 2, padding_top: 2, padding_bottom: 2 do
|
button get_image("#{GAME_ROOT_PATH}/media/ui_icons/return.png"), tip: I18n.t(:"server_browser.refresh"), image_height: 1.0, margin_left: 16, padding_left: 2, padding_right: 2, padding_top: 2, padding_bottom: 2 do
|
||||||
fetch_server_list
|
fetch_server_list
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -306,13 +306,18 @@ class W3DHub
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fetch_server_list
|
def fetch_server_list
|
||||||
|
unless Gosu.milliseconds - Store.server_list_last_fetch >= 30_000 # 30 seconds
|
||||||
|
populate_server_list # Fake it
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
Thread.new do
|
Thread.new do
|
||||||
begin
|
begin
|
||||||
list = Api.server_list(2)
|
list = Api.server_list(2)
|
||||||
|
|
||||||
if list
|
if list
|
||||||
Store.server_list = list.sort_by! { |s| s&.status&.players&.size }.reverse
|
Store.server_list = list.sort_by! { |s| s&.status&.players&.size }.reverse
|
||||||
|
Store.server_list_last_fetch = Gosu.milliseconds
|
||||||
|
|
||||||
main_thread_queue << proc { populate_server_list }
|
main_thread_queue << proc { populate_server_list }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,42 +3,110 @@ class W3DHub
|
|||||||
class Settings < Page
|
class Settings < Page
|
||||||
def setup
|
def setup
|
||||||
body.clear do
|
body.clear do
|
||||||
stack(width: 1.0, height: 1.0, padding: 64, scroll: true) do
|
stack(width: 1.0, height: 1.0, padding: 16, scroll: true) do
|
||||||
para "<b>Language</b>"
|
para "<b>Language</b>"
|
||||||
para "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", width: 1.0
|
flow(width: 1.0) do
|
||||||
list_box items: ["English", "French", "German"], width: 1.0
|
para "<b>Launcher Language</b>", width: 0.249
|
||||||
|
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"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
para "<b>Folder Paths</b>", margin_top: 32
|
para "<b>Folder Paths</b>", margin_top: 32
|
||||||
stack(width: 1.0, height: 0.35) do
|
stack(width: 1.0) do
|
||||||
flow(width: 1.0, height: 0.5) do
|
flow(width: 1.0) do
|
||||||
para "<b>App Install Folder</b>", width: 0.249
|
para "<b>App Install Folder</b>", width: 0.249
|
||||||
|
|
||||||
stack(width: 0.75, height: 1.0) do
|
stack(width: 0.75) do
|
||||||
edit_line Store.settings[:app_install_dir], width: 1.0
|
@app_install_dir_input = edit_line Store.settings[:app_install_dir], width: 1.0
|
||||||
inscription "The folder into which new games and apps will be installed by the launcher"
|
inscription "The folder into which new games and apps will be installed by the launcher"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
flow(width: 1.0, height: 0.5) do
|
flow(width: 1.0, margin_top: 16) do
|
||||||
para "<b>Package Cache Folder</b>", width: 0.249
|
para "<b>Package Cache Folder</b>", width: 0.249
|
||||||
|
|
||||||
stack(width: 0.75, height: 1.0) do
|
stack(width: 0.75) do
|
||||||
edit_line Store.settings[:package_cache_dir], width: 1.0
|
@package_cache_dir_input = edit_line Store.settings[:package_cache_dir], width: 1.0
|
||||||
inscription "A folder which will be used to cache downloaded packages used to install games and apps"
|
inscription "A folder which will be used to cache downloaded packages used to install games and apps"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
para "<b>Diagnostics</b>"
|
if true # W3DHub.unix?
|
||||||
check_box "Enable Automatic Error Reporting", text_size: 16
|
para "<b>Wine</b>", margin_top: 32
|
||||||
inscription "If this is enabled the launcher will automatically report errors to the development team, along with basic information about your machine, such as operating system.", width: 1.0
|
flow(width: 1.0) do
|
||||||
|
para "<b>Wine Command</b>", width: 0.249
|
||||||
|
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 "<b>Wine Prefix</b>", width: 0.249
|
||||||
|
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."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
button "Save" do
|
||||||
|
old_language = Store.settings[:language]
|
||||||
|
Store.settings[:language] = language_code(@language_menu.value)
|
||||||
|
|
||||||
|
Store.settings[:app_install_dir] = @app_install_dir_input.value
|
||||||
|
Store.settings[:package_cache_dir_input] = @package_cache_dir_input.value
|
||||||
|
|
||||||
|
Store.settings[:wine_command] = @wine_command_input.value
|
||||||
|
Store.settings[:wine_prefix] = @wine_prefix_toggle.value
|
||||||
|
|
||||||
button "Save", margin_top: 32 do
|
|
||||||
Store.settings.save_settings
|
Store.settings.save_settings
|
||||||
|
|
||||||
|
begin
|
||||||
|
I18n.locale = Store.settings[:language]
|
||||||
|
rescue I18n::InvalidLocale
|
||||||
|
I18n.locale = :en
|
||||||
|
end
|
||||||
|
|
||||||
|
if old_language == Store.settings[:language]
|
||||||
|
page(Pages::Games)
|
||||||
|
else
|
||||||
|
# pop back to Boot state which will immediately push a new instance of Interface
|
||||||
|
pop_state
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def language_code(string)
|
||||||
|
case string.downcase.strip
|
||||||
|
when "german"
|
||||||
|
"de"
|
||||||
|
when "french"
|
||||||
|
"fr"
|
||||||
|
when "spanish"
|
||||||
|
"es"
|
||||||
|
else
|
||||||
|
"en"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def expand_language_code(string)
|
||||||
|
case string.downcase.strip
|
||||||
|
when "en"
|
||||||
|
"English"
|
||||||
|
when "de"
|
||||||
|
"German"
|
||||||
|
when "fr"
|
||||||
|
"French"
|
||||||
|
else
|
||||||
|
raise "Unknown language error"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -120,7 +120,12 @@ class W3DHub
|
|||||||
begin
|
begin
|
||||||
list = Api.server_list(2)
|
list = Api.server_list(2)
|
||||||
|
|
||||||
Store.server_list = list.sort_by! { |s| s&.status&.players&.size }.reverse if list
|
if list
|
||||||
|
Store.server_list = list.sort_by! { |s| s&.status&.players&.size }.reverse
|
||||||
|
end
|
||||||
|
|
||||||
|
Store.server_list_last_fetch = Gosu.milliseconds
|
||||||
|
|
||||||
@tasks[:server_list][:complete] = true
|
@tasks[:server_list][:complete] = true
|
||||||
rescue => e
|
rescue => e
|
||||||
# Something went wrong!
|
# Something went wrong!
|
||||||
|
|||||||
@@ -9,6 +9,12 @@ class W3DHub
|
|||||||
|
|
||||||
Store.settings.save_settings
|
Store.settings.save_settings
|
||||||
|
|
||||||
|
begin
|
||||||
|
I18n.locale = Store.settings[:language]
|
||||||
|
rescue I18n::InvalidLocale
|
||||||
|
I18n.locale = :en
|
||||||
|
end
|
||||||
|
|
||||||
push_state(W3DHub::States::Boot)
|
push_state(W3DHub::States::Boot)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ en:
|
|||||||
fetching_news: Fetching news...
|
fetching_news: Fetching news...
|
||||||
channel: Channel
|
channel: Channel
|
||||||
server_browser:
|
server_browser:
|
||||||
|
refresh: Refresh
|
||||||
join_server: Join Server
|
join_server: Join Server
|
||||||
game: Game
|
game: Game
|
||||||
map: Map
|
map: Map
|
||||||
|
|||||||
Reference in New Issue
Block a user