Initial support for offline mode

This commit is contained in:
2022-06-19 18:23:45 -05:00
parent 7e305cdec1
commit 8d0c27d6fc
4 changed files with 66 additions and 15 deletions

View File

@@ -259,6 +259,7 @@ class W3DHub
installed_version = reg["InstalledVersion"] unless app_id == "ren" installed_version = reg["InstalledVersion"] unless app_id == "ren"
application_data = { application_data = {
name: task.application.name, # FIXME!
install_directory: install_path, install_directory: install_path,
installed_version: app_id == "ren" ? "1.0.0.0" : installed_version, installed_version: app_id == "ren" ? "1.0.0.0" : installed_version,
install_path: exe_path, install_path: exe_path,
@@ -286,6 +287,7 @@ class W3DHub
def imported!(task, exe_path) def imported!(task, exe_path)
application_data = { application_data = {
name: task.application.name,
install_directory: File.dirname(exe_path), install_directory: File.dirname(exe_path),
installed_version: task.channel.current_version, installed_version: task.channel.current_version,
install_path: exe_path, install_path: exe_path,
@@ -305,6 +307,7 @@ class W3DHub
install_directory = Cache.install_path(task.application, task.channel) install_directory = Cache.install_path(task.application, task.channel)
application_data = { application_data = {
name: task.application.name,
install_directory: install_directory, install_directory: install_directory,
installed_version: task.target_version, installed_version: task.target_version,
install_path: "#{install_directory}/game.exe", install_path: "#{install_directory}/game.exe",

View File

@@ -5,12 +5,10 @@ class W3DHub
@game_news ||= {} @game_news ||= {}
@game_events ||= {} @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 == Store.settings[:last_selected_app] }
@focused_game ||= Store.applications.games.find { |g| g.id == "ren" } @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.find { |c| c.id == Store.settings[:last_selected_channel] }
@focused_channel ||= @focused_game.channels.first @focused_channel ||= @focused_game.channels.first
# end
body.clear do body.clear do
stack(width: 1.0, height: 1.0) 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.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.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" 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.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) } } items << { label: I18n.t(:"games.uninstall_game"), block: proc { Store.application_manager.uninstall(game.id, channel.id) } } unless Store.offline_mode
end end
# From gui_state_ext.rb # From gui_state_ext.rb
@@ -225,6 +223,8 @@ class W3DHub
end end
end end
return if Store.offline_mode
unless Cache.net_lock?("game_news_#{game.id}") unless Cache.net_lock?("game_news_#{game.id}")
if @game_events[game.id] if @game_events[game.id]
populate_game_events(game) populate_game_events(game)

View File

@@ -54,6 +54,8 @@ class W3DHub
@progressbar.value = @fraction @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) push_state(States::Interface) if @offline_mode || (@progressbar.value >= 1.0 && @task_index == @tasks.size)
return if @offline_mode return if @offline_mode
@@ -188,6 +190,42 @@ class W3DHub
@tasks[:server_list][:complete] = true @tasks[:server_list][:complete] = true
end end
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 end
end end

View File

@@ -76,6 +76,15 @@ class W3DHub
end end
@account_container = flow(width: 256, height: 1.0) do @account_container = flow(width: 256, height: 1.0) do
if Store.offline_mode
stack(width: 1.0, height: 1.0) do
flow(fill: true)
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 stack(width: 1.0, height: 1.0) do
tagline "<b>#{I18n.t(:"interface.not_logged_in")}</b>", text_wrap: :none tagline "<b>#{I18n.t(:"interface.not_logged_in")}</b>", text_wrap: :none
@@ -88,6 +97,7 @@ class W3DHub
end end
end end
end end
end
@content_container = flow(width: 1.0, fill: true) do @content_container = flow(width: 1.0, fill: true) do
end end