mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2025-12-16 09:12:35 +00:00
Initial support for offline mode
This commit is contained in:
@@ -259,6 +259,7 @@ class W3DHub
|
||||
installed_version = reg["InstalledVersion"] unless app_id == "ren"
|
||||
|
||||
application_data = {
|
||||
name: task.application.name, # FIXME!
|
||||
install_directory: install_path,
|
||||
installed_version: app_id == "ren" ? "1.0.0.0" : installed_version,
|
||||
install_path: exe_path,
|
||||
@@ -286,6 +287,7 @@ class W3DHub
|
||||
|
||||
def imported!(task, exe_path)
|
||||
application_data = {
|
||||
name: task.application.name,
|
||||
install_directory: File.dirname(exe_path),
|
||||
installed_version: task.channel.current_version,
|
||||
install_path: exe_path,
|
||||
@@ -305,6 +307,7 @@ class W3DHub
|
||||
|
||||
install_directory = Cache.install_path(task.application, task.channel)
|
||||
application_data = {
|
||||
name: task.application.name,
|
||||
install_directory: install_directory,
|
||||
installed_version: task.target_version,
|
||||
install_path: "#{install_directory}/game.exe",
|
||||
|
||||
@@ -5,12 +5,10 @@ class W3DHub
|
||||
@game_news ||= {}
|
||||
@game_events ||= {}
|
||||
|
||||
# unless Store.offline_mode
|
||||
@focused_game ||= Store.applications.games.find { |g| g.id == Store.settings[:last_selected_app] }
|
||||
@focused_game ||= Store.applications.games.find { |g| g.id == "ren" }
|
||||
@focused_channel ||= @focused_game.channels.find { |c| c.id == Store.settings[:last_selected_channel] }
|
||||
@focused_channel ||= @focused_game.channels.first
|
||||
# end
|
||||
@focused_game ||= Store.applications.games.find { |g| g.id == Store.settings[:last_selected_app] }
|
||||
@focused_game ||= Store.applications.games.find { |g| g.id == "ren" }
|
||||
@focused_channel ||= @focused_game.channels.find { |c| c.id == Store.settings[:last_selected_channel] }
|
||||
@focused_channel ||= @focused_game.channels.first
|
||||
|
||||
body.clear do
|
||||
stack(width: 1.0, height: 1.0) do
|
||||
@@ -174,10 +172,10 @@ class W3DHub
|
||||
|
||||
items << { label: I18n.t(:"games.game_settings"), block: proc { Store.application_manager.settings(game.id, channel.id) } }
|
||||
items << { label: I18n.t(:"games.wine_configuration"), block: proc { Store.application_manager.wine_configuration(game.id, channel.id) } } if W3DHub.unix?
|
||||
items << { label: I18n.t(:"games.game_modifications"), block: proc { populate_game_modifications(game, channel) } }
|
||||
items << { label: I18n.t(:"games.game_modifications"), block: proc { populate_game_modifications(game, channel) } } unless Store.offline_mode
|
||||
if game.id != "ren"
|
||||
items << { label: I18n.t(:"games.repair_installation"), block: proc { Store.application_manager.repair(game.id, channel.id) } }
|
||||
items << { label: I18n.t(:"games.uninstall_game"), block: proc { Store.application_manager.uninstall(game.id, channel.id) } }
|
||||
items << { label: I18n.t(:"games.repair_installation"), block: proc { Store.application_manager.repair(game.id, channel.id) } } unless Store.offline_mode
|
||||
items << { label: I18n.t(:"games.uninstall_game"), block: proc { Store.application_manager.uninstall(game.id, channel.id) } } unless Store.offline_mode
|
||||
end
|
||||
|
||||
# From gui_state_ext.rb
|
||||
@@ -225,6 +223,8 @@ class W3DHub
|
||||
end
|
||||
end
|
||||
|
||||
return if Store.offline_mode
|
||||
|
||||
unless Cache.net_lock?("game_news_#{game.id}")
|
||||
if @game_events[game.id]
|
||||
populate_game_events(game)
|
||||
|
||||
@@ -54,6 +54,8 @@ class W3DHub
|
||||
|
||||
@progressbar.value = @fraction
|
||||
|
||||
load_offline_applications_list if @offline_mode
|
||||
|
||||
push_state(States::Interface) if @offline_mode || (@progressbar.value >= 1.0 && @task_index == @tasks.size)
|
||||
|
||||
return if @offline_mode
|
||||
@@ -188,6 +190,42 @@ class W3DHub
|
||||
@tasks[:server_list][:complete] = true
|
||||
end
|
||||
end
|
||||
|
||||
def load_offline_applications_list
|
||||
hash = {
|
||||
applications: []
|
||||
}
|
||||
|
||||
Store.settings[:games].each do |key, game|
|
||||
app_id, channel_id = key.to_s.split("_")
|
||||
|
||||
app = hash[:applications].find { |a| a[:id] == app_id }
|
||||
app_in_array = !app.nil?
|
||||
app ||= {
|
||||
id: app_id,
|
||||
name: game[:name],
|
||||
type: "",
|
||||
category: "games",
|
||||
"studio-id": "",
|
||||
channels: [],
|
||||
"web-links": [],
|
||||
"extended-data": [{ name: "colour", value: "#353535" }]
|
||||
}
|
||||
|
||||
channel = {
|
||||
id: channel_id,
|
||||
name: channel_id,
|
||||
"user-level": "",
|
||||
"current-version": game[:installed_version]
|
||||
}
|
||||
|
||||
app[:channels] << channel
|
||||
|
||||
hash[:applications] << app unless app_in_array
|
||||
end
|
||||
|
||||
Store.applications = Api::Applications.new(hash.to_json)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -76,13 +76,23 @@ class W3DHub
|
||||
end
|
||||
|
||||
@account_container = flow(width: 256, height: 1.0) do
|
||||
stack(width: 1.0, height: 1.0) do
|
||||
tagline "<b>#{I18n.t(:"interface.not_logged_in")}</b>", text_wrap: :none
|
||||
if Store.offline_mode
|
||||
stack(width: 1.0, height: 1.0) do
|
||||
flow(fill: true)
|
||||
|
||||
flow(width: 1.0) do
|
||||
link(I18n.t(:"interface.log_in"), text_size: 16, width: 0.5) { page(W3DHub::Pages::Login) }
|
||||
link I18n.t(:"interface.register"), text_size: 16, width: 0.49 do
|
||||
Launchy.open("https://secure.w3dhub.com/forum/index.php?app=core&module=global§ion=register")
|
||||
title "<b>OFFLINE</b>", text_wrap: :none, width: 1.0, text_align: :center
|
||||
|
||||
flow(fill: true)
|
||||
end
|
||||
else
|
||||
stack(width: 1.0, height: 1.0) do
|
||||
tagline "<b>#{I18n.t(:"interface.not_logged_in")}</b>", text_wrap: :none
|
||||
|
||||
flow(width: 1.0) do
|
||||
link(I18n.t(:"interface.log_in"), text_size: 16, width: 0.5) { page(W3DHub::Pages::Login) }
|
||||
link I18n.t(:"interface.register"), text_size: 16, width: 0.49 do
|
||||
Launchy.open("https://secure.w3dhub.com/forum/index.php?app=core&module=global§ion=register")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user