mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2025-12-16 09:12:35 +00:00
Removed window as central storage, added Store class to be central memory store
This commit is contained in:
@@ -5,7 +5,7 @@ class W3DHub
|
||||
|
||||
def setup
|
||||
@download_package_info ||= {}
|
||||
@task = window.application_manager.current_task
|
||||
@task = Store.application_manager.current_task
|
||||
|
||||
return unless @task
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ class W3DHub
|
||||
class Games < Page
|
||||
def setup
|
||||
@game_news ||= {}
|
||||
@focused_game ||= window.applications.games.first
|
||||
@focused_game ||= Store.applications.games.first
|
||||
|
||||
body.clear do
|
||||
# Games List
|
||||
@@ -23,7 +23,7 @@ class W3DHub
|
||||
@games_list_container.clear do
|
||||
background 0xff_121920
|
||||
|
||||
window.applications.games.each do |game|
|
||||
Store.applications.games.each do |game|
|
||||
selected = game == @focused_game
|
||||
|
||||
game_button = stack(width: 1.0, border_thickness_left: 4,
|
||||
@@ -34,7 +34,7 @@ class W3DHub
|
||||
|
||||
flow(width: 1.0, height: 48) do
|
||||
stack(width: 0.3)
|
||||
image "#{GAME_ROOT_PATH}/media/icons/#{game.id}.png", height: 48, color: window.application_manager.installed?(game.id, game.channels.first.id) ? 0xff_ffffff : 0xee_444444
|
||||
image "#{GAME_ROOT_PATH}/media/icons/#{game.id}.png", height: 48, color: Store.application_manager.installed?(game.id, game.channels.first.id) ? 0xff_ffffff : 0xee_444444
|
||||
end
|
||||
inscription game.name, width: 1.0, text_align: :center
|
||||
end
|
||||
@@ -85,17 +85,17 @@ class W3DHub
|
||||
# end
|
||||
# end
|
||||
|
||||
if window.application_manager.installed?(game.id, channel.id)
|
||||
if Store.application_manager.installed?(game.id, channel.id)
|
||||
Hash.new.tap { |hash|
|
||||
hash[I18n.t(:"games.game_settings")] = { icon: "gear", block: proc { window.application_manager.settings(game.id, channel.id) } }
|
||||
hash[I18n.t(:"games.wine_configuration")] = { icon: "gear", block: proc { window.application_manager.wine_configuration(game.id, channel.id) } } if W3DHub.unix?
|
||||
hash[I18n.t(:"games.game_settings")] = { icon: "gear", block: proc { Store.application_manager.settings(game.id, channel.id) } }
|
||||
hash[I18n.t(:"games.wine_configuration")] = { icon: "gear", block: proc { Store.application_manager.wine_configuration(game.id, channel.id) } } if W3DHub.unix?
|
||||
if game.id != "ren"
|
||||
hash[I18n.t(:"games.repair_installation")] = { icon: "wrench", block: proc { window.application_manager.repair(game.id, channel.id) } }
|
||||
hash[I18n.t(:"games.uninstall_game")] = { icon: "trashCan", block: proc { window.application_manager.uninstall(game.id, channel.id) } }
|
||||
hash[I18n.t(:"games.repair_installation")] = { icon: "wrench", block: proc { Store.application_manager.repair(game.id, channel.id) } }
|
||||
hash[I18n.t(:"games.uninstall_game")] = { icon: "trashCan", block: proc { Store.application_manager.uninstall(game.id, channel.id) } }
|
||||
end
|
||||
hash[I18n.t(:"games.install_folder")] = { icon: nil, block: proc { window.application_manager.show_folder(game.id, channel.id, :installation) } }
|
||||
hash[I18n.t(:"games.user_data_folder")] = { icon: nil, block: proc { window.application_manager.show_folder(game.id, channel.id, :user_data) } }
|
||||
hash[I18n.t(:"games.view_screenshots")] = { icon: nil, block: proc { window.application_manager.show_folder(game.id, channel.id, :screenshots) } }
|
||||
hash[I18n.t(:"games.install_folder")] = { icon: nil, block: proc { Store.application_manager.show_folder(game.id, channel.id, :installation) } }
|
||||
hash[I18n.t(:"games.user_data_folder")] = { icon: nil, block: proc { Store.application_manager.show_folder(game.id, channel.id, :user_data) } }
|
||||
hash[I18n.t(:"games.view_screenshots")] = { icon: nil, block: proc { Store.application_manager.show_folder(game.id, channel.id, :screenshots) } }
|
||||
}.each do |key, hash|
|
||||
flow(width: 1.0, height: 22, margin_bottom: 8) do
|
||||
image "#{GAME_ROOT_PATH}/media/ui_icons/#{hash[:icon]}.png", width: 0.11 if hash[:icon]
|
||||
@@ -127,24 +127,24 @@ class W3DHub
|
||||
flow(width: 1.0, height: 0.08) do
|
||||
# background 0xff_551100
|
||||
|
||||
if window.application_manager.installed?(game.id, channel.id)
|
||||
if Store.application_manager.installed?(game.id, channel.id)
|
||||
button "<b>#{I18n.t(:"interface.play_now")}</b>", margin_left: 24 do
|
||||
window.application_manager.run(game.id, channel.id)
|
||||
Store.application_manager.run(game.id, channel.id)
|
||||
end
|
||||
|
||||
button "<b>#{I18n.t(:"interface.single_player")}</b>", margin_left: 24 do
|
||||
window.application_manager.run(game.id, channel.id)
|
||||
Store.application_manager.run(game.id, channel.id)
|
||||
end
|
||||
else
|
||||
unless game.id == "ren"
|
||||
button "<b>#{I18n.t(:"interface.install")}</b>", margin_left: 24, enabled: !window.application_manager.task?(:installer, game.id, channel.id) do |button|
|
||||
button "<b>#{I18n.t(:"interface.install")}</b>", margin_left: 24, enabled: !Store.application_manager.task?(:installer, game.id, channel.id) do |button|
|
||||
button.enabled = false
|
||||
window.application_manager.install(game.id, channel.id)
|
||||
Store.application_manager.install(game.id, channel.id)
|
||||
end
|
||||
end
|
||||
|
||||
button "<b>#{I18n.t(:"interface.import")}</b>", margin_left: 24, enabled: false do
|
||||
window.application_manager.import(game.id, channel.id, "?")
|
||||
Store.application_manager.import(game.id, channel.id, "?")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -40,9 +40,9 @@ class W3DHub
|
||||
account = Api.user_login(@username.value, @password.value)
|
||||
|
||||
if account
|
||||
window.account = account
|
||||
window.settings[:account][:refresh_token] = account.refresh_token
|
||||
window.settings.save_settings
|
||||
Store.account = account
|
||||
Store.settings[:account][:refresh_token] = account.refresh_token
|
||||
Store.settings.save_settings
|
||||
|
||||
Cache.fetch(account.avatar_uri)
|
||||
|
||||
@@ -67,7 +67,7 @@ class W3DHub
|
||||
end
|
||||
end
|
||||
|
||||
if window.account
|
||||
if Store.account
|
||||
populate_account_info
|
||||
page(W3DHub::Pages::Games)
|
||||
end
|
||||
@@ -77,23 +77,23 @@ class W3DHub
|
||||
@host.instance_variable_get(:"@account_container").clear do
|
||||
stack(width: 0.7, height: 1.0) do
|
||||
# background 0xff_222222
|
||||
tagline "<b>#{window.account.username}</b>"
|
||||
tagline "<b>#{Store.account.username}</b>"
|
||||
|
||||
flow(width: 1.0) do
|
||||
link(I18n.t(:"interface.log_out"), text_size: 16, width: 0.5) { depopulate_account_info }
|
||||
link I18n.t(:"interface.profile"), text_size: 16, width: 0.49 do
|
||||
Launchy.open("https://secure.w3dhub.com/forum/index.php?showuser=#{window.account.id}")
|
||||
Launchy.open("https://secure.w3dhub.com/forum/index.php?showuser=#{Store.account.id}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
image Cache.path(window.account.avatar_uri), height: 1.0
|
||||
image Cache.path(Store.account.avatar_uri), height: 1.0
|
||||
end
|
||||
end
|
||||
|
||||
def depopulate_account_info
|
||||
window.settings[:account][:refresh_token] = nil
|
||||
window.settings.save_settings
|
||||
Store.settings[:account][:refresh_token] = nil
|
||||
Store.settings.save_settings
|
||||
|
||||
@host.instance_variable_get(:"@account_container").clear do
|
||||
stack(width: 0.7, height: 1.0) do
|
||||
|
||||
@@ -8,7 +8,7 @@ class W3DHub
|
||||
@filters = {}
|
||||
@filter_region = "Any" # "Any", "North America", "Europe"
|
||||
|
||||
window.applications.games.each { |game| @filters[game.id] = true }
|
||||
Store.applications.games.each { |game| @filters[game.id] = true }
|
||||
|
||||
body.clear do
|
||||
stack(width: 1.0, height: 1.0, padding: 8) do
|
||||
@@ -19,7 +19,7 @@ class W3DHub
|
||||
flow(width: 1.0, height: 0.06) do
|
||||
flow(width: 0.75, height: 1.0) do
|
||||
@filters.each do |app_id, enabled|
|
||||
app = window.applications.games.find { |a| a.id == app_id }
|
||||
app = Store.applications.games.find { |a| a.id == app_id }
|
||||
|
||||
image "#{GAME_ROOT_PATH}/media/icons/#{app_id}.png", tip: "#{app.name}", height: 1.0,
|
||||
border_thickness_bottom: 1, border_color_bottom: 0x00_000000,
|
||||
@@ -48,14 +48,14 @@ class W3DHub
|
||||
|
||||
flow(width: 0.249, height: 1.0) do
|
||||
inscription "#{I18n.t(:"server_browser.nickname")}:", width: 0.32
|
||||
@nickname_label = inscription "#{window.settings[:server_list_username]}", width: 0.6
|
||||
@nickname_label = inscription "#{Store.settings[:server_list_username]}", width: 0.6
|
||||
image "#{GAME_ROOT_PATH}/media/ui_icons/wrench.png", height: 16, hover: { color: 0xaa_ffffff }, tip: I18n.t(:"server_browser.set_nickname") do
|
||||
# Prompt for player name
|
||||
prompt_for_nickname(
|
||||
accept_callback: proc do |entry|
|
||||
@nickname_label.value = entry
|
||||
window.settings[:server_list_username] = entry
|
||||
window.settings.save_settings
|
||||
Store.settings[:server_list_username] = entry
|
||||
Store.settings.save_settings
|
||||
end
|
||||
)
|
||||
end
|
||||
@@ -189,7 +189,7 @@ class W3DHub
|
||||
end
|
||||
|
||||
stack(width: 1.0, height: 0.25) do
|
||||
game_installed = window.application_manager.installed?(server.game, window.applications.games.find { |g| g.id == server.game }.channels.first.id)
|
||||
game_installed = Store.application_manager.installed?(server.game, Store.applications.games.find { |g| g.id == server.game }.channels.first.id)
|
||||
|
||||
button "<b>#{I18n.t(:"server_browser.join_server")}</b>", enabled: !game_installed.nil? do
|
||||
# Check for nickname
|
||||
@@ -198,12 +198,12 @@ class W3DHub
|
||||
# Check if password needed
|
||||
# prompt for password
|
||||
# Launch game
|
||||
if window.settings[:server_list_username].to_s.length.zero?
|
||||
if Store.settings[:server_list_username].to_s.length.zero?
|
||||
prompt_for_nickname(
|
||||
accept_callback: proc do |entry|
|
||||
@nickname_label.value = entry
|
||||
window.settings[:server_list_username] = entry
|
||||
window.settings.save_settings
|
||||
Store.settings[:server_list_username] = entry
|
||||
Store.settings.save_settings
|
||||
|
||||
if server.status.password
|
||||
prompt_for_password(
|
||||
@@ -315,7 +315,7 @@ class W3DHub
|
||||
end
|
||||
|
||||
def game_name(game)
|
||||
window.applications.games.detect { |g| g.id == game }&.name
|
||||
Store.applications.games.detect { |g| g.id == game }&.name
|
||||
end
|
||||
|
||||
def prompt_for_nickname(accept_callback: nil, cancel_callback: nil)
|
||||
@@ -323,7 +323,7 @@ class W3DHub
|
||||
W3DHub::States::PromptDialog,
|
||||
title: I18n.t(:"server_browser.set_nickname"),
|
||||
message: I18n.t(:"server_browser.set_nickname_message"),
|
||||
prefill: window.settings[:server_list_username],
|
||||
prefill: Store.settings[:server_list_username],
|
||||
accept_callback: accept_callback,
|
||||
cancel_callback: cancel_callback,
|
||||
valid_callback: proc { |entry| entry.length.positive? }
|
||||
@@ -346,11 +346,11 @@ class W3DHub
|
||||
if (
|
||||
(server.status.password && password.length.positive?) ||
|
||||
!server.status.password) &&
|
||||
window.settings[:server_list_username].to_s.length.positive?
|
||||
Store.settings[:server_list_username].to_s.length.positive?
|
||||
|
||||
window.application_manager.join_server(
|
||||
Store.application_manager.join_server(
|
||||
server.game,
|
||||
window.applications.games.find { |g| g.id == server.game }.channels.first.id, server, password
|
||||
Store.applications.games.find { |g| g.id == server.game }.channels.first.id, server, password
|
||||
)
|
||||
else
|
||||
window.push_state(W3DHub::States::MessageDialog, type: "?", title: "?", message: "?")
|
||||
|
||||
@@ -14,7 +14,7 @@ class W3DHub
|
||||
para "<b>App Install Folder</b>", width: 0.249
|
||||
|
||||
stack(width: 0.75, height: 1.0) do
|
||||
edit_line window.settings[:app_install_dir], width: 1.0
|
||||
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"
|
||||
end
|
||||
end
|
||||
@@ -23,7 +23,7 @@ class W3DHub
|
||||
para "<b>Package Cache Folder</b>", width: 0.249
|
||||
|
||||
stack(width: 0.75, height: 1.0) do
|
||||
edit_line window.settings[:package_cache_dir], width: 1.0
|
||||
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"
|
||||
end
|
||||
end
|
||||
@@ -34,7 +34,7 @@ class W3DHub
|
||||
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
|
||||
|
||||
button "Save", margin_top: 32 do
|
||||
window.settings.save_settings
|
||||
Store.settings.save_settings
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user